diff --git a/src/main/java/avatartranslator/tosysmlv2/Avatar2SysML.java b/src/main/java/avatartranslator/tosysmlv2/Avatar2SysML.java index 4a6f68c4b2f3177aa453835a6695a8363dfdf6e6..5f40787dcce6e5b79b3b78d739fe2972e3f4a021 100644 --- a/src/main/java/avatartranslator/tosysmlv2/Avatar2SysML.java +++ b/src/main/java/avatartranslator/tosysmlv2/Avatar2SysML.java @@ -249,35 +249,39 @@ public class Avatar2SysML { // computine parameters depending on relation type ============== // if (ar.isAMS()) throw exception - + String blk1 = ar.getBlock1().getName(); + String blk2 = ar.getBlock2().getName(); + String blk1SysMLname = blockSysMLname(blk1); + String blk2SysMLname = blockSysMLname(blk2); + relationParameters = "(block1 = " + blk1SysMLname + ", block2 = " + blk2SysMLname; if (! ar.isAsynchronous()) { // sync relation relationType = SYNC; relationNumber = syncrelNumber++; relationConstructor = "'#Sync_Rel'"; channelConstructor = "'#Sync'"; - if(ar.isPrivate()) relationParameters = "('private'=true)"; + if(ar.isPrivate()) relationParameters += ", 'private'=true)"; } else { // fifo relation if(ar.isPrivate()) // default: false if(ar.isLossy()) // default: false if(ar.getSizeOfFIFO() > 1) // default size: 1 - relationParameters= "('private'=true, lossy=true, max_size=" + ar.getSizeOfFIFO() + ")"; + relationParameters += ", 'private'=true, lossy=true, max_size=" + ar.getSizeOfFIFO() + ")"; else - relationParameters= "('private'=true, lossy=true)"; + relationParameters += ", 'private'=true, lossy=true)"; else if(ar.getSizeOfFIFO() > 1) // default size: 1 - relationParameters= "('private'=true, max_size=" + ar.getSizeOfFIFO() + ")"; + relationParameters += ", 'private'=true, max_size=" + ar.getSizeOfFIFO() + ")"; else - relationParameters= "('private'=true)"; + relationParameters += ", 'private'=true)"; else if(ar.isLossy()) // default: false if(ar.getSizeOfFIFO() > 1) // default size: 1 - relationParameters= "(lossy=true, max_size=" + ar.getSizeOfFIFO() + ")"; + relationParameters += ", lossy=true, max_size=" + ar.getSizeOfFIFO() + ")"; else - relationParameters= "(lossy=true)"; + relationParameters += ", lossy=true)"; else if(ar.getSizeOfFIFO() > 1) // default size: 1 - relationParameters= "(max_size=" + ar.getSizeOfFIFO() + ")"; + relationParameters += ", max_size=" + ar.getSizeOfFIFO() + ")"; if (ar.isBlocking()) { // blocking fifo relation relationType = BFIFO; @@ -295,8 +299,6 @@ public class Avatar2SysML { // general type-independent generation ============== - String blk1 = ar.getBlock1().getName(); - String blk2 = ar.getBlock2().getName(); String relationSYSMLname = relationSysMLname(blk1, blk2, relationType, relationNumber); // relation declaration -------------------- @@ -313,13 +315,11 @@ public class Avatar2SysML { for(int i=0; i<relationSize; i++) { AvatarSignal sig1 = ar.getSignals1().get(i); AvatarSignal sig2 = ar.getSignals2().get(i); - boolean in2out = (sig1.getInOut() == AvatarSignal.OUT); + boolean in2out = (sig1.getInOut() == AvatarSignal.IN); // to remove String channelName = channelName(blk1, blk2, sig1.getName(), sig2.getName(), in2out); - String blk1SysMLname = blockSysMLname(blk1); - String blk2SysMLname = blockSysMLname(blk2); String channelSYSMLname = channelSysMLname(channelName(blk1, blk2, sig1.getName(), sig2.getName(), in2out), relationType); String sig1SYSMLname = signalSysMLname(sig1.getName()); String sig2SYSMLname = signalSysMLname(sig2.getName()); @@ -330,21 +330,31 @@ public class Avatar2SysML { // Channel declaration ......................... - avsysml.append("\n" + indent + "// Channel " + channelName + "-------------\n"); + avsysml.append("\n" + indent + "// Channel " + channelSYSMLname + "-------------\n"); avsysml.append(indent + "part " + channelSYSMLname + " : " + channelConstructor + " = " + channelConstructor + "(relation = " + relationSYSMLname + ");\n"); - avsysml.append(indent + "bind " + blk1SysMLname + "." + sig1SYSMLname + " = " + channelSYSMLname + ";\n"); - avsysml.append(indent + "bind " + blk2SysMLname + "." + sig2SYSMLname + " = " + channelSYSMLname + ";\n"); - + if (in2out) { + avsysml.append(indent + "bind " + blk1SysMLname + "." + sig1SYSMLname + " = " + channelSYSMLname + "{ attribute isIn : " + + "Boolean = true; }\n"); + avsysml.append(indent + "bind " + blk2SysMLname + "." + sig2SYSMLname + " = " + channelSYSMLname + "{ attribute isIn : " + + "Boolean = false; }\n"); + } else { + avsysml.append(indent + "bind " + blk1SysMLname + "." + sig1SYSMLname + " = " + channelSYSMLname + "{ attribute isIn : " + + "Boolean = false; }\n"); + avsysml.append(indent + "bind " + blk2SysMLname + "." + sig2SYSMLname + " = " + channelSYSMLname + "{ attribute isIn : " + + "Boolean = true; }\n"); + } // Message declaration ......................... StringBuffer msg1Buf = new StringBuffer(indent + "\n// Message of signal " + blk1SysMLname + "." + sig1SYSMLname + "............\n"); StringBuffer msg2Buf = new StringBuffer(indent + "\n// Message of signal " + blk2SysMLname + sig2SYSMLname + "............\n"); if (in2out) { - msg1Buf.append(indent + "part def " + message2SYSMLname + " :> '#DataMessage' {\n"); + msg1Buf.append(indent + "part def " + message2SYSMLname + " :> '#DataMessage' {\n" + + indent + indentStep + "private part '@channel' : '#Channel' = " + channelSYSMLname + ";\n"); msg2Buf.append(indent + "part def " + message1SYSMLname + " :> " + message2SYSMLname + "{\n"); } else { - msg1Buf.append(indent + "part def " + message1SYSMLname + " :> '#DataMessage' {\n"); + msg1Buf.append(indent + "part def " + message1SYSMLname + " :> '#DataMessage' {\n" + + indent + indentStep + "private part '@channel' : '#Channel' = " + channelSYSMLname + ";\n"); msg2Buf.append(indent + "part def " + message2SYSMLname + " :> " + message1SYSMLname + "{\n"); } indent += indentStep; diff --git a/src/main/java/avatartranslator/tosysmlv2/Avatar2SysMLNames.java b/src/main/java/avatartranslator/tosysmlv2/Avatar2SysMLNames.java index 119af82d5de1b458ff674a4ef96f2c972b21948f..2921120b8b9fdd9cb617a8320cbf585e5ad3c744 100644 --- a/src/main/java/avatartranslator/tosysmlv2/Avatar2SysMLNames.java +++ b/src/main/java/avatartranslator/tosysmlv2/Avatar2SysMLNames.java @@ -103,7 +103,7 @@ public class Avatar2SysMLNames { public static String preresetTimerStateSysMLname(String timerName, int number){ return "'@st:prereset." + timerName.trim() + "." + number + "'"; } public static String preexpireTimerStateSysMLname(String timerName, int number){ return "'@st:preexpire." + timerName.trim() + "." + number + "'"; } public static String timerBlockSysMLname(String timerName){ return "'@tmr:" + timerName.trim() + "'"; } - public static String timerRelationSysMLname(String timerName){ return "'TMRRel:" + timerName.trim() + "'"; } + public static String timerRelationSysMLname(String timerName){ return "'@TMRRel:" + timerName.trim() + "'"; } public static String setTimerChannelSysMLname(String timerName){ return "'@ch:set." + timerName.trim() + "'"; } public static String resetTimerChannelSysMLname(String timerName){ return "'@ch:reset." + timerName.trim() + "'"; } public static String expireTimerChannelSysMLname(String timerName){ return "'@ch:expire." + timerName.trim() + "'"; }