Commit 2e3e45ab authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Add test-simu

Another test case to stress the new "simulation" interface.
parent c31f016d
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:
$(CC) -c -g test_ada.c
$(OPENGEODE) orchestrator.pr system_structure.pr --shared
$(ASN1SCC) -Ada dataview-uniq.asn -typePrefix asn1Scc -equal
$(GNATMAKE) -O$(O) -gnat2012 -c *.adb
$(GNATBIND) -n orchestrator.ali
$(GNATLINK) -o test_ada test_ada.o orchestrator.ali -lgnat
./test_ada
test-llvm: orchestrator.o
test-python:
$(OPENGEODE) orchestrator.pr system_structure.pr --shared
$(ASN1SCC) -Ada dataview-uniq.asn -typePrefix asn1Scc -equal
$(GNATMAKE) -O$(O) -gnat2012 -c *.adb
$(GNATBIND) -n -Lliborchestrator orchestrator
$(GNATMAKE) -c -gnat2012 b~orchestrator.adb
$(CC) -shared -fPIC -o liborchestrator.so b~orchestrator.o orchestrator.o taste_basictypes.o adaasn1rtl.o -lgnat
python -c "from ctypes import *; test=CDLL('./liborchestrator.so'); test.liborchestratorinit()"
coverage:
coverage run -p $(OPENGEODE) orchestrator.pr system_structure.pr --toAda
.PHONY: all edit test-parse test-ada test-llvm coverage
TASTE-BasicTypes DEFINITIONS ::=
BEGIN
TASTE-Peek-id ::= INTEGER (0..4294967295)
TASTE-Peek-id-list ::= SEQUENCE (SIZE (1..10)) OF TASTE-Peek-id
FixedIntList ::= SEQUENCE (SIZE(3)) OF TASTE-Peek-id
MyEnum ::= ENUMERATED {one, two, three, four, five}
END
gnatmake -c orchestrator.adb
gnatbind -n -Lliborchestrator orchestrator
gnatmake -c b~orchestrator.adb
gcc -shared -fPIC -o liborchestrator.so b~orchestrator.o orchestrator.o taste_basictypes.o adaasn1rtl.o -lgnat
/* CIF PROCESS (295, 56), (150, 75) */
PROCESS orchestrator
/* CIF COMMENT (405, 192), (71, 35) */
COMMENT 'Hello';
/* CIF TEXT (0, 94), (398, 312) */
dcl seq tastE_Peek_id_list := { 1,2,3,4,5};
dcl a myEnum;
dcl fixed fixedIntList := { 1,2,3};
/* CIF ENDTEXT */
/* CIF START (478, 150), (80, 36) */
START;
/* CIF NEXTSTATE (484, 201), (68, 34) */
NEXTSTATE Wait;
/* CIF STATE (601, 354), (70, 35) */
STATE next;
/* CIF INPUT (601, 409), (70, 35) */
INPUT *;
/* CIF NEXTSTATE (601, 459), (70, 35) */
NEXTSTATE wait;
ENDSTATE;
/* CIF STATE (484, 201), (68, 34) */
STATE Wait;
/* CIF INPUT (474, 255), (87, 35) */
INPUT pulse(a);
/* CIF OUTPUT (461, 305), (114, 35) */
OUTPUT telemetry(a);
/* CIF OUTPUT (456, 355), (123, 35) */
OUTPUT peek_list(seq);
/* CIF OUTPUT (445, 405), (145, 35) */
OUTPUT peek_fixed(fixed);
/* CIF NEXTSTATE (483, 455), (70, 35) */
NEXTSTATE next;
ENDSTATE;
ENDPROCESS orchestrator;
\ No newline at end of file
#!/bin/sh
make test-python
rm -rf simu
mkdir -p simu
asn2aadlPlus dataview-uniq.asn simu/DataView.aadl
cp liborchestrator.so dataview-uniq.asn *.pr simu
mv *.aadl simu
cd simu
aadl2glueC DataView.aadl orchestrator_interface.aadl
asn2dataModel -toPython dataview-uniq.asn
make -f Makefile.python
echo "errCodes=$(taste-asn1-errCodes ./dataview-uniq.h)" >>datamodel.py
LD_LIBRARY_PATH=. taste-gui -l
/* CIF Keep Specific Geode ASNFilename 'dataview-uniq.asn' */
USE Datamodel;
SYSTEM orchestrator;
SIGNAL pulse(myenum);
SIGNAL telemetry(myenum);
SIGNAL peek_list(taste_peek_id_list);
SIGNAL peek_fixed(fixedintlist);
CHANNEL c
FROM ENV TO orchestrator WITH pulse;
FROM orchestrator TO ENV WITH telemetry, peek_list, peek_fixed;
ENDCHANNEL;
BLOCK orchestrator;
SIGNALROUTE r
FROM ENV TO orchestrator WITH pulse;
FROM orchestrator TO ENV WITH telemetry, peek_list, peek_fixed;
CONNECT c and r;
PROCESS orchestrator REFERENCED;
ENDBLOCK;
ENDSYSTEM;
#!/usr/bin/env python
''' test script showing how to view the model's internal state '''
from ctypes import *
# load the shared object
test=CDLL('./liborchestrator.so')
test.liborchestratorinit()
get_value=test.fixed_value
get_value.restype = c_char_p
get_size = test.fixed_size
get_size.restype = c_long
size = get_size()
val = get_value()
print 'size =', size
# We know the size, cast it to an array of bytes that can then be converted to swig
as_bytes = cast(val, POINTER((c_byte *size)))
print 'value =', val, as_bytes.contents[0], as_bytes.contents[1]
#include <math.h>
#include <stdio.h>
#include "dataview-uniq.h"
extern void adainit();
void orchestrator_RI_peek_list(void *_) {}
void orchestrator_RI_peek_fixed(void *_) {}
void orchestrator_RI_telemetry(void *_){}
extern char *fixed_value();
extern int fixed_size();
int main()
{
char * toto;
int size;
int i;
printf("[C Code] Running test\n");
adainit();
toto = fixed_value();
size = fixed_size();
printf("Size=%d\n", size);
for (i = 0; i<size; i++) printf("%d", toto[i]);
printf("\n");
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