diff --git a/MAC/APL/MainCU/src/MACScheduler/MACScheduler.cc b/MAC/APL/MainCU/src/MACScheduler/MACScheduler.cc index b458447aab3690e16c1c0f5adf2bb7816bcb05a4..89df99adfad3cc2f3f22336d8ccb241b66be65c5 100644 --- a/MAC/APL/MainCU/src/MACScheduler/MACScheduler.cc +++ b/MAC/APL/MainCU/src/MACScheduler/MACScheduler.cc @@ -634,12 +634,17 @@ void MACScheduler::_updatePlannedList() // this will result in CONTROL_STARTED event in our main task // Note: as soon as the ObservationController has reported itself to the MACScheduler // the observation will not be returned in the 'plannedDBlist' anymore. - LOG_DEBUG_STR("Requesting start of " << obsName); + string cntlrName(controllerName(CNTLRTYPE_OBSERVATIONCTRL, 0, obsID)); + LOG_DEBUG_STR("Requesting start of " << cntlrName); itsChildControl->startChild(CNTLRTYPE_OBSERVATIONCTRL, - plannedDBlist[idx].treeID(), + obsID, 0, // instanceNr myHostname(true)); // Note: controller is now in state NO_STATE/CONNECTED (C/R) + + // add controller to our 'monitor' administration + itsControllerMap[cntlrName] = obsID; + LOG_DEBUG_STR("itsControllerMap[" << cntlrName << "]=" << obsID); } } idx++; diff --git a/MAC/APL/MainCU/src/MACScheduler/ObsClaimer.cc b/MAC/APL/MainCU/src/MACScheduler/ObsClaimer.cc index cab0f46cac9b68b1c59e5c085da3c4c9ce51b5de..63b1a02ec45884026ab37a40ff98d4cee0db31e1 100644 --- a/MAC/APL/MainCU/src/MACScheduler/ObsClaimer.cc +++ b/MAC/APL/MainCU/src/MACScheduler/ObsClaimer.cc @@ -161,10 +161,17 @@ GCFEvent::TResult ObsClaimer::idle_state (GCFEvent& event, GCFPortInterface& por CMClaimResultEvent cmEvent(event); LOG_INFO_STR(cmEvent.nameInAppl << " is mapped to " << cmEvent.DPname); OMiter iter = itsObsMap.find(cmEvent.nameInAppl); - ASSERTSTR(iter != itsObsMap.end(), "Cannot find " << cmEvent.nameInAppl << " in admin"); - iter->second->DPname = cmEvent.DPname; - itsCurrentObs = iter; - TRAN(ObsClaimer::preparePVSS_state); +// ASSERTSTR(iter != itsObsMap.end(), "Cannot find " << cmEvent.nameInAppl << " in admin"); +// sometimes we receive a ghost message so we can't assert on it. Using an IF for the time being. + if (iter == itsObsMap.end()) { + LOG_ERROR_STR("Cannot find " << cmEvent.nameInAppl << " in admin"); + TRAN(ObsClaimer::idle_state); + } + else { + iter->second->DPname = cmEvent.DPname; + itsCurrentObs = iter; + TRAN(ObsClaimer::preparePVSS_state); + } } break; @@ -213,8 +220,10 @@ GCFEvent::TResult ObsClaimer::preparePVSS_state (GCFEvent& event, GCFPortInterfa case F_TIMER: { // must be timer that PropSet is enabled. // update PVSS. LOG_TRACE_FLOW ("Updateing observation-fields in PVSS"); - ParameterSet obsPS(formatString("%s/%s", LOFAR_SHARE_LOCATION, itsCurrentObs->second->obsName.c_str())); - Observation theObs(&obsPS); + string obsPSFilename(formatString("%s/%s", LOFAR_SHARE_LOCATION, + itsCurrentObs->second->obsName.c_str())); + ParameterSet obsPS(obsPSFilename); + Observation theObs(&obsPS); RTDBPropertySet* theObsPS = itsCurrentObs->second->propSet; // theObsPS->setValue(PN_OBS_CLAIM_PERIOD, GCFPVInteger(itsClaimPeriod), 0.0, false); // theObsPS->setValue(PN_OBS_PREPARE_PERIOD, GCFPVInteger(itsPreparePeriod), 0.0, false); @@ -256,6 +265,10 @@ GCFEvent::TResult ObsClaimer::preparePVSS_state (GCFEvent& event, GCFPortInterfa theObsPS->setValue(PN_OBS_BEAMS_DIRECTION_TYPE, GCFPVDynArr(LPT_DYNSTRING, dirTypesArr), 0.0, false); theObsPS->flush(); + // append DPname to the ParameterFile + obsPS.add("_DPname", itsCurrentObs->second->DPname); + obsPS.writeFile(obsPSFilename); + // send Maintask a signal we are ready. LOG_DEBUG_STR("Sending Maintask ready signal for " << itsCurrentObs->second->obsName); CMClaimResultEvent cmEvent; diff --git a/MAC/APL/MainCU/src/ObservationControl/ObservationControl.cc b/MAC/APL/MainCU/src/ObservationControl/ObservationControl.cc index 544d3b2a03872934d6b4ca458918971ba9205b28..933b92cf9bd4248227282d5507c3af40830fde32 100644 --- a/MAC/APL/MainCU/src/ObservationControl/ObservationControl.cc +++ b/MAC/APL/MainCU/src/ObservationControl/ObservationControl.cc @@ -59,9 +59,10 @@ static ObservationControl* thisObservationControl = 0; // ObservationControl() // ObservationControl::ObservationControl(const string& cntlrName) : - GCFTask ((State)&ObservationControl::initial_state,cntlrName), + GCFTask ((State)&ObservationControl::starting_state,cntlrName), itsPropertySet (0), itsClaimMgrTask (0), + itsClaimMgrPort (0), itsChildControl (0), itsChildPort (0), itsParentControl (0), @@ -99,6 +100,7 @@ ObservationControl::ObservationControl(const string& cntlrName) : itsTreePrefix = globalParameterSet()->getString("prefix"); itsTreeID = globalParameterSet()->getUint32("_treeID"); // !!! itsHeartBeatItv = globalParameterSet()->getUint32("heartbeatInterval"); + itsObsDPname = globalParameterSet()->getString("_DPname"); // The time I have to wait for the forced quit depends on the integration time of OLAP string OLAPpos = globalParameterSet()->locateModule("OLAP"); @@ -107,9 +109,9 @@ ObservationControl::ObservationControl(const string& cntlrName) : LOG_DEBUG_STR ("Timer for forcing quit is set to " << itsForcedQuitDelay); // Inform Logging manager who we are - // TODO read this from the PARSET file! - uint32 treeID(globalParameterSet()->getUint32("_treeID")); - LOG_INFO(formatString("MACProcessScope: LOFAR.ObsSW.Observation%d.ObsCtrl", treeID)); +// LOG_INFO(formatString("MACProcessScope: LOFAR.ObsSW.Observation%d.ObsCtrl", itsTreeID)); + LOG_INFO_STR("MACProcessScope: " << createPropertySetName(PSN_OBS_CTRL, getName(), itsObsDPname)); + // NOTE: SAS gateway is not yet aware of claimMgr so the data will not be transferred to SAS. // attach to child control task itsChildControl = ChildControl::instance(); @@ -129,11 +131,14 @@ ObservationControl::ObservationControl(const string& cntlrName) : itsTimerPort = new GCFTimerPort(*this, "TimerPort"); // startup claimManager task - itsClaimMgrTask = ClaimMgrTask::instance(); - ASSERTSTR(itsClaimMgrTask, "Can't construct a claimMgrTask"); +// itsClaimMgrTask = ClaimMgrTask::instance(); +// ASSERTSTR(itsClaimMgrTask, "Can't construct a claimMgrTask"); +// itsClaimMgrPort = new GCFITCPort (*this, *this, "ClaimMgrPort", +// GCFPortInterface::SAP, CM_PROTOCOL); registerProtocol (CONTROLLER_PROTOCOL, CONTROLLER_PROTOCOL_STRINGS); - registerProtocol (DP_PROTOCOL, DP_PROTOCOL_STRINGS); + registerProtocol (DP_PROTOCOL, DP_PROTOCOL_STRINGS); + registerProtocol (CM_PROTOCOL, CM_PROTOCOL_STRINGS); // we cannot use setState right now, wait for propertysets to come online // setState(CTState::CREATED); @@ -203,6 +208,9 @@ GCFEvent::TResult ObservationControl::initial_state(GCFEvent& event, GCFEvent::TResult status = GCFEvent::HANDLED; switch (event.signal) { + case F_INIT: // must exist in initializing FSM + break; + case F_ENTRY: { itsTimerPort->cancelAllTimers(); itsTimerPort->setTimer(0.0); @@ -217,7 +225,7 @@ GCFEvent::TResult ObservationControl::initial_state(GCFEvent& event, // Ask claimMgrTask to get the DPname of this observation itsClaimMgrTask->claimObject("Observation", - "LOFAR_ObsSW_"+observationName(itsTreeID), port); + "LOFAR_ObsSW_"+observationName(itsTreeID), *itsClaimMgrPort); // will result in CM_CLAIM_RESULT event itsTimerPort->setTimer(10.0); // set emergency timer. @@ -355,7 +363,7 @@ GCFEvent::TResult ObservationControl::starting_state(GCFEvent& event, case F_ENTRY: { // Get access to my own propertyset. - string propSetName(createPropertySetName(PSN_OBS_CTRL, getName())); + string propSetName(createPropertySetName(PSN_OBS_CTRL, getName(), itsObsDPname)); LOG_DEBUG_STR ("Activating PropertySet: " << propSetName); itsPropertySet = new RTDBPropertySet(propSetName.c_str(), PST_OBS_CTRL, diff --git a/MAC/APL/MainCU/src/ObservationControl/ObservationControl.h b/MAC/APL/MainCU/src/ObservationControl/ObservationControl.h index ddc2b94df32c56293c4851bfa7f5c43f9032fef4..b45bdf5e1741e917ed2514dc69f6e013c4dc4bd7 100644 --- a/MAC/APL/MainCU/src/ObservationControl/ObservationControl.h +++ b/MAC/APL/MainCU/src/ObservationControl/ObservationControl.h @@ -104,6 +104,7 @@ private: string itsObsDPname; // DPname of ObservationDP RTDBPropertySet* itsPropertySet; // my own propset. ClaimMgrTask* itsClaimMgrTask; // for resolving the DPnames + GCFITCPort* itsClaimMgrPort; // RTDBPropertySet* itsBootPS; // map <string, RTDBPropertySet*> itsStationDPs;