Commit 012cb298 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Add demo to stress test the backend with asn1sccv4

parent f175d4a6
include ../shared.mk
all: test-ada test-llvm
edit:
$(OPENGEODE) orchestrator.pr system_structure.pr
test-parse:
$(OPENGEODE) orchestrator.pr system_structure.pr --check
test-ada: orchestrator.ali dataview-uniq.o | test_ada.o
$(GNATBIND) -n orchestrator.ali
$(GNATLINK) -o test_ada test_ada.o orchestrator.ali -lgnat
./test_ada
#gcov orchestrator.adb
test-c: orchestrator.c test_c.o dataview-uniq.o
$(CC) orchestrator.c -c -o orchestrator.o
$(CC) test_c.o orchestrator.c dataview-uniq.o -lm -o test_c
./test_c
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 a 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), (158, 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
#include <math.h>
#include <stdio.h>
#include "dataview-uniq.h"
extern void adainit();
void orchestrator_RI_housekeeping(asn1SccMyInteger *toto)
{
printf("%lld\n", *toto);
}
int main()
{
printf("[C Code] Running test\n");
adainit();
return 0;
}
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