summaryrefslogtreecommitdiff
path: root/maximus/sci/src/SciServer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'maximus/sci/src/SciServer.cpp')
-rw-r--r--maximus/sci/src/SciServer.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/maximus/sci/src/SciServer.cpp b/maximus/sci/src/SciServer.cpp
index 1c55190085..c6b17d382b 100644
--- a/maximus/sci/src/SciServer.cpp
+++ b/maximus/sci/src/SciServer.cpp
@@ -287,6 +287,58 @@ bool SciServer::sendSciMsg ( SciMsg & sci_msg_to_send ) const
}
+bool SciServer::sendSciMsgToAllActiveStations ( SciMsg & sci_msg_to_send ) const
+{
+ clog << "<--- SciServer::sendSciMsgToAllActiveStations" << endl;
+ bool bSend = false;
+
+ // Skim through stations list
+ //
+ if ( (NULL != mpListOfStations) && (!mpListOfStations->empty()) )
+ {
+ int length;
+ int totalLength;
+
+ for (StationsList::const_iterator it = mpListOfStations->begin(); it != mpListOfStations->end(); ++it)
+ {
+ if (NULL != *it)
+ {
+ // Before sending a SCI msg, check that station status is not 'DEACTIVATED'
+ // Then, station status is set to 'BUSY'
+ // Station status will stay 'BUSY' until a system 'IDLE' msg will be received
+ //
+ if (MAXIMUS_STATION_STATUS_DEACTIVATED != (*it)->getStationStatus())
+ {
+ (*it)->setStationStatus(MAXIMUS_STATION_STATUS_BUSY);
+
+ // Write data into output pipe
+ //
+ length = 0;
+ totalLength = 0;
+ while(totalLength < (int)sci_msg_to_send.getSciMsgDataLength())
+ {
+ length = write((*it)->getOutputFileDescriptor(), sci_msg_to_send.getSciMsgData() + totalLength, sci_msg_to_send.getSciMsgDataLength());
+ if(length < 0)
+ {
+ throw Error("SciServer::sendSciMsgToAllActiveStations", "Write data failed");
+ }
+ totalLength += length;
+ }
+ clog << "\tSCI msg data have been written on pipe" << endl;
+ bSend = true;
+ }
+ }
+ else
+ {
+ throw Error("SciServer::sendSciMsgToAllActiveStations", "A station pointer is NULL");
+ }
+ }
+ }
+
+ return bSend;
+}
+
+
bool SciServer::registerSpecializedSciMsg ( const Sci_Msg_Type sci_msg_type, SciMsg * sci_msg )
{
clog << "SciServer::registerSpecializedSciMsg" << endl;