Commit 1b9a10eb authored by Maxime Perrotin's avatar Maxime Perrotin

Add Demo_Blackbox

parent 0d2a245b
This diff is collapsed.
/*
Automatically generated ACN grammar
Date was: 04/02/2012
Time was: 03:59:23
*/
TASTE-Dataview DEFINITIONS ::= BEGIN
/*A few simple types to start with ASN.1*/
MyInteger[size 16, encoding pos-int]
-- MyReal[encoding IEEE754-1985-64]
MyEnum[size 2, encoding pos-int]
MySeq[] {
a [] ,
b [size 2, encoding pos-int]
}
MyChoice[] {
a [true-value '11'B] ,
b []
}
MySeqOf[size 2] {
[]
}
MyOctStr[size 3]
END
TASTE-Dataview DEFINITIONS ::=
BEGIN
-- A few simple types to start with ASN.1
MyInteger ::= INTEGER (0..255)
--MyReal ::= REAL (0.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
MyOctStr ::= OCTET STRING (SIZE (3))
-- You can also declare variables (they will be visible in C, Ada and RTDS)
myVar MySeqOf ::= { hello, world }
-- myVar2 MyChoice ::= a:TRUE
END
---------------------------------------------------
-- AADL2.0
-- TASTE
-- (c)Ellidiss Technologies
--
---------------------------------------------------
PACKAGE deploymentview::DV::obj89
PUBLIC
WITH Taste;
WITH Deployment;
WITH TASTE_DV_Properties;
PROCESS demo_driver
END demo_driver;
PROCESS IMPLEMENTATION demo_driver.others
END demo_driver.others;
END deploymentview::DV::obj89;
PACKAGE deploymentview::DV
PUBLIC
WITH ocarina_processors_x86;
WITH deploymentview::DV::obj89;
WITH Taste;
WITH Deployment;
WITH interfaceview::IV;
WITH TASTE_DV_Properties;
SYSTEM obj89
END obj89;
SYSTEM IMPLEMENTATION obj89.others
SUBCOMPONENTS
IV_Caller_in_C : SYSTEM interfaceview::IV::Caller_in_C.others {
Taste::coordinates => "845 443 1395 599";
Taste::FunctionName => "Caller_in_C";
};
IV_Caller_in_Ada : SYSTEM interfaceview::IV::Caller_in_Ada.others {
Taste::coordinates => "1522 439 2637 630";
Taste::FunctionName => "Caller_in_Ada";
};
IV_BlackBox : SYSTEM interfaceview::IV::BlackBox.others {
Taste::coordinates => "1076 724 1996 1165";
Taste::FunctionName => "BlackBox";
};
demo_driver : PROCESS deploymentview::DV::obj89::demo_driver.others {
Taste::coordinates => "785 345 2688 1180";
Deployment::Port_Number => 0;
};
obj99 : PROCESSOR ocarina_processors_x86::x86.linux {
Taste::coordinates => "722 211 2801 1211";
};
PROPERTIES
Taste::APLC_Binding => (reference (demo_driver)) APPLIES TO IV_Caller_in_C;
Taste::APLC_Binding => (reference (demo_driver)) APPLIES TO IV_Caller_in_Ada;
Taste::APLC_Binding => (reference (demo_driver)) APPLIES TO IV_BlackBox;
Actual_Processor_Binding => (reference (obj99)) APPLIES TO demo_driver;
END obj89.others;
SYSTEM deploymentview
END deploymentview;
SYSTEM IMPLEMENTATION deploymentview.others
SUBCOMPONENTS
obj89 : SYSTEM obj89.others {
Taste::coordinates => "485 96 2853 1243";
};
interfaceview : SYSTEM interfaceview::IV::interfaceview.others;
END deploymentview.others;
PROPERTIES
Taste::coordinates => "0 0 2970 2100";
Taste::version => "1.3.17";
Taste::interfaceView => "InterfaceView.aadl";
Taste::HWLibraries => ("~/tool-inst/share/ocarina/AADLv2/ocarina_components.aadl");
END deploymentview::DV;
---------------------------------------------------
-- AADL2.0
-- TASTE
-- (c)Ellidiss Technologies
--
---------------------------------------------------
PACKAGE interfaceview::FV::Caller_in_Ada
PUBLIC
WITH Taste;
WITH DataView;
WITH TASTE_IV_Properties;
SUBPROGRAM PI_pulse
PROPERTIES
Taste::Associated_Queue_Size => 1;
END PI_pulse;
SUBPROGRAM IMPLEMENTATION PI_pulse.others
END PI_pulse.others;
SUBPROGRAM RI_RunDriver
FEATURES
inp1_uper : IN PARAMETER DataView::MyInteger {
Taste::encoding => UPER;
};
inp2_native : IN PARAMETER DataView::MyInteger {
Taste::encoding => ACN;
};
outp1_native : OUT PARAMETER DataView::MyInteger {
Taste::encoding => ACN;
};
outp2_uper : OUT PARAMETER DataView::MyInteger {
Taste::encoding => UPER;
};
END RI_RunDriver;
SUBPROGRAM IMPLEMENTATION RI_RunDriver.others
END RI_RunDriver.others;
END interfaceview::FV::Caller_in_Ada;
PACKAGE interfaceview::FV::BlackBox
PUBLIC
WITH Taste;
WITH DataView;
WITH TASTE_IV_Properties;
SUBPROGRAM PI_RunDriver
FEATURES
inp1_uper : IN PARAMETER DataView::MyInteger {
Taste::encoding => UPER;
};
inp2_native : IN PARAMETER DataView::MyInteger {
Taste::encoding => ACN;
};
outp1_native : OUT PARAMETER DataView::MyInteger {
Taste::encoding => ACN;
};
outp2_uper : OUT PARAMETER DataView::MyInteger {
Taste::encoding => UPER;
};
PROPERTIES
Taste::Associated_Queue_Size => 1;
END PI_RunDriver;
SUBPROGRAM IMPLEMENTATION PI_RunDriver.others
END PI_RunDriver.others;
END interfaceview::FV::BlackBox;
PACKAGE interfaceview::FV::Caller_in_C
PUBLIC
WITH Taste;
WITH DataView;
WITH TASTE_IV_Properties;
SUBPROGRAM PI_pulse
PROPERTIES
Taste::Associated_Queue_Size => 1;
END PI_pulse;
SUBPROGRAM IMPLEMENTATION PI_pulse.others
END PI_pulse.others;
SUBPROGRAM RI_RunDriver
FEATURES
inp1_uper : IN PARAMETER DataView::MyInteger {
Taste::encoding => UPER;
};
inp2_native : IN PARAMETER DataView::MyInteger {
Taste::encoding => ACN;
};
outp1_native : OUT PARAMETER DataView::MyInteger {
Taste::encoding => ACN;
};
outp2_uper : OUT PARAMETER DataView::MyInteger {
Taste::encoding => UPER;
};
END RI_RunDriver;
SUBPROGRAM IMPLEMENTATION RI_RunDriver.others
END RI_RunDriver.others;
END interfaceview::FV::Caller_in_C;
PACKAGE interfaceview::IV
PUBLIC
WITH interfaceview::FV::Caller_in_Ada;
WITH interfaceview::FV::BlackBox;
WITH interfaceview::FV::Caller_in_C;
WITH interfaceview::FV;
WITH Taste;
WITH DataView;
WITH TASTE_IV_Properties;
SYSTEM Caller_in_Ada
FEATURES
PI_pulse : PROVIDES SUBPROGRAM ACCESS interfaceview::FV::Caller_in_Ada::PI_pulse.others {
Taste::coordinates => "587 334";
Taste::RCMoperationKind => cyclic;
Taste::RCMperiod => 1000 ms;
Taste::Deadline => 0 ms;
Taste::InterfaceName => "pulse";
};
RI_RunDriver : REQUIRES SUBPROGRAM ACCESS interfaceview::FV::BlackBox::PI_RunDriver.others {
Taste::coordinates => "1302 384";
Taste::RCMoperationKind => unprotected;
Taste::InterfaceName => "RunDriver";
Taste::labelInheritance => "true";
};
PROPERTIES
Source_Language => (Ada);
END Caller_in_Ada;
SYSTEM IMPLEMENTATION Caller_in_Ada.others
SUBCOMPONENTS
pulse_impl : SUBPROGRAM interfaceview::FV::Caller_in_Ada::PI_pulse.others {
Compute_Execution_Time => 0 ms .. 0 ms;
};
CONNECTIONS
OpToPICnx_pulse_impl : SUBPROGRAM ACCESS pulse_impl -> PI_pulse;
END Caller_in_Ada.others;
SYSTEM BlackBox
FEATURES
PI_RunDriver : PROVIDES SUBPROGRAM ACCESS interfaceview::FV::BlackBox::PI_RunDriver.others {
Taste::coordinates => "1872 494";
Taste::RCMoperationKind => unprotected;
Taste::RCMperiod => 0 ms;
Taste::Deadline => 0 ms;
Taste::InterfaceName => "RunDriver";
};
PROPERTIES
Source_Language => (Blackbox_device);
END BlackBox;
SYSTEM IMPLEMENTATION BlackBox.others
SUBCOMPONENTS
RunDriver_impl : SUBPROGRAM interfaceview::FV::BlackBox::PI_RunDriver.others {
Compute_Execution_Time => 0 ms .. 0 ms;
};
CONNECTIONS
OpToPICnx_RunDriver_impl : SUBPROGRAM ACCESS RunDriver_impl -> PI_RunDriver;
END BlackBox.others;
SYSTEM Caller_in_C
FEATURES
PI_pulse : PROVIDES SUBPROGRAM ACCESS interfaceview::FV::Caller_in_C::PI_pulse.others {
Taste::coordinates => "576 1142";
Taste::RCMoperationKind => cyclic;
Taste::RCMperiod => 1000 ms;
Taste::Deadline => 0 ms;
Taste::InterfaceName => "pulse";
};
RI_RunDriver : REQUIRES SUBPROGRAM ACCESS interfaceview::FV::BlackBox::PI_RunDriver.others {
Taste::coordinates => "1338 1189";
Taste::RCMoperationKind => unprotected;
Taste::InterfaceName => "RunDriver";
Taste::labelInheritance => "true";
};
PROPERTIES
Source_Language => (C);
END Caller_in_C;
SYSTEM IMPLEMENTATION Caller_in_C.others
SUBCOMPONENTS
pulse_impl : SUBPROGRAM interfaceview::FV::Caller_in_C::PI_pulse.others {
Compute_Execution_Time => 0 ms .. 0 ms;
};
CONNECTIONS
OpToPICnx_pulse_impl : SUBPROGRAM ACCESS pulse_impl -> PI_pulse;
END Caller_in_C.others;
SYSTEM interfaceview
END interfaceview;
SYSTEM IMPLEMENTATION interfaceview.others
SUBCOMPONENTS
Caller_in_Ada : SYSTEM interfaceview::IV::Caller_in_Ada.others {
Taste::coordinates => "587 243 1302 896";
};
BlackBox : SYSTEM interfaceview::IV::BlackBox.others {
Taste::coordinates => "1872 359 2688 1008";
};
Caller_in_C : SYSTEM interfaceview::IV::Caller_in_C.others {
Taste::coordinates => "576 1037 1338 1690";
};
CONNECTIONS
BlackBox_RunDriver_Caller_in_Ada_RunDriver : SUBPROGRAM ACCESS BlackBox.PI_RunDriver -> Caller_in_Ada.RI_RunDriver {
Taste::coordinates => "1302 384 1579 384 1579 494 1872 494";
};
BlackBox_RunDriver_Caller_in_C_RunDriver : SUBPROGRAM ACCESS BlackBox.PI_RunDriver -> Caller_in_C.RI_RunDriver {
Taste::coordinates => "1338 1189 1597 1189 1597 494 1872 494";
};
END interfaceview.others;
PROPERTIES
Taste::dataView => ("DataView");
Taste::dataViewPath => ("DataView.aadl");
Taste::coordinates => "0 0 2970 2100";
Taste::version => "1.3.17";
END interfaceview::IV;
PACKAGE interfaceview::FV
PUBLIC
WITH Taste;
WITH DataView;
WITH TASTE_IV_Properties;
END interfaceview::FV;
KAZOO=../../kazoo
all: c ada
ada: test-parse-ada
cp caller_in_c/caller_in_c.c output.ada/caller_in_c/C/src
cp caller_in_ada/caller_in_ada.adb output.ada/caller_in_ada/Ada/src
cp blackbox/blackbox.c output.ada/blackbox/Blackbox_C/src
make -C output.ada
c: test-parse-c # Polyorb_HI_C output
cp caller_in_c/caller_in_c.c output.pohic/caller_in_c/C/src
cp caller_in_ada/caller_in_ada.adb output.pohic/caller_in_ada/Ada/src
cp blackbox/blackbox.c output.pohic/blackbox/Blackbox_C/src
$(MAKE) -C output.pohic
test-parse-ada: clean-ada
$(KAZOO) --gw \
-o output.ada \
--glue \
--debug
test-parse-c: clean-c
$(KAZOO) -p --gw \
-o output.pohic \
--glue --debug
buildsupport_pohic:
buildsupport -o output.buildsupport.pohic -p --aadlv2 --glue -i InterfaceView.aadl -c DeploymentView.aadl -d DataView.aadl ../common/ocarina_components.aadl ../common/TASTE_IV_Properties.aadl ../common/TASTE_DV_Properties.aadl
buildsupport_pohiada:
buildsupport -o output.buildsupport.ada --aadlv2 --glue -i InterfaceView.aadl -c DeploymentView.aadl -d DataView.aadl ../common/ocarina_components.aadl ../common/TASTE_IV_Properties.aadl ../common/TASTE_DV_Properties.aadl
gdb: clean
gdb --args $(KAZOO) --gw \
-o output.pohic \
--glue \
--debug
clean-ada:
rm -rf output.ada
clean-c:
rm -rf output.pohic
skeletons:
$(KAZOO) -p --gw --glue -o code && make -C code dataview
clean-skeletons:
rm -rf code
clean: clean-ada clean-c clean-skeletons
.PHONY: clean clean-ada clean-c test-parse-ada gdb test-parse-c buildsupport_pohic buildsupport_pohiada c skeletons clean-skeletons
Demo_BlackBox
This demo shows how to use blackbox devices with parameters encoded in ACN and uPER
The BB device parameters are received in binary format (not decoded) and can be sent as is to the physical device.
The interface to the BB Device is synchronous (unprotected). It could be asynchronous...
There are two callers, one in C and one in Ada, and the build is done for both runtimes (C and Ada)
/* Functions to be filled by the user (never overwritten by buildsupport tool) */
#include "blackbox.h"
#include <stdio.h>
#include <string.h>
void init_blackbox()
{
printf ("[blackbox] startup\n");
}
void blackbox_RunDriver
(const char *IN_inp1_uper, size_t IN_inp1_uper_len,
const char *IN_inp2_native, size_t IN_inp2_native_len,
char *OUT_outp1_native, size_t *OUT_outp1_native_len,
char *OUT_outp2_uper, size_t *OUT_outp2_uper_len)
{
memcpy(OUT_outp1_native, IN_inp2_native, IN_inp2_native_len);
memcpy(OUT_outp2_uper, IN_inp1_uper, IN_inp1_uper_len);
*OUT_outp1_native_len = IN_inp2_native_len;
*OUT_outp2_uper_len = IN_inp1_uper_len;
}
#!/bin/bash
# This script will build your TASTE system.
# You must check it before running it: it may need to be adapted to your context:
# 1) You may need to fix some paths and filenames (path to interface/deployment views)
# 2) You may need to specify additional paths for the compiler to find .h file
# (e.g. "export C_INCLUDE_PATH=/usr/include/xenomai/analogy/:$C_INCLUDE_PATH")
# 3) You may need to link with pre-built libraries, using the -l option
# (e.g. -l /usr/lib/libanalogy.a,/usr/lib/librtdm.a)
# 4) You may need to change the runtime (add -p flag to select PolyORB-HI-C)
# etc.
# Note: TASTE will not overwrite your changes - if you need to update some parts
# you will have to merge the changes with the newly-created "build-script.new.sh" file.
mkdir -p .cache
export PROJECT_CACHE=$HOME/.taste_AST_cache
if [ -z "$DEPLOYMENTVIEW" ]
then
DEPLOYMENTVIEW=DeploymentView.aadl
fi
SKELS="./"
cd "$SKELS"
rm -f caller_in_ada.zip
zip caller_in_ada caller_in_ada/*
rm -f blackbox.zip
zip blackbox blackbox/*
rm -f caller_in_c.zip
zip caller_in_c caller_in_c/*
cd "$OLDPWD"
[ ! -z "$CLEANUP" ] && rm -rf binary*
echo 'Building the system with the Ada runtime (add -p in the build script to replace with C)'
assert-builder-ocarina.py \
-f \
-g \
--aadlv2 \
--keep-case \
--interfaceView InterfaceView.aadl \
--deploymentView "$DEPLOYMENTVIEW" \
-o binary.ada \
--subAda caller_in_ada:"$SKELS"/caller_in_ada.zip \
--subC blackbox:"$SKELS"/blackbox.zip \
--subC caller_in_c:"$SKELS"/caller_in_c.zip
echo 'Building the system with the C runtime'
assert-builder-ocarina.py \
-f \
-g -p \
--aadlv2 \
--keep-case \
--interfaceView InterfaceView.aadl \
--deploymentView "$DEPLOYMENTVIEW" \
-o binary.pohic \
--subAda caller_in_ada:"$SKELS"/caller_in_ada.zip \
--subC blackbox:"$SKELS"/blackbox.zip \
--subC caller_in_c:"$SKELS"/caller_in_c.zip
-- User implementation of the caller_in_ada function
-- This file will never be overwritten once edited and modified
-- Only the interface of functions is regenerated (in the .ads file)
with adaasn1rtl;
use adaasn1rtl;
with taste_dataview;
use taste_dataview;
with system.io;
with interfaces;
use interfaces;
package body caller_in_ada is
i1: asn1sccMyInteger := 0;
i2: asn1SccMyInteger := 1;
o1: asn1SccMyInteger;
o2: asn1SccMyInteger;
---------------------------------------------------------
-- Provided interface "pulse"
---------------------------------------------------------
procedure pulse is
begin
RunDriver(i1, i2, o1, o2);
system.io.put("[Ada] i1=");
system.io.put(asn1sccMyInteger'image(i1));
system.io.put(" i2=");
system.io.put(asn1sccMyInteger'image(i2));
system.io.put(" o1=");
system.io.put(asn1sccMyInteger'image(o1));
system.io.put(" o2=");
system.io.put(asn1sccMyInteger'image(o2));
if i1 /= o2 or i2 /= o1 then
system.io.put_line("[...ERROR!");
else system.io.put_line("...OK");
end if;
i1 := i1 + 1;
i2 := i2 + 1;
end pulse;
begin
system.io.put_line("[Ada] startup");
end caller_in_ada;
/* Functions to be filled by the user (never overwritten by buildsupport tool) */
#include "caller_in_c.h"
#include <stdio.h>
void caller_in_c_startup()
{
printf("[C] startup\n");
}
void caller_in_c_PI_pulse()
{
static asn1SccMyInteger i1=0, i2=1, o1, o2;
caller_in_c_RI_RunDriver(&i1, &i2, &o1, &o2);
printf ("[C] i1 = %lld, i2 = %lld, o1 = %lld, o2 = %lld", i1,i2,o1,o2);
if (i1 != o2 || i2 != o1) {
printf ("... ERROR!\n");
exit(-1);
}
else printf("...OK\n");
i1++;
i2++;
}
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