Skip to content
Snippets Groups Projects
Commit 25f53137 authored by Ruud Overeem's avatar Ruud Overeem
Browse files

Bug 1189: MacScheduler now uses ClaimManager and produces three observation-lists:

planned-, active- and finished-obervations.
Not fully tested yet.
parent 591a6c90
No related branches found
No related tags found
No related merge requests found
...@@ -62,6 +62,7 @@ lofar_INTERNAL(MAC/MACIO, MACIO, , 1, MACIO/MACServiceInfo.h,,) ...@@ -62,6 +62,7 @@ lofar_INTERNAL(MAC/MACIO, MACIO, , 1, MACIO/MACServiceInfo.h,,)
lofar_INTERNAL(MAC/GCF/TM, GCFTM, , 1, GCF/TM/GCF_Task.h,,) lofar_INTERNAL(MAC/GCF/TM, GCFTM, , 1, GCF/TM/GCF_Task.h,,)
lofar_INTERNAL(MAC/GCF/RTDB, GCFRTDB, , 1, GCF/RTDB/RTDB_PropertySet.h,,) lofar_INTERNAL(MAC/GCF/RTDB, GCFRTDB, , 1, GCF/RTDB/RTDB_PropertySet.h,,)
lofar_INTERNAL(MAC/APL/APLCommon, APLCommon, , 1, APL/APLCommon/APL_Defines.h,,) lofar_INTERNAL(MAC/APL/APLCommon, APLCommon, , 1, APL/APLCommon/APL_Defines.h,,)
lofar_INTERNAL(MAC/APL/RTDBCommon, RTDBCommon, , 1, APL/RTDBCommon/RTDButilities.h,,)
lofar_INTERNAL(Appl/ApplCommon, ApplCommon, , 1, ApplCommon/Observation.h,,) lofar_INTERNAL(Appl/ApplCommon, ApplCommon, , 1, ApplCommon/Observation.h,,)
lofar_EXTERNAL(boost,1,boost/date_time/date.hpp, boost_date_time) lofar_EXTERNAL(boost,1,boost/date_time/date.hpp, boost_date_time)
lofar_EXTERNAL(pqxx,2.5.5,pqxx/pqxx, pqxx) lofar_EXTERNAL(pqxx,2.5.5,pqxx/pqxx, pqxx)
......
This diff is collapsed.
# new setup # Startup parameters for the MACScheduler.
prefix = LOFAR.PermSW.MACScheduler
# OTDB connection info
OTDBdatabasename = overeem OTDBdatabasename = overeem
OTDBhostname = dop50.astron.nl OTDBhostname = dop50.astron.nl
OTDBusername = paulus OTDBusername = paulus
OTDBpassword = boskabouter OTDBpassword = boskabouter
OTDBpollInterval = 5s OTDBpollInterval = 5s
# startup periods of Observations
QueuePeriod = 15m QueuePeriod = 15m
ClaimPeriod = 2m ClaimPeriod = 2m
# manage lists of observations
pollIntervalPlanned = 5s # check if observations must be started
pollIntervalExecute = 1m # check if observations are still active
pollIntervalFinished= 1m # update the list with finished observations
plannedPeriod = 24h # period you will see in the Navigator
finishedPeriod = 24h # period you will see in the Navigator
# next parameters are optional, defaultvalues are shown # next parameters are optional, defaultvalues are shown
#ChildControl.StartupRetryInterval = 10s #ChildControl.StartupRetryInterval = 10s
#ChildControl.MaxStartupRetry = 5 #ChildControl.MaxStartupRetry = 5
......
...@@ -46,6 +46,8 @@ ...@@ -46,6 +46,8 @@
#include <OTDB/OTDBnode.h> #include <OTDB/OTDBnode.h>
#include <APS/ParameterSet.h> #include <APS/ParameterSet.h>
#include "ObsClaimer.h"
// forward declaration // forward declaration
namespace LOFAR { namespace LOFAR {
...@@ -94,38 +96,59 @@ private: ...@@ -94,38 +96,59 @@ private:
MACScheduler(const MACScheduler&); MACScheduler(const MACScheduler&);
MACScheduler& operator=(const MACScheduler&); MACScheduler& operator=(const MACScheduler&);
Observation* _findActiveObservation(const string& name);
void _addActiveObservation(const Observation& newObs);
void _removeActiveObservation(const string& name);
void _connectedHandler(GCFPortInterface& port); void _connectedHandler(GCFPortInterface& port);
void _disconnectedHandler(GCFPortInterface& port); void _disconnectedHandler(GCFPortInterface& port);
void _databaseEventHandler(GCFEvent& event); void _databaseEventHandler(GCFEvent& event);
void _doOTDBcheck(); void _doOTDBcheck();
void _updatePlannedList();
RTDBPropertySet* itsPropertySet; void _updateActiveList();
void _updateFinishedList();
// Information about the Observations. Not used yet.
vector<Observation> itsObservations; // ----- DATA MEMBERS -----
GCF::PVSS::GCFPValueArray itsPVSSObsList; // Our own propertySet in PVSS to inform the operator
RTDBPropertySet* itsPropertySet;
// pointers to other tasks
ChildControl* itsChildControl;
GCFITCPort* itsChildPort;
ObsClaimer* itsClaimerTask;
GCFITCPort* itsClaimerPort;
// <ctlrName, ObsId>
typedef map<string, int> CtlrMap;
typedef map<string, int>::iterator CMiter;
CtlrMap itsControllerMap; // Own admin
// Define a list in which we keep the obsID's of the observations we prepared PVSS for.
// When an obs is in the list we at least have sent a claim request to PVSS. When the
// second value it true we succeeded the claim and we don't have to claim it again.
typedef map<int /*obsID*/, bool /*prepReady*/> ObsList;
typedef map<int ,bool>::iterator OLiter;
ObsList itsPreparedObs; // Observations we already prepared PVSS for.
// Ports for StartDaemon and ObservationControllers. // Ports for StartDaemon and ObservationControllers.
GCFTimerPort* itsTimerPort; // for timers GCFTimerPort* itsTimerPort; // for timers
// pointer to child control task
ChildControl* itsChildControl;
GCFITCPort* itsChildPort;
// Second timer used for internal timing. // Second timer used for internal timing.
uint32 itsSecondTimer; // 1 second hardbeat uint32 itsSecondTimer; // 1 second heartbeat
// Timer admin for the lists
uint32 itsPlannedItv; // interval to update the planned obs list
uint32 itsActiveItv; // interval to update the active obs list
uint32 itsFinishedItv; // interval to update the finished obs list
uint32 itsPlannedPeriod; // period a planned observation is visible
uint32 itsFinishedPeriod; // period a finished observation is visible
int32 itsNextPlannedTime; // time to update the planned obs list again
int32 itsNextActiveTime; // time to update the active obs list again
int32 itsNextFinishedTime; // time to update the finished obs list again
// Scheduling settings // Scheduling settings
uint32 itsQueuePeriod; // period between queueing and start uint32 itsQueuePeriod; // period between queueing and start
uint32 itsClaimPeriod; // period between claiming and start uint32 itsClaimPeriod; // period between claiming and start
// OTDB related variables. // OTDB related variables.
OTDB::OTDBconnection* itsOTDBconnection; // connection to the database OTDB::OTDBconnection* itsOTDBconnection; // connection to the database
uint32 itsOTDBpollInterval; // itv between OTDB polls
int32 itsNextOTDBpolltime; // when next OTDB poll is scheduled
}; };
......
//# MACScheduler_Defines.h: preprocessor definitions of various constants // This file was generated by create_db_files v1.0 on Mon Jun 23 06:58:37 UTC 2008
//#
//# Copyright (C) 2002-2003 #ifndef LOFAR_DEPLOYMENT_PVSSDATAPOINTS_H
//# ASTRON (Netherlands Foundation for Research in Astronomy) #define LOFAR_DEPLOYMENT_PVSSDATAPOINTS_H
//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl // process
//# #define PN_FSM_PROCESSID "process.processID"
//# This program is free software; you can redistribute it and/or modify #define PN_FSM_START_TIME "process.startTime"
//# it under the terms of the GNU General Public License as published by #define PN_FSM_STOP_TIME "process.stopTime"
//# the Free Software Foundation; either version 2 of the License, or #define PN_FSM_LOG_MSG "process.logMsg"
//# (at your option) any later version. #define PN_FSM_ERROR "process.error"
//# #define PN_FSM_CURRENT_ACTION "process.currentAction"
//# This program is distributed in the hope that it will be useful, // object
//# but WITHOUT ANY WARRANTY; without even the implied warranty of #define PN_OBJ_STATE "object.state"
//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #define PN_OBJ_CHILD_STATE "object.childState"
//# GNU General Public License for more details. #define PN_OBJ_MESSAGE "object.message"
//#
//# You should have received a copy of the GNU General Public License // Station
//# along with this program; if not, write to the Free Software #define PSN_STATION "LOFAR_PIC_@ring@_@station@"
//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #define PST_STATION "Station"
//# #define PN_STS__CHILD_DP "__childDp"
//# $Id$
// MACScheduler
#ifndef MACScheduler_DEFINES_H #define PSN_MAC_SCHEDULER "LOFAR_PermSW_MACScheduler"
#define MACScheduler_DEFINES_H #define PST_MAC_SCHEDULER "MACScheduler"
#define PN_MS_PLANNED_OBSERVATIONS "plannedObservations"
namespace LOFAR { #define PN_MS_ACTIVE_OBSERVATIONS "activeObservations"
namespace MCU { #define PN_MS_FINISHED_OBSERVATIONS "finishedObservations"
#define PN_MS_OTDB_CONNECTED "OTDB.connected"
#define MS_TASKNAME "MACScheduler" #define PN_MS_OTDB_LAST_POLL "OTDB.lastPoll"
#define PN_MS_OTDB_POLLINTERVAL "OTDB.pollinterval"
#define PSN_MAC_SCHEDULER "LOFAR_PermSW_MACScheduler"
#define PST_MAC_SCHEDULER "MACScheduler" // Observation
#define PN_MS_ACTIVE_OBSERVATIONS "activeObservations" #define PSN_OBSERVATION "LOFAR_ObsSW_@observation@"
#define PN_MS_OTDB_CONNECTED "OTDB.connected" #define PST_OBSERVATION "Observation"
#define PN_MS_OTDB_LAST_POLL "OTDB.lastPoll" #define PN_OBS_CLAIM_CLAIM_DATE "claim.claimDate"
#define PN_MS_OTDB_POLLINTERVAL "OTDB.pollinterval" #define PN_OBS_RECEIVER_BITMAP "receiverBitmap"
#define PN_OBS_CLAIM_PERIOD "claimPeriod"
#define PVSSNAME_MS_QUEUEPERIOD "QueuePeriod" #define PN_OBS_PREPARE_PERIOD "preparePeriod"
#define PVSSNAME_MS_CLAIMPERIOD "ClaimPeriod" #define PN_OBS_START_TIME "startTime"
#define PN_OBS_STOP_TIME "stopTime"
// next lines should be defined somewhere in Common. #define PN_OBS_BAND_FILTER "bandFilter"
#define PVSSNAME_FSM_CURACT "currentAction" #define PN_OBS_NYQUISTZONE "nyquistzone"
#define PVSSNAME_FSM_ERROR "error" #define PN_OBS_ANTENNA_ARRAY "antennaArray"
#define PVSSNAME_FSM_LOGMSG "logMsg" #define PN_OBS_RECEIVER_LIST "receiverList"
#define PVSSNAME_FSM_STATE "state" #define PN_OBS_SAMPLE_CLOCK "sampleClock"
#define PVSSNAME_FSM_CHILDSTATE "childState" #define PN_OBS_MEASUREMENT_SET "measurementSet"
#define PN_OBS_STATION_LIST "stationList"
#define PN_OBS_INPUT_NODE_LIST "inputNodeList"
}; // MCU #define PN_OBS_BGL_NODE_LIST "BGLNodeList"
}; // LOFAR #define PN_OBS_STORAGE_NODE_LIST "storageNodeList"
#define PN_OBS_BEAMS_ANGLE1 "Beams.angle1"
#define PN_OBS_BEAMS_ANGLE2 "Beams.angle2"
#define PN_OBS_BEAMS_DIRECTION_TYPE "Beams.directionType"
#define PN_OBS_BEAMS_BEAMLET_LIST "Beams.beamletList"
#define PN_OBS_BEAMS_SUBBAND_LIST "Beams.subbandList"
// ObsCtrl
#define PSN_OBS_CTRL "LOFAR_ObsSW_@observation@_ObsCtrl"
#define PST_OBS_CTRL "ObsCtrl"
// OnlineCtrl
#define PSN_ONLINE_CTRL "LOFAR_ObsSW_@observation@_OnlineCtrl"
#define PST_ONLINE_CTRL "OnlineCtrl"
// Correlator
#define PSN_CORRELATOR "LOFAR_ObsSW_@observation@_OnlineCtrl_Correlator"
#define PST_CORRELATOR "Correlator"
// StorageAppl
#define PSN_STORAGE_APPL "LOFAR_ObsSW_@observation@_OnlineCtrl_StorageAppl"
#define PST_STORAGE_APPL "StorageAppl"
// Cabinet
#define PSN_CABINET "LOFAR_PIC_@cabinet@"
#define PST_CABINET "Cabinet"
#define PN_CAB_DOOR_OPEN "doorOpen"
#define PN_CAB_FAN "fan"
#define PN_CAB_INLET_TEMP "inletTemp"
#define PN_CAB_FRONT_TEMP "frontTemp"
#define PN_CAB_BACK_TEMP "backTemp"
#define PN_CAB_SETPOINT_TEMP "setpointTemp"
#define PN_CAB_AMBIENT_TEMP "ambientTemp"
#define PN_CAB_CONTROL_MODE "controlMode"
// SubRack
#define PSN_SUB_RACK "LOFAR_PIC_@cabinet@_@subrack@"
#define PST_SUB_RACK "SubRack"
#define PN_SRCK_SPU__VHBA "SPU.Vhba"
#define PN_SRCK_SPU__VLBA "SPU.Vlba"
#define PN_SRCK_SPU__VDIG "SPU.Vdig"
#define PN_SRCK_SPU_TEMPERATURE "SPU.temperature"
#define PN_SRCK_CLOCK_BOARD__VFSP "clockBoard.Vfsp"
#define PN_SRCK_CLOCK_BOARD__VCLOCK "clockBoard.Vclock"
#define PN_SRCK_CLOCK_BOARD_VERSION "clockBoard.version"
#define PN_SRCK_CLOCK_BOARD_FREQ "clockBoard.freq"
#define PN_SRCK_CLOCK_BOARD_LOCK160 "clockBoard.lock160"
#define PN_SRCK_CLOCK_BOARD_LOCK200 "clockBoard.lock200"
#define PN_SRCK_CLOCK_BOARD_TEMPERATURE "clockBoard.temperature"
// RSPBoard
#define PSN_RSP_BOARD "LOFAR_PIC_@cabinet@_@subrack@_@RSPBoard@"
#define PST_RSP_BOARD "RSPBoard"
#define PN_RSP_VOLTAGE12 "voltage12"
#define PN_RSP_VOLTAGE25 "voltage25"
#define PN_RSP_VOLTAGE33 "voltage33"
#define PN_RSP_VERSION "version"
#define PN_RSP_ALERT "alert"
#define PN_RSP__ETHERNET_STATUS_STATE "Ethernet.status.state"
#define PN_RSP__ETHERNET_STATUS_CHILD_STATE "Ethernet.status.childState"
#define PN_RSP__ETHERNET_STATUS_MESSAGE "Ethernet.status.message"
#define PN_RSP_ETHERNET_PACKETS_RECEIVED "Ethernet.packetsReceived"
#define PN_RSP_ETHERNET_PACKETS_ERROR "Ethernet.packetsError"
#define PN_RSP_ETHERNET_LAST_ERROR "Ethernet.lastError"
#define PN_RSP_MEP_SEQNR "MEP.seqnr"
#define PN_RSP_MEP_ERROR "MEP.error"
#define PN_RSP_BP_STATUS_STATE "BP.status.state"
#define PN_RSP_BP_STATUS_CHILD_STATE "BP.status.childState"
#define PN_RSP_BP_STATUS_MESSAGE "BP.status.message"
#define PN_RSP_BP_TEMPERATURE "BP.temperature"
#define PN_RSP_BP_VERSION "BP.version"
#define PN_RSP_AP0_STATUS_STATE "AP0.status.state"
#define PN_RSP_AP0_STATUS_CHILD_STATE "AP0.status.childState"
#define PN_RSP_AP0_STATUS_MESSAGE "AP0.status.message"
#define PN_RSP_AP0_TEMPERATURE "AP0.temperature"
#define PN_RSP_AP0_VERSION "AP0.version"
#define PN_RSP_AP0_SYNC_SAMPLE_COUNT "AP0.SYNC.sampleCount"
#define PN_RSP_AP0_SYNC_SYNC_COUNT "AP0.SYNC.syncCount"
#define PN_RSP_AP0_SYNC_ERROR_COUNT "AP0.SYNC.errorCount"
#define PN_RSP_AP1_STATUS_STATE "AP1.status.state"
#define PN_RSP_AP1_STATUS_CHILD_STATE "AP1.status.childState"
#define PN_RSP_AP1_STATUS_MESSAGE "AP1.status.message"
#define PN_RSP_AP1_TEMPERATURE "AP1.temperature"
#define PN_RSP_AP1_VERSION "AP1.version"
#define PN_RSP_AP1_SYNC_SAMPLE_COUNT "AP1.SYNC.sampleCount"
#define PN_RSP_AP1_SYNC_SYNC_COUNT "AP1.SYNC.syncCount"
#define PN_RSP_AP1_SYNC_ERROR_COUNT "AP1.SYNC.errorCount"
#define PN_RSP_AP2_STATUS_STATE "AP2.status.state"
#define PN_RSP_AP2_STATUS_CHILD_STATE "AP2.status.childState"
#define PN_RSP_AP2_STATUS_MESSAGE "AP2.status.message"
#define PN_RSP_AP2_TEMPERATURE "AP2.temperature"
#define PN_RSP_AP2_VERSION "AP2.version"
#define PN_RSP_AP2_SYNC_SAMPLE_COUNT "AP2.SYNC.sampleCount"
#define PN_RSP_AP2_SYNC_SYNC_COUNT "AP2.SYNC.syncCount"
#define PN_RSP_AP2_SYNC_ERROR_COUNT "AP2.SYNC.errorCount"
#define PN_RSP_AP3_STATUS_STATE "AP3.status.state"
#define PN_RSP_AP3_STATUS_CHILD_STATE "AP3.status.childState"
#define PN_RSP_AP3_STATUS_MESSAGE "AP3.status.message"
#define PN_RSP_AP3_TEMPERATURE "AP3.temperature"
#define PN_RSP_AP3_VERSION "AP3.version"
#define PN_RSP_AP3_SYNC_SAMPLE_COUNT "AP3.SYNC.sampleCount"
#define PN_RSP_AP3_SYNC_SYNC_COUNT "AP3.SYNC.syncCount"
#define PN_RSP_AP3_SYNC_ERROR_COUNT "AP3.SYNC.errorCount"
// RCU
#define PSN_RCU "LOFAR_PIC_@cabinet@_@subrack@_@RSPBoard@_@rcu@"
#define PST_RCU "RCU"
#define PN_RCU_DELAY "Delay"
#define PN_RCU_INPUT_ENABLE "InputEnable"
#define PN_RCU_LBL_ENABLE "LBLEnable"
#define PN_RCU_LBH_ENABLE "LBHEnable"
#define PN_RCU_HBA_ENABLE "HBAEnable"
#define PN_RCU_BAND_SEL_LBA_HBA "bandSelLbaHba"
#define PN_RCU_HBA_FILTER_SEL "HBAFilterSel"
#define PN_RCU_VL_ENABLE "VlEnable"
#define PN_RCU_VH_ENABLE "VhEnable"
#define PN_RCU_VDD_VCC_ENABLE "VddVccEnable"
#define PN_RCU_BAND_SEL_LBL_LBH "bandSelLblLbh"
#define PN_RCU_LBA_FILTER_SEL "LBAFilterSel"
#define PN_RCU_ATTENUATION "Attenuation"
#define PN_RCU_NOF_OVERFLOW "nofOverflow"
#define PN_RCU_ADC_STATISTICS_OVERFLOW "ADCStatistics.overflow"
#define PN_RCU_TBB_ERROR "TBB.error"
#define PN_RCU_TBB_MODE "TBB.mode"
#define PN_RCU_TBB_START_ADDR "TBB.startAddr"
#define PN_RCU_TBB_BUF_SIZE "TBB.bufSize"
#define PN_RCU_TRIGGER_STARTLEVEL "Trigger.startlevel"
#define PN_RCU_TRIGGER_BASELEVEL "Trigger.baselevel"
#define PN_RCU_TRIGGER_STOPLEVEL "Trigger.stoplevel"
#define PN_RCU_TRIGGER_FILTER "Trigger.filter"
#define PN_RCU_TRIGGER_WINDOW "Trigger.window"
#define PN_RCU_TRIGGER_OPERATING_MODE "Trigger.operatingMode"
#define PN_RCU_TRIGGER_COEFF0 "Trigger.coeff0"
#define PN_RCU_TRIGGER_COEFF1 "Trigger.coeff1"
#define PN_RCU_TRIGGER_COEFF2 "Trigger.coeff2"
#define PN_RCU_TRIGGER_COEFF3 "Trigger.coeff3"
// TBBoard
#define PSN_TB_BOARD "LOFAR_PIC_@cabinet@_@subrack@_@TBBoard@"
#define PST_TB_BOARD "TBBoard"
#define PN_TBB_BOARDID "boardID"
#define PN_TBB_RAM_SIZE "RAMSize"
#define PN_TBB_SW_VERSION "SWVersion"
#define PN_TBB_BOARD_VERSION "boardVersion"
#define PN_TBB_TP_VERSION "TPVersion"
#define PN_TBB_MP0_VERSION "MP0Version"
#define PN_TBB_MP1_VERSION "MP1Version"
#define PN_TBB_MP2_VERSION "MP2Version"
#define PN_TBB_MP3_VERSION "MP3Version"
#define PN_TBB_VOLTAGE12 "voltage12"
#define PN_TBB_VOLTAGE25 "voltage25"
#define PN_TBB_VOLTAGE33 "voltage33"
#define PN_TBB_TEMPPCB "tempPCB"
#define PN_TBB_TEMPTP "tempTP"
#define PN_TBB_TEMPMP0 "tempMP0"
#define PN_TBB_TEMPMP1 "tempMP1"
#define PN_TBB_TEMPMP2 "tempMP2"
#define PN_TBB_TEMPMP3 "tempMP3"
#define PN_TBB_IMAGE_INFO_VERSION "imageInfo.version"
#define PN_TBB_IMAGE_INFO_WRITE_DATE "imageInfo.writeDate"
#define PN_TBB_IMAGE_INFO_TP_FILE "imageInfo.TPFile"
#define PN_TBB_IMAGE_INFO_MP_FILE "imageInfo.MPFile"
// StationClock
#define PSN_STATION_CLOCK "LOFAR_PIC_StationClock"
#define PST_STATION_CLOCK "StationClock"
#define PN_SCK_CLOCK "clock"
// LogProcessor
#define PSN_LOG_PROCESSOR "LOFAR_PermSW_Daemons_LogProcessor"
#define PST_LOG_PROCESSOR "LogProcessor"
// SASGateway
#define PSN_SAS_GATEWAY "LOFAR_PermSW_Daemons_SASGateway"
#define PST_SAS_GATEWAY "SASGateway"
// HardwareMonitor
#define PSN_HARDWARE_MONITOR "LOFAR_PermSW_HardwareMonitor"
#define PST_HARDWARE_MONITOR "HardwareMonitor"
#define PN_HWM_RSP_CONNECTED "RSP.connected"
#define PN_HWM_TBB_CONNECTED "TBB.connected"
// SoftwareMonitor
#define PSN_SOFTWARE_MONITOR "LOFAR_PermSW_SoftwareMonitor"
#define PST_SOFTWARE_MONITOR "SoftwareMonitor"
// TemperatureMonitor
#define PSN_TEMPERATURE_MONITOR "LOFAR_PermSW_TemperatureMonitor"
#define PST_TEMPERATURE_MONITOR "TemperatureMonitor"
// MACInfoServer
#define PSN_MAC_INFO_SERVER "LOFAR_PermSW_MACInfoServer"
#define PST_MAC_INFO_SERVER "MACInfoServer"
// StationCtrl
#define PSN_STATION_CTRL "LOFAR_PermSW_StationCtrl"
#define PST_STATION_CTRL "StationCtrl"
// DigBoardCtrl
#define PSN_DIG_BOARD_CTRL "LOFAR_PermSW_DigBoardCtrl"
#define PST_DIG_BOARD_CTRL "DigBoardCtrl"
#define PN_DBC_CONNECTED "connected"
#define PN_DBC_CLOCK "clock"
// StnObservation
#define PSN_STN_OBSERVATION "LOFAR_ObsSW_@observation@"
#define PST_STN_OBSERVATION "StnObservation"
#define PN_OBS_NAME "name"
#define PN_OBS_CLAIM_CLAIM_DATE "claim.claimDate"
// BeamCtrl
#define PSN_BEAM_CTRL "LOFAR_ObsSW_@observation@_BeamCtrl"
#define PST_BEAM_CTRL "BeamCtrl"
#define PN_BC_CONNECTED "connected"
#define PN_BC_SUB_ARRAY "subArray"
#define PN_BC_SUBBAND_LIST "subbandList"
#define PN_BC_BEAMLET_LIST "beamletList"
#define PN_BC_ANGLE1 "angle1"
#define PN_BC_ANGLE2 "angle2"
#define PN_BC_DIRECTION_TYPE "directionType"
#define PN_BC_BEAM_NAME "beamName"
// CalCtrl
#define PSN_CAL_CTRL "LOFAR_ObsSW_@observation@_CalCtrl"
#define PST_CAL_CTRL "CalCtrl"
#define PN_CC_CONNECTED "connected"
#define PN_CC_BEAM_NAMES "beamNames"
#define PN_CC_ANTENNA_ARRAY "antennaArray"
#define PN_CC_FILTER "filter"
#define PN_CC_NYQUISTZONE "nyquistzone"
#define PN_CC_RCUS "rcus"
// TBBCtrl
#define PSN_TBB_CTRL "LOFAR_ObsSW_@observation@_TBBCtrl"
#define PST_TBB_CTRL "TBBCtrl"
#define PN_TBC_CONNECTED "connected"
#define PN_TBC_TRIGGER_RCU_NR "trigger.rcuNr"
#define PN_TBC_TRIGGER_SEQUENCE_NR "trigger.sequenceNr"
#define PN_TBC_TRIGGER_TIME "trigger.time"
#define PN_TBC_TRIGGER_SAMPLE_NR "trigger.sampleNr"
#define PN_TBC_TRIGGER_SUM "trigger.sum"
#define PN_TBC_TRIGGER_NR_SAMPLES "trigger.nrSamples"
#define PN_TBC_TRIGGER_PEAK_VALUE "trigger.peakValue"
#define PN_TBC_TRIGGER_FLAGS "trigger.flags"
#define PN_TBC_TRIGGER_TABLE "trigger.table"
#endif #endif
...@@ -7,12 +7,14 @@ MACScheduler_CPPFLAGS = -DBOOST_DISABLE_THREADS \ ...@@ -7,12 +7,14 @@ MACScheduler_CPPFLAGS = -DBOOST_DISABLE_THREADS \
MACScheduler_SOURCES = ../Package__Version.cc \ MACScheduler_SOURCES = ../Package__Version.cc \
MACScheduler.cc \ MACScheduler.cc \
ObsClaimer.cc \
MACSchedulerMain.cc MACSchedulerMain.cc
MACScheduler_LDADD = -lpqxx $(LOFAR_DEPEND) MACScheduler_LDADD = -lpqxx $(LOFAR_DEPEND)
MACScheduler_DEPENDENCIES = $(LOFAR_DEPEND) MACScheduler_DEPENDENCIES = $(LOFAR_DEPEND)
NOINSTHDRS = MACScheduler.h \ NOINSTHDRS = MACScheduler.h \
ObsClaimer.h \
MACSchedulerDefines.h MACSchedulerDefines.h
INSTHDRS = INSTHDRS =
......
//# ObsClaimer.cc: Implementation of the MAC Scheduler task
//#
//# Copyright (C) 2002-2004
//# ASTRON (Netherlands Foundation for Research in Astronomy)
//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
//#
//# This program is free software; you can redistribute it and/or modify
//# it under the terms of the GNU General Public License as published by
//# the Free Software Foundation; either version 2 of the License, or
//# (at your option) any later version.
//#
//# This program is distributed in the hope that it will be useful,
//# but WITHOUT ANY WARRANTY; without even the implied warranty of
//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//# GNU General Public License for more details.
//#
//# You should have received a copy of the GNU General Public License
//# along with this program; if not, write to the Free Software
//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//#
//# $Id$
#include <lofar_config.h>
#include <Common/LofarLogger.h>
#include <Common/SystemUtil.h>
#include <Common/StreamUtil.h>
#include <Common/Version.h>
#include <APS/ParameterSet.h>
#include <GCF/TM/GCF_Protocols.h>
#include <GCF/TM/GCF_PortInterface.h>
#include <MACIO/MACServiceInfo.h>
#include <GCF/PVSS/GCF_PVTypes.h>
#include <APL/APLCommon/APL_Defines.h>
#include <APL/APLCommon/ControllerDefines.h>
#include <APL/APLCommon/StationInfo.h>
#include <GCF/RTDB/DP_Protocol.ph>
#include <APL/RTDBCommon/CM_Protocol.ph>
#include <APL/RTDBCommon/ClaimMgrTask.h>
#include <signal.h>
#include "MACSchedulerDefines.h"
#include "ObsClaimer.h"
using namespace LOFAR::GCF::PVSS;
using namespace LOFAR::GCF::TM;
using namespace LOFAR::GCF::RTDB;
using namespace LOFAR::APL::RTDBCommon;
using namespace LOFAR::Deployment;
using namespace std;
namespace LOFAR {
using namespace APLCommon;
using namespace ACC::APS;
namespace MainCU {
//
// ObsClaimer()
//
ObsClaimer::ObsClaimer(GCFTask* mainTask) :
GCFTask ((State)&ObsClaimer::idle_state, string("MS-ObsClaimer")),
itsClaimMgrTask (0),
itsITCPort (0),
itsHeartBeat (0),
itsTimerPort (0)
{
LOG_TRACE_OBJ ("ObsClaimer construction");
// construct the resources we need
itsTimerPort = new GCFTimerPort(*this, "OStimerport");
ASSERTSTR(itsTimerPort, "Can't construct a timer");
itsHeartBeat = new GCFTimerPort(*this, "OSHeartBeat");
ASSERTSTR(itsHeartBeat, "Can't construct a heatbeat timer");
itsITCPort = new GCFITCPort(*mainTask, *this, "ITCPort", GCFPortInterface::SAP, CM_PROTOCOL);
ASSERTSTR(itsITCPort, "Can't construct an ITC port");
itsClaimMgrTask = ClaimMgrTask::instance();
ASSERTSTR(itsClaimMgrTask, "Can't construct a claimMgrTask");
registerProtocol(CM_PROTOCOL, CM_PROTOCOL_STRINGS);
}
//
// ~ObsClaimer()
//
ObsClaimer::~ObsClaimer()
{
LOG_TRACE_OBJ ("~ObsClaimer");
if (itsTimerPort) { delete itsTimerPort; }
if (itsHeartBeat) { delete itsHeartBeat; }
if (itsITCPort) { delete itsITCPort; }
}
// -------------------- The only public function --------------------
//
// prepareObservation(const string& observationName);
//
// Just add the observationname to our prepareList and trigger main-loop.
void ObsClaimer::prepareObservation(const string& observationName)
{
OMiter iter = itsObsMap.find(observationName);
if (iter == itsObsMap.end()) { // new?
obsInfo* newObs = new obsInfo();
newObs->obsName = observationName;
newObs->state = OS_NEW;
// newObs->observation;
itsObsMap["LOFAR_ObsSW_"+observationName] = newObs;
LOG_DEBUG_STR("Added observation " << observationName << " to the prepareList");
}
else {
LOG_DEBUG_STR("Observation " << observationName << " already in the prepareList with state " << iter->second->state);
}
// Wake up state-machine asap.
itsHeartBeat->cancelAllTimers();
itsHeartBeat->setTimer(0.0);
}
//
// idle_state(event, port)
//
// Wait for new actions.
//
GCFEvent::TResult ObsClaimer::idle_state (GCFEvent& event, GCFPortInterface& port)
{
LOG_DEBUG_STR ("idle_state:" << eventName(event) << "@" << port.getName());
GCFEvent::TResult status = GCFEvent::HANDLED;
switch (event.signal) {
case F_ENTRY:
itsHeartBeat->setTimer(0.0); // check if there is something to do.
break;
case F_TIMER: {
// search the (first) observation that needs to be started; ask the claimMgr the name
// of the real DP.
OMiter iter = itsObsMap.begin();
OMiter end = itsObsMap.end();
while (iter != end) {
if (iter->second->state == OS_NEW) {
iter->second->state = OS_CLAIMING;
itsClaimMgrTask->claimObject("Observation", "LOFAR_ObsSW_"+iter->second->obsName, *itsITCPort);
// will result in CM_CLAIM_RESULT event
break;
}
++iter;
}
}
break;
case CM_CLAIM_RESULT: {
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);
}
break;
default:
LOG_DEBUG ("ObsClaimer::initial, default");
status = GCFEvent::NOT_HANDLED;
break;
}
return (status);
}
//
// preparePVSS_state(event, port)
//
// Fill all fields of the Observation in PVSS.
//
GCFEvent::TResult ObsClaimer::preparePVSS_state (GCFEvent& event, GCFPortInterface& port)
{
LOG_DEBUG_STR ("preparePVSS_state:" << eventName(event) << "@" << port.getName());
GCFEvent::TResult status = GCFEvent::HANDLED;
switch (event.signal) {
case F_ENTRY: {
// Create a PropSet for the Observation
LOG_DEBUG_STR ("Connecting to DP(" << itsCurrentObs->second->DPname << ") from observation "
<< itsCurrentObs->second->obsName);
itsCurrentObs->second->state = OS_FILLING;
itsCurrentObs->second->propSet = new RTDBPropertySet(itsCurrentObs->second->DPname,
"Observation",
PSAT_RW,
this);
}
break;
case DP_CREATED: {
// NOTE: thsi function may be called DURING the construction of the PropertySet.
// Always exit this event in a way that GCF can end the construction.
DPCreatedEvent dpEvent(event);
LOG_DEBUG_STR("Result of creating " << dpEvent.DPname << " = " << dpEvent.result);
itsTimerPort->cancelAllTimers();
itsTimerPort->setTimer(0.0);
}
break;
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);
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);
// theObsPS->setValue(PN_OBS_START_TIME, GCFPVString (to_simple_string(itsStartTime)), 0.0, false);
// theObsPS->setValue(PN_OBS_STOP_TIME, GCFPVString (to_simple_string(itsStopTime)), 0.0, false);
theObsPS->setValue(PN_OBS_BAND_FILTER, GCFPVString (theObs.filter), 0.0, false);
theObsPS->setValue(PN_OBS_NYQUISTZONE, GCFPVInteger(theObs.nyquistZone), 0.0, false);
theObsPS->setValue(PN_OBS_ANTENNA_ARRAY, GCFPVString (theObs.antennaArray), 0.0, false);
theObsPS->setValue(PN_OBS_RECEIVER_LIST, GCFPVString (theObs.receiverList), 0.0, false);
theObsPS->setValue(PN_OBS_SAMPLE_CLOCK, GCFPVInteger(theObs.sampleClock), 0.0, false);
theObsPS->setValue(PN_OBS_MEASUREMENT_SET, GCFPVString (theObs.MSNameMask), 0.0, false);
theObsPS->setValue(PN_OBS_STATION_LIST, GCFPVString (theObs.stationList), 0.0, false);
theObsPS->setValue(PN_OBS_BGL_NODE_LIST, GCFPVString (theObs.BGLNodeList), 0.0, false);
theObsPS->setValue(PN_OBS_STORAGE_NODE_LIST,GCFPVString (theObs.storageNodeList), 0.0, false);
// for the beams we have to construct dyn arrays first.
GCFPValueArray subbandArr;
GCFPValueArray beamletArr;
GCFPValueArray angle1Arr;
GCFPValueArray angle2Arr;
GCFPValueArray dirTypesArr;
for (uint32 i(0); i < theObs.beams.size(); i++) {
stringstream os;
writeVector(os, theObs.beams[i].subbands);
subbandArr.push_back (new GCFPVString(os.str()));
os.clear();
writeVector(os, theObs.beams[i].beamlets);
beamletArr.push_back (new GCFPVString(os.str()));
angle1Arr.push_back (new GCFPVDouble(theObs.beams[i].angle1));
angle2Arr.push_back (new GCFPVDouble(theObs.beams[i].angle2));
dirTypesArr.push_back (new GCFPVString(theObs.beams[i].directionType));
}
// Finally we can write those value to PVSS as well.
theObsPS->setValue(PN_OBS_BEAMS_SUBBAND_LIST, GCFPVDynArr(LPT_DYNSTRING, subbandArr), 0.0, false);
theObsPS->setValue(PN_OBS_BEAMS_BEAMLET_LIST, GCFPVDynArr(LPT_DYNSTRING, beamletArr), 0.0, false);
theObsPS->setValue(PN_OBS_BEAMS_ANGLE1, GCFPVDynArr(LPT_DYNDOUBLE, angle1Arr), 0.0, false);
theObsPS->setValue(PN_OBS_BEAMS_ANGLE2, GCFPVDynArr(LPT_DYNDOUBLE, angle2Arr), 0.0, false);
theObsPS->setValue(PN_OBS_BEAMS_DIRECTION_TYPE, GCFPVDynArr(LPT_DYNSTRING, dirTypesArr), 0.0, false);
theObsPS->flush();
// send Maintask a signal we are ready.
LOG_DEBUG_STR("Sending Maintask ready signal for " << itsCurrentObs->second->obsName);
CMClaimResultEvent cmEvent;
cmEvent.nameInAppl = itsCurrentObs->second->obsName;
cmEvent.DPname = itsCurrentObs->second->DPname;
itsITCPort->sendBack(cmEvent);
// remove observation from list
LOG_DEBUG_STR("Removing " << itsCurrentObs->second->obsName << " from my prepareList");
delete itsCurrentObs->second;
itsObsMap.erase(itsCurrentObs);
itsCurrentObs = 0;
// back to idle state.
TRAN(ObsClaimer::idle_state);
}
break;
default:
LOG_DEBUG("updateObsInPVSS, default");
status = GCFEvent::NOT_HANDLED;
break;
}
return (status);
}
}; // namespace MAINCU
}; // namespace LOFAR
//# ObsClaimer.h: Prepares PVSS for an Observation that is going to run.
//#
//# Copyright (C) 2008
//# ASTRON (Netherlands Foundation for Research in Astronomy)
//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
//#
//# This program is free software; you can redistribute it and/or modify
//# it under the terms of the GNU General Public License as published by
//# the Free Software Foundation; either version 2 of the License, or
//# (at your option) any later version.
//#
//# This program is distributed in the hope that it will be useful,
//# but WITHOUT ANY WARRANTY; without even the implied warranty of
//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//# GNU General Public License for more details.
//#
//# You should have received a copy of the GNU General Public License
//# along with this program; if not, write to the Free Software
//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//#
//# $Id$
#ifndef MAINCU_OBSSTARTER_H
#define MAINCU_OBSSTARTER_H
//# Common Includes
#include <Common/lofar_string.h>
#include <Common/lofar_vector.h>
#include <Common/LofarLogger.h>
//# GCF Includes
#include <MACIO/GCF_Event.h>
#include <GCF/TM/GCF_Control.h>
#include <GCF/PVSS/GCF_PVTypes.h>
#include <GCF/RTDB/RTDB_PropertySet.h>
#include <ApplCommon/Observation.h>
#include <APL/RTDBCommon/ClaimMgrTask.h>
//# ACC Includes
#include <APS/ParameterSet.h>
// forward declaration
namespace LOFAR {
using MACIO::GCFEvent;
using GCF::TM::GCFTimerPort;
using GCF::TM::GCFPortInterface;
using GCF::TM::GCFTask;
using GCF::RTDB::RTDBPropertySet;
using APL::RTDBCommon::ClaimMgrTask;
namespace MainCU {
class ObsClaimer : public GCFTask
{
public:
ObsClaimer(GCFTask* mainTask);
~ObsClaimer();
// ask the ObsClaimer to prepare the PVSS database for the given observation.
void prepareObservation(const string& observationName);
private:
// Connect to the PS of the claimManager
GCFEvent::TResult connect2claimMgr_state (GCFEvent& e, GCFPortInterface& p);
// Wait for call from MACScheduler task
GCFEvent::TResult idle_state (GCFEvent& e, GCFPortInterface& p);
// Fill all fields of the Observation.
GCFEvent::TResult preparePVSS_state (GCFEvent& e, GCFPortInterface& p);
// avoid copying
ObsClaimer(const ObsClaimer&);
ObsClaimer& operator=(const ObsClaimer&);
// internal datatypes
typedef struct obsInfo_t {
string obsName; // name used by user.
string DPname; // name of real DP.
Observation observation; // corresponding observation info.
int state; // state of handling this obs.
RTDBPropertySet* propSet;
} obsInfo;
enum {
OS_NEW = 0,
OS_CLAIMING,
OS_FILLING,
OS_STARTING
};
// ----- DATAMEMBERS -----
// admin for observations
map<string, obsInfo*> itsObsMap;
typedef map<string, obsInfo*>::iterator OMiter;
OMiter itsCurrentObs; // Obs currently handled by claimMgr.
ClaimMgrTask* itsClaimMgrTask; // Pointer to claimMgr.
GCFITCPort* itsITCPort; // Answer back from CMtask.
GCFTimerPort* itsHeartBeat; // 1 second tick
GCFTimerPort* itsTimerPort; // general purpose timer
};
};//MainCU
};//LOFAR
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment