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

Simulator: generate a startup function

Don't do anything at elaboration
parent f694de3d
......@@ -299,8 +299,18 @@ LD_LIBRARY_PATH=. opengeode-simulator
process_level_decl.append('procedure runTransition(Id: Integer);')
# Generate the code of the start transition (if process not empty)
start_transition = ['begin',
'runTransition(0);'] if process.transitions else []
if not simu:
start_transition = ['begin',
'runTransition(0);'] if process.transitions else []
else:
start_transition = ['procedure Startup;',
'pragma Export(C, Startup, "{}_startup");'
.format(process_name),
'procedure Startup is',
'begin',
' runTransition(0);' if process.transitions
else 'null;',
'end Startup;']
# Generate the TASTE template
try:
......
/* CIF PROCESS (297, 59), (150, 75) */
/* CIF PROCESS (296, 59), (150, 75) */
PROCESS orchestrator
/* CIF COMMENT (407, 195), (78, 35) */
/* CIF COMMENT (406, 195), (78, 35) */
COMMENT 'Hello';
STATE wait;
SUBSTRUCTURE
......@@ -47,84 +47,86 @@ procedure VDM2;
in/out outp MySimpleSeq;
external comment '#vdm #classname=RemoteCall';
/* CIF ENDTEXT */
/* CIF START (1081, 150), (80, 36) */
/* CIF START (1091, 150), (80, 36) */
START;
/* CIF NEXTSTATE (1085, 201), (72, 34) */
/* CIF PROCEDURECALL (1025, 201), (211, 35) */
CALL writeln('Simulation startup');
/* CIF NEXTSTATE (1095, 251), (72, 34) */
NEXTSTATE Wait;
/* CIF STATE (1670, 345), (74, 35) */
STATE next;
/* CIF INPUT (1643, 400), (122, 35) */
INPUT pulse(a);
/* CIF PROCEDURECALL (1597, 450), (213, 35) */
CALL reset_timer(mytimer);
/* CIF NEXTSTATE (1669, 500), (70, 35) */
NEXTSTATE wait;
ENDSTATE;
/* CIF STATE (1664, 125), (100, 35) */
/* CIF STATE (1674, 125), (100, 35) */
STATE timeout;
/* CIF INPUT (1649, 180), (147, 35) */
/* CIF INPUT (1659, 180), (147, 35) */
INPUT Paramless_TC;
/* CIF PROCEDURECALL (1598, 230), (249, 35) */
/* CIF PROCEDURECALL (1608, 230), (249, 35) */
CALL SET_timer(1000, mytimer);
/* CIF NEXTSTATE (1685, 280), (74, 35) */
/* CIF NEXTSTATE (1695, 280), (74, 35) */
NEXTSTATE next;
ENDSTATE;
/* CIF STATE (1085, 201), (72, 34) */
/* CIF STATE (1680, 345), (74, 35) */
STATE next;
/* CIF INPUT (1653, 400), (122, 35) */
INPUT pulse(a);
/* CIF PROCEDURECALL (1607, 450), (213, 35) */
CALL reset_timer(mytimer);
/* CIF NEXTSTATE (1679, 500), (70, 35) */
NEXTSTATE wait;
ENDSTATE;
/* CIF STATE (1095, 251), (72, 34) */
STATE Wait;
/* CIF INPUT (797, 255), (101, 35) */
/* CIF INPUT (807, 305), (101, 35) */
INPUT pulse(a);
/* CIF TASK (762, 305), (170, 48) */
/* CIF TASK (772, 355), (170, 48) */
TASK seq := {0,1,0,1,0},
anint := 478;
/* CIF PROCEDURECALL (718, 368), (259, 35) */
/* CIF PROCEDURECALL (728, 418), (259, 35) */
CALL writeln('Input param', anint);
/* CIF PROCEDURECALL (728, 418), (238, 35) */
/* CIF PROCEDURECALL (738, 468), (238, 35) */
CALL ExternalProc(anint, anint);
/* CIF PROCEDURECALL (710, 468), (275, 35) */
/* CIF PROCEDURECALL (720, 518), (275, 35) */
CALL writeln('Output param', anint);
/* CIF PROCEDURECALL (704, 518), (286, 35) */
/* CIF PROCEDURECALL (714, 568), (286, 35) */
CALL write('Calling VDM with data');
/* CIF TASK (654, 568), (386, 48) */
/* CIF TASK (664, 618), (386, 48) */
TASK for each in fixed: call write(each, ' '); endfor;
/* CIF PROCEDURECALL (762, 631), (170, 40) */
/* CIF PROCEDURECALL (772, 681), (170, 40) */
CALL writeln('');
/* CIF PROCEDURECALL (761, 686), (172, 35) */
/* CIF PROCEDURECALL (771, 736), (172, 35) */
CALL vdm(fixed, fixed);
/* CIF PROCEDURECALL (762, 736), (170, 40) */
/* CIF PROCEDURECALL (772, 786), (170, 40) */
CALL write('Result:');
/* CIF TASK (656, 791), (383, 35) */
/* CIF TASK (666, 841), (383, 35) */
TASK for each in fixed: call write(each, ' '); endfor;
/* CIF PROCEDURECALL (789, 841), (116, 40) */
/* CIF PROCEDURECALL (799, 891), (116, 40) */
CALL writeln('');
/* CIF PROCEDURECALL (657, 896), (381, 35) */
/* CIF PROCEDURECALL (667, 946), (381, 35) */
CALL writeln('Calling VDM2 with value', fixed(0));
/* CIF PROCEDURECALL (726, 946), (242, 35) */
/* CIF PROCEDURECALL (736, 996), (242, 35) */
CALL vdm2(fixed(0), simpleseq);
/* CIF PROCEDURECALL (592, 996), (511, 40) */
/* CIF PROCEDURECALL (602, 1046), (511, 40) */
CALL writeln('Result:', simpleseq!a, ' ', simpleseq!b, ' ', simpleseq!c);
/* CIF OUTPUT (778, 1051), (138, 35) */
/* CIF OUTPUT (788, 1101), (138, 35) */
OUTPUT telemetry(a);
/* CIF OUTPUT (774, 1101), (147, 35) */
/* CIF OUTPUT (784, 1151), (147, 35) */
OUTPUT peek_list(seq);
/* CIF OUTPUT (759, 1151), (177, 35) */
/* CIF OUTPUT (769, 1201), (177, 35) */
OUTPUT peek_fixed(fixed);
/* CIF NEXTSTATE (810, 1201), (74, 35) */
/* CIF NEXTSTATE (820, 1251), (74, 35) */
NEXTSTATE next;
/* CIF INPUT (1209, 255), (147, 35) */
/* CIF INPUT (1219, 305), (147, 35) */
INPUT Paramless_TC;
/* CIF PROCEDURECALL (1156, 305), (253, 35) */
/* CIF PROCEDURECALL (1166, 355), (253, 35) */
CALL writeln('Got Paramless TC');
/* CIF PROCEDURECALL (1158, 355), (249, 35) */
/* CIF PROCEDURECALL (1168, 405), (249, 35) */
CALL SET_timer(1000, mytimer);
/* CIF OUTPUT (1207, 405), (150, 35) */
/* CIF OUTPUT (1217, 455), (150, 35) */
OUTPUT Paramless_TM;
/* CIF TASK (1181, 455), (202, 35) */
/* CIF TASK (1191, 505), (202, 35) */
TASK anint := (anint + 1) mod 100;
/* CIF NEXTSTATE (1247, 505), (70, 35) */
/* CIF NEXTSTATE (1257, 555), (70, 35) */
NEXTSTATE wait;
/* CIF INPUT (1419, 255), (104, 35) */
/* CIF INPUT (1429, 305), (104, 35) */
INPUT mytimer;
/* CIF NEXTSTATE (1420, 305), (102, 35) */
/* CIF NEXTSTATE (1430, 355), (102, 35) */
NEXTSTATE Timeout;
ENDSTATE;
ENDPROCESS orchestrator;
\ No newline at end of file
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