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

BugID: 679

Renamed state UNKNOWN to state NOSTATE. Changed names of PVSS variables
to their final(?) names.
parent 7222dfe9
No related branches found
No related tags found
No related merge requests found
...@@ -2,8 +2,21 @@ ...@@ -2,8 +2,21 @@
# DpType # DpType
TypeName TypeName
SwCntrl.MacScheduler 1#1 LOFAR.LOFAR 1#1
state 25#2
TypeName
PermSW.PermSW 1#1
state 25#2
TypeName
MacScheduler.MacScheduler 1#1
state 25#2 state 25#2
error 25#3 error 25#3
activeObservations 9#4
OTDB 1#5
connected 23#6
lastPoll 25#7
pollinterval 20#8
...@@ -149,7 +149,7 @@ bool ChildControl::startChild (const string& aName, ...@@ -149,7 +149,7 @@ bool ChildControl::startChild (const string& aName,
ci.hostname = hostname; ci.hostname = hostname;
ci.requestedState = LDState::CONNECTED; ci.requestedState = LDState::CONNECTED;
ci.requestTime = time(0); ci.requestTime = time(0);
ci.currentState = LDState::UNKNOWN; ci.currentState = LDState::NOSTATE;
ci.establishTime = 0; ci.establishTime = 0;
ci.retryTime = 0; ci.retryTime = 0;
ci.nrRetries = 0; ci.nrRetries = 0;
...@@ -222,7 +222,7 @@ LDState::LDstateNr ChildControl::getCurrentState (const string& aName) ...@@ -222,7 +222,7 @@ LDState::LDstateNr ChildControl::getCurrentState (const string& aName)
{ {
CIiter controller = findController(aName); CIiter controller = findController(aName);
if (controller == itsCntlrList.end()) { if (controller == itsCntlrList.end()) {
return (LDState::UNKNOWN); return (LDState::NOSTATE);
} }
return (controller->currentState); return (controller->currentState);
...@@ -237,7 +237,7 @@ LDState::LDstateNr ChildControl::getRequestedState (const string& aName) ...@@ -237,7 +237,7 @@ LDState::LDstateNr ChildControl::getRequestedState (const string& aName)
{ {
CIiter controller = findController(aName); CIiter controller = findController(aName);
if (controller == itsCntlrList.end()) { if (controller == itsCntlrList.end()) {
return (LDState::UNKNOWN); return (LDState::NOSTATE);
} }
return (controller->requestedState); return (controller->requestedState);
...@@ -437,7 +437,7 @@ void ChildControl::_processActionList() ...@@ -437,7 +437,7 @@ void ChildControl::_processActionList()
} }
break; break;
case LDState::RESUMED: case LDState::ACTIVE:
{ {
LOGICALDEVICEResumeEvent request; LOGICALDEVICEResumeEvent request;
controller->port->send(request); controller->port->send(request);
......
...@@ -36,15 +36,14 @@ namespace LOFAR { ...@@ -36,15 +36,14 @@ namespace LOFAR {
LDState::LDState() LDState::LDState()
{ {
itsStates.resize(LAST_STATE); itsStates.resize(LAST_STATE);
itsStates[UNKNOWN] = "Unknown"; itsStates[NOSTATE] = "Unknown";
itsStates[CONNECT] = "Connecting"; itsStates[CONNECT] = "Connecting";
itsStates[CONNECTED] = "Connected"; itsStates[CONNECTED] = "Connected";
itsStates[CLAIM] = "Claiming"; itsStates[CLAIM] = "Claiming";
itsStates[CLAIMED] = "Claimed"; itsStates[CLAIMED] = "Claimed";
itsStates[PREPARE] = "Preparing"; itsStates[PREPARE] = "Preparing";
itsStates[PREPARED] = "Prepared"; itsStates[PREPARED] = "Prepared";
itsStates[RESUME] = "Resuming"; itsStates[ACTIVE] = "Active";
itsStates[RESUMED] = "Resumed";
itsStates[SUSPEND] = "Suspending"; itsStates[SUSPEND] = "Suspending";
itsStates[SUSPENDED] = "Suspended"; itsStates[SUSPENDED] = "Suspended";
itsStates[RELEASE] = "Releasing"; itsStates[RELEASE] = "Releasing";
...@@ -65,7 +64,7 @@ LDState::~LDState() ...@@ -65,7 +64,7 @@ LDState::~LDState()
// //
string LDState::name(uint16 aStateNr) string LDState::name(uint16 aStateNr)
{ {
return (((aStateNr >= UNKNOWN) && (aStateNr < LAST_STATE)) ? return (((aStateNr >= NOSTATE) && (aStateNr < LAST_STATE)) ?
itsStates[aStateNr] : ""); itsStates[aStateNr] : "");
} }
...@@ -74,7 +73,7 @@ string LDState::name(uint16 aStateNr) ...@@ -74,7 +73,7 @@ string LDState::name(uint16 aStateNr)
// //
uint16 LDState::value(const string& aStateName) uint16 LDState::value(const string& aStateName)
{ {
uint16 i = UNKNOWN; uint16 i = NOSTATE;
while (i < LAST_STATE) { while (i < LAST_STATE) {
if (itsStates[i] == aStateName) { if (itsStates[i] == aStateName) {
return (i); return (i);
...@@ -90,7 +89,7 @@ uint16 LDState::value(const string& aStateName) ...@@ -90,7 +89,7 @@ uint16 LDState::value(const string& aStateName)
// //
uint16 LDState::value(LDstateNr aStateNr) uint16 LDState::value(LDstateNr aStateNr)
{ {
ASSERTSTR((aStateNr >= UNKNOWN) && (aStateNr < LAST_STATE), ASSERTSTR((aStateNr >= NOSTATE) && (aStateNr < LAST_STATE),
aStateNr << " is not a valid LDState"); aStateNr << " is not a valid LDState");
return ((uint16) aStateNr); return ((uint16) aStateNr);
......
...@@ -49,15 +49,15 @@ public: ...@@ -49,15 +49,15 @@ public:
// define enumeration for all states of an LogicalDevice. // define enumeration for all states of an LogicalDevice.
typedef enum { typedef enum {
UNKNOWN = 0, ANYSTATE = -1,
NOSTATE = 0,
CONNECT, CONNECT,
CONNECTED, CONNECTED,
CLAIM, CLAIM,
CLAIMED, CLAIMED,
PREPARE, PREPARE,
PREPARED, PREPARED,
RESUME, ACTIVE,
RESUMED,
SUSPEND, SUSPEND,
SUSPENDED, SUSPENDED,
RELEASE, RELEASE,
......
...@@ -25,11 +25,10 @@ ...@@ -25,11 +25,10 @@
#include <boost/shared_array.hpp> #include <boost/shared_array.hpp>
#include <APS/ParameterSet.h> #include <APS/ParameterSet.h>
#include <GCF/GCF_ServiceInfo.h> #include <GCF/GCF_ServiceInfo.h>
#include <GCF/GCF_PVString.h> #include <GCF/GCF_PVTypes.h>
#include <GCF/GCF_PVDouble.h>
#include <GCF/GCF_PVInteger.h>
#include <GCF/PAL/GCF_PVSSInfo.h> #include <GCF/PAL/GCF_PVSSInfo.h>
#include <GCF/Utils.h> #include <GCF/Utils.h>
#include <APL/APLCommon/APL_Defines.h>
#include <APL/APLCommon/APLCommonExceptions.h> #include <APL/APLCommon/APLCommonExceptions.h>
#include "MACSchedulerDefines.h" #include "MACSchedulerDefines.h"
...@@ -180,14 +179,18 @@ GCFEvent::TResult MACScheduler::initial_state(GCFEvent& event, GCFPortInterface& ...@@ -180,14 +179,18 @@ GCFEvent::TResult MACScheduler::initial_state(GCFEvent& event, GCFPortInterface&
LOG_DEBUG ("Activating PropertySet"); LOG_DEBUG ("Activating PropertySet");
itsPropertySet = GCFMyPropertySetPtr(new GCFMyPropertySet(MS_PROPSET_NAME, itsPropertySet = GCFMyPropertySetPtr(new GCFMyPropertySet(MS_PROPSET_NAME,
MS_PROPSET_TYPE, MS_PROPSET_TYPE,
PS_CAT_PERMANENT, PS_CAT_PERM_AUTOLOAD,
&itsPropertySetAnswer)); &itsPropertySetAnswer));
itsPropertySet->enable(); itsPropertySet->enable();
// 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(MS_OTDB_LASTPOLL), GCFPVString (""));
itsPropertySet->setValue(string(MS_OTDB_POLL_ITV), GCFPVUnsigned(itsOTDBpollInterval));
// Try to connect to the SAS database. // Try to connect to the SAS database.
ACC::APS::ParameterSet* pParamSet = ACC::APS::globalParameterSet(); ACC::APS::ParameterSet* pParamSet = ACC::APS::globalParameterSet();
...@@ -202,6 +205,7 @@ GCFEvent::TResult MACScheduler::initial_state(GCFEvent& event, GCFPortInterface& ...@@ -202,6 +205,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));
// Start ChildControl task // Start ChildControl task
LOG_DEBUG ("Enabling ChildControltask"); LOG_DEBUG ("Enabling ChildControltask");
...@@ -217,8 +221,6 @@ GCFEvent::TResult MACScheduler::initial_state(GCFEvent& event, GCFPortInterface& ...@@ -217,8 +221,6 @@ GCFEvent::TResult MACScheduler::initial_state(GCFEvent& event, GCFPortInterface&
break; break;
case F_DISCONNECTED: case F_DISCONNECTED:
itsPropertySet->setValue(string(PVSSNAME_FSM_ERROR),
GCFPVString("Waiting for StartDaemon"));
break; break;
case F_TIMER: case F_TIMER:
...@@ -379,7 +381,8 @@ void MACScheduler::_doOTDBcheck() ...@@ -379,7 +381,8 @@ 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(PVSSNAME_FSM_STATE),GCFPVString(to_simple_string(currentTime))); itsPropertySet->setValue(string(MS_OTDB_LASTPOLL),
GCFPVString(to_simple_string(currentTime)));
while (idx < listSize) { while (idx < listSize) {
// timediff = time to go before start of Observation // timediff = time to go before start of Observation
...@@ -398,11 +401,24 @@ void MACScheduler::_doOTDBcheck() ...@@ -398,11 +401,24 @@ void MACScheduler::_doOTDBcheck()
// remember: timediff <= queueperiod // remember: timediff <= queueperiod
if (timediff > seconds(itsClaimPeriod)) { if (timediff > seconds(itsClaimPeriod)) {
// Observation is somewhere in the queueperiod // Observation is somewhere in the queueperiod
if (observationState != LDState::CONNECTED) { if (observationState != LDState::CONNECTED) { // requested a start before?
itsChildControl->startChild(cntlrName, // no, let database construct the parset for the whole observation
newTreeList[idx].treeID(), OTDB::TreeMaintenance tm(itsOTDBconnection);
OTDB::treeIDType treeID = newTreeList[idx].treeID();
OTDBnode topNode = tm.getTopNode(treeID);
string filename = formatString("%s/Observation_%d",
LOFAR_SHARE_LOCATION, treeID);
if (!tm.exportTree(treeID, topNode.nodeID(), filename)) {
LOG_ERROR_STR ("Cannot create startup file " << filename <<
" for new observation. Observation CANNOT BE STARTED!");
}
else {
// fire request for new controller
itsChildControl->startChild(cntlrName,
treeID,
LDTYPE_OBSERVATIONCTRL, LDTYPE_OBSERVATIONCTRL,
myHostname()); myHostname());
}
idx++; idx++;
continue; continue;
} }
...@@ -418,7 +434,7 @@ void MACScheduler::_doOTDBcheck() ...@@ -418,7 +434,7 @@ void MACScheduler::_doOTDBcheck()
} }
// observation must be running (otherwise it would not be in the newTreeList) // observation must be running (otherwise it would not be in the newTreeList)
if (observationState != LDState::RESUMED) { if (observationState != LDState::ACTIVE) {
// _executeObservation(&newTreeList[idx]); // _executeObservation(&newTreeList[idx]);
} }
......
...@@ -28,8 +28,11 @@ namespace LOFAR { ...@@ -28,8 +28,11 @@ namespace LOFAR {
#define MS_TASKNAME "MACScheduler" #define MS_TASKNAME "MACScheduler"
#define MS_PROPSET_NAME "SwCntrl" #define MS_PROPSET_NAME "LOFAR_PermSW_MacScheduler"
#define MS_PROPSET_TYPE "MacScheduler" #define MS_PROPSET_TYPE "MacScheduler"
#define MS_OTDB_CONNECTED "OTDB.connected"
#define MS_OTDB_LASTPOLL "OTDB.lastPoll"
#define MS_OTDB_POLL_ITV "OTDB.pollInterval"
#define PVSSNAME_MS_QUEUEPERIOD "QueuePeriod" #define PVSSNAME_MS_QUEUEPERIOD "QueuePeriod"
#define PVSSNAME_MS_CLAIMPERIOD "ClaimPeriod" #define PVSSNAME_MS_CLAIMPERIOD "ClaimPeriod"
......
...@@ -8,7 +8,8 @@ MACScheduler_CPPFLAGS = -DBOOST_DISABLE_THREADS \ ...@@ -8,7 +8,8 @@ MACScheduler_CPPFLAGS = -DBOOST_DISABLE_THREADS \
MACScheduler_SOURCES = MACScheduler.cc \ MACScheduler_SOURCES = MACScheduler.cc \
MACSchedulerMain.cc \ MACSchedulerMain.cc \
ChildControl.cc \ ChildControl.cc \
LDState.cc LDState.cc \
Controller.cc
MACScheduler_LDADD = -lpqxx $(LOFAR_DEPEND) MACScheduler_LDADD = -lpqxx $(LOFAR_DEPEND)
MACScheduler_DEPENDENCIES = $(LOFAR_DEPEND) MACScheduler_DEPENDENCIES = $(LOFAR_DEPEND)
......
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