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
GCFPValueArray activeArr;

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()) {

Jorrit Schaap
committed
LOG_DEBUG ("No active OTDB Observations");
// NOTE: do not exit routine on emptylist: we need to write an empty list to clear the DB
Ruud Overeem
committed
// walk through the list, prepare PVSS for the new obs, update own admin lists.
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

Jorrit Schaap
committed
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
// get new list (list is/should_be ordered on starttime)
Json::Value activeSubTasks = itsTMSSconnection->getActiveSubTasks();
if (activeSubTasks.empty()) {
LOG_DEBUG ("No active TMSS Observations");
// NOTE: do not exit routine on emptylist: we need to write an empty list to clear the DB
}
// walk through the list, prepare PVSS for the new obs, update own admin lists.
int32 idx = activeSubTasks.size() - 1;
for ( ; idx >= 0; idx--) {
Json::Value subtask = activeSubTasks[idx];
// if (subtask.processType=="RESERVATION" || subtask.processType=="MAINTENANCE") {
// continue;
// }
// get subtask_id from url. I know, ugly, needs to be in json itself.
vector<string> tmp;
string url(subtask["url"].asString());
boost::split(tmp, url, [](char c){return c == '/';});
int subtask_id = stoi(tmp[tmp.size()-2]);
// construct name and timings info for observation
string obsName(observationName(subtask_id));
ptime start_time = time_from_string(subtask["start_time"].asString().replace(10, 1, " "));
ptime modTime = time_from_string(subtask["updated_at"].asString().replace(10, 1, " "));
activeArr.push_back(new GCFPVString(obsName));
// remove obs from planned-list if its still in there.
OLiter prepIter = itsPreparedObs.find(subtask_id);
if (prepIter != itsPreparedObs.end()) {
itsPreparedObs.erase(prepIter);
}
} // for

Jorrit Schaap
committed
#ifndef DONT_COMPILE_OTDB_AND_PVSS_CODE

Jorrit Schaap
committed
// Finally we can pass the list with active observations to PVSS.
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
GCFPValueArray finishedArr;
int32 freeSpace = MAX_CONCURRENT_OBSERVATIONS - itsNrPlanned - itsNrActive;

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()) {

Jorrit Schaap
committed
LOG_DEBUG ("No finishing OTDB Observations");
// NOTE: do not exit routine on emptylist: we need to write an empty list to clear the DB
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 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
// 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];
}

Jorrit Schaap
committed
#endif
Ruud Overeem
committed

Jorrit Schaap
committed
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
//reset for TMSS
finishedArr = GCFPValueArray();
freeSpace = MAX_CONCURRENT_OBSERVATIONS - itsNrPlanned - itsNrActive;
// get new list (list is/should_be ordered on starttime)
Json::Value finishingSubTasks = itsTMSSconnection->getFinishingSubTasks();
if (finishingSubTasks.empty()) {
LOG_DEBUG ("No finishing TMSS Observations");
// NOTE: do not exit routine on emptylist: we need to write an empty list to clear the DB
}
// 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 idx = finishingSubTasks.size() - 1;
int32 limit = idx - (MIN2(MIN2(finishingSubTasks.size(), itsMaxFinished), (uint32)freeSpace) - 1);
for ( ; idx >= limit ; idx--) {
Json::Value subtask = finishingSubTasks[idx];
// if (subtask.processType=="RESERVATION" || subtask.processType=="MAINTENANCE") {
// continue;
// }
// get subtask_id from url. I know, ugly, needs to be in json itself.
vector<string> tmp;
string url(subtask["url"].asString());
boost::split(tmp, url, [](char c){return c == '/';});
int subtask_id = stoi(tmp[tmp.size()-2]);
// construct name info for observation
string obsName(observationName(subtask_id));
finishedArr.push_back(new GCFPVString(obsName));
} // for
// 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*/)