From ca72c8b5d6276e9ec62d3889e189858ecbb0db2d Mon Sep 17 00:00:00 2001 From: buret Date: Tue, 12 Jun 2007 16:50:24 +0000 Subject: Display SCI data git-svn-id: svn+ssh://pessac/svn/cesar/trunk@285 017c9cb6-072f-447c-8318-d5b54f68fe89 --- maximus/system/inc/Station.h | 2 +- maximus/system/inc/SystemManager.h | 2 +- maximus/system/inc/SystemSciMsg.h | 24 +++++++---- maximus/system/src/Station.cpp | 4 +- maximus/system/src/SystemManager.cpp | 2 +- maximus/system/src/SystemSciMsg.cpp | 81 ++++++++++++++++++++++-------------- 6 files changed, 70 insertions(+), 45 deletions(-) (limited to 'maximus/system') 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 // for 'std::setfill' and 'std::setw' +#include // for 'ntohl' and 'ntohs' functions #include // 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(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(mpSpecializedSciMsgHeader->type); + bIdentifyHeader = setSpecializedSciMsgType (static_cast(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(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; -- cgit v1.2.3