summaryrefslogtreecommitdiff
path: root/maximus/sci/src/SciServer.cpp
diff options
context:
space:
mode:
authorburet2007-06-13 13:20:29 +0000
committerburet2007-06-13 13:20:29 +0000
commit47ccd0baa383257f030e42278870b7461185a7ac (patch)
treee247343ea2291139a2b2e1b2c547bcc77c7e2f84 /maximus/sci/src/SciServer.cpp
parent4e7de8cce05844a0320805057b8ca7c961d6a41f (diff)
Check SCI msg compatibility
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@288 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'maximus/sci/src/SciServer.cpp')
-rw-r--r--maximus/sci/src/SciServer.cpp69
1 files changed, 41 insertions, 28 deletions
diff --git a/maximus/sci/src/SciServer.cpp b/maximus/sci/src/SciServer.cpp
index 658e74b3f0..9879c54d01 100644
--- a/maximus/sci/src/SciServer.cpp
+++ b/maximus/sci/src/SciServer.cpp
@@ -151,9 +151,15 @@ bool SciServer::sendSciMsg ( const SciMsg * sci_msg_to_send ) const
// Display SCI msg to send
//
sci_msg_to_send->displaySciMsgHeader();
+ clog << "\tSCI msg data = ";
sci_msg_to_send->displaySciMsgData();
+ clog << endl;
sci_msg_to_send->displaySpecializedSciMsgHeader();
- sci_msg_to_send->displaySpecializedSciMsgData();
+ clog << "\tspecialized SCI msg data = ";
+ sci_msg_to_send->displaySpecializedSciMsgData();
+ clog << endl;
+
+ return bSend; // TO REMOVE
// Retrieve destination station
//
@@ -252,7 +258,7 @@ bool SciServer::receiveMsg ( const Sci_Msg_Header * header,
// Create a specialized SCI message according to the message header type
//
SciMsg * sciMsg = NULL;
- Sci_Msg_Type type = (Sci_Msg_Type)header->type;
+ Sci_Msg_Type type = static_cast<Sci_Msg_Type>(header->type);
bReceiveMsg = createSciMsg (type, &sciMsg);
// Process the created specialized SCI message
@@ -265,6 +271,13 @@ bool SciServer::receiveMsg ( const Sci_Msg_Header * header,
//
bReceiveMsg = fillSciMsg (header, data_length, received_data, &sciMsg);
+ // Check msg compatibility (check msg magic id and msg versions)
+ //
+ if (0 != bReceiveMsg)
+ {
+ bReceiveMsg = sciMsg->checkCompatibility();
+ }
+
// Process SCI msg
//
if (0 != bReceiveMsg)
@@ -419,31 +432,6 @@ void * SciServer::serverThread ( void * arg )
}
-void SciServer::displayMsgHeader ( const Sci_Msg_Header * msg_header ) const
-{
- clog << "SciServer::displayMsgHeader" << endl;
-
- if (NULL != msg_header)
- {
- clog << "\tmsg header = " << endl;
- clog << "\t\tmagic_id = 0x" << hex << setfill('0') << setw(8) << uppercase << msg_header->magic_id << endl;
- clog << "\t\tversion = 0x" << hex << setfill('0') << setw(2) << uppercase << msg_header->version << endl;
- clog << "\t\ttype = 0x" << hex << setfill('0') << setw(2) << uppercase << msg_header->type << endl;
- clog << "\t\tlength = " << dec << msg_header->length << endl;
- clog << "\t\tstation_id = 0x" << hex << setfill('0') << setw(4) << uppercase << msg_header->station_id << endl;
- clog << "\t\tmsg_id = 0x" << hex << setfill('0') << setw(4) << uppercase << msg_header->msg_id << endl;
- clog << "\t\tnetclock_high = 0x" << hex << setfill('0') << setw(8) << uppercase << msg_header->netclock_high << endl;
- clog << "\t\tnetclock_low = 0x" << hex << setfill('0') << setw(8) << uppercase << msg_header->netclock_low << endl;
- clog << "\t\tflags = 0x" << hex << setfill('0') << setw(4) << uppercase << msg_header->flags << endl;
- clog << "\t\treserved = 0x" << hex << setfill('0') << setw(4) << uppercase << msg_header->reserved << endl;
- }
- else
- {
- throw Error(__FUNCTION__, "Received SCI msg header pointer is NULL");
- }
-}
-
-
bool SciServer::createSciMsg ( const Sci_Msg_Type type, SciMsg ** received_sci_msg ) const
{
clog << "SciServer::createSciMsg" << endl;
@@ -550,6 +538,29 @@ bool SciServer::processSciMsg ( SciMsg * received_sci_msg ) const
}
+void SciServer::displayStatus ( ) const
+{
+ switch (getStatus())
+ {
+ case 0:
+ clog << "MAXIMUS_SCI_SERVER_STATUS_NONE";
+ break;
+ case 1:
+ clog << "MAXIMUS_SCI_SERVER_STATUS_RUNNING";
+ break;
+ case 2:
+ clog << "MAXIMUS_SCI_SERVER_STATUS_STOP";
+ break;
+ case 3:
+ clog << "MAXIMUS_SCI_SERVER_STATUS_STOPPED";
+ break;
+ default:
+ clog << "unknown";
+ break;
+ }
+}
+
+
// protected methods
//
@@ -590,7 +601,9 @@ bool SciServer::setStatus ( const Sci_Server_Status new_status ) throw (Error)
else
{
mStatus = new_status;
- clog << "\tstatus = " << mStatus << endl;
+ clog << "\tstatus = ";
+ displayStatus();
+ clog << endl;
bSetStatus = true;
}