use of verdict.vdm.vdm_model.Port in project VERDICT by ge-high-assurance.
the class Aadl2Vdm method translateProcessTypeObjects.
// End of translateAbstractTypeObjects
/**
* Analyzing each processType:
* 1. Determine if it is a lower-level system or higher-level system
* 2. If lower-level, add to componentType list attribute of Model
* 2.1 Populate the port, contract, cyberRel, safetyRel, event, id, compCategory
* fields of componentType of the Model object
* 3. If higher-level, assign to Model
* 3.1 Populate the safetyReq
* cyberReq, mission fields of Model object
* @param processTypes
* @param m1
* @return
*/
public Model translateProcessTypeObjects(List<ProcessType> processTypes, Model m1, HashSet<String> dataTypeDecl) {
for (ProcessType prcsType : processTypes) {
// variables for unpacking prcsType
List<Event> events = new ArrayList<>();
List<CyberMission> missionReqs = new ArrayList<>();
List<CyberRel> cyberRels = new ArrayList<>();
List<SafetyRel> safetyRels = new ArrayList<>();
List<CyberReq> cyberReqs = new ArrayList<>();
List<SafetyReq> safetyReqs = new ArrayList<>();
// a flag to check if a higher -level component has already been found
boolean higher_flag = false;
// unpacking prcsType
for (AnnexSubclause annex : prcsType.getOwnedAnnexSubclauses()) {
if (annex.getName().equalsIgnoreCase("verdict")) {
Verdict verdictAnnex = VerdictUtil.getVerdict(annex);
for (Statement statement : verdictAnnex.getElements()) {
if (statement instanceof Event) {
events.add((Event) statement);
} else if (statement instanceof CyberMission) {
missionReqs.add((CyberMission) statement);
} else if (statement instanceof CyberReq) {
cyberReqs.add((CyberReq) statement);
} else if (statement instanceof CyberRel) {
cyberRels.add((CyberRel) statement);
} else if (statement instanceof SafetyReq) {
safetyReqs.add((SafetyReq) statement);
} else if (statement instanceof SafetyRel) {
safetyRels.add((SafetyRel) statement);
}
}
}
}
/**
* For every ProcessType,
* populate the id, name, compCateg, port, event,
* cyberRel, and safetyRel fields of componentType
* and add it to the list of componentType
* of the Model object
*/
if (true) {
// No Filter-- do for all System Types
// to pack the memType as a VDM component
verdict.vdm.vdm_model.ComponentType packComponent = new verdict.vdm.vdm_model.ComponentType();
// Note: Not populating "contract" for now
// ISSUE: There is no getId() function for memoryType
packComponent.setId(prcsType.getQualifiedName());
// populating "name"
packComponent.setName(prcsType.getName());
// populating "compCateg"
packComponent.setCompCateg(prcsType.getCategory().getName());
// ISSUE: no getOwnedBusAccesses
// get all data accesses and store them as ports
List<DataAccess> dataAccesses = prcsType.getOwnedDataAccesses();
// checking each dataAccess's details and adding it to the port list
for (DataAccess dataAccess : dataAccesses) {
String portName = dataAccess.getName();
String modeString = "in";
if (dataAccess.getKind() == AccessType.PROVIDES) {
modeString = "providesDataAccess";
} else if (dataAccess.getKind() == AccessType.REQUIRES) {
modeString = "requiresDataAccess";
}
verdict.vdm.vdm_model.Port newPort = createVdmPort(portName, modeString, dataAccess.getQualifiedName());
// Note: Not populating "type" for now
// ISSUE: "probe", "event", and "id" not found in DataPort class or superclass
// add to port list of component
packComponent.getPort().add(newPort);
}
// End of checking each dataAccess
// get all ports
List<DataPort> dataPorts = prcsType.getOwnedDataPorts();
// checking each port's mode and name and adding it to the port list
for (DataPort dataPort : dataPorts) {
verdict.vdm.vdm_model.Port newPort = createVdmPort(dataPort, m1, dataTypeDecl);
// Note: Not populating "type" for now
// ISSUE: "probe", "event", and "id" not found in DataPort class or superclass
// add to port list of component
packComponent.getPort().add(newPort);
}
// End of checking each port
// get all event data ports
List<EventDataPort> eventDataPorts = prcsType.getOwnedEventDataPorts();
for (EventDataPort eventDataPort : eventDataPorts) {
verdict.vdm.vdm_model.Port newPort = createVdmPort(eventDataPort, m1, dataTypeDecl);
// add to port list of component
packComponent.getPort().add(newPort);
}
// get all event ports
List<EventPort> eventPorts = prcsType.getOwnedEventPorts();
for (EventPort eventPort : eventPorts) {
verdict.vdm.vdm_model.Port newPort = createVdmEventPort(eventPort);
// add to port list of component
packComponent.getPort().add(newPort);
}
// packing all events and adding to component
for (Event anEvent : events) {
// To pack the event as a VDM event
verdict.vdm.vdm_model.Event packEvent = createVdmEvent(anEvent);
// adding to the list of component's events
packComponent.getEvent().add(packEvent);
}
// packing all cyberRels and adding to component
for (CyberRel aCyberRel : cyberRels) {
// To pack the cyberRel as a VDM event
verdict.vdm.vdm_model.CyberRel packCyberRel = createVdmCyberRel(aCyberRel);
// adding to the list of component's Cyber relations
packComponent.getCyberRel().add(packCyberRel);
}
// packing all safetyRels and adding to component
for (SafetyRel aSafetyRel : safetyRels) {
// To pack the safetyRel as a VDM event
verdict.vdm.vdm_model.SafetyRel packSafetyRel = createVdmSafetyRel(aSafetyRel);
// adding to the list of component's Safety relations
packComponent.getSafetyRel().add(packSafetyRel);
}
// End of packing all safetyRels
// adding to the list of componenmemTypes of the Model object
m1.getComponentType().add(packComponent);
}
/**
* If a high-level system
* populate the name, safetyReq, cyberReq, and mission
* for the model object
*/
if (!cyberReqs.isEmpty() || !safetyReqs.isEmpty() || !missionReqs.isEmpty()) {
// checking if a high-level system has already been found
if (higher_flag == false) {
higher_flag = true;
} else {
System.out.println("Warning: Multiple high-level systems detected!");
}
// populating name
m1.setName(prcsType.getName());
// packing all safetyReqs and adding to model
for (SafetyReq aSafetyReq : safetyReqs) {
// To pack the safettReq as a VDM event
verdict.vdm.vdm_model.SafetyReq packSafetyReq = createVdmSafetyReq(aSafetyReq, prcsType.getFullName());
// adding to the list of model's Safety requirements
m1.getSafetyReq().add(packSafetyReq);
}
// packing all cyberReqs and adding to model
for (CyberReq aCyberReq : cyberReqs) {
// To pack the safettReq as a VDM event
verdict.vdm.vdm_model.CyberReq packCyberReq = createVdmCyberReq(aCyberReq, prcsType.getFullName());
// adding to the list of model's Cyber requirements
m1.getCyberReq().add(packCyberReq);
}
// packing all missionReqs and adding to model
for (CyberMission aMission : missionReqs) {
// To pack the safettReq as a VDM event
verdict.vdm.vdm_model.Mission packMission = createVdmMission(aMission);
// adding to the list of model's Mission
m1.getMission().add(packMission);
}
// End of packing all missionReqs
}
// End of if a higher-level system
}
// returning the populated Model
return m1;
}
use of verdict.vdm.vdm_model.Port in project VERDICT by ge-high-assurance.
the class Aadl2Vdm method translateProcessorTypeObjects.
// End of translateVirtualProcessorTypeObjects
/**
* Analyzing each processorType:
* 1. Determine if it is a lower-level system or higher-level system
* 2. If lower-level, add to componentType list attribute of Model
* 2.1 Populate the port, contract, cyberRel, safetyRel, event, id, compCategory
* fields of componentType of the Model object
* 3. If higher-level, assign to Model
* 3.1 Populate the safetyReq
* cyberReq, mission fields of Model object
* @param processorTypes
* @param m1
* @return
*/
public Model translateProcessorTypeObjects(List<ProcessorType> processorTypes, Model m1, HashSet<String> dataTypeDecl) {
for (ProcessorType proType : processorTypes) {
// variables for unpacking proType
List<Event> events = new ArrayList<>();
List<CyberMission> missionReqs = new ArrayList<>();
List<CyberRel> cyberRels = new ArrayList<>();
List<SafetyRel> safetyRels = new ArrayList<>();
List<CyberReq> cyberReqs = new ArrayList<>();
List<SafetyReq> safetyReqs = new ArrayList<>();
// a flag to check if a higher -level component has already been found
boolean higher_flag = false;
// unpacking proType
for (AnnexSubclause annex : proType.getOwnedAnnexSubclauses()) {
if (annex.getName().equalsIgnoreCase("verdict")) {
Verdict verdictAnnex = VerdictUtil.getVerdict(annex);
for (Statement statement : verdictAnnex.getElements()) {
if (statement instanceof Event) {
events.add((Event) statement);
} else if (statement instanceof CyberMission) {
missionReqs.add((CyberMission) statement);
} else if (statement instanceof CyberReq) {
cyberReqs.add((CyberReq) statement);
} else if (statement instanceof CyberRel) {
cyberRels.add((CyberRel) statement);
} else if (statement instanceof SafetyReq) {
safetyReqs.add((SafetyReq) statement);
} else if (statement instanceof SafetyRel) {
safetyRels.add((SafetyRel) statement);
}
}
}
}
/**
* For every ProcessorType,
* populate the id, name, compCateg, port, event,
* cyberRel, and safetyRel fields of componentType
* and add it to the list of componentType
* of the Model object
*/
if (true) {
// No Filter-- do for all System Types
// to pack the memType as a VDM component
verdict.vdm.vdm_model.ComponentType packComponent = new verdict.vdm.vdm_model.ComponentType();
// Note: Not populating "contract" for now
// ISSUE: There is no getId() function for memoryType
packComponent.setId(proType.getQualifiedName());
// populating "name"
packComponent.setName(proType.getName());
// populating "compCateg"
packComponent.setCompCateg(proType.getCategory().getName());
// get all bus accesses and store them as ports
List<BusAccess> busAccesses = proType.getOwnedBusAccesses();
// checking each busAccess's details and adding it to the port list
for (BusAccess busAccess : busAccesses) {
String portName = busAccess.getName();
String modeString = "in";
if (busAccess.getKind() == AccessType.PROVIDES) {
modeString = "providesBusAccess";
} else if (busAccess.getKind() == AccessType.REQUIRES) {
modeString = "requiresBusAccess";
}
verdict.vdm.vdm_model.Port newPort = createVdmPort(portName, modeString, busAccess.getQualifiedName());
// Note: Not populating "type" for now
// ISSUE: "probe", "event", and "id" not found in DataPort class or superclass
// add to port list of component
packComponent.getPort().add(newPort);
}
// End of checking each busAccess
// ISSUE: no getOwnedDataAccess for processorType
// get all ports
List<DataPort> dataPorts = proType.getOwnedDataPorts();
// checking each port's mode and name and adding it to the port list
for (DataPort dataPort : dataPorts) {
verdict.vdm.vdm_model.Port newPort = createVdmPort(dataPort, m1, dataTypeDecl);
// ISSUE: "probe", "event", and "id" not found in DataPort class or superclass
// add to port list of component
packComponent.getPort().add(newPort);
}
// End of checking each port
// get all event data ports
List<EventDataPort> eventDataPorts = proType.getOwnedEventDataPorts();
for (EventDataPort eventDataPort : eventDataPorts) {
verdict.vdm.vdm_model.Port newPort = createVdmPort(eventDataPort, m1, dataTypeDecl);
// add to port list of component
packComponent.getPort().add(newPort);
}
// get all event ports
List<EventPort> eventPorts = proType.getOwnedEventPorts();
for (EventPort eventPort : eventPorts) {
verdict.vdm.vdm_model.Port newPort = createVdmEventPort(eventPort);
// add to port list of component
packComponent.getPort().add(newPort);
}
// packing all events and adding to component
for (Event anEvent : events) {
// To pack the event as a VDM event
verdict.vdm.vdm_model.Event packEvent = createVdmEvent(anEvent);
// adding to the list of component's events
packComponent.getEvent().add(packEvent);
}
// packing all cyberRels and adding to component
for (CyberRel aCyberRel : cyberRels) {
// To pack the cyberRel as a VDM event
verdict.vdm.vdm_model.CyberRel packCyberRel = createVdmCyberRel(aCyberRel);
// adding to the list of component's Cyber relations
packComponent.getCyberRel().add(packCyberRel);
}
// packing all safetyRels and adding to component
for (SafetyRel aSafetyRel : safetyRels) {
// To pack the safetyRel as a VDM event
verdict.vdm.vdm_model.SafetyRel packSafetyRel = createVdmSafetyRel(aSafetyRel);
// adding to the list of component's Safety relations
packComponent.getSafetyRel().add(packSafetyRel);
}
// End of packing all safetyRels
// adding to the list of componenmemTypes of the Model object
m1.getComponentType().add(packComponent);
}
/**
* If a high-level system
* populate the name, safetyReq, cyberReq, and mission
* for the model object
*/
if (!cyberReqs.isEmpty() || !safetyReqs.isEmpty() || !missionReqs.isEmpty()) {
// checking if a high-level system has already been found
if (higher_flag == false) {
higher_flag = true;
} else {
System.out.println("Warning: Multiple high-level systems detected!");
}
// populating name
m1.setName(proType.getName());
// packing all safetyReqs and adding to model
for (SafetyReq aSafetyReq : safetyReqs) {
// To pack the safettReq as a VDM event
verdict.vdm.vdm_model.SafetyReq packSafetyReq = createVdmSafetyReq(aSafetyReq, proType.getFullName());
// adding to the list of model's Safety requirements
m1.getSafetyReq().add(packSafetyReq);
}
// packing all cyberReqs and adding to model
for (CyberReq aCyberReq : cyberReqs) {
// To pack the safettReq as a VDM event
verdict.vdm.vdm_model.CyberReq packCyberReq = createVdmCyberReq(aCyberReq, proType.getFullName());
// adding to the list of model's Cyber requirements
m1.getCyberReq().add(packCyberReq);
}
// packing all missionReqs and adding to model
for (CyberMission aMission : missionReqs) {
// To pack the safettReq as a VDM event
verdict.vdm.vdm_model.Mission packMission = createVdmMission(aMission);
// adding to the list of model's Mission
m1.getMission().add(packMission);
}
// End of packing all missionReqs
}
// End of if a higher-level system
}
// returning the populated Model
return m1;
}
use of verdict.vdm.vdm_model.Port in project VERDICT by ge-high-assurance.
the class Aadl2Vdm method createVdmPort.
/**
* @author Vidhya Tekken Valapil
* Creates a new Vdm Port object and returns
* Populates "name", "mode" and "type"
* @param eventdataport
* @return vdm port
*/
private Port createVdmPort(EventDataPort dataPort, Model model, HashSet<String> dataTypeDecl) {
String modeString = "in";
if (dataPort.isIn()) {
modeString = "in";
} else if (dataPort.isOut()) {
modeString = "out";
}
// fetching data type information
DataSubcomponentType dSubCompType = dataPort.getDataFeatureClassifier();
verdict.vdm.vdm_model.Port newPort = new verdict.vdm.vdm_model.Port();
if (dSubCompType != null) {
verdict.vdm.vdm_data.DataType dtype = new verdict.vdm.vdm_data.DataType();
if (dSubCompType instanceof DataTypeImpl) {
org.osate.aadl2.DataType aadlDType = (org.osate.aadl2.DataType) dSubCompType;
dtype = resolveAADLDataType(aadlDType, model, dataTypeDecl);
} else if (dSubCompType instanceof DataImplementationImpl) {
org.osate.aadl2.DataImplementation aadlDImpl = (org.osate.aadl2.DataImplementation) dSubCompType;
dtype = resolveAADLDataImplementationType(aadlDImpl, model, dataTypeDecl);
} else {
System.out.println("Unresolved/unexpected Named Element.");
}
newPort.setType(dtype);
}
newPort.setProbe(false);
newPort.setId(dataPort.getQualifiedName());
newPort.setName(dataPort.getName());
newPort.setMode(convertToVdmPortMode(modeString));
newPort.setEvent(true);
return newPort;
}
use of verdict.vdm.vdm_model.Port in project VERDICT by ge-high-assurance.
the class VDMInstrumentor method isProbePort.
protected boolean isProbePort(Connection con) {
if (con != null) {
ConnectionEnd dest_con = con.getDestination();
Port dstPort = dest_con.getComponentPort();
if (dstPort == null) {
CompInstancePort instancePort = dest_con.getSubcomponentPort();
dstPort = instancePort.getPort();
}
if (dstPort.isProbe()) {
return true;
}
}
return false;
}
use of verdict.vdm.vdm_model.Port in project VERDICT by ge-high-assurance.
the class VDMInstrumentor method instrument_link.
// public void instrument_link(Connection connection) {
// // Connection Source
// ConnectionEnd src = connection.getSource();
//
// // Connection Destination
// ConnectionEnd dest = connection.getDestination();
//
// // Source Component
// Port src_port = src.getComponentPort();
// // Destination Component
// Port dest_port = dest.getComponentPort();
//
// if (src_port == null && dest_port == null) {
// // Both are sub-compon
// System.out.println("Both are subcomponents.");
// }
// if (src_port == null && dest_port != null) {
// // Only one is Subcomponent
// System.out.println(dest_port.getId() + " -- " + dest_port.getName());
// }
// if (src_port != null && dest_port == null) {
// // One Subcomponent
// System.out.println(src_port.getId() + " -- " + src_port.getName());
// }
// }
// public void create_link(Connection old_channel, ComponentInstance
// src_componentInstance,
// ComponentInstance dest_componentInstance) {
//
// ComponentInstance instrumented_componentInstance = new ComponentInstance();
//
// String component_ID = src_componentInstance.getName() + "_Inst_" +
// dest_componentInstance.getName();
// instrumented_componentInstance.setId(component_ID + "_Instance");
// instrumented_componentInstance.setName(component_ID);
//
// instrumented_componentInstance.setSpecification(value);
// instrumented_componentInstance.setImplementation(value);
//
// ComponentType instrumented_component = new ComponentType();
// instrumented_component.setId(component_ID);
// instrumented_component.setName(component_ID);
//
//
//
// Connection inst_channel = new Connection();
//
// //Update Old connection Destination
// old_channel.setDestination(value);
//
// //Add New Connection Source
// inst_channel.setSource(value);
// //Add New Connection Destination
// inst_channel.setDestination(value);
//
//
// }
public String instrument_link(String compID, Connection connection, BlockImpl blockImpl) {
// instrument_link(connection);
// System.out.println("Instrumented Link ***" + connection.getName());
// Default Block Implementation
ComponentImpl compImpl = null;
if (compID != null) {
compImpl = retrieve_cmp_impl(compID);
}
// Connections without Components Instrumentation.
if (compImpl == null) {
compImpl = retrieve_main_cmp_impl();
}
ComponentType instrumented_cmp = new ComponentType();
// R.H.S
ConnectionEnd src = connection.getSource();
ComponentInstance src_componentInstance = new ComponentInstance();
// Source Connection
Port src_port = src.getComponentPort();
if (src_port != null) {
String identifier = compImpl.getId();
// identifier = identifier.replace(".I", "_I");
identifier = identifier.replace(".", "_dot_");
identifier = identifier.replace("::", "_double_colon_");
src_componentInstance.setId(identifier);
src_componentInstance.setName(identifier);
src_componentInstance.setImplementation(compImpl);
}
// if (src_port == instrumented_port) {
CompInstancePort compInstancePort = src.getSubcomponentPort();
if (compInstancePort != null) {
src_componentInstance = compInstancePort.getSubcomponent();
src_port = compInstancePort.getPort();
}
// R.H.S
ConnectionEnd dest = connection.getDestination();
ComponentInstance dest_componentInstance = new ComponentInstance();
// Source Connection
Port dest_port = dest.getComponentPort();
if (dest_port != null) {
String identifier = compImpl.getId();
// identifier = identifier.replace(".I", "_I");
identifier = identifier.replace(".", "_dot_");
identifier = identifier.replace("::", "_double_colon_");
dest_componentInstance.setId(identifier);
dest_componentInstance.setName(identifier);
dest_componentInstance.setImplementation(compImpl);
}
// if (dest_port == instrumented_port) {
compInstancePort = dest.getSubcomponentPort();
if (compInstancePort != null) {
dest_componentInstance = compInstancePort.getSubcomponent();
dest_port = compInstancePort.getPort();
}
String instrument_cmp_Id = src_componentInstance.getName() + "_Inst_" + dest_componentInstance.getName() + "_port_" + dest_port.getName();
instrument_cmp_Id = instrument_cmp_Id.replace(".", "_dot_");
// Setting Component IDs
instrumented_cmp.setId(instrument_cmp_Id);
instrumented_cmp.setName(instrument_cmp_Id);
// output port
Port instrumented_port_dest = new Port();
instrumented_port_dest.setId(dest_port.getId());
instrumented_port_dest.setName(dest_port.getName());
instrumented_port_dest.setMode(dest_port.getMode());
instrumented_port_dest.setType(dest_port.getType());
if (dest_port.isEvent() != null && dest_port.isEvent()) {
instrumented_port_dest.setEvent(true);
} else {
instrumented_port_dest.setEvent(false);
}
instrumented_cmp.getPort().add(instrumented_port_dest);
// Input port
Port instrumented_port_src = new Port();
instrumented_port_src.setId(src_port.getId());
instrumented_port_src.setName(src_componentInstance + "_port_" + src_port.getName());
instrumented_port_src.setMode(src_port.getMode());
if (src_port.isEvent() != null && src_port.isEvent()) {
instrumented_port_src.setEvent(true);
} else {
instrumented_port_src.setEvent(false);
}
String global_constant_Id = src_componentInstance.getName();
if (instrumented_port_src.getMode() == instrumented_port_dest.getMode()) {
instrumented_port_src.setName(src_port.getName());
if (instrumented_port_src.getMode() == PortMode.IN) {
instrumented_port_src.setMode(PortMode.OUT);
} else {
instrumented_port_dest.setMode(PortMode.IN);
}
} else {
instrumented_port_src.setName(src_port.getName());
}
if (dest_port.getMode() == PortMode.OUT) {
global_constant_Id += "_port_" + dest_port.getName() + "_instrumented";
} else {
global_constant_Id += "_port_" + src_port.getName() + "_instrumented";
}
instrumented_port_src.setType(dest_port.getType());
instrumented_cmp.getPort().add(instrumented_port_src);
vdm_model.getComponentType().add(instrumented_cmp);
// Modify connection.
ConnectionEnd con_end_inst = new ConnectionEnd();
// instrumentd_port.setPort(value);
ComponentInstance instrumented_compInstance = new ComponentInstance();
instrumented_compInstance.setId(connection.getName());
instrumented_compInstance.setName(connection.getName());
instrumented_compInstance.setSpecification(instrumented_cmp);
// -----------------------------------------
// Adding Auxiliary Node.
NodeCall nodeCall = new NodeCall();
nodeCall.setNodeId(instrumented_cmp.getId());
Expression callExpr = new Expression();
callExpr.setCall(nodeCall);
ContractItem true_guarantee_item = new ContractItem();
// true_guarantee_item.setName("true");
Expression true_expr = new Expression();
Boolean true_lit = Boolean.TRUE;
true_expr.setBoolLiteral(true_lit);
true_guarantee_item.setExpression(true_expr);
ContractSpec contractSpec = new ContractSpec();
contractSpec.getGuarantee().add(true_guarantee_item);
// ---------------------------------------------
ComponentImpl instrument_compImpl = new ComponentImpl();
instrument_compImpl.setId(instrumented_cmp.getId() + "_dot_impl");
instrument_compImpl.setName(instrumented_cmp.getName() + "_dot_Impl");
instrument_compImpl.setType(instrumented_cmp);
IfThenElse ifelse = new IfThenElse();
// Condition
Expression cond_expr = new Expression();
global_constant_Id = global_constant_Id.replace(".", "_dot_");
cond_expr.setIdentifier(global_constant_Id);
ifelse.setCondition(cond_expr);
// Then
Expression then_arg = new Expression();
then_arg.setIdentifier(dest_port.getName());
ifelse.setThenBranch(callExpr);
// Else
Expression else_arg = new Expression();
else_arg.setIdentifier(dest_port.getName());
nodeCall.getArgument().add(else_arg);
ifelse.setElseBranch(then_arg);
Expression instrumented_expr = new Expression();
instrumented_expr.setConditionalExpression(ifelse);
NodeEquation n_eq = new NodeEquation();
NodeEquationLHS neq_lhs = new NodeEquationLHS();
neq_lhs.getIdentifier().add(src_port.getName() + "_instrumented");
n_eq.setLhs(neq_lhs);
n_eq.setRhs(instrumented_expr);
NodeBody nodeBody = new NodeBody();
// VariableDeclaration cond_var = new VariableDeclaration();
// cond_var.setName(gloabal_constant_Id);
// DataType dataType = new DataType();
// dataType.setPlainType(PlainType.BOOL);
// cond_var.setDataType(dataType);
// nodeBody.getVariableDeclaration().add(cond_var);
nodeBody.setIsMain(false);
nodeBody.getEquation().add(n_eq);
instrument_compImpl.setDataflowImpl(nodeBody);
instrumented_compInstance.setImplementation(instrument_compImpl);
vdm_model.getComponentImpl().add(instrument_compImpl);
vdm_model.getComponentType().add(instrumented_cmp);
// -----------------------------------------
CompInstancePort compInstance_inst_port = new CompInstancePort();
compInstance_inst_port.setPort(dest_port);
compInstance_inst_port.setSubcomponent(instrumented_compInstance);
con_end_inst.setSubcomponentPort(compInstance_inst_port);
blockImpl.getSubcomponent().add(instrumented_compInstance);
connection.setDestination(con_end_inst);
Connection new_con = new Connection();
// Copying connection related artifacts
new_con.setName(connection.getName() + "_instrumented_channel");
// new_con.setConnType(connection.getConnType());
// new_con.setFlowType(connection.getFlowType());
//
// new_con.setDataEncrypted(connection.isEncryptedTransmission());
// new_con.setAuthenticated(connection.isAuthenticated());
new_con.setSource(con_end_inst);
compInstance_inst_port.setPort(src_port);
new_con.setDestination(dest);
blockImpl.getConnection().add(new_con);
return global_constant_Id;
}
Aggregations