Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

for test with Kevoree generator

  • Loading branch information...
commit 53ca8a5bad5d8aa329efca4ce8c09adf5b180bef 1 parent 2865d75
Runze Hao authored
10 org.thingml.compilers/src/main/resources/pomtemplates/pom.xml
@@ -65,29 +65,29 @@
65 65 <version>${thingml.version}</version>
66 66 </dependency>
67 67 <!--DEP-->
68   - <dependency><!--TODO: this should be added only when needed-->
  68 + <!--<dependency>
69 69 <groupId>org.scala-lang</groupId>
70 70 <artifactId>scala-swing</artifactId>
71 71 <version>${scala.version}</version>
72 72 </dependency>
73   - <dependency><!--TODO: this should be added only when needed-->
  73 + <dependency>
74 74 <groupId>org.thingml</groupId>
75 75 <artifactId>org.thingml.simulators</artifactId>
76 76 <version>${thingml.version}</version>
77 77 </dependency>
78   - <dependency><!--TODO: this should be added only when needed-->
  78 + <dependency>
79 79 <groupId>org.thingml</groupId>
80 80 <artifactId>org.thingml.samples.utils</artifactId>
81 81 <version>${thingml.version}</version>
82 82 </dependency>
83   - <dependency><!--TODO: this should be added only when needed-->
  83 + <dependency>
84 84 <groupId>org.thingml</groupId>
85 85 <artifactId>org.thingml.samples.resources</artifactId>
86 86 <version>${thingml.version}</version>
87 87 <classifier>resources</classifier>
88 88 <type>zip</type>
89 89 <scope>provided</scope>
90   - </dependency>
  90 + </dependency>-->
