Skip to content
Snippets Groups Projects
Commit a2b1417f authored by Ruud Overeem's avatar Ruud Overeem
Browse files

BugID: 796

Added code to update the PVSS Dynamic String Array 'activeObservations'.
parent 6eee871e
No related merge requests found
...@@ -58,8 +58,8 @@ MACScheduler::MACScheduler() : ...@@ -58,8 +58,8 @@ MACScheduler::MACScheduler() :
PropertySetAnswerHandlerInterface(), PropertySetAnswerHandlerInterface(),
itsPropertySetAnswer(*this), itsPropertySetAnswer(*this),
itsPropertySet (), itsPropertySet (),
// itsObsCntlrMap (),
itsObservations (), itsObservations (),
itsPVSSObsList (),
itsTimerPort (0), itsTimerPort (0),
itsChildControl (0), itsChildControl (0),
itsChildPort (0), itsChildPort (0),
...@@ -87,6 +87,8 @@ MACScheduler::MACScheduler() : ...@@ -87,6 +87,8 @@ MACScheduler::MACScheduler() :
// need port for timers // need port for timers
itsTimerPort = new GCFTimerPort(*this, "Timerport"); itsTimerPort = new GCFTimerPort(*this, "Timerport");
itsObservations.reserve(10); // already reserve memory for 10 observations.
registerProtocol (CONTROLLER_PROTOCOL, CONTROLLER_PROTOCOL_signalnames); registerProtocol (CONTROLLER_PROTOCOL, CONTROLLER_PROTOCOL_signalnames);
registerProtocol(PA_PROTOCOL, PA_PROTOCOL_signalnames); registerProtocol(PA_PROTOCOL, PA_PROTOCOL_signalnames);
} }
...@@ -153,7 +155,7 @@ void MACScheduler::handlePropertySetAnswer(GCFEvent& answer) ...@@ -153,7 +155,7 @@ void MACScheduler::handlePropertySetAnswer(GCFEvent& answer)
// TODO: implement something usefull. // TODO: implement something usefull.
// change of queueTime // change of queueTime
if ((strstr(pPropAnswer->pPropName, MS_PROPSET_NAME) != 0) && if ((strstr(pPropAnswer->pPropName, PSN_MAC_SCHEDULER) != 0) &&
(pPropAnswer->pValue->getType() == LPT_INTEGER)) { (pPropAnswer->pValue->getType() == LPT_INTEGER)) {
uint32 newVal = (uint32) ((GCFPVInteger*)pPropAnswer->pValue)->getValue(); uint32 newVal = (uint32) ((GCFPVInteger*)pPropAnswer->pValue)->getValue();
if (strstr(pPropAnswer->pPropName, PVSSNAME_MS_QUEUEPERIOD) != 0) { if (strstr(pPropAnswer->pPropName, PVSSNAME_MS_QUEUEPERIOD) != 0) {
...@@ -194,8 +196,8 @@ GCFEvent::TResult MACScheduler::initial_state(GCFEvent& event, GCFPortInterface& ...@@ -194,8 +196,8 @@ GCFEvent::TResult MACScheduler::initial_state(GCFEvent& event, GCFPortInterface&
case F_ENTRY: { case F_ENTRY: {
// Get access to my own propertyset. // Get access to my own propertyset.
LOG_DEBUG ("Activating PropertySet"); LOG_DEBUG ("Activating PropertySet");
itsPropertySet = GCFMyPropertySetPtr(new GCFMyPropertySet(MS_PROPSET_NAME, itsPropertySet = GCFMyPropertySetPtr(new GCFMyPropertySet(PSN_MAC_SCHEDULER,
MS_PROPSET_TYPE, PST_MAC_SCHEDULER,
PS_CAT_PERM_AUTOLOAD, PS_CAT_PERM_AUTOLOAD,
&itsPropertySetAnswer)); &itsPropertySetAnswer));
itsPropertySet->enable(); itsPropertySet->enable();
...@@ -206,11 +208,11 @@ GCFEvent::TResult MACScheduler::initial_state(GCFEvent& event, GCFPortInterface& ...@@ -206,11 +208,11 @@ GCFEvent::TResult MACScheduler::initial_state(GCFEvent& event, GCFPortInterface&
case F_TIMER: { // must be timer that PropSet is enabled. case F_TIMER: { // must be timer that PropSet is enabled.
// update PVSS. // update PVSS.
LOG_TRACE_FLOW ("Updateing state to PVSS"); LOG_TRACE_FLOW ("Updateing state to PVSS");
itsPropertySet->setValue(string(PVSSNAME_FSM_STATE),GCFPVString ("initial")); itsPropertySet->setValue(string(PVSSNAME_FSM_STATE), GCFPVString ("initial"));
itsPropertySet->setValue(string(PVSSNAME_FSM_ERROR),GCFPVString ("")); itsPropertySet->setValue(string(PVSSNAME_FSM_ERROR), GCFPVString (""));
itsPropertySet->setValue(string(MS_OTDB_CONNECTED), GCFPVBool (false)); itsPropertySet->setValue(string(PN_MS_OTDB_CONNECTED), GCFPVBool (false));
itsPropertySet->setValue(string(MS_OTDB_LASTPOLL), GCFPVString ("")); itsPropertySet->setValue(string(PN_MS_OTDB_LAST_POLL), GCFPVString (""));
itsPropertySet->setValue(string(MS_OTDB_POLL_ITV), GCFPVUnsigned(itsOTDBpollInterval)); itsPropertySet->setValue(string(PN_MS_OTDB_POLLINTERVAL), GCFPVUnsigned(itsOTDBpollInterval));
// Try to connect to the SAS database. // Try to connect to the SAS database.
...@@ -226,7 +228,7 @@ GCFEvent::TResult MACScheduler::initial_state(GCFEvent& event, GCFPortInterface& ...@@ -226,7 +228,7 @@ GCFEvent::TResult MACScheduler::initial_state(GCFEvent& event, GCFPortInterface&
"Unable to connect to database " << DBname << " using " << "Unable to connect to database " << DBname << " using " <<
username << "," << password); username << "," << password);
LOG_INFO ("Connected to the OTDB"); LOG_INFO ("Connected to the OTDB");
itsPropertySet->setValue(string(MS_OTDB_CONNECTED),GCFPVBool(true)); itsPropertySet->setValue(string(PN_MS_OTDB_CONNECTED),GCFPVBool(true));
// Start ChildControl task // Start ChildControl task
LOG_DEBUG ("Enabling ChildControltask"); LOG_DEBUG ("Enabling ChildControltask");
...@@ -365,7 +367,7 @@ GCFEvent::TResult MACScheduler::active_state(GCFEvent& event, GCFPortInterface& ...@@ -365,7 +367,7 @@ GCFEvent::TResult MACScheduler::active_state(GCFEvent& event, GCFPortInterface&
LOG_ERROR_STR("Observation controller " << msg.cntlrName << LOG_ERROR_STR("Observation controller " << msg.cntlrName <<
" could not be started"); " could not be started");
LOG_INFO("Observation will be removed from administration"); LOG_INFO("Observation will be removed from administration");
itsObservations.erase(msg.cntlrName); _removeActiveObservation(msg.cntlrName);
} }
break; break;
} }
...@@ -384,7 +386,7 @@ GCFEvent::TResult MACScheduler::active_state(GCFEvent& event, GCFPortInterface& ...@@ -384,7 +386,7 @@ GCFEvent::TResult MACScheduler::active_state(GCFEvent& event, GCFPortInterface&
LOG_DEBUG_STR("Received FINISH(" << finishEvent.cntlrName << ")"); LOG_DEBUG_STR("Received FINISH(" << finishEvent.cntlrName << ")");
LOG_DEBUG_STR("Removing observation " << finishEvent.cntlrName << LOG_DEBUG_STR("Removing observation " << finishEvent.cntlrName <<
" from activeList"); " from activeList");
itsObservations.erase(finishEvent.cntlrName); _removeActiveObservation(finishEvent.cntlrName);
break; break;
} }
...@@ -423,7 +425,7 @@ void MACScheduler::_doOTDBcheck() ...@@ -423,7 +425,7 @@ void MACScheduler::_doOTDBcheck()
ASSERTSTR (currentTime != not_a_date_time, "Can't determine systemtime, bailing out"); ASSERTSTR (currentTime != not_a_date_time, "Can't determine systemtime, bailing out");
// REO: test pvss appl // REO: test pvss appl
itsPropertySet->setValue(string(MS_OTDB_LASTPOLL), itsPropertySet->setValue(string(PN_MS_OTDB_LAST_POLL),
GCFPVString(to_simple_string(currentTime))); GCFPVString(to_simple_string(currentTime)));
while (idx < listSize) { while (idx < listSize) {
...@@ -468,7 +470,7 @@ void MACScheduler::_doOTDBcheck() ...@@ -468,7 +470,7 @@ void MACScheduler::_doOTDBcheck()
Observation newObs(&obsPS); Observation newObs(&obsPS);
newObs.name = cntlrName; newObs.name = cntlrName;
newObs.treeID = treeID; newObs.treeID = treeID;
itsObservations[cntlrName] = newObs; _addActiveObservation(newObs);
LOG_DEBUG_STR("Observation " << cntlrName << " added to active Observations"); LOG_DEBUG_STR("Observation " << cntlrName << " added to active Observations");
} }
idx++; idx++;
...@@ -495,6 +497,63 @@ void MACScheduler::_doOTDBcheck() ...@@ -495,6 +497,63 @@ void MACScheduler::_doOTDBcheck()
} }
//
// _addActiveObservation(name)
//
void MACScheduler::_addActiveObservation(const Observation& newObs)
{
// Observation already in vector?
vector<Observation>::iterator end = itsObservations.end();
vector<Observation>::iterator iter = itsObservations.begin();
while (iter != end) {
if (iter->name == newObs.name) {
return;
}
}
// update own admin and PVSS datapoint
itsObservations.push_back(newObs);
itsPVSSObsList.push_back(new GCFPVString(newObs.name));
itsPropertySet->setValue(PN_MS_ACTIVE_OBSERVATIONS, GCFPVDynArr(LPT_STRING, itsPVSSObsList));
LOG_DEBUG_STR("Added observation " << newObs.name << " to active observation-list");
}
//
// _removeActiveObservation(name)
//
void MACScheduler::_removeActiveObservation(const string& name)
{
// search observation.
vector<Observation>::iterator end = itsObservations.end();
vector<Observation>::iterator iter = itsObservations.begin();
bool found(false);
while (!found && (iter != end)) {
if (iter->name == name) {
found = true;
itsObservations.erase(iter);
LOG_DEBUG_STR("Removed observation " << name << " from active observationList");
}
}
if (!found) {
return;
}
GCFPValueArray::iterator pEnd = itsPVSSObsList.end();
GCFPValueArray::iterator pIter = itsPVSSObsList.begin();
while (pIter != pEnd) {
if ((static_cast<GCFPVString*>(*pIter))->getValue() == name) {
delete *pIter;
itsPVSSObsList.erase(pIter);
break;
}
}
itsPropertySet->setValue(PN_MS_ACTIVE_OBSERVATIONS, GCFPVDynArr(LPT_STRING, itsPVSSObsList));
}
// //
// _connectedHandler(port) // _connectedHandler(port)
......
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
//# GCF Includes //# GCF Includes
#include <GCF/PAL/GCF_MyPropertySet.h> #include <GCF/PAL/GCF_MyPropertySet.h>
#include <GCF/GCF_PVDynArr.h>
#include <GCF/GCF_PVString.h>
#include <GCF/TM/GCF_Port.h> #include <GCF/TM/GCF_Port.h>
#include <GCF/TM/GCF_ITCPort.h> #include <GCF/TM/GCF_ITCPort.h>
#include <GCF/TM/GCF_TimerPort.h> #include <GCF/TM/GCF_TimerPort.h>
...@@ -97,6 +99,8 @@ private: ...@@ -97,6 +99,8 @@ private:
MACScheduler(const MACScheduler&); MACScheduler(const MACScheduler&);
MACScheduler& operator=(const MACScheduler&); MACScheduler& operator=(const MACScheduler&);
void _addActiveObservation(const Observation& newObs);
void _removeActiveObservation(const string& name);
void _connectedHandler(GCFPortInterface& port); void _connectedHandler(GCFPortInterface& port);
void _disconnectedHandler(GCFPortInterface& port); void _disconnectedHandler(GCFPortInterface& port);
void _doOTDBcheck(); void _doOTDBcheck();
...@@ -107,7 +111,8 @@ private: ...@@ -107,7 +111,8 @@ private:
GCFMyPropertySetPtr itsPropertySet; GCFMyPropertySetPtr itsPropertySet;
// Information about the Observations. Not used yet. // Information about the Observations. Not used yet.
map<string,Observation> itsObservations; vector<Observation> itsObservations;
GCF::Common::GCFPValueArray itsPVSSObsList;
// Ports for StartDaemon and ObservationControllers. // Ports for StartDaemon and ObservationControllers.
GCFTimerPort* itsTimerPort; // for timers GCFTimerPort* itsTimerPort; // for timers
......
...@@ -28,11 +28,12 @@ namespace LOFAR { ...@@ -28,11 +28,12 @@ namespace LOFAR {
#define MS_TASKNAME "MACScheduler" #define MS_TASKNAME "MACScheduler"
#define MS_PROPSET_NAME "LOFAR_PermSW_MacScheduler" #define PSN_MAC_SCHEDULER "LOFAR_PermSW_MACScheduler"
#define MS_PROPSET_TYPE "MacScheduler" #define PST_MAC_SCHEDULER "MACScheduler"
#define MS_OTDB_CONNECTED "OTDB.connected" #define PN_MS_ACTIVE_OBSERVATIONS "activeObservations"
#define MS_OTDB_LASTPOLL "OTDB.lastPoll" #define PN_MS_OTDB_CONNECTED "OTDB.connected"
#define MS_OTDB_POLL_ITV "OTDB.pollinterval" #define PN_MS_OTDB_LAST_POLL "OTDB.lastPoll"
#define PN_MS_OTDB_POLLINTERVAL "OTDB.pollinterval"
#define PVSSNAME_MS_QUEUEPERIOD "QueuePeriod" #define PVSSNAME_MS_QUEUEPERIOD "QueuePeriod"
#define PVSSNAME_MS_CLAIMPERIOD "ClaimPeriod" #define PVSSNAME_MS_CLAIMPERIOD "ClaimPeriod"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment