Skip to content
Snippets Groups Projects
MACScheduler.cc 40 KiB
Newer Older
Ruud Overeem's avatar
Ruud Overeem committed

	// Finally we can pass the list with planned observations to PVSS.
	itsPropertySet->setValue(PN_MS_PLANNED_OBSERVATIONS, GCFPVDynArr(LPT_DYNSTRING, plannedArr));
	itsNrPlanned = plannedArr.size();

	// free used memory
	for (int i = plannedArr.size()-1; i>=0; --i) {
		delete plannedArr[i];
	}
Ruud Overeem's avatar
Ruud Overeem 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()) {
			LOG_INFO_STR("Removing " << oldObsIter->first << " from the 'preparing' list.");
Ruud Overeem's avatar
Ruud Overeem committed
}

Ruud Overeem's avatar
Ruud Overeem committed
//
Ruud Overeem's avatar
Ruud Overeem committed
//
Ruud Overeem's avatar
Ruud Overeem committed
{
Ruud Overeem's avatar
Ruud Overeem committed

	// get new list (list is ordered on starttime)
	vector<OTDBtree> activeDBlist = itsOTDBconnection->getTreeGroup(2, 0, itsExclPLcluster);
	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
Ruud Overeem's avatar
Ruud Overeem committed
	}
Ruud Overeem's avatar
Ruud Overeem committed

	// walk through the list, prepare PVSS for the new obs, update own admin lists.
	GCFPValueArray	activeArr;
	for ( ; idx >= 0; idx--)  {
		if (activeDBlist[idx].processType=="RESERVATION" || activeDBlist[idx].processType=="MAINTENANCE") {
			continue;
		}

		// construct name and timings info for observation
		string		obsName(observationName(activeDBlist[idx].treeID()));
		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's avatar
Ruud Overeem committed

	// Finally we can pass the list with active observations to PVSS.
	itsPropertySet->setValue(PN_MS_ACTIVE_OBSERVATIONS,	GCFPVDynArr(LPT_DYNSTRING, activeArr));
	itsNrActive = activeArr.size();

	// free used memory
	for (int i = activeArr.size()-1; i>=0; --i) {
		delete activeArr[i];
	}
Ruud Overeem's avatar
Ruud Overeem committed
}

//
Ruud Overeem's avatar
Ruud Overeem committed
//
Ruud Overeem's avatar
Ruud Overeem committed
{
Ruud Overeem's avatar
Ruud Overeem committed

	// get new list (list is ordered on starttime)
	vector<OTDBtree> finishedDBlist = itsOTDBconnection->getTreeGroup(3, itsFinishedPeriod, itsExclPLcluster);
	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
Ruud Overeem's avatar
Ruud Overeem committed
	}
Ruud Overeem's avatar
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.
	int32	freeSpace = MAX_CONCURRENT_OBSERVATIONS - itsNrPlanned - itsNrActive;
	int32	idx       = finishedDBlist.size() - 1;
	int32	limit     = idx - (MIN2(MIN2(finishedDBlist.size(), itsMaxFinished), (uint32)freeSpace) - 1);
	for ( ; idx >= limit ; idx--)  {
		if (finishedDBlist[idx].processType=="RESERVATION" || finishedDBlist[idx].processType=="MAINTENANCE") {
			continue;
		}

		// construct name and timings info for observation
		string		obsName(observationName(finishedDBlist[idx].treeID()));
		finishedArr.push_back(new GCFPVString(obsName));
	// Finally we can pass the list with finished observations to PVSS.
	itsPropertySet->setValue(PN_MS_FINISHED_OBSERVATIONS, GCFPVDynArr(LPT_DYNSTRING, finishedArr));

	// free used memory
	for (int i = finishedArr.size()-1; i>=0; --i) {
		delete finishedArr[i];
	}
Ruud Overeem's avatar
Ruud Overeem committed
}

//
// _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);
Ruud Overeem's avatar
Ruud Overeem committed

//
// _connectedHandler(port)
//
blaakmeer's avatar
blaakmeer committed
void MACScheduler::_connectedHandler(GCFPortInterface& /*port*/)
Ruud Overeem's avatar
Ruud Overeem committed
{
}

//
// _disconnectedHandler(port)
//
void MACScheduler::_disconnectedHandler(GCFPortInterface& port)
{
	port.close();
}


};
};