System /*-trace*/ clientsimulator //interazione ordinazione client //prima immagine Dispatch readyToOrder : readyToOrder(X) //seconda immagine Request take : take(X) Reply order : order(X) //to add Dispatch serveDrink : serveDrink(X) //interazione richiesta uscita client Dispatch exitReq : exitReq(X) //interazione pagamento client Request collect : collect(X) Reply payment : payment(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= "127.0.0.1" port= 8040 ] Context ctxclientsimulator ip [ host= "localhost" port= 8060 ] ExternalQActor smartbell context ctxsmartbell ExternalQActor waiter context ctxwaiter QActor clientsimulator context ctxclientsimulator { [# var tempResult = "no" #] State init initial { println("[CLIENT] Client STARTED") discardMsg Off } Goto askToEnter State askToEnter { println("[CLIENT] Knock Knock, I'm here") request smartbell -m notify : notify } Transition t0 whenReply tempResult -> handleReply State handleReply { onMsg(tempResult : tempResult(RES)){ [# tempResult = payloadArg(0) #] } }Goto waitToEnter if [# tempResult == "yes" #] else exit State waitToEnter { } Transition t1 whenMsg inform -> wait whenMsg accept -> enter State wait { println("[CLIENT] I have to wait") onMsg(inform : inform(TIME)){ [# var Time = payloadArg(0).toLong() #] delayVar Time } } Goto enter State enter { println("[CLIENT] Choosing a drink") delay 1000 // simulate going to table and choosing a drink forward waiter -m readyToOrder : readyToOrder(1) } Transition t0 whenRequest take -> makeOrder State makeOrder { println("[CLIENT] A Na-tea-li please") replyTo take with order : order(tea) } // qua bisogna fare una transition, devo aspettare di ricevere l'ordine Transition t0 whenMsg serveDrink -> drink State drink { println("[CLIENT] *sip sip* Delicious tea") delay 10000 }Goto askToPay State askToPay { println("[CLIENT] I want to pay") forward waiter -m exitReq : exitReq(1) }Transition t0 whenRequest collect -> pay State pay { println("[CLIENT] Paying") replyTo collect with payment : payment(10) }Goto exit State exit { println("[CLIENT] Client EXIT Byeeee!") terminate 1 } }