diff --git a/MAC/APL/MainCU/src/ObservationControl/ObservationControl.cc b/MAC/APL/MainCU/src/ObservationControl/ObservationControl.cc index c0abce12dce2684e8c44b50ab459547cd20a38f7..eb09e968ad799db8fdafa35b4f62d7b6d65fea77 100644 --- a/MAC/APL/MainCU/src/ObservationControl/ObservationControl.cc +++ b/MAC/APL/MainCU/src/ObservationControl/ObservationControl.cc @@ -183,14 +183,21 @@ void ObservationControl::handlePropertySetAnswer(GCFEvent& answer) case F_VGETRESP: case F_VCHANGEMSG: { - // check which property changed + // check which propertySet(!) changed GCFPropValueEvent* pPropAnswer=static_cast<GCFPropValueEvent*>(&answer); string PropSetName = createPropertySetName(PSN_OBS_CTRL, getName()); 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) { uint32 newVal = (uint32) ((GCFPVInteger*)pPropAnswer->pValue)->getValue(); @@ -205,9 +212,17 @@ void ObservationControl::handlePropertySetAnswer(GCFEvent& answer) itsPreparePeriod = newVal; } } + // times are of type string else if (pPropAnswer->pValue->getType() == LPT_STRING) { 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) { LOG_INFO_STR ("Changing startTime from " << to_simple_string(itsStartTime) << " to " << newVal); @@ -223,16 +238,17 @@ void ObservationControl::handlePropertySetAnswer(GCFEvent& answer) break; } -// case F_SUBSCRIBED: -// case F_UNSUBSCRIBED: -// case F_PS_CONFIGURED: -// case F_EXTPS_LOADED: -// case F_EXTPS_UNLOADED: -// case F_MYPS_ENABLED: -// case F_MYPS_DISABLED: -// case F_VGETRESP: -// case F_VCHANGEMSG: -// case F_SERVER_GONE: +// case F_SUBSCRIBED: GCFPropAnswerEvent pPropName +// case F_UNSUBSCRIBED: GCFPropAnswerEvent pPropName +// case F_PS_CONFIGURED: GCFConfAnswerEvent pApcName +// case F_EXTPS_LOADED: GCFPropSetAnswerEvent pScope, result +// case F_EXTPS_UNLOADED: GCFPropSetAnswerEvent pScope, result +// case F_MYPS_ENABLED: GCFPropSetAnswerEvent pScope, result +// case F_MYPS_DISABLED: GCFPropSetAnswerEvent pScope, result +// case F_VGETRESP: GCFPropValueEvent pValue, pPropName +// case F_VSETRESP: GCFPropAnswerEvent pPropName +// case F_VCHANGEMSG: GCFPropValueEvent pValue, pPropName +// case F_SERVER_GONE: GCFPropSetAnswerEvent pScope, result default: break; @@ -243,7 +259,7 @@ void ObservationControl::handlePropertySetAnswer(GCFEvent& answer) // // initial_state(event, port) // -// Setup all connections. +// Create top datapoint of this observation in PVSS. // GCFEvent::TResult ObservationControl::initial_state(GCFEvent& event, GCFPortInterface& port) @@ -252,6 +268,57 @@ GCFEvent::TResult ObservationControl::initial_state(GCFEvent& event, 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) { case F_INIT: break; @@ -262,7 +329,7 @@ GCFEvent::TResult ObservationControl::initial_state(GCFEvent& event, LOG_DEBUG_STR ("Activating PropertySet: " << propSetName); itsPropertySet = GCFMyPropertySetPtr(new GCFMyPropertySet(propSetName.c_str(), PST_OBS_CTRL, - PS_CAT_TEMPORARY, + PS_CAT_TEMP_AUTOLOAD, &itsPropertySetAnswer)); itsPropertySet->enable(); // Wait for timer that is set in PropertySetAnswer on ENABLED event @@ -295,7 +362,7 @@ GCFEvent::TResult ObservationControl::initial_state(GCFEvent& event, break; default: - LOG_DEBUG_STR ("initial, default"); + LOG_DEBUG_STR ("starting, default"); status = GCFEvent::NOT_HANDLED; break; } diff --git a/MAC/APL/MainCU/src/ObservationControl/ObservationControl.h b/MAC/APL/MainCU/src/ObservationControl/ObservationControl.h index d6ea406b93916470d1d98c15b23ba2f330e1bb75..66dca5204abbed457c162a105bd61e8d462c1bbb 100644 --- a/MAC/APL/MainCU/src/ObservationControl/ObservationControl.h +++ b/MAC/APL/MainCU/src/ObservationControl/ObservationControl.h @@ -78,10 +78,14 @@ public: // PropertySetAnswerHandlerInterface method 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, GCFPortInterface& p); + // During this state all connections with the other programs are made. + GCFEvent::TResult starting_state (GCFEvent& e, + GCFPortInterface& p); + // Normal control mode. GCFEvent::TResult active_state (GCFEvent& e, GCFPortInterface& p); @@ -104,8 +108,9 @@ private: typedef boost::shared_ptr<GCF::PAL::GCFMyPropertySet> GCFMyPropertySetPtr; - APLCommon::PropertySetAnswer itsPropertySetAnswer; - GCFMyPropertySetPtr itsPropertySet; + APLCommon::PropertySetAnswer itsPropertySetAnswer; + GCFMyPropertySetPtr itsPropertySet; + GCFMyPropertySetPtr itsBootPS; #if 0 // Administration of the ObservationControllers diff --git a/MAC/APL/MainCU/src/ObservationControl/ObservationControlDefines.h b/MAC/APL/MainCU/src/ObservationControl/ObservationControlDefines.h index da8fb5bccfb1832910cb50642e883291d2e4cac0..edce39bfc48c61d012829700762412d6ff1597e2 100644 --- a/MAC/APL/MainCU/src/ObservationControl/ObservationControlDefines.h +++ b/MAC/APL/MainCU/src/ObservationControl/ObservationControlDefines.h @@ -42,6 +42,9 @@ namespace LOFAR { #define PVSSNAME_FSM_STATE "state" #define PVSSNAME_FSM_ERROR "error" +// Observation +#define PSN_OBSERVATION "LOFAR_ObsSW_@observation@" +#define PST_OBSERVATION "Observation" }; // MCU }; // LOFAR