summaryrefslogtreecommitdiff
path: root/maximus/sci/src/SciServer.cpp
diff options
context:
space:
mode:
authorburet2007-08-10 13:21:24 +0000
committerburet2007-08-10 13:21:24 +0000
commit07f140541150f150d5e07e6657d9a249357f8c2c (patch)
tree93cf4dd11bf375ad48d54c97cc18f250af4b9ad4 /maximus/sci/src/SciServer.cpp
parent48874eb3c77a15b6608384aa4447d92cdb3ae82a (diff)
Development of Maximus user interface + unitary tests
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@587 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'maximus/sci/src/SciServer.cpp')
-rw-r--r--maximus/sci/src/SciServer.cpp472
1 files changed, 236 insertions, 236 deletions
diff --git a/maximus/sci/src/SciServer.cpp b/maximus/sci/src/SciServer.cpp
index bcb0369b94..80101d65b5 100644
--- a/maximus/sci/src/SciServer.cpp
+++ b/maximus/sci/src/SciServer.cpp
@@ -29,18 +29,20 @@ The original location of this file is /home/buret/eclipse/maximus/sci/src/SciSer
**************************************************************************/
#include "SciServer.h"
+
#include "Station.h"
#include "SciMsg.h"
#include "ClockSciMsg.h"
-#include "SystemManager.h"
+
#include "Error.h"
+#include "Logger.h"
+#include <fstream> // for 'ofstream'
#include <stdlib.h>
#include <errno.h>
#include <sys/select.h>
#include <iomanip>
-#include <netinet/in.h> // for 'ntohl' and 'ntohs' functions
-
+#include <netinet/in.h> // for 'ntohl()' and 'ntohs()'
#include <iostream> // for 'cout', 'cerr' and 'clog'
using namespace std;
@@ -50,13 +52,12 @@ using namespace std;
SciServer::SciServer ( ) :
-mStatus(MAXIMUS_SCI_SERVER_STATUS_NONE),
mpSpecializedSciMsgArray(NULL),
mArraySize(0),
mpListOfStations(NULL),
mNetworkClockTick(0)
{
- clog << "SciServer()" << endl;
+ logFunction();
initAttributes();
}
@@ -64,7 +65,7 @@ mNetworkClockTick(0)
void SciServer::initAttributes ( )
{
- clog << "SciServer::initAttributes" << endl;
+ logFunction();
// Init array
//
@@ -79,23 +80,14 @@ void SciServer::initAttributes ( )
}
else
{
- throw Error(__FUNCTION__, "Initialized specialized SCI msg array pointer is NULL");
+ throw Error(__PRETTY_FUNCTION__, "Specialized SCI msg array pointer is NULL");
}
-
- pthread_mutex_init(&mServerMutex, NULL);
-
- // start the server thread
- setStatus ((Sci_Server_Status)pthread_create(&mServerThread, NULL, SciServer::serverThread, this));
- if(0 != getStatus())
- throw new Error(__FUNCTION__, "pthread_create", errno);
- else
- setStatus (MAXIMUS_SCI_SERVER_STATUS_RUNNING);
}
SciServer::~SciServer ( )
{
- clog << "~SciServer" << endl;
+ logFunction();
// Do not free stations list
// Station list is deleted when SystemManager is deleted
@@ -121,13 +113,6 @@ SciServer::~SciServer ( )
delete [] mpSpecializedSciMsgArray;
mpSpecializedSciMsgArray = NULL;
}
-
- if (MAXIMUS_SCI_SERVER_STATUS_STOPPED != getStatus())
- {
- setStatus(MAXIMUS_SCI_SERVER_STATUS_STOP);
- while (MAXIMUS_SCI_SERVER_STATUS_STOPPED != getStatus());
- }
- pthread_mutex_destroy(&mServerMutex);
}
@@ -144,9 +129,171 @@ SciServer::~SciServer ( )
//
+bool SciServer::init ( const std::string station_log )
+{
+ logFunction();
+
+ mStationLog = station_log;
+
+ return true;
+}
+
+
+bool SciServer::process ( )
+{
+ logFunction();
+ bool bProcess = false;
+
+ int fd_max, fd_index;
+ fd_set read_fds;
+ struct timeval timeout;
+ int result;
+ Station *station;
+ StationsList::iterator it;
+
+ // timeout set to 1s
+ timeout.tv_sec = 1;
+ timeout.tv_usec = 0;
+
+ // Read input pipes
+ //
+ FD_ZERO(&read_fds);
+ fd_max = 0;
+ for(it = getStationsList()->begin() ; it != getStationsList()->end(); it++)
+ {
+ station = *it;
+
+ FD_SET(station->getInputFileDescriptor(), &read_fds);
+ if(station->getInputFileDescriptor() > fd_max)
+ fd_max = station->getInputFileDescriptor();
+ }
+
+ result = select(fd_max + 1, &read_fds, NULL, NULL, &timeout);
+
+ if(result > 0)
+ {
+ // skim through the list...
+ for(fd_index = 0; fd_index <= fd_max; fd_index++)
+ {
+ if(FD_ISSET(fd_index, &read_fds))
+ {
+ int len, header_len;
+ struct Sci_Msg_Header header;
+ unsigned char *buffer;
+ header_len = sizeof(struct Sci_Msg_Header);
+ if((len = read(fd_index, &header, sizeof(struct Sci_Msg_Header))) < header_len)
+ {
+ clog << logger(LOG_ERROR) << "header read error: len = " << dec << len << ", errno = " << errno << endl;
+ continue;
+ }
+ else
+ {
+ // check for header
+ if(memcmp(&header.magic_id, SCI_MSG_MAGIC, 4))
+ {
+ clog << logger(LOG_ERROR) << "bad magic id: 0x" << hex << htonl(header.magic_id) << endl;
+ continue;
+ }
+ header.length = ntohs (header.length);
+ if((header.type <= SCI_MSG_TYPE_NONE)
+ || (header.type >= SCI_MSG_TYPE_NB))
+ {
+ clog << logger(LOG_ERROR) << "bad type: " << dec << header.type << endl;
+ continue;
+ }
+ if(header.version != SCI_MSG_VERSION)
+ {
+ clog << logger(LOG_ERROR) << "bad version: " << dec << header.version << endl;
+ continue;
+ }
+ header.magic_id = ntohl(header.magic_id);
+ header.msg_id = ntohs (header.msg_id);
+ header.station_id = ntohs(header.station_id);
+ header.netclock_high = ntohl(header.netclock_high);
+ header.netclock_low = ntohl(header.netclock_low);
+ header.reserved = ntohs(header.reserved);
+ header.flags = ntohs(header.flags);
+
+ buffer = (unsigned char *)malloc(header.length);
+ if((len = read(fd_index, buffer, header.length)) != header.length)
+ {
+ clog << logger(LOG_ERROR) << "data read error: len = " << dec << len << ", errno = " << errno << endl;
+ free(buffer);
+ continue;
+ }
+ receiveMsg(&header, header.length, buffer);
+ free(buffer);
+ }
+ }
+ }
+ }
+ station = NULL;
+
+ // Read log pipes
+ //
+ log();
+
+ return bProcess;
+}
+
+
+bool SciServer::log ( ) const
+{
+ logFunction();
+ bool bLog;
+
+ ofstream stationLogFile;
+ if ( (!getStationLog().empty()) && (getStationLog().compare("-")) )
+ {
+ stationLogFile.open(getStationLog().c_str(), ios_base::app | ios_base::ate | ios_base::out);
+ }
+
+ // Skim through stations list
+ //
+ if ( (NULL != mpListOfStations) && (!mpListOfStations->empty()) )
+ {
+ int length;
+ int maxLength = 1024;
+ char * pBuffer = new char [maxLength];
+
+ for (StationsList::const_iterator it = mpListOfStations->begin(); it != mpListOfStations->end(); ++it)
+ {
+ if (NULL != *it)
+ {
+ // Read logs coming from all stations (from log pipes)
+ //
+ length = 0;
+ memset(pBuffer, '\0', maxLength);
+
+ length = read((*it)->getLogFileDescriptor(), pBuffer, maxLength);
+ if (-1 != length)
+ {
+ if (stationLogFile.is_open())
+ {
+ stationLogFile.write(pBuffer, length);
+ }
+ else
+ {
+ cout << dec << pBuffer;
+ }
+ bLog = true;
+ }
+ }
+ else
+ {
+ throw Error(__PRETTY_FUNCTION__, "A station pointer is NULL");
+ }
+ }
+ }
+
+ stationLogFile.close();
+
+ return bLog;
+}
+
bool SciServer::fillSciMsg ( SciMsg & sci_msg_to_send ) const
{
- clog << "SciServer::fillSciMsg" << endl;
+ logFunction();
bool bFill = false;
// Fill SCI msg data length
@@ -219,7 +366,7 @@ bool SciServer::fillSciMsg ( SciMsg & sci_msg_to_send ) const
bool SciServer::sendSciMsg ( SciMsg & sci_msg_to_send ) const
{
- clog << "<--- SciServer::sendSciMsg" << endl;
+ logFunction();
bool bSend = false;
// Retrieve destination station
@@ -241,7 +388,7 @@ bool SciServer::sendSciMsg ( SciMsg & sci_msg_to_send ) const
//
if (MAXIMUS_STATION_STATUS_IDLE != destination->getStationStatus())
{
- throw Error("SciServer::sendSciMsg", "Cannot send msg because station status is not IDLE");
+ throw Error(__PRETTY_FUNCTION__, "Cannot send msg because station status is not IDLE");
}
else
{
@@ -254,7 +401,7 @@ bool SciServer::sendSciMsg ( SciMsg & sci_msg_to_send ) const
}
else
{
- throw Error("SciServer::sendSciMsg", "Station pointer is NULL");
+ throw Error(__PRETTY_FUNCTION__, "Station pointer is NULL");
}
}
}
@@ -270,17 +417,17 @@ bool SciServer::sendSciMsg ( SciMsg & sci_msg_to_send ) const
length = write(destination->getOutputFileDescriptor(), sci_msg_to_send.getSciMsgData() + totalLength, sci_msg_to_send.getSciMsgDataLength()-totalLength);
if(length < 0)
{
- throw Error("SciServer::sendSciMsg", "Write data failed");
+ throw Error(__PRETTY_FUNCTION__, "Write data failed");
}
totalLength += length;
}
- clog << "\tSCI msg data have been written on pipe" << endl;
+ clog << logger(LOG_INFO) << "SCI msg data have been written on pipe" << endl;
bSend = true;
destination = NULL;
}
else
{
- throw Error("SciServer::sendSciMsg", "Destination station not found");
+ throw Error(__PRETTY_FUNCTION__, "Destination station not found");
}
return bSend;
@@ -289,7 +436,7 @@ bool SciServer::sendSciMsg ( SciMsg & sci_msg_to_send ) const
bool SciServer::sendSciMsgToAllActiveStations ( SciMsg & sci_msg_to_send ) const
{
- clog << "<--- SciServer::sendSciMsgToAllActiveStations" << endl;
+ logFunction();
bool bSend = false;
// Skim through stations list
@@ -329,18 +476,18 @@ bool SciServer::sendSciMsgToAllActiveStations ( SciMsg & sci_msg_to_send ) const
length = write((*it)->getOutputFileDescriptor(), sci_msg_to_send.getSciMsgData() + totalLength, sci_msg_to_send.getSciMsgDataLength()-totalLength);
if(length < 0)
{
- throw Error("SciServer::sendSciMsgToAllActiveStations", "Write data failed");
+ throw Error(__PRETTY_FUNCTION__, "Write data failed");
}
totalLength += length;
}
- clog << "\tSCI msg data have been written on pipe" << endl;
+ clog << logger(LOG_INFO) << "SCI msg data have been written on pipe" << endl;
bSend = true;
}
}
}
else
{
- throw Error("SciServer::sendSciMsgToAllActiveStations", "A station pointer is NULL");
+ throw Error(__PRETTY_FUNCTION__, "A station pointer is NULL");
}
}
}
@@ -351,7 +498,7 @@ bool SciServer::sendSciMsgToAllActiveStations ( SciMsg & sci_msg_to_send ) const
bool SciServer::registerSpecializedSciMsg ( const Sci_Msg_Type sci_msg_type, SciMsg * sci_msg )
{
- clog << "SciServer::registerSpecializedSciMsg" << endl;
+ logFunction();
bool bRegister = false;
if (NULL != sci_msg)
@@ -366,12 +513,12 @@ bool SciServer::registerSpecializedSciMsg ( const Sci_Msg_Type sci_msg_type, Sci
}
else
{
- throw Error(__FUNCTION__, "SCI msg type exceeds specialized SCI msg array size");
+ throw Error(__PRETTY_FUNCTION__, "SCI msg type exceeds specialized SCI msg array size");
}
}
else
{
- throw Error(__FUNCTION__, "Received SCI msg pointer is NULL");
+ throw Error(__PRETTY_FUNCTION__, "SCI msg pointer is NULL");
}
return bRegister;
@@ -382,7 +529,7 @@ bool SciServer::receiveMsg ( const Sci_Msg_Header * header,
const unsigned long data_length,
const unsigned char * received_data ) const
{
- clog << "---> SciServer::receiveMsg" << endl;
+ logFunction();
bool bReceiveMsg = false;
// Log the SCI message header
@@ -415,7 +562,7 @@ bool SciServer::receiveMsg ( const Sci_Msg_Header * header,
}
else
{
- throw Error(__FUNCTION__, "SCI msg not correctly filled in");
+ throw Error(__PRETTY_FUNCTION__, "SCI msg not correctly filled in");
}
// Process SCI msg
@@ -428,44 +575,51 @@ bool SciServer::receiveMsg ( const Sci_Msg_Header * header,
{
// Display SCI msg header
//
- cerr << "\tSCI msg header = " << endl;
- cerr << "\t\tmagic_id = 0x" << setfill('0') << setw(8) << uppercase << hex << sciMsg->getSciMsgHeader()->magic_id << endl;
- cerr << "\t\tversion = 0x" << setfill('0') << setw(2) << uppercase << hex << static_cast<unsigned short int>(sciMsg->getSciMsgHeader()->version) << endl;
- cerr << "\t\ttype = 0x" << setfill('0') << setw(2) << uppercase << hex << static_cast<unsigned short int>(sciMsg->getSciMsgHeader()->type) << endl;
- cerr << "\t\tlength = " << dec << sciMsg->getSciMsgHeader()->length << endl;
- cerr << "\t\tstation_id = 0x" << setfill('0') << setw(4) << uppercase << hex << sciMsg->getSciMsgHeader()->station_id << endl;
- cerr << "\t\tmsg_id = 0x" << setfill('0') << setw(4) << uppercase << hex << sciMsg->getSciMsgHeader()->msg_id << endl;
- cerr << "\t\tnetclock = 0x" << setfill('0') << setw(8) << uppercase << hex << sciMsg->getSciMsgHeader()->netclock_high;
- cerr << setfill('0') << setw(8) << uppercase << hex << sciMsg->getSciMsgHeader()->netclock_low << endl;
- cerr << "\t\tflags = " << dec << sciMsg->getSciMsgHeader()->flags << endl;
- cerr << "\t\treserved = 0x" << setfill('0') << setw(4) << uppercase << hex << sciMsg->getSciMsgHeader()->reserved << endl;
+ clog << logger(LOG_ERROR) << "SCI msg header = " << endl;
+ clog << "\tmagic_id = 0x" << setfill('0') << setw(8) << uppercase << hex << sciMsg->getSciMsgHeader()->magic_id << endl;
+ clog << "\tversion = 0x" << setfill('0') << setw(2) << uppercase << hex << static_cast<unsigned short int>(sciMsg->getSciMsgHeader()->version) << endl;
+ clog << "\ttype = 0x" << setfill('0') << setw(2) << uppercase << hex << static_cast<unsigned short int>(sciMsg->getSciMsgHeader()->type) << endl;
+ clog << "\tlength = " << dec << sciMsg->getSciMsgHeader()->length << endl;
+ clog << "\tstation_id = 0x" << setfill('0') << setw(4) << uppercase << hex << sciMsg->getSciMsgHeader()->station_id << endl;
+ clog << "\tmsg_id = 0x" << setfill('0') << setw(4) << uppercase << hex << sciMsg->getSciMsgHeader()->msg_id << endl;
+ clog << "\tnetclock = 0x" << setfill('0') << setw(8) << uppercase << hex << sciMsg->getSciMsgHeader()->netclock_high;
+ clog << setfill('0') << setw(8) << uppercase << hex << sciMsg->getSciMsgHeader()->netclock_low << endl;
+ clog << "\tflags = " << dec << sciMsg->getSciMsgHeader()->flags << endl;
+ clog << "\treserved = 0x" << setfill('0') << setw(4) << uppercase << hex << sciMsg->getSciMsgHeader()->reserved << endl;
// Display SCI msg data
+ clog << logger(LOG_ERROR) << "SCI msg data = ";
for (unsigned int i=0; i<data_length; i++)
{
- cerr << hex << *(received_data+i);
+ clog << hex << *(received_data+i);
}
+ clog << dec << endl;
- throw Error(__FUNCTION__, "SCI msg not valid");
+ throw Error(__PRETTY_FUNCTION__, "SCI msg not valid");
}
- // Free allocated memory
+ // Free allocated memory if it is not a function SCI message
//
- delete sciMsg;
+ if ( (NULL != sciMsg)
+ && (SCI_MSG_TYPE_FUNCTION_CALL != sciMsg->getSciMsgType()) )
+ {
+ delete sciMsg;
+ sciMsg = NULL;
+ }
}
else
{
- throw Error(__FUNCTION__, "Received data pointer is NULL");
+ throw Error(__PRETTY_FUNCTION__, "Data pointer is NULL");
}
}
else
{
- throw Error(__FUNCTION__, "Error when creating SCI msg");
+ throw Error(__PRETTY_FUNCTION__, "Error when creating SCI msg");
}
}
else
{
- throw Error(__FUNCTION__, "Received SCI msg header pointer is NULL");
+ throw Error(__PRETTY_FUNCTION__, "SCI msg header pointer is NULL");
}
return bReceiveMsg;
@@ -474,20 +628,21 @@ bool SciServer::receiveMsg ( const Sci_Msg_Header * header,
void SciServer::displaySpecializedSciMsgArray ( ) const
{
- //clog << "SciServer::displaySpecializedSciMsgArray" << endl;
+ logFunction();
- clog << "\tspecialized SCI msg array = " << endl;
+ clog << logger(LOG_INFO) << "specialized SCI msg array = " << endl;
for (unsigned int i=0; i<getArraySize(); i++)
{
if (NULL != *(getSpecializedSciMsgArray()+i))
{
- clog << "\t\t" << hex << setfill('0') << setw(8) << uppercase << *(getSpecializedSciMsgArray()+i) << endl;
+ clog << "\t" << hex << setfill('0') << setw(8) << uppercase << *(getSpecializedSciMsgArray()+i) << endl;
}
else
{
- clog << "\t\tNULL" << endl;
+ clog << "\tNULL" << endl;
}
}
+ clog << dec;
}
@@ -495,113 +650,9 @@ void SciServer::displaySpecializedSciMsgArray ( ) const
//
-void * SciServer::serverThread ( void * arg )
-{
- clog << "SciServer::serverThread" << endl;
-
- SciServer *sci_server;
- if(arg == NULL)
- return NULL;
- sci_server = (SciServer *)arg;
-
- int fd_max, fd_index;
- fd_set read_fds;
- struct timeval timeout;
- int result;
- Station *station;
- StationsList::iterator it;
-
- while(sci_server->getStatus() == MAXIMUS_SCI_SERVER_STATUS_RUNNING)
- {
- //cout << "status running" << endl;
- // timeout set to 1sec
- timeout.tv_sec = 1;
- timeout.tv_usec = 0;
- FD_ZERO(&read_fds);
- fd_max = 0;
- pthread_mutex_lock(sci_server->getServerMutex());
- for(it = sci_server->getStationsList()->begin() ; it != sci_server->getStationsList()->end(); it++)
- {
- station = *it;
-
- FD_SET(station->getInputFileDescriptor(), &read_fds);
- if(station->getInputFileDescriptor() > fd_max)
- fd_max = station->getInputFileDescriptor();
- }
-
- pthread_mutex_unlock(sci_server->getServerMutex());
- result = select(fd_max + 1, &read_fds, NULL, NULL, &timeout);
- pthread_mutex_lock(sci_server->getServerMutex());
-
- if(result > 0)
- {
- // skim through the list...
- for(fd_index = 0; fd_index <= fd_max; fd_index++)
- {
- if(FD_ISSET(fd_index, &read_fds))
- {
- int len, header_len;
- struct Sci_Msg_Header header;
- unsigned char *buffer;
- header_len = sizeof(struct Sci_Msg_Header);
- if((len = read(fd_index, &header, sizeof(struct Sci_Msg_Header))) < header_len)
- {
- //cerr << "\theader read error: len=" << dec << len << ", errno=" << errno << endl;
- continue;
- }
- else
- {
- // check for header
- if(memcmp(&header.magic_id, SCI_MSG_MAGIC, 4))
- {
- cerr << "\tbad magic id: 0x" << hex << htonl(header.magic_id) << endl;
- continue;
- }
- header.length = ntohs (header.length);
- if((header.type <= SCI_MSG_TYPE_NONE)
- || (header.type >= SCI_MSG_TYPE_NB))
- {
- cerr << "\tbad type: " << dec << header.type << endl;
- continue;
- }
- if(header.version != SCI_MSG_VERSION)
- {
- cerr << "\tbad version: " << dec << header.version << endl;
- continue;
- }
- header.magic_id = ntohl(header.magic_id);
- header.msg_id = ntohs (header.msg_id);
- header.station_id = ntohs(header.station_id);
- header.netclock_high = ntohl(header.netclock_high);
- header.netclock_low = ntohl(header.netclock_low);
- header.reserved = ntohs(header.reserved);
- header.flags = ntohs(header.flags);
-
- buffer = (unsigned char *)malloc(header.length);
- if((len = read(fd_index, buffer, header.length)) != header.length)
- {
- cerr << "\tdata read error: len=" << dec << len << ", errno=" << errno << endl;
- free(buffer);
- continue;
- }
- sci_server->receiveMsg(&header, header.length, buffer);
- free(buffer);
- }
- }
- }
- }
- pthread_mutex_unlock(sci_server->getServerMutex());
- }
- sci_server->setStatus(MAXIMUS_SCI_SERVER_STATUS_STOPPED);
- station = NULL;
-
- return NULL;
-}
-
-
bool SciServer::createSciMsg ( const Sci_Msg_Type type, SciMsg ** received_sci_msg ) const
{
- //clog << "SciServer::createSciMsg" << endl;
+ logFunction();
bool bCreateMsg = false;
// Create a specialized SCI message according to the header type
@@ -614,7 +665,7 @@ bool SciServer::createSciMsg ( const Sci_Msg_Type type, SciMsg ** received_sci_m
}
else
{
- throw Error(__FUNCTION__, "Received SCI msg type is invalid: no corresponding SCI msg");
+ throw Error(__PRETTY_FUNCTION__, "SCI msg type is invalid: no corresponding SCI msg");
}
// Check if the just created SCI msg is valid
@@ -625,12 +676,12 @@ bool SciServer::createSciMsg ( const Sci_Msg_Type type, SciMsg ** received_sci_m
}
else
{
- throw Error(__FUNCTION__, "Initialized SCI msg pointer is invalid");
+ throw Error(__PRETTY_FUNCTION__, "SCI msg pointer is invalid");
}
}
else
{
- throw Error(__FUNCTION__, "Received SCI msg pointer is invalid");
+ throw Error(__PRETTY_FUNCTION__, "SCI msg pointer is invalid");
}
return bCreateMsg;
@@ -642,7 +693,7 @@ bool SciServer::fillSciMsg ( const Sci_Msg_Header * p_msg_header,
const unsigned char * p_received_data,
SciMsg ** created_sci_msg ) const
{
- //clog << "SciServer::fillSciMsg" << endl;
+ logFunction();
bool bFillMsg = false;
// Fill SCI message contents
@@ -673,17 +724,17 @@ bool SciServer::fillSciMsg ( const Sci_Msg_Header * p_msg_header,
}
else
{
- throw Error(__FUNCTION__, "Received data pointer is NULL");
+ throw Error(__PRETTY_FUNCTION__, "Data pointer is NULL");
}
}
else
{
- throw Error(__FUNCTION__, "Received SCI msg header pointer is NULL");
+ throw Error(__PRETTY_FUNCTION__, "SCI msg header pointer is NULL");
}
}
else
{
- throw Error(__FUNCTION__, "Received SCI msg pointer is invalid");
+ throw Error(__PRETTY_FUNCTION__, "SCI msg pointer is NULL");
}
return bFillMsg;
@@ -692,7 +743,7 @@ bool SciServer::fillSciMsg ( const Sci_Msg_Header * p_msg_header,
bool SciServer::processSciMsg ( SciMsg * received_sci_msg ) const
{
- //clog << "SciServer::processSciMsg" << endl;
+ logFunction();
bool bProcessMsg = false;
if (NULL != received_sci_msg)
@@ -701,34 +752,11 @@ bool SciServer::processSciMsg ( SciMsg * received_sci_msg ) const
}
else
{
- throw Error(__FUNCTION__, "Received SCI msg pointer is NULL");
+ throw Error(__PRETTY_FUNCTION__, "SCI msg pointer is NULL");
}
return bProcessMsg;
}
-
-
-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
@@ -746,41 +774,7 @@ void SciServer::displayStatus ( ) const
// private attribute accessor methods
//
-
-pthread_mutex_t * SciServer::getServerMutex ( )
-{
- return &mServerMutex;
-}
-
-
-Sci_Server_Status SciServer::getStatus ( ) const
-{
- return mStatus;
-}
-
-
-bool SciServer::setStatus ( const Sci_Server_Status new_status ) throw (Error)
-{
- //clog << "SciServer::setStatus" << endl;
- bool bSetStatus = false;
- if((new_status < 0) || (new_status >= MAXIMUS_SCI_SERVER_STATUS_NB))
- {
- throw new Error(__FUNCTION__, "", EINVAL);
- }
- else
- {
- mStatus = new_status;
- clog << "\tstatus = ";
- displayStatus();
- clog << endl;
- bSetStatus = true;
- }
-
- return bSetStatus;
-}
-
-
StationsList * SciServer::getStationsList ( ) const
{
return mpListOfStations;
@@ -789,9 +783,8 @@ StationsList * SciServer::getStationsList ( ) const
bool SciServer::setStationsList ( StationsList * stations_list )
{
- //clog << "SciServer::setStationsList" << endl;
+ logFunction();
bool bSetList = false;
- StationsList::iterator it;
if (NULL != stations_list)
{
@@ -800,7 +793,7 @@ bool SciServer::setStationsList ( StationsList * stations_list )
}
else
{
- throw Error(__FUNCTION__, "Received stations list pointer is NULL");
+ throw Error(__PRETTY_FUNCTION__, "List of stations pointer is NULL");
}
return bSetList;
@@ -828,10 +821,17 @@ Network_Clock_Tick SciServer::getNetworkClockTick ( ) const
bool SciServer::updateTickValue ( const Network_Clock_Tick current_tick_value )
{
mNetworkClockTick = current_tick_value;
+
return true;
}
+std::string SciServer::getStationLog ( ) const
+{
+ return mStationLog;
+}
+
+
// protected attribute accessor methods
//