91 91 </dependencies>
92 92
93 93 <build>
286 org.thingml.compilers/src/main/scala/org/thingml/kevoreegenerator/KevoreeGenerator.scala
... ... @@ -0,0 +1,286 @@
  1 +/**
  2 + * Copyright (C) 2011 SINTEF <franck.fleurey@sintef.no>
  3 + *
  4 + * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007;
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.gnu.org/licenses/lgpl-3.0.txt
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +/**
  17 + * This code generator targets the SMAc Framework
  18 + * see https://github.com/brice-morin/SMAc
  19 + * @author: Brice MORIN <brice.morin@sintef.no>
  20 + */
  21 +package org.thingml.kevoreegenerator
  22 +
  23 +import org.thingml.scalagenerator.ScalaGenerator._
  24 +import org.sintef.thingml.constraints.ThingMLHelpers
  25 +import org.thingml.model.scalaimpl.ThingMLScalaImpl._
  26 +import org.sintef.thingml.resource.thingml.analysis.helper.CharacterEscaper
  27 +import scala.collection.JavaConversions._
  28 +import scala.io.Source
  29 +import scala.actors._
  30 +import scala.actors.Actor._
  31 +import java.util.{ArrayList, Hashtable}
  32 +import java.util.AbstractMap.SimpleEntry
  33 +import java.io.{File, FileWriter, PrintWriter, BufferedReader, InputStreamReader}
  34 +import org.sintef.thingml._
  35 +
  36 +import org.thingml.utils.log.Logger
  37 +
  38 +object Context {
  39 + val builder = new StringBuilder()
  40 +
  41 + var thing : Thing = _
  42 + var pack : String = _
  43 + var port_name : String = _
  44 + var file_name : String = _
  45 + var wrapper_name :String =_
  46 +
  47 + def firstToUpper(value : String) : String = {
  48 + return value.capitalize
  49 + }
  50 +
  51 + def init {
  52 + builder.clear
  53 + thing = null
  54 + pack = null
  55 + port_name = null
  56 + file_name = null
  57 + wrapper_name = null
  58 + }
  59 +}
  60 +
  61 +object KevoreeGenerator {
  62 + implicit def kevoreeGeneratorAspect(self: Thing): ThingKevoreeGenerator = ThingKevoreeGenerator(self)
  63 +
  64 + //TODO: modification
  65 + def compileAndRun(cfg : Configuration, model: ThingMLModel) {
  66 + new File(System.getProperty("java.io.tmpdir") + "ThingML_temp\\").deleteOnExit
  67 +
  68 + val rootDir = System.getProperty("java.io.tmpdir") + "ThingML_temp\\" + cfg.getName
  69 + val outputDir = System.getProperty("java.io.tmpdir") + "ThingML_temp\\" + cfg.getName + "\\src\\main\\java\\org\\thingml\\generated\\kevoree"
  70 +
  71 + val outputDirFile = new File(outputDir)
  72 + outputDirFile.mkdirs
  73 +
  74 +
  75 + cfg.allThings.foreach{case thing=>
  76 + Context.init
  77 + Context.file_name = cfg.getName+"_"+thing.getName()+"_KV2ThingML"
  78 + Context.wrapper_name = cfg.getName+"_"+thing.getName()+"_Wrapper"
  79 + val code = compile(thing, "org.thingml.generated", model)
  80 +
  81 + var w = new PrintWriter(new FileWriter(new File(outputDir + "\\" + Context.file_name+".java")));
  82 + System.out.println("code generated at "+outputDir + "\\" + Context.file_name+".java");
  83 + w.println(code._1);
  84 + w.close();
  85 +
  86 + w = new PrintWriter(new FileWriter(new File(outputDir + "\\"+Context.wrapper_name+".java")));
  87 + System.out.println("code generated at "+outputDir + "\\" + Context.wrapper_name+".java");
  88 + w.println(code._2);
  89 + w.close();
  90 + }
  91 + javax.swing.JOptionPane.showMessageDialog(null, "Kevoree/java code generated");
  92 + }
  93 +
  94 + def compile(t: Thing, pack : String, model: ThingMLModel) : Pair[String, String] = {
  95 + Context.pack = pack
  96 + var wrapperBuilder = new StringBuilder()
  97 +
  98 + generateHeader()
  99 + generateHeader(wrapperBuilder, true)
  100 +
  101 + /*model.allSimpleTypes.filter{ t => t.isInstanceOf[Enumeration] }.foreach{ e =>
  102 + e.generateScala()
  103 + }*/
  104 +
  105 + // Generate code for .things which appear in the configuration
  106 +
  107 + t.generateKevoree()
  108 + t.generateKevoreeWrapper(wrapperBuilder)
  109 + (Context.builder.toString, wrapperBuilder.toString)
  110 + }
  111 +
  112 + def generateHeader(builder: StringBuilder = Context.builder, isWrapper : Boolean = false) = {
  113 + builder append "/**\n"
  114 + builder append " * File generated by the ThingML IDE\n"
  115 + builder append " * /!\\Do not edit this file/!\\\n"
  116 + builder append " * In case of a bug in the generated code,\n"
  117 + builder append " * please submit an issue on our GitHub\n"
  118 + builder append " **/\n\n"
  119 +
  120 + builder append "package " + Context.pack +".kevoree;\n"
  121 + builder append "import " + Context.pack + ".*;\n"
  122 + builder append "import org.kevoree.framework.MessagePort;\n"
  123 + if(!isWrapper){
  124 + builder append "import org.kevoree.annotation.*;\n"
  125 + builder append "import org.kevoree.framework.AbstractComponentType;\n"
  126 + builder append "import org.sintef.smac.Event;"
  127 + }
  128 + else{
  129 + builder append "import scala.collection.immutable.$colon$colon;\n"
  130 + builder append "import org.sintef.smac.*;\n"
  131 +
  132 + }
  133 + }
  134 +}
  135 +
  136 +//TODO generate kevoree class + annotation
  137 +case class ThingKevoreeGenerator(val self: Thing){
  138 +
  139 + def generateKevoreeWrapper(builder:StringBuilder = Context.builder){
  140 + builder append "public class "+Context.wrapper_name+" extends ReactiveComponent{\n"
  141 +
  142 + builder append Context.file_name+" kevoreeComponent;\n"
  143 + builder append self.getName+" thingML_"+self.getName+"_Component;\n"
  144 + self.allPorts.foreach{case p =>
  145 + if(p.getSends.size>0){
  146 + builder append "Port " + "port_" + Context.firstToUpper(self.getName) + "_" + p.getName + "_wrapper = null;\n"
  147 + }
  148 + }
  149 + self.allPorts.foreach{case p =>
  150 + if(p.getSends.size>0){
  151 + builder append "public Port get"+Context.firstToUpper(self.getName)+"_"+p.getName+"(){\n"
  152 + builder append "return port_" + Context.firstToUpper(self.getName) + "_" + p.getName + "_wrapper\n"
  153 + builder append "}\n"
  154 + }
  155 + }
  156 +
  157 + builder append "public "+Context.wrapper_name+" (" +Context.file_name+" kevoreeComponent) {\n"
  158 + builder append "this.kevoreeComponent = kevoreeComponent;\n"
  159 + builder append "thingML_"+self.getName+"_Component = new "+self.getName+"("
  160 + generateParameters(builder)
  161 + builder append ");\n"
  162 +
  163 + self.allPorts.foreach{case p=>
  164 + builder append "scala.collection.immutable.List<String> "+p.getName+"_sent = null;\n"
  165 + builder append "scala.collection.immutable.List<String> "+p.getName+"_rcv = null;\n"
  166 + if(p.getSends.size>0){
  167 + builder append p.getName+"_sent = scala.collection.immutable.List$.MODULE$.empty();\n"
  168 + // builder append p.getName+"_sent = scala.collection.immutable.List$.MODULE$.empty();\n"
  169 + p.getSends.foreach{case s=>
  170 + builder append p.getName+"_sent = new $colon$colon(\"" + s.getName + "\", "+p.getName+"_sent);\n"
  171 + //builder append p.getName+"_sent = new $colon$colon("result", "+p.getName+"_sent);\n"
  172 + }
  173 + }
  174 + if(p.getReceives.size>0){
  175 + builder append p.getName+"_rcv = scala.collection.immutable.List$.MODULE$.empty();\n"
  176 + p.getReceives.foreach{case s=>
  177 + builder append p.getName+"_rcv = new $colon$colon(\"" + s.getName + "\", "+p.getName+"_rcv);\n"
  178 + }
  179 + }
  180 + builder append "port_" + Context.firstToUpper(self.getName) + "_" + p.getName+"_wrapper = (Port) new Port(\"" + p.getName + "\", "+p.getName+"_sent, "+p.getName+"_rcv, this).start();\n"
  181 +
  182 + }
  183 + self.allPorts.foreach{case p=>
  184 + if(p.getSends.size>0 || p.getReceives.size>0){
  185 + builder append "Channel c_" + p.getName + "_sent_" + p.hashCode + " = new Channel();\n"
  186 + builder append "c_" + p.getName + "_sent_" + p.hashCode + ".connect(" + " thingML_"+self.getName+"_Component.getPort(\""+p.getName+"\").get(),"+"port_" + Context.firstToUpper(self.getName) + "_" + p.getName+"_wrapper);\n"
  187 + builder append "c_" + p.getName + "_sent_" + p.hashCode+".start();\n"
  188 + }
  189 + }
  190 + builder append "thingML_"+self.getName+"_Component.start();\n"
  191 + builder append "}\n"
  192 + builder append "public "+ self.getName +" getInstance(){\n"
  193 + builder append "return "+" thingML_"+self.getName+"_Component;\n}\n\n"
  194 + builder append "@Override\n"
  195 + builder append "public void onIncomingMessage(SignedEvent e) {\n"
  196 + builder append "kevoreeComponent.onIncomingMessage(e.event());\n"
  197 +
  198 + builder append "}\n"
  199 + builder append "}\n"
  200 + }
  201 + def generateKevoree(builder: StringBuilder = Context.builder) {
  202 + println(self.getName)
  203 + Context.thing = self
  204 +
  205 + builder append "\n@Provides({\n"
  206 + builder append self.allPorts.collect{case p=>
  207 + if(p.getReceives.size>0) "@ProvidedPort(name = \""+p.getName+"_rcv\", type = PortType.MESSAGE)"
  208 + }.mkString(",\n")
  209 +
  210 + builder append "})\n@Requires({\n"
  211 + builder append self.allPorts.collect{case p=>
  212 + if(p.getSends.size>0) "@RequiredPort(name = \""+p.getName+"_Transfer\", type = PortType.MESSAGE)"
  213 + }.mkString(",\n")
  214 +
  215 + builder append "})\n"
  216 + builder append "@ComponentType\n "
  217 + builder append "public class "+ Context.file_name+" extends AbstractComponentType{\n"
  218 + builder append Context.wrapper_name+" wrapper;\n\n"
  219 + //generateParameters();
  220 +
  221 + builder append "@Start\n"
  222 + builder append "public void startComponent() {System.out.println(\""+Context.file_name+" component start!\");"
  223 + builder append "wrapper"+" = new "+Context.wrapper_name+"(this);\n}\n"
  224 + builder append "@Stop\n"
  225 + builder append "public void stopComponent() {System.out.println(\""+Context.file_name+" component stop!\");}\n"
  226 + builder append "@Update\n"
  227 + builder append "public void updateComponent() {System.out.println(\""+Context.file_name+" component update!\");}\n"
  228 +
  229 + //generate incoming messages
  230 + builder append "public void onIncomingMessage(Event e) {\n"
  231 + self.allOutgoingMessages.foreach{case m=>
  232 + builder append "if (e.event() instanceof "+Context.pack +"."+Context.firstToUpper(m.getName)+") {\n"
  233 + builder append "System.out.println(\"Kevoree4"+self.getName+": "+m.getName+" to send tranferred\");\n"
  234 + builder append "this.kevoreeComponent.getPortByName(\""+getPortNameWrapper(m)+"_Transfer\",MessagePort.class).process(e.event());\n"
  235 + builder append "}\n"
  236 + }
  237 +
  238 + //generate port to receive messages
  239 + generatePortDef()
  240 +
  241 + builder append "}\n"
  242 + }
  243 +
  244 + def generatePortDef(builder: StringBuilder = Context.builder) {
  245 + builder append "@Ports({\n"
  246 + builder append self.allPorts.collect{case p=>
  247 + if(p.getReceives.size>0) "@Port(name = \""+p.getName+"_rcv\")"
  248 + }.mkString(",\n")
  249 +
  250 + builder append "\n})\n"
  251 + builder append "public void tranferMessages(Object o) {\n"
  252 + self.allIncomingMessages.foreach{case m=>
  253 + builder append "if (o instanceof "+Context.pack +"."+Context.firstToUpper(m.getName)+") {\n"
  254 + builder append Context.pack +"."+Context.firstToUpper(m.getName)+" rcv_"+Context.firstToUpper(m.getName)+" = ("+Context.pack +"."+Context.firstToUpper(m.getName)+") o;\n"
  255 + getPortName(m)
  256 + builder append "wrapper.get"+Context.firstToUpper(self.getName)+"_"+Context.port_name+"().send(rcv_"+Context.firstToUpper(m.getName)+");\n"
  257 + builder append "}\n"
  258 + }
  259 + builder append "}\n"
  260 +
  261 + }
  262 +
  263 + def generateParameters(builder: StringBuilder = Context.builder) {
  264 + System.out.println("jinlaileme")
  265 + builder append self.allPropertiesInDepth.collect{case p=>
  266 + (if(p.getType.scala_type(p.getCardinality != null).equals("Short")) "(short)0"
  267 + else "new "+p.getType.scala_type(p.getCardinality != null)+"()")
  268 + }.mkString(", ")
  269 + }
  270 + def getPortName(m:Message){
  271 + self.allPorts.foreach{p=>
  272 + if(p.getReceives.contains(m)){
  273 + Context.port_name = p.getName
  274 + }
  275 + }
  276 + }
  277 + def getPortNameWrapper(m:Message):String = {
  278 + var name =""
  279 + self.allPorts.foreach{p=>
  280 + if(p.getSends.contains(m)){
  281 + name = p.getName
  282 + }
  283 + }
  284 + (name)
  285 + }
  286 +}
