Commit 0a3e42db authored by jdelange's avatar jdelange
Browse files

* src/po_hi_main.c

   src/po_hi_monitor.c
   include/po_hi_monitor.h
   - Complete first shot of the monitoring function
     implementation, should be discussed now.



git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/po-hi-c@3473 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent 8c77bef8
......@@ -3,13 +3,13 @@
* middleware written for generated code from AADL models.
* You should use it with the Ocarina toolsuite.
*
* For more informations, please visit http://assert-project.net/tqste
* For more informations, please visit http://assert-project.net/taste
*
* Copyright (C) 2011, European Space Agency.
*/
/*
* \file po_hi_monitor.c
* \file po_hi_monitor.h
*
* \brief Contain the monitoring service functions.
*
......@@ -29,6 +29,20 @@
#include <deployment.h>
#include <po_hi_returns.h>
#ifndef __PO_HI_NB_BUSES
#define __PO_HI_NB_BUSES 0
#endif
#ifndef __PO_HI_NB_DEVICES
#define __PO_HI_NB_DEVICES 0
#endif
#undef __PO_HI_MONITOR_ENABLED
#if ( (__PO_HI_NB_DEVICES > 0) || (__PO_HI_NB_BUSES > 0))
#define __PO_HI_MONITOR_ENABLED 1
#endif
/*
* \enum __po_hi_monitor_status_t
*
......@@ -38,9 +52,9 @@
typedef enum
{
po_hi_monitor_status_ok = 0, /* Working */
po_hi_monitor_status_ko, = 1, /* Not working for unknown reason */
po_hi_monitor_status_ko = 1, /* Not working for unknown reason */
po_hi_monitor_status_unavailable = 2 /* No longer available, it used to work previously */
}__po_hi_monitor_status_t;
} __po_hi_monitor_status_t;
/*
......@@ -53,8 +67,8 @@ typedef enum
typedef enum
{
po_hi_monitor_failure_unknown = 0, /* Unknown failure: something failed but we don't know what */
po_hi_monitor_failure_value = 1, /* Bad value was sent or received */
}__po_hi_monitor_failure_t;
po_hi_monitor_failure_value = 1 /* Bad value was sent or received */
} __po_hi_monitor_failure_t;
/*
......@@ -131,7 +145,7 @@ int __po_hi_monitor_get_status_bus (const __po_hi_bus_id, __po_hi_monitor_status
* - __PO_HI_ERROR_INVALID - the value of the second argument is
* invalid.
*/
int __po_hi_monitor_report_failure_port (const __po_hi_port_t, __po_hi_monitor_failure_t);
int __po_hi_monitor_report_failure_port (const __po_hi_port_t, const __po_hi_monitor_failure_t);
/*
* \fn __po_hi_nonitor_report_failure_device
......@@ -156,12 +170,12 @@ int __po_hi_monitor_report_failure_port (const __po_hi_port_t, __po_hi_monitor_f
* - __PO_HI_ERROR_INVALID - the value of the second argument is
* invalid.
*/
int __po_hi_monitor_report_failure_device (const __po_hi_device_id, __po_hi_monitor_failure_t);
int __po_hi_monitor_report_failure_device (const __po_hi_device_id, const __po_hi_monitor_failure_t);
/*
* \fn __po_hi_nonitor_report_failure_bus
*
* \brief Indicate that the device pointed as first argument fails according to the failure pointed as second argument.
* \brief Indicate that the bus pointed as first argument fails according to the failure pointed as second argument.
*
* This function reports a failure on the bus indicated
* as first argument. The second argument is the kind
......@@ -182,7 +196,7 @@ int __po_hi_monitor_report_failure_device (const __po_hi_device_id, __po_hi_moni
* - __PO_HI_ERROR_INVALID - the value of the second argument is
* invalid.
*/
int __po_hi_monitor_report_failure_port (const __po_hi_port_t, const __po_hi_monitor_failure_t);
int __po_hi_monitor_report_failure_bus (const __po_hi_bus_id, const __po_hi_monitor_failure_t);
/*
......@@ -224,5 +238,14 @@ int __po_hi_monitor_recover_device (const __po_hi_device_id);
*/
int __po_hi_monitor_recover_port (const __po_hi_port_t);
/*
* \fn __po_hi_monitor_init
*
* \brief Initialise the monitoring subsystem.
*
* This function is called by the main initialisation function of
* PolyORB-HI-C, __po_hi_initialize_early in __po_hi_main.c file
*/
void __po_hi_monitor_init (void);
#endif
......@@ -15,6 +15,7 @@
#include <po_hi_config.h>
#include <po_hi_common.h>
#include <po_hi_returns.h>
#include <po_hi_monitor.h>
#include <po_hi_task.h>
#include <po_hi_debug.h>
#include <po_hi_protected.h>
......@@ -191,6 +192,10 @@ int __po_hi_initialize_early ()
__po_hi_protected_init();
#endif
#if __PO_HI_MONITOR_ENABLED == 1
__po_hi_monitor_init ();
#endif
return (__PO_HI_SUCCESS);
}
......
/*
* 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://assert-project.net/taste
*
* Copyright (C) 2011, European Space Agency.
*/
/*
* \file po_hi_monitor.c
*
* \brief Contain the implementation of the monitoring service.
*
* For a description of the types being used, you can see
* the file po_hi_monitor.h or also the deployment.h file
* generated from AADL models.
*/
#include <deployment.h>
#include <po_hi_debug.h>
#include <po_hi_monitor.h>
#include <po_hi_returns.h>
#if __PO_HI_MONITOR_ENABLED == 1
#ifndef __PO_HI_MONITOR_NB_FAILURES
#define __PO_HI_MONITOR_NB_FAILURES 10
#endif
__po_hi_monitor_status_t __po_hi_monitor_status_devices[__PO_HI_NB_DEVICES];
__po_hi_monitor_status_t __po_hi_monitor_status_buses[__PO_HI_NB_BUSES];
void __po_hi_monitor_init (void)
{
int i;
__PO_HI_DEBUG_DEBUG ("[MONITOR] Initialise the monitoring subsystem\n");
/*
* Initialise the monitoring subsystem, we assume that everything is
* working when initializing the system.
*/
for (i = 0 ; i < __PO_HI_NB_DEVICES ; i++)
{
__po_hi_monitor_status_devices[i] = po_hi_monitor_status_ok;
}
for (i = 0 ; i < __PO_HI_NB_BUSES ; i++)
{
__po_hi_monitor_status_buses[i] = po_hi_monitor_status_ok;
}
}
int __po_hi_monitor_get_status_port (const __po_hi_port_t port, __po_hi_monitor_status_t* status)
{
__PO_HI_DEBUG_DEBUG ("[MONITOR] call __po_hi_monitor_get_status_port with argument %d (port) and 0x%x (status pointer)\n", port, status);
return __PO_HI_SUCCESS;
}
int __po_hi_monitor_get_status_device (const __po_hi_device_id device,
__po_hi_monitor_status_t* status)
{
__PO_HI_DEBUG_DEBUG ("[MONITOR] call __po_hi_monitor_get_status_device with argument %d (device) and 0x%x (status pointer)\n", device, status);
if ((device < 0) || (device >= __PO_HI_NB_DEVICES))
{
__PO_HI_DEBUG_DEBUG ("[MONITOR] invalid device-id %d\n", device);
return __PO_HI_UNAVAILABLE;
}
*status = __po_hi_monitor_status_devices[device];
return __PO_HI_SUCCESS;
}
int __po_hi_monitor_get_status_bus (const __po_hi_bus_id bus,
__po_hi_monitor_status_t* status)
{
__PO_HI_DEBUG_DEBUG ("[MONITOR] call __po_hi_monitor_get_status_bus with argument %d (bus) and 0x%x (status pointer)\n", bus, status);
return __PO_HI_SUCCESS;
}
int __po_hi_monitor_report_failure_bus (const __po_hi_bus_id bus,
const __po_hi_monitor_failure_t failure)
{
__PO_HI_DEBUG_DEBUG ("[MONITOR] call __po_hi_monitor_report_failure_bus with argument %d (bus) and %d (failure)\n", bus, failure);
return __PO_HI_SUCCESS;
}
int __po_hi_monitor_report_failure_device (const __po_hi_device_id device,
const __po_hi_monitor_failure_t failure)
{
__PO_HI_DEBUG_DEBUG ("[MONITOR] call __po_hi_monitor_report_failure_device with argument %d (device) and %d (failure)\n", device, failure);
if ((device < 0) || (device >= __PO_HI_NB_DEVICES))
{
__PO_HI_DEBUG_DEBUG ("[MONITOR] invalid device-id %d\n", device);
return __PO_HI_UNAVAILABLE;
}
__po_hi_monitor_status_devices[device] = po_hi_monitor_status_ko;
return __PO_HI_SUCCESS;
}
int __po_hi_monitor_report_failure_port (const __po_hi_port_t port,
const __po_hi_monitor_failure_t failure)
{
__PO_HI_DEBUG_DEBUG ("[MONITOR] call __po_hi_monitor_report_failure_port with argument %d (port) and %d (failure)\n", port, failure);
return __PO_HI_SUCCESS;
}
int __po_hi_monitor_recover_bus (const __po_hi_bus_id bus)
{
__PO_HI_DEBUG_DEBUG ("[MONITOR] call __po_hi_monitor_recover_bus with argument %d\n", bus);
return __PO_HI_SUCCESS;
}
int __po_hi_monitor_recover_device (const __po_hi_device_id device)
{
__PO_HI_DEBUG_DEBUG ("[MONITOR] call __po_hi_monitor_recover_device with argument %d\n", device);
if ((device < 0) || (device >= __PO_HI_NB_DEVICES))
{
__PO_HI_DEBUG_DEBUG ("[MONITOR] invalid device-id %d\n", device);
return __PO_HI_UNAVAILABLE;
}
__po_hi_monitor_status_devices[device] = po_hi_monitor_status_ok;
return __PO_HI_SUCCESS;
}
int __po_hi_monitor_recover_port (const __po_hi_port_t port)
{
__PO_HI_DEBUG_DEBUG ("[MONITOR] call __po_hi_monitor_recover_port with argument %d\n", port);
return __PO_HI_SUCCESS;
}
#endif
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