Commits (3)
# this file was written manually.. for now
all: mc
mc: mcsrc/mc.adb mcsrc/properties.adb
mc: observer/my_observer.adb mcsrc/mc.adb mcsrc/properties.adb
ADA_PROJECT_PATH=~/.local/share/gpr:${ADA_PROJECT_PATH} gprbuild -p -P mc
observer/my_observer.adb: observer/observer.pr observer/observer.asn
cd observer && opengeode --toAda observer.pr && \
asn1.exe -Ada -typePrefix asn1scc -equal --target allboards observer.asn my_observer_datamodel.asn && \
mv src/my_observer_datamodel.ad? .
# gather dataviews needed to build an observer
observer/observer.asn: ../dataview/dataview-uniq.asn ../build/simulation.asn ../orchestrator/SDL/code/orchestrator_datamodel.asn ../another_function/SDL/code/another_function_datamodel.asn
cat $^ > $@
clean:
ADA_PROJECT_PATH=~/.local/share/gpr:${ADA_PROJECT_PATH} gprclean -P mc
rm observer/my_observer.ad?
......@@ -2,7 +2,7 @@ with "share/gpr/demo_simulator.gpr";
with "asn1_iterators";
project mc is
for source_dirs use ("mcsrc", "../dataview/iterators");
for source_dirs use ("mcsrc", "../dataview/iterators", "observer");
for main use ("mc.adb");
package Compiler is
for Default_Switches ("Ada") use ("-g", "-O2");
......
......@@ -16,8 +16,8 @@ with Gnat.MD5,
adaasn1rtl.encoding;
use Ada.Streams;
procedure mc is
Pulse_Event : asn1SccEvent :=
(Kind => Orchestrator_PRESENT,
Orchestrator =>
......
with iterators_types;
use iterators_types;
with my_observer; use my_observer;
package body Properties is
procedure Check_Queue (Res : out asn1Boolean) is
begin
Res := False;
end Check_Queue;
procedure My_Properties (Id : out Natural; Success : out Boolean) is
begin
Id := 0;
Observe (Global_State => Simulator.State);
Success := (Simulator.State.Orchestrator.State = asn1SccWait
and Simulator.State.Orchestrator.SeqOf = (Length => 4, Data => (4, 4, 4, 4)));
end;
......
with simulator;
with simulation_dataview; use simulation_dataview;
with orchestrator_datamodel; use orchestrator_datamodel;
with adaasn1rtl; use adaasn1rtl;
package Properties is
-- there are continuous signals in the observers, we need check_queue
procedure Check_Queue (Res : out asn1Boolean);
pragma Export (C, Check_Queue, "my_observer_check_queue");
procedure My_Properties (Id : out Natural; Success : out Boolean);
end Properties;
To create an observer:
gather dataview-uniq.asn, simulation.asn, and *_datamodel.asn into a single file
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
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
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
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 {one, two}
Another-function-Context ::= SEQUENCE {
state Another-function-States,
init-done BOOLEAN
}
END
system my_observer;
/* CIF TEXT (147, 177), (267, 126) */
use datamodel comment 'observer.asn';
exported procedure observe;
fpar in/out global_state System_State;
referenced;
signal foo;
/* CIF ENDTEXT */
channel c
from env to my_observer with foo;
endchannel;
block my_observer;
signalroute r
from env to my_observer with foo;
connect c and r;
/* CIF PROCESS (250, 86), (150, 75) */
process my_observer;
/* CIF TEXT (0, 57), (183, 56) */
dcl st System_State;
dcl last_event Event;
/* CIF ENDTEXT */
/* CIF procedure (855, 63), (70, 35) */
procedure observe;
/* CIF TEXT (38, 48), (313, 72) */
-- this procedure could be generated automatically,
-- and be read-only.
fpar in/out global_state System_State;
/* CIF ENDTEXT */
/* CIF START (181, 153), (70, 35) */
START;
/* CIF task (154, 208), (123, 35) */
task st := global_state;
/* 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 (567, 69), (101, 35) */
state second_state;
/* CIF provided (545, 124), (146, 35) */
provided length(st.events) > 0;
/* CIF task (532, 179), (173, 35) */
task last_event := st.events (0);
/* CIF decision (548, 234), (140, 50) */
decision present(last_event);
/* CIF ANSWER (525, 304), (96, 24) */
(orchestrator):
/* CIF decision (465, 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 (487, 532), (82, 24) */
(paramless):
/* CIF PROCEDURECALL (445, 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 (799, 418), (74, 24) */
(msg_out):
/* CIF NEXTSTATE (802, 462), (70, 35) */
NEXTSTATE -;
enddecision;
/* CIF ANSWER (886, 304), (70, 24) */
else:
/* CIF NEXTSTATE (886, 348), (70, 35) */
NEXTSTATE -;
enddecision;
endstate;
/* CIF state (858, 178), (95, 35) */
state end_success;
endstate;
/* CIF state (280, 115), (83, 35) */
state first_state;
/* CIF provided (217, 170), (208, 35) */
provided st.orchestrator.counter = 4;
/* CIF PROCEDURECALL (192, 225), (256, 35) */
call writeln ('counter=4, moving to state 2');
/* CIF NEXTSTATE (270, 280), (101, 35) */
NEXTSTATE second_state;
endstate;
endprocess my_observer;
endblock;
endsystem;
\ No newline at end of file