Commit 7dcc165e authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Add test case corresponding to taste's Demo-opengeode

parent e8af2842
include ../shared.mk
ROOT_MODEL=system_structure.pr
all: test-ada test-llvm
edit:
$(OPENGEODE) orchestrator.pr system_structure.pr
test-qgen-parse:
$(TESTQGEN_PARSE) $(ROOT_MODEL)
test-qgen-ada:
$(TESTQGEN_ADA) $(ROOT_MODEL)
test-qgen-c:
$(TESTQGEN_C) $(ROOT_MODEL)
test-qgen-gt-ada:
$(TESTQGEN_GT_ADA) $(ROOT_MODEL)
test-qgen-gt-c:
$(TESTQGEN_GT_C) $(ROOT_MODEL)
test-parse:
$(OPENGEODE) orchestrator.pr system_structure.pr --check
test-ada:
$(OPENGEODE) orchestrator.pr system_structure.pr --toAda
test-c:
$(OPENGEODE) orchestrator.pr system_structure.pr --check &&
test-llvm: orchestrator.o
coverage:
coverage run -p $(OPENGEODE) orchestrator.pr system_structure.pr --toAda
.PHONY: all edit test-parse test-ada test-llvm coverage
TASTE-Dataview DEFINITIONS ::=
BEGIN
MyComplexType ::= SEQUENCE {
a SEQUENCE { x INTEGER(0..255), y MyInteger }
}
MyComplexSeqOf ::= SEQUENCE(SIZE(2)) OF SEQUENCE { x INTEGER (0..255) }
MyComplexChoice ::= CHOICE { a SEQUENCE { x INTEGER (0..255) } }
EnableDisable ::= ENUMERATED {scrubon, scruboff}
MyRefSeqOf ::= SEQUENCE { seqof MySeqOf }
-- A few simple types to start with ASN.1
MyInteger ::= INTEGER (-255..255)
MyReal ::= REAL (-10.0 .. 1000.0)
MyEnum ::= ENUMERATED { hello, world, howareyou }
MySeq ::= SEQUENCE {
a MyInteger,
b ENUMERATED { taste(1), welcomes(2), you(3) }
}
MyChoice ::= CHOICE {
a BOOLEAN,
b MySeq
}
MySeqOf ::= SEQUENCE (SIZE (2)) OF MyEnum
MyPossiblyEmptySeqOf ::= SEQUENCE(SIZE(0..2)) OF INTEGER (1..2)
MySeqWithEmbeddedSeqOf ::= SEQUENCE {
a SEQUENCE(SIZE(0..2)) OF BOOLEAN
}
MyOctStr ::= OCTET STRING (SIZE (3))
-- Include an embedded choice
MyChoice2 ::= CHOICE {
a BOOLEAN,
b CHOICE {
c BOOLEAN,
d MyInteger
}
}
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
END
/* CIF PROCESS (250, 149), (150, 75) */
process orchestrator;
/* CIF TEXT (81, 252), (276, 283) */
-- You can manually declare an
-- external procedure:
-- procedure tototo;
-- fpar titi MyInteger;
-- external;
-- In that case you are responsible for
-- providing the body code.
-- toto is used to check that
-- the FPAR in myproc that also
-- has a param called toto does
-- not conflict.
dcl toto MySeqOf;
/* CIF ENDTEXT */
/* CIF TEXT (59, 8), (366, 195) */
-- This demo shows the main features
-- and syntax currently supported by
-- OpenGEODE
-- The description of the signal and
-- external procedures is in the file called
-- "system_structure.pr".
-- To open this model you must load both
-- files from the command line:
-- $ opengeode system_structure.pr orchestrator.pr
/* CIF ENDTEXT */
/* CIF TEXT (437, 19), (319, 382) */
-- Some test data
DCL a MyInteger := 4;
DCL b MySeqOf;
DCL c MySeq;
DCL e, g MyChoice;
DCL f MyEnum;
DCL h MyReal;
DCL i MyPossiblyEmptySeqOf;
DCL j MyComplexType;
DCL k MyComplexSeqOf;
DCL l MyComplexChoice;
DCL myCmd MyInteger;
dcl m MyChoice2;
/* CIF ENDTEXT */
/* CIF procedure (146, 614), (91, 50) */
procedure myproc;
/* CIF TEXT (409, 0), (197, 140) */
-- A Local variable
DCL foo MyInteger;
-- Procedure interface
fpar
in toto MyInteger,
in/out tutu MyInteger;
/* CIF ENDTEXT */
/* CIF START (617, 19), (100, 50) */
START;
/* CIF task (617, 84), (100, 50) */
task a := 42;
/* CIF decision (617, 149), (100, 70) */
decision toto;
/* CIF ANSWER (422, 239), (100, 35) */
(<10):
/* CIF task (409, 289), (126, 50) */
task tutu := 128;
/* CIF ANSWER (548, 239), (100, 35) */
ELSE:
/* CIF task (543, 289), (110, 50) */
task tutu := 254;
enddecision;
/* CIF task (617, 354), (100, 50) */
task foo := a;
/* CIF return (642, 419), (50, 50) */
return ;
endprocedure;
/* CIF START (953, 3), (100, 50) */
START;
/* CIF task (796, 73), (413, 368) */
task a := 42 + 5 * 3 - 1,
b := { hello, world },
a := length(b),
c := {a 5, b taste},
f := hello,
g := b:{a 33, b you},
e:=g,
e := a:TRUE,
b(1) := hello,
--h := {mantissa 1, base 2, exponent 5},
h := -42.5,
i := {},
i := { 1 },
a := length(i),
a := if e!a then 8 else if b(0) = hello then a else 9 fi fi,
j := { a { x if e!a then 5 else 9 fi, y 6 } },
k := { {x 4}, {x 5} },
l := a:{ x 5 },
a := if present(e)=b then 42 else 43 fi,
a := abs(-5),
h := abs(-42.5),
h := abs(h),
i := {1, 2},
m := B:C:TRUE
/* CIF comment (1273, 237), (160, 40) */
comment 'This is a comment
A multiline one, I mean';
/* CIF task (939, 456), (128, 53) */
task for x in i:
call writeln(x);
endfor;
/* CIF PROCEDURECALL (875, 524), (255, 50) */
call writeln('Should show "5 42.5": ', a, h);
/* CIF decision (947, 589), (112, 70) */
decision present(e);
/* CIF ANSWER (953, 679), (100, 31) */
(a):
/* CIF task (949, 729), (108, 50) */
task a := 37;
/* CIF ANSWER (1106, 679), (100, 35) */
(b):
/* CIF task (1066, 729), (179, 50) */
task a := 38;
/* CIF ANSWER (1256, 679), (100, 35) */
ELSE:
enddecision;
/* CIF decision (953, 794), (100, 70) */
decision e;
/* CIF ANSWER (840, 884), (100, 35) */
(a:TRUE):
/* CIF task (840, 939), (100, 50) */
task a := 41;
/* CIF ANSWER (646, 884), (100, 35) */
(g):
/* CIF task (646, 939), (100, 50) */
task a := 40;
/* CIF ANSWER (1077, 884), (100, 35) */
ELSE:
/* CIF task (1077, 939), (100, 50) */
task a := 42;
enddecision;
/* CIF NEXTSTATE (956, 1004), (94, 38) */
NEXTSTATE Stopped;
/* CIF label (452, 491), (152, 50) */
connection Transition_to_Stop:
/* CIF output (451, 556), (153, 50) */
output housekeeping(31);
/* CIF NEXTSTATE (478, 621), (100, 50) */
NEXTSTATE Stopped;
/* CIF End Label */
endconnection;
/* CIF state (2396, 617), (100, 50) */
state Running;
/* CIF input (2386, 687), (120, 50) */
input run(myCmd);
/* CIF output (2363, 752), (165, 50) */
output housekeeping(42);
/* CIF join (2421, 817), (50, 50) */
join Transition_to_Stop;
endstate;
/* CIF state (2064, 20), (100, 50) */
state Stopped;
/* CIF input (2396, 90), (100, 50) */
input run(a)
/* CIF comment (2368, 21), (167, 50) */
/* CIF Keep Specific Geode HyperLink 'http://www.esa.int' */
comment 'My comment is rich';
/* CIF label (2396, 155), (100, 50) */
Here:
/* CIF decision (2396, 220), (100, 70) */
decision a>10;
/* CIF ANSWER (2304, 310), (100, 35) */
(TRUE):
/* CIF PROCEDURECALL (2209, 360), (290, 47) */
call writeln
('a is too big! - decrementing :', a, a - 1);
/* CIF task (2298, 422), (112, 50) */
task a := a - 1;
/* CIF PROCEDURECALL (2296, 487), (116, 50) */
call myproc(5,a);
/* CIF join (2329, 552), (50, 50) */
join Here;
/* CIF ANSWER (2509, 310), (100, 35) */
(FALSE):
enddecision;
/* CIF NEXTSTATE (2396, 617), (100, 50) */
NEXTSTATE Running;
/* CIF input (1746, 90), (100, 50) */
input pulse;
/* CIF output (1715, 155), (161, 50) */
output housekeeping (1);
/* CIF NEXTSTATE (1750, 220), (91, 46) */
NEXTSTATE -
/* CIF comment (1909, 213), (153, 50) */
comment 'Stay in the same state';
endstate;
/* CIF state (1503, 29), (100, 50) */
state Running;
/* CIF input (1503, 99), (100, 50) */
input pulse;
/* CIF task (1456, 164), (193, 50) */
task a := (a+1) mod 10;
/* CIF PROCEDURECALL (1450, 229), (205, 50) */
call writeln
('Calling GNC with value ', a);
/* CIF PROCEDURECALL (1474, 294), (158, 50) */
call computeGNC(a, a);
/* CIF output (1479, 359), (148, 50) */
output housekeeping(a);
/* CIF NEXTSTATE (1503, 424), (100, 50) */
NEXTSTATE Running;
endstate;
endprocess orchestrator;
\ No newline at end of file
/* CIF Keep Specific Geode ASNFilename 'dataview-uniq.asn' */
USE Datamodel;
SYSTEM orchestrator;
SIGNAL pulse;
/* CIF Keep Specific Geode PARAMNAMES cmd */
SIGNAL run (MyInteger);
/* CIF Keep Specific Geode PARAMNAMES hk */
SIGNAL housekeeping (MyInteger);
PROCEDURE computeGNC COMMENT '#c_predef';
FPAR
IN inP MyInteger,
IN/OUT outP MyInteger;
EXTERNAL;
CHANNEL c
FROM ENV TO orchestrator WITH pulse,run;
FROM orchestrator TO ENV WITH housekeeping;
ENDCHANNEL;
BLOCK orchestrator;
SIGNALROUTE r
FROM ENV TO orchestrator WITH pulse,run;
FROM orchestrator TO ENV WITH housekeeping;
CONNECT c and r;
PROCESS orchestrator REFERENCED;
ENDBLOCK;
ENDSYSTEM;
\ 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