Commits (3)
......@@ -142,7 +142,7 @@ package body Simulator_Interface is
-- (c) if event == no_event, do nothing
-- for (1) and (2):
Run_Observers (Full_State, Current_Event'Access, Id, Stop_Condition);
Run_Observers (Full_State, Current_Event, Id, Stop_Condition);
Process_Event (Current_Event);
-- for (3):
......@@ -162,7 +162,7 @@ package body Simulator_Interface is
declare
Next_Event : aliased asn1sccObservable_Event := Simulator.Pop_Event;
begin
Run_Observers (Full_State, Next_Event'Access, Id, Stop_Condition);
Run_Observers (Full_State, Next_Event, Id, Stop_Condition);
Process_Event (Next_Event);
end;
end loop;
......@@ -177,7 +177,7 @@ package body Simulator_Interface is
New_In_Event : aliased asn1sccObservable_Event :=
User_State.@_CAPITALIZE:Block_Names_@_Queue.Data (I);
begin
Run_Observers (Full_State, New_In_Event'Access, Id, Stop_Condition);
Run_Observers (Full_State, New_In_Event, Id, Stop_Condition);
Process_Event (New_In_Event);
end;
end loop;
......
......@@ -13,7 +13,7 @@ generic
with function Full_State_Init return State_With_Observers is <>;
with function State_As_String (Full_State : State_With_Observers) return String is <>;
Run_Observers : access procedure (Full_State : in out State_With_Observers;
Event : access asn1sccObservable_Event;
Event : in out asn1sccObservable_Event;
Id : out Natural;
Success : out Boolean);
package Simulator_Interface is
......
......@@ -11,6 +11,8 @@ SOURCES += work/@_LOWER:Name_@/Ada/src/@_LOWER:Name_@.adb
HEADERS += work/@_LOWER:Name_@/Ada/src/@_LOWER:Name_@.ads
@@ELSIF@@ @_Language_@ = SDL
SOURCES += work/@_LOWER:Name_@/SDL/src/@_LOWER:Name_@.pr
SOURCES += work/@_LOWER:Name_@/SDL/code/@_LOWER:Name_@.adb
SOURCES += work/@_LOWER:Name_@/SDL/code/@_LOWER:Name_@.ads
@@ELSIF@@ @_Language_@ = CPP
SOURCES += work/@_LOWER:Name_@/CPP/src/@_LOWER:Name_@.cc
HEADERS += work/@_LOWER:Name_@/CPP/src/@_LOWER:Name_@.h
......
......@@ -42,8 +42,6 @@ procedure MC is
-- end Encode_And_md5;
begin
-- Set once for all a pointer to the current state in the observers
My_Observer.St := Simulator_Pkg.User_State'Unchecked_Access;
Simulator_Pkg.Simulation_Startup;
-- Encode_And_md5 (Simulator.State);
......
......@@ -30,27 +30,27 @@ package body Properties is
end Print_Full_State;
procedure My_Properties (Full_State : in out State_With_Observers;
Event : access asn1sccObservable_Event;
Event : in out asn1sccObservable_Event;
Id : out Natural;
Success : out Boolean) is
Local_Event : aliased asn1sccObservable_Event := Event.all;
begin
Id := 0;
-- Restore the state of the observer, and execute it
My_Observer.Ctxt := Full_State.My_Observer_State;
-- Put_Line ("[OBS] Context set to: " & GSER.Image (My_Observer.Ctxt));
-- Set the event in the observer's monitor
My_Observer.Event := Local_Event'Unchecked_access;
-- Set the observer's monitors
My_Observer.Event := Event;
My_Observer.St := Full_State.User_State;
My_Observer.Observe;
-- Read the modified state from the observer
Event := My_Observer.Event;
Full_State.User_state := My_Observer.St;
Full_State.My_Observer_State := My_Observer.Ctxt;
-- Simple stop condition:
Success := (My_Observer.Ctxt.State = My_Observer_Datamodel.asn1SccEnd_Success);
if Success then
Put_Line ("Stop condition found");
end if;
end;
end Properties;
......@@ -41,7 +41,7 @@ package Properties is
pragma Export (C, Check_Queue, "my_observer_check_queue");
procedure My_Properties (Full_State : in out State_With_Observers;
Event : access asn1sccObservable_Event;
Event : in out asn1sccObservable_Event;
Id : out Natural;
Success : out Boolean);
......
......@@ -114,7 +114,7 @@ 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, step-2}
Orchestrator-States ::= ENUMERATED {step-2, wait}
Orchestrator-Context ::= SEQUENCE {
state Orchestrator-States,
......
......@@ -18,12 +18,14 @@ observe;
connect c and r;
/* CIF PROCESS (250, 87), (150, 75) */
process my_observer;
/* CIF TEXT (0, 57), (223, 88) */
/* CIF TEXT (0, 57), (309, 104) */
monitor st System_State;
monitor event Observable_Event;
dcl count T_Int renames st.orchestrator.counter;
/* CIF ENDTEXT */
/* CIF procedure (1262, 63), (70, 35) */
/* CIF procedure (1256, 63), (70, 35) */
procedure observe;
/* CIF TEXT (38, 48), (313, 72) */
-- this procedure could be generated automatically,
......@@ -34,13 +36,13 @@ observe;
/* CIF return (198, 208), (35, 35) */
return ;
endprocedure;
/* CIF START (349, 78), (70, 35) */
/* CIF START (433, 78), (70, 35) */
START;
/* CIF PROCEDURECALL (304, 133), (159, 35) */
/* CIF PROCEDURECALL (388, 133), (159, 35) */
call writeln ('observer init');
/* CIF NEXTSTATE (342, 183), (83, 35) */
/* CIF NEXTSTATE (426, 183), (83, 35) */
NEXTSTATE first_state;
/* CIF state (1021, 111), (101, 35) */
/* CIF state (1015, 111), (101, 35) */
state second_state;
/* CIF provided (963, 168), (241, 35) */
provided st.orchestrator.magic_number = 42;
......@@ -49,10 +51,10 @@ observe;
/* CIF NEXTSTATE (1033, 273), (101, 35) */
NEXTSTATE third_state;
endstate;
/* CIF state (124, 218), (95, 35) */
/* CIF state (118, 218), (95, 35) */
state end_success;
endstate;
/* CIF state (1145, 316), (88, 35) */
/* CIF state (1139, 316), (88, 35) */
state third_state;
/* CIF provided (1104, 371), (341, 136) */
provided event =
......@@ -66,29 +68,29 @@ priority 2;
call writeln ('SUCCESS(1)');
/* CIF NEXTSTATE (1226, 593), (95, 35) */
NEXTSTATE end_success;
/* CIF provided (534, 371), (525, 104) */
/* CIF provided (528, 371), (525, 104) */
provided present(event) = output_event
and then event.output_event.dest = simulator_gui
and then present(event.output_event.event) = orchestrator
and then present(event.output_event.event.orchestrator.msg_out) = paramesstogui;
priority 3;
/* CIF PROCEDURECALL (709, 506), (176, 35) */
/* CIF PROCEDURECALL (703, 506), (176, 35) */
call writeln ('SUCCESS(2)');
/* CIF NEXTSTATE (749, 561), (95, 35) */
/* CIF NEXTSTATE (743, 561), (95, 35) */
NEXTSTATE end_success;
/* CIF provided (1454, 371), (268, 40) */
/* CIF provided (1448, 371), (268, 40) */
provided output paramesstogui from orchestrator;
priority 1;
/* CIF NEXTSTATE (1540, 431), (95, 40) */
/* CIF NEXTSTATE (1535, 431), (95, 40) */
NEXTSTATE end_success;
endstate;
/* CIF state (342, 183), (83, 35) */
/* CIF state (426, 183), (83, 35) */
state first_state;
/* CIF provided (280, 239), (208, 35) */
/* CIF provided (364, 239), (208, 35) */
provided st.orchestrator.counter = 3;
/* CIF PROCEDURECALL (233, 294), (300, 35) */
/* CIF PROCEDURECALL (317, 294), (300, 35) */
call writeln ('[observer] step 1 passed (counter=3)');
/* CIF NEXTSTATE (333, 349), (101, 35) */
/* CIF NEXTSTATE (417, 349), (101, 35) */
NEXTSTATE second_state;
endstate;
endprocess my_observer;
......