Commit 0915b33a authored by Maxime Perrotin's avatar Maxime Perrotin

Start templates for gui support

parent 2abebdb3
......@@ -6,8 +6,14 @@
@@-- @_List_Of_RIs_@ : List of all Required Interfaces (just names)
@@-- @_List_Of_Sync_PIs@ : List of synchronous Provided Interfaces
@@-- @_List_Of_Sync_RIs@ : List of synchronous Required Interfaces
@@-- @_List_Of_ASync_PIs@ : List of asynchronous Provided Interfaces
@@-- @_List_Of_ASync_RIs@ : List of asynchronous Required Interfaces
@@-- @_Sync_RIs_Parent_@
@@-- @_List_Of_ASync_PIs@ : Vector tag: list of async Provided Interfaces
@@-- @_ASync_PI_Param_Name_@ : |_ Corresponding parameter name (or empty string)
@@-- @_ASync_PI_Param_Type_@ : |_ Corresponding parameter type (or empty string)
@@-- @_List_Of_ASync_RIs@ : Vector tag: list of asynchronous Required Interfaces
@@-- @_ASync_RI_Param_Name_@ : |_ Corresponding parameter name (or empty string)
@@-- @_ASync_RI_Param_Type_@ : |_ Corresponding parameter type (or empty string)
@@-- @_Async_RIs_Parent_@ : |_ Corresponding parent function
@@-- @_ASN1_Modules_@ : List of ASN.1 Modules names
@@-- @_ASN1_Files_@ : List of ASN.1 Files with path
@@-- @_Timers_@ : List of timers (just names)
......@@ -20,4 +26,117 @@
@@-- @_Property_Values_@ : List of User-defined properties (values)
@@-- @_Is_Type_@ : Flag, True if function is a component type
@@-- @_Instance_Of_@ : Optional name of component type
@@INCLUDE@@ ../c-body/function.tmplt
/* Body file for GUI @_Name_@
* Generated by TASTE on @_NOW_@
* DO NOT EDIT THIS FILE MANUALLY - MODIFY THE KAZOO TEMPLATE IF NECESSARY
*/
#include <unistd.h>
#include <mqueue.h>
#include "queue_manager.h"
#include "@_LOWER:Name_@.h"
#include "@_LOWER:Name_@_enums_def.h"
typedef struct _PI_Messages {
T_@_LOWER:Name_@_PI_list msg_id;
union {
@@TABLE@@
@@IF@@ @_ASync_PI_Param_Type_@ /= ""
asn1Scc@_REPLACE_ALL(-/_):ASync_PI_Param_Type_@ @_LOWER:List_Of_ASync_PIs_@_param;
@@END_IF@@
@@END_TABLE@@
} msg_data;
} PI_Messages;
typedef struct _RI_Messages {
T_@_LOWER:Name_@_RI_list msg_id;
union {
@@TABLE@@
@@IF@@ @_ASync_RI_Param_Type_@ /= ""
asn1Scc@_REPLACE_ALL(-/_):ASync_RI_Param_Type_@ @_LOWER:List_Of_ASync_RIs_@_param;
@@END_IF@@
@@END_TABLE@@
} msg_data;
} RI_Messages;
@@IF@@ @_List_Of_PIs'Length_@ > 0
// Queues of messages going from the binary to the user (PIs, or TMs)
static mqd_t @_LOWER:Name_@_PI_queue_id,
@_LOWER:Name_@_PI_Python_queue_id;
@@END_IF@@
@@IF@@ @_List_Of_PIs'Length_@ > 0
// Queues of messages going from the user to the binary GUI (RIs, or TCs)
static mqd_t @_LOWER:Name_@_RI_queue_id;
@@END_IF@@
void @_LOWER:Name_@_startup(void)
{
unsigned msgsize_max = 8192;
FILE *f = fopen("/proc/sys/fs/mqueue/msgsize_max", "r");
fscanf(f, "%d", &msgsize_max);
if (msgsize_max < sizeof (PI_Messages) || msgsize_max < sizeof (RI_Messages)) {
printf("[ERROR] The GUI is passing a message which parameter size "
"exceeds your system limit (which is %d bytes per message).\n"
"You can extend this limit by running: \n"
" echo NUMBER | sudo tee /proc/sys/fs/mqueue/msgsize_max\n"
" ... with NUMBER > %ld\n"
"You can also make it permanent (check TASTE wiki)\n\n",
msgsize_max,
sizeof(PI_Messages) > sizeof(RI_Messages) ? sizeof(PI_Messages):sizeof(RI_Messages));
exit(1);
}
char *gui_queue_name = NULL;
int len = snprintf (gui_queue_name, 0, "%d_ground_RI_queue", geteuid());
gui_queue_name = (char *) malloc ((size_t) len + 1);
if (NULL != gui_queue_name) {
snprintf (gui_queue_name, len + 1, "%d_ground_RI_queue", geteuid());
create_exchange_queue(gui_queue_name, 5, sizeof(RI_Messages), &ground_RI_queue_id);
free (gui_queue_name);
gui_queue_name = NULL;
}
len = snprintf (gui_queue_name, 0, "%d_ground_PI_queue", geteuid());
gui_queue_name = (char *) malloc ((size_t) len + 1);
if (NULL != gui_queue_name) {
snprintf (gui_queue_name, len + 1, "%d_ground_PI_queue", geteuid());
create_exchange_queue(gui_queue_name, 10, sizeof(PI_Messages), &ground_PI_queue_id);
free (gui_queue_name);
gui_queue_name = NULL;
}
len = snprintf (gui_queue_name, 0, "%d_ground_PI_Python_queue", geteuid());
gui_queue_name = (char *) malloc ((size_t) len + 1);
if (NULL != gui_queue_name) {
snprintf (gui_queue_name, len + 1, "%d_ground_PI_Python_queue", geteuid());
/* Extra queue for the TM sent to the Python mappers */
create_exchange_queue(gui_queue_name, 10, sizeof (PI_Messages), &ground_PI_Python_queue_id);
free (gui_queue_name);
gui_queue_name = NULL;
}
}
@@TABLE@@
@_Provided_Interfaces_@
@@END_TABLE@@
@@TABLE@@
void @_LOWER:Name_@_PI_@_Timers_@(void)
{
// There shoud be no timers in GUI functions
// However the template may be modified to support them and do specific
// action upon timer expiration (e.g. periodic check that the GUI queue
// is still alive).
}
@@END_TABLE@@
......@@ -7,4 +7,75 @@
@@-- @_Param_Names_@ : List of parameter names
@@-- @_Param_Types_@ : |_ Corresponding parameter types
@@-- @_Param_Directions_@ : |_ Corresponding direction
@@INCLUDE@@ ../c-header/interface.tmplt
@@IF@@ @_EXIST:Param_Names_@
void @_LOWER:Parent_Function_@_PI_@_LOWER:Name_@
@@INLINE( \()(,\n )(\)\n)@@
@@TABLE@@
@@IF@@ @_Param_Directions_@ = "PARAM_IN"
const asn1Scc@_REPLACE_ALL((-)/_):Param_Types_@ *IN_@_LOWER:Param_Names_@
@@ELSE@@
asn1Scc@_REPLACE_ALL((-)/_):Param_Types_@ *OUT_@_LOWER:Param_Names_@
@@END_IF@@
@@END_TABLE@@
@@END_INLINE@@
{
@@TABLE@@ @@-- Write parameters in sequence. In practice there is only one paraemeter since it's a sporadic PI
write_message_to_queue
(@_LOWER:Parent_Function_@_PI_queue_id,
sizeof(asn1Scc@_REPLACE_ALL(-/_):Param_Types_@),
(void*)IN_@_LOWER:Param_Names_@,
i_@_LOWER:Name_@);
write_message_to_queue
(@_LOWER:Parent_Function_@_PI_Python_queue_id,
sizeof(asn1Scc@_REPLACE_ALL(-/_):Param_Types_@),
(void*)IN_@_LOWER:Param_Names_@,
i_@_LOWER:Name_@);
@@END_TABLE@@
}
@@ELSE@@
void @_LOWER:Parent_Function_@_PI_@_LOWER:Name_@(void)
{
@@IF@@ @_LOWER:Name_@ /= poll
write_message_to_queue
(@_LOWER:Parent_Function_@_PI_queue_id,
0, // Message parameter size is 0 since there is no parameter
NULL, // Pointer to message content is null for the same reason
i_@_LOWER:Name_@);
write_message_to_queue
(@_LOWER:Parent_Function_@_PI_Python_queue_id,
0,
NULL,
i_@_LOWER:Name_@);
@@ELSE@@ @@-- GUI polling function
struct mq_attr msgq_attr;
char* msgcontent = NULL;
T_ground_RI_list message_recieved_type;
if ((msgcontent = (char*)malloc(sizeof(RI_Messages))) == NULL) {
perror("Error when allocating memory in GUI polling function");
exit (-1);
}
mq_getattr(ground_RI_queue_id, &msgq_attr);
while (!retrieve_message_from_queue(ground_RI_queue_id,
sizeof(RI_Messages),
msgcontent,
(int *)&message_recieved_type))
{
switch(message_recieved_type)
{
// case i_run_forrest : INVOKE_RI_run_forrest (msgcontent);
// break;
default : break;
}
}
free(msgcontent);
return;
@@END_IF@@
}
@@END_IF@@
Generate types with list of enumerated values corresponding to the message identifiers used in GUIs. This file is included by the GUI code and by the Python-ctypes GUI interface.
@@-- The following tags are available in this template:
@@--
@@-- @_Name_@ : The name of the function
@@-- @_Is_Type_@ : True if function type
@@-- @_Instance_Of_@ : Name of instance or empty string
@_LOWER:Name_@_enums_def.h
@@-- The following tags are available in this template:
@@--
@@-- @_Name_@ : The name of the function
@@-- @_Language_@ : The implementation language
@@-- @_List_Of_PIs_@ : List of all Provided Interfaces (just names)
@@-- @_List_Of_RIs_@ : List of all Required Interfaces (just names)
@@-- @_List_Of_Sync_PIs@ : List of synchronous Provided Interfaces
@@-- @_List_Of_Sync_RIs@ : List of synchronous Required Interfaces
@@-- @_Sync_RIs_Parent_@
@@-- @_List_Of_ASync_PIs@ : Vector tag: list of async Provided Interfaces
@@-- @_ASync_PI_Param_Name_@ : |_ Corresponding parameter name (or empty string)
@@-- @_ASync_PI_Param_Type_@ : |_ Corresponding parameter type (or empty string)
@@-- @_List_Of_ASync_RIs@ : Vector tag: list of asynchronous Required Interfaces
@@-- @_ASync_RI_Param_Name_@ : |_ Corresponding parameter name (or empty string)
@@-- @_ASync_RI_Param_Type_@ : |_ Corresponding parameter type (or empty string)
@@-- @_Async_RIs_Parent_@ : |_ Corresponding parent function
@@-- @_ASN1_Modules_@ : List of ASN.1 Modules names
@@-- @_ASN1_Files_@ : List of ASN.1 Files with path
@@-- @_Timers_@ : List of timers (just names)
@@-- @_Has_Context_@ : Flag, True if there are context parameters
@@-- @_CP_Names_@ : List of Context Parameter names
@@-- @_CP_Types_@ : List of Context Parameter types
@@-- @_Provided_Interfaces_@ : From template: Provided interfaces with params
@@-- @_Required_Interfaces_@ : From template: Required interfaces with params
@@-- @_Property_Names_@ : List of User-defined properties (names)
@@-- @_Property_Values_@ : List of User-defined properties (values)
@@-- @_Is_Type_@ : Flag, True if function is a component type
@@-- @_Instance_Of_@ : Optional name of component type
/* Message identifiers for the GUI messages
* Used by the code of the GUIs and by the ctypes Python interface
* DO NOT EDIT THIS FILE MANUALLY - MODIFY THE KAZOO TEMPLATE IF NECESSARY
*/
#pragma once
typedef enum {
@@INLINE( )(,\n )()@@
@@TABLE@@
@@IF@@ @_LOWER:List_Of_ASync_PIs_@ /= poll
i_@_LOWER:List_Of_ASync_PIs_@
@@END_IF@@
@@END_TABLE@@
@@END_INLINE@@
} T_@_LOWER:Name_@_PI_list;
typedef enum {
@@INLINE( )(,\n )()@@
@@TABLE@@
i_@_LOWER:List_Of_ASync_RIs_@
@@END_TABLE@@
@@END_INLINE@@
} T_@_LOWER:Name_@_RI_list;
@@-- The following tags are available in this template:
@@--
@@-- @_Name_@ : The name of the interface
@@-- @_Direction_@ : "PI" or "RI"
@@-- @_Kind_@ : The RCM Kind
@@-- @_Parent_Function_@ : The name of the function
@@-- @_Param_Names_@ : List of parameter names
@@-- @_Param_Types_@ : |_ Corresponding parameter types
@@-- @_Param_Directions_@ : |_ Corresponding direction
@@-- This template must return either TRUE or something else (meaning FALSE)
@@-- It is used to determine if the other templates in this folder will be
@@-- processed or ignored.
@@-- One folder can contain two templates: one for a function, and one for
@@-- a corresponding makefile (or build script)
@@-- The name of the function is read from template "function-filename.tmplt"
@@-- The name of the makefile is read from template "makefile-filename.tmplt"
@@-- These files are optional, if absent no error is raised
@@-- The following tags are available in this template:
@@--
@@-- @_Name_@ : The name of the function
@@-- @_Is_Type_@ : True if function type
@@-- @_Instance_Of_@ : Name of instance or empty string
@@-- @_Language_@ : Implementation language for the function
@@-- @_Filename_Is_Present_@ : True if target function output already exists
@@-- @_Makefile_Is_Present_@ : True if target build script already exists
@@-- @_C_Middleware_@ : True if middleware is in C (e.g. PO-HI-C)
@@IF@@ @_Language_@ = "GUI"
TRUE
@@END_IF@@
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