2  org.thingml.compilers/src/main/scala/org/thingml/scalagenerator/ScalaGenerator.scala
@@ -77,7 +77,7 @@ object ScalaGenerator {
77 77 case t: PrimitiveType => PrimitiveTypeScalaGenerator(t)
78 78 case t: Enumeration => EnumerationScalaGenerator(t)
79 79 case _ => TypeScalaGenerator(self)
80   - }
  80 + }
81 81
82 82 implicit def scalaGeneratorAspect(self: TypedElement) = self match {
83 83 case t: Function => FunctionScalaGenerator(t)
67 org.thingml.editor.standalone/BookhotelMediator_KV.java
... ... @@ -0,0 +1,67 @@
  1 +/**
  2 + * Copyright (C) 2011 SINTEF <franck.fleurey@sintef.no>
  3 + *
  4 + * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007;
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.gnu.org/licenses/lgpl-3.0.txt
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +/**
  17 + * File generated by the ThingML IDE /!\Do not edit this file/!\ In case of a
  18 + * bug in the generated code, please submit an issue on our GitHub
  19 + *
  20 + */
  21 +package org.thingml.generated;
  22 +
  23 +import org.thingml.generated.*;
  24 +import org.sintef.smac.*;
  25 +import org.kevoree.annotation.*;
  26 +import org.kevoree.framework.*;
  27 +import org.thingml.generated.*;
  28 +
  29 +@Provides({
  30 + @ProvidedPort(name = "kv2thingML_client_port", type = PortType.MESSAGE)})
  31 +@ComponentType
  32 +public class Kv2ThingML_client extends AbstractComponentType {
  33 +
  34 + Client thingML_client_component = new Client(new String(), new String(), new String(), (short) 0, (short) 0, new String(), new String());
  35 +
  36 + @Start
  37 + public void startComponent() {
  38 + }
  39 +
  40 + @Stop
  41 + public void stopComponent() {
  42 + }
  43 +
  44 + @Update
  45 + public void updateComponent() {
  46 + }
  47 +
  48 + @Port(name = "kv2thingML_client_port")
  49 + public void kv2thingML_client_port(Object o) {
  50 + if (o instanceof RRequest) {
  51 + RRequest rcv_RRequest = (RRequest) o;
  52 + kv2thingML_client_port.getPort("kv2thingML_client_port").get().send(rcv_RRequest);
  53 + }
  54 + if (o instanceof InputID) {
  55 + InputID rcv_InputID = (InputID) o;
  56 + kv2thingML_client_port.getPort("kv2thingML_client_port").get().send(rcv_InputID);
  57 + }
  58 + if (o instanceof TypeRequest) {
  59 + TypeRequest rcv_TypeRequest = (TypeRequest) o;
  60 + kv2thingML_client_port.getPort("kv2thingML_client_port").get().send(rcv_TypeRequest);
  61 + }
  62 + if (o instanceof Number) {
  63 + Number rcv_Number = (Number) o;
  64 + kv2thingML_client_port.getPort("kv2thingML_client_port").get().send(rcv_Number);
  65 + }
  66 + }
  67 +}
39 org.thingml.editor.standalone/BookhotelMergeMediator_KV.java
... ... @@ -0,0 +1,39 @@
  1 +/**
  2 + * Copyright (C) 2011 SINTEF <franck.fleurey@sintef.no>
  3 + *
  4 + * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007;
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.gnu.org/licenses/lgpl-3.0.txt
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +/**
  17 + * File generated by the ThingML IDE
  18 + * /!\Do not edit this file/!\
  19 + * In case of a bug in the generated code,
  20 + * please submit an issue on our GitHub
  21 + **/
  22 +
  23 +package org.thingml.generated;
  24 +import org.thingml.generated.*;
  25 +import org.sintef.smac.*;
  26 +import org.kevoree.annotation.*;
  27 +import org.kevoree.framework.*;
  28 +import org.thingml.generated.*;
  29 +
  30 +@Provides({
  31 +@ProvidedPort(name = "kv2thingML_client_port", type = PortType.MESSAGE)})
  32 +@ComponentType
  33 + public class Kv2ThingML_client extends AbstractComponentType{Client thingML_client_component = new Client(new String(), new String(), new String(), (short)0, (short)0, new String(), new String());
  34 +
  35 +@Start
  36 +public void startComponent() {}@Stop
  37 +public void stopComponent() {}@Update
  38 +public void updateComponent() {}@Port(name = "kv2thingML_client_port")public void kv2thingML_client_port(Object o) {if (o instanceof RRequest) {RRequest rcv_RRequest = (RRequest) o;kv2thingML_client_port.getPort("kv2thingML_client_port").get().send(rcv_RRequest);}if (o instanceof InputID) {InputID rcv_InputID = (InputID) o;kv2thingML_client_port.getPort("kv2thingML_client_port").get().send(rcv_InputID);}if (o instanceof TypeRequest) {TypeRequest rcv_TypeRequest = (TypeRequest) o;kv2thingML_client_port.getPort("kv2thingML_client_port").get().send(rcv_TypeRequest);}if (o instanceof Number) {Number rcv_Number = (Number) o;kv2thingML_client_port.getPort("kv2thingML_client_port").get().send(rcv_Number);}}}
  39 +
39 org.thingml.editor.standalone/BookhotelOneClientOneServer_KV.java
... ... @@ -0,0 +1,39 @@
  1 +/**
  2 + * Copyright (C) 2011 SINTEF <franck.fleurey@sintef.no>
  3 + *
  4 + * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007;
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.gnu.org/licenses/lgpl-3.0.txt
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +/**
  17 + * File generated by the ThingML IDE
  18 + * /!\Do not edit this file/!\
  19 + * In case of a bug in the generated code,
  20 + * please submit an issue on our GitHub
  21 + **/
  22 +
  23 +package org.thingml.generated;
  24 +import org.thingml.generated.*;
  25 +import org.sintef.smac.*;
  26 +import org.kevoree.annotation.*;
  27 +import org.kevoree.framework.*;
  28 +import org.thingml.generated.*;
  29 +
  30 +@Provides({
  31 +@ProvidedPort(name = "kv2thingML_client_port", type = PortType.MESSAGE)})
  32 +@ComponentType
  33 + public class Kv2ThingML_client extends AbstractComponentType{Client thingML_client_component = new Client(new String(), new String(), new String(), (short)0, (short)0, new String(), new String());
  34 +
  35 +@Start
  36 +public void startComponent() {}@Stop
  37 +public void stopComponent() {}@Update
  38 +public void updateComponent() {}@Port(name = "kv2thingML_client_port")public void kv2thingML_client_port(Object o) {if (o instanceof RRequest) {RRequest rcv_RRequest = (RRequest) o;kv2thingML_client_port.getPort("kv2thingML_client_port").get().send(rcv_RRequest);}if (o instanceof InputID) {InputID rcv_InputID = (InputID) o;kv2thingML_client_port.getPort("kv2thingML_client_port").get().send(rcv_InputID);}if (o instanceof TypeRequest) {TypeRequest rcv_TypeRequest = (TypeRequest) o;kv2thingML_client_port.getPort("kv2thingML_client_port").get().send(rcv_TypeRequest);}if (o instanceof Number) {Number rcv_Number = (Number) o;kv2thingML_client_port.getPort("kv2thingML_client_port").get().send(rcv_Number);}}}
  39 +
2  org.thingml.editor.standalone/src/main/java/org/sintef/thingml/MacIntegration.java
@@ -76,7 +76,7 @@ public void handleOpenApplication(ApplicationEvent applicationEvent) {
76 76 @Override
77 77 public void handleOpenFile(ApplicationEvent applicationEvent) {
78 78 System.out.println("open => "+applicationEvent.getFilename());
79   - editor.codeEditor().setText(editor.codeEditor()+"\n"+applicationEvent.getFilename());
  79 + //editor.codeEditor().setText(editor.codeEditor()+"\n"+applicationEvent.getFilename());
80 80 }
81 81
82 82 @Override
25 org.thingml.editor.standalone/src/main/scala/org/sintef/thingml/ThingMLPanel.scala
@@ -53,6 +53,7 @@ import java.io._
53 53 import java.util.Hashtable
54 54 import javax.management.remote.rmi._RMIConnection_Stub
55 55 import org.thingml.model.scalaimpl.ThingMLScalaImpl._
  56 +import org.thingml.kevoreegenerator.KevoreeGenerator
56 57
57 58 import scala.collection.JavaConversions._
58 59
@@ -87,10 +88,13 @@ class ThingMLPanel extends JPanel {
87 88 var bThingML = new JButton("Generate Comm")
88 89 var bThingML2 = new JButton("Generate Comm2")
89 90 var bCoAP = new JButton("Generate CoAP")
  91 + var bKevoree = new JButton("Generate Kevoree")
  92 +
  93 + //TODO: add a button for the kevoree compiler
90 94 val filechooser = new JFileChooser();
91 95 filechooser.setDialogTitle("Select target directory");
92 96 filechooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
93   -
  97 +
94 98 b.addActionListener(new ActionListener {
95 99 def actionPerformed(e: ActionEvent) {
96 100 println("Input file : " + targetFile)
@@ -213,12 +217,31 @@ class ThingMLPanel extends JPanel {
213 217 }
214 218 })
215 219
  220 + bKevoree.addActionListener(new ActionListener{
  221 + def actionPerformed(e:ActionEvent){
  222 + println("Input file : "+targetFile)
  223 + if(targetFile.isEmpty) return;
  224 +
  225 + try{
  226 + val thingmlModel = loadThingMLmodel(targetFile.get)
  227 + thingmlModel.allConfigurations.foreach{c =>
  228 + KevoreeGenerator.compileAndRun(c,thingmlModel)
  229 + }
  230 + }
  231 + catch {
  232 + case t : Throwable => t.printStackTrace()
  233 + }
  234 + }
  235 + })
  236 +
216 237 arduinoToolBar.add("Compilers", b)
217 238 arduinoToolBar.add("Compilers", bScala)
218 239 arduinoToolBar.add("Compilers", bSwing)
219 240 arduinoToolBar.add("Compilers", bThingML)
220 241 arduinoToolBar.add("Compilers", bThingML2)
221 242 arduinoToolBar.add("Compilers", bCoAP)
  243 + arduinoToolBar.add("Compilers", bKevoree)
  244 + //TODO
222 245 add(arduinoToolBar, BorderLayout.SOUTH)
223 246
224 247

0 comments on commit 53ca8a5

Brice Morin

I guess this file should not be commited (at least not here). Otherwise, very nice commit :-)

Brice Morin

I guess this file should not be commited (at least not here). Otherwise, very nice commit :-)

Brice Morin

I guess this file should not be commited (at least not here). Otherwise, very nice commit :-)

Brice Morin

I think we should generate the Kevoree code only from the model : ThingMLModel. The idea is indeed to use the Kevoree graphical editor and runtime to define and run the configuration. Basically we should generate the code for all the things defined in the model.

Runze Hao
Please sign in to comment.
Something went wrong with that request. Please try again.