Commit 2589db29 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Add attempt to make an observer

parent 1a2d965f
To create an observer:
gather dataview-uniq.asn, simulation.asn, and *_datamodel.asn into a single file
Another-function-Datamodel DEFINITIONS ::=
BEGIN
IMPORTS
T-Null, T-Int, T-SeqOf FROM Iterators-Types
T-Int32, T-UInt32, T-Int8, T-UInt8, T-Boolean, T-Null-Record FROM TASTE-BasicTypes;
Another-function-States ::= ENUMERATED {two, one}
Another-function-Context ::= SEQUENCE {
state Another-function-States,
init-done BOOLEAN
}
END
Iterators-Types DEFINITIONS ::=
BEGIN
T-Null ::= SEQUENCE {}
T-Int ::= INTEGER (0..4)
T-SeqOf ::= SEQUENCE (SIZE (1..4)) OF T-Int
END
TASTE-BasicTypes DEFINITIONS ::=
BEGIN
-- Set of TASTE predefined basic types
T-Int32 ::= INTEGER (-2147483648 .. 2147483647)
T-UInt32 ::= INTEGER (0 .. 4294967295)
T-Int8 ::= INTEGER (-128 .. 127)
T-UInt8 ::= INTEGER (0 .. 255)
T-Boolean ::= BOOLEAN
T-Null-Record ::= SEQUENCE {}
END
Orchestrator-Datamodel DEFINITIONS ::=
BEGIN
IMPORTS
T-Null, T-Int, T-SeqOf FROM Iterators-Types
T-Int32, T-UInt32, T-Int8, T-UInt8, T-Boolean, T-Null-Record FROM TASTE-BasicTypes;
Orchestrator-States ::= ENUMERATED {wait, running}
Orchestrator-Context ::= SEQUENCE {
state Orchestrator-States,
init-done BOOLEAN,
t T-Int,
counter T-Int,
seqof T-SeqOf
}
END
Simulation-DataView DEFINITIONS ::=
BEGIN
IMPORTS
-- ASN.1 modules used by thread orchestrator_arr
T-SeqOf FROM Iterators-Types
-- ASN.1 modules used by thread orchestrator_pulse
T-Int FROM Iterators-Types
-- Import generic integer type (used for timers)
T-UInt32 FROM TASTE-BasicTypes
-- Import the SDL function states needed for the global system state
Another-function-Context FROM Another-function-Datamodel
Orchestrator-Context FROM Orchestrator-Datamodel
;
Another-Function-Event ::= CHOICE {
msg-in CHOICE {
do-something SEQUENCE { }
}
}
Orchestrator-Event ::= CHOICE {
msg-in CHOICE {
arr SEQUENCE { p1 T-SeqOf },
paramless SEQUENCE { },
pulse SEQUENCE { p1 T-Int }
},
msg-out ENUMERATED {
paramlesstogui,
do-something
}
}
Simulator-Gui-Event ::= CHOICE {
msg-in CHOICE {
paramlesstogui SEQUENCE { },
poll SEQUENCE { }
},
msg-out ENUMERATED {
arr,
paramless,
pulse
}
}
Event ::= CHOICE {
system-startup SEQUENCE {},
another-function Another-Function-Event,
orchestrator Orchestrator-Event,
simulator-gui Simulator-Gui-Event
}
-- Define a queue of events
max-events INTEGER ::= 10
Events-Ty ::= SEQUENCE (SIZE (0 .. max-events)) OF Event
-- Global system state
System-State ::= SEQUENCE {
events Events-Ty,
another-function Another-function-Context,
orchestrator Orchestrator-Context
}
END
system my_observer;
/* CIF TEXT (147, 177), (267, 126) */
use datamodel comment 'observer.asn';
exported procedure observe;
fpar in/out ctxt System_State;
referenced;
/* CIF ENDTEXT */
block my_observer;
/* CIF PROCESS (249, 86), (150, 75) */
process my_observer;
/* CIF TEXT (0, 57), (183, 56) */
dcl st System_State;
dcl last_event Event;
/* CIF ENDTEXT */
/* CIF procedure (857, 63), (70, 35) */
procedure observe;
/* CIF TEXT (38, 48), (313, 72) */
-- this procedure could be generated automatically,
-- and be read-only.
fpar in/out ctxt System_State;
/* CIF ENDTEXT */
/* CIF START (181, 153), (70, 35) */
START;
/* CIF task (159, 208), (113, 35) */
task st := ctxt;
/* CIF return (198, 263), (35, 35) */
return ;
endprocedure;
/* CIF START (287, 60), (70, 35) */
START;
/* CIF NEXTSTATE (280, 115), (83, 35) */
NEXTSTATE first_state;
/* CIF state (569, 69), (101, 35) */
state second_state;
/* CIF provided (547, 124), (146, 35) */
provided length(st.events) > 0;
/* CIF task (533, 179), (173, 35) */
task last_event := st.events (0);
/* CIF decision (550, 234), (140, 50) */
decision present(last_event);
/* CIF ANSWER (527, 304), (96, 24) */
(orchestrator):
/* CIF decision (466, 348), (217, 50) */
decision present(last_event.orchestrator);
/* CIF ANSWER (495, 418), (70, 24) */
(msg_in):
/* CIF decision (399, 462), (261, 50) */
decision present(last_event.orchestrator.msg_in);
/* CIF ANSWER (318, 532), (70, 24) */
(arr):
/* CIF PROCEDURECALL (270, 576), (166, 35) */
call writeln('Got arr');
/* CIF ANSWER (489, 532), (82, 24) */
(paramless):
/* CIF PROCEDURECALL (447, 576), (166, 35) */
call writeln('Got paramless');
/* CIF ANSWER (672, 532), (70, 24) */
(pulse):
/* CIF PROCEDURECALL (624, 576), (166, 35) */
call writeln('Got pulse');
enddecision;
/* CIF NEXTSTATE (481, 627), (98, 35) */
NEXTSTATE end_success;
/* CIF ANSWER (801, 418), (74, 24) */
(msg_out):
/* CIF NEXTSTATE (803, 462), (70, 35) */
NEXTSTATE -;
enddecision;
/* CIF ANSWER (886, 304), (70, 24) */
else:
/* CIF NEXTSTATE (886, 348), (70, 35) */
NEXTSTATE -;
enddecision;
endstate;
/* CIF state (280, 115), (83, 35) */
state first_state;
/* CIF provided (217, 170), (208, 35) */
provided st.orchestrator.counter = 4 ;
/* CIF PROCEDURECALL (194, 225), (256, 35) */
call writeln ('counter=4, moving to state 2');
/* CIF NEXTSTATE (271, 280), (101, 35) */
NEXTSTATE second_state;
endstate;
/* CIF state (860, 178), (95, 35) */
state end_success;
endstate;
endprocess my_observer;
endblock;
endsystem;
\ No newline at end of file
Supports Markdown
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