diff --git a/LCS/ApplCommon/include/ApplCommon/Observation.h b/LCS/ApplCommon/include/ApplCommon/Observation.h index 89ee84766d4d82a85f48043c2a2536b19d924270..11ef0f9a10abf8a39d745373be26039646521a5d 100644 --- a/LCS/ApplCommon/include/ApplCommon/Observation.h +++ b/LCS/ApplCommon/include/ApplCommon/Observation.h @@ -65,6 +65,8 @@ public: // Returns a bitset containing the RCU's requested by the observation. bitset<MAX_RCUS> getRCUbitset(int nrLBAs, int nrHBAs, int nrRSPs, bool hasSplitters); + // TEMP HACK + string getAntennaArrayName(bool hasSplitters) const; // REO: The next functions don't make sense, all info is public!!!!! // OLAP: get the subbandList diff --git a/LCS/ApplCommon/src/Observation.cc b/LCS/ApplCommon/src/Observation.cc index 52db959bc9861d5e57eba6586bb2652153563bc7..97f7392cc1100ea5fbe13aa2de20ca81b5432da4 100644 --- a/LCS/ApplCommon/src/Observation.cc +++ b/LCS/ApplCommon/src/Observation.cc @@ -319,12 +319,37 @@ bitset<MAX_RCUS> Observation::getRCUbitset(int nrLBAs, int nrHBAs, int nrRSPs, b // Set up the RCUbits. Remember that we don't care here which of the three inputs is used. RCUset.reset(); - for (int rcu = firstRCU; rcu < nrAnts; rcu++) { + for (int rcu = firstRCU; rcu < 2*nrAnts; rcu++) { RCUset.set(rcu); } return (RCUset); } +// +// TEMP HACK TO GET THE ANTENNAARRAYNAME +// +string Observation::getAntennaArrayName(bool hasSplitters) const +{ + string result; + if (antennaSet.empty()) { + result = antennaArray; + } + else { + result = antennaSet; + } + + if (!hasSplitters) { // no splitter, always use all HBA + if (result.find("HBA") == 0) return ("HBA"); + } + else { // has splitter, translate SAS names to AntennaArray.conf names + if (result == "HBA_ONE") return ("HBA_0"); + if (result == "HBA_TWO") return ("HBA_1"); + if (result == "HBA_BOTH") return ("HBA"); + } + + return (result); +} + // // getBeamName(beamidx): string // @@ -357,14 +382,6 @@ vector<uint32> Observation::getRspBoardList() const return rspBoardList; } -// -// OLAP: getRspSlotList(): vector<uint32> -// -vector<uint32> Observation::getRspSlotList() const -{ - return rspSlotList; -} - // // nyquistzoneFromFilter(filtername) // @@ -406,6 +423,7 @@ ostream& Observation::print (ostream& os) const // os << "stations : " << stations << endl; os << "stations : "; writeVector(os, stations, ",", "[", "]"); os << endl; os << "antennaArray : " << antennaArray << endl; + os << "antenna set : " << antennaSet << endl; os << "receiver set : " << RCUset << endl; os << "sampleClock : " << sampleClock << endl; os << "filter : " << filter << endl; diff --git a/LCS/ApplCommon/test/tObservation.cc b/LCS/ApplCommon/test/tObservation.cc index 1f1197064b3e5a9b54a0bec6c14587be8f509a98..79a84f1f21935dc43300f02c385085eb41424810 100644 --- a/LCS/ApplCommon/test/tObservation.cc +++ b/LCS/ApplCommon/test/tObservation.cc @@ -109,7 +109,24 @@ int main (int, char* argv[]) cout << "getRCUbitset(96,48,24,false) = " << obs3.getRCUbitset(96,48,24,false) << endl; // Europe cout << "getRCUbitset(96,96,24,false) = " << obs3.getRCUbitset(96,96,24,false) << endl; // Europe - + cout << "HBA_ONE(false) = " << obs3.getAntennaArrayName(false) << endl; + cout << "HBA_ONE(true) = " << obs3.getAntennaArrayName(true) << endl; + obs3.antennaSet = "HBA_TWO"; + cout << "HBA_TWO(false) = " << obs3.getAntennaArrayName(false) << endl; + cout << "HBA_TWO(true) = " << obs3.getAntennaArrayName(true) << endl; + obs3.antennaSet = "HBA_BOTH"; + cout << "HBA_BOTH(false) = " << obs3.getAntennaArrayName(false) << endl; + cout << "HBA_BOTH(true) = " << obs3.getAntennaArrayName(true) << endl; + + obs3.antennaSet = "LBA_INNER"; + cout << "LBA_INNER(false) = " << obs3.getAntennaArrayName(false) << endl; + cout << "LBA_INNER(true) = " << obs3.getAntennaArrayName(true) << endl; + obs3.antennaSet = "LBA_OUTER"; + cout << "LBA_OUTER(false) = " << obs3.getAntennaArrayName(false) << endl; + cout << "LBA_OUTER(true) = " << obs3.getAntennaArrayName(true) << endl; + obs3.antennaSet = "LBA_X"; + cout << "LBA_X(false) = " << obs3.getAntennaArrayName(false) << endl; + cout << "LBA_X(true) = " << obs3.getAntennaArrayName(true) << endl; } catch (Exception& e) { cout << "Exception: " << e.what() << endl; diff --git a/MAC/APL/APLCommon/include/APL/APLCommon/AntennaMapper.h b/MAC/APL/APLCommon/include/APL/APLCommon/AntennaMapper.h index 25e97e5286d2f807d4a6f8f6aa10c187ffd498db..9d77ed572276697925a42b4d15f0161e9be08e4c 100644 --- a/MAC/APL/APLCommon/include/APL/APLCommon/AntennaMapper.h +++ b/MAC/APL/APLCommon/include/APL/APLCommon/AntennaMapper.h @@ -79,12 +79,12 @@ private: inline int AntennaMapper::XRCU(int antNr) const { - return ((antNr <= itsRCUs/2) ? 2*antNr : 2*antNr+1 - itsRCUs); + return ((antNr < itsRCUs/2) ? 2*antNr : 2*antNr+1 - itsRCUs); } inline int AntennaMapper::YRCU(int antNr) const { - return ((antNr <= itsRCUs/2) ? 2*antNr+1 : 2*antNr - itsRCUs); + return ((antNr < itsRCUs/2) ? 2*antNr+1 : 2*antNr - itsRCUs); } inline int AntennaMapper::RCUinput(int antNr, int antType) const diff --git a/MAC/APL/APLCommon/include/APL/APLCommon/ControllerDefines.h b/MAC/APL/APLCommon/include/APL/APLCommon/ControllerDefines.h index c8448bcb740b67e9cbcd81f2abfb031ca1124fde..ef4c9545c789fb4f706efdbeb4452b64cf0d17e3 100644 --- a/MAC/APL/APLCommon/include/APL/APLCommon/ControllerDefines.h +++ b/MAC/APL/APLCommon/include/APL/APLCommon/ControllerDefines.h @@ -50,6 +50,7 @@ enum CT_RESULT_CONFLICTING_ARGS, CT_RESULT_OUT_OF_SYNC, CT_RESULT_OBS_CONFLICT, + CT_RESULT_MANUAL_ABORT, CT_RESULT_UNSPECIFIED }; diff --git a/MAC/APL/APLCommon/test/tAntennaMapper.cc b/MAC/APL/APLCommon/test/tAntennaMapper.cc index 4ae40a659fcee81f2c1bbdb4b5753b0d2a487b37..a53286f51291b7360d52323949e0407fb88e20ac 100644 --- a/MAC/APL/APLCommon/test/tAntennaMapper.cc +++ b/MAC/APL/APLCommon/test/tAntennaMapper.cc @@ -40,6 +40,7 @@ void doTest(int antNr, int antType, AntennaMapper& AM) int main (int argc, char* argv[]) { + // rcus, lbas, hbas AntennaMapper AMCore (96, 96, 48); AntennaMapper AMRemote(96, 96, 0); AntennaMapper AMEurope(192,96, 48); @@ -47,6 +48,7 @@ int main (int argc, char* argv[]) cout << endl << "Core station with half HW and full LBA and HBA" << endl; doTest(5, AntennaMapper::AT_LBA, AMCore); doTest(5+48, AntennaMapper::AT_LBA, AMCore); + doTest(48, AntennaMapper::AT_LBA, AMCore); doTest(5, AntennaMapper::AT_HBA, AMCore); cout << endl << "Remote station with half HW and full LBA and NO HBA" << endl; diff --git a/MAC/APL/MainCU/src/ObservationControl/ObservationControl.cc b/MAC/APL/MainCU/src/ObservationControl/ObservationControl.cc index ea25988188dc74e83811ab5ced431662e580b05e..c7b78220634d91b7f02ab0319e864e7658b0edbb 100644 --- a/MAC/APL/MainCU/src/ObservationControl/ObservationControl.cc +++ b/MAC/APL/MainCU/src/ObservationControl/ObservationControl.cc @@ -500,7 +500,7 @@ GCFEvent::TResult ObservationControl::finishing_state(GCFEvent& event, // inform MACScheduler we are going down CONTROLQuitedEvent msg; msg.cntlrName = getName(); - msg.result = itsQuitReason;; + msg.result = itsQuitReason; itsParentPort->send(msg); // update PVSS @@ -640,7 +640,9 @@ void ObservationControl::doHeartBeatTask() // if no more children left while we are not in the quit-phase (stoptimer still running) if (!nrChilds && itsStopTimer) { LOG_FATAL("Too less stations left, FORCING QUIT OF OBSERVATION"); - itsQuitReason = CT_RESULT_LOST_CONNECTION; + if (itsState >= CTState::RESUME) { + itsQuitReason = CT_RESULT_LOST_CONNECTION; + } itsTimerPort->cancelTimer(itsStopTimer); itsStopTimer = itsTimerPort->setTimer(0.0); return; @@ -719,6 +721,9 @@ void ObservationControl::_databaseEventHandler(GCFEvent& event) string command = ((GCFPVString*) (dpEvent.value._pValue))->getValue(); if (command == "ABORT") { LOG_INFO("Received manual request for abort, accepting it."); + if (itsState < CTState::RESUME) { + itsQuitReason = CT_RESULT_MANUAL_ABORT; + } itsTimerPort->cancelTimer(itsStopTimer); // cancel old timer itsStopTimer = itsTimerPort->setTimer(0.0); // expire immediately } diff --git a/MAC/APL/PAC/Beam_Server/src/BeamServer.cc b/MAC/APL/PAC/Beam_Server/src/BeamServer.cc index a088f3fbd96db403d3c6cbfc8d30380d879c71ca..058866688716cc7f644dcaf38faa370df6f6f643 100644 --- a/MAC/APL/PAC/Beam_Server/src/BeamServer.cc +++ b/MAC/APL/PAC/Beam_Server/src/BeamServer.cc @@ -1145,7 +1145,6 @@ void BeamServer::send_sbselection() } LOG_DEBUG_STR("Sending subbandselecton for ring segment " << ringNr); -// LOG_DEBUG_STR(sbsel); itsRSPDriver->send(ss); } } diff --git a/MAC/APL/PAC/Cal_Server/src/CalServer.cc b/MAC/APL/PAC/Cal_Server/src/CalServer.cc index 676001c73877a8387743e6d1b23655695370bdec..a7f0aa4cc21a61c26dd61d215e6ec70251530689 100644 --- a/MAC/APL/PAC/Cal_Server/src/CalServer.cc +++ b/MAC/APL/PAC/Cal_Server/src/CalServer.cc @@ -285,6 +285,7 @@ GCFEvent::TResult CalServer::initial(GCFEvent& e, GCFPortInterface& port) RSPGetconfigackEvent ack(e); m_n_rspboards = ack.n_rspboards; m_n_rcus = ack.n_rcus; + LOG_INFO_STR("nrRSPboards=" << m_n_rspboards << ", nrRCUS=" << m_n_rcus); // resize and clear itsRCUcounters. itsRCUcounts.assign(m_n_rcus, 0); @@ -365,6 +366,7 @@ GCFEvent::TResult CalServer::enabled(GCFEvent& e, GCFPortInterface& port) switch (e.signal) { case F_ENTRY: { + _disableRCUs(0); m_acceptor.setTimer(0.0, 1.0); } break; @@ -396,7 +398,7 @@ GCFEvent::TResult CalServer::enabled(GCFEvent& e, GCFPortInterface& port) case RSP_SETRCUACK: { RSPSetrcuackEvent ack(e); if (ack.status != RSP_Protocol::RSP_SUCCESS) { - LOG_FATAL("Failed to set RCU control register"); + LOG_FATAL_STR("Failed to set RCU control register, error = " << ack.status); exit (EXIT_FAILURE); } } @@ -405,7 +407,7 @@ GCFEvent::TResult CalServer::enabled(GCFEvent& e, GCFPortInterface& port) case RSP_SETBYPASSACK: { RSPSetbypassackEvent ack(e); if (ack.status != RSP_Protocol::RSP_SUCCESS) { - LOG_FATAL("Failed to set Spectral Inversion control register"); + LOG_FATAL_STR("Failed to set Spectral Inversion control register, error = " << ack.status); exit (EXIT_FAILURE); } } @@ -824,20 +826,34 @@ void CalServer::_enableRCUs(SubArray* subarray) // void CalServer::_disableRCUs(SubArray* subarray) { - if (!subarray) { - return; - } // decrement the usecount of the receivers and build mask of receiver that may be disabled. - SubArray::RCUmask_t rcuMask = subarray->getRCUMask(); + bool allSwitchedOff(true); SubArray::RCUmask_t rcus2switchOff; rcus2switchOff.reset(); - for (int r = 0; r < m_n_rcus; r++) { - if (rcuMask.test(r)) { - if (--itsRCUcounts[r] == 0) { - rcus2switchOff.set(r); - } // count reaches 0 - } // rcu in mask - } // for all rcus + + if (subarray) { // when no subarray is defined skipp this loop: switch all rcus off. + SubArray::RCUmask_t rcuMask = subarray->getRCUMask(); + for (int r = 0; r < m_n_rcus; r++) { + if (rcuMask.test(r)) { + if (--itsRCUcounts[r] == 0) { + rcus2switchOff.set(r); + } // count reaches 0 + } // rcu in mask + + // independant of the rcuMask check if this receiver is (also) off + if (itsRCUcounts[r]) { // still on? + allSwitchedOff = false; + } + } // for all rcus + } + + if (allSwitchedOff) { // all receivers off? force all rcu's to mode 0, disable + rcus2switchOff.reset(); + for (int i = 0; i < m_n_rcus; i++) { + rcus2switchOff.set(i); + } + LOG_INFO("No active rcu's anymore, forcing all units to mode 0 and disable"); + } // anything to disable? Tell the RSPDriver. if (rcus2switchOff.any()) { @@ -848,7 +864,7 @@ void CalServer::_disableRCUs(SubArray* subarray) disableCmd.settings()(0).setEnable(false); disableCmd.settings()(0).setMode(RCUSettings::Control::MODE_OFF); sleep (1); - LOG_INFO_STR("Disabling some rcu's because they are not used anymore"); + LOG_INFO_STR("Disabling " << rcus2switchOff.count() << " rcu's because they are not used anymore"); m_rspdriver.send(disableCmd); } } diff --git a/MAC/APL/PIC/RSP_Driver/src/rspctl.cc b/MAC/APL/PIC/RSP_Driver/src/rspctl.cc index aacf7d1472976a7aa5b3664d69829bfc646e2cd7..4058853cf5f98fb5b9bd8ddae3ae9d57debdc6bf 100644 --- a/MAC/APL/PIC/RSP_Driver/src/rspctl.cc +++ b/MAC/APL/PIC/RSP_Driver/src/rspctl.cc @@ -2422,7 +2422,7 @@ GCFEvent::TResult RSPCtl::sub2Clock(GCFEvent& e, GCFPortInterface& port) case RSP_UPDCLOCK: { RSPUpdclockEvent answer(e); - gSampleFrequency = 10e6 * answer.clock; + gSampleFrequency = 1e6 * answer.clock; logMessage(cerr, formatString("Current clockvalue is %d Mhz", answer.clock)); if (itsNeedSplitter) { diff --git a/MAC/APL/StationCU/src/BeamControl/BeamControl.cc b/MAC/APL/StationCU/src/BeamControl/BeamControl.cc index e39e79538d49ee836ef0120b71b5d67e0c96f264..5b4d94fcd8e68cb884a10baab8640b611bfead06 100644 --- a/MAC/APL/StationCU/src/BeamControl/BeamControl.cc +++ b/MAC/APL/StationCU/src/BeamControl/BeamControl.cc @@ -27,13 +27,14 @@ #include <ApplCommon/StationInfo.h> #include <Common/ParameterSet.h> -#include <GCF/PVSS/GCF_PVTypes.h> #include <Common/SystemUtil.h> +#include <GCF/PVSS/GCF_PVTypes.h> +#include <GCF/RTDB/DP_Protocol.ph> #include <MACIO/MACServiceInfo.h> #include <APL/APLCommon/APL_Defines.h> #include <APL/APLCommon/Controller_Protocol.ph> #include <APL/BS_Protocol/BS_Protocol.ph> -#include <GCF/RTDB/DP_Protocol.ph> +#include <APL/RTDBCommon/RTDButilities.h> #include <signal.h> #include "BeamControl.h" @@ -43,6 +44,7 @@ using namespace LOFAR::GCF::TM; using namespace LOFAR::GCF::PVSS; using namespace LOFAR::GCF::RTDB; +using namespace LOFAR::APL::RTDBCommon; using namespace std; namespace LOFAR { @@ -372,8 +374,10 @@ GCFEvent::TResult BeamControl::claimed_state(GCFEvent& event, GCFPortInterface& port.close(); ASSERTSTR (&port == itsBeamServer, "F_DISCONNECTED event from port " << port.getName()); - LOG_WARN("Connection with BeamServer lost, going to reconnect state."); - TRAN(BeamControl::started_state); + LOG_WARN("Connection with BeamServer lost"); + setObjectState("Connection with BeamServer lost!", itsPropertySet->getFullScope(), RTDB_OBJ_STATE_BROKEN); + finish(); +// TRAN(BeamControl::started_state); break; } @@ -389,6 +393,7 @@ GCFEvent::TResult BeamControl::claimed_state(GCFEvent& event, GCFPortInterface& LOG_WARN_STR("Beamallocation error: nr subbands != nr beamlets" << ", staying in CLAIMED mode"); setState(CTState::CLAIMED); + setObjectState("Number of subbands != number of beamlets", itsPropertySet->getFullScope(), RTDB_OBJ_STATE_BROKEN); LOG_DEBUG_STR("Sending PREPARED(" << getName() << "," << CT_RESULT_CONFLICTING_ARGS << ")"); sendControlResult(*itsParentPort, CONTROL_PREPARED, getName(), @@ -461,8 +466,10 @@ GCFEvent::TResult BeamControl::active_state(GCFEvent& event, GCFPortInterface& p port.close(); ASSERTSTR (&port == itsBeamServer, "F_DISCONNECTED event from port " << port.getName()); - LOG_WARN("Connection with BeamServer lost, going to reconnect"); - TRAN(BeamControl::started_state); + LOG_WARN("Connection with BeamServer lost"); + setObjectState("Connection with BeamServer lost!", itsPropertySet->getFullScope(), RTDB_OBJ_STATE_BROKEN); + finish(); +// TRAN(BeamControl::started_state); break; } @@ -661,10 +668,11 @@ uint16 BeamControl::handleBeamAllocAck(GCFEvent& event) { // check the beam ID and status of the ACK message BSBeamallocackEvent ackEvent(event); - if (ackEvent.status != 0) { + if (ackEvent.status != BS_NO_ERR) { LOG_ERROR_STR("Beamlet allocation for beam " << ackEvent.subarrayname << " failed with errorcode: " << ackEvent.status); itsBeamIDs[ackEvent.subarrayname] = 0; + setObjectState("Beamlet alloc error", itsPropertySet->getFullScope(), RTDB_OBJ_STATE_BROKEN); return (CT_RESULT_BEAMALLOC_FAILED); } itsBeamIDs[ackEvent.subarrayname] = ackEvent.handle; @@ -676,6 +684,7 @@ uint16 BeamControl::handleBeamAllocAck(GCFEvent& event) if (beamIdx >= theObs.beams.size()) { LOG_FATAL_STR("Beamnr " << beamIdx+1 << " (=beam " << ackEvent.subarrayname << ") is out of range: 1.." << theObs.beams.size()); + setObjectState("Beamlet alloc index error", itsPropertySet->getFullScope(), RTDB_OBJ_STATE_BROKEN); return (CT_RESULT_BEAMALLOC_FAILED); } Observation::Beam* theBeam = &theObs.beams[beamIdx]; @@ -721,7 +730,7 @@ bool BeamControl::doRelease() bool BeamControl::handleBeamFreeAck(GCFEvent& event) { BSBeamfreeackEvent ack(event); - if (ack.status != 0) { + if (ack.status != BS_NO_ERR) { LOG_ERROR_STR("Beam de-allocation failed with errorcode: " << ack.status); itsPropertySet->setValue(PN_FSM_ERROR,GCFPVString("De-allocation of the beam failed.")); return (false); diff --git a/MAC/APL/StationCU/src/CalibrationControl/CalibrationControl.cc b/MAC/APL/StationCU/src/CalibrationControl/CalibrationControl.cc index a9726f2581abae5b7e7de72c7112f545b7ad1cbf..06265367557fc60c9c449334a38bb107da655d51 100644 --- a/MAC/APL/StationCU/src/CalibrationControl/CalibrationControl.cc +++ b/MAC/APL/StationCU/src/CalibrationControl/CalibrationControl.cc @@ -26,11 +26,12 @@ #include <ApplCommon/StationConfig.h> #include <ApplCommon/StationInfo.h> -#include <GCF/PVSS/GCF_PVTypes.h> #include <MACIO/MACServiceInfo.h> +#include <GCF/PVSS/GCF_PVTypes.h> +#include <GCF/RTDB/DP_Protocol.ph> #include <APL/APLCommon/Controller_Protocol.ph> #include <APL/CAL_Protocol/CAL_Protocol.ph> -#include <GCF/RTDB/DP_Protocol.ph> +#include <APL/RTDBCommon/RTDButilities.h> #include <signal.h> #include "CalibrationControl.h" @@ -40,6 +41,7 @@ using namespace LOFAR::GCF::TM; using namespace LOFAR::GCF::PVSS; using namespace LOFAR::GCF::RTDB; +using namespace LOFAR::APL::RTDBCommon; namespace LOFAR { using namespace APLCommon; @@ -396,9 +398,9 @@ GCFEvent::TResult CalibrationControl::claimed_state(GCFEvent& event, setState(CTState::PREPARE); gResult = CT_RESULT_NO_ERROR; if (!startCalibration()) { // will result in CAL_STARTACK event - sendControlResult(port, CONTROL_PREPARED, msg.cntlrName, - CT_RESULT_CALSTART_FAILED); + sendControlResult(port, CONTROL_PREPARED, msg.cntlrName, CT_RESULT_CALSTART_FAILED); setState(CTState::CLAIMED); + setObjectState("No beams specified!", itsPropertySet->getFullScope(), RTDB_OBJ_STATE_SUSPICIOUS); } break; } @@ -419,6 +421,7 @@ GCFEvent::TResult CalibrationControl::claimed_state(GCFEvent& event, LOG_ERROR_STR("Start of calibration of beam " << ack.name << " failed, staying in CLAIMED mode"); itsBeams[ack.name] = false; // add to beammap + setObjectState("Cannot start beam", itsPropertySet->getFullScope(), RTDB_OBJ_STATE_BROKEN); } if (itsObsPar.beams.size() == itsBeams.size()) { // answer for all beams received? report state @@ -430,6 +433,7 @@ GCFEvent::TResult CalibrationControl::claimed_state(GCFEvent& event, } else { LOG_INFO("Not all beams were calibrated right, staying in claiming mode"); + setObjectState("Cannot start calibration", itsPropertySet->getFullScope(), RTDB_OBJ_STATE_BROKEN); sendControlResult(*itsParentPort, CONTROL_PREPARED, getName(), CT_RESULT_CALSTART_FAILED); setState(CTState::CLAIMED); } @@ -544,6 +548,7 @@ GCFEvent::TResult CalibrationControl::active_state(GCFEvent& event, GCFPortInter } else { LOG_ERROR("Stop of some calibrations failed, staying in SUSPENDED mode"); + setObjectState("Cannot stop the calibration", itsPropertySet->getFullScope(), RTDB_OBJ_STATE_BROKEN); sendControlResult(*itsParentPort, CONTROL_RELEASED, getName(), CT_RESULT_CALSTOP_FAILED); setState(CTState::SUSPENDED); @@ -617,6 +622,10 @@ bool CalibrationControl::startCalibration() { uint32 nrBeams = itsObsPar.beams.size(); LOG_DEBUG_STR("Calibrating " << nrBeams << " beams."); + if (nrBeams == 0) { + LOG_WARN("No beams specified"); + return (false); + } GCFPValueArray beamNameArr; for (uint32 i(0); i < nrBeams; i++) { @@ -624,12 +633,13 @@ bool CalibrationControl::startCalibration() string beamName(itsObsPar.getBeamName(i)); CALStartEvent calStartEvent; - calStartEvent.name = beamName; - calStartEvent.parent = itsObsPar.antennaArray; + calStartEvent.name = beamName; + StationConfig config; + // TODO: As long as the AntennaArray.conf uses different names as SAS we have to use this dirty hack. + calStartEvent.parent = itsObsPar.getAntennaArrayName(config.hasSplitters); calStartEvent.rcumode().resize(1); calStartEvent.rcumode()(0).setMode((RSP_Protocol::RCUSettings::Control::RCUMode) convertFilterSelection(itsObsPar.filter, itsObsPar.antennaSet)); - StationConfig config; calStartEvent.subset = itsObsPar.getRCUbitset(config.nrLBAs, config.nrHBAs, config.nrRSPs, config.hasSplitters); LOG_DEBUG(formatString("Sending CALSTART(%s,%s,%08X)", beamName.c_str(), calStartEvent.parent.c_str(), diff --git a/MAC/APL/StationCU/src/ClockControl/ClockControl.cc b/MAC/APL/StationCU/src/ClockControl/ClockControl.cc index 18d1e92ae0791f457dec482d96d9d9610d6aa161..0b2ab4ee5239911e9a5835a83cec39738fa2471e 100644 --- a/MAC/APL/StationCU/src/ClockControl/ClockControl.cc +++ b/MAC/APL/StationCU/src/ClockControl/ClockControl.cc @@ -200,7 +200,7 @@ GCFEvent::TResult ClockControl::initial_state(GCFEvent& event, case F_ENTRY: { // Get access to my own propertyset. string myPropSetName(createPropertySetName(PSN_CLOCK_CONTROL, getName())); - LOG_DEBUG_STR ("Activating PropertySet " << myPropSetName); + LOG_INFO_STR ("Activating PropertySet " << myPropSetName); itsOwnPropertySet = new RTDBPropertySet(myPropSetName, PST_CLOCK_CONTROL, PSAT_RW, @@ -249,7 +249,7 @@ GCFEvent::TResult ClockControl::initial_state(GCFEvent& event, GCFPVInteger clockVal; itsOwnPropertySet->getValue(PN_CLC_REQUESTED_CLOCK, clockVal); itsClock = clockVal.getValue(); - LOG_DEBUG_STR("ClockSetting is " << itsClock); + LOG_INFO_STR("Requested clock is " << itsClock); LOG_DEBUG ("Going to connect2RSP state"); TRAN(ClockControl::connect2RSP_state); // go to next state. @@ -519,6 +519,7 @@ GCFEvent::TResult ClockControl::subscribeClock_state(GCFEvent& event, } itsClockSubscription = ack.handle; LOG_INFO("Subscription on the clock successful. going to operational mode"); + itsOwnPropertySet->setValue(PN_CLC_ACTUAL_CLOCK,GCFPVInteger(itsClock)); TRAN(ClockControl::active_state); // go to next state. } break; diff --git a/MAC/APL/StationCU/src/HardwareMonitor/ECMonitor.cc b/MAC/APL/StationCU/src/HardwareMonitor/ECMonitor.cc index 49176ad54d024024fe32a296ddefc12077bf0d8f..44dedbf3485e469cd96e67b4928c5cdda1fdd3cd 100644 --- a/MAC/APL/StationCU/src/HardwareMonitor/ECMonitor.cc +++ b/MAC/APL/StationCU/src/HardwareMonitor/ECMonitor.cc @@ -288,7 +288,7 @@ GCFEvent::TResult ECMonitor::createPropertySets(GCFEvent& event, GCFPortInterfac } LOG_INFO_STR("Allocation of all propertySets successfull, going to operational mode"); // itsOwnPropertySet->setValue(PN_FSM_ERROR,GCFPVString("")); - TRAN(ECMonitor::askStatus); + TRAN(ECMonitor::askSettings); } break; diff --git a/MAC/APL/StationCU/src/HardwareMonitor/RSPMonitor.cc b/MAC/APL/StationCU/src/HardwareMonitor/RSPMonitor.cc index a02df1784f03a4b172aa9b40adbce9d684d96ffc..244404010e48bc358e4f421272863d29d77fd6d3 100644 --- a/MAC/APL/StationCU/src/HardwareMonitor/RSPMonitor.cc +++ b/MAC/APL/StationCU/src/HardwareMonitor/RSPMonitor.cc @@ -292,14 +292,14 @@ GCFEvent::TResult RSPMonitor::askConfiguration(GCFEvent& event, itsHasSplitters = RSconf.getBool("RS.HBA_SPLIT", false); // inform user - LOG_DEBUG(formatString("nr RCUs = %d",ack.n_rcus)); - LOG_DEBUG(formatString("nr RSPboards = %d",ack.max_rspboards)); - LOG_DEBUG(formatString("nr Subracks = %d", itsNrSubracks)); - LOG_DEBUG(formatString("nr Cabinets = %d", itsNrCabinets)); - LOG_DEBUG(formatString("nr LBAs = %d", itsNrLBAs)); - LOG_DEBUG(formatString("nr HBAs = %d", itsNrHBAs)); - LOG_DEBUG_STR( "RSPmask = " << itsRSPmask); - LOG_DEBUG(formatString("has splitters= %s", (itsHasSplitters ? "yes" : "no"))); + LOG_INFO(formatString("nr RCUs = %d",ack.n_rcus)); + LOG_INFO(formatString("nr RSPboards = %d",ack.max_rspboards)); + LOG_INFO(formatString("nr Subracks = %d", itsNrSubracks)); + LOG_INFO(formatString("nr Cabinets = %d", itsNrCabinets)); + LOG_INFO(formatString("nr LBAs = %d", itsNrLBAs)); + LOG_INFO(formatString("nr HBAs = %d", itsNrHBAs)); + LOG_INFO_STR( "RSPmask = " << itsRSPmask); + LOG_INFO(formatString("has splitters= %s", (itsHasSplitters ? "yes" : "no"))); // do some checks if (itsNrRSPboards != (uint32)ack.max_rspboards) { @@ -423,7 +423,7 @@ GCFEvent::TResult RSPMonitor::createPropertySets(GCFEvent& event, for (uint32 rcu = 0; rcu < itsNrRCUs; rcu++) { ASSERTSTR(itsRCUs[rcu], "Allocation of PS for rcu " << rcu << " failed."); } - LOG_DEBUG_STR("Allocation of all propertySets successfull, going to subscribe to RCU states"); + LOG_INFO_STR("Allocation of all propertySets successfull, going to subscribe to RCU states"); // itsOwnPropertySet->setValue(PN_HWM_RSP_ERROR,GCFPVString("")); TRAN(RSPMonitor::subscribeToRCUs); } @@ -550,7 +550,7 @@ GCFEvent::TResult RSPMonitor::askVersion(GCFEvent& event, case RSP_GETVERSIONACK: { RSPGetversionackEvent ack(event); - if (ack.status != RSP_SUCCESS) { + if ((ack.status != RSP_SUCCESS) || (ack.versions.bp()(0).rsp_version == 0)) { LOG_ERROR_STR ("RSP:Failed to get the version information, retry in 5 seconds"); itsOwnPropertySet->setValue(PN_FSM_ERROR,GCFPVString("RSP:getVersion error")); itsTimerPort->setTimer(5.0); diff --git a/MAC/APL/StationCU/src/StationControl/ActiveObs.cc b/MAC/APL/StationCU/src/StationControl/ActiveObs.cc index a4efe77922bf4915b6437bc1310524eef55f8185..6b8b8320f0078c329610eb28eb35a6fa8d0b26c4 100644 --- a/MAC/APL/StationCU/src/StationControl/ActiveObs.cc +++ b/MAC/APL/StationCU/src/StationControl/ActiveObs.cc @@ -182,7 +182,10 @@ GCFEvent::TResult ActiveObs::starting(GCFEvent& event, GCFPortInterface& port) rbm[i] = '1'; } } - itsPropertySet->setValue(PN_OBS_RECEIVER_BITMAP,GCFPVString (rbm), 0.0, false); + LOG_INFO_STR("Setting receiverBitMap of DP:" << itsObsPar.realPVSSdatapoint << "." << PN_OBS_RECEIVER_BITMAP); + itsPropertySet->setValue(PN_OBS_RECEIVER_BITMAP,GCFPVString (rbm)); + itsPropertySet->setValue(PN_OBS_CLAIM_NAME, + GCFPVString(formatString("LOFAR_ObsSW_Observation%d", itsObsPar.obsID))); // Startup the right controllers. itsReqState = CTState::CREATED; diff --git a/MAC/APL/StationCU/src/StationControl/StationControl.cc b/MAC/APL/StationCU/src/StationControl/StationControl.cc index c10ff4609a03450910a071d3f6590379018b1b88..9e8ddd8b6a7e001ea3e7c1144425264128eaa8d4 100644 --- a/MAC/APL/StationCU/src/StationControl/StationControl.cc +++ b/MAC/APL/StationCU/src/StationControl/StationControl.cc @@ -124,8 +124,8 @@ StationControl::StationControl(const string& cntlrName) : itsRCUmask.reset(); itsTBmask.reset(); - LOG_DEBUG_STR("sizeof itsLBAmask: " << itsLBAmask.size()); - LOG_DEBUG_STR("sizeof itsHBAmask: " << itsHBAmask.size()); + LOG_DEBUG_STR("sizeof itsLBArcumask: " << itsLBArcumask.size()); + LOG_DEBUG_STR("sizeof itsHBArcumask: " << itsHBArcumask.size()); LOG_DEBUG_STR("sizeof itsRCUmask: " << itsRCUmask.size()); LOG_DEBUG_STR("sizeof itsTBmask: " << itsTBmask.size()); } @@ -632,9 +632,9 @@ GCFEvent::TResult StationControl::operational_state(GCFEvent& event, GCFPortInte if (event.signal == CONTROL_CLAIM) { itsStartingObs = theObs; TRAN(StationControl::startObservation_state); -// queueTaskEvent(event, port); -// return (GCFEvent::HANDLED); - return (GCFEvent::NEXT_STATE); + queueTaskEvent(event, port); + return (GCFEvent::HANDLED); +// return (GCFEvent::NEXT_STATE); } // TODO: CLEAN UP THE CODE BELOW @@ -773,6 +773,21 @@ GCFEvent::TResult StationControl::startObservation_state(GCFEvent& event, GCFPor break; case F_TIMER: { + StationConfig sc; + if (!sc.hasSplitters) { + LOG_INFO_STR("Ignoring splitter settings because we don't have splitters"); + // finally send a CLAIM event to the observation + LOG_TRACE_FLOW("Dispatch CLAIM event to observation FSM's."); + CONTROLClaimEvent claimEvent; + itsStartingObs->second->doEvent(claimEvent, port); + + LOG_INFO("Going back to operational state."); + itsStartingObs = itsObsMap.end(); + TRAN(StationControl::operational_state); + break; + } + + // set the splitters in the right state. bool splitterState = itsStartingObs->second->obsPar()->splitter; LOG_DEBUG_STR ("Setting the splitters to " << (splitterState ? "ON" : "OFF")); CLKCTRLSetSplittersEvent setEvent; @@ -793,6 +808,7 @@ GCFEvent::TResult StationControl::startObservation_state(GCFEvent& event, GCFPor } itsSplitters = splitterState; + sleep (2); // give splitters time to stabilize. // finally send a CLAIM event to the observation LOG_TRACE_FLOW("Dispatch CLAIM event to observation FSM's"); @@ -805,6 +821,7 @@ GCFEvent::TResult StationControl::startObservation_state(GCFEvent& event, GCFPor } break; + case F_ENTRY: case F_EXIT: break; @@ -942,6 +959,8 @@ void StationControl::_handleQueryEvent(GCFEvent& event) uint32 newState(((GCFPVInteger*)(DPvalues->getValue()[idx]))->getValue()); // value size_t pos; + LOG_DEBUG_STR("QryUpdate: DP=" << nameStr << ", value=" << newState); + // test for RCU if ((pos = nameStr.find("_RCU")) != string::npos) { int rcu; @@ -984,8 +1003,15 @@ void StationControl::_handleQueryEvent(GCFEvent& event) } if (sscanf(nameStr.substr(pos).c_str(), "_RSPBoard%d.splitterOn", &rsp) == 1) { - LOG_INFO_STR("New setting of splitter " << rsp << " is " << (newState ? "on" : "off")); - itsSplitters.set(rsp); + if (itsSplitters[rsp] != (newState ? true : false)) { + LOG_INFO_STR("New setting of splitter " << rsp << " is " << (newState ? "on" : "off")); + if (newState) { + itsSplitters.set(rsp); + } + else { + itsSplitters.reset(rsp); + } + } } } else { @@ -1120,8 +1146,8 @@ void StationControl::_abortObservation(ObsIter theObs) void StationControl::_initAntennaMasks() { // reset all variables - itsLBAmask.reset(); - itsHBAmask.reset(); + itsLBArcumask.reset(); + itsHBArcumask.reset(); // Adopt values from RemoteStation.conf StationConfig SC; @@ -1130,15 +1156,17 @@ void StationControl::_initAntennaMasks() itsNrHBAs = SC.nrHBAs; itsHasSplitters= SC.hasSplitters; - ASSERTSTR (itsNrLBAs <= itsLBAmask.size() && - itsNrHBAs <= itsHBAmask.size(), "Number of antennas exceed expected count"); + ASSERTSTR (2*itsNrLBAs <= itsLBArcumask.size() && + 2*itsNrHBAs <= itsHBArcumask.size(), "Number of antennas exceed expected count"); // set the right bits. for (uint i = 0; i < itsNrLBAs; i++) { - itsLBAmask.set(i); + itsLBArcumask.set(2*i); + itsLBArcumask.set(2*i+1); } for (uint i = 0; i < itsNrHBAs; i++) { - itsHBAmask.set(i); + itsHBArcumask.set(2*i); + itsHBArcumask.set(2*i+1); } // The masks are now initialized with the static information. The _handleQueryEvent routine @@ -1156,21 +1184,27 @@ void StationControl::_updateAntennaMasks() { // Note: the definition in StationControl.h and the ASSERT in _initAntennaMasks assure // that we never exceed the boundaries of the bitmaps here. - for (int rcu = 0; rcu < MAX_RCUS ; rcu+=2) { + for (int rcu = 0; rcu < MAX_RCUS/2 ; rcu+=2) { if (itsRCUmask[rcu] && itsRCUmask[rcu+1]) { // X and Y - itsLBAmask.set(rcu/2); - itsLBAmask.set(48+(rcu/2)); - itsHBAmask.set(rcu/2); + itsLBArcumask.set(rcu); + itsLBArcumask.set(rcu+1); + itsLBArcumask.set(96+rcu); + itsLBArcumask.set(96+rcu+1); + itsHBArcumask.set(rcu); + itsHBArcumask.set(rcu+1); } else { - itsLBAmask.reset(rcu/2); - itsLBAmask.reset(48+(rcu/2)); - itsHBAmask.reset(rcu/2); + itsLBArcumask.reset(rcu); + itsLBArcumask.reset(rcu+1); + itsLBArcumask.reset(96+rcu); + itsLBArcumask.reset(96+rcu+1); + itsHBArcumask.reset(rcu); + itsHBArcumask.reset(rcu+1); } } LOG_DEBUG_STR("itsRCU:" << string(itsRCUmask.to_string<char,char_traits<char>,allocator<char> >())); - LOG_DEBUG_STR("itsLBA:" << string(itsLBAmask.to_string<char,char_traits<char>,allocator<char> >())); - LOG_DEBUG_STR("itsHBA:" << string(itsHBAmask.to_string<char,char_traits<char>,allocator<char> >())); + LOG_DEBUG_STR("itsLBA:" << string(itsLBArcumask.to_string<char,char_traits<char>,allocator<char> >())); + LOG_DEBUG_STR("itsHBA:" << string(itsHBArcumask.to_string<char,char_traits<char>,allocator<char> >())); if (itsHasSplitters && itsSplitters.count() != 0 && itsSplitters.count() != itsNrRSPboards) { LOG_WARN_STR("Not all splitters have the same state! " << itsSplitters); diff --git a/MAC/APL/StationCU/src/StationControl/StationControl.h b/MAC/APL/StationCU/src/StationControl/StationControl.h index b1ce4869ad7301c0e6aa7730c6ca08f1ac40f540..70acb62253708a46c0cc02166b07380021315496 100644 --- a/MAC/APL/StationCU/src/StationControl/StationControl.h +++ b/MAC/APL/StationCU/src/StationControl/StationControl.h @@ -139,8 +139,8 @@ private: // Availability information of Antenna's and circuit boards. bool itsUseHWinfo; - bitset<MAX_RCUS / N_POL * 2> itsLBAmask; // LBA's are tight to LBL AND LBH!!! - bitset<MAX_RCUS / N_POL> itsHBAmask; + bitset<MAX_RCUS / N_POL * 2> itsLBArcumask; // LBA's are tight to LBL AND LBH!!! + bitset<MAX_RCUS / N_POL> itsHBArcumask; bitset<MAX_RCUS> itsRCUmask; bitset<MAX_RCUS / NR_RCUS_PER_TBBOARD> itsTBmask; uint32 itsNrLBAs;