From 434ddbc8c2a58b00c48b9f89ee7c73ca9aaf0634 Mon Sep 17 00:00:00 2001 From: Franck Fleurey Date: Sun, 14 Oct 2018 17:19:33 +0200 Subject: [PATCH] cleanup --- doc/examples/04_internal_port.thingml | 20 - doc/examples/robot.thingml | 1 + .../thingml-gen/browser/Ping/PingClient.js | 109 --- .../thingml-gen/browser/Ping/PingServer.js | 83 --- .../browser/Ping/Ping_merged.thingml | 189 ------ .../thingml-gen/browser/Ping/enums.js | 23 - .../thingml-gen/browser/Ping/index.html | 31 - .../browser/Ping/lib/EventEmitter.min.js | 23 - .../thingml-gen/browser/Ping/lib/state.min.js | 17 - .../thingml-gen/browser/Ping/runtime.js | 40 -- .../MQTTAdapterTest_merged.thingml | 627 ------------------ .../thingml-gen/java/MQTTAdapterTest/pom.xml | 114 ---- .../thingml/generated/JavaMQTTAdapter.java | 365 ---------- .../thingml/generated/MQTTAdapterTest.java | 314 --------- .../main/java/org/thingml/generated/Main.java | 87 --- .../java/org/thingml/generated/TimerJava.java | 154 ----- .../generated/api/IJavaMQTTAdapter_mqtt.java | 28 - .../api/IJavaMQTTAdapter_mqttClient.java | 25 - .../generated/api/IMQTTAdapterTest_clock.java | 23 - .../api/IMQTTAdapterTest_clockClient.java | 24 - .../generated/api/IMQTTAdapterTest_mqtt.java | 25 - .../api/IMQTTAdapterTest_mqttClient.java | 28 - .../generated/api/ITimerJava_timer.java | 24 - .../generated/api/ITimerJava_timerClient.java | 23 - .../messages/Mqtt_connectMessageType.java | 66 -- .../messages/Mqtt_connectedMessageType.java | 58 -- .../messages/Mqtt_disconnectMessageType.java | 58 -- .../Mqtt_disconnectedMessageType.java | 58 -- .../messages/Mqtt_messageMessageType.java | 64 -- .../messages/Mqtt_publishMessageType.java | 64 -- .../Mqtt_set_credentialsMessageType.java | 62 -- .../messages/Mqtt_set_prefixMessageType.java | 60 -- .../Mqtt_set_tls_certificatesMessageType.java | 66 -- .../messages/Mqtt_subscribeMessageType.java | 60 -- .../messages/Timer_cancelMessageType.java | 60 -- .../messages/Timer_startMessageType.java | 62 -- .../messages/Timer_timeoutMessageType.java | 60 -- doc/examples/thingml-gen/posix/Ping/Makefile | 19 - doc/examples/thingml-gen/posix/Ping/Ping | Bin 15560 -> 0 bytes .../thingml-gen/posix/Ping/PingClient.c | 151 ----- .../thingml-gen/posix/Ping/PingClient.h | 68 -- .../thingml-gen/posix/Ping/PingClient.o | Bin 3920 -> 0 bytes .../thingml-gen/posix/Ping/PingServer.c | 102 --- .../thingml-gen/posix/Ping/PingServer.h | 65 -- .../thingml-gen/posix/Ping/PingServer.o | Bin 2456 -> 0 bytes .../thingml-gen/posix/Ping/Ping_cfg.c | 230 ------- .../thingml-gen/posix/Ping/Ping_cfg.o | Bin 5872 -> 0 bytes .../posix/Ping/Ping_merged.thingml | 189 ------ doc/examples/thingml-gen/posix/Ping/runtime.c | 142 ---- doc/examples/thingml-gen/posix/Ping/runtime.h | 85 --- doc/examples/thingml-gen/posix/Ping/runtime.o | Bin 4360 -> 0 bytes .../thingml-gen/posix/Ping/thingml_typedefs.h | 51 -- .../CountdownUML/docs/CountdownUML.plantuml | 8 - .../docs/CountdownUML_class.plantuml | 66 -- .../docs/CountdownUML_class_compact.plantuml | 38 -- .../docs/CountdownUML_datatypes.plantuml | 11 - .../CountdownUML/docs/Countdown_null.plantuml | 19 - .../docs/TimerArduino_SoftTimer.plantuml | 13 - .../docs/TimerJS_SoftTimer.plantuml | 12 - .../docs/TimerJava_SoftTimer.plantuml | 12 - .../docs/TimerPosix_SoftTimer.plantuml | 13 - .../CountdownUML/CountdownUML_merged.thingml | 453 ------------- .../uml/Hello/Hello/docs/Hello.plantuml | 4 - .../docs/HelloThing_HelloStateChart.plantuml | 12 - .../uml/Hello/Hello/docs/Hello_class.plantuml | 5 - .../Hello/docs/Hello_class_compact.plantuml | 5 - .../Hello/Hello/docs/Hello_datatypes.plantuml | 3 - .../uml/Hello/Hello_merged.thingml | 10 - .../MQTTAdapterTest_merged.thingml | 627 ------------------ .../uml/Ping/Ping/docs/Ping.plantuml | 6 - .../PingClient_PingClientMachine.plantuml | 26 - .../Ping/Ping/docs/PingServer_null.plantuml | 12 - .../uml/Ping/Ping/docs/Ping_class.plantuml | 20 - .../Ping/docs/Ping_class_compact.plantuml | 20 - .../Ping/Ping/docs/Ping_datatypes.plantuml | 6 - .../thingml-gen/uml/Ping/Ping_merged.thingml | 189 ------ .../uml/Robot/Robot/docs/Robot.plantuml | 14 - .../uml/Robot/Robot/docs/Robot_class.plantuml | 69 -- .../Robot/docs/Robot_class_compact.plantuml | 64 -- .../Robot/Robot/docs/Robot_datatypes.plantuml | 12 - .../Robot/docs/WheelControl_null.plantuml | 28 - .../uml/Robot/Robot_merged.thingml | 229 ------- 82 files changed, 1 insertion(+), 6302 deletions(-) delete mode 100644 doc/examples/04_internal_port.thingml delete mode 100644 doc/examples/thingml-gen/browser/Ping/PingClient.js delete mode 100644 doc/examples/thingml-gen/browser/Ping/PingServer.js delete mode 100644 doc/examples/thingml-gen/browser/Ping/Ping_merged.thingml delete mode 100644 doc/examples/thingml-gen/browser/Ping/enums.js delete mode 100644 doc/examples/thingml-gen/browser/Ping/index.html delete mode 100644 doc/examples/thingml-gen/browser/Ping/lib/EventEmitter.min.js delete mode 100644 doc/examples/thingml-gen/browser/Ping/lib/state.min.js delete mode 100644 doc/examples/thingml-gen/browser/Ping/runtime.js delete mode 100644 doc/examples/thingml-gen/java/MQTTAdapterTest/MQTTAdapterTest_merged.thingml delete mode 100644 doc/examples/thingml-gen/java/MQTTAdapterTest/pom.xml delete mode 100644 doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/JavaMQTTAdapter.java delete mode 100644 doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/MQTTAdapterTest.java delete mode 100644 doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/Main.java delete mode 100644 doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/TimerJava.java delete mode 100644 doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/api/IJavaMQTTAdapter_mqtt.java delete mode 100644 doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/api/IJavaMQTTAdapter_mqttClient.java delete mode 100644 doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/api/IMQTTAdapterTest_clock.java delete mode 100644 doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/api/IMQTTAdapterTest_clockClient.java delete mode 100644 doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/api/IMQTTAdapterTest_mqtt.java delete mode 100644 doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/api/IMQTTAdapterTest_mqttClient.java delete mode 100644 doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/api/ITimerJava_timer.java delete mode 100644 doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/api/ITimerJava_timerClient.java delete mode 100644 doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_connectMessageType.java delete mode 100644 doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_connectedMessageType.java delete mode 100644 doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_disconnectMessageType.java delete mode 100644 doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_disconnectedMessageType.java delete mode 100644 doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_messageMessageType.java delete mode 100644 doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_publishMessageType.java delete mode 100644 doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_set_credentialsMessageType.java delete mode 100644 doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_set_prefixMessageType.java delete mode 100644 doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_set_tls_certificatesMessageType.java delete mode 100644 doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_subscribeMessageType.java delete mode 100644 doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Timer_cancelMessageType.java delete mode 100644 doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Timer_startMessageType.java delete mode 100644 doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Timer_timeoutMessageType.java delete mode 100644 doc/examples/thingml-gen/posix/Ping/Makefile delete mode 100644 doc/examples/thingml-gen/posix/Ping/Ping delete mode 100644 doc/examples/thingml-gen/posix/Ping/PingClient.c delete mode 100644 doc/examples/thingml-gen/posix/Ping/PingClient.h delete mode 100644 doc/examples/thingml-gen/posix/Ping/PingClient.o delete mode 100644 doc/examples/thingml-gen/posix/Ping/PingServer.c delete mode 100644 doc/examples/thingml-gen/posix/Ping/PingServer.h delete mode 100644 doc/examples/thingml-gen/posix/Ping/PingServer.o delete mode 100644 doc/examples/thingml-gen/posix/Ping/Ping_cfg.c delete mode 100644 doc/examples/thingml-gen/posix/Ping/Ping_cfg.o delete mode 100644 doc/examples/thingml-gen/posix/Ping/Ping_merged.thingml delete mode 100644 doc/examples/thingml-gen/posix/Ping/runtime.c delete mode 100644 doc/examples/thingml-gen/posix/Ping/runtime.h delete mode 100644 doc/examples/thingml-gen/posix/Ping/runtime.o delete mode 100644 doc/examples/thingml-gen/posix/Ping/thingml_typedefs.h delete mode 100644 doc/examples/thingml-gen/uml/CountdownUML/CountdownUML/docs/CountdownUML.plantuml delete mode 100644 doc/examples/thingml-gen/uml/CountdownUML/CountdownUML/docs/CountdownUML_class.plantuml delete mode 100644 doc/examples/thingml-gen/uml/CountdownUML/CountdownUML/docs/CountdownUML_class_compact.plantuml delete mode 100644 doc/examples/thingml-gen/uml/CountdownUML/CountdownUML/docs/CountdownUML_datatypes.plantuml delete mode 100644 doc/examples/thingml-gen/uml/CountdownUML/CountdownUML/docs/Countdown_null.plantuml delete mode 100644 doc/examples/thingml-gen/uml/CountdownUML/CountdownUML/docs/TimerArduino_SoftTimer.plantuml delete mode 100644 doc/examples/thingml-gen/uml/CountdownUML/CountdownUML/docs/TimerJS_SoftTimer.plantuml delete mode 100644 doc/examples/thingml-gen/uml/CountdownUML/CountdownUML/docs/TimerJava_SoftTimer.plantuml delete mode 100644 doc/examples/thingml-gen/uml/CountdownUML/CountdownUML/docs/TimerPosix_SoftTimer.plantuml delete mode 100644 doc/examples/thingml-gen/uml/CountdownUML/CountdownUML_merged.thingml delete mode 100644 doc/examples/thingml-gen/uml/Hello/Hello/docs/Hello.plantuml delete mode 100644 doc/examples/thingml-gen/uml/Hello/Hello/docs/HelloThing_HelloStateChart.plantuml delete mode 100644 doc/examples/thingml-gen/uml/Hello/Hello/docs/Hello_class.plantuml delete mode 100644 doc/examples/thingml-gen/uml/Hello/Hello/docs/Hello_class_compact.plantuml delete mode 100644 doc/examples/thingml-gen/uml/Hello/Hello/docs/Hello_datatypes.plantuml delete mode 100644 doc/examples/thingml-gen/uml/Hello/Hello_merged.thingml delete mode 100644 doc/examples/thingml-gen/uml/MQTTAdapterTest/MQTTAdapterTest_merged.thingml delete mode 100644 doc/examples/thingml-gen/uml/Ping/Ping/docs/Ping.plantuml delete mode 100644 doc/examples/thingml-gen/uml/Ping/Ping/docs/PingClient_PingClientMachine.plantuml delete mode 100644 doc/examples/thingml-gen/uml/Ping/Ping/docs/PingServer_null.plantuml delete mode 100644 doc/examples/thingml-gen/uml/Ping/Ping/docs/Ping_class.plantuml delete mode 100644 doc/examples/thingml-gen/uml/Ping/Ping/docs/Ping_class_compact.plantuml delete mode 100644 doc/examples/thingml-gen/uml/Ping/Ping/docs/Ping_datatypes.plantuml delete mode 100644 doc/examples/thingml-gen/uml/Ping/Ping_merged.thingml delete mode 100644 doc/examples/thingml-gen/uml/Robot/Robot/docs/Robot.plantuml delete mode 100644 doc/examples/thingml-gen/uml/Robot/Robot/docs/Robot_class.plantuml delete mode 100644 doc/examples/thingml-gen/uml/Robot/Robot/docs/Robot_class_compact.plantuml delete mode 100644 doc/examples/thingml-gen/uml/Robot/Robot/docs/Robot_datatypes.plantuml delete mode 100644 doc/examples/thingml-gen/uml/Robot/Robot/docs/WheelControl_null.plantuml delete mode 100644 doc/examples/thingml-gen/uml/Robot/Robot_merged.thingml diff --git a/doc/examples/04_internal_port.thingml b/doc/examples/04_internal_port.thingml deleted file mode 100644 index 0048fffa1..000000000 --- a/doc/examples/04_internal_port.thingml +++ /dev/null @@ -1,20 +0,0 @@ - -thing InternalPort { - - message quit(); - - internal port ctrl { - sends quit - } - - statechart init HelloState { - - final state HelloState { - on entry println "Hello World!" - } - } -} - -configuration Hello { - instance h : Hello -} diff --git a/doc/examples/robot.thingml b/doc/examples/robot.thingml index 80f3e8b5f..96e47ef8c 100644 --- a/doc/examples/robot.thingml +++ b/doc/examples/robot.thingml @@ -160,6 +160,7 @@ thing WheelControlArduino includes RobotMsgs } configuration Robot +@compiler "uml" { instance robot : RobotControl instance sdist : DistanceSensor diff --git a/doc/examples/thingml-gen/browser/Ping/PingClient.js b/doc/examples/thingml-gen/browser/Ping/PingClient.js deleted file mode 100644 index ec25f87f1..000000000 --- a/doc/examples/thingml-gen/browser/Ping/PingClient.js +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - */ -'use strict'; - -StateJS.internalTransitionsTriggerCompletion = true; - - -/* - * Definition for type : PingClient - */ - -function PingClient(name, root) { - this.name = name; - this.root = (root === null)? this : root; - this.ready = false; - this.bus = (root === null)? new EventEmitter() : this.root.bus; - - this.build(name); -} - -PingClient.prototype.build = function(session) { - /*State machine (states and regions)*/ - /*Building root component*/ - this._statemachine = new StateJS.StateMachine('PingClientMachine'); - let _initial_PingClient_PingClientMachine = new StateJS.PseudoState('_initial', this._statemachine, StateJS.PseudoStateKind.Initial); - let PingClient_PingClientMachine_Ping = new StateJS.State('Ping', this._statemachine).entry(() => { - console.log(''+'Send Ping '+this.PingClient_PingClientMachine_counter_var+' ... '); - setTimeout(() => this.bus.emit('ping_service?ping', this.PingClient_PingClientMachine_counter_var), 0); - }).exit(() => { - this.PingClient_PingClientMachine_counter_var = this.PingClient_PingClientMachine_counter_var + 1; - }); - let PingClient_PingClientMachine_OK = new StateJS.State('OK', this._statemachine); - let PingClient_PingClientMachine_Stop = new StateJS.FinalState('Stop', this._statemachine).entry(() => { - console.log(''+'Bye.'); - setImmediate(()=>this._stop()); - }); - _initial_PingClient_PingClientMachine.to(PingClient_PingClientMachine_Ping); - PingClient_PingClientMachine_OK.to(PingClient_PingClientMachine_Stop).when(() => { - return (this.PingClient_PingClientMachine_counter_var > 5); - }); - PingClient_PingClientMachine_OK.to(PingClient_PingClientMachine_Ping).when(() => { - return (this.PingClient_PingClientMachine_counter_var <= 5); - }); - PingClient_PingClientMachine_Ping.to(PingClient_PingClientMachine_OK).when((pong) => { - return pong._port === 'ping_service' && pong._msg === 'pong' && (pong.seq === this.PingClient_PingClientMachine_counter_var); - }).effect((pong) => { - console.log(''+'[OK]'); - }); - PingClient_PingClientMachine_Ping.to(PingClient_PingClientMachine_Stop).when((pong) => { - return pong._port === 'ping_service' && pong._msg === 'pong' && (pong.seq != this.PingClient_PingClientMachine_counter_var); - }).effect((pong) => { - console.log(''+'[Error]'); - }); -} -PingClient.prototype._stop = function() { - this.root = null; - this.ready = false; -} - -PingClient.prototype._delete = function() { - this._statemachine = null; - this._PingClientMachine_instance = null; - this.bus.removeAllListeners(); -} - -PingClient.prototype._init = function() { - this._PingClientMachine_instance = new StateJS.StateMachineInstance("PingClientMachine_instance"); - StateJS.initialise(this._statemachine, this._PingClientMachine_instance); - this.ready = true; -} - -PingClient.prototype._receive = function(msg) { - /*msg = {_port:myPort, _msg:myMessage, paramN=paramN, ...}*/ - if (this.ready) { - StateJS.evaluate(this._statemachine, this._PingClientMachine_instance, msg); - } else { - setTimeout(()=>this._receive(msg),0); - } -} - -PingClient.prototype.receivepongOnping_service = function(seq) { - this._receive({_port:"ping_service", _msg:"pong", seq:seq}); -} - -PingClient.prototype.initPingClient_PingClientMachine_counter_var = function(PingClient_PingClientMachine_counter_var) { - this.PingClient_PingClientMachine_counter_var = PingClient_PingClientMachine_counter_var; -} - -PingClient.prototype.toString = function() { - let result = 'instance ' + this.name + ':' + this.constructor.name + '\n'; - result += '\n\tcounter = ' + this.PingClient_PingClientMachine_counter_var; - result += ''; - return result; -} - diff --git a/doc/examples/thingml-gen/browser/Ping/PingServer.js b/doc/examples/thingml-gen/browser/Ping/PingServer.js deleted file mode 100644 index fb2e8daf4..000000000 --- a/doc/examples/thingml-gen/browser/Ping/PingServer.js +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - */ -'use strict'; - -StateJS.internalTransitionsTriggerCompletion = true; - - -/* - * Definition for type : PingServer - */ - -function PingServer(name, root) { - this.name = name; - this.root = (root === null)? this : root; - this.ready = false; - this.bus = (root === null)? new EventEmitter() : this.root.bus; - - this.build(name); -} - -PingServer.prototype.build = function(session) { - /*State machine (states and regions)*/ - /*Building root component*/ - this._statemachine = new StateJS.StateMachine('default'); - let _initial_PingServer = new StateJS.PseudoState('_initial', this._statemachine, StateJS.PseudoStateKind.Initial); - let PingServer_null_Active = new StateJS.State('Active', this._statemachine); - _initial_PingServer.to(PingServer_null_Active); - PingServer_null_Active.to(PingServer_null_Active).when((ping) => { - return ping._port === 'ping_service' && ping._msg === 'ping'; - }).effect((ping) => { - setTimeout(() => this.bus.emit('ping_service?pong', ping.seq), 0); - }); -} -PingServer.prototype._stop = function() { - this.root = null; - this.ready = false; -} - -PingServer.prototype._delete = function() { - this._statemachine = null; - this._null_instance = null; - this.bus.removeAllListeners(); -} - -PingServer.prototype._init = function() { - this._null_instance = new StateJS.StateMachineInstance("null_instance"); - StateJS.initialise(this._statemachine, this._null_instance); - this.ready = true; -} - -PingServer.prototype._receive = function(msg) { - /*msg = {_port:myPort, _msg:myMessage, paramN=paramN, ...}*/ - if (this.ready) { - StateJS.evaluate(this._statemachine, this._null_instance, msg); - } else { - setTimeout(()=>this._receive(msg),0); - } -} - -PingServer.prototype.receivepingOnping_service = function(seq) { - this._receive({_port:"ping_service", _msg:"ping", seq:seq}); -} - -PingServer.prototype.toString = function() { - let result = 'instance ' + this.name + ':' + this.constructor.name + '\n'; - result += ''; - return result; -} - diff --git a/doc/examples/thingml-gen/browser/Ping/Ping_merged.thingml b/doc/examples/thingml-gen/browser/Ping/Ping_merged.thingml deleted file mode 100644 index 3525873ea..000000000 --- a/doc/examples/thingml-gen/browser/Ping/Ping_merged.thingml +++ /dev/null @@ -1,189 +0,0 @@ -thing fragment PingMsgs { - message ping(seq : UInt8) - message pong(seq : UInt8) -} -thing PingServer includes PingMsgs { - provided port ping_service { - sends pong receives ping - } - statechart init Active { - state Active { - transition -> Active - event m : ping_service?ping - action ping_service!pong(m.seq) - } - } -} -thing PingClient includes PingMsgs { - required port ping_service { - sends ping receives pong - } - statechart PingClientMachine init Ping { - property counter : UInt8 = 0 - state Ping { - on entry do - print "Send Ping " , counter , " ... " - ping_service!ping(counter) - end - on exit counter = counter + 1 - transition -> OK - event e : ping_service?pong - guard e.seq == counter - action println "[OK]" - transition -> Stop - event e : ping_service?pong - guard e.seq != counter - action println "[Error]" - } - state OK { - transition -> Stop guard counter > 5 - transition -> Ping guard counter <= 5 - } - final state Stop { - on entry println "Bye." - } - } -} -datatype Byte<1> - @type_checker "Byte" - @c_type "uint8_t" - @c_byte_size "1" - @java_type "byte" - @js_type "byte" - @java_primitive "true" - @go_type "byte" -datatype Char<1> - @type_checker "Byte" - @c_type "char" - @c_byte_size "1" - @java_type "byte" - @js_type "byte" - @java_primitive "true" - @go_type "byte" -datatype Boolean<1> - @type_checker "Boolean" - @c_type "bool" - @c_byte_size "1" - @java_type "boolean" - @js_type "boolean" - @java_primitive "true" - @go_type "bool" -datatype Integer<2> - @type_checker "Integer" - @c_type "int" - @c_byte_size "2" - @java_type "short" - @js_type "short" - @java_primitive "true" - @go_type "int16" -datatype UInt8<1> - @type_checker "Integer" - @c_type "uint8_t" - @c_byte_size "1" - @java_type "short" - @js_type "short" - @java_primitive "true" - @go_type "uint8" -datatype Int8<1> - @type_checker "Integer" - @c_type "int8_t" - @c_byte_size "1" - @java_type "byte" - @js_type "byte" - @java_primitive "true" - @go_type "int8" -datatype UInt16<2> - @type_checker "Integer" - @c_type "uint16_t" - @c_byte_size "2" - @java_type "int" - @js_type "int" - @java_primitive "true" - @go_type "uint16" -datatype Int16<2> - @type_checker "Integer" - @c_type "int16_t" - @c_byte_size "2" - @java_type "short" - @js_type "short" - @java_primitive "true" - @go_type "int16" -datatype Int32<4> - @type_checker "Integer" - @c_type "int32_t" - @c_byte_size "4" - @java_type "int" - @js_type "int" - @java_primitive "true" - @go_type "int32" -datatype UInt32<4> - @type_checker "Integer" - @c_type "uint32_t" - @c_byte_size "4" - @java_type "long" - @js_type "long" - @java_primitive "true" - @go_type "uint32" -datatype Long<4> - @type_checker "Integer" - @c_type "long" - @c_byte_size "4" - @java_type "int" - @js_type "int" - @java_primitive "true" - @go_type "int32" -datatype ULong<4> - @type_checker "Integer" - @c_type "unsigned long" - @c_byte_size "4" - @java_type "long" - @js_type "long" - @java_primitive "true" - @go_type "uint32" -datatype LongLong<8> - @type_checker "Integer" - @c_type "long long" - @c_byte_size "8" - @java_type "long" - @js_type "long" - @java_primitive "true" - @go_type "int64" -datatype Float<4> - @type_checker "Real" - @c_type "float" - @c_byte_size "4" - @java_type "float" - @js_type "float" - @java_primitive "true" - @go_type "float32" -datatype Double<8> - @type_checker "Real" - @c_type "double" - @c_byte_size "8" - @java_type "double" - @js_type "double" - @java_primitive "true" - @go_type "float64" -object String - @serializable - @c_type "char *" - @c_byte_size "*" - @java_type "String" - @js_type "String" - @go_type "string" -enumeration DigitalState - @type_checker "Integer" - @java_type "byte" - @java_primitive "true" - @c_byte_size "1" - @c_type "uint8_t" - @go_type "uint8" - { - LOW @enum_val "0" - HIGH @enum_val "1" -} -configuration Ping { - instance client : PingClient - instance server : PingServer - connector client.ping_service => server . ping_service -} diff --git a/doc/examples/thingml-gen/browser/Ping/enums.js b/doc/examples/thingml-gen/browser/Ping/enums.js deleted file mode 100644 index 526e5fbf9..000000000 --- a/doc/examples/thingml-gen/browser/Ping/enums.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - */ -/*Definition of Enumeration DigitalState*/ -const DigitalState_ENUM = Object.freeze({ - LOW: 0, - HIGH: 1, -}); -exports.DigitalState_ENUM = DigitalState_ENUM; - diff --git a/doc/examples/thingml-gen/browser/Ping/index.html b/doc/examples/thingml-gen/browser/Ping/index.html deleted file mode 100644 index 267c7b4d3..000000000 --- a/doc/examples/thingml-gen/browser/Ping/index.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - - ThingML in the Browser! - - - - - - - - - diff --git a/doc/examples/thingml-gen/browser/Ping/lib/EventEmitter.min.js b/doc/examples/thingml-gen/browser/Ping/lib/EventEmitter.min.js deleted file mode 100644 index 1a410bc0e..000000000 --- a/doc/examples/thingml-gen/browser/Ping/lib/EventEmitter.min.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - */ -/*! - * EventEmitter v5.1.0 - git.io/ee - * Unlicense - http://unlicense.org/ - * Oliver Caldwell - http://oli.me.uk/ - * @preserve - */ -(function(){"use strict";function t(){}function i(t,n){for(var e=t.length;e--;)if(t[e].listener===n)return e;return-1}function n(e){return function(){return this[e].apply(this,arguments)}}var e=t.prototype,r=this,s=r.EventEmitter;e.getListeners=function(n){var r,e,t=this._getEvents();if(n instanceof RegExp){r={};for(e in t)t.hasOwnProperty(e)&&n.test(e)&&(r[e]=t[e])}else r=t[n]||(t[n]=[]);return r},e.flattenListeners=function(t){var e,n=[];for(e=0;e1&&n.console.error(t+": multiple outbound transitions evaluated true for message "+o)}return a}function l(t,e,n){for(var i=t.onTraverse.slice(0);t.target&&t.target instanceof x&&t.target.kind===y.Junction;)t=p(t.target,e,n),o(i,t.onTraverse);return a(i,n,e),t.target&&(t.target instanceof x&&t.target.kind===y.Choice?l(p(t.target,e,n),e,n):t.target instanceof C&&r(t.target,e)&&h(t.target,e,t.target)),!0}function p(t,e,i){var r=t.outgoing.filter(function(t){return t.guard(i,e)});return t.kind===y.Choice?0!==r.length?r[n.random(r.length)]:f(t):(r.length>1&&n.console.error("Multiple outbound transition guards returned true at "+t+" for "+i),r[0]||f(t))}function f(t){return t.outgoing.filter(function(t){return t.guard===I})[0]}function v(t){n.console=t}function g(t){n.internalTransitionsTriggerCompletion=t}function d(t){t.accept(new M)}var y,m=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)};!function(t){t[t.Choice=0]="Choice",t[t.DeepHistory=1]="DeepHistory",t[t.Initial=2]="Initial",t[t.Junction=3]="Junction",t[t.ShallowHistory=4]="ShallowHistory",t[t.Terminate=5]="Terminate"}(y=n.PseudoStateKind||(n.PseudoStateKind={}));var S;!function(t){t[t.External=0]="External",t[t.Internal=1]="Internal",t[t.Local=2]="Local"}(S=n.TransitionKind||(n.TransitionKind={}));var w=function(){function t(t){this.parent=t}return t}();n.Element=w;var b=function(t){function e(n,i){var r=t.call(this,i)||this;return r.name=n,r.qualifiedName=i?i.toString()+e.namespaceSeparator+n:n,r}return m(e,t),e.prototype.toString=function(){return this.qualifiedName},e}(w);b.namespaceSeparator=".",n.NamedElement=b;var E=function(t){function e(e,n){var i=t.call(this,e,n)||this;return i.vertices=new Array,i.parent.regions.push(i),i.getRoot().clean=!1,i}return m(e,t),e.prototype.remove=function(){for(var t=0,e=this.vertices;t0},e.prototype.isOrthogonal=function(){return this.regions.length>1},e.prototype.remove=function(){for(var e=0,n=this.regions;e "+this.target:this.source)+"]"},t}();n.Transition=O;var H=function(){function t(t){void 0===t&&(t="unnamed"),this.name=t,this.current={},this.last={},this.isTerminated=!1,this.name=t}return t.prototype.setCurrent=function(t,e){this.current[t.toString()]=e,e instanceof C&&(this.last[t.toString()]=e)},t.prototype.getCurrent=function(t){return this.current[t.toString()]},t.prototype.getLastKnownState=function(t){return this.last[t.toString()]},t.prototype.toString=function(){return this.name},t}();n.StateMachineInstance=H;var L=function(){function t(t){void 0===t&&(t="unnamed"),this.name=t,this.current={},this.isTerminated=!1}return t.prototype.setCurrent=function(t,e){this.current[t.toString()]=e,e instanceof C&&(this.getNode(t).lastKnown=e.name)},t.prototype.getCurrent=function(t){return this.current[t.toString()]},t.prototype.getLastKnownState=function(t){var e=this.getNode(t).lastKnown;return t.vertices.reduce(function(t,n){return n instanceof C&&n.name===e?n:t},void 0)},t.prototype.getNode=function(t){if(t.parent){var e=this.getNode(t.parent),n=e.children.reduce(function(e,n){return n.name===t.name?n:e},void 0);return n||(n={name:t.name,children:[]},e.children.push(n)),n}return this.activeStateConfiguration||(this.activeStateConfiguration={name:t.name,children:[]})},t.prototype.toJSON=function(){return JSON.stringify(this.activeStateConfiguration)},t.prototype.fromJSON=function(t){return this.activeStateConfiguration=JSON.parse(t)},t.prototype.toString=function(){return this.name},t}();n.JSONInstance=L;var B=function(){function t(){}return t.prototype.visitNamedElement=function(t,e){},t.prototype.visitRegion=function(t,e){this.visitNamedElement(t,e);for(var n=0,i=t.vertices;n1&&n.console.error(e+": "+e.kind+" pseudo states cannot have more than one Else transitions.")):(0!==e.outgoing.filter(function(t){return t.guard===I}).length&&n.console.error(e+": "+e.kind+" pseudo states cannot have Else transitions."),e.isInitial()&&(e.outgoing.length>1?n.console.error(e+": initial pseudo states must have no more than one outgoing transition."):1===e.outgoing.length&&e.outgoing[0].guard!==k&&n.console.error(e+": initial pseudo states cannot have a guard condition.")))},e.prototype.visitRegion=function(e){t.prototype.visitRegion.call(this,e);for(var i=0,r=0,o=0,a=0,s=e.vertices;a1&&n.console.error(e+": regions may have at most one initial pseudo state."),r>1&&n.console.error(e+": regions may have at most one deep history pseudo state."),o>1&&n.console.error(e+": regions may have at most one shallow history pseudo state.")},e.prototype.visitState=function(e){t.prototype.visitState.call(this,e),e.regions.filter(function(t){return t.name===E.defaultName}).length>1&&n.console.error(e+": a state cannot have more than one region named "+E.defaultName)},e.prototype.visitFinalState=function(e){t.prototype.visitFinalState.call(this,e),0!==e.outgoing.length&&n.console.error(e+": final states must not have outgoing transitions."),0!==e.regions.length&&n.console.error(e+": final states must not have child regions."),e.entryBehavior.length>0&&n.console.warn(e+": final states may not have entry behavior."),e.exitBehavior.length>0&&n.console.warn(e+": final states may not have exit behavior.")},e.prototype.visitTransition=function(e){t.prototype.visitTransition.call(this,e),e.kind===S.Local&&e.target&&e.target.ancestry().indexOf(e.source)===-1&&n.console.error(e+": local transition target vertices must be a child of the source composite sate.")},e}(B)},{}],2:[function(t,e,n){window[((document.currentScript||document.getElementsByTagName("script")[scripts.length-1]).attributes.target||{textContent:"fsm"}).textContent]=t("../lib/node/state.js")},{"../lib/node/state.js":1}]},{},[2]); diff --git a/doc/examples/thingml-gen/browser/Ping/runtime.js b/doc/examples/thingml-gen/browser/Ping/runtime.js deleted file mode 100644 index 2a1abba0e..000000000 --- a/doc/examples/thingml-gen/browser/Ping/runtime.js +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - */ -'use strict'; - -var RunThingMLConfiguration = function() { - /*$REQUIRE_PLUGINS$*/ - - const client = new PingClient('client', null); - client.initPingClient_PingClientMachine_counter_var(0); - const server = new PingServer('server', null); - - /*Connecting internal ports...*/ - /*Connecting ports...*/ - server.bus.on('ping_service?pong', (seq) => client.receivepongOnping_service(seq)); - client.bus.on('ping_service?ping', (seq) => server.receivepingOnping_service(seq)); - - server._init(); - client._init(); - - /*$PLUGINS_END$*/ -} - -window.addEventListener('DOMContentLoaded', function(){ - RunThingMLConfiguration(); -}); - diff --git a/doc/examples/thingml-gen/java/MQTTAdapterTest/MQTTAdapterTest_merged.thingml b/doc/examples/thingml-gen/java/MQTTAdapterTest/MQTTAdapterTest_merged.thingml deleted file mode 100644 index 73c6acbd5..000000000 --- a/doc/examples/thingml-gen/java/MQTTAdapterTest/MQTTAdapterTest_merged.thingml +++ /dev/null @@ -1,627 +0,0 @@ -thing MQTTAdapterTest includes MQTTAdapterMsgs , TimerMsgs { - required port clock { - sends timer_start sends timer_cancel receives timer_timeout - } - required port mqtt @sync_send "true" { - sends mqtt_connect sends mqtt_disconnect sends mqtt_publish sends mqtt_subscribe sends mqtt_set_credentials sends mqtt_set_prefix receives mqtt_connected receives mqtt_disconnected receives mqtt_message - } - readonly property client_id : String = "TestClient1" - property broker_host : String = "localhost" - property broker_port : UInt16 = 1883 - property broker_user : String = `null` - property broker_pass : String = `null` - property broker_tls : Boolean = false - readonly property timer_id : UInt8 = 0 - function publish_hello() do - mqtt!mqtt_publish("Hello", `"World".getBytes()`, 5) - end - statechart MQTTAdapterTestSC init DISCONNECTED { - on entry do - if (broker_user != `null`) mqtt!mqtt_set_credentials(broker_user, broker_pass) - mqtt!mqtt_connect(client_id, broker_host, broker_port, broker_tls) - end - state DISCONNECTED { - transition -> CONNECTED - event mqtt?mqtt_connected - action print "Client got mqtt_connected\n" - } - state CONNECTED { - on entry do - mqtt!mqtt_set_prefix("models18/") - mqtt!mqtt_subscribe("#") - publish_hello() - clock!timer_start(timer_id, 5000) - end - internal - event e : clock?timer_timeout - guard e.id == timer_id - action do - publish_hello() - clock!timer_start(timer_id, 5000) - end - internal - event m : mqtt?mqtt_message - action do - `System.out.println("RCV topic:"+` & m.topic & `+" payload:" + ` & m.payload & `);` - end - transition -> DISCONNECTED - event mqtt?mqtt_disconnected - action print "Client got mqtt_disconnected\n" - } - } -} -object MQTTMessage @java_type "org.eclipse.paho.client.mqttv3.MqttMessage" -object Throwable @java_type "Throwable" -object IMqttDeliveryToken @java_type "IMqttDeliveryToken" -thing JavaMQTTAdapter includes MQTTAdapterMsgs @maven_dep " - - org.eclipse.paho - org.eclipse.paho.client.mqttv3 - 1.2.0 - - - - org.json - org.json - chargebee-1.0 - " @java_interface "org.eclipse.paho.client.mqttv3.MqttCallbackExtended" @java_import "import java.util.logging.Logger;" @java_import "import java.util.logging.Level;" @java_import "import org.eclipse.paho.client.mqttv3.*;" @java_import "import org.eclipse.paho.client.mqttv3.persist.*;" @java_features "org.eclipse.paho.client.mqttv3.MqttClient clientPub, clientSub;" { - provided port mqtt @sync_send "true" { - sends mqtt_connected sends mqtt_disconnected sends mqtt_message receives mqtt_connect receives mqtt_disconnect receives mqtt_publish receives mqtt_subscribe receives mqtt_set_credentials receives mqtt_set_prefix - } - property broker_uri : String = "tcp://localhost:1883" - property client_id : String = `null` - property username : String = `null` - property password : String = `null` - property topic_prefix : String = `null` - function setTopicPrefix(src : String) do - topic_prefix = src - end - function mqtt_connect() : Boolean do - `try {` - `MemoryPersistence persistence = new MemoryPersistence();` - `Logger.getLogger(this.getClass().getName()).log(Level.INFO, "MQTT Connect to: " + ` & broker_uri & `);` - `MqttConnectOptions connOpts = new MqttConnectOptions();` - `connOpts.setCleanSession(true);` - `connOpts.setAutomaticReconnect(true);` - if (username != `null` and password != `null`) do - `connOpts.setUserName(` & username & `);` - `connOpts.setPassword(` & password & `.toCharArray());` - end - if (client_id == `null`) do - client_id = `MqttClient.generateClientId()` - end - `clientSub = new MqttClient(` & broker_uri & `, ` & client_id & ` + "_Sub", persistence);` - `clientPub = new MqttClient(` & broker_uri & `, ` & client_id & ` + "_Pub", persistence);` - `clientSub. setCallback(this);` - `clientSub.connect(connOpts);` - `clientPub.connect(connOpts);` - `} catch (org.eclipse.paho.client.mqttv3.MqttException ex) {` - `Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);` - return false - `}` - return true - end - function mqtt_publish(topic : String, payload : Buffer, size : UInt16) : Boolean do - if (`clientPub == null`) return false - `try { - Logger.getLogger(this.getClass().getName()).log(Level.INFO, "MQTT Publish: " + ` & topic & ` + " -> " + new String(` & payload & `)); - MqttMessage message = new MqttMessage(` & payload & `); - if (` & topic_prefix & ` != null) clientPub.publish(` & topic_prefix & ` + ` & topic & `, message); - else clientPub.publish(` & topic & `, message); - } catch (org.eclipse.paho.client.mqttv3.MqttException ex) { - Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);` - return false - `}` - return true - end - function mqtt_subscribe(topic : String) : Boolean do - if (`clientSub == null`) return false - `try { - Logger.getLogger(this.getClass().getName()).log(Level.INFO, "MQTT Subscribe: " + ` & topic & `); - if (` & topic_prefix & ` != null) clientSub.subscribe(` & topic_prefix & ` + ` & topic & `); - else clientSub.subscribe(` & topic & `); - } catch (org.eclipse.paho.client.mqttv3.MqttException ex) { - Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);` - return false - `}` - return true - end - function messageArrived(topic : String, m : MQTTMessage) @override "true" @java_visibility "public" do - print "Message arrived on topic " - print topic - print "\n" - end - function connectionLost(t : Throwable) @override "true" @java_visibility "public" do - print "connectionLost \n" - mqtt!mqtt_disconnected() - end - function deliveryComplete(imdt : IMqttDeliveryToken) @override "true" @java_visibility "public" do - print "deliveryComplete \n" - end - function connectComplete(reconnect : Boolean, serverURI : String) @override "true" @java_visibility "public" do - print "connectComplete \n" - mqtt!mqtt_connected() - end - statechart MQTTAdapterThing init Start { - state Start { - } - internal - event m : mqtt?mqtt_set_credentials - action do - username = m.usr - password = m.pwd - end - internal - event m : mqtt?mqtt_set_prefix - action do - setTopicPrefix(m.prefix) - end - internal - event m : mqtt?mqtt_connect - action do - client_id = m.client_id - `String uri;` - if (m.tls) `uri = "ssl://";` - else `uri = "tcp://";` - `uri += ` & m.host & ` + ":" + ` & m.portno & `;` - broker_uri = `uri` - mqtt_connect() - end - internal - event m : mqtt?mqtt_publish - action do - mqtt_publish(m.topic, m.payload, m.size) - end - internal - event m : mqtt?mqtt_subscribe - action do - mqtt_subscribe(m.topic) - end - } -} -thing fragment TimerMsgs { - message timer_start(id : UInt8, time : UInt16) - message timer_cancel(id : UInt8) - message timer_timeout(id : UInt8) -} -thing fragment TimerClientPort includes TimerMsgs { - required port timer { - sends timer_start sends timer_cancel receives timer_timeout - } -} -thing fragment Timer includes TimerMsgs { - provided port timer { - sends timer_timeout receives timer_start receives timer_cancel - } -} -thing TimerJava includes Timer @java_import "import java.util.*;" @java_features " - Hashtable tasks = new Hashtable(); - Timer timer = new java.util.Timer();" { - function startTimer(id : UInt8, delay : UInt16) do - cancel(id) - `final int t_id = ` & id & `;` - `TimerTask t = new TimerTask() { public void run(){` - timer!timer_timeout(`t_id` as UInt8) - ` - } }; - tasks.put(t_id, t); - timer.schedule(t, ` & delay & `);` - end - function cancel(id : UInt8) do - `TimerTask t = tasks.get(` & id & `);` - `if (t != null) t.cancel();` - `timer.purge();` - end - statechart SoftTimer init default { - state default { - internal - event m : timer?timer_start - guard m.time > 0 - action startTimer(m.id, m.time) - internal cancel - event m : timer?timer_cancel - action cancel(m.id) - } - } -} -object JSArray -thing TimerJS includes Timer { - property Timeouts : JSArray = `{}` as JSArray - function startTimer(id : UInt8, delay : UInt16) do - ` - if (` & Timeouts & `[` & id & `] != undefined) { - ` - cancel(id) - ` - } - - ` & Timeouts & `[` & id & `] = setTimeout(() => { - ` - timer!timer_timeout(id) - ` - ` & Timeouts & `[` & id & `] = undefined; - }, ` & delay & `); - ` - end - function cancel(id : UInt8) do - ` - if (` & Timeouts & `[` & id & `] != undefined) { - clearTimeout(` & Timeouts & `[` & id & `]); - ` & Timeouts & `[` & id & `] = undefined; - } - ` - end - statechart SoftTimer init default { - state default { - internal - event m : timer?timer_start - guard m.time > 0 - action startTimer(m.id, m.time) - internal cancel - event m : timer?timer_cancel - action cancel(m.id) - } - } -} -thing TimerPosix includes Timer @c_header " -#include -#include -#include - -#define NB_SOFT_TIMERS 16 -" @c_global "uint32_t Timer_timeouts[NB_SOFT_TIMERS]; -uint8_t Timer_wraps[NB_SOFT_TIMERS]; -uint32_t Timer_prev; -pthread_mutex_t Timer_mut;" { - readonly property NB_SOFT_TIMERS : UInt16 = `NB_SOFT_TIMERS` as UInt16 - readonly property SOFT_TIMER_PERIOD : UInt16 = 4 - function time_ms() : UInt32 do - `struct timespec current; - int res; - uint32_t millis = 0; - - res = clock_gettime(CLOCK_MONOTONIC, ¤t); - if (res != 0) { - perror("[ERROR]: Could not get current time : "); - } else { - millis = current.tv_sec * 1000; - millis += current.tv_nsec / 1000000; - }` - return `millis` as UInt32 - end - function sleep_ms(timeout_ms : UInt16) do - `struct timeval tv; - tv.tv_sec = ` & timeout_ms & `/1000; - tv.tv_usec = (` & timeout_ms & `%1000) * 1000; - select(0, NULL, NULL, NULL, &tv);` - end - function start_soft_timer_process() @fork_linux_thread "true" do - `pthread_mutex_init(&Timer_mut, NULL); - uint8_t i; - for (i = 0; i < ` & NB_SOFT_TIMERS & `; i++) { - Timer_timeouts[i] = 0; - Timer_wraps[i] = 0; - } - Timer_prev = ` & time_ms()& `;` - while (true) do - sleep_ms(SOFT_TIMER_PERIOD) - `pthread_mutex_lock(&Timer_mut); - uint32_t current = ` & time_ms()& `; - uint8_t i; - for (i = 0; i < ` & NB_SOFT_TIMERS & `; i++) { - if (Timer_timeouts[i] > 0) { - if (current >= Timer_prev) { - // Normal time progression - if (current > Timer_timeouts[i] && Timer_wraps[i] == 0) {` - timer!timer_timeout(`i` as UInt8) - `Timer_timeouts[i] = 0; - Timer_wraps[i] = 0; - } - } else { - // A wraparound has occurred - if (Timer_wraps[i] == 0) {` - timer!timer_timeout(`i` as UInt8) - `Timer_timeouts[i] = 0; - } else { - Timer_wraps[i] = 0; - if (current > Timer_timeouts[i]) {` - timer!timer_timeout(`i` as UInt8) - `Timer_timeouts[i] = 0; - } - } - } - } - } - Timer_prev = current; - pthread_mutex_unlock(&Timer_mut);` - end - end - function startTimer(id : UInt8, delay : UInt16) do - ` - if (` & id & ` < NB_SOFT_TIMERS) { - uint32_t current = ` & time_ms()& `; - uint32_t timeout = current + ` & delay & `; - if (timeout == 0) timeout = 1; - - pthread_mutex_lock(&Timer_mut); - Timer_timeouts[` & id & `] = timeout; - Timer_wraps[` & id & `] = (timeout > current) ? 0 : 1; - pthread_mutex_unlock(&Timer_mut); - } - ` - end - function cancel(id : UInt8) do - ` - if (` & id & ` < NB_SOFT_TIMERS) { - pthread_mutex_lock(&Timer_mut); - Timer_timeouts[` & id & `] = 0; - Timer_wraps[` & id & `] = 0; - pthread_mutex_unlock(&Timer_mut); - } - ` - end - statechart SoftTimer init default { - on entry start_soft_timer_process() - state default { - internal - event m : timer?timer_start - guard m.time > 0 - action startTimer(m.id, m.time) - internal cancel - event m : timer?timer_cancel - action cancel(m.id) - } - } -} -thing TimerArduino includes Timer @c_header " -#define NB_SOFT_TIMERS 16 -" @c_global "uint32_t Timer_timeouts[NB_SOFT_TIMERS]; -uint8_t Timer_wraps[NB_SOFT_TIMERS]; -uint32_t Timer_prev;" { - readonly property NB_SOFT_TIMERS : UInt16 = `NB_SOFT_TIMERS` as UInt16 - function time_ms() : UInt32 do - return `millis()` as UInt32 - end - function init_arrays() do - `uint8_t i; - for (i = 0; i < ` & NB_SOFT_TIMERS & `; i++) { - Timer_timeouts[i] = 0; - Timer_wraps[i] = 0; - } - Timer_prev = ` & time_ms()& `;` - end - function poll_soft_timers() @scheduler_polling "true" do - `uint32_t current = ` & time_ms()& `; - uint8_t i; - for (i = 0; i < ` & NB_SOFT_TIMERS & `; i++) { - if (Timer_timeouts[i] > 0) { - if (current >= Timer_prev) { - // Normal time progression - if (current > Timer_timeouts[i] && Timer_wraps[i] == 0) {` - timer!timer_timeout(`i` as UInt8) - `Timer_timeouts[i] = 0; - Timer_wraps[i] = 0; - } - } else { - // A wraparound has occurred - if (Timer_wraps[i] == 0) {` - timer!timer_timeout(`i` as UInt8) - `Timer_timeouts[i] = 0; - } else { - Timer_wraps[i] = 0; - if (current > Timer_timeouts[i]) {` - timer!timer_timeout(`i` as UInt8) - `Timer_timeouts[i] = 0; - } - } - } - } - }` - end - function startTimer(id : UInt8, delay : UInt16) do - ` - if (` & id & ` < NB_SOFT_TIMERS) { - uint32_t current = ` & time_ms()& `; - uint32_t timeout = current + ` & delay & `; - if (timeout == 0) timeout = 1; - - Timer_timeouts[` & id & `] = timeout; - Timer_wraps[` & id & `] = (timeout > current) ? 0 : 1; - } - ` - end - function cancel(id : UInt8) do - ` - if (` & id & ` < NB_SOFT_TIMERS) { - Timer_timeouts[` & id & `] = 0; - Timer_wraps[` & id & `] = 0; - } - ` - end - statechart SoftTimer init default { - on entry init_arrays() - state default { - internal - event m : timer?timer_start - guard m.time > 0 - action startTimer(m.id, m.time) - internal cancel - event m : timer?timer_cancel - action cancel(m.id) - } - } -} -object Buffer - @java_type " byte[]" - @java_primitive "true" - @c_type "uint8_t *" - @c_byte_size "*" -thing MQTTAdapterMsgs { - message mqtt_set_credentials(usr : String, pwd : String) - message mqtt_set_tls_certificates(cafile : String, capath : String, certfile : String, keyfile : String) - message mqtt_connect(client_id : String, host : String, portno : UInt16, tls : Boolean) - message mqtt_disconnect() - message mqtt_connected() - message mqtt_disconnected() - message mqtt_publish(topic : String, payload : Buffer, size : UInt32) - message mqtt_subscribe(topic : String) - message mqtt_set_prefix(prefix : String) - message mqtt_message(topic : String, payload : Buffer, size : UInt32) -} -thing MQTTAdapterCtrlPort includes MQTTAdapterMsgs { - required port mqtt @sync_send "true" { - sends mqtt_connect sends mqtt_disconnect receives mqtt_connected receives mqtt_disconnected - } -} -datatype Byte<1> - @type_checker "Byte" - @c_type "uint8_t" - @c_byte_size "1" - @java_type "byte" - @js_type "byte" - @java_primitive "true" - @go_type "byte" -datatype Char<1> - @type_checker "Byte" - @c_type "char" - @c_byte_size "1" - @java_type "byte" - @js_type "byte" - @java_primitive "true" - @go_type "byte" -datatype Boolean<1> - @type_checker "Boolean" - @c_type "bool" - @c_byte_size "1" - @java_type "boolean" - @js_type "boolean" - @java_primitive "true" - @go_type "bool" -datatype Integer<2> - @type_checker "Integer" - @c_type "int" - @c_byte_size "2" - @java_type "short" - @js_type "short" - @java_primitive "true" - @go_type "int16" -datatype UInt8<1> - @type_checker "Integer" - @c_type "uint8_t" - @c_byte_size "1" - @java_type "short" - @js_type "short" - @java_primitive "true" - @go_type "uint8" -datatype Int8<1> - @type_checker "Integer" - @c_type "int8_t" - @c_byte_size "1" - @java_type "byte" - @js_type "byte" - @java_primitive "true" - @go_type "int8" -datatype UInt16<2> - @type_checker "Integer" - @c_type "uint16_t" - @c_byte_size "2" - @java_type "int" - @js_type "int" - @java_primitive "true" - @go_type "uint16" -datatype Int16<2> - @type_checker "Integer" - @c_type "int16_t" - @c_byte_size "2" - @java_type "short" - @js_type "short" - @java_primitive "true" - @go_type "int16" -datatype Int32<4> - @type_checker "Integer" - @c_type "int32_t" - @c_byte_size "4" - @java_type "int" - @js_type "int" - @java_primitive "true" - @go_type "int32" -datatype UInt32<4> - @type_checker "Integer" - @c_type "uint32_t" - @c_byte_size "4" - @java_type "long" - @js_type "long" - @java_primitive "true" - @go_type "uint32" -datatype Long<4> - @type_checker "Integer" - @c_type "long" - @c_byte_size "4" - @java_type "int" - @js_type "int" - @java_primitive "true" - @go_type "int32" -datatype ULong<4> - @type_checker "Integer" - @c_type "unsigned long" - @c_byte_size "4" - @java_type "long" - @js_type "long" - @java_primitive "true" - @go_type "uint32" -datatype LongLong<8> - @type_checker "Integer" - @c_type "long long" - @c_byte_size "8" - @java_type "long" - @js_type "long" - @java_primitive "true" - @go_type "int64" -datatype Float<4> - @type_checker "Real" - @c_type "float" - @c_byte_size "4" - @java_type "float" - @js_type "float" - @java_primitive "true" - @go_type "float32" -datatype Double<8> - @type_checker "Real" - @c_type "double" - @c_byte_size "8" - @java_type "double" - @js_type "double" - @java_primitive "true" - @go_type "float64" -object String - @serializable - @c_type "char *" - @c_byte_size "*" - @java_type "String" - @js_type "String" - @go_type "string" -enumeration DigitalState - @type_checker "Integer" - @java_type "byte" - @java_primitive "true" - @c_byte_size "1" - @c_type "uint8_t" - @go_type "uint8" - { - LOW @enum_val "0" - HIGH @enum_val "1" -} -configuration MQTTAdapterTest { - instance adapter1 : JavaMQTTAdapter - instance timer : TimerJava - instance test1 : MQTTAdapterTest - connector test1.mqtt => adapter1 . mqtt - connector test1.clock => timer . timer - set test1.client_id = "Test1" - set test1.broker_host = "mqtt.tutorials.tellucloud.com" - set test1.broker_port = 1883 - set test1.broker_user = "models18" - set test1.broker_pass = "thingml" - set test1.broker_tls = false - set test1.timer_id = 1 -} diff --git a/doc/examples/thingml-gen/java/MQTTAdapterTest/pom.xml b/doc/examples/thingml-gen/java/MQTTAdapterTest/pom.xml deleted file mode 100644 index b148e5da7..000000000 --- a/doc/examples/thingml-gen/java/MQTTAdapterTest/pom.xml +++ /dev/null @@ -1,114 +0,0 @@ - - - - 4.0.0 - org.thingml.generated - MQTTAdapterTest - jar - 1.0.0 - - - UTF-8 - 1.2.0 - - - - - - - - - - - - - no.sintef - jasm - ${jasm.version} - - - - -org.eclipse.pahoorg.eclipse.paho.client.mqttv31.2.0org.jsonorg.jsonchargebee-1.0 - - - - - src/main/java - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.1 - - 1.8 - 1.8 - - - - - org.codehaus.mojo - exec-maven-plugin - - - - java - - - - - org.thingml.generated.Main - - - - - maven-assembly-plugin - - - - org.thingml.generated.Main - - - - jar-with-dependencies - - - - - make-assembly - - package - - - single - - - - - - - - - - - diff --git a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/JavaMQTTAdapter.java b/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/JavaMQTTAdapter.java deleted file mode 100644 index 4dce02c12..000000000 --- a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/JavaMQTTAdapter.java +++ /dev/null @@ -1,365 +0,0 @@ -/** - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - */ -/** - * File generated by the ThingML IDE - * /!\Do not edit this file/!\ - * In case of a bug in the generated code, - * please submit an issue on our GitHub - **/ - -package org.thingml.generated; - -import no.sintef.jasm.*; -import no.sintef.jasm.ext.*; - -import org.thingml.generated.api.*; -import org.thingml.generated.messages.*; - -import java.util.*; - -//START: @java_import annotation -import java.util.logging.Logger; -import java.util.logging.Level; -import org.eclipse.paho.client.mqttv3.*; -import org.eclipse.paho.client.mqttv3.persist.*; - -//END: @java_import annotation - -/** - * Definition for type : JavaMQTTAdapter - **/ -public class JavaMQTTAdapter extends Component implements IJavaMQTTAdapter_mqtt, org.eclipse.paho.client.mqttv3.MqttCallbackExtended { - - - // START: @java_features annotation -org.eclipse.paho.client.mqttv3.MqttClient clientPub, clientSub; - - // END: @java_features annotation - -private boolean debug = false; -public boolean isDebug() {return debug;} -public void setDebug(boolean debug) {this.debug = debug;} -public String toString() { -String result = "instance " + getName() + "\n"; -result += "\tbroker_uri = " + JavaMQTTAdapter_broker_uri_var; -result += "\tclient_id = " + JavaMQTTAdapter_client_id_var; -result += "\tusername = " + JavaMQTTAdapter_username_var; -result += "\tpassword = " + JavaMQTTAdapter_password_var; -result += "\ttopic_prefix = " + JavaMQTTAdapter_topic_prefix_var; -result += ""; -return result; -} - -public synchronized void mqtt_connect_via_mqtt(String MQTTAdapterMsgs_mqtt_connect_client_id_var, String MQTTAdapterMsgs_mqtt_connect_host_var, int MQTTAdapterMsgs_mqtt_connect_portno_var, boolean MQTTAdapterMsgs_mqtt_connect_tls_var){ -final Event _msg = mqtt_connectType.instantiate(MQTTAdapterMsgs_mqtt_connect_client_id_var, MQTTAdapterMsgs_mqtt_connect_host_var, MQTTAdapterMsgs_mqtt_connect_portno_var, MQTTAdapterMsgs_mqtt_connect_tls_var); -_msg.setPort(mqtt_port); -receive(_msg); -} - -public synchronized void mqtt_disconnect_via_mqtt(){ -final Event _msg = mqtt_disconnectType.instantiate(); -_msg.setPort(mqtt_port); -receive(_msg); -} - -public synchronized void mqtt_publish_via_mqtt(String MQTTAdapterMsgs_mqtt_publish_topic_var, byte[] MQTTAdapterMsgs_mqtt_publish_payload_var, long MQTTAdapterMsgs_mqtt_publish_size_var){ -final Event _msg = mqtt_publishType.instantiate(MQTTAdapterMsgs_mqtt_publish_topic_var, MQTTAdapterMsgs_mqtt_publish_payload_var, MQTTAdapterMsgs_mqtt_publish_size_var); -_msg.setPort(mqtt_port); -receive(_msg); -} - -public synchronized void mqtt_subscribe_via_mqtt(String MQTTAdapterMsgs_mqtt_subscribe_topic_var){ -final Event _msg = mqtt_subscribeType.instantiate(MQTTAdapterMsgs_mqtt_subscribe_topic_var); -_msg.setPort(mqtt_port); -receive(_msg); -} - -public synchronized void mqtt_set_credentials_via_mqtt(String MQTTAdapterMsgs_mqtt_set_credentials_usr_var, String MQTTAdapterMsgs_mqtt_set_credentials_pwd_var){ -final Event _msg = mqtt_set_credentialsType.instantiate(MQTTAdapterMsgs_mqtt_set_credentials_usr_var, MQTTAdapterMsgs_mqtt_set_credentials_pwd_var); -_msg.setPort(mqtt_port); -receive(_msg); -} - -public synchronized void mqtt_set_prefix_via_mqtt(String MQTTAdapterMsgs_mqtt_set_prefix_prefix_var){ -final Event _msg = mqtt_set_prefixType.instantiate(MQTTAdapterMsgs_mqtt_set_prefix_prefix_var); -_msg.setPort(mqtt_port); -receive(_msg); -} - -private void sendMqtt_connected_via_mqtt(){ -mqtt_port.send(mqtt_connectedType.instantiate()); -} - -private void sendMqtt_disconnected_via_mqtt(){ -mqtt_port.send(mqtt_disconnectedType.instantiate()); -} - -private void sendMqtt_message_via_mqtt(String MQTTAdapterMsgs_mqtt_message_topic_var, byte[] MQTTAdapterMsgs_mqtt_message_payload_var, long MQTTAdapterMsgs_mqtt_message_size_var){ -mqtt_port.send(mqtt_messageType.instantiate(MQTTAdapterMsgs_mqtt_message_topic_var, MQTTAdapterMsgs_mqtt_message_payload_var, MQTTAdapterMsgs_mqtt_message_size_var)); -} - -//Attributes -private String JavaMQTTAdapter_username_var; -private String JavaMQTTAdapter_client_id_var; -private String JavaMQTTAdapter_topic_prefix_var; -private String JavaMQTTAdapter_password_var; -private String JavaMQTTAdapter_broker_uri_var; -//Ports -private Port mqtt_port; -//Message types -protected final Mqtt_set_credentialsMessageType mqtt_set_credentialsType = new Mqtt_set_credentialsMessageType(); -protected final Mqtt_set_tls_certificatesMessageType mqtt_set_tls_certificatesType = new Mqtt_set_tls_certificatesMessageType(); -protected final Mqtt_connectMessageType mqtt_connectType = new Mqtt_connectMessageType(); -protected final Mqtt_disconnectMessageType mqtt_disconnectType = new Mqtt_disconnectMessageType(); -protected final Mqtt_connectedMessageType mqtt_connectedType = new Mqtt_connectedMessageType(); -protected final Mqtt_disconnectedMessageType mqtt_disconnectedType = new Mqtt_disconnectedMessageType(); -protected final Mqtt_publishMessageType mqtt_publishType = new Mqtt_publishMessageType(); -protected final Mqtt_subscribeMessageType mqtt_subscribeType = new Mqtt_subscribeMessageType(); -protected final Mqtt_set_prefixMessageType mqtt_set_prefixType = new Mqtt_set_prefixMessageType(); -protected final Mqtt_messageMessageType mqtt_messageType = new Mqtt_messageMessageType(); -//Empty Constructor -public JavaMQTTAdapter() { -super(); -} - -//Getters and Setters for non readonly/final attributes -public String getJavaMQTTAdapter_username_var() { -return JavaMQTTAdapter_username_var; -} - -public void setJavaMQTTAdapter_username_var(String JavaMQTTAdapter_username_var) { -this.JavaMQTTAdapter_username_var = JavaMQTTAdapter_username_var; -} - -public JavaMQTTAdapter initJavaMQTTAdapter_username_var(String JavaMQTTAdapter_username_var) { -this.JavaMQTTAdapter_username_var = JavaMQTTAdapter_username_var; -return this; -} - -public String getJavaMQTTAdapter_client_id_var() { -return JavaMQTTAdapter_client_id_var; -} - -public void setJavaMQTTAdapter_client_id_var(String JavaMQTTAdapter_client_id_var) { -this.JavaMQTTAdapter_client_id_var = JavaMQTTAdapter_client_id_var; -} - -public JavaMQTTAdapter initJavaMQTTAdapter_client_id_var(String JavaMQTTAdapter_client_id_var) { -this.JavaMQTTAdapter_client_id_var = JavaMQTTAdapter_client_id_var; -return this; -} - -public String getJavaMQTTAdapter_topic_prefix_var() { -return JavaMQTTAdapter_topic_prefix_var; -} - -public void setJavaMQTTAdapter_topic_prefix_var(String JavaMQTTAdapter_topic_prefix_var) { -this.JavaMQTTAdapter_topic_prefix_var = JavaMQTTAdapter_topic_prefix_var; -} - -public JavaMQTTAdapter initJavaMQTTAdapter_topic_prefix_var(String JavaMQTTAdapter_topic_prefix_var) { -this.JavaMQTTAdapter_topic_prefix_var = JavaMQTTAdapter_topic_prefix_var; -return this; -} - -public String getJavaMQTTAdapter_password_var() { -return JavaMQTTAdapter_password_var; -} - -public void setJavaMQTTAdapter_password_var(String JavaMQTTAdapter_password_var) { -this.JavaMQTTAdapter_password_var = JavaMQTTAdapter_password_var; -} - -public JavaMQTTAdapter initJavaMQTTAdapter_password_var(String JavaMQTTAdapter_password_var) { -this.JavaMQTTAdapter_password_var = JavaMQTTAdapter_password_var; -return this; -} - -public String getJavaMQTTAdapter_broker_uri_var() { -return JavaMQTTAdapter_broker_uri_var; -} - -public void setJavaMQTTAdapter_broker_uri_var(String JavaMQTTAdapter_broker_uri_var) { -this.JavaMQTTAdapter_broker_uri_var = JavaMQTTAdapter_broker_uri_var; -} - -public JavaMQTTAdapter initJavaMQTTAdapter_broker_uri_var(String JavaMQTTAdapter_broker_uri_var) { -this.JavaMQTTAdapter_broker_uri_var = JavaMQTTAdapter_broker_uri_var; -return this; -} - -//Getters for Ports -public Port getMqtt_port() { -return mqtt_port; -} -private CompositeState buildJavaMQTTAdapter_MQTTAdapterThing(){ -final AtomicState state_JavaMQTTAdapter_MQTTAdapterThing_Start = new AtomicState("Start"); -final CompositeState state_JavaMQTTAdapter_MQTTAdapterThing = new CompositeState("MQTTAdapterThing"); -Handler h732470450 = new Handler(); -h732470450.from(state_JavaMQTTAdapter_MQTTAdapterThing); -h732470450.event(mqtt_set_credentialsType); -h732470450.port(mqtt_port); -h732470450.action((Event e)->{ -final Mqtt_set_credentialsMessageType.Mqtt_set_credentialsMessage mqtt_set_credentials = (Mqtt_set_credentialsMessageType.Mqtt_set_credentialsMessage) e; -JavaMQTTAdapter_username_var = (String) (mqtt_set_credentials.usr); -JavaMQTTAdapter_password_var = (String) (mqtt_set_credentials.pwd); -}); - -Handler h1499489673 = new Handler(); -h1499489673.from(state_JavaMQTTAdapter_MQTTAdapterThing); -h1499489673.event(mqtt_set_prefixType); -h1499489673.port(mqtt_port); -h1499489673.action((Event e)->{ -final Mqtt_set_prefixMessageType.Mqtt_set_prefixMessage mqtt_set_prefix = (Mqtt_set_prefixMessageType.Mqtt_set_prefixMessage) e; -setTopicPrefix((String) (mqtt_set_prefix.prefix)); -}); - -Handler h706341616 = new Handler(); -h706341616.from(state_JavaMQTTAdapter_MQTTAdapterThing); -h706341616.event(mqtt_connectType); -h706341616.port(mqtt_port); -h706341616.action((Event e)->{ -final Mqtt_connectMessageType.Mqtt_connectMessage mqtt_connect = (Mqtt_connectMessageType.Mqtt_connectMessage) e; -JavaMQTTAdapter_client_id_var = (String) (mqtt_connect.client_id); -String uri; -if(mqtt_connect.tls) { -uri = "ssl://"; - -} else { -uri = "tcp://"; - -} -uri += mqtt_connect.host + ":" + mqtt_connect.portno; -JavaMQTTAdapter_broker_uri_var = (String) (uri); -mqtt_connect(); -}); - -Handler h617412264 = new Handler(); -h617412264.from(state_JavaMQTTAdapter_MQTTAdapterThing); -h617412264.event(mqtt_publishType); -h617412264.port(mqtt_port); -h617412264.action((Event e)->{ -final Mqtt_publishMessageType.Mqtt_publishMessage mqtt_publish = (Mqtt_publishMessageType.Mqtt_publishMessage) e; -mqtt_publish((String) (mqtt_publish.topic), ( byte[]) (mqtt_publish.payload), (int) (mqtt_publish.size)); -}); - -Handler h2020698344 = new Handler(); -h2020698344.from(state_JavaMQTTAdapter_MQTTAdapterThing); -h2020698344.event(mqtt_subscribeType); -h2020698344.port(mqtt_port); -h2020698344.action((Event e)->{ -final Mqtt_subscribeMessageType.Mqtt_subscribeMessage mqtt_subscribe = (Mqtt_subscribeMessageType.Mqtt_subscribeMessage) e; -mqtt_subscribe((String) (mqtt_subscribe.topic)); -}); - -state_JavaMQTTAdapter_MQTTAdapterThing.add(state_JavaMQTTAdapter_MQTTAdapterThing_Start); -state_JavaMQTTAdapter_MQTTAdapterThing.initial(state_JavaMQTTAdapter_MQTTAdapterThing_Start); -return state_JavaMQTTAdapter_MQTTAdapterThing; -} - -public Component buildBehavior(String session, Component root) { -if (root == null) { -//Init ports -mqtt_port = new Port("mqtt", this); -} else { -mqtt_port = ((JavaMQTTAdapter)root).mqtt_port; -} -if (session == null){ -//Init state machine -behavior = buildJavaMQTTAdapter_MQTTAdapterThing(); -} -return this; -} - - void setTopicPrefix(final String JavaMQTTAdapter_setTopicPrefix_src_var) { -JavaMQTTAdapter_topic_prefix_var = (String) (JavaMQTTAdapter_setTopicPrefix_src_var); -} - boolean mqtt_connect() { -try { -MemoryPersistence persistence = new MemoryPersistence(); -Logger.getLogger(this.getClass().getName()).log(Level.INFO, "MQTT Connect to: " + getJavaMQTTAdapter_broker_uri_var()); -MqttConnectOptions connOpts = new MqttConnectOptions(); -connOpts.setCleanSession(true); -connOpts.setAutomaticReconnect(true); -if(getJavaMQTTAdapter_username_var() != null && getJavaMQTTAdapter_password_var() != null) { -connOpts.setUserName(getJavaMQTTAdapter_username_var()); -connOpts.setPassword(getJavaMQTTAdapter_password_var().toCharArray()); - -} -if(getJavaMQTTAdapter_client_id_var() == null) { -JavaMQTTAdapter_client_id_var = (String) (MqttClient.generateClientId()); - -} -clientSub = new MqttClient(getJavaMQTTAdapter_broker_uri_var(), getJavaMQTTAdapter_client_id_var() + "_Sub", persistence); -clientPub = new MqttClient(getJavaMQTTAdapter_broker_uri_var(), getJavaMQTTAdapter_client_id_var() + "_Pub", persistence); -clientSub. setCallback(this); -clientSub.connect(connOpts); -clientPub.connect(connOpts); -} catch (org.eclipse.paho.client.mqttv3.MqttException ex) { -Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex); -return (boolean) (false); -} -return (boolean) (true); -} - boolean mqtt_publish(final String JavaMQTTAdapter_mqtt_publish_topic_var, final byte[] JavaMQTTAdapter_mqtt_publish_payload_var, final int JavaMQTTAdapter_mqtt_publish_size_var) { -if(clientPub == null) { -return (boolean) (false); - -} -try { - Logger.getLogger(this.getClass().getName()).log(Level.INFO, "MQTT Publish: " + JavaMQTTAdapter_mqtt_publish_topic_var + " -> " + new String(JavaMQTTAdapter_mqtt_publish_payload_var)); - MqttMessage message = new MqttMessage(JavaMQTTAdapter_mqtt_publish_payload_var); - if (getJavaMQTTAdapter_topic_prefix_var() != null) clientPub.publish(getJavaMQTTAdapter_topic_prefix_var() + JavaMQTTAdapter_mqtt_publish_topic_var, message); - else clientPub.publish(JavaMQTTAdapter_mqtt_publish_topic_var, message); - } catch (org.eclipse.paho.client.mqttv3.MqttException ex) { - Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex); -return (boolean) (false); -} -return (boolean) (true); -} - boolean mqtt_subscribe(final String JavaMQTTAdapter_mqtt_subscribe_topic_var) { -if(clientSub == null) { -return (boolean) (false); - -} -try { - Logger.getLogger(this.getClass().getName()).log(Level.INFO, "MQTT Subscribe: " + JavaMQTTAdapter_mqtt_subscribe_topic_var); - if (getJavaMQTTAdapter_topic_prefix_var() != null) clientSub.subscribe(getJavaMQTTAdapter_topic_prefix_var() + JavaMQTTAdapter_mqtt_subscribe_topic_var); - else clientSub.subscribe(JavaMQTTAdapter_mqtt_subscribe_topic_var); - } catch (org.eclipse.paho.client.mqttv3.MqttException ex) { - Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex); -return (boolean) (false); -} -return (boolean) (true); -} -public void messageArrived(final String JavaMQTTAdapter_messageArrived_topic_var, final org.eclipse.paho.client.mqttv3.MqttMessage JavaMQTTAdapter_messageArrived_m_var) { -System.out.print("Message arrived on topic "); -System.out.print(JavaMQTTAdapter_messageArrived_topic_var); -System.out.print("\n"); -} -public void connectionLost(final Throwable JavaMQTTAdapter_connectionLost_t_var) { -System.out.print("connectionLost \n"); -sendMqtt_disconnected_via_mqtt(); -} -public void deliveryComplete(final IMqttDeliveryToken JavaMQTTAdapter_deliveryComplete_imdt_var) { -System.out.print("deliveryComplete \n"); -} -public void connectComplete(final boolean JavaMQTTAdapter_connectComplete_reconnect_var, final String JavaMQTTAdapter_connectComplete_serverURI_var) { -System.out.print("connectComplete \n"); -sendMqtt_connected_via_mqtt(); -} -} diff --git a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/MQTTAdapterTest.java b/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/MQTTAdapterTest.java deleted file mode 100644 index 588c9acd3..000000000 --- a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/MQTTAdapterTest.java +++ /dev/null @@ -1,314 +0,0 @@ -/** - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - */ -/** - * File generated by the ThingML IDE - * /!\Do not edit this file/!\ - * In case of a bug in the generated code, - * please submit an issue on our GitHub - **/ - -package org.thingml.generated; - -import no.sintef.jasm.*; -import no.sintef.jasm.ext.*; - -import org.thingml.generated.api.*; -import org.thingml.generated.messages.*; - -import java.util.*; - -/** - * Definition for type : MQTTAdapterTest - **/ -public class MQTTAdapterTest extends Component implements IMQTTAdapterTest_clock, IMQTTAdapterTest_mqtt { - -private boolean debug = false; -public boolean isDebug() {return debug;} -public void setDebug(boolean debug) {this.debug = debug;} -public String toString() { -String result = "instance " + getName() + "\n"; -result += "\tclient_id = " + MQTTAdapterTest_client_id_var; -result += "\tbroker_host = " + MQTTAdapterTest_broker_host_var; -result += "\tbroker_port = " + MQTTAdapterTest_broker_port_var; -result += "\tbroker_user = " + MQTTAdapterTest_broker_user_var; -result += "\tbroker_pass = " + MQTTAdapterTest_broker_pass_var; -result += "\tbroker_tls = " + MQTTAdapterTest_broker_tls_var; -result += "\ttimer_id = " + MQTTAdapterTest_timer_id_var; -result += ""; -return result; -} - -public synchronized void timer_timeout_via_clock(short TimerMsgs_timer_timeout_id_var){ -final Event _msg = timer_timeoutType.instantiate(TimerMsgs_timer_timeout_id_var); -_msg.setPort(clock_port); -receive(_msg); -} - -public synchronized void mqtt_connected_via_mqtt(){ -final Event _msg = mqtt_connectedType.instantiate(); -_msg.setPort(mqtt_port); -receive(_msg); -} - -public synchronized void mqtt_disconnected_via_mqtt(){ -final Event _msg = mqtt_disconnectedType.instantiate(); -_msg.setPort(mqtt_port); -receive(_msg); -} - -public synchronized void mqtt_message_via_mqtt(String MQTTAdapterMsgs_mqtt_message_topic_var, byte[] MQTTAdapterMsgs_mqtt_message_payload_var, long MQTTAdapterMsgs_mqtt_message_size_var){ -final Event _msg = mqtt_messageType.instantiate(MQTTAdapterMsgs_mqtt_message_topic_var, MQTTAdapterMsgs_mqtt_message_payload_var, MQTTAdapterMsgs_mqtt_message_size_var); -_msg.setPort(mqtt_port); -receive(_msg); -} - -private void sendTimer_start_via_clock(short TimerMsgs_timer_start_id_var, int TimerMsgs_timer_start_time_var){ -clock_port.send(timer_startType.instantiate(TimerMsgs_timer_start_id_var, TimerMsgs_timer_start_time_var)); -} - -private void sendTimer_cancel_via_clock(short TimerMsgs_timer_cancel_id_var){ -clock_port.send(timer_cancelType.instantiate(TimerMsgs_timer_cancel_id_var)); -} - -private void sendMqtt_connect_via_mqtt(String MQTTAdapterMsgs_mqtt_connect_client_id_var, String MQTTAdapterMsgs_mqtt_connect_host_var, int MQTTAdapterMsgs_mqtt_connect_portno_var, boolean MQTTAdapterMsgs_mqtt_connect_tls_var){ -mqtt_port.send(mqtt_connectType.instantiate(MQTTAdapterMsgs_mqtt_connect_client_id_var, MQTTAdapterMsgs_mqtt_connect_host_var, MQTTAdapterMsgs_mqtt_connect_portno_var, MQTTAdapterMsgs_mqtt_connect_tls_var)); -} - -private void sendMqtt_disconnect_via_mqtt(){ -mqtt_port.send(mqtt_disconnectType.instantiate()); -} - -private void sendMqtt_publish_via_mqtt(String MQTTAdapterMsgs_mqtt_publish_topic_var, byte[] MQTTAdapterMsgs_mqtt_publish_payload_var, long MQTTAdapterMsgs_mqtt_publish_size_var){ -mqtt_port.send(mqtt_publishType.instantiate(MQTTAdapterMsgs_mqtt_publish_topic_var, MQTTAdapterMsgs_mqtt_publish_payload_var, MQTTAdapterMsgs_mqtt_publish_size_var)); -} - -private void sendMqtt_subscribe_via_mqtt(String MQTTAdapterMsgs_mqtt_subscribe_topic_var){ -mqtt_port.send(mqtt_subscribeType.instantiate(MQTTAdapterMsgs_mqtt_subscribe_topic_var)); -} - -private void sendMqtt_set_credentials_via_mqtt(String MQTTAdapterMsgs_mqtt_set_credentials_usr_var, String MQTTAdapterMsgs_mqtt_set_credentials_pwd_var){ -mqtt_port.send(mqtt_set_credentialsType.instantiate(MQTTAdapterMsgs_mqtt_set_credentials_usr_var, MQTTAdapterMsgs_mqtt_set_credentials_pwd_var)); -} - -private void sendMqtt_set_prefix_via_mqtt(String MQTTAdapterMsgs_mqtt_set_prefix_prefix_var){ -mqtt_port.send(mqtt_set_prefixType.instantiate(MQTTAdapterMsgs_mqtt_set_prefix_prefix_var)); -} - -//Attributes -private short MQTTAdapterTest_timer_id_var; -private String MQTTAdapterTest_broker_pass_var; -private String MQTTAdapterTest_broker_host_var; -private int MQTTAdapterTest_broker_port_var; -private boolean MQTTAdapterTest_broker_tls_var; -private String MQTTAdapterTest_client_id_var; -private String MQTTAdapterTest_broker_user_var; -//Ports -private Port clock_port; -private Port mqtt_port; -//Message types -protected final Mqtt_set_credentialsMessageType mqtt_set_credentialsType = new Mqtt_set_credentialsMessageType(); -protected final Mqtt_set_tls_certificatesMessageType mqtt_set_tls_certificatesType = new Mqtt_set_tls_certificatesMessageType(); -protected final Mqtt_connectMessageType mqtt_connectType = new Mqtt_connectMessageType(); -protected final Mqtt_disconnectMessageType mqtt_disconnectType = new Mqtt_disconnectMessageType(); -protected final Mqtt_connectedMessageType mqtt_connectedType = new Mqtt_connectedMessageType(); -protected final Mqtt_disconnectedMessageType mqtt_disconnectedType = new Mqtt_disconnectedMessageType(); -protected final Mqtt_publishMessageType mqtt_publishType = new Mqtt_publishMessageType(); -protected final Mqtt_subscribeMessageType mqtt_subscribeType = new Mqtt_subscribeMessageType(); -protected final Mqtt_set_prefixMessageType mqtt_set_prefixType = new Mqtt_set_prefixMessageType(); -protected final Mqtt_messageMessageType mqtt_messageType = new Mqtt_messageMessageType(); -protected final Timer_startMessageType timer_startType = new Timer_startMessageType(); -protected final Timer_cancelMessageType timer_cancelType = new Timer_cancelMessageType(); -protected final Timer_timeoutMessageType timer_timeoutType = new Timer_timeoutMessageType(); -//Empty Constructor -public MQTTAdapterTest() { -super(); -} - -//Getters and Setters for non readonly/final attributes -public short getMQTTAdapterTest_timer_id_var() { -return MQTTAdapterTest_timer_id_var; -} - -public MQTTAdapterTest initMQTTAdapterTest_timer_id_var(short MQTTAdapterTest_timer_id_var) { -this.MQTTAdapterTest_timer_id_var = MQTTAdapterTest_timer_id_var; -return this; -} - -public String getMQTTAdapterTest_broker_pass_var() { -return MQTTAdapterTest_broker_pass_var; -} - -public void setMQTTAdapterTest_broker_pass_var(String MQTTAdapterTest_broker_pass_var) { -this.MQTTAdapterTest_broker_pass_var = MQTTAdapterTest_broker_pass_var; -} - -public MQTTAdapterTest initMQTTAdapterTest_broker_pass_var(String MQTTAdapterTest_broker_pass_var) { -this.MQTTAdapterTest_broker_pass_var = MQTTAdapterTest_broker_pass_var; -return this; -} - -public String getMQTTAdapterTest_broker_host_var() { -return MQTTAdapterTest_broker_host_var; -} - -public void setMQTTAdapterTest_broker_host_var(String MQTTAdapterTest_broker_host_var) { -this.MQTTAdapterTest_broker_host_var = MQTTAdapterTest_broker_host_var; -} - -public MQTTAdapterTest initMQTTAdapterTest_broker_host_var(String MQTTAdapterTest_broker_host_var) { -this.MQTTAdapterTest_broker_host_var = MQTTAdapterTest_broker_host_var; -return this; -} - -public int getMQTTAdapterTest_broker_port_var() { -return MQTTAdapterTest_broker_port_var; -} - -public void setMQTTAdapterTest_broker_port_var(int MQTTAdapterTest_broker_port_var) { -this.MQTTAdapterTest_broker_port_var = MQTTAdapterTest_broker_port_var; -} - -public MQTTAdapterTest initMQTTAdapterTest_broker_port_var(int MQTTAdapterTest_broker_port_var) { -this.MQTTAdapterTest_broker_port_var = MQTTAdapterTest_broker_port_var; -return this; -} - -public boolean getMQTTAdapterTest_broker_tls_var() { -return MQTTAdapterTest_broker_tls_var; -} - -public void setMQTTAdapterTest_broker_tls_var(boolean MQTTAdapterTest_broker_tls_var) { -this.MQTTAdapterTest_broker_tls_var = MQTTAdapterTest_broker_tls_var; -} - -public MQTTAdapterTest initMQTTAdapterTest_broker_tls_var(boolean MQTTAdapterTest_broker_tls_var) { -this.MQTTAdapterTest_broker_tls_var = MQTTAdapterTest_broker_tls_var; -return this; -} - -public String getMQTTAdapterTest_client_id_var() { -return MQTTAdapterTest_client_id_var; -} - -public MQTTAdapterTest initMQTTAdapterTest_client_id_var(String MQTTAdapterTest_client_id_var) { -this.MQTTAdapterTest_client_id_var = MQTTAdapterTest_client_id_var; -return this; -} - -public String getMQTTAdapterTest_broker_user_var() { -return MQTTAdapterTest_broker_user_var; -} - -public void setMQTTAdapterTest_broker_user_var(String MQTTAdapterTest_broker_user_var) { -this.MQTTAdapterTest_broker_user_var = MQTTAdapterTest_broker_user_var; -} - -public MQTTAdapterTest initMQTTAdapterTest_broker_user_var(String MQTTAdapterTest_broker_user_var) { -this.MQTTAdapterTest_broker_user_var = MQTTAdapterTest_broker_user_var; -return this; -} - -//Getters for Ports -public Port getClock_port() { -return clock_port; -} -public Port getMqtt_port() { -return mqtt_port; -} -private CompositeState buildMQTTAdapterTest_MQTTAdapterTestSC(){ -final AtomicState state_MQTTAdapterTest_MQTTAdapterTestSC_DISCONNECTED = new AtomicState("DISCONNECTED"); -final AtomicState state_MQTTAdapterTest_MQTTAdapterTestSC_CONNECTED = new AtomicState("CONNECTED"); -state_MQTTAdapterTest_MQTTAdapterTestSC_CONNECTED.onEntry(()->{ -sendMqtt_set_prefix_via_mqtt((String) ("models18/")); -sendMqtt_subscribe_via_mqtt((String) ("#")); -publish_hello(); -sendTimer_start_via_clock((short) (getMQTTAdapterTest_timer_id_var()), (int) (5000)); -}); -Transition h2038827813 = new Transition(); -h2038827813.from(state_MQTTAdapterTest_MQTTAdapterTestSC_DISCONNECTED).to(state_MQTTAdapterTest_MQTTAdapterTestSC_CONNECTED); -h2038827813.event(mqtt_connectedType); -h2038827813.port(mqtt_port); -h2038827813.action((Event e)->{ -System.out.print("Client got mqtt_connected\n"); -}); - -Handler h1399391725 = new Handler(); -h1399391725.from(state_MQTTAdapterTest_MQTTAdapterTestSC_CONNECTED); -h1399391725.event(timer_timeoutType); -h1399391725.guard((Event e)->{ -final Timer_timeoutMessageType.Timer_timeoutMessage timer_timeout = (Timer_timeoutMessageType.Timer_timeoutMessage) e; -return timer_timeout.id == getMQTTAdapterTest_timer_id_var(); -}); - -h1399391725.port(clock_port); -h1399391725.action((Event e)->{ -final Timer_timeoutMessageType.Timer_timeoutMessage timer_timeout = (Timer_timeoutMessageType.Timer_timeoutMessage) e; -publish_hello(); -sendTimer_start_via_clock((short) (getMQTTAdapterTest_timer_id_var()), (int) (5000)); -}); - -Handler h1786959028 = new Handler(); -h1786959028.from(state_MQTTAdapterTest_MQTTAdapterTestSC_CONNECTED); -h1786959028.event(mqtt_messageType); -h1786959028.port(mqtt_port); -h1786959028.action((Event e)->{ -final Mqtt_messageMessageType.Mqtt_messageMessage mqtt_message = (Mqtt_messageMessageType.Mqtt_messageMessage) e; -System.out.println("RCV topic:"+mqtt_message.topic+" payload:" + mqtt_message.payload); -}); - -Transition h274480106 = new Transition(); -h274480106.from(state_MQTTAdapterTest_MQTTAdapterTestSC_CONNECTED).to(state_MQTTAdapterTest_MQTTAdapterTestSC_DISCONNECTED); -h274480106.event(mqtt_disconnectedType); -h274480106.port(mqtt_port); -h274480106.action((Event e)->{ -System.out.print("Client got mqtt_disconnected\n"); -}); - -final CompositeState state_MQTTAdapterTest_MQTTAdapterTestSC = new CompositeState("MQTTAdapterTestSC"); -state_MQTTAdapterTest_MQTTAdapterTestSC.onEntry(()->{ -if(getMQTTAdapterTest_broker_user_var() != null) { -sendMqtt_set_credentials_via_mqtt((String) (getMQTTAdapterTest_broker_user_var()), (String) (getMQTTAdapterTest_broker_pass_var())); - -} -sendMqtt_connect_via_mqtt((String) (getMQTTAdapterTest_client_id_var()), (String) (getMQTTAdapterTest_broker_host_var()), (int) (getMQTTAdapterTest_broker_port_var()), (boolean) (getMQTTAdapterTest_broker_tls_var())); -}); -state_MQTTAdapterTest_MQTTAdapterTestSC.add(state_MQTTAdapterTest_MQTTAdapterTestSC_DISCONNECTED); -state_MQTTAdapterTest_MQTTAdapterTestSC.add(state_MQTTAdapterTest_MQTTAdapterTestSC_CONNECTED); -state_MQTTAdapterTest_MQTTAdapterTestSC.initial(state_MQTTAdapterTest_MQTTAdapterTestSC_DISCONNECTED); -return state_MQTTAdapterTest_MQTTAdapterTestSC; -} - -public Component buildBehavior(String session, Component root) { -if (root == null) { -//Init ports -clock_port = new Port("clock", this); -mqtt_port = new Port("mqtt", this); -} else { -clock_port = ((MQTTAdapterTest)root).clock_port; -mqtt_port = ((MQTTAdapterTest)root).mqtt_port; -} -if (session == null){ -//Init state machine -behavior = buildMQTTAdapterTest_MQTTAdapterTestSC(); -} -return this; -} - - void publish_hello() { -sendMqtt_publish_via_mqtt((String) ("Hello"), ( byte[]) ("World".getBytes()), (long) (5)); -} -} diff --git a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/Main.java b/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/Main.java deleted file mode 100644 index 61070cc1b..000000000 --- a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/Main.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - */ -/** - * File generated by the ThingML IDE - * /!\Do not edit this file/!\ - * In case of a bug in the generated code, - * please submit an issue on our GitHub - **/ - -package org.thingml.generated; - -import no.sintef.jasm.*; -import no.sintef.jasm.ext.*; - -import org.thingml.generated.api.*; -import org.thingml.generated.messages.*; - -import java.util.*; -public class Main { -//Things -public static MQTTAdapterTest MQTTAdapterTest_test1; -public static TimerJava TimerJava_timer; -public static JavaMQTTAdapter JavaMQTTAdapter_adapter1; -public static void main(String args[]) { -//Things -MQTTAdapterTest_test1 = (MQTTAdapterTest) new MQTTAdapterTest(); -MQTTAdapterTest_test1.buildBehavior(null, null); -MQTTAdapterTest_test1.init(); -TimerJava_timer = (TimerJava) new TimerJava(); -TimerJava_timer.buildBehavior(null, null); -TimerJava_timer.init(); -JavaMQTTAdapter_adapter1 = (JavaMQTTAdapter) new JavaMQTTAdapter(); -JavaMQTTAdapter_adapter1.buildBehavior(null, null); -JavaMQTTAdapter_adapter1.init(); -//Connecting internal ports... -//Connectors -TimerJava_timer.getTimer_port().addListener(MQTTAdapterTest_test1.getClock_port()); -MQTTAdapterTest_test1.getClock_port().addListener(TimerJava_timer.getTimer_port()); -JavaMQTTAdapter_adapter1.getMqtt_port().addListener(MQTTAdapterTest_test1.getMqtt_port()); -MQTTAdapterTest_test1.getMqtt_port().addListener(JavaMQTTAdapter_adapter1.getMqtt_port()); -MQTTAdapterTest_test1.initMQTTAdapterTest_client_id_var((String) ("Test1")); -MQTTAdapterTest_test1.initMQTTAdapterTest_broker_host_var((String) ("mqtt.tutorials.tellucloud.com")); -MQTTAdapterTest_test1.initMQTTAdapterTest_broker_port_var((int) (1883)); -MQTTAdapterTest_test1.initMQTTAdapterTest_broker_user_var((String) ("models18")); -MQTTAdapterTest_test1.initMQTTAdapterTest_broker_pass_var((String) ("thingml")); -MQTTAdapterTest_test1.initMQTTAdapterTest_broker_tls_var((boolean) (false)); -MQTTAdapterTest_test1.initMQTTAdapterTest_timer_id_var((short) (1)); -JavaMQTTAdapter_adapter1.initJavaMQTTAdapter_broker_uri_var((String) ("tcp://localhost:1883")); -JavaMQTTAdapter_adapter1.initJavaMQTTAdapter_client_id_var((String) (null)); -JavaMQTTAdapter_adapter1.initJavaMQTTAdapter_username_var((String) (null)); -JavaMQTTAdapter_adapter1.initJavaMQTTAdapter_password_var((String) (null)); -JavaMQTTAdapter_adapter1.initJavaMQTTAdapter_topic_prefix_var((String) (null)); -//Init instances (queues, etc) -//Network components for external connectors -/*$NETWORK$*/ -//External Connectors -/*$EXT CONNECTORS$*/ -/*$START$*/ -TimerJava_timer.start(); -JavaMQTTAdapter_adapter1.start(); -MQTTAdapterTest_test1.start(); -//Hook to stop instances following client/server dependencies (clients firsts) -Runtime.getRuntime().addShutdownHook(new Thread() { -public void run() { -MQTTAdapterTest_test1.stop(); -JavaMQTTAdapter_adapter1.stop(); -TimerJava_timer.stop(); -/*$STOP$*/ -} -}); - -} -} diff --git a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/TimerJava.java b/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/TimerJava.java deleted file mode 100644 index c34cee06d..000000000 --- a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/TimerJava.java +++ /dev/null @@ -1,154 +0,0 @@ -/** - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - */ -/** - * File generated by the ThingML IDE - * /!\Do not edit this file/!\ - * In case of a bug in the generated code, - * please submit an issue on our GitHub - **/ - -package org.thingml.generated; - -import no.sintef.jasm.*; -import no.sintef.jasm.ext.*; - -import org.thingml.generated.api.*; -import org.thingml.generated.messages.*; - -import java.util.*; - -//START: @java_import annotation -import java.util.*; - -//END: @java_import annotation - -/** - * Definition for type : TimerJava - **/ -public class TimerJava extends Component implements ITimerJava_timer { - - - // START: @java_features annotation - - Hashtable tasks = new Hashtable(); - Timer timer = new java.util.Timer(); - - // END: @java_features annotation - -private boolean debug = false; -public boolean isDebug() {return debug;} -public void setDebug(boolean debug) {this.debug = debug;} -public String toString() { -String result = "instance " + getName() + "\n"; -result += ""; -return result; -} - -public synchronized void timer_start_via_timer(short TimerMsgs_timer_start_id_var, int TimerMsgs_timer_start_time_var){ -final Event _msg = timer_startType.instantiate(TimerMsgs_timer_start_id_var, TimerMsgs_timer_start_time_var); -_msg.setPort(timer_port); -receive(_msg); -} - -public synchronized void timer_cancel_via_timer(short TimerMsgs_timer_cancel_id_var){ -final Event _msg = timer_cancelType.instantiate(TimerMsgs_timer_cancel_id_var); -_msg.setPort(timer_port); -receive(_msg); -} - -private void sendTimer_timeout_via_timer(short TimerMsgs_timer_timeout_id_var){ -timer_port.send(timer_timeoutType.instantiate(TimerMsgs_timer_timeout_id_var)); -} - -//Attributes -//Ports -private Port timer_port; -//Message types -protected final Timer_startMessageType timer_startType = new Timer_startMessageType(); -protected final Timer_cancelMessageType timer_cancelType = new Timer_cancelMessageType(); -protected final Timer_timeoutMessageType timer_timeoutType = new Timer_timeoutMessageType(); -//Empty Constructor -public TimerJava() { -super(); -} - -//Getters and Setters for non readonly/final attributes -//Getters for Ports -public Port getTimer_port() { -return timer_port; -} -private CompositeState buildTimerJava_SoftTimer(){ -final AtomicState state_TimerJava_SoftTimer_default = new AtomicState("default"); -Handler h1498186511 = new Handler(); -h1498186511.from(state_TimerJava_SoftTimer_default); -h1498186511.event(timer_startType); -h1498186511.guard((Event e)->{ -final Timer_startMessageType.Timer_startMessage timer_start = (Timer_startMessageType.Timer_startMessage) e; -return timer_start.time > 0; -}); - -h1498186511.port(timer_port); -h1498186511.action((Event e)->{ -final Timer_startMessageType.Timer_startMessage timer_start = (Timer_startMessageType.Timer_startMessage) e; -startTimer((short) (timer_start.id), (int) (timer_start.time)); -}); - -Handler cancel = new Handler(); -cancel.from(state_TimerJava_SoftTimer_default); -cancel.event(timer_cancelType); -cancel.port(timer_port); -cancel.action((Event e)->{ -final Timer_cancelMessageType.Timer_cancelMessage timer_cancel = (Timer_cancelMessageType.Timer_cancelMessage) e; -cancel((short) (timer_cancel.id)); -}); - -final CompositeState state_TimerJava_SoftTimer = new CompositeState("SoftTimer"); -state_TimerJava_SoftTimer.add(state_TimerJava_SoftTimer_default); -state_TimerJava_SoftTimer.initial(state_TimerJava_SoftTimer_default); -return state_TimerJava_SoftTimer; -} - -public Component buildBehavior(String session, Component root) { -if (root == null) { -//Init ports -timer_port = new Port("timer", this); -} else { -timer_port = ((TimerJava)root).timer_port; -} -if (session == null){ -//Init state machine -behavior = buildTimerJava_SoftTimer(); -} -return this; -} - - void startTimer(final short TimerJava_startTimer_id_var, final int TimerJava_startTimer_delay_var) { -cancel((short) (TimerJava_startTimer_id_var)); -final int t_id = TimerJava_startTimer_id_var; -TimerTask t = new TimerTask() { public void run(){ -sendTimer_timeout_via_timer((short) (t_id)); - - } }; - tasks.put(t_id, t); - timer.schedule(t, TimerJava_startTimer_delay_var); -} - void cancel(final short TimerJava_cancel_id_var) { -TimerTask t = tasks.get(TimerJava_cancel_id_var); -if (t != null) t.cancel(); -timer.purge(); -} -} diff --git a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/api/IJavaMQTTAdapter_mqtt.java b/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/api/IJavaMQTTAdapter_mqtt.java deleted file mode 100644 index 309e40853..000000000 --- a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/api/IJavaMQTTAdapter_mqtt.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - */ -package org.thingml.generated.api; - -import org.thingml.generated.api.*; - -public interface IJavaMQTTAdapter_mqtt{ -void mqtt_connect_via_mqtt(String MQTTAdapterMsgs_mqtt_connect_client_id_var, String MQTTAdapterMsgs_mqtt_connect_host_var, int MQTTAdapterMsgs_mqtt_connect_portno_var, boolean MQTTAdapterMsgs_mqtt_connect_tls_var); -void mqtt_disconnect_via_mqtt(); -void mqtt_publish_via_mqtt(String MQTTAdapterMsgs_mqtt_publish_topic_var, byte[] MQTTAdapterMsgs_mqtt_publish_payload_var, long MQTTAdapterMsgs_mqtt_publish_size_var); -void mqtt_subscribe_via_mqtt(String MQTTAdapterMsgs_mqtt_subscribe_topic_var); -void mqtt_set_credentials_via_mqtt(String MQTTAdapterMsgs_mqtt_set_credentials_usr_var, String MQTTAdapterMsgs_mqtt_set_credentials_pwd_var); -void mqtt_set_prefix_via_mqtt(String MQTTAdapterMsgs_mqtt_set_prefix_prefix_var); -} \ No newline at end of file diff --git a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/api/IJavaMQTTAdapter_mqttClient.java b/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/api/IJavaMQTTAdapter_mqttClient.java deleted file mode 100644 index e0d3e2ff7..000000000 --- a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/api/IJavaMQTTAdapter_mqttClient.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - */ -package org.thingml.generated.api; - -import org.thingml.generated.api.*; - -public interface IJavaMQTTAdapter_mqttClient{ -void mqtt_connected_from_mqtt(); -void mqtt_disconnected_from_mqtt(); -void mqtt_message_from_mqtt(String MQTTAdapterMsgs_mqtt_message_topic_var, byte[] MQTTAdapterMsgs_mqtt_message_payload_var, long MQTTAdapterMsgs_mqtt_message_size_var); -} \ No newline at end of file diff --git a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/api/IMQTTAdapterTest_clock.java b/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/api/IMQTTAdapterTest_clock.java deleted file mode 100644 index 1550ae742..000000000 --- a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/api/IMQTTAdapterTest_clock.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - */ -package org.thingml.generated.api; - -import org.thingml.generated.api.*; - -public interface IMQTTAdapterTest_clock{ -void timer_timeout_via_clock(short TimerMsgs_timer_timeout_id_var); -} \ No newline at end of file diff --git a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/api/IMQTTAdapterTest_clockClient.java b/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/api/IMQTTAdapterTest_clockClient.java deleted file mode 100644 index 72d0e2409..000000000 --- a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/api/IMQTTAdapterTest_clockClient.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - */ -package org.thingml.generated.api; - -import org.thingml.generated.api.*; - -public interface IMQTTAdapterTest_clockClient{ -void timer_start_from_clock(short TimerMsgs_timer_start_id_var, int TimerMsgs_timer_start_time_var); -void timer_cancel_from_clock(short TimerMsgs_timer_cancel_id_var); -} \ No newline at end of file diff --git a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/api/IMQTTAdapterTest_mqtt.java b/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/api/IMQTTAdapterTest_mqtt.java deleted file mode 100644 index 3e72037da..000000000 --- a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/api/IMQTTAdapterTest_mqtt.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - */ -package org.thingml.generated.api; - -import org.thingml.generated.api.*; - -public interface IMQTTAdapterTest_mqtt{ -void mqtt_connected_via_mqtt(); -void mqtt_disconnected_via_mqtt(); -void mqtt_message_via_mqtt(String MQTTAdapterMsgs_mqtt_message_topic_var, byte[] MQTTAdapterMsgs_mqtt_message_payload_var, long MQTTAdapterMsgs_mqtt_message_size_var); -} \ No newline at end of file diff --git a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/api/IMQTTAdapterTest_mqttClient.java b/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/api/IMQTTAdapterTest_mqttClient.java deleted file mode 100644 index c00410acb..000000000 --- a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/api/IMQTTAdapterTest_mqttClient.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - */ -package org.thingml.generated.api; - -import org.thingml.generated.api.*; - -public interface IMQTTAdapterTest_mqttClient{ -void mqtt_connect_from_mqtt(String MQTTAdapterMsgs_mqtt_connect_client_id_var, String MQTTAdapterMsgs_mqtt_connect_host_var, int MQTTAdapterMsgs_mqtt_connect_portno_var, boolean MQTTAdapterMsgs_mqtt_connect_tls_var); -void mqtt_disconnect_from_mqtt(); -void mqtt_publish_from_mqtt(String MQTTAdapterMsgs_mqtt_publish_topic_var, byte[] MQTTAdapterMsgs_mqtt_publish_payload_var, long MQTTAdapterMsgs_mqtt_publish_size_var); -void mqtt_subscribe_from_mqtt(String MQTTAdapterMsgs_mqtt_subscribe_topic_var); -void mqtt_set_credentials_from_mqtt(String MQTTAdapterMsgs_mqtt_set_credentials_usr_var, String MQTTAdapterMsgs_mqtt_set_credentials_pwd_var); -void mqtt_set_prefix_from_mqtt(String MQTTAdapterMsgs_mqtt_set_prefix_prefix_var); -} \ No newline at end of file diff --git a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/api/ITimerJava_timer.java b/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/api/ITimerJava_timer.java deleted file mode 100644 index 3d0448bde..000000000 --- a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/api/ITimerJava_timer.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - */ -package org.thingml.generated.api; - -import org.thingml.generated.api.*; - -public interface ITimerJava_timer{ -void timer_start_via_timer(short TimerMsgs_timer_start_id_var, int TimerMsgs_timer_start_time_var); -void timer_cancel_via_timer(short TimerMsgs_timer_cancel_id_var); -} \ No newline at end of file diff --git a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/api/ITimerJava_timerClient.java b/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/api/ITimerJava_timerClient.java deleted file mode 100644 index 2830a9a0a..000000000 --- a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/api/ITimerJava_timerClient.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - */ -package org.thingml.generated.api; - -import org.thingml.generated.api.*; - -public interface ITimerJava_timerClient{ -void timer_timeout_from_timer(short TimerMsgs_timer_timeout_id_var); -} \ No newline at end of file diff --git a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_connectMessageType.java b/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_connectMessageType.java deleted file mode 100644 index 0eadab098..000000000 --- a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_connectMessageType.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - */ -/** - * File generated by the ThingML IDE - * /!\Do not edit this file/!\ - * In case of a bug in the generated code, - * please submit an issue on our GitHub - **/ - -package org.thingml.generated.messages; - -import no.sintef.jasm.*; -import no.sintef.jasm.ext.*; - -import java.util.*; -import java.nio.*; - -public class Mqtt_connectMessageType extends EventType { -public Mqtt_connectMessageType(short code) {super("mqtt_connect", code); -} - -public Mqtt_connectMessageType() { -super("mqtt_connect", (short) 0); -} - -public Event instantiate(final String client_id, final String host, final int portno, final boolean tls) { return new Mqtt_connectMessage(this, client_id, host, portno, tls); } -public Event instantiate(Map params) {return instantiate((String) params.get("client_id"), (String) params.get("host"), (Integer) params.get("portno"), (Boolean) params.get("tls")); -} - -public class Mqtt_connectMessage extends Event implements java.io.Serializable { - -public final String client_id; -public final String host; -public final int portno; -public final boolean tls; -public String toString(){ -return "mqtt_connect (" + "client_id: " + client_id + ", " + "host: " + host + ", " + "portno: " + portno + ", " + "tls: " + tls + ")"; -} - -protected Mqtt_connectMessage(EventType type, final String client_id, final String host, final int portno, final boolean tls) { -super(type); -this.client_id = client_id; -this.host = host; -this.portno = portno; -this.tls = tls; -} -public Event clone() { -return instantiate(this.client_id, this.host, this.portno, this.tls); -}} - -} - diff --git a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_connectedMessageType.java b/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_connectedMessageType.java deleted file mode 100644 index fc079dd95..000000000 --- a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_connectedMessageType.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - */ -/** - * File generated by the ThingML IDE - * /!\Do not edit this file/!\ - * In case of a bug in the generated code, - * please submit an issue on our GitHub - **/ - -package org.thingml.generated.messages; - -import no.sintef.jasm.*; -import no.sintef.jasm.ext.*; - -import java.util.*; -import java.nio.*; - -public class Mqtt_connectedMessageType extends EventType { -public Mqtt_connectedMessageType(short code) {super("mqtt_connected", code); -} - -public Mqtt_connectedMessageType() { -super("mqtt_connected", (short) 0); -} - -public Event instantiate() { return new Mqtt_connectedMessage(this); } -public Event instantiate(Map params) {return instantiate(); -} - -public class Mqtt_connectedMessage extends Event implements java.io.Serializable { - -public String toString(){ -return "mqtt_connected (" + ")"; -} - -protected Mqtt_connectedMessage(EventType type) { -super(type); -} -public Event clone() { -return instantiate(); -}} - -} - diff --git a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_disconnectMessageType.java b/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_disconnectMessageType.java deleted file mode 100644 index 16e04188d..000000000 --- a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_disconnectMessageType.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - */ -/** - * File generated by the ThingML IDE - * /!\Do not edit this file/!\ - * In case of a bug in the generated code, - * please submit an issue on our GitHub - **/ - -package org.thingml.generated.messages; - -import no.sintef.jasm.*; -import no.sintef.jasm.ext.*; - -import java.util.*; -import java.nio.*; - -public class Mqtt_disconnectMessageType extends EventType { -public Mqtt_disconnectMessageType(short code) {super("mqtt_disconnect", code); -} - -public Mqtt_disconnectMessageType() { -super("mqtt_disconnect", (short) 0); -} - -public Event instantiate() { return new Mqtt_disconnectMessage(this); } -public Event instantiate(Map params) {return instantiate(); -} - -public class Mqtt_disconnectMessage extends Event implements java.io.Serializable { - -public String toString(){ -return "mqtt_disconnect (" + ")"; -} - -protected Mqtt_disconnectMessage(EventType type) { -super(type); -} -public Event clone() { -return instantiate(); -}} - -} - diff --git a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_disconnectedMessageType.java b/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_disconnectedMessageType.java deleted file mode 100644 index 9dc3bb9d9..000000000 --- a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_disconnectedMessageType.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - */ -/** - * File generated by the ThingML IDE - * /!\Do not edit this file/!\ - * In case of a bug in the generated code, - * please submit an issue on our GitHub - **/ - -package org.thingml.generated.messages; - -import no.sintef.jasm.*; -import no.sintef.jasm.ext.*; - -import java.util.*; -import java.nio.*; - -public class Mqtt_disconnectedMessageType extends EventType { -public Mqtt_disconnectedMessageType(short code) {super("mqtt_disconnected", code); -} - -public Mqtt_disconnectedMessageType() { -super("mqtt_disconnected", (short) 0); -} - -public Event instantiate() { return new Mqtt_disconnectedMessage(this); } -public Event instantiate(Map params) {return instantiate(); -} - -public class Mqtt_disconnectedMessage extends Event implements java.io.Serializable { - -public String toString(){ -return "mqtt_disconnected (" + ")"; -} - -protected Mqtt_disconnectedMessage(EventType type) { -super(type); -} -public Event clone() { -return instantiate(); -}} - -} - diff --git a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_messageMessageType.java b/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_messageMessageType.java deleted file mode 100644 index 570e3d51e..000000000 --- a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_messageMessageType.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - */ -/** - * File generated by the ThingML IDE - * /!\Do not edit this file/!\ - * In case of a bug in the generated code, - * please submit an issue on our GitHub - **/ - -package org.thingml.generated.messages; - -import no.sintef.jasm.*; -import no.sintef.jasm.ext.*; - -import java.util.*; -import java.nio.*; - -public class Mqtt_messageMessageType extends EventType { -public Mqtt_messageMessageType(short code) {super("mqtt_message", code); -} - -public Mqtt_messageMessageType() { -super("mqtt_message", (short) 0); -} - -public Event instantiate(final String topic, final byte[] payload, final long size) { return new Mqtt_messageMessage(this, topic, payload, size); } -public Event instantiate(Map params) {return instantiate((String) params.get("topic"), ( byte[]) params.get("payload"), (Long) params.get("size")); -} - -public class Mqtt_messageMessage extends Event implements java.io.Serializable { - -public final String topic; -public final byte[] payload; -public final long size; -public String toString(){ -return "mqtt_message (" + "topic: " + topic + ", " + "payload: " + payload + ", " + "size: " + size + ")"; -} - -protected Mqtt_messageMessage(EventType type, final String topic, final byte[] payload, final long size) { -super(type); -this.topic = topic; -this.payload = payload; -this.size = size; -} -public Event clone() { -return instantiate(this.topic, this.payload, this.size); -}} - -} - diff --git a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_publishMessageType.java b/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_publishMessageType.java deleted file mode 100644 index 56f320064..000000000 --- a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_publishMessageType.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - */ -/** - * File generated by the ThingML IDE - * /!\Do not edit this file/!\ - * In case of a bug in the generated code, - * please submit an issue on our GitHub - **/ - -package org.thingml.generated.messages; - -import no.sintef.jasm.*; -import no.sintef.jasm.ext.*; - -import java.util.*; -import java.nio.*; - -public class Mqtt_publishMessageType extends EventType { -public Mqtt_publishMessageType(short code) {super("mqtt_publish", code); -} - -public Mqtt_publishMessageType() { -super("mqtt_publish", (short) 0); -} - -public Event instantiate(final String topic, final byte[] payload, final long size) { return new Mqtt_publishMessage(this, topic, payload, size); } -public Event instantiate(Map params) {return instantiate((String) params.get("topic"), ( byte[]) params.get("payload"), (Long) params.get("size")); -} - -public class Mqtt_publishMessage extends Event implements java.io.Serializable { - -public final String topic; -public final byte[] payload; -public final long size; -public String toString(){ -return "mqtt_publish (" + "topic: " + topic + ", " + "payload: " + payload + ", " + "size: " + size + ")"; -} - -protected Mqtt_publishMessage(EventType type, final String topic, final byte[] payload, final long size) { -super(type); -this.topic = topic; -this.payload = payload; -this.size = size; -} -public Event clone() { -return instantiate(this.topic, this.payload, this.size); -}} - -} - diff --git a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_set_credentialsMessageType.java b/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_set_credentialsMessageType.java deleted file mode 100644 index 587b8b4fc..000000000 --- a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_set_credentialsMessageType.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - */ -/** - * File generated by the ThingML IDE - * /!\Do not edit this file/!\ - * In case of a bug in the generated code, - * please submit an issue on our GitHub - **/ - -package org.thingml.generated.messages; - -import no.sintef.jasm.*; -import no.sintef.jasm.ext.*; - -import java.util.*; -import java.nio.*; - -public class Mqtt_set_credentialsMessageType extends EventType { -public Mqtt_set_credentialsMessageType(short code) {super("mqtt_set_credentials", code); -} - -public Mqtt_set_credentialsMessageType() { -super("mqtt_set_credentials", (short) 0); -} - -public Event instantiate(final String usr, final String pwd) { return new Mqtt_set_credentialsMessage(this, usr, pwd); } -public Event instantiate(Map params) {return instantiate((String) params.get("usr"), (String) params.get("pwd")); -} - -public class Mqtt_set_credentialsMessage extends Event implements java.io.Serializable { - -public final String usr; -public final String pwd; -public String toString(){ -return "mqtt_set_credentials (" + "usr: " + usr + ", " + "pwd: " + pwd + ")"; -} - -protected Mqtt_set_credentialsMessage(EventType type, final String usr, final String pwd) { -super(type); -this.usr = usr; -this.pwd = pwd; -} -public Event clone() { -return instantiate(this.usr, this.pwd); -}} - -} - diff --git a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_set_prefixMessageType.java b/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_set_prefixMessageType.java deleted file mode 100644 index e58170989..000000000 --- a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_set_prefixMessageType.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - */ -/** - * File generated by the ThingML IDE - * /!\Do not edit this file/!\ - * In case of a bug in the generated code, - * please submit an issue on our GitHub - **/ - -package org.thingml.generated.messages; - -import no.sintef.jasm.*; -import no.sintef.jasm.ext.*; - -import java.util.*; -import java.nio.*; - -public class Mqtt_set_prefixMessageType extends EventType { -public Mqtt_set_prefixMessageType(short code) {super("mqtt_set_prefix", code); -} - -public Mqtt_set_prefixMessageType() { -super("mqtt_set_prefix", (short) 0); -} - -public Event instantiate(final String prefix) { return new Mqtt_set_prefixMessage(this, prefix); } -public Event instantiate(Map params) {return instantiate((String) params.get("prefix")); -} - -public class Mqtt_set_prefixMessage extends Event implements java.io.Serializable { - -public final String prefix; -public String toString(){ -return "mqtt_set_prefix (" + "prefix: " + prefix + ")"; -} - -protected Mqtt_set_prefixMessage(EventType type, final String prefix) { -super(type); -this.prefix = prefix; -} -public Event clone() { -return instantiate(this.prefix); -}} - -} - diff --git a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_set_tls_certificatesMessageType.java b/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_set_tls_certificatesMessageType.java deleted file mode 100644 index 9ccff4ee4..000000000 --- a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_set_tls_certificatesMessageType.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - */ -/** - * File generated by the ThingML IDE - * /!\Do not edit this file/!\ - * In case of a bug in the generated code, - * please submit an issue on our GitHub - **/ - -package org.thingml.generated.messages; - -import no.sintef.jasm.*; -import no.sintef.jasm.ext.*; - -import java.util.*; -import java.nio.*; - -public class Mqtt_set_tls_certificatesMessageType extends EventType { -public Mqtt_set_tls_certificatesMessageType(short code) {super("mqtt_set_tls_certificates", code); -} - -public Mqtt_set_tls_certificatesMessageType() { -super("mqtt_set_tls_certificates", (short) 0); -} - -public Event instantiate(final String cafile, final String capath, final String certfile, final String keyfile) { return new Mqtt_set_tls_certificatesMessage(this, cafile, capath, certfile, keyfile); } -public Event instantiate(Map params) {return instantiate((String) params.get("cafile"), (String) params.get("capath"), (String) params.get("certfile"), (String) params.get("keyfile")); -} - -public class Mqtt_set_tls_certificatesMessage extends Event implements java.io.Serializable { - -public final String cafile; -public final String capath; -public final String certfile; -public final String keyfile; -public String toString(){ -return "mqtt_set_tls_certificates (" + "cafile: " + cafile + ", " + "capath: " + capath + ", " + "certfile: " + certfile + ", " + "keyfile: " + keyfile + ")"; -} - -protected Mqtt_set_tls_certificatesMessage(EventType type, final String cafile, final String capath, final String certfile, final String keyfile) { -super(type); -this.cafile = cafile; -this.capath = capath; -this.certfile = certfile; -this.keyfile = keyfile; -} -public Event clone() { -return instantiate(this.cafile, this.capath, this.certfile, this.keyfile); -}} - -} - diff --git a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_subscribeMessageType.java b/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_subscribeMessageType.java deleted file mode 100644 index 6b4f6934a..000000000 --- a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Mqtt_subscribeMessageType.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - */ -/** - * File generated by the ThingML IDE - * /!\Do not edit this file/!\ - * In case of a bug in the generated code, - * please submit an issue on our GitHub - **/ - -package org.thingml.generated.messages; - -import no.sintef.jasm.*; -import no.sintef.jasm.ext.*; - -import java.util.*; -import java.nio.*; - -public class Mqtt_subscribeMessageType extends EventType { -public Mqtt_subscribeMessageType(short code) {super("mqtt_subscribe", code); -} - -public Mqtt_subscribeMessageType() { -super("mqtt_subscribe", (short) 0); -} - -public Event instantiate(final String topic) { return new Mqtt_subscribeMessage(this, topic); } -public Event instantiate(Map params) {return instantiate((String) params.get("topic")); -} - -public class Mqtt_subscribeMessage extends Event implements java.io.Serializable { - -public final String topic; -public String toString(){ -return "mqtt_subscribe (" + "topic: " + topic + ")"; -} - -protected Mqtt_subscribeMessage(EventType type, final String topic) { -super(type); -this.topic = topic; -} -public Event clone() { -return instantiate(this.topic); -}} - -} - diff --git a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Timer_cancelMessageType.java b/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Timer_cancelMessageType.java deleted file mode 100644 index ace9cf892..000000000 --- a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Timer_cancelMessageType.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - */ -/** - * File generated by the ThingML IDE - * /!\Do not edit this file/!\ - * In case of a bug in the generated code, - * please submit an issue on our GitHub - **/ - -package org.thingml.generated.messages; - -import no.sintef.jasm.*; -import no.sintef.jasm.ext.*; - -import java.util.*; -import java.nio.*; - -public class Timer_cancelMessageType extends EventType { -public Timer_cancelMessageType(short code) {super("timer_cancel", code); -} - -public Timer_cancelMessageType() { -super("timer_cancel", (short) 0); -} - -public Event instantiate(final short id) { return new Timer_cancelMessage(this, id); } -public Event instantiate(Map params) {return instantiate((Short) params.get("id")); -} - -public class Timer_cancelMessage extends Event implements java.io.Serializable { - -public final short id; -public String toString(){ -return "timer_cancel (" + "id: " + id + ")"; -} - -protected Timer_cancelMessage(EventType type, final short id) { -super(type); -this.id = id; -} -public Event clone() { -return instantiate(this.id); -}} - -} - diff --git a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Timer_startMessageType.java b/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Timer_startMessageType.java deleted file mode 100644 index a69a66a13..000000000 --- a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Timer_startMessageType.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - */ -/** - * File generated by the ThingML IDE - * /!\Do not edit this file/!\ - * In case of a bug in the generated code, - * please submit an issue on our GitHub - **/ - -package org.thingml.generated.messages; - -import no.sintef.jasm.*; -import no.sintef.jasm.ext.*; - -import java.util.*; -import java.nio.*; - -public class Timer_startMessageType extends EventType { -public Timer_startMessageType(short code) {super("timer_start", code); -} - -public Timer_startMessageType() { -super("timer_start", (short) 0); -} - -public Event instantiate(final short id, final int time) { return new Timer_startMessage(this, id, time); } -public Event instantiate(Map params) {return instantiate((Short) params.get("id"), (Integer) params.get("time")); -} - -public class Timer_startMessage extends Event implements java.io.Serializable { - -public final short id; -public final int time; -public String toString(){ -return "timer_start (" + "id: " + id + ", " + "time: " + time + ")"; -} - -protected Timer_startMessage(EventType type, final short id, final int time) { -super(type); -this.id = id; -this.time = time; -} -public Event clone() { -return instantiate(this.id, this.time); -}} - -} - diff --git a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Timer_timeoutMessageType.java b/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Timer_timeoutMessageType.java deleted file mode 100644 index 025cb68c6..000000000 --- a/doc/examples/thingml-gen/java/MQTTAdapterTest/src/main/java/org/thingml/generated/messages/Timer_timeoutMessageType.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - */ -/** - * File generated by the ThingML IDE - * /!\Do not edit this file/!\ - * In case of a bug in the generated code, - * please submit an issue on our GitHub - **/ - -package org.thingml.generated.messages; - -import no.sintef.jasm.*; -import no.sintef.jasm.ext.*; - -import java.util.*; -import java.nio.*; - -public class Timer_timeoutMessageType extends EventType { -public Timer_timeoutMessageType(short code) {super("timer_timeout", code); -} - -public Timer_timeoutMessageType() { -super("timer_timeout", (short) 0); -} - -public Event instantiate(final short id) { return new Timer_timeoutMessage(this, id); } -public Event instantiate(Map params) {return instantiate((Short) params.get("id")); -} - -public class Timer_timeoutMessage extends Event implements java.io.Serializable { - -public final short id; -public String toString(){ -return "timer_timeout (" + "id: " + id + ")"; -} - -protected Timer_timeoutMessage(EventType type, final short id) { -super(type); -this.id = id; -} -public Event clone() { -return instantiate(this.id); -}} - -} - diff --git a/doc/examples/thingml-gen/posix/Ping/Makefile b/doc/examples/thingml-gen/posix/Ping/Makefile deleted file mode 100644 index 660aa7c06..000000000 --- a/doc/examples/thingml-gen/posix/Ping/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -# CC = /*CC*/ -LIBS = -lpthread -CFLAGS = -O2 -w -SRCS = PingServer.c PingClient.c Ping_cfg.c runtime.c -OBJS = PingServer.o PingClient.o Ping_cfg.o runtime.o - -all : Ping - -.c.o : - ${CC} ${CFLAGS} -c $< - -.cpp.o : - ${CC} ${CFLAGS} -c $< - -Ping : $(OBJS) - $(CC) -o $@ $(OBJS) $(LIBS) -lm - -clean: - rm -f *.o *~ Ping diff --git a/doc/examples/thingml-gen/posix/Ping/Ping b/doc/examples/thingml-gen/posix/Ping/Ping deleted file mode 100644 index ea7737ebeba0df91f9fb2adc8dbec604cc8d5a86..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 15560 zcmeHOe{@q-p1(;N2)~kmpjB{qD(r$vY_%XPGA5-!iUley>Mr7I$d5LfrZsti!kN)x zfkUP++f~M8oSAbvyQ4d^%W>4@Fz9-05C&X!cDK4X<2mEeu7jG0#3)7N1gq#hu0@p&T4lJ~Kc}CJ1I*c0hBwI+7>MJI% z$m(?eMGJlU}9Js}%B*4v}FbNoD`2Z*(;a zyUkWFIO4rTSRKC?Dalf5d|L}qK6VLbLA^X9X`QG~QmJ=4^mzYtwJ*K9g~VD>-)Mee zqWzMJ>e&sk=*9&#H^f5oV$pc2YhKsF1@jivc#<8S8+pIUKFO|Fy^hx;{iuMWHc!Px zF+ki*p0VhoUKt)h zO4DSpN-4y-XK^PR=F|}xc(^&RF&1X(%1!E8QLr=?NG8KcUB0ZeFslYT z;vqE}k7`UJ?I|tXRSI#T&4Cd@v5w$<1wAg5jJC!DF$NL{YSE5(p;Wh;igOioD@Yw$ zz#@@YD%r-uU9hdHkEbrr6}<owpq zrb)+dz~P`mYBb>E3n*iE8Sse)yv2Y|GT?0n+-bl&4LFUDOkDg=rlk76^P_#pTylY(~BJOZB&>W$|KD_K|F;@ZjkdY5>G>s z%W(cV;%&q~#rbE5C)eltIscEulgo2`oc}xG$p!Hh4XJ+s<22Oc%GV`rRb`D#lP+Seq=)a-iq0C zknyLt&)P>N8Grg+fBK!X{(l;vPWq2m%sS)rvh43J=JQZXzcb(hoIOcwCOZ!e138BN zL|ilLh#6p4wXp0dcw|Q=bte07==$j#3b#WI<-e~_zkH8B{g%Jy)S1TS`s0}@yb<`1 zAI?l6a$LcCTJ|4c{G4v@(BEQ!*ZJr5f%todo&NOOo2DNkOEj#LHw;igeyCu7!x0+A zh)34<0+p}xZ~K57IDF9t1OD_G|KaSde#!XGMMS5%qA=$GR z@_E<6+c2q@9HQbi0C_RO?_HEZt)Fn3X}a24QhS~k*?);5*TMT76g1<6Te!atpn$-c zqxfq_-nIQ+jG*X8AF5eI)lgIQYVM+H*70iQe*;AW)bQ-d&-3|XHooGJy9@ESBd<+F zk5dyc=otHR-OC+_q+&UZ_xj!y6_`8CO|FA092jix!ZX?$RGhg)VLchk@fAFLcCBzc zN6UuZijCBY|3sz!-ue3=r?+A?0qHje$c^iB-I!LWi_cS-yT4$LCOVlbc4`Be>(VfzEu zq2;|cL?E?1yA3(l!Ef8LU3$iv?ckZuv#p@ivFgnF4Y|+26vuO2lhOW@D1-gY2K(0m z;wx?TD&)BRN{!r({l~x*?Kfd9=w0%}WQAp){**?4$#ax{9QpK{*(X6t z*Tcx7C8r^vjirUAjxo%I^L)k5J%mAs^r8G;MwGj+YGJtqq9M}fYhG8KY0AEh9-JPJ zaYS!EMIPi8I0;evK{gFOeWW^b_;-%%w~==p%vfHF^bA|HmAG3|H4qMy%rB9-n+v=K z>9-x(HDG+{qkzAM+@88CS!A*OdTLJddLBI+e0PiZh0ImbMy1ilgo2IRi#CSc3QIlj za~(XVKb;=MbUnSF^VGNOqX_KNKO|34{0>yn1MeeX1AUb1f@cOu?wEZ)3|X?95e_d9 zP@RvY?LPo^-2MoaP?%gndh`rDW{-2}dZ5ScLF6ex;jfT=L6>MIbO0mD$2a!|bctI^t1~uK51C*r1y~PotDLY&o{t}h{jVM1h_r*nr59J@kSgnHWk-lOZdhL%va*=%> z?ykKVj3v!pWBFE;U{(75;rAw624|Czxr2-CZKKHhgOln}w8v*wxEZK+dD?y*sCU=1 z3LMCXyfEH+y!wOF#z6x8_wIU*gv?c^?K!7{cocfQ)7}8Pc-l$awQK#s7kgf`q+fO& z>?YmApUym-n`}9;?JeHy6X|JBLktyp$pD`p0}5Q6d*VFC#lSBp@GnsLKnn@I{4v%; z9zTR-r$B}m(9F%9LZOVW>hs)c)(Z*bNtw$GLdJKe?+#x&?_1|(j3`%zc|bj1PZd%U%Wr|Bl~lO7(B$^SdGaUPJnP9W3OhzV7ciV(~9JoqCVV zugB!^ZSdXWQ;p+$_6UU@-j!)xMi|oXoThL*q%=n3tqPkRWs1k+QCRJku!pT*bK3^C zepw>Xk=Q`8(`}2ri1|N9{^+@UemC+5(4-hv(HivaZtyjqp*`68Uj59dK7eq zm9dkcHK3Eg$=x)$iSfvht zZU=oG^Z@8NPe z%+lqyOrJQ`(PtU!CY&~d2I1FhNkF9X^5{3pNxtfAK0idVPWN(WlKTy zy=m6f1e1Opt}cwzL;^%2{BB&Gz^6zMv<8=ki{$Sl{C1~%r`6}I?6K85m5t+_mHs16 zx9^zKv2sG4v(hIRUeA7r_e0P4`;qE7iff+;=hE1ZgTFEx-$ubj|;JW64tc0y8SsXfimZ$rFZO8O#^KV!fvZp?_}OV&>Qs6vtVxW@a;Ll2=~zK7Bm1Wy--UJH zA(F3ix~*HB4)XH_;NB1Od3yX(|9Y&eoln76lt^y|=J_D>%yC@<{3YO5a!LJ0@(n`X z+>a3O*C0RJB>yeoXMoc$Xqm{)Uf{#PuaO`q;roHRv3@N!;YWcl1a6+!v|crqk*D>m z3;1}G9a_&i%iy%WwE=gT|pr5 zPG5WAYY%+wf&ViPbdL9O+l_+Cio|1r|3o89@~;U2`OI)Qyd05x(lwXpy!Z@T_|7_A z=*egL6_Wo(3(xU27CBk|@x^=x73{Nmi4?y1_E+dUUIlr|SiPLewVvLgDT&t!R;jaW znxK;45uqogg;TlK()SEXw9Zqa9V1GY>4XiA@$#I+cL`p$+b`s31DcYoAFsK*KXZgU zUS~Nk>pdg*3wAHp`~SMh@7U)0mWy${L(qtzn*`k{=%a!@A?QItj|uu~LEjPdyr5&S zZ(S~}Si1BtlsW4*rs7&kneVCbRLxtE;#~Cu)eAgTHJ(LtbzHfzs(L}yf~rO3%#>g@ zMDIeYw*(`GzIHWRy_79U^xaFddP^{3=v$eLM`NK4(V4M&jS$b<@HI=utFh3As46$k zHblRSk5c(@OvYI$KE4o-rT7FU=Vd8AkyQ!*m*SI{yUcjln3K`>1#_}77nAecSZ2eQ zK(CnprTFB+Ifhbv3VUj**9h^vjlSrKb-`F@!>n|a#iud)tYA(yb}7znl*2D$@_VCE z$40YNtOup|<*d6bUi^+-Dlb>NB1+3j1^X~xMD!f3qZX`A=JwP2X@&m>P5vj#guBOk zkt-$-vV@!0@jBoZd{=)-v|p~{O&lNT&#l6ad@g|HX(#TMGUM_%@N)fnW)ys26#T>} z_-KAR33&^?2>^v`UCUE&1@85wdLdHmPz{{QExEdW%*vR?vF7|M!UyT#I+zkJ%j@%cp zLwNTT9hdI`Q_*qbz6w{u?K+M-S;o{a`ohfZi}quLcuE4NcGC7SrGkHeyU|Yi%xO$J zggk9`^3<)9?*K2?o}Y0X^HH>au`bT;;{6)AP97BUifE_&&3r=OUf~}(UKfE=`)P}m z(j0!rdx=f&uj2A@M2^=qfe(r}k^QATK=Mz&Xs06VR0Ajb!%7QBP#sS`A^((!E7|uZ zfoCRqx!linakg35p&fQgZhmL174bmz4vF!SO4suI6{fc5+-W2J-z;@I%5* zmC0`(k0MWdr_|r9(!#AvKVOP=5>A`Tl&bh0u?(Ez#Jv8`6Y}ST9k4vzj12X+Q}nk{ z;OitV{O=ODDscL6LW%E1fu?~g1enr3;FGPFvt6QIS^PNRXsK7M8(?|*XS^u$aToC> zJ1%>@dcQ{QsJ1 zTs}j&8+e}>7isFxWIM(4@mf)^QrI69am)8$Q5F}tSImotg#2#c+`h@5OGKOuncA~Y z*pcr=d~Xf5ekAaIF)uC^_74lZ(bQi$=Aj4~BY9KE(!js*43X+B;)mEgbUPJbzJ5c_B4|lZ9#^kqB&2!*MOK zg+&s9_OKdCwYP79ih<(?4ogJon^IFau_>HDD~VYei^7Ot)L^6)*#v$nMcc!?AIsPJ zRxMMPt*%2y^j^t4oo_7I4l%XvFIW3k)h~sVp@bhN1cXDm>N3BoTl3egW$KECHMPD5 zbYDg6?gM!q zQ!RE%P2ww>+KEmgm)H~yhIJ-J$2{X1>LKNU`e4LuKRg5UX}*Fy7((NfNr9dK-^FL54~g`&yMfEH|1 zJ5kQ$kf|HDsL>Eu#Eb~9LRk{$Wf5_vQKiGHhOumeS7TxT3!`bQA<5v%cKv8;vA=Xc zb;QZm(&9pIO9n%PSD6qh>9#!IYdEJ{v|eyFm7*CmLi%x9-R*5Sf?TGLd~DV5Cd^A+ zjvo>Z$N7MLd8DACl5@MLH`$@;{zF`^K?_3BxSC3aL#2^IgHzggga3=!Re@kzG#)O@ zJm~`CVdSD2!vN4+raHv=K1TqFf*<%__=FS=lBupQcP8G(7dp)8V+d}#ppzJ zXQCq*P9|633bclA=W~`HSeId2a$LPQ`N&75BU3uOd|Y^sMaN9ig2-;PKr~v-W=_(Y_3R z@)drs%l$_A|4s6Dt*ne>jp-UNw5N>MPM+kxWU~MiflGqd-;z`f&ZsZqMUzgTx$UM<|aM7N+tY7Z0UJwm7w_nOhdLQ&@k6!X}A9fBk z7^#Kd_5V*G8QFdTGuk(!rb>OeU%N}_`-Py{f3pAEg?_D&liwKzg}(eQLHeX4>zDf9 z1x7I?#0&es4k3sgkdh?aTENoC8TI8pah1>?DoE-Xx8Nn+3*M+N_mkb@bV1o(p;l-0@LwUmAxlZd!9L`T^~?SJ z;h9`)M7+uVOZo?sK2utBMMWpwIw{*L}O?qac6co6L<#uH38uedN kbgoKlL{d21h)ecgu3t1i%hf-8y{?~^1Fy4%b_PingClient_PingClientMachine_State = PINGCLIENT_PINGCLIENTMACHINE_PING_STATE; -PingClient_PingClientMachine_OnEntry(_instance->PingClient_PingClientMachine_State, _instance); -break; -} -case PINGCLIENT_PINGCLIENTMACHINE_PING_STATE:{ -fprintf(stdout, "Send Ping "); -fprintf(stdout, "%i",_instance->PingClient_PingClientMachine_counter_var); -fprintf(stdout, " ... "); -PingClient_send_ping_service_ping(_instance, _instance->PingClient_PingClientMachine_counter_var); -break; -} -case PINGCLIENT_PINGCLIENTMACHINE_STOP_STATE:{ -fprintf(stdout, "Bye."); -fprintf(stdout, "\n"); -_instance->active = false; -break; -} -case PINGCLIENT_PINGCLIENTMACHINE_OK_STATE:{ -break; -} -default: break; -} -} - -// On Exit Actions: -void PingClient_PingClientMachine_OnExit(int state, struct PingClient_Instance *_instance) { -switch(state) { -case PINGCLIENT_PINGCLIENTMACHINE_STATE:{ -PingClient_PingClientMachine_OnExit(_instance->PingClient_PingClientMachine_State, _instance); -break;} -case PINGCLIENT_PINGCLIENTMACHINE_PING_STATE:{ -_instance->PingClient_PingClientMachine_counter_var = _instance->PingClient_PingClientMachine_counter_var + 1; -break;} -case PINGCLIENT_PINGCLIENTMACHINE_STOP_STATE:{ -break;} -case PINGCLIENT_PINGCLIENTMACHINE_OK_STATE:{ -break;} -default: break; -} -} - -// Event Handlers for incoming messages: -void PingClient_handle_ping_service_pong(struct PingClient_Instance *_instance, uint8_t seq) { -if(!(_instance->active)) return; -//Region PingClientMachine -uint8_t PingClient_PingClientMachine_State_event_consumed = 0; -if (_instance->PingClient_PingClientMachine_State == PINGCLIENT_PINGCLIENTMACHINE_PING_STATE) { -if (PingClient_PingClientMachine_State_event_consumed == 0 && seq == _instance->PingClient_PingClientMachine_counter_var) { -PingClient_PingClientMachine_OnExit(PINGCLIENT_PINGCLIENTMACHINE_PING_STATE, _instance); -_instance->PingClient_PingClientMachine_State = PINGCLIENT_PINGCLIENTMACHINE_OK_STATE; -fprintf(stdout, "[OK]"); -fprintf(stdout, "\n"); -PingClient_PingClientMachine_OnEntry(PINGCLIENT_PINGCLIENTMACHINE_OK_STATE, _instance); -PingClient_PingClientMachine_State_event_consumed = 1; -} -else if (PingClient_PingClientMachine_State_event_consumed == 0 && seq != _instance->PingClient_PingClientMachine_counter_var) { -PingClient_PingClientMachine_OnExit(PINGCLIENT_PINGCLIENTMACHINE_PING_STATE, _instance); -_instance->PingClient_PingClientMachine_State = PINGCLIENT_PINGCLIENTMACHINE_STOP_STATE; -fprintf(stdout, "[Error]"); -fprintf(stdout, "\n"); -PingClient_PingClientMachine_OnEntry(PINGCLIENT_PINGCLIENTMACHINE_STOP_STATE, _instance); -PingClient_PingClientMachine_State_event_consumed = 1; -} -} -//End Region PingClientMachine -//End dsregion PingClientMachine -//Session list: -} -int PingClient_handle_empty_event(struct PingClient_Instance *_instance) { - uint8_t empty_event_consumed = 0; -if(!(_instance->active)) return 0; -//Region PingClientMachine -if (_instance->PingClient_PingClientMachine_State == PINGCLIENT_PINGCLIENTMACHINE_OK_STATE) { -if (_instance->PingClient_PingClientMachine_counter_var > 5) { -PingClient_PingClientMachine_OnExit(PINGCLIENT_PINGCLIENTMACHINE_OK_STATE, _instance); -_instance->PingClient_PingClientMachine_State = PINGCLIENT_PINGCLIENTMACHINE_STOP_STATE; -PingClient_PingClientMachine_OnEntry(PINGCLIENT_PINGCLIENTMACHINE_STOP_STATE, _instance); -return 1; -} -else if (_instance->PingClient_PingClientMachine_counter_var <= 5) { -PingClient_PingClientMachine_OnExit(PINGCLIENT_PINGCLIENTMACHINE_OK_STATE, _instance); -_instance->PingClient_PingClientMachine_State = PINGCLIENT_PINGCLIENTMACHINE_PING_STATE; -PingClient_PingClientMachine_OnEntry(PINGCLIENT_PINGCLIENTMACHINE_PING_STATE, _instance); -return 1; -} -} -//begin dispatchEmptyToSession -//end dispatchEmptyToSession -return empty_event_consumed; -} - -// Observers for outgoing messages: -void (*external_PingClient_send_ping_service_ping_listener)(struct PingClient_Instance *, uint8_t)= 0x0; -void (*PingClient_send_ping_service_ping_listener)(struct PingClient_Instance *, uint8_t)= 0x0; -void register_external_PingClient_send_ping_service_ping_listener(void (*_listener)(struct PingClient_Instance *, uint8_t)){ -external_PingClient_send_ping_service_ping_listener = _listener; -} -void register_PingClient_send_ping_service_ping_listener(void (*_listener)(struct PingClient_Instance *, uint8_t)){ -PingClient_send_ping_service_ping_listener = _listener; -} -void PingClient_send_ping_service_ping(struct PingClient_Instance *_instance, uint8_t seq){ -if (PingClient_send_ping_service_ping_listener != 0x0) PingClient_send_ping_service_ping_listener(_instance, seq); -if (external_PingClient_send_ping_service_ping_listener != 0x0) external_PingClient_send_ping_service_ping_listener(_instance, seq); -; -} - - - diff --git a/doc/examples/thingml-gen/posix/Ping/PingClient.h b/doc/examples/thingml-gen/posix/Ping/PingClient.h deleted file mode 100644 index 2744c0752..000000000 --- a/doc/examples/thingml-gen/posix/Ping/PingClient.h +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - */ -/***************************************************** - * THIS IS A GENERATED FILE. DO NOT EDIT. - * Header for Thing PingClient - * Generated from ThingML (http://www.thingml.org) - *****************************************************/ - -#ifndef PingClient_H_ -#define PingClient_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "thingml_typedefs.h" - -/***************************************************************************** - * Headers for type : PingClient - *****************************************************************************/ - -// Definition of the instance struct: -struct PingClient_Instance { - -// Instances of different sessions -bool active; -// Variables for the ID of the ports of the instance -uint16_t id_ping_service; -// Variables for the current instance state -int PingClient_PingClientMachine_State; -// Variables for the properties of the instance -uint8_t PingClient_PingClientMachine_counter_var; - -}; -// Declaration of prototypes outgoing messages : -void PingClient_PingClientMachine_OnEntry(int state, struct PingClient_Instance *_instance); -void PingClient_handle_ping_service_pong(struct PingClient_Instance *_instance, uint8_t seq); -// Declaration of callbacks for incoming messages: -void register_PingClient_send_ping_service_ping_listener(void (*_listener)(struct PingClient_Instance *, uint8_t)); -void register_external_PingClient_send_ping_service_ping_listener(void (*_listener)(struct PingClient_Instance *, uint8_t)); - -// Definition of the states: -#define PINGCLIENT_PINGCLIENTMACHINE_PING_STATE 0 -#define PINGCLIENT_PINGCLIENTMACHINE_STOP_STATE 1 -#define PINGCLIENT_PINGCLIENTMACHINE_OK_STATE 2 -#define PINGCLIENT_PINGCLIENTMACHINE_STATE 3 - - - -#ifdef __cplusplus -} -#endif - -#endif //PingClient_H_ diff --git a/doc/examples/thingml-gen/posix/Ping/PingClient.o b/doc/examples/thingml-gen/posix/Ping/PingClient.o deleted file mode 100644 index 60240c002d419fd3426da6d427882b1795aebb12..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3920 zcmbtXU2GIp6u!G#V4-z(G5%mMb`r#30+U@R4G`2V6n3!C5}^sn+HAMmS-N&RZDwbI z`aqj(t8VtC51RO(&-!4LMAMKOrAdkKpb7EC7lS-PH2wrd6P59NGxv6HZ*~xpVJ!>d5h<;ZTSP3b7YiVZnQSWDSwz^8f#_!r_9=2v-(rC>V;x6ACsi& zMPjq>(BRt97ATtaN5B>~(d$dNzJlp(ykhe`QM3L6h6{N4;^d+)6K3lK-Y_%k0LgkZ zYR)dY8&k3QKg`+>-VH7Q*lt#@M!6s};N6O~&%lPwda;?;JkNtTGq5x#!XQ;8JF~tQ z7FUqCpVC(m#?1;w!=KwmE3UNGFSg8jmEWh2MniX(8uICvn477mTV@w4r%%P^(^0eb zcWU3SZXXX^T?}1Ix1cO|>8a>Cvv&XdR?3t#S<>^%aT!^lAWN}!#uwpd){y>q z%dGkBC6yVNGIfsq^KY<&r0%V!&fQzl&nFQmHhlt8~BaSof3^0~HeE5LAqkpJkyA^$}(P1QZbyoaY@?x^nNOTzc zpAT?-cOu!D=uGVQ(`JtajD=o*g@rD}LtEQ6MCYgg2MK?g%kF`9Y4JD0UD}pvB(3S; zw>N29OfBA}MPF_`PGgeN_)u$E4C7?-Dz|@v^Jj@q@bM?$C$xAq9PVAxqQU48jR@XC z&%2Nloy6<379ZTCMZ4)+h2PJB5kVIO?7BZ{U>!97o?~h7M*hb%eTY&{`ziOdc8ip` zc5{Y3(ZYW7nn@!~PZq`^^w*3czu#-Z_Rxd6s&s&WW_Z^F@NWp;EUj1c>?+5_T=2dJ_~|Fy&l8Ox5_@Wr#=v!s z`}>Np_c?xp<0okj`kWqLA7=xRi2E0ffhQDvC)oo}aopcaFvK@`xKy-k*T_qgYy&@$ z%a0UoE8Axuv0Z19mEGa-ipvV;ouX^8Y_>4r6m7SV&5w+-!bHVg+s%cdD~B4%*~29( zJ3*Ob%a(Jln5W6OeYS~?H8$Z+X03CSE_1B2#j&y9|Wy7=+78{yO;aEP$8&h-)AF z3Iu)J=faOTyHr1;P$m-j;QIkh1Z-74=OrAv!vCCv$0U47!sR-A%W)A`oZH_?`f?p^ zO1SLjwuIw57Wo|H--){3GaMIjpW*fclD-^wSik=;Of534O_bDFtBS~M5 z`>BM>e!h@!Iqshlju@g2kD~xYU^2c`tQxKjC5k3ESv;$FdT8PId|09Stz zTvOsg7sT5fOz6Fn9{5!4uXB6sZJ9)TfhB1GpSuOXxv)omGKu(tr$~sgTECwkGXFkq zpCB%iu=oEZkpv>H;AcoC#*!M_rWS+?RoyXeuco_$+s73HwSFUH-?aZYB#1r?7(@T@ z>r2>+{%PingServer_State = PINGSERVER_NULL_ACTIVE_STATE; -PingServer_OnEntry(_instance->PingServer_State, _instance); -break; -} -case PINGSERVER_NULL_ACTIVE_STATE:{ -break; -} -default: break; -} -} - -// On Exit Actions: -void PingServer_OnExit(int state, struct PingServer_Instance *_instance) { -switch(state) { -case PINGSERVER_STATE:{ -PingServer_OnExit(_instance->PingServer_State, _instance); -break;} -case PINGSERVER_NULL_ACTIVE_STATE:{ -break;} -default: break; -} -} - -// Event Handlers for incoming messages: -void PingServer_handle_ping_service_ping(struct PingServer_Instance *_instance, uint8_t seq) { -if(!(_instance->active)) return; -//Region null -uint8_t PingServer_State_event_consumed = 0; -if (_instance->PingServer_State == PINGSERVER_NULL_ACTIVE_STATE) { -if (PingServer_State_event_consumed == 0 && 1) { -PingServer_OnExit(PINGSERVER_NULL_ACTIVE_STATE, _instance); -_instance->PingServer_State = PINGSERVER_NULL_ACTIVE_STATE; -PingServer_send_ping_service_pong(_instance, seq); -PingServer_OnEntry(PINGSERVER_NULL_ACTIVE_STATE, _instance); -PingServer_State_event_consumed = 1; -} -} -//End Region null -//End dsregion null -//Session list: -} - -// Observers for outgoing messages: -void (*external_PingServer_send_ping_service_pong_listener)(struct PingServer_Instance *, uint8_t)= 0x0; -void (*PingServer_send_ping_service_pong_listener)(struct PingServer_Instance *, uint8_t)= 0x0; -void register_external_PingServer_send_ping_service_pong_listener(void (*_listener)(struct PingServer_Instance *, uint8_t)){ -external_PingServer_send_ping_service_pong_listener = _listener; -} -void register_PingServer_send_ping_service_pong_listener(void (*_listener)(struct PingServer_Instance *, uint8_t)){ -PingServer_send_ping_service_pong_listener = _listener; -} -void PingServer_send_ping_service_pong(struct PingServer_Instance *_instance, uint8_t seq){ -if (PingServer_send_ping_service_pong_listener != 0x0) PingServer_send_ping_service_pong_listener(_instance, seq); -if (external_PingServer_send_ping_service_pong_listener != 0x0) external_PingServer_send_ping_service_pong_listener(_instance, seq); -; -} - - - diff --git a/doc/examples/thingml-gen/posix/Ping/PingServer.h b/doc/examples/thingml-gen/posix/Ping/PingServer.h deleted file mode 100644 index 2617e2326..000000000 --- a/doc/examples/thingml-gen/posix/Ping/PingServer.h +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - */ -/***************************************************** - * THIS IS A GENERATED FILE. DO NOT EDIT. - * Header for Thing PingServer - * Generated from ThingML (http://www.thingml.org) - *****************************************************/ - -#ifndef PingServer_H_ -#define PingServer_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "thingml_typedefs.h" - -/***************************************************************************** - * Headers for type : PingServer - *****************************************************************************/ - -// Definition of the instance struct: -struct PingServer_Instance { - -// Instances of different sessions -bool active; -// Variables for the ID of the ports of the instance -uint16_t id_ping_service; -// Variables for the current instance state -int PingServer_State; -// Variables for the properties of the instance - -}; -// Declaration of prototypes outgoing messages : -void PingServer_OnEntry(int state, struct PingServer_Instance *_instance); -void PingServer_handle_ping_service_ping(struct PingServer_Instance *_instance, uint8_t seq); -// Declaration of callbacks for incoming messages: -void register_PingServer_send_ping_service_pong_listener(void (*_listener)(struct PingServer_Instance *, uint8_t)); -void register_external_PingServer_send_ping_service_pong_listener(void (*_listener)(struct PingServer_Instance *, uint8_t)); - -// Definition of the states: -#define PINGSERVER_STATE 0 -#define PINGSERVER_NULL_ACTIVE_STATE 1 - - - -#ifdef __cplusplus -} -#endif - -#endif //PingServer_H_ diff --git a/doc/examples/thingml-gen/posix/Ping/PingServer.o b/doc/examples/thingml-gen/posix/Ping/PingServer.o deleted file mode 100644 index aa4f25c609d5e2063195d20b6fbbf18728086add..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2456 zcmbW1O-NKx6oAh-rjyzml_0^uX%hwY7)vdKYDCLtMSmg{V&kY!9h`Z}n>V2mC78j` zMyN$gp%yJ$wT!^1mM+`Xx`GNR7ZuYvZ_aUUw-^1KVct3CyXWV=d+)n9j-5JQ5ek7w z2#!G66AEy#s%$5GGXYzm1{RC?>KDf=DP<+vk|4kC_Vvnl>(Q2Z3S0B(xEXD^NiNJE z1+Qx1MrFv`St;GK)+S^URe9Pe$mHkR^bD+E7vde1L*DUJ`~$EFp_t?e5~DU zGvj+Z^1j!4y|u%Px0#*0OFXtO-r5oGhDh7>)15X-27=J+$#!5jF2LIsvG8BgD zUl@Tf$O`;C90ui(^N@kMQJJUg%?{?Yh9t5-`+YmKv2Xq!Axq=GL7BhIV3@i1qA8F1 z>ict-`7&w}iGPVU#Xs^X9#7VAHtkIG+wK+HHAfXEdB!>Bc#!k*) zjbsjsq(@5*xb{Rk=h<%3p2eq=$|TEuFwz;*a;C9BhB6%6Ehqm&&L2bheNVHlKuvq~ ztyq#_g>O;#o!{{L3Rmkq`3+xHxLQA^aGH|{eP<-Z=r8BUB8Vb9UUFfcweThO={%4K zU-mtKhpdG^Vjs-hT-HmCp!VF7o)pWqGbz)<9R+hN<)y$J$>qQYX5Pu9r|iren4{C# ztnFZkGws=C@9BZPIWILj1*V^EPbSCRRMwVm|E*(~Nq2|-MJAAute4crQ`S#FGa7VT zBm}Tt -#include -#include -#include -#include -#include -#include -#include -#include "thingml_typedefs.h" -#include "runtime.h" -#include "PingServer.h" -#include "PingClient.h" - - - - - -/***************************************************************************** - * Definitions for configuration : Ping - *****************************************************************************/ - -//Declaration of instance variables -//Instance server -// Variables for the properties of the instance -struct PingServer_Instance server_var; -// Variables for the sessions of the instance -//Instance client -// Variables for the properties of the instance -struct PingClient_Instance client_var; -// Variables for the sessions of the instance - - -// Enqueue of messages PingServer::ping_service::pong -void enqueue_PingServer_send_ping_service_pong(struct PingServer_Instance *_instance, uint8_t seq){ -fifo_lock(); -if ( fifo_byte_available() > 5 ) { - -_fifo_enqueue( (1 >> 8) & 0xFF ); -_fifo_enqueue( 1 & 0xFF ); - -// ID of the source port of the instance -_fifo_enqueue( (_instance->id_ping_service >> 8) & 0xFF ); -_fifo_enqueue( _instance->id_ping_service & 0xFF ); - -// parameter seq -union u_seq_t { -uint8_t p; -byte bytebuffer[1]; -} u_seq; -u_seq.p = seq; -_fifo_enqueue(u_seq.bytebuffer[0] & 0xFF ); -} -fifo_unlock_and_notify(); -} -// Enqueue of messages PingClient::ping_service::ping -void enqueue_PingClient_send_ping_service_ping(struct PingClient_Instance *_instance, uint8_t seq){ -fifo_lock(); -if ( fifo_byte_available() > 5 ) { - -_fifo_enqueue( (2 >> 8) & 0xFF ); -_fifo_enqueue( 2 & 0xFF ); - -// ID of the source port of the instance -_fifo_enqueue( (_instance->id_ping_service >> 8) & 0xFF ); -_fifo_enqueue( _instance->id_ping_service & 0xFF ); - -// parameter seq -union u_seq_t { -uint8_t p; -byte bytebuffer[1]; -} u_seq; -u_seq.p = seq; -_fifo_enqueue(u_seq.bytebuffer[0] & 0xFF ); -} -fifo_unlock_and_notify(); -} - - -//New dispatcher for messages -void dispatch_pong(uint16_t sender, uint8_t param_seq) { -if (sender == server_var.id_ping_service) { -PingClient_handle_ping_service_pong(&client_var, param_seq); - -} - -} - - -//New dispatcher for messages -void dispatch_ping(uint16_t sender, uint8_t param_seq) { -if (sender == client_var.id_ping_service) { -PingServer_handle_ping_service_ping(&server_var, param_seq); - -} - -} - - -int processMessageQueue() { -fifo_lock(); -while (fifo_empty()) fifo_wait(); -uint8_t mbufi = 0; - -// Read the code of the next port/message in the queue -uint16_t code = fifo_dequeue() << 8; - -code += fifo_dequeue(); - -// Switch to call the appropriate handler -switch(code) { -case 1:{ -byte mbuf[5 - 2]; -while (mbufi < (5 - 2)) mbuf[mbufi++] = fifo_dequeue(); -fifo_unlock(); -uint8_t mbufi_pong = 2; -union u_pong_seq_t { -uint8_t p; -byte bytebuffer[1]; -} u_pong_seq; -u_pong_seq.bytebuffer[0] = mbuf[mbufi_pong + 0]; -mbufi_pong += 1; -dispatch_pong((mbuf[0] << 8) + mbuf[1] /* instance port*/, - u_pong_seq.p /* seq */ ); -break; -} -case 2:{ -byte mbuf[5 - 2]; -while (mbufi < (5 - 2)) mbuf[mbufi++] = fifo_dequeue(); -fifo_unlock(); -uint8_t mbufi_ping = 2; -union u_ping_seq_t { -uint8_t p; -byte bytebuffer[1]; -} u_ping_seq; -u_ping_seq.bytebuffer[0] = mbuf[mbufi_ping + 0]; -mbufi_ping += 1; -dispatch_ping((mbuf[0] << 8) + mbuf[1] /* instance port*/, - u_ping_seq.p /* seq */ ); -break; -} -} -return 1; -} - - -//external Message enqueue - -void initialize_configuration_Ping() { -// Initialize connectors -register_PingServer_send_ping_service_pong_listener(&enqueue_PingServer_send_ping_service_pong); -register_PingClient_send_ping_service_ping_listener(&enqueue_PingClient_send_ping_service_ping); - - -// Network Initialization -// End Network Initialization - -// Init the ID, state variables and properties for instance server -server_var.active = true; -server_var.id_ping_service = add_instance( (void*) &server_var); -server_var.PingServer_State = PINGSERVER_NULL_ACTIVE_STATE; - -PingServer_OnEntry(PINGSERVER_STATE, &server_var); -// Init the ID, state variables and properties for instance client -client_var.active = true; -client_var.id_ping_service = add_instance( (void*) &client_var); -client_var.PingClient_PingClientMachine_State = PINGCLIENT_PINGCLIENTMACHINE_PING_STATE; -client_var.PingClient_PingClientMachine_counter_var = 0; - -PingClient_PingClientMachine_OnEntry(PINGCLIENT_PINGCLIENTMACHINE_STATE, &client_var); -} - - - - -void term(int signum) -{ - - - fflush(stdout); - fflush(stderr); - exit(signum); -} - - -int main(int argc, char *argv[]) { - struct sigaction action; - memset(&action, 0, sizeof(struct sigaction)); - action.sa_handler = term; - sigaction(SIGINT, &action, NULL); - sigaction(SIGTERM, &action, NULL); - - init_runtime(); - - initialize_configuration_Ping(); - - while (1) { - -// Network Listener// End Network Listener - -int emptyEventConsumed = 1; -while (emptyEventConsumed != 0) { -emptyEventConsumed = 0; -emptyEventConsumed += PingClient_handle_empty_event(&client_var); -} - - processMessageQueue(); - } -} \ No newline at end of file diff --git a/doc/examples/thingml-gen/posix/Ping/Ping_cfg.o b/doc/examples/thingml-gen/posix/Ping/Ping_cfg.o deleted file mode 100644 index 9ba0e7144b0b27eea7059b03aa48373a3d7983cd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5872 zcmb`LZEPIH8OP`DoM6&$cL`7|UTQ-Vnh?0&p~NUq&>1J>pd~<@00N?AecrQIocGM$ zUXr6Cyf{Ui0w}5~wI70nT2-o4BqBaoty=K4N#R4k(0l~H?_%rno-?vC@w=3m^DPNjsgl(<1G+!-oF@!W-aSysy;CzgvHBc*Po z^F`-GW%}dZ571ER%3}KDlD+Fn^Rhk*kFu7Vc{pP#XA zhsw9~pC+Yo``!GHbWTty-}M!nTl?q-*jue7I*%o zE4i6BNd2Bt4|R@c{Pd?DcSvH#8sNFbtHRLwGfhxvL9Egc68AlWOtToCg?8`zmCo@Kl|Rp77gb*ESw)2kgSvH&&*o0w zc4crnbtaDsbEMUqlZuZ%6kCReuN_#kW3&}St$_`N^@ZY9gDrVi+FKed6xSCvu2p>C z>SAfII9S|>Va0j!SBTU@+eB(lK6TOZvw9EE(jlmeb=#dNhqC!6(nHz4>CDfw1L<+fv%s=`c=R>n=k{{-!Abd8+Qy{71S3L#|+kT}k!lB@yCHls9JcPa&Qs zGQ-({>7I0RS+?({Z2rb<@0K4>GscrTDj%myY|7@-?QAdR^eOJicH>9Ju{C=r=_Q1A zZD{ThpUj(kUS<;CU_xZ*Uy^0WQ<7zb+?8iEWyI1m7(hmxZQ;u-y!Q;goXAQRzg$CN zgLGjX;#MY*#J5}csD-zQW8C|xgqd;wKy~mgAer1NRQ`#sq;X%c@EHq#$-@6h9OKSW z2{ZfdHL9-=|C=|NGv%=uM;>9v=}L-o8Eqi=&+C0={P)p)lKy8}U(|ZDmv6V|@3C;t z!b1z+OI*g8meWzs4pk3Y^siZX5A{!)*9r??W#KmyU&;2rd}b-0trq>=7VcTNxZMxN zooa2oP!(SAV9RTH4$z1f?(#yX=>=oX6eLXoe${iP8o{`z`L%{qZ&V*pwb6FuIqojk zue+mlPdKt!dsB*50JYl;L`j3u$RhH>NzshP8m&mwYV}rg0(V{* z3U7}ei7~%9$xOcgss4B0hVn%w935uak(>P;J3w|&t%RyofXr{tO)oV6y zrOO@n?m+I;YyHjiBa_w?a4a8-ZK`5qjf( zlV<$N3oJ-2Z+H|BZz|YvF&i@K+dLL3NY2e>1+4@uQ66 z1ZVWGGtTvIF@7G?pJ4olRR2=1;}UvL!tiCjK-SdHxtb&Y;6}fi>EXxNHB8U*Kg>AJ zI41sE7{7$^5ytT?GJ40tcU$4f`s+>k{|VDqs1AcW&To@c@ikO8{_kXbfbpv4@%&6M{aU7fknxKcA7ETh zQ4$^}`2AWprAsheU48$gE)Ad4_XlI#oUaeXxH(6^6XSU}Bs-}JIp$Jbmqnr3o{Zd4 zQD{b?Dkn@W^y+RQ^7cfcFy=Df zQP3-F*}CH@YNE5G(s~n4Ep+MB@V(dodBK)jG$*<*(*^srp1-miTM6Oc%F4 zY)G;`?HJ#7jMEE9hCL6voGx(l9D%`(#>Q1tX-ysFm2|=9|J%PreUs+@ZO6wsD5?KD zI{w|%&W%5#;AOg!@>j&6gsdxn)!7TFjOTBJ7{)JZohk0p3E5zPE}?~)@;+9V4f^M) zctSNd{frjRHCTMP4(R^oc{6$wzqzkdC29V13G>Ih#`HJ)2ePD458*II_DfZq{*A|< h6g$MvAt Active - event m : ping_service?ping - action ping_service!pong(m.seq) - } - } -} -thing PingClient includes PingMsgs { - required port ping_service { - sends ping receives pong - } - statechart PingClientMachine init Ping { - property counter : UInt8 = 0 - state Ping { - on entry do - print "Send Ping " , counter , " ... " - ping_service!ping(counter) - end - on exit counter = counter + 1 - transition -> OK - event e : ping_service?pong - guard e.seq == counter - action println "[OK]" - transition -> Stop - event e : ping_service?pong - guard e.seq != counter - action println "[Error]" - } - state OK { - transition -> Stop guard counter > 5 - transition -> Ping guard counter <= 5 - } - final state Stop { - on entry println "Bye." - } - } -} -datatype Byte<1> - @type_checker "Byte" - @c_type "uint8_t" - @c_byte_size "1" - @java_type "byte" - @js_type "byte" - @java_primitive "true" - @go_type "byte" -datatype Char<1> - @type_checker "Byte" - @c_type "char" - @c_byte_size "1" - @java_type "byte" - @js_type "byte" - @java_primitive "true" - @go_type "byte" -datatype Boolean<1> - @type_checker "Boolean" - @c_type "bool" - @c_byte_size "1" - @java_type "boolean" - @js_type "boolean" - @java_primitive "true" - @go_type "bool" -datatype Integer<2> - @type_checker "Integer" - @c_type "int" - @c_byte_size "2" - @java_type "short" - @js_type "short" - @java_primitive "true" - @go_type "int16" -datatype UInt8<1> - @type_checker "Integer" - @c_type "uint8_t" - @c_byte_size "1" - @java_type "short" - @js_type "short" - @java_primitive "true" - @go_type "uint8" -datatype Int8<1> - @type_checker "Integer" - @c_type "int8_t" - @c_byte_size "1" - @java_type "byte" - @js_type "byte" - @java_primitive "true" - @go_type "int8" -datatype UInt16<2> - @type_checker "Integer" - @c_type "uint16_t" - @c_byte_size "2" - @java_type "int" - @js_type "int" - @java_primitive "true" - @go_type "uint16" -datatype Int16<2> - @type_checker "Integer" - @c_type "int16_t" - @c_byte_size "2" - @java_type "short" - @js_type "short" - @java_primitive "true" - @go_type "int16" -datatype Int32<4> - @type_checker "Integer" - @c_type "int32_t" - @c_byte_size "4" - @java_type "int" - @js_type "int" - @java_primitive "true" - @go_type "int32" -datatype UInt32<4> - @type_checker "Integer" - @c_type "uint32_t" - @c_byte_size "4" - @java_type "long" - @js_type "long" - @java_primitive "true" - @go_type "uint32" -datatype Long<4> - @type_checker "Integer" - @c_type "long" - @c_byte_size "4" - @java_type "int" - @js_type "int" - @java_primitive "true" - @go_type "int32" -datatype ULong<4> - @type_checker "Integer" - @c_type "unsigned long" - @c_byte_size "4" - @java_type "long" - @js_type "long" - @java_primitive "true" - @go_type "uint32" -datatype LongLong<8> - @type_checker "Integer" - @c_type "long long" - @c_byte_size "8" - @java_type "long" - @js_type "long" - @java_primitive "true" - @go_type "int64" -datatype Float<4> - @type_checker "Real" - @c_type "float" - @c_byte_size "4" - @java_type "float" - @js_type "float" - @java_primitive "true" - @go_type "float32" -datatype Double<8> - @type_checker "Real" - @c_type "double" - @c_byte_size "8" - @java_type "double" - @js_type "double" - @java_primitive "true" - @go_type "float64" -object String - @serializable - @c_type "char *" - @c_byte_size "*" - @java_type "String" - @js_type "String" - @go_type "string" -enumeration DigitalState - @type_checker "Integer" - @java_type "byte" - @java_primitive "true" - @c_byte_size "1" - @c_type "uint8_t" - @go_type "uint8" - { - LOW @enum_val "0" - HIGH @enum_val "1" -} -configuration Ping { - instance client : PingClient - instance server : PingServer - connector client.ping_service => server . ping_service -} diff --git a/doc/examples/thingml-gen/posix/Ping/runtime.c b/doc/examples/thingml-gen/posix/Ping/runtime.c deleted file mode 100644 index 8dbebe6c4..000000000 --- a/doc/examples/thingml-gen/posix/Ping/runtime.c +++ /dev/null @@ -1,142 +0,0 @@ -/** - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - */ -/***************************************************** - * THIS IS A GENERATED FILE. DO NOT EDIT. - * - * Generated from ThingML (http://www.thingml.org) - *****************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "runtime.h" - - -#define MAX_INSTANCES 2 -#define FIFO_SIZE 32768 - -/********************************* - * Instance IDs and lookup - *********************************/ - -void * instances[MAX_INSTANCES]; -uint16_t instances_count = 0; - -void * instance_by_id(uint16_t id) { - return instances[id]; -} - -uint16_t add_instance(void * instance_struct) { - instances[instances_count] = instance_struct; - return instances_count++; -} - -/****************************************** - * Simple byte FIFO implementation - ******************************************/ - -byte fifo[FIFO_SIZE]; -int fifo_head = 0; -int fifo_tail = 0; - -// Returns the number of byte currently in the fifo -int fifo_byte_length() { - if (fifo_tail >= fifo_head) - return fifo_tail - fifo_head; - return fifo_tail + FIFO_SIZE - fifo_head; -} - -// Returns the number of bytes currently available in the fifo -int fifo_byte_available() { - return FIFO_SIZE - 1 - fifo_byte_length(); -} - -// Returns true if the fifo is empty -int fifo_empty() { - return fifo_head == fifo_tail; -} - -// Return true if the fifo is full -int fifo_full() { - return fifo_head == ((fifo_tail + 1) % FIFO_SIZE); -} - -// Enqueue 1 byte in the fifo if there is space -// returns 1 for sucess and 0 if the fifo was full -int fifo_enqueue(byte b) { - int new_tail = (fifo_tail + 1) % FIFO_SIZE; - if (new_tail == fifo_head) return 0; // the fifo is full - fifo[fifo_tail] = b; - fifo_tail = new_tail; - return 1; -} - -// Enqueue 1 byte in the fifo without checking for available space -// The caller should have checked that there is enough space -int _fifo_enqueue(byte b) { - fifo[fifo_tail] = b; - fifo_tail = (fifo_tail + 1) % FIFO_SIZE; - return 0; // Dummy added by steffend -} - -// Dequeue 1 byte in the fifo. -// The caller should check that the fifo is not empty -byte fifo_dequeue() { - if (!fifo_empty()) { - byte result = fifo[fifo_head]; - fifo_head = (fifo_head + 1) % FIFO_SIZE; - return result; - } - return 0; -} - -/****************************************** - * Synchronization for thread safe access - ******************************************/ - -pthread_mutex_t fifo_mut; -pthread_cond_t fifo_cond; - -void fifo_lock() { - pthread_mutex_lock (&fifo_mut); -} -void fifo_unlock() { - pthread_mutex_unlock (&fifo_mut); -} -void fifo_wait() { - pthread_cond_wait (&fifo_cond, &fifo_mut); -} -void fifo_unlock_and_notify() { - pthread_mutex_unlock (&fifo_mut); - pthread_cond_signal (&fifo_cond); -} - - -/****************************************** - * Initialization - ******************************************/ - -void init_runtime() { - pthread_mutex_init (&fifo_mut, NULL); - pthread_cond_init (&fifo_cond, NULL); -} diff --git a/doc/examples/thingml-gen/posix/Ping/runtime.h b/doc/examples/thingml-gen/posix/Ping/runtime.h deleted file mode 100644 index c1629e588..000000000 --- a/doc/examples/thingml-gen/posix/Ping/runtime.h +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - */ -/***************************************************** - * THIS IS A GENERATED FILE. DO NOT EDIT. - * - * Generated from ThingML (http://www.thingml.org) - *****************************************************/ - -#ifndef RUNTIME_H_ -#define RUNTIME_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -typedef unsigned char byte; - -/* Queuing of pointers (size is different depending of the platform)*/ - -#define PTR_MAX_SIZE 8 // Code generator should adjust this - -typedef union { - uint8_t buffer[PTR_MAX_SIZE]; - void* pointer; -} ptr_union_t; - -/* -void _fifo_enqueue_ptr(void * ptr); -void * _fifo_dequeue_ptr(); -static_assert(sizeof(void*) <= PTR_MAX_SIZE*sizeof(uint8_t)); -*/ - - -/* Adds and instance to the runtime and returns its id */ -uint16_t add_instance(void * instance_struct); -/* Returns the instance with id */ -void * instance_by_id(uint16_t id); - -/* Returns the number of byte currently in the fifo */ -int fifo_byte_length(); -/* Returns the number of bytes currently available in the fifo */ -int fifo_byte_available(); -/* Returns true if the fifo is empty */ -int fifo_empty(); -/* Return true if the fifo is full */ -int fifo_full(); -/* Enqueue 1 byte in the fifo if there is space - returns 1 for sucess and 0 if the fifo was full */ -int fifo_enqueue(byte b); -/* Enqueue 1 byte in the fifo without checking for available space - The caller should have checked that there is enough space */ -int _fifo_enqueue(byte b); -/* Dequeue 1 byte in the fifo. - The caller should check that the fifo is not empty */ -byte fifo_dequeue(); - -// Synchronization for thread safe FIFO access -void fifo_lock(); -void fifo_unlock(); -void fifo_wait(); -void fifo_unlock_and_notify(); - -void init_runtime(); - -#ifdef __cplusplus -} -#endif - -#endif /*RUNTIME_H_*/ diff --git a/doc/examples/thingml-gen/posix/Ping/runtime.o b/doc/examples/thingml-gen/posix/Ping/runtime.o deleted file mode 100644 index a8023df1f1b7fe806a23c19b87554d4a55ff753d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4360 zcmbW5U2IfE6vxl9D76CHiY6jpHwuOlx!EE#RE${!Wlh91C{YsQa=UxCyJ0`Dy{nW5 zSu7fwhFB6b`c`=`CYs2Lh{Q-g3?V$2C5pcI;>QCR9>fQt38tPi_nh6s^lm~tV+NuC#!a4a6CXPaHGr}2x_|7h_g#wZJU^S8;QBjE%i~;szI&!` z`pn!RfY?sd&Q9ccy@for-)o{YPh{zJ`)?*SECPr!r=M z$F_zw@RyI7hRLH}QQv21qGofkuI&Il)GwB)jNE_n=vflkT?ZLZ9<&Q)VvA|yuS;cS zMrR^pmtv=D)OPxxuIa0tk&B0aHN(Exn8swIzjLI!NV85Y(9ox1&9$&kApj!5;@lDP~C$YY_YNDPudwQM3MyIbk;PDNK zp58=nqK|sImwwP92X{f_Ku2W7;zex}IDZ|;R+<`s#at3gu)j(%oL*xOD)ut_YZNQ8 zzf7?j`wuI2g8eOueZu}a#l8;F)tR*`-R~jnZ)PzrX&x5y3uf+n`_hgVmbRJsSZ74=FhCUlg;^9cg;^BLYM)mXg+=oifhdHJHwt&o)8CEc9yLyR z_75QMgumu!4UkE>8hz4BEbF2Nc_)rvdR{<{(6-`5`hjk&C~x0z2em-Y4@^Ez``bMInI_Zw#pwZNgZY3`TTgsjJt%#+L|&*#i* z%w=8DMy2zw#h7dcFPTdN_~$Z~)Gxi8WRm9>^uzQwkduCr^|H zIpsOUd1Oy`tc89D>+7tKo9qBDw$Kl@;4p+6S)t@P87P#8eYc$P(gP#uLbeeOgPYB! zrLu|BnF=q%KGNuW2hz>DYT5X=Rx>mmyx|sj_?b#M+sH#f zx>*;rNV^Ej6~B-hxm7q^7%aO*oRxx~=BaE5f)Pp(j~T$9pSQvrz|e}Je{Xx zqVEqv*w3Z#8plU0KFRS17O!*snZ-N!ex@v*Wd4K2Ys{}$T+Y3l7N2Cj^dsXx#e6N7 z!s{G^GdxoA-2p89p`gr*H{=yv2RCgWoUH4+;0z28g8>fix`lmSaRi)9rBw3poN;jX z^_(5g?_Q6m6z>0yY3=3HxgodY@o4{l5yz%9Wcy1kiHz(|xt}1McZSniq;IAq*Go}r z3%m*b^rZcSQZa74%a1U(zfco2p&@1s2OdQYfPr3zsl`xd7i;$E4j?S^tA__u;WrzR( diff --git a/doc/examples/thingml-gen/posix/Ping/thingml_typedefs.h b/doc/examples/thingml-gen/posix/Ping/thingml_typedefs.h deleted file mode 100644 index 5800d8941..000000000 --- a/doc/examples/thingml-gen/posix/Ping/thingml_typedefs.h +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - */ -/***************************************************** - * THIS IS A GENERATED FILE. DO NOT EDIT. - * Definitions of datatypes and enums - * Generated from ThingML (http://www.thingml.org) - *****************************************************/ - -#ifndef THINGML_TYPEDEFS_H_ -#define THINGML_TYPEDEFS_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include -#include -#include -#include - - - -/*typedef unsigned char uint8; -typedef unsigned short uint16; -typedef signed short int16; -typedef unsigned long uint32; -typedef signed char int8;*/ - - -#ifdef __cplusplus -} -#endif - -#endif //THINGML_TYPEDEFS_H_ diff --git a/doc/examples/thingml-gen/uml/CountdownUML/CountdownUML/docs/CountdownUML.plantuml b/doc/examples/thingml-gen/uml/CountdownUML/CountdownUML/docs/CountdownUML.plantuml deleted file mode 100644 index 1086d9a2a..000000000 --- a/doc/examples/thingml-gen/uml/CountdownUML/CountdownUML/docs/CountdownUML.plantuml +++ /dev/null @@ -1,8 +0,0 @@ -@startuml -caption Instances and Connectors in configuration CountdownUML -component timer4<> -component timer3<> -component timer1<> -component countdown<> -component timer2<> -@enduml \ No newline at end of file diff --git a/doc/examples/thingml-gen/uml/CountdownUML/CountdownUML/docs/CountdownUML_class.plantuml b/doc/examples/thingml-gen/uml/CountdownUML/CountdownUML/docs/CountdownUML_class.plantuml deleted file mode 100644 index ad9199e72..000000000 --- a/doc/examples/thingml-gen/uml/CountdownUML/CountdownUML/docs/CountdownUML_class.plantuml +++ /dev/null @@ -1,66 +0,0 @@ -@startuml -caption Things used in configuration CountdownUML -class TimerJS <<(T,#F94918)PSM>> { -..Properties.. --Timeouts : JSArray = '{}' -..Functions.. --startTimer(id : UInt8delay : UInt16) : void --cancel(id : UInt8) : void -} -class Timer <<(F,#BC74ED)Fragment>> { -..Port timer.. ->>timer_start ->>timer_cancel -<> { -..Messages.. --timer_start(id : UInt8time : UInt16) --timer_cancel(id : UInt8) --timer_timeout(id : UInt8) -} -class TimerPosix <<(T,#F94918)PSM>> { -..Properties.. --NB_SOFT_TIMERS : UInt16 = 'NB_SOFT_TIMERS' --SOFT_TIMER_PERIOD : UInt16 = 4 -..Functions.. --time_ms() : UInt32 --sleep_ms(timeout_ms : UInt16) : void --start_soft_timer_process() : void --startTimer(id : UInt8delay : UInt16) : void --cancel(id : UInt8) : void -} -class TimerJava <<(T,#F94918)PSM>> { -..Functions.. --startTimer(id : UInt8delay : UInt16) : void --cancel(id : UInt8) : void -} -class Countdown <<(T,#5BBF09)PIM>> { -..Properties.. --TimerID : UInt8 = 1 --StartTime : UInt8 = 10 -} -class TimerClientPort <<(F,#BC74ED)Fragment>> { -..Port timer.. ->>timer_timeout -<> { -..Properties.. --NB_SOFT_TIMERS : UInt16 = 'NB_SOFT_TIMERS' -..Functions.. --time_ms() : UInt32 --init_arrays() : void --poll_soft_timers() : void --startTimer(id : UInt8delay : UInt16) : void --cancel(id : UInt8) : void -} -Timer <|-- TimerJS -TimerMsgs <|-- Timer -Timer <|-- TimerPosix -Timer <|-- TimerJava -TimerClientPort <|-- Countdown -TimerMsgs <|-- TimerClientPort -Timer <|-- TimerArduino -@enduml \ No newline at end of file diff --git a/doc/examples/thingml-gen/uml/CountdownUML/CountdownUML/docs/CountdownUML_class_compact.plantuml b/doc/examples/thingml-gen/uml/CountdownUML/CountdownUML/docs/CountdownUML_class_compact.plantuml deleted file mode 100644 index 59205cc97..000000000 --- a/doc/examples/thingml-gen/uml/CountdownUML/CountdownUML/docs/CountdownUML_class_compact.plantuml +++ /dev/null @@ -1,38 +0,0 @@ -@startuml -caption Things used in configuration CountdownUML -class TimerJS <<(T,#F94918)PSM>> { -} -class Timer <<(F,#BC74ED)Fragment>> { -..Port timer.. ->>timer_start ->>timer_cancel -<> { -..Messages.. --timer_start(...) --timer_cancel(...) --timer_timeout(...) -} -class TimerPosix <<(T,#F94918)PSM>> { -} -class TimerJava <<(T,#F94918)PSM>> { -} -class Countdown <<(T,#5BBF09)PIM>> { -} -class TimerClientPort <<(F,#BC74ED)Fragment>> { -..Port timer.. ->>timer_timeout -<> { -} -Timer <|-- TimerJS -TimerMsgs <|-- Timer -Timer <|-- TimerPosix -Timer <|-- TimerJava -TimerClientPort <|-- Countdown -TimerMsgs <|-- TimerClientPort -Timer <|-- TimerArduino -@enduml \ No newline at end of file diff --git a/doc/examples/thingml-gen/uml/CountdownUML/CountdownUML/docs/CountdownUML_datatypes.plantuml b/doc/examples/thingml-gen/uml/CountdownUML/CountdownUML/docs/CountdownUML_datatypes.plantuml deleted file mode 100644 index 081b51e76..000000000 --- a/doc/examples/thingml-gen/uml/CountdownUML/CountdownUML/docs/CountdownUML_datatypes.plantuml +++ /dev/null @@ -1,11 +0,0 @@ -@startuml -caption Datatypes used in configuration CountdownUML -class UInt16 <<(D,#D2E524)2>> { -} -note bottom of UInt16 : @type_checker "Integer"\n@c_type "uint16_t"\n@c_byte_size "2"\n@java_type "int"\n@js_type "int"\n@java_primitive "true"\n@go_type "uint16"\n -class UInt8 <<(D,#D2E524)1>> { -} -note bottom of UInt8 : @type_checker "Integer"\n@c_type "uint8_t"\n@c_byte_size "1"\n@java_type "short"\n@js_type "short"\n@java_primitive "true"\n@go_type "uint8"\n -class JSArray <<(O,#E5D224)>> { -} -@enduml \ No newline at end of file diff --git a/doc/examples/thingml-gen/uml/CountdownUML/CountdownUML/docs/Countdown_null.plantuml b/doc/examples/thingml-gen/uml/CountdownUML/CountdownUML/docs/Countdown_null.plantuml deleted file mode 100644 index 4e7993dd5..000000000 --- a/doc/examples/thingml-gen/uml/CountdownUML/CountdownUML/docs/Countdown_null.plantuml +++ /dev/null @@ -1,19 +0,0 @@ -@startuml -skinparam defaultTextAlignment left -caption Behavior of thing Countdown -[*] --> default -state default{ -state Counting{ - Counting : entry / do...end - -Counting --> Counting : e:timer?timer_timeout\naction current = current - 1\n - -Counting --> Stopped : [current == 0]\naction timer!timer_cancel(TimerID)\n -} -state Stopped{ - Stopped : entry / println "Stopped."\n -} -Stopped --> [*] -[*] --> Counting -} -@enduml diff --git a/doc/examples/thingml-gen/uml/CountdownUML/CountdownUML/docs/TimerArduino_SoftTimer.plantuml b/doc/examples/thingml-gen/uml/CountdownUML/CountdownUML/docs/TimerArduino_SoftTimer.plantuml deleted file mode 100644 index 558da82f4..000000000 --- a/doc/examples/thingml-gen/uml/CountdownUML/CountdownUML/docs/TimerArduino_SoftTimer.plantuml +++ /dev/null @@ -1,13 +0,0 @@ -@startuml -skinparam defaultTextAlignment left -caption Behavior of thing TimerArduino -[*] --> SoftTimer -state SoftTimer{ -state default_3{ - default_3 : m:timer?timer_start / [m.time > 0]\naction startTimer(...)\n - default_3 : m:timer?timer_cancel / \naction cancel(m.id)\n -} -[*] --> default_3 - SoftTimer : entry / init_arrays()\n -} -@enduml diff --git a/doc/examples/thingml-gen/uml/CountdownUML/CountdownUML/docs/TimerJS_SoftTimer.plantuml b/doc/examples/thingml-gen/uml/CountdownUML/CountdownUML/docs/TimerJS_SoftTimer.plantuml deleted file mode 100644 index 9a0b56cdb..000000000 --- a/doc/examples/thingml-gen/uml/CountdownUML/CountdownUML/docs/TimerJS_SoftTimer.plantuml +++ /dev/null @@ -1,12 +0,0 @@ -@startuml -skinparam defaultTextAlignment left -caption Behavior of thing TimerJS -[*] --> SoftTimer -state SoftTimer{ -state default{ - default : m:timer?timer_start / [m.time > 0]\naction startTimer(...)\n - default : m:timer?timer_cancel / \naction cancel(m.id)\n -} -[*] --> default -} -@enduml diff --git a/doc/examples/thingml-gen/uml/CountdownUML/CountdownUML/docs/TimerJava_SoftTimer.plantuml b/doc/examples/thingml-gen/uml/CountdownUML/CountdownUML/docs/TimerJava_SoftTimer.plantuml deleted file mode 100644 index 9a12748d2..000000000 --- a/doc/examples/thingml-gen/uml/CountdownUML/CountdownUML/docs/TimerJava_SoftTimer.plantuml +++ /dev/null @@ -1,12 +0,0 @@ -@startuml -skinparam defaultTextAlignment left -caption Behavior of thing TimerJava -[*] --> SoftTimer -state SoftTimer{ -state default_4{ - default_4 : m:timer?timer_start / [m.time > 0]\naction startTimer(...)\n - default_4 : m:timer?timer_cancel / \naction cancel(m.id)\n -} -[*] --> default_4 -} -@enduml diff --git a/doc/examples/thingml-gen/uml/CountdownUML/CountdownUML/docs/TimerPosix_SoftTimer.plantuml b/doc/examples/thingml-gen/uml/CountdownUML/CountdownUML/docs/TimerPosix_SoftTimer.plantuml deleted file mode 100644 index ddf41fd6f..000000000 --- a/doc/examples/thingml-gen/uml/CountdownUML/CountdownUML/docs/TimerPosix_SoftTimer.plantuml +++ /dev/null @@ -1,13 +0,0 @@ -@startuml -skinparam defaultTextAlignment left -caption Behavior of thing TimerPosix -[*] --> SoftTimer -state SoftTimer{ -state default_2{ - default_2 : m:timer?timer_start / [m.time > 0]\naction startTimer(...)\n - default_2 : m:timer?timer_cancel / \naction cancel(m.id)\n -} -[*] --> default_2 - SoftTimer : entry / start_soft_timer_process()\n -} -@enduml diff --git a/doc/examples/thingml-gen/uml/CountdownUML/CountdownUML_merged.thingml b/doc/examples/thingml-gen/uml/CountdownUML/CountdownUML_merged.thingml deleted file mode 100644 index 486b9c56f..000000000 --- a/doc/examples/thingml-gen/uml/CountdownUML/CountdownUML_merged.thingml +++ /dev/null @@ -1,453 +0,0 @@ -thing Countdown includes TimerClientPort { - readonly property TimerID : UInt8 = 1 - readonly property StartTime : UInt8 = 10 - statechart init Counting { - property current : UInt8 = StartTime - state Counting { - on entry do - println current - timer!timer_start(TimerID, 1000) - end - transition -> Counting - event e : timer?timer_timeout - action current = current - 1 - transition -> Stopped guard current == 0 - action timer!timer_cancel(TimerID) - } - final state Stopped { - on entry println "Stopped." - } - } -} -datatype Byte<1> - @type_checker "Byte" - @c_type "uint8_t" - @c_byte_size "1" - @java_type "byte" - @js_type "byte" - @java_primitive "true" - @go_type "byte" -datatype Char<1> - @type_checker "Byte" - @c_type "char" - @c_byte_size "1" - @java_type "byte" - @js_type "byte" - @java_primitive "true" - @go_type "byte" -datatype Boolean<1> - @type_checker "Boolean" - @c_type "bool" - @c_byte_size "1" - @java_type "boolean" - @js_type "boolean" - @java_primitive "true" - @go_type "bool" -datatype Integer<2> - @type_checker "Integer" - @c_type "int" - @c_byte_size "2" - @java_type "short" - @js_type "short" - @java_primitive "true" - @go_type "int16" -datatype UInt8<1> - @type_checker "Integer" - @c_type "uint8_t" - @c_byte_size "1" - @java_type "short" - @js_type "short" - @java_primitive "true" - @go_type "uint8" -datatype Int8<1> - @type_checker "Integer" - @c_type "int8_t" - @c_byte_size "1" - @java_type "byte" - @js_type "byte" - @java_primitive "true" - @go_type "int8" -datatype UInt16<2> - @type_checker "Integer" - @c_type "uint16_t" - @c_byte_size "2" - @java_type "int" - @js_type "int" - @java_primitive "true" - @go_type "uint16" -datatype Int16<2> - @type_checker "Integer" - @c_type "int16_t" - @c_byte_size "2" - @java_type "short" - @js_type "short" - @java_primitive "true" - @go_type "int16" -datatype Int32<4> - @type_checker "Integer" - @c_type "int32_t" - @c_byte_size "4" - @java_type "int" - @js_type "int" - @java_primitive "true" - @go_type "int32" -datatype UInt32<4> - @type_checker "Integer" - @c_type "uint32_t" - @c_byte_size "4" - @java_type "long" - @js_type "long" - @java_primitive "true" - @go_type "uint32" -datatype Long<4> - @type_checker "Integer" - @c_type "long" - @c_byte_size "4" - @java_type "int" - @js_type "int" - @java_primitive "true" - @go_type "int32" -datatype ULong<4> - @type_checker "Integer" - @c_type "unsigned long" - @c_byte_size "4" - @java_type "long" - @js_type "long" - @java_primitive "true" - @go_type "uint32" -datatype LongLong<8> - @type_checker "Integer" - @c_type "long long" - @c_byte_size "8" - @java_type "long" - @js_type "long" - @java_primitive "true" - @go_type "int64" -datatype Float<4> - @type_checker "Real" - @c_type "float" - @c_byte_size "4" - @java_type "float" - @js_type "float" - @java_primitive "true" - @go_type "float32" -datatype Double<8> - @type_checker "Real" - @c_type "double" - @c_byte_size "8" - @java_type "double" - @js_type "double" - @java_primitive "true" - @go_type "float64" -object String - @serializable - @c_type "char *" - @c_byte_size "*" - @java_type "String" - @js_type "String" - @go_type "string" -enumeration DigitalState - @type_checker "Integer" - @java_type "byte" - @java_primitive "true" - @c_byte_size "1" - @c_type "uint8_t" - @go_type "uint8" - { - LOW @enum_val "0" - HIGH @enum_val "1" -} -thing fragment TimerMsgs { - message timer_start(id : UInt8, time : UInt16) - message timer_cancel(id : UInt8) - message timer_timeout(id : UInt8) -} -thing fragment TimerClientPort includes TimerMsgs { - required port timer { - sends timer_start sends timer_cancel receives timer_timeout - } -} -thing fragment Timer includes TimerMsgs { - provided port timer { - sends timer_timeout receives timer_start receives timer_cancel - } -} -thing TimerJava includes Timer @java_import "import java.util.*;" @java_features " - Hashtable tasks = new Hashtable(); - Timer timer = new java.util.Timer();" { - function startTimer(id : UInt8, delay : UInt16) do - cancel(id) - `final int t_id = ` & id & `;` - `TimerTask t = new TimerTask() { public void run(){` - timer!timer_timeout(`t_id` as UInt8) - ` - } }; - tasks.put(t_id, t); - timer.schedule(t, ` & delay & `);` - end - function cancel(id : UInt8) do - `TimerTask t = tasks.get(` & id & `);` - `if (t != null) t.cancel();` - `timer.purge();` - end - statechart SoftTimer init default { - state default { - internal - event m : timer?timer_start - guard m.time > 0 - action startTimer(m.id, m.time) - internal cancel - event m : timer?timer_cancel - action cancel(m.id) - } - } -} -object JSArray -thing TimerJS includes Timer { - property Timeouts : JSArray = `{}` as JSArray - function startTimer(id : UInt8, delay : UInt16) do - ` - if (` & Timeouts & `[` & id & `] != undefined) { - ` - cancel(id) - ` - } - - ` & Timeouts & `[` & id & `] = setTimeout(() => { - ` - timer!timer_timeout(id) - ` - ` & Timeouts & `[` & id & `] = undefined; - }, ` & delay & `); - ` - end - function cancel(id : UInt8) do - ` - if (` & Timeouts & `[` & id & `] != undefined) { - clearTimeout(` & Timeouts & `[` & id & `]); - ` & Timeouts & `[` & id & `] = undefined; - } - ` - end - statechart SoftTimer init default { - state default { - internal - event m : timer?timer_start - guard m.time > 0 - action startTimer(m.id, m.time) - internal cancel - event m : timer?timer_cancel - action cancel(m.id) - } - } -} -thing TimerPosix includes Timer @c_header " -#include -#include -#include - -#define NB_SOFT_TIMERS 16 -" @c_global "uint32_t Timer_timeouts[NB_SOFT_TIMERS]; -uint8_t Timer_wraps[NB_SOFT_TIMERS]; -uint32_t Timer_prev; -pthread_mutex_t Timer_mut;" { - readonly property NB_SOFT_TIMERS : UInt16 = `NB_SOFT_TIMERS` as UInt16 - readonly property SOFT_TIMER_PERIOD : UInt16 = 4 - function time_ms() : UInt32 do - `struct timespec current; - int res; - uint32_t millis = 0; - - res = clock_gettime(CLOCK_MONOTONIC, ¤t); - if (res != 0) { - perror("[ERROR]: Could not get current time : "); - } else { - millis = current.tv_sec * 1000; - millis += current.tv_nsec / 1000000; - }` - return `millis` as UInt32 - end - function sleep_ms(timeout_ms : UInt16) do - `struct timeval tv; - tv.tv_sec = ` & timeout_ms & `/1000; - tv.tv_usec = (` & timeout_ms & `%1000) * 1000; - select(0, NULL, NULL, NULL, &tv);` - end - function start_soft_timer_process() @fork_linux_thread "true" do - `pthread_mutex_init(&Timer_mut, NULL); - uint8_t i; - for (i = 0; i < ` & NB_SOFT_TIMERS & `; i++) { - Timer_timeouts[i] = 0; - Timer_wraps[i] = 0; - } - Timer_prev = ` & time_ms()& `;` - while (true) do - sleep_ms(SOFT_TIMER_PERIOD) - `pthread_mutex_lock(&Timer_mut); - uint32_t current = ` & time_ms()& `; - uint8_t i; - for (i = 0; i < ` & NB_SOFT_TIMERS & `; i++) { - if (Timer_timeouts[i] > 0) { - if (current >= Timer_prev) { - // Normal time progression - if (current > Timer_timeouts[i] && Timer_wraps[i] == 0) {` - timer!timer_timeout(`i` as UInt8) - `Timer_timeouts[i] = 0; - Timer_wraps[i] = 0; - } - } else { - // A wraparound has occurred - if (Timer_wraps[i] == 0) {` - timer!timer_timeout(`i` as UInt8) - `Timer_timeouts[i] = 0; - } else { - Timer_wraps[i] = 0; - if (current > Timer_timeouts[i]) {` - timer!timer_timeout(`i` as UInt8) - `Timer_timeouts[i] = 0; - } - } - } - } - } - Timer_prev = current; - pthread_mutex_unlock(&Timer_mut);` - end - end - function startTimer(id : UInt8, delay : UInt16) do - ` - if (` & id & ` < NB_SOFT_TIMERS) { - uint32_t current = ` & time_ms()& `; - uint32_t timeout = current + ` & delay & `; - if (timeout == 0) timeout = 1; - - pthread_mutex_lock(&Timer_mut); - Timer_timeouts[` & id & `] = timeout; - Timer_wraps[` & id & `] = (timeout > current) ? 0 : 1; - pthread_mutex_unlock(&Timer_mut); - } - ` - end - function cancel(id : UInt8) do - ` - if (` & id & ` < NB_SOFT_TIMERS) { - pthread_mutex_lock(&Timer_mut); - Timer_timeouts[` & id & `] = 0; - Timer_wraps[` & id & `] = 0; - pthread_mutex_unlock(&Timer_mut); - } - ` - end - statechart SoftTimer init default { - on entry start_soft_timer_process() - state default { - internal - event m : timer?timer_start - guard m.time > 0 - action startTimer(m.id, m.time) - internal cancel - event m : timer?timer_cancel - action cancel(m.id) - } - } -} -thing TimerArduino includes Timer @c_header " -#define NB_SOFT_TIMERS 16 -" @c_global "uint32_t Timer_timeouts[NB_SOFT_TIMERS]; -uint8_t Timer_wraps[NB_SOFT_TIMERS]; -uint32_t Timer_prev;" { - readonly property NB_SOFT_TIMERS : UInt16 = `NB_SOFT_TIMERS` as UInt16 - function time_ms() : UInt32 do - return `millis()` as UInt32 - end - function init_arrays() do - `uint8_t i; - for (i = 0; i < ` & NB_SOFT_TIMERS & `; i++) { - Timer_timeouts[i] = 0; - Timer_wraps[i] = 0; - } - Timer_prev = ` & time_ms()& `;` - end - function poll_soft_timers() @scheduler_polling "true" do - `uint32_t current = ` & time_ms()& `; - uint8_t i; - for (i = 0; i < ` & NB_SOFT_TIMERS & `; i++) { - if (Timer_timeouts[i] > 0) { - if (current >= Timer_prev) { - // Normal time progression - if (current > Timer_timeouts[i] && Timer_wraps[i] == 0) {` - timer!timer_timeout(`i` as UInt8) - `Timer_timeouts[i] = 0; - Timer_wraps[i] = 0; - } - } else { - // A wraparound has occurred - if (Timer_wraps[i] == 0) {` - timer!timer_timeout(`i` as UInt8) - `Timer_timeouts[i] = 0; - } else { - Timer_wraps[i] = 0; - if (current > Timer_timeouts[i]) {` - timer!timer_timeout(`i` as UInt8) - `Timer_timeouts[i] = 0; - } - } - } - } - }` - end - function startTimer(id : UInt8, delay : UInt16) do - ` - if (` & id & ` < NB_SOFT_TIMERS) { - uint32_t current = ` & time_ms()& `; - uint32_t timeout = current + ` & delay & `; - if (timeout == 0) timeout = 1; - - Timer_timeouts[` & id & `] = timeout; - Timer_wraps[` & id & `] = (timeout > current) ? 0 : 1; - } - ` - end - function cancel(id : UInt8) do - ` - if (` & id & ` < NB_SOFT_TIMERS) { - Timer_timeouts[` & id & `] = 0; - Timer_wraps[` & id & `] = 0; - } - ` - end - statechart SoftTimer init default { - on entry init_arrays() - state default { - internal - event m : timer?timer_start - guard m.time > 0 - action startTimer(m.id, m.time) - internal cancel - event m : timer?timer_cancel - action cancel(m.id) - } - } -} -configuration CountdownArduino @compiler "arduino" @arduino_stdout "Serial" { - instance countdown : Countdown - instance timer : TimerArduino - connector countdown.timer => timer . timer -} -configuration CountdownPosix @compiler "posix" { - instance countdown : Countdown - instance timer : TimerPosix - connector countdown.timer => timer . timer -} -configuration CountdownJava @compiler "java" { - instance countdown : Countdown - instance timer : TimerJava - connector countdown.timer => timer . timer -} -configuration CountdownUML @compiler "uml" { - instance countdown : Countdown - instance timer1 : TimerJava - instance timer2 : TimerArduino - instance timer3 : TimerPosix - instance timer4 : TimerJS -} diff --git a/doc/examples/thingml-gen/uml/Hello/Hello/docs/Hello.plantuml b/doc/examples/thingml-gen/uml/Hello/Hello/docs/Hello.plantuml deleted file mode 100644 index 7be7baf3e..000000000 --- a/doc/examples/thingml-gen/uml/Hello/Hello/docs/Hello.plantuml +++ /dev/null @@ -1,4 +0,0 @@ -@startuml -caption Instances and Connectors in configuration Hello -component "hello :HelloThing"<> -@enduml \ No newline at end of file diff --git a/doc/examples/thingml-gen/uml/Hello/Hello/docs/HelloThing_HelloStateChart.plantuml b/doc/examples/thingml-gen/uml/Hello/Hello/docs/HelloThing_HelloStateChart.plantuml deleted file mode 100644 index a32b75566..000000000 --- a/doc/examples/thingml-gen/uml/Hello/Hello/docs/HelloThing_HelloStateChart.plantuml +++ /dev/null @@ -1,12 +0,0 @@ -@startuml -skinparam defaultTextAlignment left -caption Behavior of thing HelloThing -[*] --> HelloStateChart -state HelloStateChart{ -state HelloState_1{ - HelloState_1 : entry / println "Hello World!"\n -} -HelloState_1 --> [*] -[*] --> HelloState_1 -} -@enduml diff --git a/doc/examples/thingml-gen/uml/Hello/Hello/docs/Hello_class.plantuml b/doc/examples/thingml-gen/uml/Hello/Hello/docs/Hello_class.plantuml deleted file mode 100644 index 44058e439..000000000 --- a/doc/examples/thingml-gen/uml/Hello/Hello/docs/Hello_class.plantuml +++ /dev/null @@ -1,5 +0,0 @@ -@startuml -caption Things used in configuration Hello -class HelloThing <<(T,#5BBF09)PIM>> { -} -@enduml \ No newline at end of file diff --git a/doc/examples/thingml-gen/uml/Hello/Hello/docs/Hello_class_compact.plantuml b/doc/examples/thingml-gen/uml/Hello/Hello/docs/Hello_class_compact.plantuml deleted file mode 100644 index 44058e439..000000000 --- a/doc/examples/thingml-gen/uml/Hello/Hello/docs/Hello_class_compact.plantuml +++ /dev/null @@ -1,5 +0,0 @@ -@startuml -caption Things used in configuration Hello -class HelloThing <<(T,#5BBF09)PIM>> { -} -@enduml \ No newline at end of file diff --git a/doc/examples/thingml-gen/uml/Hello/Hello/docs/Hello_datatypes.plantuml b/doc/examples/thingml-gen/uml/Hello/Hello/docs/Hello_datatypes.plantuml deleted file mode 100644 index e136a6c34..000000000 --- a/doc/examples/thingml-gen/uml/Hello/Hello/docs/Hello_datatypes.plantuml +++ /dev/null @@ -1,3 +0,0 @@ -@startuml -caption Datatypes used in configuration Hello -@enduml \ No newline at end of file diff --git a/doc/examples/thingml-gen/uml/Hello/Hello_merged.thingml b/doc/examples/thingml-gen/uml/Hello/Hello_merged.thingml deleted file mode 100644 index 7198743df..000000000 --- a/doc/examples/thingml-gen/uml/Hello/Hello_merged.thingml +++ /dev/null @@ -1,10 +0,0 @@ -thing HelloThing { - statechart HelloStateChart init HelloState { - final state HelloState { - on entry println "Hello World!" - } - } -} -configuration Hello { - instance hello : HelloThing -} diff --git a/doc/examples/thingml-gen/uml/MQTTAdapterTest/MQTTAdapterTest_merged.thingml b/doc/examples/thingml-gen/uml/MQTTAdapterTest/MQTTAdapterTest_merged.thingml deleted file mode 100644 index 376147203..000000000 --- a/doc/examples/thingml-gen/uml/MQTTAdapterTest/MQTTAdapterTest_merged.thingml +++ /dev/null @@ -1,627 +0,0 @@ -thing MQTTAdapterTest includes MQTTAdapterMsgs , TimerMsgs { - required port clock { - sends timer_start sends timer_cancel receives timer_timeout - } - required port mqtt @sync_send "true" { - sends mqtt_connect sends mqtt_disconnect sends mqtt_publish sends mqtt_subscribe sends mqtt_set_credentials sends mqtt_set_prefix receives mqtt_connected receives mqtt_disconnected receives mqtt_message - } - readonly property client_id : String = "TestClient1" - property broker_host : String = "localhost" - property broker_port : UInt16 = 1883 - property broker_user : String = `null` - property broker_pass : String = `null` - property broker_tls : Boolean = false - readonly property timer_id : UInt8 = 0 - function publish_hello() do - mqtt!mqtt_publish("Hello", `"World".getBytes()`, 5) - end - statechart MQTTAdapterTestSC init DISCONNECTED { - on entry do - if (broker_user != `null`) mqtt!mqtt_set_credentials(broker_user, broker_pass) - mqtt!mqtt_connect(client_id, broker_host, broker_port, broker_tls) - end - state DISCONNECTED { - transition -> CONNECTED - event mqtt?mqtt_connected - action print "Client got mqtt_connected\n" - } - state CONNECTED { - on entry do - mqtt!mqtt_set_prefix("models18/") - mqtt!mqtt_subscribe("#") - publish_hello() - clock!timer_start(timer_id, 5000) - end - internal - event e : clock?timer_timeout - guard e.id == timer_id - action do - publish_hello() - clock!timer_start(timer_id, 5000) - end - internal - event m : mqtt?mqtt_message - action do - `System.out.println("RCV topic:"+` & m.topic & `+" payload:" + ` & m.payload & `);` - end - transition -> DISCONNECTED - event mqtt?mqtt_disconnected - action print "Client got mqtt_disconnected\n" - } - } -} -object MQTTMessage @java_type "org.eclipse.paho.client.mqttv3.MqttMessage" -object Throwable @java_type "Throwable" -object IMqttDeliveryToken @java_type "IMqttDeliveryToken" -thing JavaMQTTAdapter includes MQTTAdapterMsgs @maven_dep " - - org.eclipse.paho - org.eclipse.paho.client.mqttv3 - 1.2.0 - - - - org.json - org.json - chargebee-1.0 - " @java_interface "org.eclipse.paho.client.mqttv3.MqttCallbackExtended" @java_import "import java.util.logging.Logger;" @java_import "import java.util.logging.Level;" @java_import "import org.eclipse.paho.client.mqttv3.*;" @java_import "import org.eclipse.paho.client.mqttv3.persist.*;" @java_features "org.eclipse.paho.client.mqttv3.MqttClient clientPub, clientSub;" { - provided port mqtt @sync_send "true" { - sends mqtt_connected sends mqtt_disconnected sends mqtt_message receives mqtt_connect receives mqtt_disconnect receives mqtt_publish receives mqtt_subscribe receives mqtt_set_credentials receives mqtt_set_prefix - } - property broker_uri : String = "tcp://localhost:1883" - property client_id : String = `null` - property username : String = `null` - property password : String = `null` - property topic_prefix : String = `null` - function setTopicPrefix(src : String) do - topic_prefix = src - end - function mqtt_connect() : Boolean do - `try {` - `MemoryPersistence persistence = new MemoryPersistence();` - `Logger.getLogger(this.getClass().getName()).log(Level.INFO, "MQTT Connect to: " + ` & broker_uri & `);` - `MqttConnectOptions connOpts = new MqttConnectOptions();` - `connOpts.setCleanSession(true);` - `connOpts.setAutomaticReconnect(true);` - if (username != `null` and password != `null`) do - `connOpts.setUserName(` & username & `);` - `connOpts.setPassword(` & password & `.toCharArray());` - end - if (client_id == `null`) do - client_id = `MqttClient.generateClientId()` - end - `clientSub = new MqttClient(` & broker_uri & `, ` & client_id & ` + "_Sub", persistence);` - `clientPub = new MqttClient(` & broker_uri & `, ` & client_id & ` + "_Pub", persistence);` - `clientSub. setCallback(this);` - `clientSub.connect(connOpts);` - `clientPub.connect(connOpts);` - `} catch (org.eclipse.paho.client.mqttv3.MqttException ex) {` - `Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);` - return false - `}` - return true - end - function mqtt_publish(topic : String, payload : Buffer, size : UInt16) : Boolean do - if (`clientPub == null`) return false - `try { - Logger.getLogger(this.getClass().getName()).log(Level.INFO, "MQTT Publish: " + ` & topic & ` + " -> " + new String(` & payload & `)); - MqttMessage message = new MqttMessage(` & payload & `); - if (` & topic_prefix & ` != null) clientPub.publish(` & topic_prefix & ` + ` & topic & `, message); - else clientPub.publish(` & topic & `, message); - } catch (org.eclipse.paho.client.mqttv3.MqttException ex) { - Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);` - return false - `}` - return true - end - function mqtt_subscribe(topic : String) : Boolean do - if (`clientSub == null`) return false - `try { - Logger.getLogger(this.getClass().getName()).log(Level.INFO, "MQTT Subscribe: " + ` & topic & `); - if (` & topic_prefix & ` != null) clientSub.subscribe(` & topic_prefix & ` + ` & topic & `); - else clientSub.subscribe(` & topic & `); - } catch (org.eclipse.paho.client.mqttv3.MqttException ex) { - Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);` - return false - `}` - return true - end - function messageArrived(topic : String, m : MQTTMessage) @override "true" do - print "Message arrived on topic " - print topic - print "\n" - end - function connectionLost(t : Throwable) @override "true" do - print "connectionLost \n" - mqtt!mqtt_disconnected() - end - function deliveryComplete(imdt : IMqttDeliveryToken) @override "true" do - print "deliveryComplete \n" - end - function connectComplete(reconnect : Boolean, serverURI : String) @override "true" do - print "connectComplete \n" - mqtt!mqtt_connected() - end - statechart MQTTAdapterThing init Start { - state Start { - } - internal - event m : mqtt?mqtt_set_credentials - action do - username = m.usr - password = m.pwd - end - internal - event m : mqtt?mqtt_set_prefix - action do - setTopicPrefix(m.prefix) - end - internal - event m : mqtt?mqtt_connect - action do - client_id = m.client_id - `String uri;` - if (m.tls) `uri = "ssl://";` - else `uri = "tcp://";` - `uri += ` & m.host & ` + ":" + ` & m.portno & `;` - broker_uri = `uri` - mqtt_connect() - end - internal - event m : mqtt?mqtt_publish - action do - mqtt_publish(m.topic, m.payload, m.size) - end - internal - event m : mqtt?mqtt_subscribe - action do - mqtt_subscribe(m.topic) - end - } -} -thing fragment TimerMsgs { - message timer_start(id : UInt8, time : UInt16) - message timer_cancel(id : UInt8) - message timer_timeout(id : UInt8) -} -thing fragment TimerClientPort includes TimerMsgs { - required port timer { - sends timer_start sends timer_cancel receives timer_timeout - } -} -thing fragment Timer includes TimerMsgs { - provided port timer { - sends timer_timeout receives timer_start receives timer_cancel - } -} -thing TimerJava includes Timer @java_import "import java.util.*;" @java_features " - Hashtable tasks = new Hashtable(); - Timer timer = new java.util.Timer();" { - function startTimer(id : UInt8, delay : UInt16) do - cancel(id) - `final int t_id = ` & id & `;` - `TimerTask t = new TimerTask() { public void run(){` - timer!timer_timeout(`t_id` as UInt8) - ` - } }; - tasks.put(t_id, t); - timer.schedule(t, ` & delay & `);` - end - function cancel(id : UInt8) do - `TimerTask t = tasks.get(` & id & `);` - `if (t != null) t.cancel();` - `timer.purge();` - end - statechart SoftTimer init default { - state default { - internal - event m : timer?timer_start - guard m.time > 0 - action startTimer(m.id, m.time) - internal cancel - event m : timer?timer_cancel - action cancel(m.id) - } - } -} -object JSArray -thing TimerJS includes Timer { - property Timeouts : JSArray = `{}` as JSArray - function startTimer(id : UInt8, delay : UInt16) do - ` - if (` & Timeouts & `[` & id & `] != undefined) { - ` - cancel(id) - ` - } - - ` & Timeouts & `[` & id & `] = setTimeout(() => { - ` - timer!timer_timeout(id) - ` - ` & Timeouts & `[` & id & `] = undefined; - }, ` & delay & `); - ` - end - function cancel(id : UInt8) do - ` - if (` & Timeouts & `[` & id & `] != undefined) { - clearTimeout(` & Timeouts & `[` & id & `]); - ` & Timeouts & `[` & id & `] = undefined; - } - ` - end - statechart SoftTimer init default { - state default { - internal - event m : timer?timer_start - guard m.time > 0 - action startTimer(m.id, m.time) - internal cancel - event m : timer?timer_cancel - action cancel(m.id) - } - } -} -thing TimerPosix includes Timer @c_header " -#include -#include -#include - -#define NB_SOFT_TIMERS 16 -" @c_global "uint32_t Timer_timeouts[NB_SOFT_TIMERS]; -uint8_t Timer_wraps[NB_SOFT_TIMERS]; -uint32_t Timer_prev; -pthread_mutex_t Timer_mut;" { - readonly property NB_SOFT_TIMERS : UInt16 = `NB_SOFT_TIMERS` as UInt16 - readonly property SOFT_TIMER_PERIOD : UInt16 = 4 - function time_ms() : UInt32 do - `struct timespec current; - int res; - uint32_t millis = 0; - - res = clock_gettime(CLOCK_MONOTONIC, ¤t); - if (res != 0) { - perror("[ERROR]: Could not get current time : "); - } else { - millis = current.tv_sec * 1000; - millis += current.tv_nsec / 1000000; - }` - return `millis` as UInt32 - end - function sleep_ms(timeout_ms : UInt16) do - `struct timeval tv; - tv.tv_sec = ` & timeout_ms & `/1000; - tv.tv_usec = (` & timeout_ms & `%1000) * 1000; - select(0, NULL, NULL, NULL, &tv);` - end - function start_soft_timer_process() @fork_linux_thread "true" do - `pthread_mutex_init(&Timer_mut, NULL); - uint8_t i; - for (i = 0; i < ` & NB_SOFT_TIMERS & `; i++) { - Timer_timeouts[i] = 0; - Timer_wraps[i] = 0; - } - Timer_prev = ` & time_ms()& `;` - while (true) do - sleep_ms(SOFT_TIMER_PERIOD) - `pthread_mutex_lock(&Timer_mut); - uint32_t current = ` & time_ms()& `; - uint8_t i; - for (i = 0; i < ` & NB_SOFT_TIMERS & `; i++) { - if (Timer_timeouts[i] > 0) { - if (current >= Timer_prev) { - // Normal time progression - if (current > Timer_timeouts[i] && Timer_wraps[i] == 0) {` - timer!timer_timeout(`i` as UInt8) - `Timer_timeouts[i] = 0; - Timer_wraps[i] = 0; - } - } else { - // A wraparound has occurred - if (Timer_wraps[i] == 0) {` - timer!timer_timeout(`i` as UInt8) - `Timer_timeouts[i] = 0; - } else { - Timer_wraps[i] = 0; - if (current > Timer_timeouts[i]) {` - timer!timer_timeout(`i` as UInt8) - `Timer_timeouts[i] = 0; - } - } - } - } - } - Timer_prev = current; - pthread_mutex_unlock(&Timer_mut);` - end - end - function startTimer(id : UInt8, delay : UInt16) do - ` - if (` & id & ` < NB_SOFT_TIMERS) { - uint32_t current = ` & time_ms()& `; - uint32_t timeout = current + ` & delay & `; - if (timeout == 0) timeout = 1; - - pthread_mutex_lock(&Timer_mut); - Timer_timeouts[` & id & `] = timeout; - Timer_wraps[` & id & `] = (timeout > current) ? 0 : 1; - pthread_mutex_unlock(&Timer_mut); - } - ` - end - function cancel(id : UInt8) do - ` - if (` & id & ` < NB_SOFT_TIMERS) { - pthread_mutex_lock(&Timer_mut); - Timer_timeouts[` & id & `] = 0; - Timer_wraps[` & id & `] = 0; - pthread_mutex_unlock(&Timer_mut); - } - ` - end - statechart SoftTimer init default { - on entry start_soft_timer_process() - state default { - internal - event m : timer?timer_start - guard m.time > 0 - action startTimer(m.id, m.time) - internal cancel - event m : timer?timer_cancel - action cancel(m.id) - } - } -} -thing TimerArduino includes Timer @c_header " -#define NB_SOFT_TIMERS 16 -" @c_global "uint32_t Timer_timeouts[NB_SOFT_TIMERS]; -uint8_t Timer_wraps[NB_SOFT_TIMERS]; -uint32_t Timer_prev;" { - readonly property NB_SOFT_TIMERS : UInt16 = `NB_SOFT_TIMERS` as UInt16 - function time_ms() : UInt32 do - return `millis()` as UInt32 - end - function init_arrays() do - `uint8_t i; - for (i = 0; i < ` & NB_SOFT_TIMERS & `; i++) { - Timer_timeouts[i] = 0; - Timer_wraps[i] = 0; - } - Timer_prev = ` & time_ms()& `;` - end - function poll_soft_timers() @scheduler_polling "true" do - `uint32_t current = ` & time_ms()& `; - uint8_t i; - for (i = 0; i < ` & NB_SOFT_TIMERS & `; i++) { - if (Timer_timeouts[i] > 0) { - if (current >= Timer_prev) { - // Normal time progression - if (current > Timer_timeouts[i] && Timer_wraps[i] == 0) {` - timer!timer_timeout(`i` as UInt8) - `Timer_timeouts[i] = 0; - Timer_wraps[i] = 0; - } - } else { - // A wraparound has occurred - if (Timer_wraps[i] == 0) {` - timer!timer_timeout(`i` as UInt8) - `Timer_timeouts[i] = 0; - } else { - Timer_wraps[i] = 0; - if (current > Timer_timeouts[i]) {` - timer!timer_timeout(`i` as UInt8) - `Timer_timeouts[i] = 0; - } - } - } - } - }` - end - function startTimer(id : UInt8, delay : UInt16) do - ` - if (` & id & ` < NB_SOFT_TIMERS) { - uint32_t current = ` & time_ms()& `; - uint32_t timeout = current + ` & delay & `; - if (timeout == 0) timeout = 1; - - Timer_timeouts[` & id & `] = timeout; - Timer_wraps[` & id & `] = (timeout > current) ? 0 : 1; - } - ` - end - function cancel(id : UInt8) do - ` - if (` & id & ` < NB_SOFT_TIMERS) { - Timer_timeouts[` & id & `] = 0; - Timer_wraps[` & id & `] = 0; - } - ` - end - statechart SoftTimer init default { - on entry init_arrays() - state default { - internal - event m : timer?timer_start - guard m.time > 0 - action startTimer(m.id, m.time) - internal cancel - event m : timer?timer_cancel - action cancel(m.id) - } - } -} -object Buffer - @java_type " byte[]" - @java_primitive "true" - @c_type "uint8_t *" - @c_byte_size "*" -thing MQTTAdapterMsgs { - message mqtt_set_credentials(usr : String, pwd : String) - message mqtt_set_tls_certificates(cafile : String, capath : String, certfile : String, keyfile : String) - message mqtt_connect(client_id : String, host : String, portno : UInt16, tls : Boolean) - message mqtt_disconnect() - message mqtt_connected() - message mqtt_disconnected() - message mqtt_publish(topic : String, payload : Buffer, size : UInt32) - message mqtt_subscribe(topic : String) - message mqtt_set_prefix(prefix : String) - message mqtt_message(topic : String, payload : Buffer, size : UInt32) -} -thing MQTTAdapterCtrlPort includes MQTTAdapterMsgs { - required port mqtt @sync_send "true" { - sends mqtt_connect sends mqtt_disconnect receives mqtt_connected receives mqtt_disconnected - } -} -datatype Byte<1> - @type_checker "Byte" - @c_type "uint8_t" - @c_byte_size "1" - @java_type "byte" - @js_type "byte" - @java_primitive "true" - @go_type "byte" -datatype Char<1> - @type_checker "Byte" - @c_type "char" - @c_byte_size "1" - @java_type "byte" - @js_type "byte" - @java_primitive "true" - @go_type "byte" -datatype Boolean<1> - @type_checker "Boolean" - @c_type "bool" - @c_byte_size "1" - @java_type "boolean" - @js_type "boolean" - @java_primitive "true" - @go_type "bool" -datatype Integer<2> - @type_checker "Integer" - @c_type "int" - @c_byte_size "2" - @java_type "short" - @js_type "short" - @java_primitive "true" - @go_type "int16" -datatype UInt8<1> - @type_checker "Integer" - @c_type "uint8_t" - @c_byte_size "1" - @java_type "short" - @js_type "short" - @java_primitive "true" - @go_type "uint8" -datatype Int8<1> - @type_checker "Integer" - @c_type "int8_t" - @c_byte_size "1" - @java_type "byte" - @js_type "byte" - @java_primitive "true" - @go_type "int8" -datatype UInt16<2> - @type_checker "Integer" - @c_type "uint16_t" - @c_byte_size "2" - @java_type "int" - @js_type "int" - @java_primitive "true" - @go_type "uint16" -datatype Int16<2> - @type_checker "Integer" - @c_type "int16_t" - @c_byte_size "2" - @java_type "short" - @js_type "short" - @java_primitive "true" - @go_type "int16" -datatype Int32<4> - @type_checker "Integer" - @c_type "int32_t" - @c_byte_size "4" - @java_type "int" - @js_type "int" - @java_primitive "true" - @go_type "int32" -datatype UInt32<4> - @type_checker "Integer" - @c_type "uint32_t" - @c_byte_size "4" - @java_type "long" - @js_type "long" - @java_primitive "true" - @go_type "uint32" -datatype Long<4> - @type_checker "Integer" - @c_type "long" - @c_byte_size "4" - @java_type "int" - @js_type "int" - @java_primitive "true" - @go_type "int32" -datatype ULong<4> - @type_checker "Integer" - @c_type "unsigned long" - @c_byte_size "4" - @java_type "long" - @js_type "long" - @java_primitive "true" - @go_type "uint32" -datatype LongLong<8> - @type_checker "Integer" - @c_type "long long" - @c_byte_size "8" - @java_type "long" - @js_type "long" - @java_primitive "true" - @go_type "int64" -datatype Float<4> - @type_checker "Real" - @c_type "float" - @c_byte_size "4" - @java_type "float" - @js_type "float" - @java_primitive "true" - @go_type "float32" -datatype Double<8> - @type_checker "Real" - @c_type "double" - @c_byte_size "8" - @java_type "double" - @js_type "double" - @java_primitive "true" - @go_type "float64" -object String - @serializable - @c_type "char *" - @c_byte_size "*" - @java_type "String" - @js_type "String" - @go_type "string" -enumeration DigitalState - @type_checker "Integer" - @java_type "byte" - @java_primitive "true" - @c_byte_size "1" - @c_type "uint8_t" - @go_type "uint8" - { - LOW @enum_val "0" - HIGH @enum_val "1" -} -configuration MQTTAdapterTest { - instance adapter1 : JavaMQTTAdapter - instance timer : TimerJava - instance test1 : MQTTAdapterTest - connector test1.mqtt => adapter1 . mqtt - connector test1.clock => timer . timer - set test1.client_id = "Test1" - set test1.broker_host = "mqtt.tutorials.tellucloud.com" - set test1.broker_port = 1883 - set test1.broker_user = "models18" - set test1.broker_pass = "thingml" - set test1.broker_tls = false - set test1.timer_id = 1 -} diff --git a/doc/examples/thingml-gen/uml/Ping/Ping/docs/Ping.plantuml b/doc/examples/thingml-gen/uml/Ping/Ping/docs/Ping.plantuml deleted file mode 100644 index 409787b20..000000000 --- a/doc/examples/thingml-gen/uml/Ping/Ping/docs/Ping.plantuml +++ /dev/null @@ -1,6 +0,0 @@ -@startuml -caption Instances and Connectors in configuration Ping -component server<> -component client<> -client -(0- server : ping_service => ping_service -@enduml \ No newline at end of file diff --git a/doc/examples/thingml-gen/uml/Ping/Ping/docs/PingClient_PingClientMachine.plantuml b/doc/examples/thingml-gen/uml/Ping/Ping/docs/PingClient_PingClientMachine.plantuml deleted file mode 100644 index 53b5781be..000000000 --- a/doc/examples/thingml-gen/uml/Ping/Ping/docs/PingClient_PingClientMachine.plantuml +++ /dev/null @@ -1,26 +0,0 @@ -@startuml -skinparam defaultTextAlignment left -caption Behavior of thing PingClient -[*] --> PingClientMachine -state PingClientMachine{ -state Ping{ - Ping : entry / do...end - Ping : exit / counter = counter + 1\n - -Ping --> OK : e:ping_service?pong[e.seq == counter]\naction println "[OK]"\n - -Ping --> Stop : e:ping_service?pong[e.seq != counter]\naction println "[Error]"\n -} -state OK{ - -OK --> Stop : [counter > 5] - -OK --> Ping : [counter <= 5] -} -state Stop{ - Stop : entry / println "Bye."\n -} -Stop --> [*] -[*] --> Ping -} -@enduml diff --git a/doc/examples/thingml-gen/uml/Ping/Ping/docs/PingServer_null.plantuml b/doc/examples/thingml-gen/uml/Ping/Ping/docs/PingServer_null.plantuml deleted file mode 100644 index f428c4ffd..000000000 --- a/doc/examples/thingml-gen/uml/Ping/Ping/docs/PingServer_null.plantuml +++ /dev/null @@ -1,12 +0,0 @@ -@startuml -skinparam defaultTextAlignment left -caption Behavior of thing PingServer -[*] --> default -state default{ -state Active{ - -Active --> Active : m:ping_service?ping\naction ping_service!pong(m.seq)\n -} -[*] --> Active -} -@enduml diff --git a/doc/examples/thingml-gen/uml/Ping/Ping/docs/Ping_class.plantuml b/doc/examples/thingml-gen/uml/Ping/Ping/docs/Ping_class.plantuml deleted file mode 100644 index eeaf72ac2..000000000 --- a/doc/examples/thingml-gen/uml/Ping/Ping/docs/Ping_class.plantuml +++ /dev/null @@ -1,20 +0,0 @@ -@startuml -caption Things used in configuration Ping -class PingServer <<(T,#5BBF09)PIM>> { -..Port ping_service.. ->>ping -<> { -..Messages.. --ping(seq : UInt8) --pong(seq : UInt8) -} -class PingClient <<(T,#5BBF09)PIM>> { -..Port ping_service.. ->>pong -<> { -..Port ping_service.. ->>ping -<> { -..Messages.. --ping(...) --pong(...) -} -class PingClient <<(T,#5BBF09)PIM>> { -..Port ping_service.. ->>pong -<> { -} -note bottom of UInt8 : @type_checker "Integer"\n@c_type "uint8_t"\n@c_byte_size "1"\n@java_type "short"\n@js_type "short"\n@java_primitive "true"\n@go_type "uint8"\n -@enduml \ No newline at end of file diff --git a/doc/examples/thingml-gen/uml/Ping/Ping_merged.thingml b/doc/examples/thingml-gen/uml/Ping/Ping_merged.thingml deleted file mode 100644 index 3525873ea..000000000 --- a/doc/examples/thingml-gen/uml/Ping/Ping_merged.thingml +++ /dev/null @@ -1,189 +0,0 @@ -thing fragment PingMsgs { - message ping(seq : UInt8) - message pong(seq : UInt8) -} -thing PingServer includes PingMsgs { - provided port ping_service { - sends pong receives ping - } - statechart init Active { - state Active { - transition -> Active - event m : ping_service?ping - action ping_service!pong(m.seq) - } - } -} -thing PingClient includes PingMsgs { - required port ping_service { - sends ping receives pong - } - statechart PingClientMachine init Ping { - property counter : UInt8 = 0 - state Ping { - on entry do - print "Send Ping " , counter , " ... " - ping_service!ping(counter) - end - on exit counter = counter + 1 - transition -> OK - event e : ping_service?pong - guard e.seq == counter - action println "[OK]" - transition -> Stop - event e : ping_service?pong - guard e.seq != counter - action println "[Error]" - } - state OK { - transition -> Stop guard counter > 5 - transition -> Ping guard counter <= 5 - } - final state Stop { - on entry println "Bye." - } - } -} -datatype Byte<1> - @type_checker "Byte" - @c_type "uint8_t" - @c_byte_size "1" - @java_type "byte" - @js_type "byte" - @java_primitive "true" - @go_type "byte" -datatype Char<1> - @type_checker "Byte" - @c_type "char" - @c_byte_size "1" - @java_type "byte" - @js_type "byte" - @java_primitive "true" - @go_type "byte" -datatype Boolean<1> - @type_checker "Boolean" - @c_type "bool" - @c_byte_size "1" - @java_type "boolean" - @js_type "boolean" - @java_primitive "true" - @go_type "bool" -datatype Integer<2> - @type_checker "Integer" - @c_type "int" - @c_byte_size "2" - @java_type "short" - @js_type "short" - @java_primitive "true" - @go_type "int16" -datatype UInt8<1> - @type_checker "Integer" - @c_type "uint8_t" - @c_byte_size "1" - @java_type "short" - @js_type "short" - @java_primitive "true" - @go_type "uint8" -datatype Int8<1> - @type_checker "Integer" - @c_type "int8_t" - @c_byte_size "1" - @java_type "byte" - @js_type "byte" - @java_primitive "true" - @go_type "int8" -datatype UInt16<2> - @type_checker "Integer" - @c_type "uint16_t" - @c_byte_size "2" - @java_type "int" - @js_type "int" - @java_primitive "true" - @go_type "uint16" -datatype Int16<2> - @type_checker "Integer" - @c_type "int16_t" - @c_byte_size "2" - @java_type "short" - @js_type "short" - @java_primitive "true" - @go_type "int16" -datatype Int32<4> - @type_checker "Integer" - @c_type "int32_t" - @c_byte_size "4" - @java_type "int" - @js_type "int" - @java_primitive "true" - @go_type "int32" -datatype UInt32<4> - @type_checker "Integer" - @c_type "uint32_t" - @c_byte_size "4" - @java_type "long" - @js_type "long" - @java_primitive "true" - @go_type "uint32" -datatype Long<4> - @type_checker "Integer" - @c_type "long" - @c_byte_size "4" - @java_type "int" - @js_type "int" - @java_primitive "true" - @go_type "int32" -datatype ULong<4> - @type_checker "Integer" - @c_type "unsigned long" - @c_byte_size "4" - @java_type "long" - @js_type "long" - @java_primitive "true" - @go_type "uint32" -datatype LongLong<8> - @type_checker "Integer" - @c_type "long long" - @c_byte_size "8" - @java_type "long" - @js_type "long" - @java_primitive "true" - @go_type "int64" -datatype Float<4> - @type_checker "Real" - @c_type "float" - @c_byte_size "4" - @java_type "float" - @js_type "float" - @java_primitive "true" - @go_type "float32" -datatype Double<8> - @type_checker "Real" - @c_type "double" - @c_byte_size "8" - @java_type "double" - @js_type "double" - @java_primitive "true" - @go_type "float64" -object String - @serializable - @c_type "char *" - @c_byte_size "*" - @java_type "String" - @js_type "String" - @go_type "string" -enumeration DigitalState - @type_checker "Integer" - @java_type "byte" - @java_primitive "true" - @c_byte_size "1" - @c_type "uint8_t" - @go_type "uint8" - { - LOW @enum_val "0" - HIGH @enum_val "1" -} -configuration Ping { - instance client : PingClient - instance server : PingServer - connector client.ping_service => server . ping_service -} diff --git a/doc/examples/thingml-gen/uml/Robot/Robot/docs/Robot.plantuml b/doc/examples/thingml-gen/uml/Robot/Robot/docs/Robot.plantuml deleted file mode 100644 index 1771755fd..000000000 --- a/doc/examples/thingml-gen/uml/Robot/Robot/docs/Robot.plantuml +++ /dev/null @@ -1,14 +0,0 @@ -@startuml -caption Instances and Connectors in configuration Robot -component [right_wheel : WheelControl]<> -component [sdist : DistanceSensor]<> -component [robot : RobotControl]<> -component [motion : MotionControl]<> -component [left_wheel : WheelControl]<> -component [scoll : CollisionSensor]<> -[robot : RobotControl] -(0- [motion : MotionControl] : platform => ctrl -[motion : MotionControl] -(0- [left_wheel : WheelControl] : left => ctrl -[robot : RobotControl] -(0- [scoll : CollisionSensor] : bumper => data -[robot : RobotControl] -(0- [sdist : DistanceSensor] : rangefinder => data -[motion : MotionControl] -(0- [right_wheel : WheelControl] : right => ctrl -@enduml \ No newline at end of file diff --git a/doc/examples/thingml-gen/uml/Robot/Robot/docs/Robot_class.plantuml b/doc/examples/thingml-gen/uml/Robot/Robot/docs/Robot_class.plantuml deleted file mode 100644 index 316cef624..000000000 --- a/doc/examples/thingml-gen/uml/Robot/Robot/docs/Robot_class.plantuml +++ /dev/null @@ -1,69 +0,0 @@ -@startuml -caption Things used in configuration Robot -class WheelControl <<(T,#5BBF09)PIM>> { -..Properties.. --motor_position : Int16 -..Port ctrl.. ->>forward ->>backward ->>stop -<> { -..Messages.. --distance(d : UInt16) --bump(direction : UInt8) --turn(angle : Int16) --forward(speed : UInt8) --backward(speed : UInt8) --stop() --odometry(left : Int16right : Int16) --wheel_position() -} -class DistanceSensor <<(T,#5BBF09)PIM>> { -..Port data.. -<> { -..Port rangefinder.. ->>distance -..Port bumper.. ->>bump -..Port platform.. ->>odometry -<> { -..Port ctrl.. ->>forward ->>backward ->>stop ->>turn -<>wheel_position -<>wheel_position -<> { -..Port data.. -<> { -..Port ctrl.. ->>forward ->>backward ->>stop -<> { -..Messages.. --distance(...) --bump(...) --turn(...) --forward(...) --backward(...) --stop() --odometry(...) --wheel_position() -} -class DistanceSensor <<(T,#5BBF09)PIM>> { -..Port data.. -<> { -..Port rangefinder.. ->>distance -..Port bumper.. ->>bump -..Port platform.. ->>odometry -<> { -..Port ctrl.. ->>forward ->>backward ->>stop ->>turn -<>wheel_position -<>wheel_position -<> { -..Port data.. -<> { -} -note bottom of UInt16 : @type_checker "Integer"\n@c_type "uint16_t"\n@c_byte_size "2"\n@java_type "int"\n@js_type "int"\n@java_primitive "true"\n@go_type "uint16"\n -class Int16 <<(D,#D2E524)2>> { -} -note bottom of Int16 : @type_checker "Integer"\n@c_type "int16_t"\n@c_byte_size "2"\n@java_type "short"\n@js_type "short"\n@java_primitive "true"\n@go_type "int16"\n -class UInt8 <<(D,#D2E524)1>> { -} -note bottom of UInt8 : @type_checker "Integer"\n@c_type "uint8_t"\n@c_byte_size "1"\n@java_type "short"\n@js_type "short"\n@java_primitive "true"\n@go_type "uint8"\n -@enduml \ No newline at end of file diff --git a/doc/examples/thingml-gen/uml/Robot/Robot/docs/WheelControl_null.plantuml b/doc/examples/thingml-gen/uml/Robot/Robot/docs/WheelControl_null.plantuml deleted file mode 100644 index d1b3fdec1..000000000 --- a/doc/examples/thingml-gen/uml/Robot/Robot/docs/WheelControl_null.plantuml +++ /dev/null @@ -1,28 +0,0 @@ -@startuml -skinparam defaultTextAlignment left -caption Behavior of thing WheelControl -[*] --> default -state default{ -state Stopped_1{ - Stopped_1 : entry / set_motor_speed(0)\n - -Stopped_1 --> Forward_1 : e:ctrl?forward\naction set_motor_speed(e.speed)\n - -Stopped_1 --> Backward_1 : e:ctrl?backward\naction set_motor_speed( -e.speed)\n -} -state Forward_1{ - -Forward_1 --> Forward_1 : e:ctrl?forward\naction set_motor_speed(e.speed)\n - -Forward_1 --> Stopped_1 : e:ctrl?stop -} -state Backward_1{ - -Backward_1 --> Backward_1 : e:ctrl?backward\naction set_motor_speed( -e.speed)\n - -Backward_1 --> Stopped_1 : e:ctrl?stop -} -[*] --> Stopped_1 - default : entry / init_motor()\n -} -@enduml diff --git a/doc/examples/thingml-gen/uml/Robot/Robot_merged.thingml b/doc/examples/thingml-gen/uml/Robot/Robot_merged.thingml deleted file mode 100644 index d13347845..000000000 --- a/doc/examples/thingml-gen/uml/Robot/Robot_merged.thingml +++ /dev/null @@ -1,229 +0,0 @@ -thing fragment RobotMsgs { - message distance(d : UInt16) - message bump(direction : UInt8) - message turn(angle : Int16) - message forward(speed : UInt8) - message backward(speed : UInt8) - message stop() - message odometry(left : Int16, right : Int16) - message wheel_position() -} -thing RobotControl includes RobotMsgs { - required port rangefinder { - receives distance - } - required port bumper { - receives bump - } - required port platform { - sends forward sends backward sends stop sends turn receives odometry - } -} -thing DistanceSensor includes RobotMsgs { - provided port data { - sends distance - } -} -thing CollisionSensor includes RobotMsgs { - provided port data { - sends bump - } -} -thing MotionControl includes RobotMsgs { - provided port ctrl { - sends odometry receives forward receives backward receives stop receives turn - } - required port left { - sends forward sends backward sends stop receives wheel_position - } - required port right { - sends forward sends backward sends stop receives wheel_position - } -} -thing WheelControl includes RobotMsgs { - provided port ctrl { - sends wheel_position receives forward receives backward receives stop - } - property motor_position : Int16 - function init_motor() do - end - function set_motor_speed(speed : Int16) do - end - statechart init Stopped { - on entry init_motor() - state Stopped { - on entry set_motor_speed(0) - transition -> Forward - event e : ctrl?forward - action set_motor_speed(e.speed) - transition -> Backward - event e : ctrl?backward - action set_motor_speed(-e.speed) - } - state Forward { - transition -> Forward - event e : ctrl?forward - action set_motor_speed(e.speed) - transition -> Stopped - event e : ctrl?stop - } - state Backward { - transition -> Backward - event e : ctrl?backward - action set_motor_speed(-e.speed) - transition -> Stopped - event e : ctrl?stop - } - } -} -datatype Byte<1> - @type_checker "Byte" - @c_type "uint8_t" - @c_byte_size "1" - @java_type "byte" - @js_type "byte" - @java_primitive "true" - @go_type "byte" -datatype Char<1> - @type_checker "Byte" - @c_type "char" - @c_byte_size "1" - @java_type "byte" - @js_type "byte" - @java_primitive "true" - @go_type "byte" -datatype Boolean<1> - @type_checker "Boolean" - @c_type "bool" - @c_byte_size "1" - @java_type "boolean" - @js_type "boolean" - @java_primitive "true" - @go_type "bool" -datatype Integer<2> - @type_checker "Integer" - @c_type "int" - @c_byte_size "2" - @java_type "short" - @js_type "short" - @java_primitive "true" - @go_type "int16" -datatype UInt8<1> - @type_checker "Integer" - @c_type "uint8_t" - @c_byte_size "1" - @java_type "short" - @js_type "short" - @java_primitive "true" - @go_type "uint8" -datatype Int8<1> - @type_checker "Integer" - @c_type "int8_t" - @c_byte_size "1" - @java_type "byte" - @js_type "byte" - @java_primitive "true" - @go_type "int8" -datatype UInt16<2> - @type_checker "Integer" - @c_type "uint16_t" - @c_byte_size "2" - @java_type "int" - @js_type "int" - @java_primitive "true" - @go_type "uint16" -datatype Int16<2> - @type_checker "Integer" - @c_type "int16_t" - @c_byte_size "2" - @java_type "short" - @js_type "short" - @java_primitive "true" - @go_type "int16" -datatype Int32<4> - @type_checker "Integer" - @c_type "int32_t" - @c_byte_size "4" - @java_type "int" - @js_type "int" - @java_primitive "true" - @go_type "int32" -datatype UInt32<4> - @type_checker "Integer" - @c_type "uint32_t" - @c_byte_size "4" - @java_type "long" - @js_type "long" - @java_primitive "true" - @go_type "uint32" -datatype Long<4> - @type_checker "Integer" - @c_type "long" - @c_byte_size "4" - @java_type "int" - @js_type "int" - @java_primitive "true" - @go_type "int32" -datatype ULong<4> - @type_checker "Integer" - @c_type "unsigned long" - @c_byte_size "4" - @java_type "long" - @js_type "long" - @java_primitive "true" - @go_type "uint32" -datatype LongLong<8> - @type_checker "Integer" - @c_type "long long" - @c_byte_size "8" - @java_type "long" - @js_type "long" - @java_primitive "true" - @go_type "int64" -datatype Float<4> - @type_checker "Real" - @c_type "float" - @c_byte_size "4" - @java_type "float" - @js_type "float" - @java_primitive "true" - @go_type "float32" -datatype Double<8> - @type_checker "Real" - @c_type "double" - @c_byte_size "8" - @java_type "double" - @js_type "double" - @java_primitive "true" - @go_type "float64" -object String - @serializable - @c_type "char *" - @c_byte_size "*" - @java_type "String" - @js_type "String" - @go_type "string" -enumeration DigitalState - @type_checker "Integer" - @java_type "byte" - @java_primitive "true" - @c_byte_size "1" - @c_type "uint8_t" - @go_type "uint8" - { - LOW @enum_val "0" - HIGH @enum_val "1" -} -configuration Robot { - instance robot : RobotControl - instance sdist : DistanceSensor - instance scoll : CollisionSensor - instance motion : MotionControl - instance left_wheel : WheelControl - instance right_wheel : WheelControl - connector robot.rangefinder => sdist . data - connector robot.bumper => scoll . data - connector robot.platform => motion . ctrl - connector motion.left => left_wheel . ctrl - connector motion.right => right_wheel . ctrl -}