System /*-trace*/ smartbell //interazione ingresso client Request checkAvail : checkAvail(X) Reply waitingTime : waitingTime(X) //interazioni client Request notify : notify(X) Reply tempResult : tempResult(X) Dispatch accept : accept(X) Dispatch inform : inform(X) Context ctxwaiter ip [ host= "127.0.0.1" port= 8010 ] Context ctxsmartbell ip [ host= "localhost" port= 8040 ] Context ctxclientsimulator ip [ host= "127.0.0.1" port= 8060 ] ExternalQActor waiter context ctxwaiter ExternalQActor clientsimulator context ctxclientsimulator QActor smartbell context ctxsmartbell{ [# var temperature = 37 var clientID = 0 #] State s0 initial { discardMsg Off } Goto waitingForClient State waitingForClient{ println("[SMARTBELL] Waiting for a new client...") } Transition t0 whenRequest notify -> checkTemp State checkTemp{ println("[SMARTBELL] Checking your temperature...") /*[# val randomNumber = Math.random() if (randomNumber >= 0.7) temperature = 39.0 else temperature = 37.0 #]*/ } Goto badTemp if [# temperature > 37.5 #] else goodTemp State badTemp{ println("[SMARTBELL] You should go to the hospital! ") replyTo notify with tempResult : tempResult(no) } Goto waitingForClient State goodTemp{ println("[SMARTBELL] Your temperature is ok ") [# clientID++ #] replyTo notify with tempResult : tempResult(yes) } Goto waiterInfo State waiterInfo { println("[SMARTBELL] Checking table situation with the waiter... ") request waiter -m checkAvail : checkAvail( clientID ) } Transition t1 whenReply waitingTime -> informClient State informClient{ onMsg(waitingTime : waitingTime(X)){ if [# payloadArg(0).toDouble() == 0.0 #] { println("[SMARTBELL] A waiter is coming... ") forward clientsimulator -m accept : accept(enter) } else { println("[SMARTBELL] You have to wait... ") forward clientsimulator -m inform : inform($payloadArg(0)) } } } Goto waitingForClient }