summaryrefslogtreecommitdiff
path: root/maximus/sci/src/SciServer.cpp
diff options
context:
space:
mode:
authorburet2007-06-07 17:09:59 +0000
committerburet2007-06-07 17:09:59 +0000
commitc3df772233e886963a5382af8579b30ca4863454 (patch)
tree675fd0575b2d175c5a7c7a8ecfd73756492352b6 /maximus/sci/src/SciServer.cpp
parent37e7f2572aee43c33e335ab4a711a7c2a7e9664a (diff)
- Development of send sci msg
- Update tests git-svn-id: svn+ssh://pessac/svn/cesar/trunk@252 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'maximus/sci/src/SciServer.cpp')
-rw-r--r--maximus/sci/src/SciServer.cpp47
1 files changed, 45 insertions, 2 deletions
diff --git a/maximus/sci/src/SciServer.cpp b/maximus/sci/src/SciServer.cpp
index 25a9d877d6..9279646bf4 100644
--- a/maximus/sci/src/SciServer.cpp
+++ b/maximus/sci/src/SciServer.cpp
@@ -148,9 +148,50 @@ bool SciServer::sendSciMsg ( const SciMsg * sci_msg_to_send ) const
if (NULL != sci_msg_to_send)
{
- // ...
+ // Retrieve destination station
+ //
+ Station * destination = NULL;
+ if (!mpListOfStations->empty())
+ {
+ for (StationsList::const_iterator it = mpListOfStations->begin(); it != mpListOfStations->end(); ++it)
+ {
+ if (NULL != *it)
+ {
+ if ( ((*it)->getStationId()) == sci_msg_to_send->getSciMsgHeader()->station_id )
+ {
+ destination = (*it);
+ it = mpListOfStations->end();
+ --it;
+ }
+ }
+ else
+ {
+ throw Error("SciServer::sendSciMsg", "Station pointer is NULL");
+ }
+ }
+ }
- bSend = true;
+ // Write data into output pipe
+ //
+ if (NULL != destination)
+ {
+ int length=0, totalLength=0;
+
+ while(totalLength < (int)sci_msg_to_send->getSciMsgDataLength())
+ {
+ length = write(destination->getOutputFileDescriptor(), sci_msg_to_send->getSciMsgData() + totalLength, sci_msg_to_send->getSciMsgDataLength());
+ if(length < 0)
+ {
+ throw Error("SciServer::sendSciMsg", "Write failed");
+ }
+ totalLength += length;
+ bSend = true;
+ }
+ }
+ else
+ {
+ throw Error("SciServer::sendSciMsg", "Destination station not found");
+ }
}
else
{
@@ -201,6 +242,8 @@ bool SciServer::receiveMsg ( const Sci_Msg_Header * header,
//
if (NULL != header)
{
+ displayMsgHeader(header);
+
// Create a specialized SCI message according to the message header type
//
SciMsg * sciMsg = NULL;