diff --git a/src/main/java/avatartranslator/AvatarSpecification.java b/src/main/java/avatartranslator/AvatarSpecification.java index 023a0953698cb21531c88c90fcee3435e43f061d..06f28f937056e6e6af4ebe2a7b39a37d919aa44e 100644 --- a/src/main/java/avatartranslator/AvatarSpecification.java +++ b/src/main/java/avatartranslator/AvatarSpecification.java @@ -39,6 +39,7 @@ package avatartranslator; import avatartranslator.intboolsolver.AvatarIBSolver; +import avatartranslator.tosysmlv2.AvatarFromSysML; import myutil.Conversion; import myutil.NameChecker; import myutil.TraceManager; @@ -1696,8 +1697,8 @@ public class AvatarSpecification extends AvatarElement implements IBSParamSpec { // SysML V2 public static AvatarSpecification makeFromSysMLV2(String pathToFile) { - AvatarSpecification as = new AvatarSpecification(pathToFile, null); - return as; + AvatarFromSysML builder = new AvatarFromSysML(); + return builder.sysMLtoSpec(pathToFile); } } diff --git a/src/main/java/avatartranslator/tosysmlv2/Avatar2SysML.java b/src/main/java/avatartranslator/tosysmlv2/Avatar2SysML.java index 984b109c032643c51ea96520d4f3b16841f0bf8e..c37b5e5a40d220bf94ef86fd878cac558c5c0730 100644 --- a/src/main/java/avatartranslator/tosysmlv2/Avatar2SysML.java +++ b/src/main/java/avatartranslator/tosysmlv2/Avatar2SysML.java @@ -190,8 +190,8 @@ public class Avatar2SysML { blocks2SysML(); avsysml.append(blockLinks); avsysml.append("}\n"); - AvatarFromSysML parser = new AvatarFromSysML(); - parser.sysMLtoSpec(avsysml.toString()); /// !!!!!!!!!!!!!! TESTEUR + //AvatarFromSysML parser = new AvatarFromSysML(); + //parser.sysMLtoSpec(avsysml.toString()); /// !!!!!!!!!!!!!! TESTEUR return avsysml; } String removeFieldName(String fullName, AvatarDataType dt) { diff --git a/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysML.java b/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysML.java index 57a36469d310e7c1ce2253c40e6456769d3ff59e..e9afbbe130618c129878a0c253d8ec7b40d0898c 100644 --- a/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysML.java +++ b/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysML.java @@ -37,6 +37,7 @@ */ package avatartranslator.tosysmlv2; +import java.io.FileReader; import java.io.StringReader; import java.util.ArrayList; import java.util.HashMap; @@ -70,14 +71,19 @@ public class AvatarFromSysML { errors.add(_err); out.println(_err.toString()); } - public void sysMLtoSpec(String _txt) { - AvatarFromSysMLParser parser = - new AvatarFromSysMLParser(new AvatarFromSysMLLexer(new StringReader(_txt)), - new ComplexSymbolFactory()); + public AvatarSpecification sysMLtoSpec(String _fileName) { + AvatarFromSysMLParser parser; + try { parser = + new AvatarFromSysMLParser(new AvatarFromSysMLLexer(new FileReader(_fileName)), + new ComplexSymbolFactory()); } + catch (java.lang.Exception e) { + e.printStackTrace(out); + return new AvatarSpecification("DummySpec", null); + } try { stxSpec = parser.parseModel(); } catch (java.lang.Exception e) { e.printStackTrace(out); - return; + return new AvatarSpecification("DummySpec", null); } errors = stxSpec.getErrors(); avSpec = new AvatarSpecification("FromSysMLV2_EXAMPLE_SPECIFICATION",null); @@ -88,6 +94,7 @@ public class AvatarFromSysML { buildDataTypes(); buildBlocks(); buildRelations(); + return avSpec; } private AvatarBlock getBlock(StxBlock _b) { @@ -199,6 +206,7 @@ public class AvatarFromSysML { // set father StxBlock fth = blk.getFather(); if (fth != null) theBlock.setFather(blockMap.get(fth)); + // add Attributes int size = blk.getNbAttributes(); for (int i = 0; i < size; i++) { @@ -540,6 +548,8 @@ public class AvatarFromSysML { for (int i = 0; i < size; i++) { StxChannel c = r.getChannel(i); c.commuteSignals(r.getBlock1().getName()); + System.out.println("$$$$$$$$$ : " +blk1.getName() + "." + c.getSignalA().getName() + ", " + + blk2.getName() + "." + c.getSignalB().getName()); theRelation.addSignals(getSignal(c.getSignalA()),getSignal(c.getSignalB())); } } diff --git a/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysMLSyntax.java b/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysMLSyntax.java index d03c574bf5f585b37ed380c184e5c1ff2373d287..eb881f5a42a30d77f8a4ba5cc706f15544c0d346 100644 --- a/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysMLSyntax.java +++ b/src/main/java/avatartranslator/tosysmlv2/AvatarFromSysMLSyntax.java @@ -395,6 +395,7 @@ public class AvatarFromSysMLSyntax { else if (signalB == null) { blockB = _block; signalB = s; } } public void commuteSignals(String _block1) { + System.out.println("%%%%%%%%%% " + blockA + "." + signalA.getName() + " " + blockB + "." + signalB.getName()); boolean permut = (blockB != null && blockB.equals(_block1)) ||(blockA != null && ! blockB.equals(_block1)); if (permut) { @@ -405,6 +406,7 @@ public class AvatarFromSysMLSyntax { blockB = auxStr; signalB = auxSig; } + System.out.println("????????????? " + blockA + "." + signalA.getName() + " " + blockB + "." + signalB.getName()); } public void setSignalA(StxSignal s) { signalA = s; } public void setSignalB(StxSignal s) { signalB = s; } @@ -543,8 +545,8 @@ public class AvatarFromSysMLSyntax { signal = null; sendPayload = null; receivePayload = null; - minDelay = null; - maxDelay = null; + minDelay = ""; + maxDelay = ""; delayDistributionLaw = null; delayExtra = null; target = null;