Commit 26f96c14 authored by yoogx's avatar yoogx
Browse files

* Extend some-types example to support arrays

        For openaadl/ocarina#99
parent 47796aa2
......@@ -43,7 +43,7 @@ features
end P;
thread implementation P.Impl
calls
calls
Mycalls: {
P_Spg : subprogram Produce_Spg;
};
......@@ -60,7 +60,7 @@ features
end Q;
thread implementation Q.Impl
calls
calls
Mycalls: {
Q_Spg : subprogram Consume_Spg;
};
......
......@@ -2,187 +2,234 @@ package Software
public
with Data_Model;
----------
-- Data --
----------
data Boolean_Type
properties
Data_Model::Data_Representation => boolean;
end Boolean_Type;
data Integer_Type
properties
Data_Model::Data_Representation => integer;
end Integer_Type;
data Struct_Type
end Struct_Type;
data implementation Struct_Type.impl
subcomponents
x : data Integer_Type;
y : data Integer_Type;
properties
Data_Model::Data_Representation => struct;
end Struct_Type.impl;
-----------------
-- Subprograms --
-----------------
subprogram Emit_Boolean
features
Data_Source : out parameter Boolean_Type;
properties
source_language => C;
source_name => "user_emit_boolean";
source_text => ("some-types.c");
end Emit_Boolean;
subprogram Receive_Boolean
features
Data_Sink : in parameter Boolean_Type;
properties
source_language => C;
source_name => "user_receive_boolean";
source_text => ("some-types.c");
end Receive_Boolean;
subprogram Emit_Integer
features
Data_Source : out parameter Integer_Type;
properties
source_language => C;
source_name => "user_emit_integer";
source_text => ("some-types.c");
end Emit_Integer;
subprogram Receive_Integer
features
Data_Sink : in parameter Integer_Type;
properties
source_language => C;
source_name => "user_receive_integer";
source_text => ("some-types.c");
end Receive_Integer;
subprogram Emit_Struct
features
Data_Source : out parameter Struct_Type.impl;
properties
source_language => C;
source_name => "user_emit_struct";
source_text => ("some-types.c");
end Emit_Struct;
subprogram Receive_Struct
features
Data_Sink : in parameter Struct_Type.impl;
properties
source_language => C;
source_name => "user_receive_struct";
source_text => ("some-types.c");
end Receive_Struct;
--------------------------
-- Wrappers Subprograms --
--------------------------
subprogram Emitter_Wrapper
features
Boolean_Source : out parameter Boolean_Type;
Integer_Source : out parameter Integer_Type;
Struct_Source : out parameter Struct_Type.Impl;
end Emitter_Wrapper;
subprogram implementation Emitter_Wrapper.Impl
calls
Mycalls: {
B_Spg : subprogram Emit_Boolean;
I_Spg : subprogram Emit_Integer;
S_Spg : subprogram Emit_Struct;
};
connections
parameter B_Spg.Data_Source -> Boolean_Source;
parameter I_Spg.Data_Source -> Integer_Source;
parameter S_Spg.Data_Source -> Struct_Source;
end Emitter_Wrapper.Impl;
-------------
-- Threads --
-------------
thread Emitter
features
Boolean_Source : out event data port Boolean_Type;
Integer_Source : out event data port Integer_Type;
Struct_Source : out event data port Struct_Type.Impl;
end Emitter;
thread implementation Emitter.Impl
calls
Mycalls: {
Emitter_Wrapper : subprogram Emitter_Wrapper.Impl;
};
connections
parameter Emitter_Wrapper.Boolean_Source -> Boolean_Source;
parameter Emitter_Wrapper.Integer_Source -> Integer_Source;
parameter Emitter_Wrapper.Struct_Source -> Struct_Source;
properties
Dispatch_Protocol => Periodic;
Period => 1000 Ms;
end Emitter.Impl;
thread Boolean_Receiver
features
Data_Sink : in event data port Boolean_Type;
end Boolean_Receiver;
thread implementation Boolean_Receiver.Impl
calls
Mycalls: {
B_Spg : subprogram Receive_Boolean;
};
connections
parameter Data_Sink -> B_Spg.Data_Sink;
properties
Dispatch_Protocol => Sporadic;
Period => 10 Ms;
end Boolean_Receiver.Impl;
thread Integer_Receiver
features
Data_Sink : in event data port Integer_Type;
end Integer_Receiver;
thread implementation Integer_Receiver.Impl
calls
Mycalls: {
I_Spg : subprogram Receive_Integer;
};
connections
parameter Data_Sink -> I_Spg.Data_Sink;
properties
Dispatch_Protocol => Sporadic;
Period => 10 Ms;
end Integer_Receiver.Impl;
thread Struct_Receiver
features
Data_Sink : in event data port Struct_Type.Impl;
end Struct_Receiver;
thread implementation Struct_Receiver.Impl
calls
Mycalls: {
S_Spg : subprogram Receive_Struct;
};
connections
parameter Data_Sink -> S_Spg.Data_Sink;
properties
Dispatch_Protocol => Sporadic;
Period => 10 Ms;
end Struct_Receiver.Impl;
----------
-- Data --
----------
data Boolean_Type
properties
Data_Model::Data_Representation => boolean;
end Boolean_Type;
data Integer_Type
properties
Data_Model::Data_Representation => integer;
end Integer_Type;
data Struct_Type
end Struct_Type;
data implementation Struct_Type.impl
subcomponents
x : data Integer_Type;
y : data Integer_Type;
properties
Data_Model::Data_Representation => struct;
end Struct_Type.impl;
data Array_Type
properties
Data_Model::Data_Representation => Array;
Data_Model::Base_Type => (classifier (Base_Types::Integer));
Data_Model::Dimension => (500_000_0);
end Array_Type;
-----------------
-- Subprograms --
-----------------
subprogram Emit_Boolean
features
Data_Source : out parameter Boolean_Type;
properties
source_language => C;
source_name => "user_emit_boolean";
source_text => ("some-types.c");
end Emit_Boolean;
subprogram Receive_Boolean
features
Data_Sink : in parameter Boolean_Type;
properties
source_language => C;
source_name => "user_receive_boolean";
source_text => ("some-types.c");
end Receive_Boolean;
subprogram Emit_Integer
features
Data_Source : out parameter Integer_Type;
properties
source_language => C;
source_name => "user_emit_integer";
source_text => ("some-types.c");
end Emit_Integer;
subprogram Receive_Integer
features
Data_Sink : in parameter Integer_Type;
properties
source_language => C;
source_name => "user_receive_integer";
source_text => ("some-types.c");
end Receive_Integer;
subprogram Emit_Struct
features
Data_Source : out parameter Struct_Type.impl;
properties
source_language => C;
source_name => "user_emit_struct";
source_text => ("some-types.c");
end Emit_Struct;
subprogram Receive_Struct
features
Data_Sink : in parameter Struct_Type.impl;
properties
source_language => C;
source_name => "user_receive_struct";
source_text => ("some-types.c");
end Receive_Struct;
subprogram Emit_Array
features
Data_Source : out parameter Array_Type;
properties
source_language => C;
source_name => "user_emit_array";
source_text => ("some-types.c");
end Emit_Array;
subprogram Receive_Array
features
Data_Sink : in parameter Array_Type;
properties
source_language => C;
source_name => "user_receive_array";
source_text => ("some-types.c");
end Receive_Array;
--------------------------
-- Wrappers Subprograms --
--------------------------
subprogram Emitter_Wrapper
features
Boolean_Source : out parameter Boolean_Type;
Integer_Source : out parameter Integer_Type;
Struct_Source : out parameter Struct_Type.Impl;
Array_Source : out parameter Array_Type;
end Emitter_Wrapper;
subprogram implementation Emitter_Wrapper.Impl
calls
Mycalls: {
B_Spg : subprogram Emit_Boolean;
I_Spg : subprogram Emit_Integer;
S_Spg : subprogram Emit_Struct;
A_Spg : subprogram Emit_Array;
};
connections
parameter B_Spg.Data_Source -> Boolean_Source;
parameter I_Spg.Data_Source -> Integer_Source;
parameter S_Spg.Data_Source -> Struct_Source;
parameter A_Spg.Data_Source -> Array_Source;
end Emitter_Wrapper.Impl;
-------------
-- Threads --
-------------
thread Emitter
features
Boolean_Source : out event data port Boolean_Type;
Integer_Source : out event data port Integer_Type;
Struct_Source : out event data port Struct_Type.Impl;
Array_Source : out event data port Array_Type;
end Emitter;
thread implementation Emitter.Impl
calls
Mycalls: {
Emitter_Wrapper : subprogram Emitter_Wrapper.Impl;
};
connections
parameter Emitter_Wrapper.Boolean_Source -> Boolean_Source;
parameter Emitter_Wrapper.Integer_Source -> Integer_Source;
parameter Emitter_Wrapper.Struct_Source -> Struct_Source;
parameter Emitter_Wrapper.Array_Source -> Array_Source;
properties
Dispatch_Protocol => Periodic;
Period => 5000 ms;
end Emitter.Impl;
thread Boolean_Receiver
features
Data_Sink : in event data port Boolean_Type;
end Boolean_Receiver;
thread implementation Boolean_Receiver.Impl
calls
Mycalls: {
B_Spg : subprogram Receive_Boolean;
};
connections
parameter Data_Sink -> B_Spg.Data_Sink;
properties
Dispatch_Protocol => Sporadic;
Period => 10 Ms;
end Boolean_Receiver.Impl;
thread Integer_Receiver
features
Data_Sink : in event data port Integer_Type;
end Integer_Receiver;
thread implementation Integer_Receiver.Impl
calls
Mycalls: {
I_Spg : subprogram Receive_Integer;
};
connections
parameter Data_Sink -> I_Spg.Data_Sink;
properties
Dispatch_Protocol => Sporadic;
Period => 10 Ms;
end Integer_Receiver.Impl;
thread Struct_Receiver
features
Data_Sink : in event data port Struct_Type.Impl;
end Struct_Receiver;
thread implementation Struct_Receiver.Impl
calls
Mycalls: {
S_Spg : subprogram Receive_Struct;
};
connections
parameter Data_Sink -> S_Spg.Data_Sink;
properties
Dispatch_Protocol => Sporadic;
Period => 10 Ms;
end Struct_Receiver.Impl;
thread Array_Receiver
features
Data_Sink : in event data port Array_Type;
end Array_Receiver;
thread implementation Array_Receiver.Impl
calls
Mycalls: {
S_Spg : subprogram Receive_Array;
};
connections
parameter Data_Sink -> S_Spg.Data_Sink;
properties
Dispatch_Protocol => Sporadic;
Period => 10 Ms;
end Array_Receiver.Impl;
end Software;
/*
* This is a part of PolyORB-HI-C distribution, a minimal
* middleware written for generated code from AADL models.
* You should use it with the Ocarina toolsuite.
*
* For more informations, please visit http://taste.tuxfamily.org/wiki
*
* Copyright (C) 2017 ESA & ISAE.
*/
#include <assert.h>
#include <stdio.h>
#include <types.h>
......@@ -23,13 +34,22 @@ void user_receive_boolean (int boolean)
printf ("Receiving boolean : %d\n", boolean);
}
void user_emit_integer( int* integer)
void user_emit_integer (int* integer)
{
integer_type_var++;
*integer = integer_type_var;
printf ("Emetting integer : %d\n", *integer);
}
void user_emit_array (software__array_type* data_source)
{
for (int i = 0; i < 16384; i++)
(*data_source)[i]=i;
printf ("Emetting array\n");
printf ("\n");
}
void user_receive_integer (int integer)
{
printf ("Receiving integer : %d\n", integer);
......@@ -42,7 +62,7 @@ void user_emit_struct (software__struct_type_impl *v)
value.x = i;
value.y = i;
printf ("*** SENDING PING *** %d\n", i);
i++;
*v = value;
......@@ -54,3 +74,13 @@ void user_receive_struct (software__struct_type_impl i)
printf ("*** PING *** (%d, %d)\n" ,i.x, i.y);
fflush (stdout);
}
void user_receive_array (software__array_type data)
{
printf("Receive array: ");
for (int i = 0; i < 16; i++)
assert (data[i] == i);
printf (" OK \n");
fflush(stdout);
}
......@@ -5,121 +5,129 @@ public
with ocarina_drivers;
with ocarina_buses;
---------------
-- Processor --
---------------
processor the_processor
properties
Deployment::Execution_Platform => Native;
end the_processor;
---------------
-- Processes --
---------------
process A
features
Out_Boolean : out event data port Software::Boolean_Type;
Out_Integer : out event data port Software::Integer_Type;
Out_Struct : out event data port Software::Struct_Type.Impl;
end A;
process implementation A.Impl
subcomponents
Emitter_Thread : thread Software::Emitter.Impl;
connections
port Emitter_Thread.Boolean_Source -> Out_Boolean;
port Emitter_Thread.Integer_Source -> Out_Integer;
port Emitter_Thread.Struct_Source -> Out_Struct;
end A.Impl;
process B
features
In_Boolean : in event data port Software::Boolean_Type;
In_Integer : in event data port Software::Integer_Type;
In_Struct : in event data port Software::Struct_Type.Impl;
end B;
process implementation B.Impl
subcomponents
Boolean_Rcv_Thread : thread Software::Boolean_Receiver.Impl;
Integer_Rcv_Thread : thread Software::Integer_Receiver.Impl;
Struct_Rcv_Thread : thread Software::Struct_Receiver.Impl;
connections
port In_Boolean -> Boolean_Rcv_Thread.Data_Sink;
port In_Integer -> Integer_Rcv_Thread.Data_Sink;
port In_Struct -> Struct_Rcv_Thread.Data_Sink;
end B.Impl;
process singleProcess
end singleProcess;
process implementation singleProcess.impl
subcomponents
Emitter_Thread : thread Software::Emitter.Impl;
Boolean_Rcv_Thread : thread Software::Boolean_Receiver.Impl;
Integer_Rcv_Thread : thread Software::Integer_Receiver.Impl;
Struct_Rcv_Thread : thread Software::Struct_Receiver.Impl;
connections
port Emitter_Thread.Boolean_Source -> Boolean_Rcv_Thread.Data_Sink;
port Emitter_Thread.Integer_Source -> Integer_Rcv_Thread.Data_Sink;
port Emitter_Thread.Struct_Source -> Struct_Rcv_Thread.Data_Sink;
end singleProcess.impl;
------------
-- System --
------------
system Some_Types
end Some_Types;
system implementation Some_Types.Impl
subcomponents
Node_A : process A.Impl;
Node_B : process B.Impl;
Device_A : device ocarina_drivers::generic_sockets_ip.pohic
---------------
-- Processor --
---------------
processor the_processor
properties
Deployment::Execution_Platform => Native;
end the_processor;
---------------
-- Processes --
---------------
process A
features
Out_Boolean : out event data port Software::Boolean_Type;
Out_Integer : out event data port Software::Integer_Type;
Out_Struct : out event data port Software::Struct_Type.Impl;
Out_Array : out event data port Software::Array_Type;
end A;
process implementation A.Impl
subcomponents
Emitter_Thread : thread Software::Emitter.Impl;
connections
port Emitter_Thread.Boolean_Source -> Out_Boolean;
port Emitter_Thread.Integer_Source -> Out_Integer;
port Emitter_Thread.Struct_Source -> Out_Struct;
port Emitter_Thread.Array_Source -> Out_Array;
end A.Impl;
process B
features
In_Boolean : in event data port Software::Boolean_Type;
In_Integer : in event data port Software::Integer_Type;
In_Struct : in event data port Software::Struct_Type.Impl;
in_array : in event data port Software::Array_Type;
end B;
process implementation B.Impl
subcomponents
Boolean_Rcv_Thread : thread Software::Boolean_Receiver.Impl;
Integer_Rcv_Thread : thread Software::Integer_Receiver.Impl;