Newer
Older
// }
// }

Jorrit Schaap
committed
}
Ruud Overeem
committed
// Finally we can pass the list with planned observations to PVSS.

Jorrit Schaap
committed
#ifndef DONT_COMPILE_OTDB_AND_PVSS_CODE
Ruud Overeem
committed
itsPropertySet->setValue(PN_MS_PLANNED_OBSERVATIONS, GCFPVDynArr(LPT_DYNSTRING, plannedArr));

Jorrit Schaap
committed
#endif
itsNrPlanned = plannedArr.size();
Arno Schoenmakers
committed
// free used memory
for (int i = plannedArr.size()-1; i>=0; --i) {
delete plannedArr[i];
}
Arno Schoenmakers
committed
// the backupObsList now contains the observations that were are in the preparedObs list but are not in
// the SAS list anymore. Remove them here from the preparedObs list.
OLiter oldObsIter = backupObsList.begin();
OLiter prepIter;
while (oldObsIter != backupObsList.end()) {
prepIter = itsPreparedObs.find(oldObsIter->first);
if (prepIter != itsPreparedObs.end()) {
Arno Schoenmakers
committed
LOG_INFO_STR("Removing " << oldObsIter->first << " from the 'preparing' list.");
Arno Schoenmakers
committed
itsPreparedObs.erase(prepIter);
}
oldObsIter++;
}
Ruud Overeem
committed
// _updateActiveList()
Ruud Overeem
committed
void MACScheduler::_updateActiveList()
Ruud Overeem
committed
LOG_DEBUG("_updateActiveList()");

Jorrit Schaap
committed
#ifndef DONT_COMPILE_OTDB_AND_PVSS_CODE
Ruud Overeem
committed
// get new list (list is ordered on starttime)
Ruud Overeem
committed
vector<OTDBtree> activeDBlist = itsOTDBconnection->getTreeGroup(2, 0, itsExclPLcluster);
Ruud Overeem
committed
if (activeDBlist.empty()) {
LOG_DEBUG ("No active Observations");
// NOTE: do not exit routine on emptylist: we need to write an empty list to clear the DB

Jorrit Schaap
committed
#endif
Ruud Overeem
committed
// walk through the list, prepare PVSS for the new obs, update own admin lists.
GCFPValueArray activeArr;

Jorrit Schaap
committed

Jorrit Schaap
committed
#ifndef DONT_COMPILE_OTDB_AND_PVSS_CODE
Arno Schoenmakers
committed
int32 idx = activeDBlist.size() - 1;
Ruud Overeem
committed
for ( ; idx >= 0; idx--) {
if (activeDBlist[idx].processType=="RESERVATION" || activeDBlist[idx].processType=="MAINTENANCE") {
continue;
}
Ruud Overeem
committed
// construct name and timings info for observation
string obsName(observationName(activeDBlist[idx].treeID()));
Ruud Overeem
committed
activeArr.push_back(new GCFPVString(obsName));
// remove obs from planned-list if its still their.
OLiter prepIter = itsPreparedObs.find(activeDBlist[idx].treeID());
if (prepIter != itsPreparedObs.end()) {
itsPreparedObs.erase(prepIter);
}
Ruud Overeem
committed
} // for

Jorrit Schaap
committed
#endif
// Finally we can pass the list with active observations to PVSS.

Jorrit Schaap
committed
#ifndef DONT_COMPILE_OTDB_AND_PVSS_CODE
Ruud Overeem
committed
itsPropertySet->setValue(PN_MS_ACTIVE_OBSERVATIONS, GCFPVDynArr(LPT_DYNSTRING, activeArr));

Jorrit Schaap
committed
#endif
itsNrActive = activeArr.size();
Arno Schoenmakers
committed
// free used memory
for (int i = activeArr.size()-1; i>=0; --i) {
delete activeArr[i];
}
Ruud Overeem
committed
// _updateFinishedList()
Ruud Overeem
committed
void MACScheduler::_updateFinishedList()
Ruud Overeem
committed
LOG_DEBUG("_updateFinishedList()");

Jorrit Schaap
committed
#ifndef DONT_COMPILE_OTDB_AND_PVSS_CODE
Ruud Overeem
committed
// get new list (list is ordered on starttime)
Ruud Overeem
committed
vector<OTDBtree> finishedDBlist = itsOTDBconnection->getTreeGroup(3, itsFinishedPeriod, itsExclPLcluster);
Ruud Overeem
committed
if (finishedDBlist.empty()) {
LOG_DEBUG ("No finished Observations");
// NOTE: do not exit routine on emptylist: we need to write an empty list to clear the DB

Jorrit Schaap
committed
#endif
Ruud Overeem
committed
// walk through the list, prepare PVSS for the new obs, update own admin lists.
// We must show the last part of the (optional) limited list.
Ruud Overeem
committed
GCFPValueArray finishedArr;
int32 freeSpace = MAX_CONCURRENT_OBSERVATIONS - itsNrPlanned - itsNrActive;

Jorrit Schaap
committed

Jorrit Schaap
committed
#ifndef DONT_COMPILE_OTDB_AND_PVSS_CODE
int32 idx = finishedDBlist.size() - 1;
int32 limit = idx - (MIN2(MIN2(finishedDBlist.size(), itsMaxFinished), (uint32)freeSpace) - 1);
Ruud Overeem
committed
for ( ; idx >= limit ; idx--) {
if (finishedDBlist[idx].processType=="RESERVATION" || finishedDBlist[idx].processType=="MAINTENANCE") {
continue;
}
Ruud Overeem
committed
// construct name and timings info for observation
string obsName(observationName(finishedDBlist[idx].treeID()));
Ruud Overeem
committed
finishedArr.push_back(new GCFPVString(obsName));
Ruud Overeem
committed
} // for

Jorrit Schaap
committed
#endif
Ruud Overeem
committed
// Finally we can pass the list with finished observations to PVSS.

Jorrit Schaap
committed
#ifndef DONT_COMPILE_OTDB_AND_PVSS_CODE
Arno Schoenmakers
committed
itsPropertySet->setValue(PN_MS_FINISHED_OBSERVATIONS, GCFPVDynArr(LPT_DYNSTRING, finishedArr));

Jorrit Schaap
committed
#endif
Arno Schoenmakers
committed
// free used memory
for (int i = finishedArr.size()-1; i>=0; --i) {
delete finishedArr[i];
}
//
// _setParsetOnMsgBus(parsetFile)
//
void MACScheduler::_setParsetOnMsgBus(const string& filename) const
{
// open file
ParameterSet obsSpecs(filename);
string obsPrefix = obsSpecs.fullModuleName("Observation");
string momID = obsSpecs.getString(obsPrefix + ".momID");
string sasID = obsSpecs.getString(obsPrefix + ".otdbID");
// from, forUser, summary, protocol, protocolVersion, momID, sasID
TaskSpecificationSystem outMsg("LOFAR.MACScheduler", "", "", momID, sasID, obsSpecs);

Jorrit Schaap
committed
#ifndef DONT_COMPILE_OTDB_AND_PVSS_CODE
itsMsgQueue->send(outMsg);

Jorrit Schaap
committed
#endif
}
void MACScheduler::_connectedHandler(GCFPortInterface& /*port*/)