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

BugID: 797

ObservationController now also creates the top DP of the observation:
LOFAR_ObsSW_Observation%d.
Fixed some bugs in interpreting the PVSS values.
parent 6c7b81cb
No related branches found
No related tags found
No related merge requests found
...@@ -183,14 +183,21 @@ void ObservationControl::handlePropertySetAnswer(GCFEvent& answer) ...@@ -183,14 +183,21 @@ void ObservationControl::handlePropertySetAnswer(GCFEvent& answer)
case F_VGETRESP: case F_VGETRESP:
case F_VCHANGEMSG: { case F_VCHANGEMSG: {
// check which property changed // check which propertySet(!) changed
GCFPropValueEvent* pPropAnswer=static_cast<GCFPropValueEvent*>(&answer); GCFPropValueEvent* pPropAnswer=static_cast<GCFPropValueEvent*>(&answer);
string PropSetName = createPropertySetName(PSN_OBS_CTRL, getName()); string PropSetName = createPropertySetName(PSN_OBS_CTRL, getName());
if (strstr(pPropAnswer->pPropName, PropSetName.c_str()) == 0) { if (strstr(pPropAnswer->pPropName, PropSetName.c_str()) == 0) {
break; break; // if not my own, exit
} }
// don't watch state and error fields.
if ((strstr(pPropAnswer->pPropName, PVSSNAME_FSM_STATE) != 0) ||
(strstr(pPropAnswer->pPropName, PVSSNAME_FSM_ERROR) != 0)) {
return;
}
// periods are of type integer.
if (pPropAnswer->pValue->getType() == LPT_INTEGER) { if (pPropAnswer->pValue->getType() == LPT_INTEGER) {
uint32 newVal = (uint32) ((GCFPVInteger*)pPropAnswer->pValue)->getValue(); uint32 newVal = (uint32) ((GCFPVInteger*)pPropAnswer->pValue)->getValue();
...@@ -205,9 +212,17 @@ void ObservationControl::handlePropertySetAnswer(GCFEvent& answer) ...@@ -205,9 +212,17 @@ void ObservationControl::handlePropertySetAnswer(GCFEvent& answer)
itsPreparePeriod = newVal; itsPreparePeriod = newVal;
} }
} }
// times are of type string
else if (pPropAnswer->pValue->getType() == LPT_STRING) { else if (pPropAnswer->pValue->getType() == LPT_STRING) {
string newVal = (string) ((GCFPVString*)pPropAnswer->pValue)->getValue(); string newVal = (string) ((GCFPVString*)pPropAnswer->pValue)->getValue();
ptime newTime = time_from_string(newVal); ptime newTime;
try {
newTime = time_from_string(newVal);
}
catch (exception& e) {
LOG_DEBUG_STR(newVal << " is not a legal time!!!");
return;
}
if (strstr(pPropAnswer->pPropName, PN_OC_START_TIME) != 0) { if (strstr(pPropAnswer->pPropName, PN_OC_START_TIME) != 0) {
LOG_INFO_STR ("Changing startTime from " << to_simple_string(itsStartTime) LOG_INFO_STR ("Changing startTime from " << to_simple_string(itsStartTime)
<< " to " << newVal); << " to " << newVal);
...@@ -223,16 +238,17 @@ void ObservationControl::handlePropertySetAnswer(GCFEvent& answer) ...@@ -223,16 +238,17 @@ void ObservationControl::handlePropertySetAnswer(GCFEvent& answer)
break; break;
} }
// case F_SUBSCRIBED: // case F_SUBSCRIBED: GCFPropAnswerEvent pPropName
// case F_UNSUBSCRIBED: // case F_UNSUBSCRIBED: GCFPropAnswerEvent pPropName
// case F_PS_CONFIGURED: // case F_PS_CONFIGURED: GCFConfAnswerEvent pApcName
// case F_EXTPS_LOADED: // case F_EXTPS_LOADED: GCFPropSetAnswerEvent pScope, result
// case F_EXTPS_UNLOADED: // case F_EXTPS_UNLOADED: GCFPropSetAnswerEvent pScope, result
// case F_MYPS_ENABLED: // case F_MYPS_ENABLED: GCFPropSetAnswerEvent pScope, result
// case F_MYPS_DISABLED: // case F_MYPS_DISABLED: GCFPropSetAnswerEvent pScope, result
// case F_VGETRESP: // case F_VGETRESP: GCFPropValueEvent pValue, pPropName
// case F_VCHANGEMSG: // case F_VSETRESP: GCFPropAnswerEvent pPropName
// case F_SERVER_GONE: // case F_VCHANGEMSG: GCFPropValueEvent pValue, pPropName
// case F_SERVER_GONE: GCFPropSetAnswerEvent pScope, result
default: default:
break; break;
...@@ -243,7 +259,7 @@ void ObservationControl::handlePropertySetAnswer(GCFEvent& answer) ...@@ -243,7 +259,7 @@ void ObservationControl::handlePropertySetAnswer(GCFEvent& answer)
// //
// initial_state(event, port) // initial_state(event, port)
// //
// Setup all connections. // Create top datapoint of this observation in PVSS.
// //
GCFEvent::TResult ObservationControl::initial_state(GCFEvent& event, GCFEvent::TResult ObservationControl::initial_state(GCFEvent& event,
GCFPortInterface& port) GCFPortInterface& port)
...@@ -252,6 +268,57 @@ GCFEvent::TResult ObservationControl::initial_state(GCFEvent& event, ...@@ -252,6 +268,57 @@ GCFEvent::TResult ObservationControl::initial_state(GCFEvent& event,
GCFEvent::TResult status = GCFEvent::HANDLED; GCFEvent::TResult status = GCFEvent::HANDLED;
switch (event.signal) {
case F_INIT:
break;
case F_ENTRY: {
// Get access to my own propertyset.
string propSetName(createPropertySetName(PSN_OBSERVATION, getName()));
LOG_DEBUG_STR ("Activating PropertySet: " << propSetName);
itsBootPS = GCFMyPropertySetPtr(new GCFMyPropertySet(propSetName.c_str(),
PST_OBSERVATION,
PS_CAT_TEMP_AUTOLOAD,
&itsPropertySetAnswer));
itsBootPS->enable();
// Wait for timer that is set in PropertySetAnswer on ENABLED event
}
break;
case F_TIMER: { // must be timer that PropSet has set.
// update PVSS.
LOG_TRACE_FLOW ("top DP of observation created, going to starting state");
TRAN(ObservationControl::starting_state); // go to next state.
}
break;
case F_CONNECTED:
break;
case F_DISCONNECTED:
break;
default:
LOG_DEBUG_STR ("initial, default");
status = GCFEvent::NOT_HANDLED;
break;
}
return (status);
}
//
// starting_state(event, port)
//
// Setup all connections.
//
GCFEvent::TResult ObservationControl::starting_state(GCFEvent& event,
GCFPortInterface& port)
{
LOG_DEBUG_STR ("starting:" << evtstr(event) << "@" << port.getName());
GCFEvent::TResult status = GCFEvent::HANDLED;
switch (event.signal) { switch (event.signal) {
case F_INIT: case F_INIT:
break; break;
...@@ -262,7 +329,7 @@ GCFEvent::TResult ObservationControl::initial_state(GCFEvent& event, ...@@ -262,7 +329,7 @@ GCFEvent::TResult ObservationControl::initial_state(GCFEvent& event,
LOG_DEBUG_STR ("Activating PropertySet: " << propSetName); LOG_DEBUG_STR ("Activating PropertySet: " << propSetName);
itsPropertySet = GCFMyPropertySetPtr(new GCFMyPropertySet(propSetName.c_str(), itsPropertySet = GCFMyPropertySetPtr(new GCFMyPropertySet(propSetName.c_str(),
PST_OBS_CTRL, PST_OBS_CTRL,
PS_CAT_TEMPORARY, PS_CAT_TEMP_AUTOLOAD,
&itsPropertySetAnswer)); &itsPropertySetAnswer));
itsPropertySet->enable(); itsPropertySet->enable();
// Wait for timer that is set in PropertySetAnswer on ENABLED event // Wait for timer that is set in PropertySetAnswer on ENABLED event
...@@ -295,7 +362,7 @@ GCFEvent::TResult ObservationControl::initial_state(GCFEvent& event, ...@@ -295,7 +362,7 @@ GCFEvent::TResult ObservationControl::initial_state(GCFEvent& event,
break; break;
default: default:
LOG_DEBUG_STR ("initial, default"); LOG_DEBUG_STR ("starting, default");
status = GCFEvent::NOT_HANDLED; status = GCFEvent::NOT_HANDLED;
break; break;
} }
......
...@@ -78,10 +78,14 @@ public: ...@@ -78,10 +78,14 @@ public:
// PropertySetAnswerHandlerInterface method // PropertySetAnswerHandlerInterface method
virtual void handlePropertySetAnswer(GCFEvent& answer); virtual void handlePropertySetAnswer(GCFEvent& answer);
// During the initial state all connections with the other programs are made. // During this state the top DP LOFAR_ObsSW_<observation> is created
GCFEvent::TResult initial_state (GCFEvent& e, GCFEvent::TResult initial_state (GCFEvent& e,
GCFPortInterface& p); GCFPortInterface& p);
// During this state all connections with the other programs are made.
GCFEvent::TResult starting_state (GCFEvent& e,
GCFPortInterface& p);
// Normal control mode. // Normal control mode.
GCFEvent::TResult active_state (GCFEvent& e, GCFEvent::TResult active_state (GCFEvent& e,
GCFPortInterface& p); GCFPortInterface& p);
...@@ -104,8 +108,9 @@ private: ...@@ -104,8 +108,9 @@ private:
typedef boost::shared_ptr<GCF::PAL::GCFMyPropertySet> GCFMyPropertySetPtr; typedef boost::shared_ptr<GCF::PAL::GCFMyPropertySet> GCFMyPropertySetPtr;
APLCommon::PropertySetAnswer itsPropertySetAnswer; APLCommon::PropertySetAnswer itsPropertySetAnswer;
GCFMyPropertySetPtr itsPropertySet; GCFMyPropertySetPtr itsPropertySet;
GCFMyPropertySetPtr itsBootPS;
#if 0 #if 0
// Administration of the ObservationControllers // Administration of the ObservationControllers
......
...@@ -42,6 +42,9 @@ namespace LOFAR { ...@@ -42,6 +42,9 @@ namespace LOFAR {
#define PVSSNAME_FSM_STATE "state" #define PVSSNAME_FSM_STATE "state"
#define PVSSNAME_FSM_ERROR "error" #define PVSSNAME_FSM_ERROR "error"
// Observation
#define PSN_OBSERVATION "LOFAR_ObsSW_@observation@"
#define PST_OBSERVATION "Observation"
}; // MCU }; // MCU
}; // LOFAR }; // LOFAR
......
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