Commit ff289649 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Update observer example

parent cbd2b0a6
system my_observer;
/* CIF TEXT (145, 177), (483, 168) */
/* CIF TEXT (145, 177), (507, 168) */
use datamodel comment 'observer.asn';
exported procedure observe;
......@@ -8,17 +8,23 @@ system my_observer;
referenced;
signal pre_in_orchestrator_pulse (t_int) renames input pulse to orchestrator;
signal foo renames input pulse to orchestrator;
/* CIF ENDTEXT */
channel c
from env to my_observer with observe;
from env to my_observer with observe,
pre_in_orchestrator_pulse,
foo;
endchannel;
block my_observer;
signalroute r
from env to my_observer with observe;
from env to my_observer with observe,
pre_in_orchestrator_pulse,
foo;
connect c and r;
/* CIF PROCESS (250, 87), (150, 75) */
process my_observer;
/* CIF TEXT (46, 57), (256, 184) */
/* CIF TEXT (0, 57), (256, 184) */
monitor st System_State;
monitor event Observable_Event;
......@@ -31,23 +37,23 @@ system my_observer;
dcl p1 T_Int;
/* CIF ENDTEXT */
/* CIF procedure (1794, 152), (70, 35) */
/* CIF procedure (2060, 152), (70, 35) */
procedure observe;
/* CIF TEXT (132, 48), (313, 120) */
/* CIF TEXT (140, 48), (313, 120) */
-- this procedure could be generated automatically,
-- and be read-only.
fpar in/out model System_State,
in/out last_event Observable_Event;
/* CIF ENDTEXT */
/* CIF START (456, 153), (70, 35) */
/* CIF START (464, 153), (70, 35) */
START;
/* CIF task (422, 208), (137, 40) */
/* CIF task (430, 208), (137, 40) */
task st := model,
Event := Last_Event;
/* CIF PROCEDURECALL (337, 268), (308, 35) */
/* CIF PROCEDURECALL (345, 268), (308, 35) */
call writeln('[observer] Event: ', present(event));
/* CIF decision (434, 323), (113, 50) */
/* CIF decision (442, 323), (113, 50) */
decision present(event);
/* CIF ANSWER (97, 393), (93, 24) */
(input_event):
......@@ -70,111 +76,124 @@ Event := Last_Event;
/* CIF PROCEDURECALL (780, 437), (169, 35) */
call writeln('no_event');
enddecision;
/* CIF return (473, 543), (35, 35) */
/* CIF return (481, 543), (35, 35) */
return ;
endprocedure;
/* CIF START (440, 86), (70, 35) */
/* CIF START (683, 86), (70, 35) */
START;
/* CIF PROCEDURECALL (395, 141), (159, 35) */
/* CIF PROCEDURECALL (638, 141), (159, 35) */
call writeln ('observer init');
/* CIF NEXTSTATE (433, 191), (83, 35) */
/* CIF NEXTSTATE (676, 191), (83, 35) */
NEXTSTATE first_state;
/* CIF state (299, 430), (101, 34) */
/* CIF state (662, 434), (101, 34) */
state second_state;
/* CIF provided (230, 485), (239, 45) */
/* CIF provided (594, 489), (239, 45) */
provided st.orchestrator.magic_number = 42;
/* CIF NEXTSTATE (299, 550), (101, 35) */
/* CIF NEXTSTATE (663, 554), (101, 35) */
NEXTSTATE third_state;
endstate;
/* CIF state (299, 320), (101, 35) */
/* CIF state (663, 324), (101, 35) */
state Wait_count;
/* CIF provided (307, 375), (85, 35) */
/* CIF provided (671, 379), (85, 35) */
provided count = 3
/* CIF comment (416, 372), (104, 40) */
/* CIF comment (780, 376), (104, 40) */
comment 'Called AFTER
the input';
/* CIF NEXTSTATE (299, 430), (101, 34) */
/* CIF NEXTSTATE (662, 434), (101, 34) */
NEXTSTATE second_state;
endstate;
/* CIF state (433, 191), (83, 35) */
/* CIF state (676, 191), (83, 35) */
state first_state;
/* CIF provided (280, 246), (139, 54) */
/* CIF provided (644, 248), (139, 56) */
provided input pulse
to orchestrator
/* CIF comment (446, 253), (111, 40) */
/* CIF comment (810, 256), (111, 40) */
comment 'Called BEFORE
the input';
/* CIF NEXTSTATE (299, 320), (101, 35) */
/* CIF NEXTSTATE (663, 324), (101, 35) */
NEXTSTATE Wait_count;
/* CIF input (568, 246), (70, 35) */
input d;
endstate;
/* CIF state (844, 237), (97, 40) */
/* CIF state (992, 237), (97, 40) */
state fourth_state;
/* CIF provided (795, 297), (193, 79) */
/* CIF provided (943, 297), (193, 79) */
provided output do_something(p)
from orchestrator
to another_function
/* CIF comment (1011, 308), (146, 56) */
/* CIF comment (1159, 308), (146, 56) */
comment 'intercept the output
and modify the value
of the parameter';
/* CIF decision (856, 396), (70, 50) */
/* CIF decision (1005, 396), (70, 50) */
decision p = 42;
/* CIF ANSWER (791, 466), (70, 24) */
/* CIF ANSWER (939, 466), (70, 24) */
(true):
/* CIF task (791, 510), (70, 35) */
/* CIF task (939, 510), (70, 35) */
task p := 99;
/* CIF NEXTSTATE (783, 565), (85, 35) */
/* CIF NEXTSTATE (932, 565), (85, 35) */
NEXTSTATE fifth_state;
/* CIF ANSWER (891, 466), (70, 24) */
/* CIF ANSWER (1039, 466), (70, 24) */
(false):
/* CIF NEXTSTATE (880, 510), (92, 35) */
/* CIF NEXTSTATE (1028, 510), (92, 35) */
NEXTSTATE unexpected;
enddecision;
endstate;
/* CIF state (845, 90), (88, 35) */
/* CIF state (1286, 90), (88, 35) */
state third_state;
/* CIF provided (806, 145), (173, 72) */
/* CIF provided (954, 145), (173, 72) */
provided output paramesstogui
from orchestrator;
/* CIF NEXTSTATE (844, 237), (97, 40) */
/* CIF NEXTSTATE (992, 237), (97, 40) */
NEXTSTATE fourth_state;
/* CIF input (1317, 145), (218, 49) */
input pre_in_orchestrator_pulse(toto)
/* CIF comment (1555, 152), (127, 56) */
comment 'alias for
input pulse to
orchestrator';
/* CIF decision (1391, 214), (70, 50) */
decision toto;
/* CIF ANSWER (1335, 284), (70, 24) */
(1):
/* CIF ANSWER (1425, 284), (70, 24) */
else:
enddecision;
/* CIF NEXTSTATE (1391, 324), (70, 35) */
NEXTSTATE -;
endstate;
/* CIF state (0, 262), (95, 35) */
/* CIF state (154, 262), (95, 35) */
state end_success;
endstate;
/* CIF state (3, 314), (92, 35) */
/* CIF state (157, 314), (92, 35) */
state unexpected;
endstate;
/* CIF state (1279, 437), (87, 35) */
/* CIF state (1710, 437), (87, 35) */
state sixth_state;
/* CIF provided (1263, 492), (121, 50) */
/* CIF provided (1694, 492), (121, 50) */
provided actual_val = 100;
/* CIF NEXTSTATE (1276, 562), (95, 35) */
/* CIF NEXTSTATE (1706, 562), (95, 35) */
NEXTSTATE end_success;
endstate;
/* CIF state (1297, 88), (145, 57) */
/* CIF state (1728, 88), (145, 57) */
state fifth_state;
/* CIF provided (1277, 165), (184, 68) */
/* CIF provided (1708, 165), (184, 68) */
provided input do_something(val)
to another_function
/* CIF comment (1484, 163), (134, 72) */
/* CIF comment (1915, 163), (134, 72) */
comment 'intercept the input
before execution
(=post-output)
alter it again';
/* CIF decision (1319, 253), (99, 68) */
/* CIF decision (1750, 253), (99, 68) */
decision val = 99;
/* CIF ANSWER (1292, 343), (62, 24) */
/* CIF ANSWER (1723, 343), (62, 24) */
(true):
/* CIF task (1276, 387), (93, 35) */
/* CIF task (1707, 387), (93, 35) */
task val := val + 1;
/* CIF NEXTSTATE (1279, 437), (87, 35) */
/* CIF NEXTSTATE (1710, 437), (87, 35) */
NEXTSTATE sixth_state;
/* CIF ANSWER (1408, 343), (70, 24) */
/* CIF ANSWER (1839, 343), (70, 24) */
(false):
/* CIF NEXTSTATE (1397, 387), (92, 35) */
/* CIF NEXTSTATE (1827, 387), (92, 35) */
NEXTSTATE unexpected;
enddecision;
endstate;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment