diff options
Diffstat (limited to 'runtime/org.eclipse.etrice.modellib.java/model')
3 files changed, 380 insertions, 433 deletions
diff --git a/runtime/org.eclipse.etrice.modellib.java/model/ALogService.room b/runtime/org.eclipse.etrice.modellib.java/model/ALogService.room index 51a868f60..e20934293 100644 --- a/runtime/org.eclipse.etrice.modellib.java/model/ALogService.room +++ b/runtime/org.eclipse.etrice.modellib.java/model/ALogService.room @@ -1,70 +1,65 @@ RoomModel room.basic.service.logging { - + import room.basic.types.* from "Types.room" - + ActorClass ALogService { Interface { SPP log: Log } Structure { - usercode1 { - "import java.io.*;" - "import java.util.*;" - } - usercode2 { - "FileOutputStream file = null;" - "PrintStream p = null;" - "static long tStart = System.currentTimeMillis();" - } + usercode1 ''' + import java.io.*; + import java.util.*;''' + usercode2 ''' + FileOutputStream file = null; + PrintStream p = null; + static long tStart = System.currentTimeMillis();''' ServiceImplementation of log } Behavior { - Operation destroyUser() { - "if (p!= null) {" - "p.flush();" - "p.close();" - "p=null;" - "}" - } + Operation destroyUser() ''' + if (p!= null) { + p.flush(); + p.close(); + p=null; + }''' StateMachine { - Transition init: initial -> closed { } + Transition init: initial -> closed { + } Transition open: closed -> opened { triggers { <open: log> } - action { - "Date d=new Date(tStart);" - "try{" - "file=new FileOutputStream(fileName);" - "p=new PrintStream(file);" - "p.println(\"Log opened at \"+ d.toString());" - "p.println(\"--------------------------------------------------\");" - "} catch (Exception e){" - "System.out.println(\"Log file not opened !\");" - "}" - } + action ''' + Date d=new Date(tStart); + try{ + file=new FileOutputStream(transitionData); + p=new PrintStream(file); + p.println("Log opened at "+ d.toString()); + p.println("--------------------------------------------------"); + } catch (Exception e){ + System.out.println("Log file not opened !"); + }''' } Transition tr0: opened -> closed { triggers { <close: log> } - action { - "p.flush();" - "p.close();" - "p=null;" - } + action ''' + p.flush(); + p.close(); + p=null;''' } Transition tr1: opened -> opened { triggers { <internalLog: log> } - action { - "p.println(\"Timestamp: \" + Long.toString(data.timeStamp-tStart) + \"ms\");" - "p.println(\"SenderInstance: \"+ data.sender);" - "p.println(\"UserString: \" + data.userString);" - "p.println(\"--------------------------------------------------\");" - "System.out.printf(data.userString);" - } + action ''' + p.println("Timestamp: " + Long.toString(transitionData.timeStamp-tStart) + "ms"); + p.println("SenderInstance: "+ transitionData.sender); + p.println("UserString: " + transitionData.userString); + p.println("--------------------------------------------------"); + System.out.printf(transitionData.userString);''' } State closed State opened @@ -73,35 +68,32 @@ RoomModel room.basic.service.logging { } ProtocolClass Log { - usercode2 { - "public static final int LOG_LEVEL_LOW = 1;" - "public static final int LOG_LEVEL_MEDIUM = 2;" - "public static final int LOG_LEVEL_HIGH = 3;" - } + usercode2 ''' + public static final int LOG_LEVEL_LOW = 1; + public static final int LOG_LEVEL_MEDIUM = 2; + public static final int LOG_LEVEL_HIGH = 3;''' incoming { - Message open(fileName: string) + Message open(string) Message close() - private Message internalLog(data: InternalLogData) + private Message internalLog(InternalLogData) } - conjugated PortClass { - usercode { - "static int logLevel=0;" - "InternalLogData d = new InternalLogData();" - } - Operation setLogLevel(l: int32) { - "logLevel=l;" - "if (logLevel > LOG_LEVEL_HIGH) logLevel=LOG_LEVEL_HIGH;" - } - Operation log(logLevel: int32, userString: string) sends internalLog { - "if (logLevel>LogConjPort.logLevel){" - "d.userString=userString;" - "d.timeStamp=System.currentTimeMillis();" - "d.sender=getInstancePath();" - "if (getPeerAddress()!=null)" - "getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), IN_internalLog, d.deepCopy()));" - "}" - } + conjugated PortClass + { + usercode ''' + static int logLevel=0; + InternalLogData d = new InternalLogData();''' + Operation setLogLevel(l: int32) ''' + logLevel=l; + if (logLevel > LOG_LEVEL_HIGH) logLevel=LOG_LEVEL_HIGH;''' + Operation log(logLevel: int32, userString: string) sends internalLog ''' + if (logLevel>LogConjPort.logLevel){ + d.userString=userString; + d.timeStamp=System.currentTimeMillis(); + d.sender=getInstancePath(); + if (getPeerAddress()!=null) + getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), IN_internalLog, d.deepCopy())); + }''' } } @@ -110,5 +102,4 @@ RoomModel room.basic.service.logging { Attribute sender: string Attribute timeStamp: int64 } - }
\ No newline at end of file diff --git a/runtime/org.eclipse.etrice.modellib.java/model/TcpService.room b/runtime/org.eclipse.etrice.modellib.java/model/TcpService.room index 5af3819d6..40621266a 100644 --- a/runtime/org.eclipse.etrice.modellib.java/model/TcpService.room +++ b/runtime/org.eclipse.etrice.modellib.java/model/TcpService.room @@ -2,96 +2,96 @@ RoomModel room.basic.service.tcp { import room.basic.types.* from "Types.room" - ActorClass ATcpServer { Interface { Port ControlPort: PTcpControl Port PayloadPort: PTcpPayload } Structure { - usercode1 { - "import java.net.ServerSocket;" - "import java.net.Socket;" - "import java.io.*;" - "import java.util.*;" - "" - "class ServerRxThread extends Thread{" - " private int connectionId;" - " private Socket sock;" - " PTcpPayloadPort port;" - "" - " public ServerRxThread (int connectionId, PTcpPayloadPort port, Socket sock){" - " this.sock = sock;" - " this.connectionId = connectionId;" - " this.port = port;" - " }" - "" - " public void run(){" - " try{" - " InputStream in = sock.getInputStream();" - " DTcpPayload d = new DTcpPayload();" - " d.setConnectionId(connectionId);" - " int c;" - " while ((c=in.read(d.getData()))!=-1){" - " d.setLength(c);" - " port.receive(d); " - " }" - " }catch (IOException e){" - " System.err.println(\"ServerRx: \" + e.toString());" - " }" - " }" - "}" - "" - "class ServerAcceptThread extends Thread{" - " private ServerSocket sock;" - " private PTcpPayloadPort port;" - " private ATcpServer parent;" - " public ServerAcceptThread (PTcpPayloadPort port, ServerSocket sock, ATcpServer parent){" - " this.sock = sock;" - " this.port = port;" - " this.parent = parent;" - " }" - " public void run(){" - " int cnt=0;" - " try{" - " while (true){" - " Socket s = sock.accept();" - " parent.addOutStreamToHashmap(cnt, s.getOutputStream());" - " (new ServerRxThread(cnt, port, s)).start();" - " cnt++;" - " }" - " }catch (IOException e){" - " System.err.println(\"Server Accept: \" + e.toString());" - " }" - " }" - "}" - " " - } - usercode2 { - "ServerSocket socket = null;" - "InputStream in = null;" - "OutputStream out = null;" - "Hashtable<Integer,OutputStream> outStreams = new Hashtable<Integer,OutputStream>();" - "" - "synchronized protected void addOutStreamToHashmap(int cnt, OutputStream out){" - " outStreams.put(cnt,out);" - "}" - "" - } + usercode1 ''' + import java.net.ServerSocket; + import java.net.Socket; + import java.io.*; + import java.util.*; + + class ServerRxThread extends Thread{ + private int connectionId; + private Socket sock; + PTcpPayloadPort port; + + public ServerRxThread (int connectionId, PTcpPayloadPort port, Socket sock){ + this.sock = sock; + this.connectionId = connectionId; + this.port = port; + } + + public void run(){ + try{ + InputStream in = sock.getInputStream(); + DTcpPayload d = new DTcpPayload(); + d.setConnectionId(connectionId); + int c; + while ((c=in.read(d.getData()))!=-1){ + d.setLength(c); + port.receive(d); + } + } + catch (IOException e){ + System.err.println("ServerRx: " + e.toString()); + } + } + } + + class ServerAcceptThread extends Thread{ + private ServerSocket sock; + private PTcpPayloadPort port; + private ATcpServer parent; + public ServerAcceptThread (PTcpPayloadPort port, ServerSocket sock, ATcpServer parent){ + this.sock = sock; + this.port = port; + this.parent = parent; + } + public void run(){ + int cnt=0; + try{ + while (true){ + Socket s = sock.accept(); + parent.addOutStreamToHashmap(cnt, s.getOutputStream()); + (new ServerRxThread(cnt, port, s)).start(); + cnt++; + } + } + catch (IOException e){ + System.err.println("Server Accept: " + e.toString()); + } + } + } + ''' + usercode2 ''' + ServerSocket socket = null; + InputStream in = null; + OutputStream out = null; + Hashtable<Integer,OutputStream> outStreams = new Hashtable<Integer,OutputStream>(); + + synchronized protected void addOutStreamToHashmap(int cnt, OutputStream out){ + outStreams.put(cnt,out); + } + ''' external Port ControlPort external Port PayloadPort Attribute lastError: int32 Attribute payloadPortReplocation: int32 } Behavior { - Operation stopUser() { - "try{" - "if(socket != null){" - "socket.close();" - "}" - "}catch(IOException e){" - "System.err.println(e.toString());}" - } + Operation stopUser() ''' + try{ + if (socket != null){ + socket.close(); + } + } + catch (IOException e){ + System.err.println(e.toString()); + }''' StateMachine { Transition init: initial -> closed { } @@ -99,60 +99,56 @@ RoomModel room.basic.service.tcp { triggers { <open: ControlPort> } - action { - "lastError=0;" - "try{" - "socket = new ServerSocket(data.TcpPort);" - "(new ServerAcceptThread(PayloadPort, socket, this)).start();" - "}catch(IOException e){" - "System.err.println(e.toString());" - "lastError=1;" - "}" - } + action ''' + lastError=0; + try{ + socket = new ServerSocket(transitionData.TcpPort); + (new ServerAcceptThread(PayloadPort, socket, this)).start(); + } + catch(IOException e){ + System.err.println(e.toString()); + lastError=1; + }''' } Transition tr1: opened -> closed { triggers { <close: ControlPort> } - action { - "try{" - "\tif(socket!=null){" - "\t\tsocket.close();" - "\t\t}" - "\t}catch(IOException e){" - "\tSystem.err.println(e.toString());" - "}" - } + action ''' + try{ + if(socket!=null){ + socket.close(); + } + } + catch(IOException e){ + System.err.println(e.toString()); + }''' } Transition tr2: cp cp0 -> opened { - action { - "ControlPort.established();" - } + action '''ControlPort.established();''' } Transition socketError: cp cp0 -> error { - cond { - "lastError!=0" - } - action { - "ControlPort.error();" - "try{" - "socket.close();" - "} catch(IOException e){" - "System.err.println(e.toString());" - "}" - } + cond '''lastError!=0''' + action ''' + ControlPort.error(); + try{ + socket.close(); + } + catch(IOException e){ + System.err.println(e.toString()); + }''' } Transition tr3: opened -> opened { triggers { <send: PayloadPort> } - action { - "try{" - "outStreams.get(data.getConnectionId()).write(data.getData(),0,data.length);" - "}catch(IOException e){" - "System.err.println(e.toString());" - "}" - } + action ''' + try{ + outStreams.get(transitionData.getConnectionId()).write(transitionData.getData(),0,transitionData.length); + } + catch(IOException e){ + System.err.println(e.toString()); + }''' } ChoicePoint cp0 State closed @@ -168,119 +164,110 @@ RoomModel room.basic.service.tcp { Port PayloadPort: PTcpPayload } Structure { - usercode1 { - "import java.net.Socket;" - "import java.io.*;" - - " " - "class ClientRxThread extends Thread{ " - " private Socket sock;" - " PTcpPayloadPort port;" - " public ClientRxThread (PTcpPayloadPort port, Socket sock){" - " this.sock = sock;" - " this.port = port;" - " }" - " public void run(){" - " try{" - " InputStream in = sock.getInputStream();" - " DTcpPayload d = new DTcpPayload();" - " d.setConnectionId(0);" - " int c;" - " while ((c=in.read(d.getData()))!=-1){" - " d.setLength(c);" - " port.receive(d);" - " }" - " }catch (IOException e){" - " System.err.println(\"ClientRx: \" + e.toString());" - " }" - " " - " }" - "}" - "" - } - usercode2 { - "Socket socket;" - "InputStream in;" - "OutputStream out;" - } + usercode1 ''' + import java.net.Socket; + import java.io.*; + + class ClientRxThread extends Thread{ + private Socket sock; + PTcpPayloadPort port; + public ClientRxThread (PTcpPayloadPort port, Socket sock){ + this.sock = sock; + this.port = port; + } + public void run(){ + try{ + InputStream in = sock.getInputStream(); + DTcpPayload d = new DTcpPayload(); + d.setConnectionId(0); + int c; + while ((c=in.read(d.getData()))!=-1){ + d.setLength(c); + port.receive(d); + } + } + catch (IOException e){ + System.err.println("ClientRx: " + e.toString()); + } + + } + } + ''' + usercode2 ''' + Socket socket; + InputStream in; + OutputStream out;''' external Port ControlPort external Port PayloadPort Attribute lastError: int32 } Behavior { - Operation stopUser() { - "try{" - "if(socket != null){" - "socket.close();" - "}" - "}catch(IOException e){" - "System.err.println(e.toString());}" - } + Operation stopUser() ''' + try{ + if(socket != null){ + socket.close(); + } + }catch(IOException e){ + System.err.println(e.toString());}''' StateMachine { Transition init: initial -> closed { - action { - "System.out.println(\"Client Init !\");" - } + action '''System.out.println("Client Init !");''' } Transition tr0: closed -> cp cp0 { triggers { <open: ControlPort> } - action { - "lastError=0;" - "try{" - "socket = new Socket(data.IPAddr,data.TcpPort);" - "(new ClientRxThread(PayloadPort, socket)).start();" - "out = socket.getOutputStream();" - "}catch(IOException e){" - "System.err.println(e.toString());" - "lastError=1;" - "}" - } + action ''' + lastError=0; + try{ + socket = new Socket(transitionData.IPAddr,transitionData.TcpPort); + (new ClientRxThread(PayloadPort, socket)).start(); + out = socket.getOutputStream(); + } + catch(IOException e){ + System.err.println(e.toString()); + lastError=1; + }''' } Transition tr1: opened -> closed { triggers { <close: ControlPort> } - action { - "try{" - "\tif (socket!=null){" - "\t\tsocket.close();" - "\t}" - "} catch (IOException e){" - "System.err.println(e.toString());" - "}" - } + action ''' + try{ + if (socket!=null){ + socket.close(); + } + } + catch (IOException e){ + System.err.println(e.toString()); + }''' } Transition tr2: cp cp0 -> opened { - action { - "ControlPort.established();" - } + action '''ControlPort.established();''' } Transition socketError: cp cp0 -> error { - cond { - "lastError!=0" - } - action { - "ControlPort.error();" - "try{" - "socket.close();" - "} catch(IOException e){" - "System.err.println(e.toString());" - "}" - } + cond '''lastError!=0''' + action ''' + ControlPort.error(); + try{ + socket.close(); + } + catch(IOException e){ + System.err.println(e.toString()); + }''' } Transition tr3: opened -> opened { triggers { <send: PayloadPort> } - action { - "try{" - "\tout.write(data.getData(),0,data.length);" - "\t}catch(IOException e){" - "\t\tSystem.err.println(e.toString());" - "\t}" - } + action ''' + try{ + out.write(transitionData.getData(),0,transitionData.length); + } + catch(IOException e){ + System.err.println(e.toString()); + }''' } ChoicePoint cp0 State closed @@ -292,7 +279,7 @@ RoomModel room.basic.service.tcp { ProtocolClass PTcpControl { incoming { - Message open(data: DTcpControl) + Message open(DTcpControl) Message close() } outgoing { @@ -303,10 +290,10 @@ RoomModel room.basic.service.tcp { ProtocolClass PTcpPayload { incoming { - Message send(data: DTcpPayload) + Message send(DTcpPayload) } outgoing { - Message receive(data: DTcpPayload) + Message receive(DTcpPayload) } } @@ -318,7 +305,6 @@ RoomModel room.basic.service.tcp { DataClass DTcpPayload { Attribute connectionId: int32 Attribute length: int32 - Attribute data [ 1000 ]: int8 + Attribute data [1000]: int8 } - }
\ No newline at end of file diff --git a/runtime/org.eclipse.etrice.modellib.java/model/TimingService.room b/runtime/org.eclipse.etrice.modellib.java/model/TimingService.room index ed6dad1ae..1361e4412 100644 --- a/runtime/org.eclipse.etrice.modellib.java/model/TimingService.room +++ b/runtime/org.eclipse.etrice.modellib.java/model/TimingService.room @@ -7,200 +7,170 @@ RoomModel room.basic.service.timing { SPP timer: PTimer } Structure { - usercode1 { - "import java.util.Timer;" - } - usercode2 { - "private Timer timerService = null;" - "private int taskCount = 0;" - "private static final int PURGE_LIMIT = 1000;" - } + usercode1 '''import java.util.Timer;''' + usercode2 ''' + private Timer timerService = null; + private int taskCount = 0; + private static final int PURGE_LIMIT = 1000;''' ServiceImplementation of timer } Behavior { - Operation stop() { - "System.out.println(toString() + \"::stop()\");" - "timerService.cancel();" - "timerService = null;" - } + Operation stop() ''' + System.out.println(toString() + "::stop()"); + timerService.cancel(); + timerService = null;''' StateMachine { Transition tr0: initial -> Operational { - action { - "timerService = new Timer();" - } + action '''timerService = new Timer();''' } Transition tr1: Operational -> Operational { triggers { <internalStartTimer: timer> } - action { - "// start timer" - "taskCount++;" - "if (taskCount>PURGE_LIMIT) timerService.purge();" - "int t = td.getTime();" - "timerService.scheduleAtFixedRate(((PTimerPort)ifitem).getTask(),t,t);" - } + action ''' + // start timer + taskCount++; + if (taskCount>PURGE_LIMIT) timerService.purge(); + int t = transitionData.getTime(); + timerService.scheduleAtFixedRate(((PTimerPort)ifitem).getTask(),t,t);''' } Transition tr3: Operational -> Operational { triggers { <internalStartTimeout: timer> } - action { - "// start timeout" - "taskCount++;" - "if (taskCount>PURGE_LIMIT) timerService.purge();" - "timerService.schedule(((PTimerPort)ifitem).getTask(), ((TimerData)td).getTime());" - } + action ''' + // start timeout + taskCount++; + if (taskCount>PURGE_LIMIT) timerService.purge(); + timerService.schedule(((PTimerPort)ifitem).getTask(), transitionData.getTime());''' } Transition tr4: Operational -> Operational { triggers { <kill: timer> } - action { - "// nothing to do to kill timer (handled by timer)" - } + action '''// nothing to do to kill timer (handled by timer)''' } State Operational { - entry { - "// prepare" - } + entry '''// prepare''' } } } } ProtocolClass PTimer { - usercode1 { - "import java.util.TimerTask;" - "import org.eclipse.etrice.runtime.java.messaging.RTServices;" - } - usercode2 { - "static protected class FireTimeoutTask extends TimerTask {" - " " - " private int time;" - " private int id;" - " private boolean periodic;" - " private PTimerPort port;" - " " - " public FireTimeoutTask(int time, int id, boolean periodic, PTimerPort port) {" - " this.time = time;" - " this.id = id;" - " this.periodic = periodic;" - " this.port = port;" - " }" - " " - " @Override" - " public void run() {" - " TimerData td = new TimerData(0,id);" - " if (periodic)" - " port.internalTimer(td);" - " else" - " port.internalTimeout(td);" - " }" - " " - " public int getTime() {" - " return time;" - " }" - " " - " public int getId() {" - " return id;" - " }" - "}" - "" - } + usercode1 ''' + import java.util.TimerTask; + import org.eclipse.etrice.runtime.java.messaging.RTServices;''' + usercode2 ''' + static protected class FireTimeoutTask extends TimerTask { + + private int time; + private int id; + private boolean periodic; + private PTimerPort port; + + public FireTimeoutTask(int time, int id, boolean periodic, PTimerPort port) { + this.time = time; + this.id = id; + this.periodic = periodic; + this.port = port; + } + + @Override + public void run() { + TimerData td = new TimerData(0,id); + if (periodic) + port.internalTimer(td); + else + port.internalTimeout(td); + } + + public int getTime() { + return time; + } + + public int getId() { + return id; + } + } + ''' incoming { Message kill() - private Message internalStartTimer(td: TimerData) - private Message internalStartTimeout(td: TimerData) + private Message internalStartTimer(TimerData) + private Message internalStartTimeout(TimerData) } outgoing { Message timeout() - private Message internalTimer(td: TimerData) - private Message internalTimeout(td: TimerData) + private Message internalTimer(TimerData) + private Message internalTimeout(TimerData) } regular PortClass { - usercode { - "private FireTimeoutTask task = null;" - "public TimerTask getTask() { return task; }" - } - handle - incoming internalStartTimer { - "EventWithDataMessage dataMsg = (EventWithDataMessage) msg;" - "TimerData td = (TimerData)dataMsg.getData();" - "task = new FireTimeoutTask(td.time, td.id, true, this);" - "getActor().receiveEvent(this, IN_internalStartTimer, td);" - } - handle - incoming internalStartTimeout { - "EventWithDataMessage dataMsg = (EventWithDataMessage) msg;" - "TimerData td = (TimerData)dataMsg.getData();" - "task = new FireTimeoutTask(td.time, td.id, false, this);" - "getActor().receiveEvent(this, IN_internalStartTimeout, td);" - } - handle - incoming kill { - "//regular PortClass handle kill" - "EventWithDataMessage dataMsg = (EventWithDataMessage) msg;" - "TimerData td = (TimerData)dataMsg.getData();" - "if (task!=null && task.getId()==td.getId()) {" - " task.cancel();" - "}" - } + usercode ''' + private FireTimeoutTask task = null; + public TimerTask getTask() { return task; }''' + handle incoming internalStartTimer ''' + EventWithDataMessage dataMsg = (EventWithDataMessage) msg; + TimerData transitionData = (TimerData)dataMsg.getData(); + task = new FireTimeoutTask(transitionData.time, transitionData.id, true, this); + getActor().receiveEvent(this, IN_internalStartTimer, transitionData);''' + handle incoming internalStartTimeout ''' + EventWithDataMessage dataMsg = (EventWithDataMessage) msg; + TimerData transitionData = (TimerData)dataMsg.getData(); + task = new FireTimeoutTask(transitionData.time, transitionData.id, false, this); + getActor().receiveEvent(this, IN_internalStartTimeout, transitionData);''' + handle incoming kill ''' + //regular PortClass handle kill + EventWithDataMessage dataMsg = (EventWithDataMessage) msg; + TimerData td = (TimerData)dataMsg.getData(); + if (task!=null && task.getId()==td.getId()) { + task.cancel(); + }''' } conjugated PortClass { - usercode { - "private int currentId = 0;" - "private boolean active = false;" - } - handle - outgoing internalTimer { - "//conjugated PortClass handle timer" - "EventWithDataMessage dataMsg = (EventWithDataMessage) msg;" - "TimerData td = (TimerData) dataMsg.getData();" - "if (active && td.getId()==currentId) {" - " getActor().receiveEvent(this, OUT_timeout, null);" - "}" - } - handle - outgoing internalTimeout { - "//conjugated PortClass handle timeout" - "EventWithDataMessage dataMsg = (EventWithDataMessage) msg;" - "TimerData td = (TimerData) dataMsg.getData();" - "if (active && td.getId()==currentId) {" - " active = false;" - " getActor().receiveEvent(this, OUT_timeout, null);" - "}" - } - handle - incoming kill { - "//conjugated PortClass kill" - "if (active) {" - " active = false;" - " TimerData td = new TimerData();" - " td.setId(currentId);" - " getPeerMsgReceiver().receive(" - " new EventWithDataMessage(getPeerAddress(), IN_kill, td));" - "}" - } - Operation startTimer(time_ms: int32) sends internalStartTimer { - "if (active) return;" - " active = true;" - "" - "if (RTServices.getInstance().getSubSystem().hasGeneratedMSCInstrumentation())" - " DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_internalStartTimer]);" - "getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), IN_internalStartTimer, new TimerData(time_ms,++currentId)));" - "" - } - Operation startTimeout(time_ms: int32) sends internalStartTimeout { - "if (active) return;" - " active = true;" - "" - "if (RTServices.getInstance().getSubSystem().hasGeneratedMSCInstrumentation())" - " DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_internalStartTimeout]);" - "getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), IN_internalStartTimeout, new TimerData(time_ms,++currentId)));" - } + usercode ''' + private int currentId = 0; + private boolean active = false;''' + handle outgoing internalTimer ''' + //conjugated PortClass handle timer + EventWithDataMessage dataMsg = (EventWithDataMessage) msg; + TimerData transitionData = (TimerData) dataMsg.getData(); + if (active && transitionData.getId()==currentId) { + getActor().receiveEvent(this, OUT_timeout, null); + }''' + handle outgoing internalTimeout ''' + //conjugated PortClass handle timeout + EventWithDataMessage dataMsg = (EventWithDataMessage) msg; + TimerData transitionData = (TimerData) dataMsg.getData(); + if (active && transitionData.getId()==currentId) { + active = false; + getActor().receiveEvent(this, OUT_timeout, null); + }''' + handle incoming kill ''' + //conjugated PortClass kill + if (active) { + active = false; + TimerData td = new TimerData(); + td.setId(currentId); + getPeerMsgReceiver().receive( + new EventWithDataMessage(getPeerAddress(), IN_kill, td)); + }''' + Operation startTimer(time_ms: int32) sends internalStartTimer ''' + if (active) return; + active = true; + + if (RTServices.getInstance().getSubSystem().hasGeneratedMSCInstrumentation()) + DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_internalStartTimer]); + getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), IN_internalStartTimer, new TimerData(time_ms,++currentId))); + ''' + Operation startTimeout(time_ms: int32) sends internalStartTimeout ''' + if (active) return; + active = true; + + if (RTServices.getInstance().getSubSystem().hasGeneratedMSCInstrumentation()) + DebuggingService.getInstance().addMessageAsyncOut(getAddress(), getPeerAddress(), messageStrings[IN_internalStartTimeout]); + getPeerMsgReceiver().receive(new EventWithDataMessage(getPeerAddress(), IN_internalStartTimeout, new TimerData(time_ms,++currentId)));''' } } |