summaryrefslogtreecommitdiff
path: root/maximus
diff options
context:
space:
mode:
authorburet2007-06-12 16:50:24 +0000
committerburet2007-06-12 16:50:24 +0000
commitca72c8b5d6276e9ec62d3889e189858ecbb0db2d (patch)
treeb659ad0000c7ba302d0ee1639f2edc3d90e144a2 /maximus
parentd8dfc330014646b3a0b14b326f067f149256a138 (diff)
Display SCI data
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@285 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'maximus')
-rw-r--r--maximus/common/interfaces/IPhy.h34
-rw-r--r--maximus/common/types/functioncall_types.h22
-rw-r--r--maximus/common/types/networkclock_types.h29
-rw-r--r--maximus/common/types/phy_types.h97
-rw-r--r--maximus/common/types/sci_types.h73
-rw-r--r--maximus/common/types/system_types.h37
-rw-r--r--maximus/coreengine/src/CoreEngine.cpp9
-rw-r--r--maximus/functioncall/inc/FunctionSciMsg.h124
-rw-r--r--maximus/functioncall/src/FunctionCallManager.cpp76
-rw-r--r--maximus/functioncall/src/FunctionCallManagerTest.cpp11
-rw-r--r--maximus/functioncall/src/FunctionSciMsg.cpp643
-rw-r--r--maximus/networkclock/inc/ClockSciMsg.h50
-rw-r--r--maximus/networkclock/inc/NetworkClockEvt.h12
-rw-r--r--maximus/networkclock/src/ClockSciMsg.cpp212
-rw-r--r--maximus/networkclock/src/NetworkClockEvt.cpp10
-rw-r--r--maximus/networkclock/src/NetworkClockProcessor.cpp49
-rw-r--r--maximus/networkclock/src/NetworkClockProcessorTest.cpp10
-rw-r--r--maximus/phy/inc/PhyProcessor.h35
-rw-r--r--maximus/phy/inc/PhySciMsg.h55
-rw-r--r--maximus/phy/src/PhyProcessor.cpp45
-rw-r--r--maximus/phy/src/PhySciMsg.cpp118
-rw-r--r--maximus/sci/inc/SciMsg.h135
-rw-r--r--maximus/sci/src/SciMsg.cpp386
-rw-r--r--maximus/sci/src/SciServer.cpp15
-rw-r--r--maximus/system/inc/Station.h2
-rw-r--r--maximus/system/inc/SystemManager.h2
-rw-r--r--maximus/system/inc/SystemSciMsg.h24
-rw-r--r--maximus/system/src/Station.cpp4
-rw-r--r--maximus/system/src/SystemManager.cpp2
-rw-r--r--maximus/system/src/SystemSciMsg.cpp81
30 files changed, 1353 insertions, 1049 deletions
diff --git a/maximus/common/interfaces/IPhy.h b/maximus/common/interfaces/IPhy.h
index e89f9becc3..7e9eb64cad 100644
--- a/maximus/common/interfaces/IPhy.h
+++ b/maximus/common/interfaces/IPhy.h
@@ -33,8 +33,8 @@ The original location of this file is /home/buret/eclipse/maximus/common/interfa
#include <string>
-#include "Station.h"
#include "phy_types.h"
+#include "sci_types.h"
/**
@@ -64,45 +64,45 @@ public:
/**
* @return bool
- * @param station1
- * @param station2
+ * @param station1_id
+ * @param station2_id
* @param link_quality
*/
- virtual bool checkLinkQuality ( const Station * station1, const Station * station2, Phy_Link_Quality & link_quality ) const = 0;
+ virtual bool checkLinkQuality ( const Sci_Msg_Station_Id station1_id, const Sci_Msg_Station_Id station2_id, Phy_Link_Quality & link_quality ) const = 0;
/**
* @return bool
- * @param station1
- * @param station2
+ * @param station1_id
+ * @param station2_id
* @param link_quality
*/
- virtual bool manageLinkQuality ( const Station * station1, const Station * station2, const Phy_Link_Quality link_quality ) = 0;
+ virtual bool manageLinkQuality ( const Sci_Msg_Station_Id station1_id, const Sci_Msg_Station_Id station2_id, const Phy_Link_Quality link_quality ) = 0;
/**
* @return bool
- * @param destination_station
+ * @param destination_station_id
* @param data_length
- * @param data
+ * @param p_data
*/
- virtual bool sendEthernetData ( const Station * destination_station, const short int data_length, const unsigned char * data ) const = 0;
+ virtual bool sendEthernetData ( const Sci_Msg_Station_Id destination_station_id, const unsigned long data_length, const unsigned char * p_data ) const = 0;
/**
* @return bool
- * @param destination_station
+ * @param destination_station_id
* @param mpdu_format
* @param fc_10
* @param fc_av
* @param nb_of_pbs
* @param pb_size
- * @param mpdu_payload
+ * @param p_mpdu_payload
*/
- virtual bool sendAvData ( const Station * destination_station,
- const char mpdu_format,
+ virtual bool sendAvData ( const Sci_Msg_Station_Id destination_station_id,
+ const Phy_Mpdu_Format mpdu_format,
const unsigned long fc_10,
const unsigned long fc_av[4],
- const unsigned char nb_of_pbs,
- const char pb_size,
- const unsigned char * mpdu_payload ) const = 0;
+ const Phy_Pbs_Number nb_of_pbs,
+ const Phy_Pb_Size pb_size,
+ const unsigned char * p_mpdu_payload ) const = 0;
};
diff --git a/maximus/common/types/functioncall_types.h b/maximus/common/types/functioncall_types.h
index e8cd91de39..8776249557 100644
--- a/maximus/common/types/functioncall_types.h
+++ b/maximus/common/types/functioncall_types.h
@@ -17,6 +17,16 @@ struct Function_Call_Parameter
unsigned char * p_value;
};
+struct Function_Call_Header
+{
+ uint8_t version;
+ uint8_t type;
+ uint8_t param_nb;
+ uint8_t flags;
+} __attribute__ ((__packed__));
+
+// Function_Call_Header.type
+//
enum Function_Call_Type
{
FUNCTION_CALL_TYPE_NONE = 0x00,
@@ -25,14 +35,8 @@ enum Function_Call_Type
FUNCTION_CALL_TYPE_NB
};
-typedef uint8_t Function_Call_Parameters_Number;
-
-struct Function_Call_Header
-{
- uint8_t version;
- uint8_t type;
- uint8_t param_nb;
- uint8_t flags;
-} __attribute__ ((__packed__));
+// Function_Call_Header.param_nb
+//
+typedef unsigned int Function_Call_Parameters_Number;
#endif /*FUNCTIONCALL_TYPES_H_*/
diff --git a/maximus/common/types/networkclock_types.h b/maximus/common/types/networkclock_types.h
index 925d4dd2b7..363e6f6ffe 100644
--- a/maximus/common/types/networkclock_types.h
+++ b/maximus/common/types/networkclock_types.h
@@ -7,6 +7,19 @@
#define NETWORK_CLOCK_VERSION 0x01
#define NETWORK_CLOCK_ID_MASK 0xffff
+struct Network_Clock_Header
+{
+ uint8_t version;
+ uint8_t type;
+ uint16_t id;
+ uint16_t flags;
+ uint16_t reserved;
+ uint32_t tick_high;
+ uint32_t tick_low;
+} __attribute__ ((__packed__));
+
+// Network_Clock_Header.type
+//
enum Network_Clock_Type
{
NETWORK_CLOCK_TYPE_NONE = 0x00,
@@ -18,19 +31,13 @@ enum Network_Clock_Type
NETWORK_CLOCK_TYPE_NB
};
+// Network_Clock_Header.id
+//
typedef uint16_t Network_Clock_Id;
+// Network_Clock_Header.tick_high
+// Network_Clock_Header.tick_low
+//
typedef double Network_Clock_Tick;
-struct Network_Clock_Header
-{
- uint8_t version;
- uint8_t type;
- uint16_t id;
- uint16_t flags;
- uint16_t reserved;
- uint32_t tick_high;
- uint32_t tick_low;
-} __attribute__ ((__packed__));
-
#endif /*NETWORKCLOCK_TYPES_H_*/
diff --git a/maximus/common/types/phy_types.h b/maximus/common/types/phy_types.h
index ecf7b01c42..6a224ef188 100644
--- a/maximus/common/types/phy_types.h
+++ b/maximus/common/types/phy_types.h
@@ -9,59 +9,80 @@
enum Phy_Link_Quality
{
MAXIMUS_PHY_LINK_QUALITY_OK = 0,
- MAXIMUS_PHY_LINK_QUALITY_DAMAGED,
- MAXIMUS_PHY_LINK_QUALITY_NO_TRANSMISSION,
+ MAXIMUS_PHY_LINK_QUALITY_DAMAGED = 1,
+ MAXIMUS_PHY_LINK_QUALITY_NO_TRANSMISSION = 2,
MAXIMUS_PHY_LINK_QUALITY_NB
};
-enum Phy_Sci_Msg_Mpdu_Format
+struct Phy_Header
+{
+ uint8_t version;
+ uint8_t type;
+ uint16_t nek;
+ uint8_t mpdu_format;
+ uint8_t data_type;
+ uint16_t nb_of_pbs;
+ uint8_t pb_size;
+ uint16_t reserved;
+ uint16_t flags;
+} __attribute__ ((__packed__));
+
+// Phy_Header.type
+//
+enum Phy_Type
{
- MAXIMUS_PHY_SCI_MSG_MPDU_FORMAT_NONE = 0x00,
- MAXIMUS_PHY_SCI_MSG_MPDU_FORMAT_AV_ONLY_LONG = 0x01,
- MAXIMUS_PHY_SCI_MSG_MPDU_FORMAT_HYBRID_LONG = 0x02,
- MAXIMUS_PHY_SCI_MSG_MPDU_FORMAT_AV_ONLY_SHORT = 0x03,
- MAXIMUS_PHY_SCI_MSG_MPDU_FORMAT_HYBRID_SHORT = 0x04,
- MAXIMUS_PHY_SCI_MSG_MPDU_FORMAT_NB
+ PHY_TYPE_NONE = 0x00,
+ PHY_TYPE_AV_DATA = 0x01,
+ PHY_TYPE_NB
};
-enum Phy_Sci_Msg_Data_Type
+// Phy_Header.mpdu_format
+//
+enum Phy_Mpdu_Format
{
- MAXIMUS_PHY_SCI_MSG_DATA_TYPE_NONE = 0x00,
- MAXIMUS_PHY_SCI_MSG_DATA_TYPE_HP10_FC = 0x01,
- MAXIMUS_PHY_SCI_MSG_DATA_TYPE_AV_FC = 0x02,
- MAXIMUS_PHY_SCI_MSG_DATA_TYPE_PB = 0x03,
- MAXIMUS_PHY_SCI_MSG_DATA_TYPE_TONE_MAP = 0x04,
- MAXIMUS_PHY_SCI_MSG_DATA_TYPE_CHANDATA = 0x05,
- MAXIMUS_PHY_SCI_MSG_DATA_TYPE_NB
+ MAXIMUS_PHY_MPDU_FORMAT_NONE = 0x00,
+ MAXIMUS_PHY_MPDU_FORMAT_AV_ONLY_LONG = 0x01,
+ MAXIMUS_PHY_MPDU_FORMAT_HYBRID_LONG = 0x02,
+ MAXIMUS_PHY_MPDU_FORMAT_AV_ONLY_SHORT = 0x03,
+ MAXIMUS_PHY_MPDU_FORMAT_HYBRID_SHORT = 0x04,
+ MAXIMUS_PHY_MPDU_FORMAT_NB
};
-enum Phy_Sci_Msg_Pb_Size
+// Phy_Header.data_type
+//
+enum Phy_Data_Type
{
- MAXIMUS_PHY_SCI_MSG_PB_SIZE_NONE = 0x00,
- MAXIMUS_PHY_SCI_MSG_PB_SIZE_520_OCTETS = 0x01,
- MAXIMUS_PHY_SCI_MSG_PB_SIZE_136_OCTETS = 0x02,
- MAXIMUS_PHY_SCI_MSG_PB_SIZE_NB
+ MAXIMUS_PHY_DATA_TYPE_NONE = 0x00,
+ MAXIMUS_PHY_DATA_TYPE_HP10_FC = 0x01,
+ MAXIMUS_PHY_DATA_TYPE_AV_FC = 0x02,
+ MAXIMUS_PHY_DATA_TYPE_PB = 0x03,
+ MAXIMUS_PHY_DATA_TYPE_TONE_MAP = 0x04,
+ MAXIMUS_PHY_DATA_TYPE_CHANDATA = 0x05,
+ MAXIMUS_PHY_DATA_TYPE_NB
};
-enum Phy_Type
+// Phy_Header.nb_of_pbs
+//
+typedef unsigned int Phy_Pbs_Number;
+
+// Phy_Header.pb_size
+//
+enum Phy_Pb_Size
{
- PHY_TYPE_NONE = 0x00,
- PHY_TYPE_AV_DATA = 0x01,
- PHY_TYPE_NB
+ MAXIMUS_PHY_PB_SIZE_NONE = 0x00,
+ MAXIMUS_PHY_PB_SIZE_520_OCTETS = 0x01,
+ MAXIMUS_PHY_PB_SIZE_136_OCTETS = 0x02,
+ MAXIMUS_PHY_PB_SIZE_NB
};
-struct Phy_Header
+// Phy_Header.flags
+//
+enum Phy_Flag
{
- uint8_t version;
- uint8_t type;
- uint16_t nek;
- uint8_t mpdu_format;
- uint8_t data_type;
- uint16_t nb_of_pbs;
- uint8_t pb_size;
- uint16_t reserved;
- uint16_t flags; // SCI_MSG_PREAMBLE_PRESENT
- // SCI_MSG_CRC_STATUS
-} __attribute__ ((__packed__));
+ MAXIMUS_PHY_FLAG_NONE = 0x00,
+ MAXIMUS_PHY_PREAMBLE_PRESENT = 0x01,
+ MAXIMUS_PHY_CRC_STATUS = 0x02,
+ MAXIMUS_PHY_FLAG_NB
+};
#endif /*PHY_TYPES_H_*/
diff --git a/maximus/common/types/sci_types.h b/maximus/common/types/sci_types.h
index 45152d3b75..171946e675 100644
--- a/maximus/common/types/sci_types.h
+++ b/maximus/common/types/sci_types.h
@@ -10,37 +10,31 @@
#define SCI_MSG_ID_MASK 0xffff
#define SCI_MSG_MAX_SIZE 4096
-typedef uint16_t Sci_Station_Id;
-
-enum Sci_Msg_Type
+// Used by SciServer
+//
+enum Sci_Server_Status
{
- SCI_MSG_TYPE_NONE = 0x00,
- SCI_MSG_TYPE_NETWORK_CLOCK = 0x01,
- SCI_MSG_TYPE_FUNCTION_CALL = 0x02,
- SCI_MSG_TYPE_PHY = 0x03,
- SCI_MSG_TYPE_SYSTEM = 0x04,
- SCI_MSG_TYPE_NB = 0x05
+ MAXIMUS_SCI_SERVER_STATUS_NONE = 0,
+ MAXIMUS_SCI_SERVER_STATUS_RUNNING = 1,
+ MAXIMUS_SCI_SERVER_STATUS_STOP = 2,
+ MAXIMUS_SCI_SERVER_STATUS_STOPPED = 3,
+ MAXIMUS_SCI_SERVER_STATUS_NB
};
+// Used by SciMsg
+//
enum Sci_Msg_Status
{
- MAXIMUS_SCI_MSG_STATUS_NONE = 0x00,
- MAXIMUS_SCI_MSG_STATUS_TO_SEND = 0x01,
- MAXIMUS_SCI_MSG_STATUS_SENT = 0x02,
- MAXIMUS_SCI_MSG_STATUS_RECEIVED = 0x03,
- MAXIMUS_SCI_MSG_STATUS_PROCESSED = 0x04,
- MAXIMUS_SCI_MSG_STATUS_NB = 0x05
+ MAXIMUS_SCI_MSG_STATUS_NONE = 0,
+ MAXIMUS_SCI_MSG_STATUS_TO_SEND = 1,
+ MAXIMUS_SCI_MSG_STATUS_SENT = 2,
+ MAXIMUS_SCI_MSG_STATUS_RECEIVED = 3,
+ MAXIMUS_SCI_MSG_STATUS_PROCESSED = 4,
+ MAXIMUS_SCI_MSG_STATUS_NB
};
-
-enum Sci_Msg_Flag
-{
- SCI_MSG_FLAG_RESP = 0x00, // if set, message is a response to a request; else, it is a request
- SCI_MSG_FLAG_ACK = 0x01, // if set, message is an acknowledge to a request or a response
- SCI_MSG_FLAG_NEEDACK = 0x02, // set an ack is requested from remote receiver
- SCI_MSG_FLAG_SYNC = 0x03, // if set, a synchronous response is required
- SCI_MSG_FLAG_NB = 0x04
-};
+// Common SCI message structure between station and maximus
+//
struct Sci_Msg_Header
{
uint32_t magic_id; /* 1st field is magic id (32 bits): always “MAXI” */
@@ -57,13 +51,32 @@ struct Sci_Msg_Header
uint16_t reserved; /* 10th field is reserved (16 bits) */
} __attribute__ ((__packed__));
-enum Sci_Server_Status
+// Sci_Msg_Header.type
+//
+enum Sci_Msg_Type
{
- MAXIMUS_SCI_SERVER_STATUS_NONE = 0x00,
- MAXIMUS_SCI_SERVER_STATUS_RUNNING = 0x01,
- MAXIMUS_SCI_SERVER_STATUS_STOP = 0x02,
- MAXIMUS_SCI_SERVER_STATUS_STOPPED = 0x03,
- MAXIMUS_SCI_SERVER_STATUS_NB = 0x04
+ SCI_MSG_TYPE_NONE = 0x00,
+ SCI_MSG_TYPE_NETWORK_CLOCK = 0x01,
+ SCI_MSG_TYPE_FUNCTION_CALL = 0x02,
+ SCI_MSG_TYPE_PHY = 0x03,
+ SCI_MSG_TYPE_SYSTEM = 0x04,
+ SCI_MSG_TYPE_NB
};
+// Sci_Msg_Header.station_id
+//
+typedef uint16_t Sci_Msg_Station_Id;
+
+
+// Sci_Msg_Header.flags
+//
+enum Sci_Msg_Flag
+{
+ SCI_MSG_FLAG_RESP = 0x00, // if set, message is a response to a request; else, it is a request
+ SCI_MSG_FLAG_ACK = 0x01, // if set, message is an acknowledge to a request or a response
+ SCI_MSG_FLAG_NEEDACK = 0x02, // set an ack is requested from remote receiver
+ SCI_MSG_FLAG_SYNC = 0x03, // if set, a synchronous response is required
+ SCI_MSG_FLAG_NB = 0x04
+};
+
#endif /*SCI_TYPES_H_*/
diff --git a/maximus/common/types/system_types.h b/maximus/common/types/system_types.h
index 9a5b09cd87..c848437a67 100644
--- a/maximus/common/types/system_types.h
+++ b/maximus/common/types/system_types.h
@@ -9,42 +9,40 @@
enum Cco_Capability
{
MAXIMUS_NOT_CCO_CAPABLE = 0,
- MAXIMUS_CCO_CAPABLE_WITHOUT_QOS_SUPPORT,
- MAXIMUS_PREFERRED_CCO_CAPABILITY,
- MAXIMUS_NEXT_GENERATION_CCO_CAPABILITY
+ MAXIMUS_CCO_CAPABLE_WITHOUT_QOS_SUPPORT = 1,
+ MAXIMUS_PREFERRED_CCO_CAPABILITY = 2,
+ MAXIMUS_NEXT_GENERATION_CCO_CAPABILITY = 3,
+ MAXIMUS_CCO_CAPABILITY_NB
};
enum Bridge_Capability
{
MAXIMUS_NOT_BRIDGE_CAPABLE = 0,
- MAXIMUS_BRIDGE_CAPABLE
+ MAXIMUS_BRIDGE_CAPABLE = 1,
+ MAXIMUS_BRIDGE_CAPABILITY_NB
};
enum Homeplug_Version
{
MAXIMUS_HOMEPLUG_AV = 0,
- MAXIMUS_HOMEPLUG_101
+ MAXIMUS_HOMEPLUG_101 = 1,
+ MAXIMUS_HOMEPLUG_VERSION_NB
};
enum Station_Status
{
MAXIMUS_STATION_STATUS_NONE = 0,
- MAXIMUS_STATION_STATUS_IDLE,
- MAXIMUS_STATION_STATUS_BUSY,
- MAXIMUS_STATION_STATUS_DEACTIVATED
+ MAXIMUS_STATION_STATUS_IDLE = 1,
+ MAXIMUS_STATION_STATUS_BUSY = 2,
+ MAXIMUS_STATION_STATUS_DEACTIVATED = 3,
+ MAXIMUS_STATION_STATUS_NB
};
typedef unsigned long Device_Access_Key;
typedef int File_Descriptor;
-typedef int Error_Id;
-enum System_Type
-{
- SYSTEM_TYPE_NONE = 0x00,
- SYSTEM_TYPE_IDLE = 0x01,
- SYSTEM_TYPE_NB
-};
+typedef int Error_Id;
struct System_Header
{
@@ -53,4 +51,13 @@ struct System_Header
uint16_t flags;
} __attribute__ ((__packed__));
+// System_Header.type
+//
+enum System_Type
+{
+ SYSTEM_TYPE_NONE = 0x00,
+ SYSTEM_TYPE_IDLE = 0x01,
+ SYSTEM_TYPE_NB
+};
+
#endif /*SYSTEM_TYPES_H_*/
diff --git a/maximus/coreengine/src/CoreEngine.cpp b/maximus/coreengine/src/CoreEngine.cpp
index 7c6cad4f27..6a8d75d75c 100644
--- a/maximus/coreengine/src/CoreEngine.cpp
+++ b/maximus/coreengine/src/CoreEngine.cpp
@@ -77,15 +77,6 @@ void CoreEngine::initAttributes ( )
mpNetworkClockProcessor = new NetworkClockProcessor(mpSciServer, mpSystemManager, mpFunctionCallManager, mpPhyProcessor);
}
}
-
- if ( (NULL == mpSciServer)
- || (NULL == mpFunctionCallManager)
- || (NULL == mpSystemManager)
- || (NULL == mpPhyProcessor)
- || (NULL == mpNetworkClockProcessor) )
- {
- throw Error("CoreEngine::initAttributes", "At least one of the initialized pointers is NULL");
- }
}
diff --git a/maximus/functioncall/inc/FunctionSciMsg.h b/maximus/functioncall/inc/FunctionSciMsg.h
index 5755b99709..a33f82349c 100644
--- a/maximus/functioncall/inc/FunctionSciMsg.h
+++ b/maximus/functioncall/inc/FunctionSciMsg.h
@@ -41,6 +41,7 @@ class FunctionCallManager;
typedef std::vector<Function_Call_Parameter *> ParametersList;
+
/**
* class FunctionSciMsg
*/
@@ -58,14 +59,24 @@ private:
// private attributes
//
-
- Sci_Station_Id mStationId;
+ // Get from specialized SCI message header
+ //
Function_Call_Type mSpecializedSciMsgType;
Function_Call_Parameters_Number mSpecializedSciMsgParametersNumber;
- char * mpFunctionName; // unique string identifier for function call
- FunctionCallManager * mpFunctionCallManager;
- ParametersList * mpListOfParameters;
+
+ // Specialized SCI msg header
+ //
Function_Call_Header * mpSpecializedSciMsgHeader;
+
+ // Unique string identifier for function call
+ //
+ char * mpFunctionName;
+
+ // Function parameters
+ //
+ ParametersList * mpListOfParameters;
+
+ FunctionCallManager * mpFunctionCallManager;
protected:
@@ -113,8 +124,6 @@ public:
/**
* @return bool
- * @param data_length
- * @param p_data
*/
bool identifySpecializedSciMsgHeader ( );
@@ -134,108 +143,101 @@ public:
/**
* @return bool
*/
- bool fillSpecializedSciMsgToSend ( );
+ bool identifyCallbackName ( );
/**
* @return bool
*/
- bool identifyCallbackName ( );
-
+ bool identifyCallbackParameters ( );
+
/**
* @return bool
*/
- bool identifyCallbackParameters ( );
+ bool fillSpecializedSciMsgToSend ( );
+
+ void displaySpecializedSciMsgHeader ( ) const;
// public attribute accessor methods
//
// private attribute accessor methods
//
-
+
/**
- * @return Sci_Station_Id
+ * Get the value of mSpecializedSciMsgType
+ * @return the value of mSpecializedSciMsgType
*/
- Sci_Station_Id getStationId ( ) const;
-
+ Function_Call_Type getSpecializedSciMsgType ( ) const;
+
/**
+ * Set the value of mSpecializedSciMsgType
* @return bool
- * @param station_id
+ * @param type the new value of mSpecializedSciMsgType
*/
- bool setStationId ( const Sci_Station_Id station_id );
-
+ bool setSpecializedSciMsgType ( const Function_Call_Type type );
+
/**
- * @return FunctionCallManager *
+ * Get the value of mSpecializedSciMsgParametersNumber
+ * @return the value of mSpecializedSciMsgParametersNumber
*/
- FunctionCallManager * getFunctionCallManager ( ) const;
-
+ Function_Call_Parameters_Number getSpecializedSciMsgParametersNumber ( ) const;
+
/**
+ * Set the value of mSpecializedSciMsgParametersNumber
* @return bool
- * @param p_function_call_manager
+ * @param number_of_parameters the new value of mSpecializedSciMsgParametersNumber
*/
- bool setFunctionCallManager ( FunctionCallManager * p_function_call_manager );
-
+ bool setSpecializedSciMsgParametersNumber ( const Function_Call_Parameters_Number number_of_parameters );
+
/**
- * @return Function_Call_Header *
+ * @return mpSpecializedSciMsgHeader
*/
Function_Call_Header * getSpecializedSciMsgHeader ( ) const;
/**
* @return bool
- * @param p_specialized_sci_msg_header
+ * @param p_specialized_sci_msg_header the new value of mpSpecializedSciMsgHeader
*/
bool setSpecializedSciMsgHeader ( const Function_Call_Header * p_specialized_sci_msg_header );
/**
- * Set the value of mpFunctionName
- * @return bool
- * @param name the new value of mpFunctionName
- */
- bool setFunctionName ( const char * name );
-
- /**
* Get the value of mpFunctionName
* @return the value of mpFunctionName
*/
char * getFunctionName ( ) const;
-
+
/**
- * Set the value of mpListOfParameters
+ * Set the value of mpFunctionName
* @return bool
- * @param list_of_parameters the new value of mpListOfParameters
+ * @param name the new value of mpFunctionName
*/
- bool setListOfParameters ( ParametersList * list_of_parameters );
+ bool setFunctionName ( const char * name );
/**
- * Get the value of mListOfParameters
- * @return the value of mListOfParameters
+ * Get the value of mpListOfParameters
+ * @return the value of mpListOfParameters
*/
ParametersList * getListOfParameters ( ) const;
-
+
/**
- * Set the value of mSpecializedSciMsgType and mpSpecializedSciMsgHeader->type
+ * Set the value of mpListOfParameters
* @return bool
- * @param type the new value of mSpecializedSciMsgType and mpSpecializedSciMsgHeader->type
+ * @param p_list_of_parameters the new value of mpListOfParameters
*/
- bool setSpecializedSciMsgType ( const Function_Call_Type type );
-
+ bool setListOfParameters ( ParametersList * p_list_of_parameters );
+
/**
- * Get the value of mSpecializedSciMsgType
- * @return the value of mSpecializedSciMsgType
+ * Get the value of mpFunctionCallManager
+ * @return mpFunctionCallManager
*/
- Function_Call_Type getSpecializedSciMsgType ( ) const;
+ FunctionCallManager * getFunctionCallManager () const;
/**
- * Set the value of mSpecializedSciMsgParametersNumber
+ * Set the value of mpFunctionCallManager
* @return bool
- * @param number_of_parameters the new value of mSpecializedSciMsgParametersNumber
- */
- bool setSpecializedSciMsgParametersNumber ( const Function_Call_Parameters_Number number_of_parameters );
-
- /**
- * Get the value of mSpecializedSciMsgParametersNumber
- * @return the value of mSpecializedSciMsgParametersNumber
+ * @param p_function_call_manager the new value of mpFunctionCallManager
*/
- Function_Call_Parameters_Number getSpecializedSciMsgParametersNumber ( ) const;
+ bool setFunctionCallManager ( FunctionCallManager * p_function_call_manager );
// protected attribute accessor methods
//
@@ -246,13 +248,11 @@ private:
//
void initAttributes ( );
-
- void displayListOfParameters ( ) const;
-
+
void displayParameter ( unsigned int parameter_iterator ) const;
-
- void displaySpecializedSciMsgHeader ( ) const;
-
+
+ void displayListOfParameters ( ) const;
+
void deleteParameters ( );
protected:
diff --git a/maximus/functioncall/src/FunctionCallManager.cpp b/maximus/functioncall/src/FunctionCallManager.cpp
index 2355f3aa1f..dbd1941dba 100644
--- a/maximus/functioncall/src/FunctionCallManager.cpp
+++ b/maximus/functioncall/src/FunctionCallManager.cpp
@@ -76,10 +76,6 @@ void FunctionCallManager::initAttributes ( )
clog << "FunctionCallManager::initAttributes" << endl;
mpListOfCallbacks = new Map ();
- if (NULL == mpListOfCallbacks)
- {
- throw Error("FunctionCallManager::initAttributes", "Initialized Map pointer is NULL");
- }
}
@@ -163,35 +159,61 @@ bool FunctionCallManager::sendMsg ( FunctionSciMsg * function_sci_msg_to_send )
if (NULL != function_sci_msg_to_send)
{
+ // Fill specialized SCI msg attributes
+ // Fill specialized SCI msg data length and specialized SCI msg data
+ //
bSend = function_sci_msg_to_send->fillSpecializedSciMsgToSend();
+ // Fill specialized SCI msg header
+ //
+ struct Function_Call_Header functionSciMsgHeader = { FUNCTION_CALL_VERSION,
+ static_cast<uint8_t>(function_sci_msg_to_send->getSpecializedSciMsgType()),
+ static_cast<uint8_t>(function_sci_msg_to_send->getSpecializedSciMsgParametersNumber()),
+ 0x00 }; // flags
+ bSend &= function_sci_msg_to_send->setSpecializedSciMsgHeader(&functionSciMsgHeader);
+
+ // Fill SCI msg data length and SCI msg data
+ //
+ bSend &= function_sci_msg_to_send->setSciMsgDataLength(static_cast<unsigned long>(sizeof(struct Function_Call_Header)) + function_sci_msg_to_send->getSpecializedSciMsgDataLength());
+ unsigned char * pTempData = new unsigned char [function_sci_msg_to_send->getSciMsgDataLength()];
+ if (NULL != pTempData)
+ {
+ *(pTempData) = static_cast<unsigned char>(function_sci_msg_to_send->getSpecializedSciMsgHeader()->version);
+ *(pTempData+1) = static_cast<unsigned char>(function_sci_msg_to_send->getSpecializedSciMsgHeader()->type);
+ *(pTempData+2) = static_cast<unsigned char>(function_sci_msg_to_send->getSpecializedSciMsgHeader()->param_nb);
+ *(pTempData+3) = static_cast<unsigned char>(function_sci_msg_to_send->getSpecializedSciMsgHeader()->flags);
+ for (unsigned int j=0; j<(function_sci_msg_to_send->getSciMsgDataLength()-sizeof(struct Function_Call_Header)); j++)
+ {
+ *(pTempData+j+sizeof(struct Function_Call_Header)) = *(function_sci_msg_to_send->getSpecializedSciMsgData()+j);
+ }
+ }
+ bSend &= function_sci_msg_to_send->setSciMsgData(pTempData);
+
+ // Fill SCI msg header
+ //
uint32_t netclockHigh=0, netclockLow=0;
netclockLow = (uint32_t)(getNetworkClockTick());
netclockHigh = (uint32_t)(((uint64_t)(getNetworkClockTick()) >> 32));
- clog << "\tMSB = 0x" << hex << setfill('0') << setw(8) << uppercase << netclockHigh << " and LSB = 0x" << setfill('0') << setw(8) << uppercase << netclockLow << dec << endl;
-
- struct Function_Call_Header functionSciMsgHeader = { FUNCTION_CALL_VERSION,
- FUNCTION_CALL_TYPE_REQ,
- function_sci_msg_to_send->getSpecializedSciMsgParametersNumber(),
- 0 }; // flags
- bSend &= function_sci_msg_to_send->setSpecializedSciMsgHeader(&functionSciMsgHeader);
-
- bSend &= function_sci_msg_to_send->setSciMsgDataLength(sizeof(struct Function_Call_Header) + function_sci_msg_to_send->getSpecializedSciMsgDataLength());
- //bSend &= function_sci_msg_to_send->setSciMsgData();
struct Sci_Msg_Header sciMsgHeader = { (uint32_t)SCI_MSG_MAGIC,
SCI_MSG_VERSION,
- SCI_MSG_TYPE_FUNCTION_CALL,
- (uint16_t)function_sci_msg_to_send->getSciMsgDataLength(),
- function_sci_msg_to_send->getStationId(),
- 0, // msg_id
+ static_cast<uint8_t>(SCI_MSG_TYPE_FUNCTION_CALL),
+ static_cast<uint16_t>(function_sci_msg_to_send->getSciMsgDataLength()),
+ function_sci_msg_to_send->getSciMsgStationId(),
+ 0x0000, // msg_id
netclockHigh,
netclockLow,
- 0, // flags
- 0 }; // reserved
+ 0x0000, // flags
+ 0x0000 }; // reserved
bSend &= function_sci_msg_to_send->setSciMsgHeader(&sciMsgHeader);
-
- clog << "\tsends event to station" << endl;
+ // Free temporary allocated memory
+ //
+ if (NULL != pTempData)
+ {
+ delete [] pTempData;
+ pTempData = NULL;
+ }
+
if (bSend)
{
if (NULL != mpSciServer)
@@ -200,7 +222,7 @@ bool FunctionCallManager::sendMsg ( FunctionSciMsg * function_sci_msg_to_send )
}
else
{
- throw Error("FunctionCallManager::sendMsg", "SciServer pointer is NULL");
+ throw Error("FunctionCallManager::sendMsg", "SCI server pointer is NULL");
}
}
else
@@ -210,7 +232,7 @@ bool FunctionCallManager::sendMsg ( FunctionSciMsg * function_sci_msg_to_send )
}
else
{
- throw Error("FunctionCallManager::sendMsg", "Received FunctionSciMsg pointer is NULL");
+ throw Error("FunctionCallManager::sendMsg", "Received function SCI msg pointer is NULL");
}
return bSend;
@@ -224,14 +246,10 @@ bool FunctionCallManager::receiveMsg ( FunctionSciMsg & function_sci_msg )
clog << "FunctionCallManager::receiveMsg" << endl;
bool bReceive = false;
- bReceive = function_sci_msg.identifyCallbackName();
- bReceive &= function_sci_msg.identifyCallbackParameters();
-
displayListOfCallbacks();
- if ( (!mpListOfCallbacks->empty()) && (0 != bReceive) )
+ if ( !mpListOfCallbacks->empty() )
{
- bReceive = false;
for (Map::const_iterator it = mpListOfCallbacks->begin(); it != mpListOfCallbacks->end(); ++it)
{
if (!strcmp(it->first, function_sci_msg.getFunctionName()))
diff --git a/maximus/functioncall/src/FunctionCallManagerTest.cpp b/maximus/functioncall/src/FunctionCallManagerTest.cpp
index ce5c4111c0..ac1081d619 100644
--- a/maximus/functioncall/src/FunctionCallManagerTest.cpp
+++ b/maximus/functioncall/src/FunctionCallManagerTest.cpp
@@ -101,8 +101,15 @@ void FunctionCallManagerTest::receiveMsgTest (void)
functionSciMsg.setFunctionName ("userFunction1") );
clog << "\tFunctionCallManagerTest -> FunctionCallManager::receiveMsg" << endl;
- CPPUNIT_ASSERT_MESSAGE ( CPPUNIT_NS::Message("receiveMsg failed"),
- mpFunctionCallManager->receiveMsg (functionSciMsg) );
+ try
+ {
+ CPPUNIT_ASSERT_MESSAGE ( CPPUNIT_NS::Message("receiveMsg failed"),
+ !mpFunctionCallManager->receiveMsg (functionSciMsg) );
+ }
+ catch (Error &e)
+ {
+ e.display();
+ }
}
clog << "-------------------------------------------------------------------------------------" << endl;
diff --git a/maximus/functioncall/src/FunctionSciMsg.cpp b/maximus/functioncall/src/FunctionSciMsg.cpp
index cb3c513f07..c4616366f1 100644
--- a/maximus/functioncall/src/FunctionSciMsg.cpp
+++ b/maximus/functioncall/src/FunctionSciMsg.cpp
@@ -49,10 +49,10 @@ using namespace std;
FunctionSciMsg::FunctionSciMsg ( ):
mSpecializedSciMsgType(FUNCTION_CALL_TYPE_NONE),
mSpecializedSciMsgParametersNumber(0),
+mpSpecializedSciMsgHeader(NULL),
mpFunctionName(NULL),
-mpFunctionCallManager(NULL),
mpListOfParameters(NULL),
-mpSpecializedSciMsgHeader(NULL)
+mpFunctionCallManager(NULL)
{
clog << "FunctionSciMsg()" << endl;
@@ -63,10 +63,10 @@ mpSpecializedSciMsgHeader(NULL)
FunctionSciMsg::FunctionSciMsg ( FunctionCallManager * p_function_call_manager ):
mSpecializedSciMsgType(FUNCTION_CALL_TYPE_NONE),
mSpecializedSciMsgParametersNumber(0),
+mpSpecializedSciMsgHeader(NULL),
mpFunctionName(NULL),
-mpFunctionCallManager(NULL),
mpListOfParameters(NULL),
-mpSpecializedSciMsgHeader(NULL)
+mpFunctionCallManager(NULL)
{
clog << "FunctionSciMsg(FunctionCallManager*)" << endl;
@@ -76,7 +76,7 @@ mpSpecializedSciMsgHeader(NULL)
}
else
{
- throw Error("FunctionSciMsg(FunctionCallManager*)", "Received FunctionCallManager pointer is NULL");
+ throw Error("FunctionSciMsg(FunctionCallManager*)", "Received function call manager pointer is NULL");
}
initAttributes ();
@@ -90,35 +90,35 @@ void FunctionSciMsg::initAttributes ( )
mpSpecializedSciMsgHeader = new Function_Call_Header;
mpListOfParameters = new ParametersList ();
- if ( (NULL != mpSpecializedSciMsgHeader) && (NULL != mpListOfParameters) )
+ if (NULL != mpSpecializedSciMsgHeader)
{
mpSpecializedSciMsgHeader->version = FUNCTION_CALL_VERSION;
- mpSpecializedSciMsgHeader->type = (uint8_t)FUNCTION_CALL_TYPE_NONE;
- mpSpecializedSciMsgHeader->param_nb = 0;
- mpSpecializedSciMsgHeader->flags = 0;
- }
- else
- {
- throw Error("FunctionSciMsg::initAttributes", "Initialized ParametersList and/or Function_Sci_Msg_Header pointer is NULL");
+ mpSpecializedSciMsgHeader->type = 0x00;
+ mpSpecializedSciMsgHeader->param_nb = 0x00;
+ mpSpecializedSciMsgHeader->flags = 0x00;
}
}
-FunctionSciMsg::FunctionSciMsg ( const FunctionSciMsg & function_sci_msg ) : SciMsg (function_sci_msg)
+FunctionSciMsg::FunctionSciMsg ( const FunctionSciMsg & function_sci_msg ) : SciMsg ( function_sci_msg )
{
clog << "FunctionSciMsg(FunctionSciMsg&)" << endl;
initAttributes ();
-
- setFunctionCallManager (function_sci_msg.getFunctionCallManager());
- setSpecializedSciMsgHeader (function_sci_msg.getSpecializedSciMsgHeader());
+
setSpecializedSciMsgType (function_sci_msg.getSpecializedSciMsgType());
+ setSpecializedSciMsgParametersNumber (function_sci_msg.getSpecializedSciMsgParametersNumber());
+
+ setSpecializedSciMsgHeader (function_sci_msg.getSpecializedSciMsgHeader());
+
setFunctionName (function_sci_msg.getFunctionName());
setListOfParameters (function_sci_msg.getListOfParameters());
+
+ setFunctionCallManager (function_sci_msg.getFunctionCallManager());
}
-FunctionSciMsg::FunctionSciMsg ( const FunctionSciMsg * function_sci_msg ) : SciMsg (function_sci_msg)
+FunctionSciMsg::FunctionSciMsg ( const FunctionSciMsg * function_sci_msg ) : SciMsg ( function_sci_msg )
{
clog << "FunctionSciMsg(FunctionSciMsg*)" << endl;
@@ -126,15 +126,19 @@ FunctionSciMsg::FunctionSciMsg ( const FunctionSciMsg * function_sci_msg ) : Sci
if (NULL != function_sci_msg)
{
- setFunctionCallManager (function_sci_msg->getFunctionCallManager());
- setSpecializedSciMsgHeader (function_sci_msg->getSpecializedSciMsgHeader());
setSpecializedSciMsgType (function_sci_msg->getSpecializedSciMsgType());
+ setSpecializedSciMsgParametersNumber (function_sci_msg->getSpecializedSciMsgParametersNumber());
+
+ setSpecializedSciMsgHeader (function_sci_msg->getSpecializedSciMsgHeader());
+
setFunctionName (function_sci_msg->getFunctionName());
setListOfParameters (function_sci_msg->getListOfParameters());
+
+ setFunctionCallManager (function_sci_msg->getFunctionCallManager());
}
else
{
- throw Error("FunctionSciMsg(FunctionSciMsg*)", "Received FunctionSciMsg pointer is NULL");
+ throw Error("FunctionSciMsg(FunctionSciMsg*)", "Received function SCI msg pointer is NULL");
}
}
@@ -149,6 +153,11 @@ FunctionSciMsg::~FunctionSciMsg ( )
mpSpecializedSciMsgHeader = NULL;
}
+ if (NULL != mpFunctionName)
+ {
+ delete [] mpFunctionName;
+ mpFunctionName = NULL;
+ }
if (NULL != mpListOfParameters)
{
if (!mpListOfParameters->empty())
@@ -164,12 +173,6 @@ FunctionSciMsg::~FunctionSciMsg ( )
{
mpFunctionCallManager = NULL;
}
-
- if (NULL != mpFunctionName)
- {
- delete [] mpFunctionName;
- mpFunctionName = NULL;
- }
}
@@ -223,14 +226,20 @@ bool FunctionSciMsg::dispatchMsg ( )
{
clog << "FunctionSciMsg::dispatchMsg" << endl;
bool bDispatch = false;
-
- if (NULL != mpFunctionCallManager)
+
+ if ( NULL != mpFunctionCallManager )
{
- bDispatch = mpFunctionCallManager->receiveMsg(*this);
+ bDispatch = identifyCallbackName();
+ bDispatch &= identifyCallbackParameters();
+
+ if ( FUNCTION_CALL_TYPE_RSP == getSpecializedSciMsgType() )
+ {
+ bDispatch &= mpFunctionCallManager->receiveMsg(*this);
+ }
}
else
{
- throw Error("FunctionSciMsg::dispatchMsg", "FunctionCallManager NULL pointer");
+ throw Error("FunctionSciMsg::dispatchMsg", "Function call manager pointer is NULL");
}
return bDispatch;
@@ -246,23 +255,24 @@ bool FunctionSciMsg::identifySpecializedSciMsgHeader ( )
if (NULL != SciMsg::getSciMsgData())
{
- // Get specialized SCI message header contents
+ // Set specialized SCI msg header size
//
SciMsg::setSpecializedSciMsgHeaderSize((unsigned long)sizeof(struct Function_Call_Header));
- if (SciMsg::getSciMsgDataLength() >= (unsigned long)SciMsg::getSpecializedSciMsgHeaderSize()) // check that there are enough data to get the specialized SCI message header
+
+ // Get specialized SCI message header contents
+ //
+ if (SciMsg::getSciMsgDataLength() >= SciMsg::getSpecializedSciMsgHeaderSize()) // check that there are enough data to get the specialized SCI message header
{
if (NULL != mpSpecializedSciMsgHeader)
{
*mpSpecializedSciMsgHeader = *((Function_Call_Header*)SciMsg::getSciMsgData());
- mSpecializedSciMsgType = static_cast<Function_Call_Type>(mpSpecializedSciMsgHeader->type);
-
- mSpecializedSciMsgParametersNumber = static_cast<Function_Call_Parameters_Number>(mpSpecializedSciMsgHeader->param_nb);
+ // Set specialized SCI msg attributes from specialized SCI msg header
+ //
+ setSpecializedSciMsgType (static_cast<Function_Call_Type>(getSpecializedSciMsgHeader()->type));
+ setSpecializedSciMsgParametersNumber (static_cast<Function_Call_Parameters_Number>(getSpecializedSciMsgHeader()->param_nb));
- //displaySpecializedSciMsgHeader();
- clog << dec << "\ttype = " << getSpecializedSciMsgType() << endl;
- clog << dec << "\tnumber of parameters = " << getSpecializedSciMsgParametersNumber() << endl;
-
+ displaySpecializedSciMsgHeader();
bIdentifyHeader = true;
}
}
@@ -273,13 +283,118 @@ bool FunctionSciMsg::identifySpecializedSciMsgHeader ( )
}
else
{
- throw Error("FunctionSciMsg::identifySpecializedSciMsgHeader", "Received data pointer is NULL");
+ throw Error("FunctionSciMsg::identifySpecializedSciMsgHeader", "SCI msg data pointer is NULL");
}
return bIdentifyHeader;
}
+// Called by user to configure a message to send
+//
+bool FunctionSciMsg::addParameter ( Function_Call_Parameter & function_argument_to_add )
+{
+ clog << "FunctionSciMsg::addParameter" << endl;
+ bool bAddParameter = false;
+
+ if (NULL != mpListOfParameters)
+ {
+ Function_Call_Parameter * parameterToAdd = new Function_Call_Parameter;
+ if (NULL != parameterToAdd)
+ {
+ parameterToAdd->p_name = new char [strlen(function_argument_to_add.p_name)+1];
+ if ( (NULL != parameterToAdd->p_name) && (NULL != function_argument_to_add.p_name) )
+ {
+ strcpy(parameterToAdd->p_name, function_argument_to_add.p_name);
+ parameterToAdd->length = function_argument_to_add.length;
+
+ parameterToAdd->p_value = new unsigned char [parameterToAdd->length+1];
+ if ( (NULL != parameterToAdd->p_value) && (NULL != function_argument_to_add.p_value) )
+ {
+ strncpy((char*)parameterToAdd->p_value, (char*)function_argument_to_add.p_value, parameterToAdd->length);
+ parameterToAdd->p_value[parameterToAdd->length] = '\0';
+ mpListOfParameters->push_back(parameterToAdd);
+
+ displayListOfParameters();
+ bAddParameter = true;
+ }
+ else
+ {
+ throw Error("FunctionSciMsg::addParameter", "Function call parameter value pointer is NULL");
+ }
+ }
+ else
+ {
+ throw Error("FunctionSciMsg::addParameter", "Function call parameter name pointer is NULL");
+ }
+ }
+ else
+ {
+ throw Error("FunctionSciMsg::addParameter", "Initialized function call parameter pointer is NULL");
+ }
+ }
+ else
+ {
+ throw Error("FunctionSciMsg::addParameter", "Initialized parameters list pointer is NULL");
+ }
+
+ return bAddParameter;
+}
+
+
+// Called by user when a message is received to retrieve function parameters
+//
+bool FunctionSciMsg::bindParameter ( const char * name_of_parameter_to_get, unsigned long & data_length, void ** pp_data ) const
+{
+ clog << "FunctionSciMsg::bindParameter" << endl;
+ bool bBindParameter = false;
+
+ if (NULL != pp_data)
+ {
+ displayListOfParameters();
+ if (NULL != mpListOfParameters)
+ {
+ for (unsigned int i=0; i<mpListOfParameters->size(); ++i)
+ {
+ if (!strcmp(name_of_parameter_to_get, (*mpListOfParameters)[i]->p_name))
+ {
+ data_length = (*mpListOfParameters)[i]->length;
+ *pp_data = malloc(data_length);
+ if (NULL != *pp_data)
+ {
+ if (NULL != (*mpListOfParameters)[i]->p_value)
+ {
+ *pp_data = (void*)((*mpListOfParameters)[i]->p_value);
+ }
+ else
+ {
+ *pp_data = NULL;
+ }
+ displayParameter(i);
+ i = mpListOfParameters->size()-1;
+ bBindParameter = true;
+ }
+ else
+ {
+ throw Error("FunctionSciMsg::bindParameter", "Allocated data pointer is NULL");
+ }
+ }
+ }
+ }
+ else
+ {
+ throw Error("FunctionSciMsg::bindParameter", "Initialized parameters list pointer is NULL");
+ }
+ }
+ else
+ {
+ throw Error("FunctionSciMsg::bindParameter", "Received parameter value pointer is NULL");
+ }
+
+ return bBindParameter;
+}
+
+
// Called when a function SCI msg is received
//
bool FunctionSciMsg::identifyCallbackName ( )
@@ -297,27 +412,30 @@ bool FunctionSciMsg::identifyCallbackName ( )
{
functionNameLength++;
}
- clog << "\tlength of callback name = " << functionNameLength << endl;
+ clog << "\tcallback name length = " << dec << functionNameLength << endl;
- // Copy function name from data to function msg header
+ // Copy function name from specialized SCI msg data to function name attribute
//
mpFunctionName = new char [functionNameLength+1];
if (NULL != mpFunctionName)
{
- clog << "\tcallback name = ";
for (unsigned int i=0; i<functionNameLength+1; i++)
{
- *(mpFunctionName+i) = *(getSpecializedSciMsgData()+i);
- clog << *(mpFunctionName+i);
+ *(mpFunctionName+i) = static_cast<char>(*(getSpecializedSciMsgData()+i));
}
- clog << endl;
clog << "\tcallback name = " << mpFunctionName << endl;
+ // Remove function name from specialized SCI msg data
+ //
unsigned long tempDataLength = getSpecializedSciMsgDataLength();
unsigned char * pTempData = getSpecializedSciMsgData();
- SciMsg::removeData (functionNameLength+1, tempDataLength, &pTempData);
- bIdentifyName = setSpecializedSciMsgDataLength(tempDataLength);
- bIdentifyName &= setSpecializedSciMsgData(pTempData);
+ bIdentifyName = SciMsg::removeData (functionNameLength+1, tempDataLength, &pTempData);
+ if (0 != bIdentifyName)
+ {
+ bIdentifyName &= setSpecializedSciMsgDataLength(tempDataLength);
+ bIdentifyName &= setSpecializedSciMsgData(pTempData);
+ }
+ pTempData = NULL; // free pointer
}
else
{
@@ -330,6 +448,10 @@ bool FunctionSciMsg::identifyCallbackName ( )
{
bIdentifyName = true;
}
+ else
+ {
+ throw Error("FunctionSciMsg::identifyCallbackName", "Specialized SCI msg data pointer is NULL");
+ }
}
return bIdentifyName;
@@ -341,10 +463,12 @@ bool FunctionSciMsg::identifyCallbackName ( )
bool FunctionSciMsg::identifyCallbackParameters ( )
{
clog << "FunctionSciMsg::identifyCallbackParameters" << endl;
- bool bIdentifyParameters = true;
+ bool bIdentifyParameters = false;
- if ( (0 != getSpecializedSciMsgParametersNumber()) && (NULL != getSpecializedSciMsgData()) )
+ if ( NULL != getSpecializedSciMsgData() )
{
+ // For each parameter
+ //
for (unsigned int n=0; n<getSpecializedSciMsgParametersNumber(); n++)
{
// Find parameter name length
@@ -357,58 +481,63 @@ bool FunctionSciMsg::identifyCallbackParameters ( )
}
clog << dec << "\tparameter " << n+1 << " name length = " << parameterNameLength << endl;
- // Copy function name from data to function msg header
+ // Copy parameter name from specialized SCI msg data to parameter name attribute
//
Function_Call_Parameter parameterToFill = { NULL, 0, NULL };
parameterToFill.p_name = new char [parameterNameLength+1];
if (NULL != parameterToFill.p_name)
{
- clog << "\tparameter " << n+1 << " name = ";
for (unsigned int i=0; i<parameterNameLength+1; i++)
{
*(parameterToFill.p_name+i) = static_cast<char>(*(getSpecializedSciMsgData()+i));
- clog << *(parameterToFill.p_name+i);
}
- clog << endl;
+ clog << "\tparameter " << dec << n+1 << " name = " << parameterToFill.p_name << endl;
+ // Remove parameter name from specialized SCI msg data
+ //
unsigned long tempDataLength = getSpecializedSciMsgDataLength();
unsigned char * pTempData = getSpecializedSciMsgData();
- SciMsg::removeData (parameterNameLength+1, tempDataLength, &pTempData);
- bIdentifyParameters &= setSpecializedSciMsgDataLength(tempDataLength);
- bIdentifyParameters &= setSpecializedSciMsgData(pTempData);
- pTempData = NULL;
+ bIdentifyParameters = SciMsg::removeData (parameterNameLength+1, tempDataLength, &pTempData);
+ if (0 != bIdentifyParameters)
+ {
+ bIdentifyParameters &= setSpecializedSciMsgDataLength(tempDataLength);
+ bIdentifyParameters &= setSpecializedSciMsgData(pTempData);
+ }
- // Find parameter length
- // Length of parameter value is coded on 2 bytes
+ // Find parameter value length (coded on 2 bytes)
//
uint16_t tempLength = (static_cast<uint8_t>(*(getSpecializedSciMsgData()))<<8) + static_cast<uint8_t>(*(getSpecializedSciMsgData()+1));
- parameterToFill.length = (unsigned long)tempLength;
- clog << dec << "\tlength of parameter " << n+1 << " value = " << parameterToFill.length << endl;
+ parameterToFill.length = static_cast<unsigned long>(tempLength);
+ clog << dec << "\tparameter " << n+1 << " value length = " << parameterToFill.length << endl;
// Find parameter value
//
parameterToFill.p_value = new unsigned char [parameterToFill.length];
if (NULL != parameterToFill.p_value)
{
- clog << "\tparameter " << n+1 << " value = ";
- for (unsigned int i=0; i<(unsigned int)parameterToFill.length; i++)
+ clog << "\tparameter " << dec << n+1 << " value = ";
+ for (unsigned int i=0; i<static_cast<unsigned int>(parameterToFill.length); i++)
{
- *(parameterToFill.p_value+i) = *(getSpecializedSciMsgData()+2+i); // +2 because Length of parameter value is coded on 2 bytes
+ *(parameterToFill.p_value+i) = *(getSpecializedSciMsgData()+2+i); // +2 because parameter value length is coded on 2 bytes
clog << *(parameterToFill.p_value+i);
}
clog << endl;
+ // Remove parameter value length and parameter value from specialized SCI msg data
+ //
tempDataLength = getSpecializedSciMsgDataLength();
pTempData = getSpecializedSciMsgData();
- SciMsg::displaySpecializedSciMsgData();
- SciMsg::removeData (2+parameterToFill.length, tempDataLength, &pTempData); // 2 because Length of parameter value is coded on 2 bytes
- SciMsg::displaySpecializedSciMsgData();
- bIdentifyParameters &= setSpecializedSciMsgDataLength(tempDataLength);
- bIdentifyParameters &= setSpecializedSciMsgData(pTempData);
+ bIdentifyParameters &= SciMsg::removeData (2+parameterToFill.length, tempDataLength, &pTempData); // +2 because parameter value length is coded on 2 bytes
+ if (0 != bIdentifyParameters)
+ {
+ bIdentifyParameters &= setSpecializedSciMsgDataLength(tempDataLength);
+ bIdentifyParameters &= setSpecializedSciMsgData(pTempData);
+ }
+ pTempData = NULL; // free pointer
}
else
{
- throw Error("FunctionSciMsg::identifyCallbackParameters", "Initialized parameter name pointer is NULL");
+ throw Error("FunctionSciMsg::identifyCallbackParameters", "Initialized parameter value pointer is NULL");
}
// Add parameter to the parameters list of the received function SCI msg
@@ -421,119 +550,18 @@ bool FunctionSciMsg::identifyCallbackParameters ( )
}
}
}
-
- return bIdentifyParameters;
-}
-
-
-// Called by user to configure a message to send
-//
-bool FunctionSciMsg::addParameter ( Function_Call_Parameter & function_argument_to_add )
-{
- clog << "FunctionSciMsg::addParameter" << endl;
- bool bAddParameter = false;
-
- if (NULL != mpListOfParameters)
- {
- Function_Call_Parameter * parameterToAdd = new Function_Call_Parameter;
- if (NULL != parameterToAdd)
- {
- parameterToAdd->p_name = new char [strlen(function_argument_to_add.p_name)+1];
- if ( (NULL != parameterToAdd->p_name) && (NULL != function_argument_to_add.p_name) )
- {
- strcpy(parameterToAdd->p_name, function_argument_to_add.p_name);
- parameterToAdd->length = function_argument_to_add.length;
-
- parameterToAdd->p_value = new unsigned char [parameterToAdd->length+1];
- if (NULL != parameterToAdd->p_value)
- {
- if (NULL != function_argument_to_add.p_value)
- {
- strncpy((char*)parameterToAdd->p_value, (char*)function_argument_to_add.p_value, parameterToAdd->length);
- parameterToAdd->p_value[parameterToAdd->length] = '\0';
- }
- else
- {
- parameterToAdd->p_value = NULL;
- }
- mpListOfParameters->push_back(parameterToAdd);
- displayListOfParameters();
- bAddParameter = true;
- }
- else
- {
- throw Error("FunctionSciMsg::addParameter", "Initialized Function_Call_Parameter value pointer is NULL");
- }
- }
- else
- {
- throw Error("FunctionSciMsg::addParameter", "Initialized and/or received Function_Call_Parameter name pointer is NULL");
- }
- }
- else
- {
- throw Error("FunctionSciMsg::addParameter", "Initialized Function_Call_Parameter pointer is NULL");
- }
- }
else
{
- throw Error("FunctionSciMsg::addParameter", "Initialized ParametersList pointer is NULL");
+ throw Error("FunctionSciMsg::identifyCallbackParameters", "Specialized SCI msg data pointer is NULL");
}
-
- return bAddParameter;
-}
-
-// Called by user when a message is received to retrieve function parameters
-//
-bool FunctionSciMsg::bindParameter ( const char * name_of_parameter_to_get, unsigned long & data_length, void ** pp_data ) const
-{
- clog << "FunctionSciMsg::bindParameter" << endl;
- bool bBindParameter = false;
-
- if (NULL != pp_data)
- {
- displayListOfParameters();
- if (NULL != mpListOfParameters)
- {
- for (unsigned int i=0; i<mpListOfParameters->size(); ++i)
- {
- if (!strcmp(name_of_parameter_to_get, (*mpListOfParameters)[i]->p_name))
- {
- data_length = (*mpListOfParameters)[i]->length;
- *pp_data = malloc(data_length);
- if (NULL != *pp_data)
- {
- if (NULL != (*mpListOfParameters)[i]->p_value)
- {
- *pp_data = (void*)((*mpListOfParameters)[i]->p_value);
- }
- else
- {
- *pp_data = NULL;
- }
- displayParameter(i);
- i = mpListOfParameters->size()-1;
- bBindParameter = true;
- }
- }
- }
- }
- else
- {
- throw Error("FunctionSciMsg::bindParameter", "Initialized list of parameters pointer is NULL");
- }
- }
- else
- {
- throw Error("FunctionSciMsg::bindParameter", "Received parameter value pointer is NULL");
- }
-
- return bBindParameter;
+ return bIdentifyParameters;
}
// Called when a function SCI msg is sent
+// Fill specialized SCI msg attributes
+// Fill specialized SCI msg data length and specialized SCI msg data
//
bool FunctionSciMsg::fillSpecializedSciMsgToSend ( )
{
@@ -541,7 +569,7 @@ bool FunctionSciMsg::fillSpecializedSciMsgToSend ( )
bool bFill = false;
displayListOfParameters();
- unsigned int numberOfParameters = 0;
+ Function_Call_Parameters_Number numberOfParameters = 0;
unsigned long dataLength = 0;
unsigned char * pData = NULL;
@@ -549,55 +577,77 @@ bool FunctionSciMsg::fillSpecializedSciMsgToSend ( )
//
if (NULL != getFunctionName())
{
- pData = (unsigned char *) malloc (strlen(getFunctionName())+1); // memory allocation for function SCI msg data
- strcpy ((char*)pData, getFunctionName()); // copy function name into data
+ pData = (unsigned char *)(malloc(strlen(getFunctionName())+1)); // memory allocation for function name
+ strcpy ((char*)(pData), getFunctionName()); // copy function name into data
pData[strlen(getFunctionName())] = '\0';
- clog << "\tdata of SCI msg to send = " << pData << endl;
- dataLength += (unsigned long)strlen((char*)pData)+1; // update data length
- clog << "\tdata length of SCI msg to send = " << dataLength << endl;
+ clog << "\tfunction name = " << pData << endl; // display function name
+ dataLength += static_cast<unsigned long>(strlen((char*)(pData))+1); // update data length
// Parameters are defined as 'struct Function_Call_Parameter'
// They will be sent into the function SCI msg into specialized SCI msg data
// 'Function_Call_Parameter' fields are sent according to the following format:
- // [name,length,p_value][name,length,p_value] etc.
- // For msg reception, number of parameters is sent into the 'Function_Sci_Msg_Header.number_of_parameters' field
+ // name\0lengthp_value etc. with length coded on 2 bytes
+ // Number of parameters is sent into the 'Function_Call_Header.param_nb' field
//
for (unsigned int i=0; i<mpListOfParameters->size(); ++i)
{
- // We need to convert 'Function_Call_Parameter.length' field (defined as unsigned short) to char *
- // To do this (as 'itoa' function is not available) an 'ostringstream' is used
- //
- ostringstream oss;
- oss << (*mpListOfParameters)[i]->p_name << ends;
- oss << (*mpListOfParameters)[i]->p_value;
-
- // Dynamic memory allocation for function SCI msg data
+ // Dynamic memory allocation for parameter
//
- pData = (unsigned char *) realloc (pData, dataLength+(unsigned long)oss.str().length()); // 'length()' gets the resulting string length
-
- for (unsigned long l=0; l<(unsigned long)oss.str().length(); l++)
+ pData = (unsigned char *)(realloc(pData, dataLength+strlen((*mpListOfParameters)[i]->p_name)+1+2+(*mpListOfParameters)[i]->length));
+
+ // Parameter name
+ //
+ strcpy ((char*)(pData+dataLength), (*mpListOfParameters)[i]->p_name); // copy parameter name into data
+ pData[strlen((*mpListOfParameters)[i]->p_name)] = '\0';
+ clog << "\tparameter " << dec << i+1 << " name = ";
+ for (unsigned int j=dataLength; j<dataLength+strlen((*mpListOfParameters)[i]->p_name)+1; j++)
{
- *(pData+dataLength+l) = oss.str()[l]; // retrieve the resulting string with 'str()' and copy it into data
+ clog << *(pData+j); // display parameter name
}
-
- // Update data length
+ clog << endl;
+ dataLength += static_cast<unsigned long>(strlen((char*)(pData))+1); // update data length
+
+ // Parameter value length
//
- dataLength += (unsigned long)oss.str().length();
- clog << "\tdata length of SCI msg to send = " << dataLength << endl;
-
+ uint16_t tempLength = static_cast<uint16_t>((*mpListOfParameters)[i]->length);
+ uint8_t tempLengthHigh=0, tempLengthLow=0;
+ tempLengthHigh = static_cast<uint8_t>(tempLength >> 8);
+ tempLengthLow = static_cast<uint8_t>(tempLength);
+ *(pData+dataLength) = static_cast<unsigned char>(tempLengthHigh);
+ *(pData+dataLength+1) = static_cast<unsigned char>(tempLengthLow);
+ clog << "\tparameter " << dec << i+1 << " value length = 0x" << setfill('0') << setw(2) << uppercase << hex << static_cast<unsigned short int>(tempLengthHigh);
+ clog << setfill('0') << setw(2) << uppercase << hex << static_cast<unsigned short int>(tempLengthLow) << endl; // display parameter value length
+ dataLength += 2; // update data length
+
+ // Parameter value
+ //
+ clog << "\tparameter value = ";
+ for (unsigned int j=0; j<(*mpListOfParameters)[i]->length; j++)
+ {
+ *(pData+dataLength+j) = *((*mpListOfParameters)[i]->p_value+j);
+ clog << *(pData+dataLength+j); // display parameter value
+ }
+ clog << endl;
+ dataLength += (*mpListOfParameters)[i]->length; // update data length
+
// Increment number of parameters that have been copied into data
//
numberOfParameters++;
}
}
+ else
+ {
+ throw Error("FunctionSciMsg::fillSpecializedSciMsgToSend", "Function name pointer is NULL");
+ }
- // Fill SCI msg data, data length and number of parameters
+ // Fill specialized SCI msg data, specialized SCI msg data length and specialized SCI msg number of parameters
//
if (NULL != pData)
{
- bFill = setSpecializedSciMsgParametersNumber (numberOfParameters); // set number of parameters
- bFill &= setSpecializedSciMsgDataLength(dataLength); // set data length
- bFill &= setSpecializedSciMsgData(pData); // set data
+ bFill = setSpecializedSciMsgType(FUNCTION_CALL_TYPE_REQ);
+ bFill &= setSpecializedSciMsgParametersNumber(numberOfParameters);
+ bFill &= setSpecializedSciMsgDataLength(dataLength);
+ bFill &= setSpecializedSciMsgData(pData);
// Free temporary allocated memory
//
@@ -609,27 +659,23 @@ bool FunctionSciMsg::fillSpecializedSciMsgToSend ( )
}
-// private methods
-//
-
-
void FunctionSciMsg::displaySpecializedSciMsgHeader ( ) const
{
- clog << "FunctionSciMsg::displaySpecializedSciMsgHeader" << endl;
-
- clog << hex << "\tversion = 0x" << setfill('0') << setw(2) << uppercase << mpSpecializedSciMsgHeader->version << endl;
- clog << dec << "\ttype = " << mpSpecializedSciMsgHeader->type << endl;
- clog << dec << "\tnumber of parameters = " << mpSpecializedSciMsgHeader->param_nb << endl;
- clog << hex << "\tflags = 0x" << setfill('0') << setw(2) << uppercase << mpSpecializedSciMsgHeader->flags << endl;
- clog << dec;
+ clog << "\tfunction SCI msg header = " << endl;
+ clog << "\t\tversion = " << dec << static_cast<unsigned short int>(mpSpecializedSciMsgHeader->version) << endl;
+ clog << "\t\ttype = " << dec << static_cast<unsigned short int>(mpSpecializedSciMsgHeader->type) << endl;
+ clog << "\t\tnumber of parameters = " << dec << static_cast<unsigned short int>(mpSpecializedSciMsgHeader->param_nb) << endl;
+ clog << "\t\tflags = " << dec << static_cast<unsigned short int>(mpSpecializedSciMsgHeader->flags) << endl;
}
+// private methods
+//
+
+
void FunctionSciMsg::displayParameter ( unsigned int parameter_iterator ) const
{
- clog << "FunctionSciMsg::displayParameter" << endl;
-
- clog << dec << "\tparameter " << parameter_iterator+1 << " = ";
+ clog << "\tparameter " << dec << parameter_iterator+1 << " = ";
if (parameter_iterator < mpListOfParameters->size())
{
clog << "[";
@@ -644,7 +690,7 @@ void FunctionSciMsg::displayParameter ( unsigned int parameter_iterator ) const
clog << ", " << (*mpListOfParameters)[parameter_iterator]->length << ", ";
if (NULL != (*mpListOfParameters)[parameter_iterator]->p_value)
{
- for (unsigned short i = 0; i<(*mpListOfParameters)[parameter_iterator]->length; i++)
+ for (unsigned int i=0; i<static_cast<unsigned int>((*mpListOfParameters)[parameter_iterator]->length); i++)
{
clog << *((*mpListOfParameters)[parameter_iterator]->p_value+i);
}
@@ -664,35 +710,13 @@ void FunctionSciMsg::displayParameter ( unsigned int parameter_iterator ) const
void FunctionSciMsg::displayListOfParameters ( ) const
{
- clog << "FunctionSciMsg::displayListOfParameters" << endl;
-
if (!mpListOfParameters->empty())
{
- clog << dec << "\tlist of parameters = " << endl;
+ clog << "\tlist of parameters = " << endl;
for (unsigned int i=0; i<mpListOfParameters->size(); i++)
{
- clog << "\t\tparameter " << i+1 << " = " << "[";
- if (NULL != (*mpListOfParameters)[i]->p_name)
- {
- clog << (*mpListOfParameters)[i]->p_name;
- }
- else
- {
- clog << "NULL";
- }
- clog << ", " << (*mpListOfParameters)[i]->length << ", ";
- if (NULL != (*mpListOfParameters)[i]->p_value)
- {
- for (unsigned short j = 0; j<(*mpListOfParameters)[i]->length; j++)
- {
- clog << *((*mpListOfParameters)[i]->p_value+j);
- }
- }
- else
- {
- clog << "NULL";
- }
- clog << "]" << endl;
+ clog << "\t";
+ displayParameter(i);
}
}
else
@@ -718,63 +742,69 @@ void FunctionSciMsg::displayListOfParameters ( ) const
//
+Function_Call_Type FunctionSciMsg::getSpecializedSciMsgType ( ) const
+{
+ return mSpecializedSciMsgType;
+}
+
-Sci_Station_Id FunctionSciMsg::getStationId ( ) const
+bool FunctionSciMsg::setSpecializedSciMsgType ( const Function_Call_Type type )
{
- return mStationId;
+ clog << "FunctionSciMsg::setSpecializedSciMsgType" << endl;
+
+ mSpecializedSciMsgType = type;
+ clog << "\ttype = " << dec << getSpecializedSciMsgType() << endl;
+
+ return true;
}
-bool FunctionSciMsg::setStationId ( const Sci_Station_Id station_id )
+Function_Call_Parameters_Number FunctionSciMsg::getSpecializedSciMsgParametersNumber ( ) const
{
- clog << "FunctionSciMsg::setStationId" << endl;
+ return mSpecializedSciMsgParametersNumber;
+}
+
+
+bool FunctionSciMsg::setSpecializedSciMsgParametersNumber ( const Function_Call_Parameters_Number number_of_parameters )
+{
+ clog << "FunctionSciMsg::setSpecializedSciMsgParametersNumber" << endl;
- mStationId = station_id;
- clog << "\tstation id = " << mStationId << endl;
+ mSpecializedSciMsgParametersNumber = number_of_parameters;
+ clog << "\tnumber of parameters = " << dec << getSpecializedSciMsgParametersNumber() << endl;
return true;
}
-FunctionCallManager * FunctionSciMsg::getFunctionCallManager ( ) const
+Function_Call_Header * FunctionSciMsg::getSpecializedSciMsgHeader ( ) const
{
- return mpFunctionCallManager;
+ return mpSpecializedSciMsgHeader;
}
-
-bool FunctionSciMsg::setFunctionCallManager ( FunctionCallManager * p_function_call_manager )
+
+bool FunctionSciMsg::setSpecializedSciMsgHeader ( const Function_Call_Header * p_specialized_sci_msg_header )
{
- clog << "FunctionSciMsg::setFunctionCallManager" << endl;
- bool bSet = false;
+ clog << "FunctionSciMsg::setSpecializedSciMsgHeader" << endl;
+ bool bSetHeader = false;
- if (NULL != p_function_call_manager)
+ if ( (NULL != p_specialized_sci_msg_header) && (NULL != mpSpecializedSciMsgHeader) )
{
- mpFunctionCallManager = p_function_call_manager;
- bSet = true;
+ *mpSpecializedSciMsgHeader = *p_specialized_sci_msg_header;
+ displaySpecializedSciMsgHeader();
+ bSetHeader = true;
}
else
{
- throw Error("FunctionSciMsg::setFunctionCallManager", "Received FunctionCallManager pointer is NULL");
+ throw Error("FunctionSciMsg::setSpecializedSciMsgHeader", "Received and/or initialized function call header pointer is NULL");
}
-
- return bSet;
-}
-
-
-bool FunctionSciMsg::setSpecializedSciMsgParametersNumber ( const Function_Call_Parameters_Number number_of_parameters )
-{
- clog << "FunctionSciMsg::setSpecializedSciMsgParametersNumber" << endl;
-
- mSpecializedSciMsgParametersNumber = number_of_parameters;
- clog << "\tnumber of parameters = " << dec << mSpecializedSciMsgParametersNumber << endl;
-
- return true;
+
+ return bSetHeader;
}
-Function_Call_Parameters_Number FunctionSciMsg::getSpecializedSciMsgParametersNumber ( ) const
+char * FunctionSciMsg::getFunctionName ( ) const
{
- return mSpecializedSciMsgParametersNumber;
+ return mpFunctionName;
}
@@ -804,11 +834,11 @@ bool FunctionSciMsg::setFunctionName ( const char * name )
}
-char * FunctionSciMsg::getFunctionName ( ) const
+ParametersList * FunctionSciMsg::getListOfParameters ( ) const
{
- return mpFunctionName;
+ return mpListOfParameters;
}
-
+
bool FunctionSciMsg::setListOfParameters ( ParametersList * list_of_parameters )
{
@@ -822,62 +852,37 @@ bool FunctionSciMsg::setListOfParameters ( ParametersList * list_of_parameters )
}
else
{
- throw Error("FunctionSciMsg::setFunctionCallManager", "Received ParametersList pointer is NULL");
+ throw Error("FunctionSciMsg::setFunctionCallManager", "Received parameters list pointer is NULL");
}
return bSetList;
}
-ParametersList * FunctionSciMsg::getListOfParameters ( ) const
+FunctionCallManager * FunctionSciMsg::getFunctionCallManager ( ) const
{
- return mpListOfParameters;
+ return mpFunctionCallManager;
}
-bool FunctionSciMsg::setSpecializedSciMsgType ( const Function_Call_Type type )
-{
- clog << "FunctionSciMsg::setSpecializedSciMsgType" << endl;
-
- mSpecializedSciMsgType = type;
- mpSpecializedSciMsgHeader->type = (uint8_t)mSpecializedSciMsgType;
- clog << dec << "\ttype = " << mpSpecializedSciMsgHeader->type << endl;
-
- return true;
-}
-
-
-Function_Call_Type FunctionSciMsg::getSpecializedSciMsgType ( ) const
-{
- return mSpecializedSciMsgType;
-}
-
-
-Function_Call_Header * FunctionSciMsg::getSpecializedSciMsgHeader ( ) const
-{
- return mpSpecializedSciMsgHeader;
-}
-
-
-bool FunctionSciMsg::setSpecializedSciMsgHeader ( const Function_Call_Header * p_specialized_sci_msg_header )
+bool FunctionSciMsg::setFunctionCallManager ( FunctionCallManager * p_function_call_manager )
{
- clog << "FunctionSciMsg::setSpecializedSciMsgHeader" << endl;
- bool bSetHeader = false;
+ clog << "FunctionSciMsg::setFunctionCallManager" << endl;
+ bool bSet = false;
- if ( (NULL != p_specialized_sci_msg_header) && (NULL != mpSpecializedSciMsgHeader) )
+ if (NULL != p_function_call_manager)
{
- *mpSpecializedSciMsgHeader = *p_specialized_sci_msg_header;
- displaySpecializedSciMsgHeader();
- bSetHeader = true;
+ mpFunctionCallManager = p_function_call_manager;
+ bSet = true;
}
else
{
- throw Error("FunctionSciMsg::setSpecializedSciMsgHeader", "Received and/or initialized Function_Call_Header pointer is NULL");
+ throw Error("FunctionSciMsg::setFunctionCallManager", "Received function call manager pointer is NULL");
}
-
- return bSetHeader;
-}
+ return bSet;
+}
+
// protected attribute accessor methods
//
diff --git a/maximus/networkclock/inc/ClockSciMsg.h b/maximus/networkclock/inc/ClockSciMsg.h
index 8984a0c33d..605ccbd1ba 100644
--- a/maximus/networkclock/inc/ClockSciMsg.h
+++ b/maximus/networkclock/inc/ClockSciMsg.h
@@ -53,11 +53,17 @@ private:
// private attributes
//
-
+
+ // Get from specialized SCI msg header
+ //
+ Network_Clock_Type mSpecializedSciMsgType;
Network_Clock_Id mSpecializedSciMsgId;
- Network_Clock_Type mSpecializedSciMsgType;
Network_Clock_Tick mSpecializedSciMsgTick;
+
+ // Specialized SCI message header
+ //
Network_Clock_Header * mpSpecializedSciMsgHeader;
+
NetworkClockProcessor * mpNetworkClockProcessor;
protected:
@@ -100,11 +106,11 @@ public:
/**
* @return bool
- * @param data_length
- * @param p_data
*/
bool identifySpecializedSciMsgHeader ( );
+ void displaySpecializedSciMsgHeader ( ) const;
+
// public attribute accessor methods
//
@@ -112,48 +118,48 @@ public:
//
/**
- * @return Network_Clock_Header *
+ * @return mSpecializedSciMsgType
*/
- Network_Clock_Header * getSpecializedSciMsgHeader ( ) const;
+ Network_Clock_Type getSpecializedSciMsgType ( ) const;
/**
* @return bool
- * @param p_specialized_sci_msg_header
+ * @param type the new value of mSpecializedSciMsgType
*/
- bool setSpecializedSciMsgHeader ( const Network_Clock_Header * p_specialized_sci_msg_header );
-
+ bool setSpecializedSciMsgType ( const Network_Clock_Type type );
+
/**
- * @return Network_Clock_Type
+ * @return mSpecializedSciMsgId
*/
- Network_Clock_Type getSpecializedSciMsgType ( ) const;
+ Network_Clock_Id getSpecializedSciMsgId ( ) const;
/**
* @return bool
- * @param type
+ * @param id the new value of mSpecializedSciMsgId
*/
- bool setSpecializedSciMsgType ( const Network_Clock_Type type );
-
+ bool setSpecializedSciMsgId ( const Network_Clock_Id id );
+
/**
- * @return Network_Clock_Tick
+ * @return mSpecializedSciMsgTick
*/
Network_Clock_Tick getSpecializedSciMsgTick ( ) const;
/**
* @return bool
- * @param tick
+ * @param tick the new value of mSpecializedSciMsgTick
*/
bool setSpecializedSciMsgTick ( const Network_Clock_Tick tick );
- /**
- * @return Network_Clock_Id
+ /**
+ * @return mpSpecializedSciMsgHeader
*/
- Network_Clock_Id getSpecializedSciMsgId ( ) const;
+ Network_Clock_Header * getSpecializedSciMsgHeader ( ) const;
/**
* @return bool
- * @param id
+ * @param p_specialized_sci_msg_header
*/
- bool setSpecializedSciMsgId ( const Network_Clock_Id id );
+ bool setSpecializedSciMsgHeader ( const Network_Clock_Header * p_specialized_sci_msg_header );
// protected attribute accessor methods
//
@@ -165,7 +171,7 @@ private:
void initAttributes ( ) ;
- void displaySpecializedSciMsgHeader ( ) const;
+ void displaySpecializedSciMsgType ( ) const;
protected:
diff --git a/maximus/networkclock/inc/NetworkClockEvt.h b/maximus/networkclock/inc/NetworkClockEvt.h
index b5e028f993..954ac2899c 100644
--- a/maximus/networkclock/inc/NetworkClockEvt.h
+++ b/maximus/networkclock/inc/NetworkClockEvt.h
@@ -54,7 +54,7 @@ private:
// private attributes
//
- Sci_Station_Id mStationId;
+ Sci_Msg_Station_Id mStationId;
Network_Clock_Id mId;
Network_Clock_Type mType;
@@ -76,9 +76,9 @@ public:
/**
* Constructor
*/
- NetworkClockEvt ( const Sci_Station_Id station_id,
- const Network_Clock_Id id,
- const Network_Clock_Type type = NETWORK_CLOCK_TYPE_NONE );
+ NetworkClockEvt ( const Sci_Msg_Station_Id station_id,
+ const Network_Clock_Type type,
+ const Network_Clock_Id id );
/**
* Copy Constructors
@@ -111,13 +111,13 @@ public:
* @return bool
* @param station_id the new value of mStationId
*/
- bool setStationId ( const Sci_Station_Id station_id );
+ bool setStationId ( const Sci_Msg_Station_Id station_id );
/**
* Get the value of mStationId
* @return the value of mStationId
*/
- Sci_Station_Id getStationId ( ) const;
+ Sci_Msg_Station_Id getStationId ( ) const;
/**
* Set the value of mType
diff --git a/maximus/networkclock/src/ClockSciMsg.cpp b/maximus/networkclock/src/ClockSciMsg.cpp
index af6f777a4c..947efda137 100644
--- a/maximus/networkclock/src/ClockSciMsg.cpp
+++ b/maximus/networkclock/src/ClockSciMsg.cpp
@@ -32,7 +32,6 @@ The original location of this file is /home/buret/eclipse/maximus/networkclock/s
#include "NetworkClockProcessor.h"
#include "Error.h"
-//#include <cstring>
#include <iomanip> // for 'std::setfill' and 'std::setw'
#include <iostream> // for 'cout', 'clog' and 'cerr'
#include <netinet/in.h> // for 'ntohl' and 'ntohs' functions
@@ -44,8 +43,8 @@ using namespace std;
ClockSciMsg::ClockSciMsg ( ):
-mSpecializedSciMsgId(0),
mSpecializedSciMsgType(NETWORK_CLOCK_TYPE_NONE),
+mSpecializedSciMsgId(0),
mSpecializedSciMsgTick(0),
mpSpecializedSciMsgHeader(NULL),
mpNetworkClockProcessor(NULL)
@@ -57,8 +56,8 @@ mpNetworkClockProcessor(NULL)
ClockSciMsg::ClockSciMsg ( NetworkClockProcessor * p_network_clock_processor ):
-mSpecializedSciMsgId(0),
mSpecializedSciMsgType(NETWORK_CLOCK_TYPE_NONE),
+mSpecializedSciMsgId(0),
mSpecializedSciMsgTick(0),
mpSpecializedSciMsgHeader(NULL),
mpNetworkClockProcessor(NULL)
@@ -84,17 +83,13 @@ void ClockSciMsg::initAttributes ( )
mpSpecializedSciMsgHeader = new Network_Clock_Header;
if (NULL != mpSpecializedSciMsgHeader)
{
- mpSpecializedSciMsgHeader->version = 0;
- mpSpecializedSciMsgHeader->type = 0;
- mpSpecializedSciMsgHeader->id = 0;
- mpSpecializedSciMsgHeader->flags = 0;
- mpSpecializedSciMsgHeader->reserved = 0;
- mpSpecializedSciMsgHeader->tick_high = 0;
- mpSpecializedSciMsgHeader->tick_low = 0;
- }
- else
- {
- throw Error("ClockSciMsg::initAttributes", "Initialized Network_Clock_Header pointer is NULL");
+ mpSpecializedSciMsgHeader->version = NETWORK_CLOCK_VERSION;
+ mpSpecializedSciMsgHeader->type = 0x00;
+ mpSpecializedSciMsgHeader->id = 0x0000;
+ mpSpecializedSciMsgHeader->flags = 0x0000;
+ mpSpecializedSciMsgHeader->reserved = 0x0000;
+ mpSpecializedSciMsgHeader->tick_high = 0x00000000;
+ mpSpecializedSciMsgHeader->tick_low = 0x00000000;
}
}
@@ -108,6 +103,7 @@ ClockSciMsg::~ClockSciMsg ( )
delete (mpSpecializedSciMsgHeader);
mpSpecializedSciMsgHeader = NULL;
}
+
if (NULL != mpNetworkClockProcessor)
{
mpNetworkClockProcessor = NULL;
@@ -143,33 +139,29 @@ bool ClockSciMsg::dispatchMsg ( )
if (NULL != mpNetworkClockProcessor)
{
- if ( (NULL != SciMsg::getSciMsgHeader()) && (NULL != getSpecializedSciMsgHeader()) )
- {
- // Create event to insert or remove
- //
- NetworkClockEvt evtToDispatch ( SciMsg::getSciMsgHeader()->station_id,
- getSpecializedSciMsgId(),
- getSpecializedSciMsgType() );
+ // Create event to insert or remove
+ //
+ NetworkClockEvt evtToDispatch ( SciMsg::getSciMsgStationId(),
+ getSpecializedSciMsgType(),
+ getSpecializedSciMsgId() );
- // According to the clock SCI msg type, dispatch clock SCI msg
- //
- if ( NETWORK_CLOCK_TYPE_REMOVE == getSpecializedSciMsgType() )
- {
- bDispatch = mpNetworkClockProcessor->removeEvt (getSpecializedSciMsgTick(), evtToDispatch);
- }
- else
- {
- bDispatch = mpNetworkClockProcessor->insertEvt (getSpecializedSciMsgTick(), evtToDispatch);
- }
+ // According to the clock SCI msg type, dispatch clock SCI msg
+ //
+ if ( NETWORK_CLOCK_TYPE_REMOVE == getSpecializedSciMsgType() )
+ {
+ bDispatch = mpNetworkClockProcessor->removeEvt (getSpecializedSciMsgTick(), evtToDispatch);
}
else
{
- throw Error("ClockSciMsg::dispatchMsg", "Cannot dispatch clock SCI msg because clock SCI msg header and/or SCI msg header pointer is NULL");
+ if ( (0 < getSpecializedSciMsgType()) && (NETWORK_CLOCK_TYPE_NB > getSpecializedSciMsgType()) )
+ {
+ bDispatch = mpNetworkClockProcessor->insertEvt (getSpecializedSciMsgTick(), evtToDispatch);
+ }
}
}
else
{
- throw Error("ClockSciMsg::dispatchMsg", "Initialized NetworkClockProcessor pointer is NULL");
+ throw Error("ClockSciMsg::dispatchMsg", "Initialized network clock processor pointer is NULL");
}
return bDispatch;
@@ -185,33 +177,34 @@ bool ClockSciMsg::identifySpecializedSciMsgHeader ( )
if (NULL != SciMsg::getSciMsgData())
{
- // Get specialized SCI message header contents
+ // Set specialized SCI msg header size
//
SciMsg::setSpecializedSciMsgHeaderSize((unsigned long)sizeof(struct Network_Clock_Header));
+
+ // Get specialized SCI message header contents
+ //
if (SciMsg::getSciMsgDataLength() >= SciMsg::getSpecializedSciMsgHeaderSize()) // check that there are enough data to get the specialized SCI message header
{
if (NULL != mpSpecializedSciMsgHeader)
{
- clog << "\tdata = " << getSciMsgData() << endl;
-
*mpSpecializedSciMsgHeader = *((Network_Clock_Header*)SciMsg::getSciMsgData());
-
- mpSpecializedSciMsgHeader->id = ntohs(mpSpecializedSciMsgHeader->id);
- mSpecializedSciMsgId = static_cast<Network_Clock_Id>(mpSpecializedSciMsgHeader->id);
-
- mSpecializedSciMsgType = static_cast<Network_Clock_Type>(mpSpecializedSciMsgHeader->type);
-
+ getSpecializedSciMsgHeader()->id = ntohs(getSpecializedSciMsgHeader()->id);
+ getSpecializedSciMsgHeader()->flags = ntohs(getSpecializedSciMsgHeader()->flags);
+ getSpecializedSciMsgHeader()->reserved = ntohs(getSpecializedSciMsgHeader()->reserved);
+ getSpecializedSciMsgHeader()->tick_high = ntohl(getSpecializedSciMsgHeader()->tick_high);
+ getSpecializedSciMsgHeader()->tick_low = ntohl(getSpecializedSciMsgHeader()->tick_low);
+
// Recompose tick value
//
- mpSpecializedSciMsgHeader->tick_high = ntohl(mpSpecializedSciMsgHeader->tick_high);
- mpSpecializedSciMsgHeader->tick_low = ntohl(mpSpecializedSciMsgHeader->tick_low);
- uint64_t tempTickValue = (static_cast<uint64_t>(mpSpecializedSciMsgHeader->tick_high)<<32) + static_cast<uint64_t>(mpSpecializedSciMsgHeader->tick_low);
- clog << "\ttemp tick value = 0x" << hex << setfill('0') << setw(16) << uppercase << tempTickValue << endl;
- mSpecializedSciMsgTick = static_cast<Network_Clock_Tick>(tempTickValue);
- clog << "\ttick value = " << dec << mSpecializedSciMsgTick << endl;
+ uint64_t tempTickValue = (static_cast<uint64_t>(getSpecializedSciMsgHeader()->tick_high)<<32) + static_cast<uint64_t>(getSpecializedSciMsgHeader()->tick_low);
+
+ // Set specialized SCI msg attributes from specialized SCI msg header
+ //
+ bIdentifyHeader = setSpecializedSciMsgType (static_cast<Network_Clock_Type>(getSpecializedSciMsgHeader()->type));
+ bIdentifyHeader &= setSpecializedSciMsgId (static_cast<Network_Clock_Id>(getSpecializedSciMsgHeader()->id));
+ bIdentifyHeader &= setSpecializedSciMsgTick (static_cast<Network_Clock_Tick>(tempTickValue));
displaySpecializedSciMsgHeader();
- bIdentifyHeader = true;
}
}
else
@@ -221,7 +214,7 @@ bool ClockSciMsg::identifySpecializedSciMsgHeader ( )
}
else
{
- throw Error("ClockSciMsg::identifySpecializedSciMsgHeader", "Received data pointer is NULL");
+ throw Error("ClockSciMsg::identifySpecializedSciMsgHeader", "SCI msg data pointer is NULL");
}
return bIdentifyHeader;
@@ -230,12 +223,16 @@ bool ClockSciMsg::identifySpecializedSciMsgHeader ( )
void ClockSciMsg::displaySpecializedSciMsgHeader( ) const
{
- clog << "ClockSciMsg::displaySciMsgHeader" << endl;
-
clog << "\tclock SCI msg header = " << endl;
- clog << "\t\ttype = 0x" << hex << setfill('0') << setw(2) << uppercase << getSpecializedSciMsgType() << endl;
- clog << "\t\tid = 0x" << hex << setfill('0') << setw(4) << uppercase << getSpecializedSciMsgId() << endl;
- clog << "\t\ttick = 0x" << hex << setfill('0') << setw(8) << uppercase << getSpecializedSciMsgTick() << endl;
+ clog << "\t\tversion = " << dec << (unsigned short int)getSpecializedSciMsgHeader()->version << endl;
+ clog << "\t\ttype = ";
+ displaySpecializedSciMsgType();
+ clog << endl;
+ clog << "\t\tid = 0x" << setfill('0') << setw(4) << uppercase << hex << getSpecializedSciMsgId() << endl;
+ clog << "\t\tflags = 0x" << setfill('0') << setw(4) << uppercase << hex << getSpecializedSciMsgHeader()->flags << endl;
+ clog << "\t\treserved = 0x" << setfill('0') << setw(4) << uppercase << hex << getSpecializedSciMsgHeader()->reserved << endl;
+ clog << "\t\ttick = 0x" << setfill('0') << setw(8) << uppercase << hex << getSpecializedSciMsgHeader()->tick_high;
+ clog << setfill('0') << setw(8) << uppercase << hex << getSpecializedSciMsgHeader()->tick_low << endl;
}
@@ -243,6 +240,35 @@ void ClockSciMsg::displaySpecializedSciMsgHeader( ) const
//
+void ClockSciMsg::displaySpecializedSciMsgType ( ) const
+{
+ switch (getSpecializedSciMsgType())
+ {
+ case 0:
+ clog << "NETWORK_CLOCK_TYPE_NONE";
+ break;
+ case 1:
+ clog << "NETWORK_CLOCK_TYPE_REMOVE";
+ break;
+ case 2:
+ clog << "NETWORK_CLOCK_TYPE_STATION";
+ break;
+ case 3:
+ clog << "NETWORK_CLOCK_TYPE_FUNCTION_CALL";
+ break;
+ case 4:
+ clog << "NETWORK_CLOCK_TYPE_PHY";
+ break;
+ case 5:
+ clog << "NETWORK_CLOCK_TYPE_SYSTEM";
+ break;
+ default:
+ clog << "unknown";
+ break;
+ }
+}
+
+
// protected methods
//
@@ -259,45 +285,41 @@ void ClockSciMsg::displaySpecializedSciMsgHeader( ) const
//
-Network_Clock_Header * ClockSciMsg::getSpecializedSciMsgHeader ( ) const
+Network_Clock_Type ClockSciMsg::getSpecializedSciMsgType ( ) const
{
- return mpSpecializedSciMsgHeader;
+ return mSpecializedSciMsgType;
}
-bool ClockSciMsg::setSpecializedSciMsgHeader ( const Network_Clock_Header * p_specialized_sci_msg_header )
+bool ClockSciMsg::setSpecializedSciMsgType ( const Network_Clock_Type type )
{
- clog << "ClockSciMsg::setSpecializedSciMsgHeader" << endl;
- bool bSetHeader = false;
+ clog << "ClockSciMsg::setSpecializedSciMsgType" << endl;
+ bool bSetType = true;
- if ( (NULL != p_specialized_sci_msg_header) && (NULL != mpSpecializedSciMsgHeader) )
- {
- *mpSpecializedSciMsgHeader = *p_specialized_sci_msg_header;
- displaySpecializedSciMsgHeader();
- }
- else
- {
- throw Error("ClockSciMsg::setSpecializedSciMsgHeader", "Received and/or initialized Network_Clock_Header pointer is NULL");
- }
-
- return bSetHeader;
+ mSpecializedSciMsgType = type;
+ clog << "\tspecialized SCI msg type = ";
+ displaySpecializedSciMsgType();
+ clog << endl;
+
+ return bSetType;
}
-Network_Clock_Type ClockSciMsg::getSpecializedSciMsgType ( ) const
+Network_Clock_Id ClockSciMsg::getSpecializedSciMsgId ( ) const
{
- return mSpecializedSciMsgType;
+ return mSpecializedSciMsgId;
}
-bool ClockSciMsg::setSpecializedSciMsgType ( const Network_Clock_Type type )
+bool ClockSciMsg::setSpecializedSciMsgId ( const Network_Clock_Id id )
{
- clog << "ClockSciMsg::setSpecializedSciMsgType" << endl;
+ clog << "ClockSciMsg::setSpecializedSciMsgId" << endl;
+ bool bSetId = true;
- mSpecializedSciMsgType = type;
- clog << "\tspecialized SCI msg type = " << mSpecializedSciMsgType << endl;
+ mSpecializedSciMsgId = id;
+ clog << "\tspecialized SCI msg id = " << dec << getSpecializedSciMsgId() << endl;
- return true;
+ return bSetId;
}
@@ -307,12 +329,42 @@ Network_Clock_Tick ClockSciMsg::getSpecializedSciMsgTick ( ) const
}
-Network_Clock_Id ClockSciMsg::getSpecializedSciMsgId ( ) const
+bool ClockSciMsg::setSpecializedSciMsgTick ( const Network_Clock_Tick tick )
{
- return mSpecializedSciMsgId;
+ clog << "ClockSciMsg::setSpecializedSciMsgTick" << endl;
+ bool bSetTick = true;
+
+ mSpecializedSciMsgTick = tick;
+ clog << "\tspecialized SCI msg tick = " << getSpecializedSciMsgTick() << endl;
+
+ return bSetTick;
}
+Network_Clock_Header * ClockSciMsg::getSpecializedSciMsgHeader ( ) const
+{
+ return mpSpecializedSciMsgHeader;
+}
+
+
+bool ClockSciMsg::setSpecializedSciMsgHeader ( const Network_Clock_Header * p_specialized_sci_msg_header )
+{
+ clog << "ClockSciMsg::setSpecializedSciMsgHeader" << endl;
+ bool bSetHeader = false;
+
+ if ( (NULL != p_specialized_sci_msg_header) && (NULL != mpSpecializedSciMsgHeader) )
+ {
+ *mpSpecializedSciMsgHeader = *p_specialized_sci_msg_header;
+ displaySpecializedSciMsgHeader();
+ }
+ else
+ {
+ throw Error("ClockSciMsg::setSpecializedSciMsgHeader", "Received and/or initialized network clock header pointer is NULL");
+ }
+
+ return bSetHeader;
+}
+
// protected attribute accessor methods
//
diff --git a/maximus/networkclock/src/NetworkClockEvt.cpp b/maximus/networkclock/src/NetworkClockEvt.cpp
index e3c3127566..379f48aac6 100644
--- a/maximus/networkclock/src/NetworkClockEvt.cpp
+++ b/maximus/networkclock/src/NetworkClockEvt.cpp
@@ -51,9 +51,9 @@ mType(NETWORK_CLOCK_TYPE_NONE)
initAttributes();
}
-NetworkClockEvt::NetworkClockEvt ( const Sci_Station_Id station_id,
- const Network_Clock_Id id,
- const Network_Clock_Type type )
+NetworkClockEvt::NetworkClockEvt ( const Sci_Msg_Station_Id station_id,
+ const Network_Clock_Type type,
+ const Network_Clock_Id id )
{
clog << "NetworkClockEvt(...)" << endl;
@@ -179,7 +179,7 @@ void NetworkClockEvt::display ( ) const
//
-bool NetworkClockEvt::setStationId ( const Sci_Station_Id station_id )
+bool NetworkClockEvt::setStationId ( const Sci_Msg_Station_Id station_id )
{
clog << "NetworkClockEvt::setStationId" << endl;
@@ -190,7 +190,7 @@ bool NetworkClockEvt::setStationId ( const Sci_Station_Id station_id )
}
-Sci_Station_Id NetworkClockEvt::getStationId ( ) const
+Sci_Msg_Station_Id NetworkClockEvt::getStationId ( ) const
{
return mStationId;
}
diff --git a/maximus/networkclock/src/NetworkClockProcessor.cpp b/maximus/networkclock/src/NetworkClockProcessor.cpp
index f850700ff9..048302b206 100644
--- a/maximus/networkclock/src/NetworkClockProcessor.cpp
+++ b/maximus/networkclock/src/NetworkClockProcessor.cpp
@@ -284,21 +284,47 @@ bool NetworkClockProcessor::processEvtStation ( NetworkClockEvt & evt_to_process
uint32_t netclockHigh=0, netclockLow=0;
netclockLow = (uint32_t)(getCurrentTickValue());
netclockHigh = (uint32_t)(((uint64_t)(getCurrentTickValue()) >> 32));
- clog << "\tMSB = 0x" << hex << setfill('0') << setw(8) << uppercase << netclockHigh << " and LSB = 0x" << setfill('0') << setw(8) << uppercase << netclockLow << dec << endl;
-
+
+ // Fill specialized SCI msg header
+ //
struct Network_Clock_Header clockSciMsgHeader = { NETWORK_CLOCK_VERSION,
- evt_to_process.getType(),
- evt_to_process.getId(),
- 0, // flags
- 0, // reserved
+ static_cast<uint8_t>(evt_to_process.getType()),
+ static_cast<uint16_t>(evt_to_process.getId()),
+ 0x0000, // flags
+ 0x0000, // reserved
netclockHigh,
netclockLow };
bProcessStation = clockSciMsgToSend.setSpecializedSciMsgHeader(&clockSciMsgHeader);
+
+ // Fill specialized SCI msg data length and specialized SCI msg data
+ //
bProcessStation &= clockSciMsgToSend.setSpecializedSciMsgDataLength(0);
bProcessStation &= clockSciMsgToSend.setSpecializedSciMsgData(NULL);
- bProcessStation &= clockSciMsgToSend.setSciMsgDataLength(sizeof(struct Network_Clock_Header) + clockSciMsgToSend.getSpecializedSciMsgDataLength());
+ // Fill SCI msg data length and SCI msg data
+ //
+ bProcessStation &= clockSciMsgToSend.setSciMsgDataLength(static_cast<unsigned long>(sizeof(struct Network_Clock_Header)) + clockSciMsgToSend.getSpecializedSciMsgDataLength());
+ unsigned char * pTempData = new unsigned char [clockSciMsgToSend.getSciMsgDataLength()];
+ if (NULL != pTempData)
+ {
+ *(pTempData) = static_cast<unsigned char>(clockSciMsgToSend.getSpecializedSciMsgHeader()->version);
+ *(pTempData+1) = static_cast<unsigned char>(clockSciMsgToSend.getSpecializedSciMsgHeader()->type);
+ *(pTempData+2) = static_cast<unsigned char>(clockSciMsgToSend.getSpecializedSciMsgHeader()->id);
+ *(pTempData+4) = static_cast<unsigned char>(clockSciMsgToSend.getSpecializedSciMsgHeader()->flags);
+ *(pTempData+6) = static_cast<unsigned char>(clockSciMsgToSend.getSpecializedSciMsgHeader()->reserved);
+ *(pTempData+12) = static_cast<unsigned char>(clockSciMsgToSend.getSpecializedSciMsgHeader()->tick_high);
+ *(pTempData+16) = static_cast<unsigned char>(clockSciMsgToSend.getSpecializedSciMsgHeader()->tick_low);
+ for (unsigned int j=0; j<(clockSciMsgToSend.getSciMsgDataLength()-sizeof(struct Network_Clock_Header)); j++)
+ {
+ *(pTempData+j+sizeof(struct Network_Clock_Header)) = *(clockSciMsgToSend.getSpecializedSciMsgData()+j);
+ }
+ }
+ bProcessStation &= clockSciMsgToSend.setSciMsgData(pTempData);
+
//bProcessStation &= clockSciMsgToSend.setSciMsgData();
+
+ // Fill SCI msg header
+ //
struct Sci_Msg_Header sciMsgHeader = { (uint32_t)SCI_MSG_MAGIC,
SCI_MSG_VERSION,
SCI_MSG_TYPE_NETWORK_CLOCK,
@@ -311,9 +337,16 @@ bool NetworkClockProcessor::processEvtStation ( NetworkClockEvt & evt_to_process
0 }; // reserved
bProcessStation &= clockSciMsgToSend.setSciMsgHeader(&sciMsgHeader);
+ // Free temporary allocated memory
+ //
+ if (NULL != pTempData)
+ {
+ delete [] pTempData;
+ pTempData = NULL;
+ }
+
if (bProcessStation)
{
- clog << "\tsends event to station" << endl;
bProcessStation = sendEvtMsg (clockSciMsgToSend);
}
else
diff --git a/maximus/networkclock/src/NetworkClockProcessorTest.cpp b/maximus/networkclock/src/NetworkClockProcessorTest.cpp
index 7d117de5db..767c0c0553 100644
--- a/maximus/networkclock/src/NetworkClockProcessorTest.cpp
+++ b/maximus/networkclock/src/NetworkClockProcessorTest.cpp
@@ -91,7 +91,7 @@ void NetworkClockProcessorTest::createEvtTest (void)
try
{
clog << "\tNetworkClockProcessorTest -> NetworkClockEvt(...)" << endl;
- NetworkClockEvt evt (123, 456);
+ NetworkClockEvt evt (123, NETWORK_CLOCK_TYPE_NONE, 456);
clog << "\tNetworkClockProcessorTest -> NetworkClockProcessor::createEvt" << endl;
mpNetworkClockProcessor->createEvt(555, evt);
}
@@ -123,7 +123,7 @@ void NetworkClockProcessorTest::removeEvtTest (void)
try
{
clog << "\tNetworkClockProcessorTest -> NetworkClockEvt(...)" << endl;
- NetworkClockEvt evt (789, 1011);
+ NetworkClockEvt evt (789, NETWORK_CLOCK_TYPE_NONE, 1011);
clog << "\tNetworkClockProcessorTest -> NetworkClockProcessor::removeEvt" << endl;
CPPUNIT_ASSERT_MESSAGE ( CPPUNIT_NS::Message("removeEvt failed"),
@@ -164,7 +164,7 @@ void NetworkClockProcessorTest::processNextEvtTest (void)
{
try
{
- Sci_Station_Id stationId = 0;
+ Sci_Msg_Station_Id stationId = 0;
Station * station = mpSystemManager->createStation(); // will be deleted by SystemManager
if (NULL != station)
{
@@ -172,7 +172,7 @@ void NetworkClockProcessorTest::processNextEvtTest (void)
}
clog << "\tNetworkClockProcessorTest -> NetworkClockEvt(...)" << endl;
- NetworkClockEvt evt (stationId, 0, NETWORK_CLOCK_TYPE_STATION);
+ NetworkClockEvt evt (stationId, NETWORK_CLOCK_TYPE_STATION, 0);
clog << "\tNetworkClockProcessorTest -> NetworkClockProcessor::insertEvt" << endl;
CPPUNIT_ASSERT_MESSAGE ( CPPUNIT_NS::Message("insertEvt failed"),
@@ -221,7 +221,7 @@ void NetworkClockProcessorTest::processEvtStationTest (void)
try
{
clog << "\tNetworkClockProcessorTest -> NetworkClockEvt(...)" << endl;
- NetworkClockEvt evt (2021, 2324, NETWORK_CLOCK_TYPE_STATION);
+ NetworkClockEvt evt (2021, NETWORK_CLOCK_TYPE_STATION, 2324);
clog << "\tNetworkClockProcessorTest -> NetworkClockProcessor::processEvtStation" << endl;
CPPUNIT_ASSERT_MESSAGE ( CPPUNIT_NS::Message("processEvtStation failed"),
diff --git a/maximus/phy/inc/PhyProcessor.h b/maximus/phy/inc/PhyProcessor.h
index b8d8ef7c0c..85cb56ca7d 100644
--- a/maximus/phy/inc/PhyProcessor.h
+++ b/maximus/phy/inc/PhyProcessor.h
@@ -31,7 +31,6 @@ The original location of this file is /home/buret/eclipse/maximus/phy/inc/PhyPro
#ifndef PHYPROCESSOR_H
#define PHYPROCESSOR_H
#include "IPhy.h"
-#include "phy_types.h"
#include "networkclock_types.h"
class Station;
@@ -88,47 +87,47 @@ public:
// public methods
//
- /**
+ /**
* @return bool
- * @param station1
- * @param station2
+ * @param station1_id
+ * @param station2_id
* @param link_quality
*/
- bool checkLinkQuality ( const Station * station1, const Station * station2, Phy_Link_Quality & link_quality ) const;
+ bool checkLinkQuality ( const Sci_Msg_Station_Id station1_id, const Sci_Msg_Station_Id station2_id, Phy_Link_Quality & link_quality ) const;
/**
* @return bool
- * @param station1
- * @param station2
+ * @param station1_id
+ * @param station2_id
* @param link_quality
*/
- bool manageLinkQuality ( const Station * station1, const Station * station2, const Phy_Link_Quality link_quality );
+ bool manageLinkQuality ( const Sci_Msg_Station_Id station1_id, const Sci_Msg_Station_Id station2_id, const Phy_Link_Quality link_quality );
/**
* @return bool
- * @param destination_station
+ * @param destination_station_id
* @param data_length
- * @param data
+ * @param p_data
*/
- bool sendEthernetData ( const Station * destination_station, const short int data_length, const unsigned char * data ) const;
+ bool sendEthernetData ( const Sci_Msg_Station_Id destination_station_id, const unsigned long data_length, const unsigned char * p_data ) const;
/**
* @return bool
- * @param destination_station
+ * @param destination_station_id
* @param mpdu_format
* @param fc_10
* @param fc_av
* @param nb_of_pbs
* @param pb_size
- * @param mpdu_payload
+ * @param p_mpdu_payload
*/
- bool sendAvData ( const Station * destination_station,
- const char mpdu_format,
+ bool sendAvData ( const Sci_Msg_Station_Id destination_station_id,
+ const Phy_Mpdu_Format mpdu_format,
const unsigned long fc_10,
const unsigned long fc_av[4],
- const unsigned char nb_of_pbs,
- const char pb_size,
- const unsigned char * mpdu_payload ) const;
+ const Phy_Pbs_Number nb_of_pbs,
+ const Phy_Pb_Size pb_size,
+ const unsigned char * p_mpdu_payload ) const;
// public attribute accessor methods
//
diff --git a/maximus/phy/inc/PhySciMsg.h b/maximus/phy/inc/PhySciMsg.h
index a1c0407dfe..d0457b4957 100644
--- a/maximus/phy/inc/PhySciMsg.h
+++ b/maximus/phy/inc/PhySciMsg.h
@@ -53,17 +53,24 @@ private:
// private attributes
//
-
- Sci_Station_Id mStationId;
- PhyProcessor * mpPhyProcessor;
- bool mPreamblePresent;
+
+ // Get from specialized SCI msg header
+ //
Phy_Type mSpecializedSciMsgType;
- Phy_Link_Quality mLinkQuality;
- Phy_Sci_Msg_Mpdu_Format mMpduFormat;
- Phy_Sci_Msg_Data_Type mDataType;
- Phy_Sci_Msg_Pb_Size mPbSize;
+ Phy_Mpdu_Format mSpecializedSciMsgMpduFormat;
+ Phy_Data_Type mSpecializedSciMsgDataType;
+ Phy_Pbs_Number mSpecializedSciMsgPbsNumber;
+ Phy_Pb_Size mSpecializedSciMsgPbSize;
+ Phy_Flag mSpecializedSciMsgFlag;
+
+ // Specialized SCI msg header
+ //
Phy_Header * mpSpecializedSciMsgHeader;
+ Phy_Link_Quality mLinkQuality;
+
+ PhyProcessor * mpPhyProcessor;
+
protected:
// protected attributes
@@ -104,49 +111,25 @@ public:
/**
* @return bool
- * @param data_length
- * @param p_data
*/
bool identifySpecializedSciMsgHeader ( );
+ void displaySpecializedSciMsgHeader ( ) const;
+
// public attribute accessor methods
//
- /**
- * Set the value of mPreamblePresent
- * @return bool
- * @param preamble_present the new value of mPreamblePresent
- */
- bool setPreamblePresent ( bool preamble_present );
-
- /**
- * Get the value of mPreamblePresent
- * @return the value of mPreamblePresent
- */
- bool isPreamblePresent ( ) const;
-
// private attribute accessor methods
//
/**
- * @return Sci_Station_Id
- */
- Sci_Station_Id getStationId ( ) const;
-
- /**
- * @return bool
- * @param station_id
- */
- bool setStationId ( const Sci_Station_Id station_id );
-
- /**
- * @return Phy_Header *
+ * @return mpSpecializedSciMsgHeader
*/
Phy_Header * getSpecializedSciMsgHeader ( ) const;
/**
* @return bool
- * @param p_specialized_sci_msg_header
+ * @param p_specialized_sci_msg_header the new value of mpSpecializedSciMsgHeader
*/
bool setSpecializedSciMsgHeader ( const Phy_Header * p_specialized_sci_msg_header );
diff --git a/maximus/phy/src/PhyProcessor.cpp b/maximus/phy/src/PhyProcessor.cpp
index ca724d153e..745d897fbd 100644
--- a/maximus/phy/src/PhyProcessor.cpp
+++ b/maximus/phy/src/PhyProcessor.cpp
@@ -110,30 +110,33 @@ PhyProcessor::~PhyProcessor ( )
//
-bool PhyProcessor::checkLinkQuality ( const Station * station1, const Station * station2, Phy_Link_Quality & link_quality ) const
+bool PhyProcessor::checkLinkQuality ( const Sci_Msg_Station_Id station1_id, const Sci_Msg_Station_Id station2_id, Phy_Link_Quality & link_quality ) const
{
- return false;
+ return true;
}
-bool PhyProcessor::manageLinkQuality ( const Station * station1, const Station * station2, const Phy_Link_Quality link_quality )
+
+bool PhyProcessor::manageLinkQuality ( const Sci_Msg_Station_Id station1_id, const Sci_Msg_Station_Id station2_id, const Phy_Link_Quality link_quality )
{
- return false;
+ return true;
}
-bool PhyProcessor::sendEthernetData ( const Station * destination_station, const short int data_length, const unsigned char * data ) const
+
+bool PhyProcessor::sendEthernetData ( const Sci_Msg_Station_Id destination_station_id, const unsigned long data_length, const unsigned char * p_data ) const
{
- return false;
+ return true;
}
-bool PhyProcessor::sendAvData ( const Station * destination_station,
- const char mpdu_format,
+
+bool PhyProcessor::sendAvData ( const Sci_Msg_Station_Id destination_station_id,
+ const Phy_Mpdu_Format mpdu_format,
const unsigned long fc_10,
const unsigned long fc_av[4],
- const unsigned char nb_of_pbs,
- const char pb_size,
- const unsigned char * mpdu_payload ) const
+ const Phy_Pbs_Number nb_of_pbs,
+ const Phy_Pb_Size pb_size,
+ const unsigned char * p_mpdu_payload ) const
{
- return false;
+ return true;
}
@@ -141,24 +144,6 @@ bool PhyProcessor::sendAvData ( const Station * destination_station,
//
-void PhyProcessor::relayAvData ( )
-{
-
-}
-
-
-void PhyProcessor::decodeFrameControl ( )
-{
-
-}
-
-
-void PhyProcessor::addHeaderInfo ( )
-{
-
-}
-
-
void PhyProcessor::registerPhySciMsg ( )
{
clog << "PhyProcessor::registerPhySciMsg" << endl;
diff --git a/maximus/phy/src/PhySciMsg.cpp b/maximus/phy/src/PhySciMsg.cpp
index 797780044f..9d4d2f990f 100644
--- a/maximus/phy/src/PhySciMsg.cpp
+++ b/maximus/phy/src/PhySciMsg.cpp
@@ -32,6 +32,8 @@ The original location of this file is /home/buret/eclipse/maximus/phy/src/PhySci
#include "PhyProcessor.h"
#include "Error.h"
+#include <iomanip> // for 'std::setfill' and 'std::setw'
+#include <netinet/in.h> // for 'ntohl' and 'ntohs' functions
#include <iostream> // for 'cout', 'cerr' and 'clog'
using namespace std;
@@ -41,14 +43,15 @@ using namespace std;
PhySciMsg::PhySciMsg ( ):
-mpPhyProcessor(NULL),
-mPreamblePresent(false),
mSpecializedSciMsgType(PHY_TYPE_NONE),
+mSpecializedSciMsgMpduFormat(MAXIMUS_PHY_MPDU_FORMAT_NONE),
+mSpecializedSciMsgDataType(MAXIMUS_PHY_DATA_TYPE_NONE),
+mSpecializedSciMsgPbsNumber(0),
+mSpecializedSciMsgPbSize(MAXIMUS_PHY_PB_SIZE_NONE),
+mSpecializedSciMsgFlag(MAXIMUS_PHY_FLAG_NONE),
+mpSpecializedSciMsgHeader(NULL),
mLinkQuality(MAXIMUS_PHY_LINK_QUALITY_OK),
-mMpduFormat(MAXIMUS_PHY_SCI_MSG_MPDU_FORMAT_NONE),
-mDataType(MAXIMUS_PHY_SCI_MSG_DATA_TYPE_NONE),
-mPbSize(MAXIMUS_PHY_SCI_MSG_PB_SIZE_NONE),
-mpSpecializedSciMsgHeader(NULL)
+mpPhyProcessor(NULL)
{
clog << "PhySciMsg()" << endl;
@@ -57,25 +60,27 @@ mpSpecializedSciMsgHeader(NULL)
PhySciMsg::PhySciMsg ( PhyProcessor * p_phy_processor ):
-mpPhyProcessor(NULL),
-mPreamblePresent(false),
mSpecializedSciMsgType(PHY_TYPE_NONE),
+mSpecializedSciMsgMpduFormat(MAXIMUS_PHY_MPDU_FORMAT_NONE),
+mSpecializedSciMsgDataType(MAXIMUS_PHY_DATA_TYPE_NONE),
+mSpecializedSciMsgPbsNumber(0),
+mSpecializedSciMsgPbSize(MAXIMUS_PHY_PB_SIZE_NONE),
+mSpecializedSciMsgFlag(MAXIMUS_PHY_FLAG_NONE),
+mpSpecializedSciMsgHeader(NULL),
mLinkQuality(MAXIMUS_PHY_LINK_QUALITY_OK),
-mMpduFormat(MAXIMUS_PHY_SCI_MSG_MPDU_FORMAT_NONE),
-mDataType(MAXIMUS_PHY_SCI_MSG_DATA_TYPE_NONE),
-mPbSize(MAXIMUS_PHY_SCI_MSG_PB_SIZE_NONE),
-mpSpecializedSciMsgHeader(NULL)
+mpPhyProcessor(NULL)
{
clog << "PhySciMsg(PhyProcessor*)" << endl;
initAttributes ();
+
if (NULL != p_phy_processor)
{
mpPhyProcessor = p_phy_processor;
}
else
{
- throw Error("PhySciMsg(PhyProcessor*)", "Received PhyProcessor pointer is NULL");
+ throw Error("PhySciMsg(PhyProcessor*)", "Received PHY processor pointer is NULL");
}
}
@@ -88,18 +93,14 @@ void PhySciMsg::initAttributes ( )
if (NULL != mpSpecializedSciMsgHeader)
{
mpSpecializedSciMsgHeader->version = PHY_VERSION;
- mpSpecializedSciMsgHeader->type = 0;
- mpSpecializedSciMsgHeader->nek = 0;
- mpSpecializedSciMsgHeader->mpdu_format = 0;
- mpSpecializedSciMsgHeader->data_type = 0;
- mpSpecializedSciMsgHeader->nb_of_pbs = 0;
- mpSpecializedSciMsgHeader->pb_size = 0;
- mpSpecializedSciMsgHeader->reserved = 0;
- mpSpecializedSciMsgHeader->flags = 0;
- }
- else
- {
- throw Error("PhySciMsg::initAttributes", "Initialized Phy_Sci_Msg_Header pointer is NULL");
+ mpSpecializedSciMsgHeader->type = 0x00;
+ mpSpecializedSciMsgHeader->nek = 0x0000;
+ mpSpecializedSciMsgHeader->mpdu_format = 0x00;
+ mpSpecializedSciMsgHeader->data_type = 0x00;
+ mpSpecializedSciMsgHeader->nb_of_pbs = 0x0000;
+ mpSpecializedSciMsgHeader->pb_size = 0x00;
+ mpSpecializedSciMsgHeader->reserved = 0x0000;
+ mpSpecializedSciMsgHeader->flags = 0x0000;
}
}
@@ -113,6 +114,7 @@ PhySciMsg::~PhySciMsg ( )
delete (mpSpecializedSciMsgHeader);
mpSpecializedSciMsgHeader = NULL;
}
+
if (NULL != mpPhyProcessor)
{
mpPhyProcessor = NULL;
@@ -161,14 +163,23 @@ bool PhySciMsg::identifySpecializedSciMsgHeader ( )
if (NULL != SciMsg::getSciMsgData())
{
- // Get specialized SCI message header contents
+ // Set specialized SCI msg header size
//
SciMsg::setSpecializedSciMsgHeaderSize((unsigned long)sizeof(struct Phy_Header));
+
+ // Get specialized SCI message header contents
+ //
if (SciMsg::getSciMsgDataLength() >= SciMsg::getSpecializedSciMsgHeaderSize()) // check that there are enough data to get the specialized SCI message header
{
if (NULL != mpSpecializedSciMsgHeader)
{
*mpSpecializedSciMsgHeader = *((Phy_Header*)SciMsg::getSciMsgData());
+ getSpecializedSciMsgHeader()->nek = ntohs(getSpecializedSciMsgHeader()->nek);
+ getSpecializedSciMsgHeader()->nb_of_pbs = ntohs(getSpecializedSciMsgHeader()->nb_of_pbs);
+ getSpecializedSciMsgHeader()->reserved = ntohs(getSpecializedSciMsgHeader()->reserved);
+ getSpecializedSciMsgHeader()->flags = ntohl(getSpecializedSciMsgHeader()->flags);
+
+ displaySpecializedSciMsgHeader();
bIdentifyHeader = true;
}
}
@@ -179,13 +190,28 @@ bool PhySciMsg::identifySpecializedSciMsgHeader ( )
}
else
{
- throw Error("PhySciMsg::identifySpecializedSciMsgHeader", "Received data pointer is NULL");
+ throw Error("PhySciMsg::identifySpecializedSciMsgHeader", "SCI msg data pointer is NULL");
}
return bIdentifyHeader;
}
+void PhySciMsg::displaySpecializedSciMsgHeader ( ) const
+{
+ clog << "\tPHY SCI msg header = " << endl;
+ clog << "\t\tversion = " << dec << static_cast<unsigned short int>(getSpecializedSciMsgHeader()->version) << endl;
+ clog << "\t\ttype = "<< dec << static_cast<unsigned short int>(getSpecializedSciMsgHeader()->type) << endl;
+ clog << "\t\tnek = 0x" << setfill('0') << setw(4) << uppercase << hex << getSpecializedSciMsgHeader()->nek << endl;
+ clog << "\t\tmpdu_format = " << dec << static_cast<unsigned short int>(getSpecializedSciMsgHeader()->mpdu_format) << endl;
+ clog << "\t\tdata_type = " << dec << static_cast<unsigned short int>(getSpecializedSciMsgHeader()->data_type) << endl;
+ clog << "\t\tnb_of_pbs = 0x" << setfill('0') << setw(4) << uppercase << hex << getSpecializedSciMsgHeader()->nb_of_pbs << endl;
+ clog << "\t\tpb_size = " << dec << static_cast<unsigned short int>(getSpecializedSciMsgHeader()->pb_size) << endl;
+ clog << "\t\treserved = 0x" << setfill('0') << setw(4) << uppercase << hex << getSpecializedSciMsgHeader()->reserved << endl;
+ clog << "\t\tflags = 0x" << setfill('0') << setw(4) << uppercase << hex << getSpecializedSciMsgHeader()->flags << endl;
+}
+
+
// private methods
//
@@ -206,41 +232,6 @@ bool PhySciMsg::identifySpecializedSciMsgHeader ( )
//
-Sci_Station_Id PhySciMsg::getStationId ( ) const
-{
- return mStationId;
-}
-
-
-bool PhySciMsg::setStationId ( const Sci_Station_Id station_id )
-{
- clog << "PhySciMsg::setStationId" << endl;
-
- mStationId = station_id;
- clog << "\tstation id = " << mStationId << endl;
-
- return true;
-}
-
-
-bool PhySciMsg::setPreamblePresent ( bool preamble_present )
-{
- clog << "PhySciMsg::setPreamblePresent" << endl;
-
- mPreamblePresent = preamble_present;
-
- return true;
-}
-
-
-bool PhySciMsg::isPreamblePresent ( ) const
-{
- clog << "PhySciMsg::isPreamblePresent" << endl;
-
- return mPreamblePresent;
-}
-
-
Phy_Header * PhySciMsg::getSpecializedSciMsgHeader ( ) const
{
return mpSpecializedSciMsgHeader;
@@ -255,10 +246,11 @@ bool PhySciMsg::setSpecializedSciMsgHeader ( const Phy_Header * p_specialized_sc
if ( (NULL != p_specialized_sci_msg_header) && (NULL != mpSpecializedSciMsgHeader) )
{
*mpSpecializedSciMsgHeader = *p_specialized_sci_msg_header;
+ displaySpecializedSciMsgHeader();
}
else
{
- throw Error("PhySciMsg::setSpecializedSciMsgHeader", "Received and/or initialized Phy_Header pointer is NULL");
+ throw Error("PhySciMsg::setSpecializedSciMsgHeader", "PHY header pointer is NULL");
}
return bSetHeader;
diff --git a/maximus/sci/inc/SciMsg.h b/maximus/sci/inc/SciMsg.h
index b7afe5bcff..1f7d3d09e0 100644
--- a/maximus/sci/inc/SciMsg.h
+++ b/maximus/sci/inc/SciMsg.h
@@ -33,8 +33,6 @@ The original location of this file is /home/buret/eclipse/maximus/sci/inc/SciMsg
#include "sci_types.h"
-class Station;
-
/**
* class SciMsg
@@ -54,9 +52,15 @@ private:
//
Sci_Msg_Status mSciMsgStatus; // NOT USED YET
- Sci_Msg_Flag mSciMsgFlag; // NOT USED YET
+
+ // Get from SCI message header
+ //
Sci_Msg_Type mSciMsgType;
+ Sci_Msg_Station_Id mSciMsgStationId;
+ Sci_Msg_Flag mSciMsgFlag;
+ // SCI message header, SCI message data length, and SCI message data
+ //
Sci_Msg_Header * mpSciMsgHeader;
unsigned long mSciMsgDataLength;
unsigned char * mpSciMsgData;
@@ -66,6 +70,8 @@ protected:
// protected attributes
//
+ // Specialized SCI message header size, specialized SCI message data length, and specialized SCI message data
+ //
unsigned long mSpecializedSciMsgHeaderSize;
unsigned long mSpecializedSciMsgDataLength;
unsigned char * mpSpecializedSciMsgData;
@@ -84,7 +90,7 @@ public:
* Copy Constructors
*/
SciMsg ( const SciMsg & sci_msg );
- SciMsg ( const SciMsg * sci_msg );
+ SciMsg ( const SciMsg * p_sci_msg );
/**
* Empty Destructor
@@ -106,18 +112,22 @@ public:
/**
* @return bool
- * @param data_length
- * @param p_data
*/
virtual bool identifySpecializedSciMsgHeader ( ) = 0;
/**
* @return bool
- * @param data_length
- * @param p_data
*/
bool identifySpecializedSciMsgData ( );
+ void displaySciMsgHeader ( ) const;
+
+ void displaySciMsgData ( ) const;
+
+ virtual void displaySpecializedSciMsgHeader ( ) const = 0;
+
+ void displaySpecializedSciMsgData ( ) const;
+
// public attribute accessor methods
//
@@ -125,20 +135,18 @@ public:
//
/**
- * Set the value of mpSciMsgHeader->station_id
- * @return bool
- * @param station_id the new value of mpSciMsgHeader->station_id
+ * @return mSciMsgStatus
*/
- bool setStationId ( const uint16_t station_id );
+ Sci_Msg_Status getSciMsgStatus ( ) const;
/**
- * Get the value of mpSciMsgHeader->station_id
- * @return the value of mpSciMsgHeader->station_id
+ * @return bool
+ * @param status the new value of mSciMsgStatus
*/
- uint16_t getStationId ( ) const;
+ bool setSciMsgStatus ( const Sci_Msg_Status status );
/**
- * @return Sci_Msg_Type
+ * @return the value of mSciMsgType
*/
Sci_Msg_Type getSciMsgType ( ) const;
@@ -149,39 +157,46 @@ public:
bool setSciMsgType ( const Sci_Msg_Type type );
/**
- * @return Sci_Msg_Flag
+ * Get the value of mSciMsgStationId
+ * @return the value of mSciMsgStationId
*/
- Sci_Msg_Flag getSciMsgFlag ( ) const;
+ Sci_Msg_Station_Id getSciMsgStationId ( ) const;
/**
- * @return Sci_Msg_Status
+ * Set the value of mSciMsgStationId
+ * @return bool
+ * @param station_id the new value of mSciMsgStationId
*/
- Sci_Msg_Status getSciMsgStatus ( ) const;
-
+ bool setSciMsgStationId ( const Sci_Msg_Station_Id station_id );
+
+ /**
+ * @return the value of mSciMsgFlag
+ */
+ Sci_Msg_Flag getSciMsgFlag ( ) const;
+
/**
* @return bool
- * @param sci_msg_header
+ * @param flag the new value of mSciMsgFlag
*/
- bool setSciMsgHeader ( const Sci_Msg_Header * p_sci_msg_header );
-
+ bool setSciMsgFlag ( const Sci_Msg_Flag flag );
+
/**
- * @return Sci_Msg_Header *
+ * @return mpSciMsgHeader
*/
Sci_Msg_Header * getSciMsgHeader ( ) const;
-
+
/**
- * Set the value of mpSciMsgData
* @return bool
- * @param p_data the new value of mpSciMsgData
+ * @param p_sci_msg_header the new value of mpSciMsgHeader
*/
- bool setSciMsgData ( const unsigned char * p_data );
+ bool setSciMsgHeader ( const Sci_Msg_Header * p_sci_msg_header );
/**
- * Get the value of mpSciMsgData
- * @return the value of mpSciMsgData
+ * Get the value of mSciMsgDataLength
+ * @return the value of mSciMsgDataLength
*/
- unsigned char * getSciMsgData ( ) const;
-
+ unsigned long getSciMsgDataLength ( ) const;
+
/**
* Set the value of mSciMsgDataLength
* @return bool
@@ -190,26 +205,39 @@ public:
bool setSciMsgDataLength ( const unsigned long data_length );
/**
- * Get the value of mSciMsgDataLength
- * @return the value of mSciMsgDataLength
+ * Get the value of mpSciMsgData
+ * @return the value of mpSciMsgData
*/
- unsigned long getSciMsgDataLength ( ) const;
+ unsigned char * getSciMsgData ( ) const;
+
+ /**
+ * Set the value of mpSciMsgData
+ * @return bool
+ * @param p_data the new value of mpSciMsgData
+ */
+ bool setSciMsgData ( const unsigned char * p_data );
// protected attribute accessor methods
//
+
+ /**
+ * Get the value of mSpecializedSciMsgHeaderSize
+ * @return the value of mSpecializedSciMsgHeaderSize
+ */
+ virtual unsigned long getSpecializedSciMsgHeaderSize ( ) const;
/**
* Set the value of mSpecializedSciMsgHeaderSize
* @return bool
* @param header_size the new value of mSpecializedSciMsgHeaderSize
*/
- bool setSpecializedSciMsgHeaderSize ( const unsigned long header_size );
-
+ virtual bool setSpecializedSciMsgHeaderSize ( const unsigned long header_size );
+
/**
- * Get the value of mSpecializedSciMsgHeaderSize
- * @return the value of mSpecializedSciMsgHeaderSize
+ * Get the value of mSpecializedSciMsgDataLength
+ * @return the value of mSpecializedSciMsgDataLength
*/
- unsigned long getSpecializedSciMsgHeaderSize ( ) const;
+ virtual unsigned long getSpecializedSciMsgDataLength ( ) const;
/**
* Set the value of mSpecializedSciMsgDataLength
@@ -219,10 +247,10 @@ public:
virtual bool setSpecializedSciMsgDataLength ( const unsigned long data_length );
/**
- * Get the value of mSpecializedSciMsgDataLength
- * @return the value of mSpecializedSciMsgDataLength
+ * Get the value of mpSpecializedSciMsgData
+ * @return the value of mpSpecializedSciMsgData
*/
- virtual unsigned long getSpecializedSciMsgDataLength ( ) const;
+ virtual unsigned char * getSpecializedSciMsgData ( ) const;
/**
* Set the value of mpSpecializedSciMsgData
@@ -230,12 +258,6 @@ public:
* @param p_data the new value of mpSpecializedSciMsgData
*/
virtual bool setSpecializedSciMsgData ( const unsigned char * p_data );
-
- /**
- * Get the value of mpSpecializedSciMsgData
- * @return the value of mpSpecializedSciMsgData
- */
- virtual unsigned char * getSpecializedSciMsgData ( ) const;
private:
@@ -243,10 +265,10 @@ private:
//
void initAttributes ( ) ;
-
- void displaySciMsgHeader ( ) const;
- void displaySciMsgData ( ) const;
+ void displaySciMsgType ( ) const;
+
+ void displaySciMsgFlag ( ) const;
protected:
@@ -255,13 +277,12 @@ protected:
/**
* @return bool
- * @param header_size
+ * @param data_length_to_remove
* @param data_length
- * @param data
+ * @param pp_data
*/
bool removeData ( const unsigned long data_length_to_remove, unsigned long & data_length, unsigned char ** pp_data );
-
- void displaySpecializedSciMsgData ( ) const;
+
};
diff --git a/maximus/sci/src/SciMsg.cpp b/maximus/sci/src/SciMsg.cpp
index 67a278e8bf..43fc67aebe 100644
--- a/maximus/sci/src/SciMsg.cpp
+++ b/maximus/sci/src/SciMsg.cpp
@@ -44,8 +44,9 @@ using namespace std;
SciMsg::SciMsg ( ):
mSciMsgStatus(MAXIMUS_SCI_MSG_STATUS_NONE),
-mSciMsgFlag(SCI_MSG_FLAG_RESP),
mSciMsgType(SCI_MSG_TYPE_NONE),
+mSciMsgStationId(0),
+mSciMsgFlag(SCI_MSG_FLAG_RESP),
mpSciMsgHeader(NULL),
mSciMsgDataLength(0),
mpSciMsgData(NULL),
@@ -66,20 +67,20 @@ void SciMsg::initAttributes ( )
mpSciMsgHeader = new Sci_Msg_Header;
if (NULL != mpSciMsgHeader)
{
- mpSciMsgHeader->magic_id = 0;
- mpSciMsgHeader->version = SCI_MSG_VERSION;
- mpSciMsgHeader->type = 0;
- mpSciMsgHeader->length = 0;
- mpSciMsgHeader->station_id = 0;
- mpSciMsgHeader->msg_id = 0;
- mpSciMsgHeader->netclock_high = 0;
- mpSciMsgHeader->netclock_low = 0;
- mpSciMsgHeader->flags = 0;
- mpSciMsgHeader->reserved = 0;
+ mpSciMsgHeader->magic_id = 0x00000000;
+ mpSciMsgHeader->version = 0x00;
+ mpSciMsgHeader->type = 0x00;
+ mpSciMsgHeader->length = 0x0000;
+ mpSciMsgHeader->station_id = 0x0000;
+ mpSciMsgHeader->msg_id = 0x0000;
+ mpSciMsgHeader->netclock_high = 0x00000000;
+ mpSciMsgHeader->netclock_low = 0x00000000;
+ mpSciMsgHeader->flags = 0x0000;
+ mpSciMsgHeader->reserved = 0x0000;
}
else
{
- throw Error("SciMsg::initAttributes", "Initialized Sci_Msg_Header pointer is NULL");
+ throw Error("SciMsg::initAttributes", "Initialized SCI message header pointer is NULL");
}
}
@@ -90,35 +91,43 @@ SciMsg::SciMsg ( const SciMsg & sci_msg )
initAttributes();
+ mSciMsgStatus = sci_msg.getSciMsgStatus();
+
mSciMsgType = sci_msg.getSciMsgType();
+ mSciMsgStationId = sci_msg.getSciMsgStationId();
mSciMsgFlag = sci_msg.getSciMsgFlag();
- mSciMsgStatus = sci_msg.getSciMsgStatus();
+
mpSciMsgHeader = sci_msg.getSciMsgHeader();
mSciMsgDataLength = sci_msg.getSciMsgDataLength();
mpSciMsgData = sci_msg.getSciMsgData();
+
mSpecializedSciMsgHeaderSize = sci_msg.getSpecializedSciMsgHeaderSize();
mSpecializedSciMsgDataLength = sci_msg.getSpecializedSciMsgDataLength();
mpSpecializedSciMsgData = sci_msg.getSpecializedSciMsgData();
}
-SciMsg::SciMsg ( const SciMsg * sci_msg )
+SciMsg::SciMsg ( const SciMsg * p_sci_msg )
{
clog << "SciMsg(SciMsg*)" << endl;
initAttributes();
- if (NULL != sci_msg)
+ if (NULL != p_sci_msg)
{
- mSciMsgType = sci_msg->getSciMsgType();
- mSciMsgFlag = sci_msg->getSciMsgFlag();
- mSciMsgStatus = sci_msg->getSciMsgStatus();
- mpSciMsgHeader = sci_msg->getSciMsgHeader();
- mSciMsgDataLength = sci_msg->getSciMsgDataLength();
- mpSciMsgData = sci_msg->getSciMsgData();
- mSpecializedSciMsgHeaderSize = sci_msg->getSpecializedSciMsgHeaderSize();
- mSpecializedSciMsgDataLength = sci_msg->getSpecializedSciMsgDataLength();
- mpSpecializedSciMsgData = sci_msg->getSpecializedSciMsgData();
+ mSciMsgStatus = p_sci_msg->getSciMsgStatus();
+
+ mSciMsgType = p_sci_msg->getSciMsgType();
+ mSciMsgStationId = p_sci_msg->getSciMsgStationId();
+ mSciMsgFlag = p_sci_msg->getSciMsgFlag();
+
+ mpSciMsgHeader = p_sci_msg->getSciMsgHeader();
+ mSciMsgDataLength = p_sci_msg->getSciMsgDataLength();
+ mpSciMsgData = p_sci_msg->getSciMsgData();
+
+ mSpecializedSciMsgHeaderSize = p_sci_msg->getSpecializedSciMsgHeaderSize();
+ mSpecializedSciMsgDataLength = p_sci_msg->getSpecializedSciMsgDataLength();
+ mpSpecializedSciMsgData = p_sci_msg->getSpecializedSciMsgData();
}
else
{
@@ -141,6 +150,7 @@ SciMsg::~SciMsg ( )
delete [] mpSciMsgData;
mpSciMsgData = NULL;
}
+
if (NULL != mpSpecializedSciMsgData)
{
delete [] mpSpecializedSciMsgData;
@@ -162,21 +172,25 @@ SciMsg::~SciMsg ( )
//
+// Remove specialized SCI message header from specialized SCI msg data
+// Then, set specialized SCI message data length, and specialized SCI msg data
+//
bool SciMsg::identifySpecializedSciMsgData ( )
{
clog << "SciMsg::identifySpecializedSciMsgData" << endl;
- bool bIdentifyData = true;
+ bool bIdentifyData = false;
if (NULL != getSciMsgData())
{
// Check data lengths coherence
//
- if (getSciMsgDataLength() == (getSciMsgHeader()->length))
+ if ( (NULL != getSciMsgHeader()) && (getSciMsgDataLength() == getSciMsgHeader()->length) )
{
- // Create temporary variables because input variables are defined as constant
+ // Create temporary variables
//
unsigned long tempDataLength = getSciMsgDataLength();
unsigned char * pTempData = new unsigned char [tempDataLength];
+
if (NULL != pTempData)
{
for (unsigned long i=0; i<tempDataLength; i++)
@@ -190,6 +204,8 @@ bool SciMsg::identifySpecializedSciMsgData ( )
bIdentifyData &= setSpecializedSciMsgData (pTempData);
}
+ // Free temporary allocated memory
+ //
delete [] pTempData;
pTempData = NULL;
}
@@ -200,7 +216,7 @@ bool SciMsg::identifySpecializedSciMsgData ( )
}
else
{
- throw Error("SciMsg::identifySpecializedSciMsgData", "Incoherent data lengths between SCI message header and input data length");
+ throw Error("SciMsg::identifySpecializedSciMsgData", "Incoherent data lengths between SCI message header and set data length");
}
}
else
@@ -212,45 +228,122 @@ bool SciMsg::identifySpecializedSciMsgData ( )
}
-// private methods
-//
-
-
void SciMsg::displaySciMsgHeader ( ) const
{
- clog << "SciMsg::displaySciMsgHeader" << endl;
-
clog << "\tSCI msg header = " << endl;
- clog << "\t\tmagic_id = 0x" << hex << setfill('0') << setw(8) << uppercase << getSciMsgHeader()->magic_id << endl;
- clog << "\t\tversion = 0x" << hex << setfill('0') << setw(2) << uppercase << getSciMsgHeader()->version << endl;
- clog << "\t\ttype = 0x" << hex << setfill('0') << setw(2) << uppercase << getSciMsgHeader()->type << endl;
+ clog << "\t\tmagic_id = 0x" << setfill('0') << setw(8) << uppercase << hex << getSciMsgHeader()->magic_id << endl;
+ clog << "\t\tversion = " << dec << (unsigned short int)getSciMsgHeader()->version << endl;
+ clog << "\t\ttype = ";
+ displaySciMsgType();
+ clog << endl;
clog << "\t\tlength = " << dec << getSciMsgHeader()->length << endl;
- clog << "\t\tstation_id = 0x" << hex << setfill('0') << setw(4) << uppercase << getSciMsgHeader()->station_id << endl;
- clog << "\t\tmsg_id = 0x" << hex << setfill('0') << setw(4) << uppercase << getSciMsgHeader()->msg_id << endl;
- clog << "\t\tnetclock_high = 0x" << hex << setfill('0') << setw(8) << uppercase << getSciMsgHeader()->netclock_high << endl;
- clog << "\t\tnetclock_low = 0x" << hex << setfill('0') << setw(8) << uppercase << getSciMsgHeader()->netclock_low << endl;
- clog << "\t\tflags = 0x" << hex << setfill('0') << setw(4) << uppercase << getSciMsgHeader()->flags << endl;
- clog << "\t\treserved = 0x" << hex << setfill('0') << setw(4) << uppercase << getSciMsgHeader()->reserved << endl;
+ clog << "\t\tstation_id = 0x" << setfill('0') << setw(4) << uppercase << hex << getSciMsgStationId() << endl;
+ clog << "\t\tmsg_id = 0x" << setfill('0') << setw(4) << uppercase << hex << getSciMsgHeader()->msg_id << endl;
+ clog << "\t\tnetclock = 0x" << setfill('0') << setw(8) << uppercase << hex << getSciMsgHeader()->netclock_high;
+ clog << setfill('0') << setw(8) << uppercase << hex << getSciMsgHeader()->netclock_low << endl;
+ clog << "\t\tflags = ";
+ displaySciMsgFlag();
+ clog << endl;
+ clog << "\t\treserved = 0x" << setfill('0') << setw(4) << uppercase << hex << getSciMsgHeader()->reserved << endl;
}
void SciMsg::displaySciMsgData ( ) const
{
- clog << "SciMsg::displaySciMsgData" << endl;
-
- clog << "\tSCI msg data = ";
if (NULL != getSciMsgData())
{
for (unsigned long i=0; i<getSciMsgDataLength(); i++)
{
- clog << *(getSciMsgData()+i);
+ if ( '\0' == *(getSciMsgData()+i) )
+ {
+ clog << " ";
+ }
+ else
+ {
+ clog << *(getSciMsgData()+i);
+ }
+ }
+ }
+ else
+ {
+ clog << "NULL";
+ }
+}
+
+
+void SciMsg::displaySpecializedSciMsgData ( ) const
+{
+ if (NULL != getSpecializedSciMsgData())
+ {
+ for (unsigned long i=0; i<getSpecializedSciMsgDataLength(); i++)
+ {
+ if ( '\0' == *(getSpecializedSciMsgData()+i) )
+ {
+ clog << " ";
+ }
+ else
+ {
+ clog << *(getSpecializedSciMsgData()+i);
+ }
}
}
else
{
clog << "NULL";
}
- clog << endl;
+}
+
+
+// private methods
+//
+
+
+void SciMsg::displaySciMsgType ( ) const
+{
+ switch (getSciMsgType())
+ {
+ case 0:
+ clog << "SCI_MSG_TYPE_NONE";
+ break;
+ case 1:
+ clog << "SCI_MSG_TYPE_NETWORK_CLOCK";
+ break;
+ case 2:
+ clog << "SCI_MSG_TYPE_FUNCTION_CALL";
+ break;
+ case 3:
+ clog << "SCI_MSG_TYPE_PHY";
+ break;
+ case 4:
+ clog << "SCI_MSG_TYPE_SYSTEM";
+ break;
+ default:
+ clog << "unknown";
+ break;
+ }
+}
+
+
+void SciMsg::displaySciMsgFlag ( ) const
+{
+ switch (getSciMsgFlag())
+ {
+ case 0:
+ clog << "SCI_MSG_FLAG_RESP";
+ break;
+ case 1:
+ clog << "SCI_MSG_FLAG_ACK";
+ break;
+ case 2:
+ clog << "SCI_MSG_FLAG_NEEDACK";
+ break;
+ case 3:
+ clog << "SCI_MSG_FLAG_SYNC";
+ break;
+ default:
+ clog << "unknown";
+ break;
+ }
}
@@ -258,16 +351,18 @@ void SciMsg::displaySciMsgData ( ) const
//
+// Remove required data length from data, and update data length
+//
bool SciMsg::removeData ( const unsigned long data_length_to_remove, unsigned long & data_length, unsigned char ** pp_data )
{
clog << "SciMsg::removeData" << endl;
bool bRemoveData = false;
- // Keep data without header
- //
- if ( (data_length >= data_length_to_remove) // check that there are enough data to remove the message header
+ if ( (data_length >= data_length_to_remove) // check that there are enough data to remove the required data length
&& (NULL != *pp_data) )
{
+ // Create temporary variable
+ //
unsigned char * remainingData = new unsigned char [data_length-data_length_to_remove];
for (unsigned long i=data_length_to_remove; i<data_length; i++)
{
@@ -284,32 +379,19 @@ bool SciMsg::removeData ( const unsigned long data_length_to_remove, unsigned lo
*pp_data = NULL;
}
+ // Free temporary allocated memory
+ //
delete [] remainingData;
remainingData = NULL;
+
bRemoveData = true;
}
-
- return bRemoveData;
-}
-
-
-void SciMsg::displaySpecializedSciMsgData ( ) const
-{
- clog << "SciMsg::displaySpecializedSciMsgData" << endl;
-
- clog << "\tspecialized SCI msg data = ";
- if (NULL != getSpecializedSciMsgData())
- {
- for (unsigned long i=0; i<getSpecializedSciMsgDataLength(); i++)
- {
- clog << *(getSpecializedSciMsgData()+i);
- }
- }
else
{
- clog << "NULL";
+ throw Error("SciMsg::removeData", "Not enough data");
}
- clog << endl;
+
+ return bRemoveData;
}
@@ -325,6 +407,12 @@ void SciMsg::displaySpecializedSciMsgData ( ) const
//
+Sci_Msg_Status SciMsg::getSciMsgStatus ( ) const
+{
+ return mSciMsgStatus;
+}
+
+
Sci_Msg_Type SciMsg::getSciMsgType ( ) const
{
return mSciMsgType;
@@ -334,11 +422,32 @@ Sci_Msg_Type SciMsg::getSciMsgType ( ) const
bool SciMsg::setSciMsgType ( const Sci_Msg_Type type )
{
clog << "SciMsg::setSciMsgType" << endl;
-
+ bool bSet = true;
+
mSciMsgType = type;
- clog << "\ttype = " << mSciMsgType << endl;
+ clog << "\tSCI msg type = ";
+ displaySciMsgType();
+ clog << endl;
- return true;
+ return bSet;
+}
+
+
+Sci_Msg_Station_Id SciMsg::getSciMsgStationId ( ) const
+{
+ return mSciMsgStationId;
+}
+
+
+bool SciMsg::setSciMsgStationId ( const Sci_Msg_Station_Id station_id )
+{
+ clog << "SciMsg::setSciMsgStationId" << endl;
+ bool bSet = true;
+
+ mSciMsgStationId = station_id;
+ clog << "\tSCI msg station id = " << getSciMsgStationId() << endl;
+
+ return bSet;
}
@@ -348,9 +457,23 @@ Sci_Msg_Flag SciMsg::getSciMsgFlag ( ) const
}
-Sci_Msg_Status SciMsg::getSciMsgStatus ( ) const
+bool SciMsg::setSciMsgFlag ( const Sci_Msg_Flag flag )
{
- return mSciMsgStatus;
+ clog << "SciMsg::setSciMsgFlag" << endl;
+ bool bSet = true;
+
+ mSciMsgFlag = flag;
+ clog << "\tSCI msg flag = ";
+ displaySciMsgFlag();
+ clog << endl;
+
+ return bSet;
+}
+
+
+Sci_Msg_Header * SciMsg::getSciMsgHeader ( ) const
+{
+ return mpSciMsgHeader;
}
@@ -364,27 +487,51 @@ bool SciMsg::setSciMsgHeader ( const Sci_Msg_Header * p_sci_msg_header )
mpSciMsgHeader = new Sci_Msg_Header;
if (NULL != mpSciMsgHeader)
{
- * mpSciMsgHeader = * p_sci_msg_header;
- displaySciMsgHeader ();
+ *mpSciMsgHeader = *p_sci_msg_header;
+
+ // Set SCI msg attributes from SCI msg header
+ //
+ setSciMsgType (static_cast<Sci_Msg_Type>(getSciMsgHeader()->type));
+ setSciMsgStationId (static_cast<Sci_Msg_Station_Id>(getSciMsgHeader()->station_id));
+ setSciMsgFlag (static_cast<Sci_Msg_Flag>(getSciMsgHeader()->flags));
+
+ displaySciMsgHeader();
bSetHeader = true;
}
else
{
- throw Error("SciMsg::setSciMsgHeader", "Initialized Sci_Msg_Header pointer is NULL");
+ throw Error("SciMsg::setSciMsgHeader", "Initialized SCI message header pointer is NULL");
}
}
else
{
- throw Error("SciMsg::setSciMsgHeader", "Received Sci_Msg_Header pointer is NULL");
+ throw Error("SciMsg::setSciMsgHeader", "Received SCI messsage header pointer is NULL");
}
return bSetHeader;
}
-Sci_Msg_Header * SciMsg::getSciMsgHeader ( ) const
+unsigned long SciMsg::getSciMsgDataLength ( ) const
{
- return mpSciMsgHeader;
+ return mSciMsgDataLength;
+}
+
+
+bool SciMsg::setSciMsgDataLength ( const unsigned long data_length )
+{
+ clog << "SciMsg::setSciMsgDataLength" << endl;
+
+ mSciMsgDataLength = data_length;
+ clog << "\tSCI msg data length = " << dec << mSciMsgDataLength << " bytes" << endl;
+
+ return true;
+}
+
+
+unsigned char * SciMsg::getSciMsgData ( ) const
+{
+ return mpSciMsgData;
}
@@ -404,7 +551,9 @@ bool SciMsg::setSciMsgData ( const unsigned char * p_data )
{
*(mpSciMsgData+i) = *(p_data+i);
}
- displaySciMsgData ();
+ clog << "\tSCI msg data = ";
+ displaySciMsgData();
+ clog << endl;
bSetData = true;
}
else
@@ -426,64 +575,47 @@ bool SciMsg::setSciMsgData ( const unsigned char * p_data )
}
-unsigned char * SciMsg::getSciMsgData ( ) const
-{
- return mpSciMsgData;
-}
+// protected attribute accessor methods
+//
-bool SciMsg::setSciMsgDataLength ( const unsigned long data_length )
+unsigned long SciMsg::getSpecializedSciMsgHeaderSize ( ) const
{
- clog << "SciMsg::setSciMsgDataLength" << endl;
-
- mSciMsgDataLength = data_length;
- clog << "\tSCI msg data length = " << dec << mSciMsgDataLength << endl;
+ return mSpecializedSciMsgHeaderSize;
+}
- return true;
-}
-
-
-unsigned long SciMsg::getSciMsgDataLength ( ) const
-{
- return mSciMsgDataLength;
-}
-
-
-// protected attribute accessor methods
-//
-
bool SciMsg::setSpecializedSciMsgHeaderSize ( const unsigned long header_size )
{
clog << "SciMsg::setSpecializedSciMsgHeaderSize" << endl;
mSpecializedSciMsgHeaderSize = header_size;
- clog << dec << "\tspecialized SCI msg header size = " << mSpecializedSciMsgHeaderSize << endl;
+ clog << dec << "\tspecialized SCI msg header size = " << dec << mSpecializedSciMsgHeaderSize << " bytes" << endl;
return true;
}
-unsigned long SciMsg::getSpecializedSciMsgHeaderSize ( ) const
+unsigned long SciMsg::getSpecializedSciMsgDataLength ( ) const
{
- return mSpecializedSciMsgHeaderSize;
-}
-
+ return mSpecializedSciMsgDataLength;
+}
+
bool SciMsg::setSpecializedSciMsgDataLength ( const unsigned long data_length )
{
clog << "SciMsg::setSpecializedSciMsgDataLength" << endl;
mSpecializedSciMsgDataLength = data_length;
- clog << dec << "\tspecialized SCI msg data length = " << mSpecializedSciMsgDataLength << endl;
+ clog << dec << "\tspecialized SCI msg data length = " << dec << mSpecializedSciMsgDataLength << " bytes" << endl;
return true;
}
-unsigned long SciMsg::getSpecializedSciMsgDataLength ( ) const
+unsigned char * SciMsg::getSpecializedSciMsgData ( ) const
{
- return mSpecializedSciMsgDataLength;
+ return mpSpecializedSciMsgData;
}
@@ -492,35 +624,23 @@ bool SciMsg::setSpecializedSciMsgData ( const unsigned char * p_data )
clog << "SciMsg::setSpecializedSciMsgData" << endl;
bool bSetData = false;
- if (NULL != p_data)
- {
- mpSpecializedSciMsgData = new unsigned char [getSpecializedSciMsgDataLength()];
- if (NULL != mpSpecializedSciMsgData)
- {
- for (unsigned long i=0; i<getSpecializedSciMsgDataLength(); i++)
- {
- *(mpSpecializedSciMsgData+i) = *(p_data+i);
- }
- displaySpecializedSciMsgData ();
- bSetData = true;
- }
- else
+ mpSpecializedSciMsgData = new unsigned char [getSpecializedSciMsgDataLength()];
+ if ( (NULL != p_data) && (NULL != mpSpecializedSciMsgData) )
+ {
+ for (unsigned long i=0; i<getSpecializedSciMsgDataLength(); i++)
{
- throw Error("SciMsg::setSciMsgData", "Initialized data pointer is NULL");
+ *(mpSpecializedSciMsgData+i) = *(p_data+i);
}
}
else
{
mpSpecializedSciMsgData = NULL;
- bSetData = true;
}
+ clog << "\tspecialized SCI msg data = ";
+ displaySpecializedSciMsgData();
+ clog << endl;
+ bSetData = true;
return bSetData;
}
-
-unsigned char * SciMsg::getSpecializedSciMsgData ( ) const
-{
- return mpSpecializedSciMsgData;
-}
-
diff --git a/maximus/sci/src/SciServer.cpp b/maximus/sci/src/SciServer.cpp
index 4c86926ad8..658e74b3f0 100644
--- a/maximus/sci/src/SciServer.cpp
+++ b/maximus/sci/src/SciServer.cpp
@@ -148,6 +148,13 @@ bool SciServer::sendSciMsg ( const SciMsg * sci_msg_to_send ) const
if (NULL != sci_msg_to_send)
{
+ // Display SCI msg to send
+ //
+ sci_msg_to_send->displaySciMsgHeader();
+ sci_msg_to_send->displaySciMsgData();
+ sci_msg_to_send->displaySpecializedSciMsgHeader();
+ sci_msg_to_send->displaySpecializedSciMsgData();
+
// Retrieve destination station
//
Station * destination = NULL;
@@ -495,7 +502,15 @@ bool SciServer::fillSciMsg ( const Sci_Msg_Header * p_msg_header,
if (NULL != p_received_data)
{
bFillMsg &= (*created_sci_msg)->setSciMsgData(p_received_data);
+
+ // Set specialized SCI message header
+ // Set specialized attributes
+ //
bFillMsg &= (*created_sci_msg)->identifySpecializedSciMsgHeader();
+
+ // Remove specialized SCI message header from specialized SCI msg data
+ // Then, set specialized SCI message data length, and specialized SCI message data
+ //
bFillMsg &= (*created_sci_msg)->identifySpecializedSciMsgData();
}
else
diff --git a/maximus/system/inc/Station.h b/maximus/system/inc/Station.h
index c259d0f544..265b5d72a4 100644
--- a/maximus/system/inc/Station.h
+++ b/maximus/system/inc/Station.h
@@ -123,7 +123,7 @@ public:
/**
* @return Sci_Station_Id
*/
- Sci_Station_Id getStationId ( ) const;
+ Sci_Msg_Station_Id getStationId ( ) const;
/**
* @return bool
diff --git a/maximus/system/inc/SystemManager.h b/maximus/system/inc/SystemManager.h
index e5a2ee8114..dd51e82be8 100644
--- a/maximus/system/inc/SystemManager.h
+++ b/maximus/system/inc/SystemManager.h
@@ -106,7 +106,7 @@ public:
* @return bool
* @param station_id
*/
- bool setStationToIdle ( Sci_Station_Id station_id );
+ bool setStationToIdle ( Sci_Msg_Station_Id station_id );
// public attribute accessor methods
//
diff --git a/maximus/system/inc/SystemSciMsg.h b/maximus/system/inc/SystemSciMsg.h
index 47ce5e63ae..6209b2c109 100644
--- a/maximus/system/inc/SystemSciMsg.h
+++ b/maximus/system/inc/SystemSciMsg.h
@@ -53,11 +53,17 @@ private:
// private attributes
//
-
- SystemManager * mpSystemManager;
+
+ // Get from specialized SCI msg header
+ //
System_Type mSpecializedSciMsgType;
+
+ // Specialized SCI msg header
+ //
System_Header * mpSpecializedSciMsgHeader;
+ SystemManager * mpSystemManager;
+
protected:
// protected attributes
@@ -99,11 +105,11 @@ public:
/**
* @return bool
- * @param data_length
- * @param p_data
*/
bool identifySpecializedSciMsgHeader ( );
+ void displaySpecializedSciMsgHeader ( ) const;
+
// public attribute accessor methods
//
@@ -111,24 +117,24 @@ public:
//
/**
- * @return System_Type
+ * @return mSpecializedSciMsgType
*/
System_Type getSpecializedSciMsgType ( ) const;
/**
* @return bool
- * @param type
+ * @param type the new value of mSpecializedSciMsgType
*/
bool setSpecializedSciMsgType ( const System_Type type );
/**
- * @return System_Header *
+ * @return mpSpecializedSciMsgHeader
*/
System_Header * getSpecializedSciMsgHeader ( ) const;
/**
* @return bool
- * @param p_specialized_sci_msg_header
+ * @param p_specialized_sci_msg_header the new value of mpSpecializedSciMsgHeader
*/
bool setSpecializedSciMsgHeader ( const System_Header * p_specialized_sci_msg_header );
@@ -142,7 +148,7 @@ private:
void initAttributes ( ) ;
- void displaySpecializedSciMsgHeader ( ) const;
+ void displaySpecializedSciMsgType ( ) const;
protected:
diff --git a/maximus/system/src/Station.cpp b/maximus/system/src/Station.cpp
index d1f283b48a..83be422b33 100644
--- a/maximus/system/src/Station.cpp
+++ b/maximus/system/src/Station.cpp
@@ -179,9 +179,9 @@ void Station::displayStation ( ) const
//
-Sci_Station_Id Station::getStationId ( ) const
+Sci_Msg_Station_Id Station::getStationId ( ) const
{
- return (Sci_Station_Id)mPid;
+ return (Sci_Msg_Station_Id)mPid;
}
diff --git a/maximus/system/src/SystemManager.cpp b/maximus/system/src/SystemManager.cpp
index ccf64ab730..497af94b3e 100644
--- a/maximus/system/src/SystemManager.cpp
+++ b/maximus/system/src/SystemManager.cpp
@@ -201,7 +201,7 @@ bool SystemManager::areAllActiveStationsIdle ( ) const
}
-bool SystemManager::setStationToIdle ( Sci_Station_Id station_id )
+bool SystemManager::setStationToIdle ( Sci_Msg_Station_Id station_id )
{
clog << "SystemManager::setStationToIdle" << endl;
bool bSetIdle = false;
diff --git a/maximus/system/src/SystemSciMsg.cpp b/maximus/system/src/SystemSciMsg.cpp
index 1ab6a3dbd7..767e9d94e3 100644
--- a/maximus/system/src/SystemSciMsg.cpp
+++ b/maximus/system/src/SystemSciMsg.cpp
@@ -33,6 +33,7 @@ The original location of this file is /home/buret/eclipse/maximus/system/src/Sys
#include "Error.h"
#include <iomanip> // for 'std::setfill' and 'std::setw'
+#include <netinet/in.h> // for 'ntohl' and 'ntohs' functions
#include <iostream> // for 'cout', 'cerr' and 'clog'
using namespace std;
@@ -42,9 +43,9 @@ using namespace std;
SystemSciMsg::SystemSciMsg ( ):
-mpSystemManager(NULL),
mSpecializedSciMsgType(SYSTEM_TYPE_NONE),
-mpSpecializedSciMsgHeader(NULL)
+mpSpecializedSciMsgHeader(NULL),
+mpSystemManager(NULL)
{
clog << "SystemSciMsg()" << endl;
@@ -53,20 +54,21 @@ mpSpecializedSciMsgHeader(NULL)
SystemSciMsg::SystemSciMsg ( SystemManager * p_system_manager ):
-mpSystemManager(NULL),
mSpecializedSciMsgType(SYSTEM_TYPE_NONE),
-mpSpecializedSciMsgHeader(NULL)
+mpSpecializedSciMsgHeader(NULL),
+mpSystemManager(NULL)
{
clog << "SystemSciMsg(SystemManager*)" << endl;
initAttributes ();
+
if (NULL != p_system_manager)
{
mpSystemManager = p_system_manager;
}
else
{
- throw Error("SystemSciMsg(SystemManager*)", "Received SystemManager pointer is NULL");
+ throw Error("SystemSciMsg(SystemManager*)", "Received system manager pointer is NULL");
}
}
@@ -79,8 +81,8 @@ void SystemSciMsg::initAttributes ( )
if (NULL != mpSpecializedSciMsgHeader)
{
mpSpecializedSciMsgHeader->version = SYSTEM_VERSION;
- mpSpecializedSciMsgHeader->type = 0;
- mpSpecializedSciMsgHeader->flags = 0;
+ mpSpecializedSciMsgHeader->type = 0x00;
+ mpSpecializedSciMsgHeader->flags = 0x0000;
}
else
{
@@ -98,6 +100,7 @@ SystemSciMsg::~SystemSciMsg ( )
delete (mpSpecializedSciMsgHeader);
mpSpecializedSciMsgHeader = NULL;
}
+
if (NULL != mpSystemManager)
{
mpSystemManager = NULL;
@@ -133,14 +136,14 @@ bool SystemSciMsg::dispatchMsg ( )
if (NULL != mpSystemManager)
{
- if ( (NULL != getSpecializedSciMsgHeader()) && (SYSTEM_TYPE_IDLE == getSpecializedSciMsgType()) )
+ if ( SYSTEM_TYPE_IDLE == getSpecializedSciMsgType() )
{
- bDispatch = mpSystemManager->setStationToIdle(SciMsg::getSciMsgHeader()->station_id);
+ bDispatch = mpSystemManager->setStationToIdle(SciMsg::getSciMsgStationId());
}
}
else
{
- throw Error("SystemSciMsg::dispatchMsg", "SystemManager pointer is NULL");
+ throw Error("SystemSciMsg::dispatchMsg", "System manager pointer is NULL");
}
return bDispatch;
@@ -156,21 +159,22 @@ bool SystemSciMsg::identifySpecializedSciMsgHeader ( )
if (NULL != SciMsg::getSciMsgData())
{
+ // Set specialized SCI msg header size
+ //
+ SciMsg::setSpecializedSciMsgHeaderSize(static_cast<unsigned long>(sizeof(struct System_Header)));
+
// Get specialized SCI message header contents
//
- SciMsg::setSpecializedSciMsgHeaderSize((unsigned long)sizeof(struct System_Header));
if (SciMsg::getSciMsgDataLength() >= SciMsg::getSpecializedSciMsgHeaderSize()) // check that there are enough data to get the specialized SCI message header
{
if (NULL != mpSpecializedSciMsgHeader)
{
*mpSpecializedSciMsgHeader = *((System_Header*)SciMsg::getSciMsgData());
+ getSpecializedSciMsgHeader()->flags = ntohs(getSpecializedSciMsgHeader()->flags);
- mSpecializedSciMsgType = static_cast<System_Type>(mpSpecializedSciMsgHeader->type);
+ bIdentifyHeader = setSpecializedSciMsgType (static_cast<System_Type>(getSpecializedSciMsgHeader()->type));
displaySpecializedSciMsgHeader();
-
-
- bIdentifyHeader = true;
}
else
{
@@ -179,36 +183,50 @@ bool SystemSciMsg::identifySpecializedSciMsgHeader ( )
}
else
{
- Error e = Error("SystemSciMsg::identifySpecializedSciMsgHeader", "Not enough data to get the system header");
- throw (e);
+ throw Error("SystemSciMsg::identifySpecializedSciMsgHeader", "Not enough data to get the system header");
}
}
else
{
- Error e = Error("SystemSciMsg::identifySpecializedSciMsgHeader", "Received data pointer is NULL");
- throw (e);
+ throw Error("SystemSciMsg::identifySpecializedSciMsgHeader", "SCI msg data pointer is NULL");
}
return bIdentifyHeader;
}
-// private methods
-//
-
-
void SystemSciMsg::displaySpecializedSciMsgHeader ( ) const
{
- clog << "SystemSciMsg::displaySpecializedSciMsgHeader" << endl;
-
clog << "\tsystem SCI msg header = " << endl;
- clog << "\t\tversion = 0x" << setfill('0') << setw(2) << uppercase << hex << getSpecializedSciMsgHeader()->version << endl;
- clog << "\t\ttype = " << dec << getSpecializedSciMsgType() << endl;
+ clog << "\t\tversion = " << dec << static_cast<unsigned short int>(getSpecializedSciMsgHeader()->version) << endl;
+ clog << "\t\ttype = ";
+ displaySpecializedSciMsgType();
+ clog << endl;
clog << "\t\tflags = 0x" << setfill('0') << setw(4) << uppercase << hex << getSpecializedSciMsgHeader()->flags << endl;
- clog << dec;
}
+// private methods
+//
+
+
+void SystemSciMsg::displaySpecializedSciMsgType ( ) const
+{
+ switch (getSpecializedSciMsgType())
+ {
+ case 0:
+ clog << "SYSTEM_TYPE_NONE";
+ break;
+ case 1:
+ clog << "SYSTEM_TYPE_IDLE";
+ break;
+ default:
+ clog << "unknown";
+ break;
+ }
+}
+
+
// protected methods
//
@@ -236,7 +254,9 @@ bool SystemSciMsg::setSpecializedSciMsgType ( const System_Type type )
clog << "SystemSciMsg::setSpecializedSciMsgType" << endl;
mSpecializedSciMsgType = type;
- clog << "\tsystem sci msg type = " << mSpecializedSciMsgType << endl;
+ clog << "\tsystem SCI msg type = ";
+ displaySpecializedSciMsgType();
+ clog << endl;
return true;
}
@@ -261,8 +281,7 @@ bool SystemSciMsg::setSpecializedSciMsgHeader ( const System_Header * p_speciali
}
else
{
- Error e = Error("SystemSciMsg::setSpecializedSciMsgHeader", "System SCI msg header pointer is NULL");
- throw (e);
+ throw Error("SystemSciMsg::setSpecializedSciMsgHeader", "System SCI msg header pointer is NULL");
}
return bSetHeader;