From 5c5205ce9508950a063d44b13277329eed73a13f Mon Sep 17 00:00:00 2001 From: wierenga <sdos@astron.nl> Date: Wed, 24 May 2006 10:22:42 +0000 Subject: [PATCH] BugID: 646 Implemented new defintion and behaviour of RegisterState states. --- MAC/APL/PIC/RSPDriver/src/BSWrite.cc | 6 +- MAC/APL/PIC/RSPDriver/src/BWWrite.cc | 15 +- MAC/APL/PIC/RSPDriver/src/BstRead.cc | 6 +- MAC/APL/PIC/RSPDriver/src/CDOWrite.cc | 9 +- MAC/APL/PIC/RSPDriver/src/Cache.cc | 5 - .../PIC/RSPDriver/src/GetRegisterStateCmd.cc | 95 +++++++++++++ .../PIC/RSPDriver/src/GetRegisterStateCmd.h | 92 +++++++++++++ MAC/APL/PIC/RSPDriver/src/Makefile.am | 4 + MAC/APL/PIC/RSPDriver/src/RCUProtocolWrite.cc | 13 +- MAC/APL/PIC/RSPDriver/src/RCUResultRead.cc | 27 ++-- MAC/APL/PIC/RSPDriver/src/RCUResultRead.h | 1 + MAC/APL/PIC/RSPDriver/src/RCUWrite.cc | 16 ++- MAC/APL/PIC/RSPDriver/src/RSPDriver.cc | 103 ++++++++++++++ MAC/APL/PIC/RSPDriver/src/RSPDriver.conf.in | 2 +- MAC/APL/PIC/RSPDriver/src/RSPDriver.h | 5 + MAC/APL/PIC/RSPDriver/src/RSUWrite.cc | 8 +- MAC/APL/PIC/RSPDriver/src/SSRead.cc | 7 +- MAC/APL/PIC/RSPDriver/src/SSWrite.cc | 6 +- MAC/APL/PIC/RSPDriver/src/Scheduler.cc | 9 ++ MAC/APL/PIC/RSPDriver/src/SetClocksCmd.cc | 4 +- MAC/APL/PIC/RSPDriver/src/SetRCUCmd.cc | 6 +- MAC/APL/PIC/RSPDriver/src/SetRSUCmd.cc | 2 +- MAC/APL/PIC/RSPDriver/src/SetWGCmd.cc | 4 +- MAC/APL/PIC/RSPDriver/src/SetWeightsCmd.cc | 4 +- MAC/APL/PIC/RSPDriver/src/SstRead.cc | 8 +- MAC/APL/PIC/RSPDriver/src/StatusRead.cc | 6 +- MAC/APL/PIC/RSPDriver/src/TDSProtocolWrite.cc | 6 +- MAC/APL/PIC/RSPDriver/src/TDSResultRead.cc | 17 ++- MAC/APL/PIC/RSPDriver/src/UpdClocksCmd.cc | 2 +- .../PIC/RSPDriver/src/UpdRegisterStateCmd.cc | 89 ++++++++++++ .../PIC/RSPDriver/src/UpdRegisterStateCmd.h | 86 ++++++++++++ MAC/APL/PIC/RSPDriver/src/WGWrite.cc | 6 +- MAC/APL/PIC/RSPDriver/src/XstRead.cc | 8 +- MAC/APL/PIC/RSPDriver/src/rspctl.cc | 123 ++++++++++++++--- MAC/APL/PIC/RSPDriver/src/rspctl.h | 130 ++++++++++-------- MAC/APL/PIC/RSPDriver/test/EPAStub.cc | 4 +- MAC/APL/PIC/RSPDriver/test/EPAStub.conf.in | 5 +- .../APL/RSP_Protocol/AllRegisterState.h | 61 ++++---- .../PIC/RSP_Protocol/src/AllRegisterState.cc | 54 ++++---- 39 files changed, 833 insertions(+), 221 deletions(-) create mode 100644 MAC/APL/PIC/RSPDriver/src/GetRegisterStateCmd.cc create mode 100644 MAC/APL/PIC/RSPDriver/src/GetRegisterStateCmd.h create mode 100644 MAC/APL/PIC/RSPDriver/src/UpdRegisterStateCmd.cc create mode 100644 MAC/APL/PIC/RSPDriver/src/UpdRegisterStateCmd.h diff --git a/MAC/APL/PIC/RSPDriver/src/BSWrite.cc b/MAC/APL/PIC/RSPDriver/src/BSWrite.cc index cafd856f287..3d528f074ba 100644 --- a/MAC/APL/PIC/RSPDriver/src/BSWrite.cc +++ b/MAC/APL/PIC/RSPDriver/src/BSWrite.cc @@ -49,8 +49,9 @@ BSWrite::~BSWrite() void BSWrite::sendrequest() { // skip update if the neither of the RCU's settings have been modified - if (RTC::RegisterState::MODIFIED != Cache::getInstance().getState().bs().get((getBoardId() * StationSettings::instance()->nrBlps()) + m_blp)) + if (RTC::RegisterState::WRITE != Cache::getInstance().getState().bs().get((getBoardId() * StationSettings::instance()->nrBlps()) + m_blp)) { + Cache::getInstance().getState().bs().unmodified((getBoardId() * StationSettings::instance()->nrBlps()) + m_blp); setContinue(true); return; } @@ -87,11 +88,12 @@ GCFEvent::TResult BSWrite::handleack(GCFEvent& event, GCFPortInterface& /*port*/ if (!ack.hdr.isValidAck(m_hdr)) { LOG_ERROR("BSWrite::handleack: invalid ack"); + Cache::getInstance().getState().bs().write_error((getBoardId() * StationSettings::instance()->nrBlps()) + m_blp); return GCFEvent::NOT_HANDLED; } // change state to indicate that it has been applied in the hardware - Cache::getInstance().getState().bs().confirmed((getBoardId() * StationSettings::instance()->nrBlps()) + m_blp); + Cache::getInstance().getState().bs().write_ack((getBoardId() * StationSettings::instance()->nrBlps()) + m_blp); return GCFEvent::HANDLED; } diff --git a/MAC/APL/PIC/RSPDriver/src/BWWrite.cc b/MAC/APL/PIC/RSPDriver/src/BWWrite.cc index 6d8ef93b5e5..e030b50446d 100644 --- a/MAC/APL/PIC/RSPDriver/src/BWWrite.cc +++ b/MAC/APL/PIC/RSPDriver/src/BWWrite.cc @@ -58,7 +58,8 @@ void BWWrite::sendrequest() { uint8 global_blp = (getBoardId() * StationSettings::instance()->nrBlpsPerBoard()) + m_blp; - // never skip update of beamformer weights, they need to be written every second + // mark as modified, never skip update of beamformer weights, they need to be written every second + //Cache::getInstance().getState().bf().write_now(global_blp * MEPHeader::N_PHASEPOL + m_regid); // reset m_offset and m_remaining for each register if (0 == getCurrentIndex()) { @@ -208,7 +209,7 @@ GCFEvent::TResult BWWrite::handleack(GCFEvent& event, GCFPortInterface& /*port*/ if (!ack.hdr.isValidAck(m_hdr)) { - Cache::getInstance().getState().bf().modified(global_blp * MEPHeader::N_PHASEPOL + m_regid); + Cache::getInstance().getState().bf().write_error(global_blp * MEPHeader::N_PHASEPOL + m_regid); LOG_ERROR("BWWrite::handleack: invalid ack"); return GCFEvent::NOT_HANDLED; @@ -216,14 +217,10 @@ GCFEvent::TResult BWWrite::handleack(GCFEvent& event, GCFPortInterface& /*port*/ } else { // - // This code assumed that BF_N_FRAGMENTS == 2 - // First fragment transitions state to applied. - // Second (and last) fragment transitions state to confirmed. + // Last fragment signals completion // - if (0 == getCurrentIndex() % BF_N_FRAGMENTS) { - Cache::getInstance().getState().bf().applied(global_blp * MEPHeader::N_PHASEPOL + m_regid); - } else { - Cache::getInstance().getState().bf().confirmed(global_blp * MEPHeader::N_PHASEPOL + m_regid); + if (BF_N_FRAGMENTS - 1 == getCurrentIndex()) { + Cache::getInstance().getState().bf().write_ack(global_blp * MEPHeader::N_PHASEPOL + m_regid); } } diff --git a/MAC/APL/PIC/RSPDriver/src/BstRead.cc b/MAC/APL/PIC/RSPDriver/src/BstRead.cc index 0044e9920b0..032eaa07e40 100644 --- a/MAC/APL/PIC/RSPDriver/src/BstRead.cc +++ b/MAC/APL/PIC/RSPDriver/src/BstRead.cc @@ -51,7 +51,7 @@ void BstRead::sendrequest() { EPAReadEvent bstread; - Cache::getInstance().getState().bst().modified(getBoardId()); + Cache::getInstance().getState().bst().read(getBoardId()); bstread.hdr.set(MEPHeader::BST_POWER_HDR, MEPHeader::DST_RSP, MEPHeader::READ, MEPHeader::BST_POWER_SIZE); @@ -100,7 +100,7 @@ GCFEvent::TResult BstRead::handleack(GCFEvent& event, GCFPortInterface& /*port*/ if (!ack.hdr.isValidAck(m_hdr)) { - Cache::getInstance().getState().bst().applied(getBoardId()); + Cache::getInstance().getState().bst().read_error(getBoardId()); LOG_ERROR("BstRead::handleack: invalid ack"); return GCFEvent::NOT_HANDLED; } @@ -133,7 +133,7 @@ GCFEvent::TResult BstRead::handleack(GCFEvent& event, GCFPortInterface& /*port*/ cache(getBoardId() * 2 + 1, fragment_range) = convert_uint32_to_double(stats(Range::all(), 1)); - Cache::getInstance().getState().bst().confirmed(getBoardId()); + Cache::getInstance().getState().bst().read_ack(getBoardId()); return GCFEvent::HANDLED; } diff --git a/MAC/APL/PIC/RSPDriver/src/CDOWrite.cc b/MAC/APL/PIC/RSPDriver/src/CDOWrite.cc index 8e92e341371..49dbcff72fc 100644 --- a/MAC/APL/PIC/RSPDriver/src/CDOWrite.cc +++ b/MAC/APL/PIC/RSPDriver/src/CDOWrite.cc @@ -137,8 +137,9 @@ uint16 CDOWrite::compute_ip_checksum(void* addr, int count) void CDOWrite::sendrequest() { // skip update if the CDO settings have not been modified - if (RTC::RegisterState::MODIFIED != Cache::getInstance().getState().cdo().get(getBoardId())) + if (RTC::RegisterState::WRITE != Cache::getInstance().getState().cdo().get(getBoardId())) { + Cache::getInstance().getState().cdo().unmodified(getBoardId()); setContinue(true); return; } @@ -195,14 +196,12 @@ GCFEvent::TResult CDOWrite::handleack(GCFEvent& event, GCFPortInterface& /*port* if (!ack.hdr.isValidAck(m_hdr)) { LOG_ERROR("CDOWrite::handleack: invalid ack"); + Cache::getInstance().getState().cdo().write_error(getBoardId()); return GCFEvent::NOT_HANDLED; } - if (0 == getCurrentIndex()) { - Cache::getInstance().getState().cdo().applied(getBoardId()); - } if (1 == getCurrentIndex()) { - Cache::getInstance().getState().cdo().confirmed(getBoardId()); + Cache::getInstance().getState().cdo().write_ack(getBoardId()); } return GCFEvent::HANDLED; diff --git a/MAC/APL/PIC/RSPDriver/src/Cache.cc b/MAC/APL/PIC/RSPDriver/src/Cache.cc index 97ab5d2ac03..3dee349ee47 100644 --- a/MAC/APL/PIC/RSPDriver/src/Cache.cc +++ b/MAC/APL/PIC/RSPDriver/src/Cache.cc @@ -271,11 +271,6 @@ Cache::~Cache() void Cache::swapBuffers() { - // clear modified flags on back buffer - getState().clear(); - - getState().print(cout); - CacheBuffer *tmp = m_front; m_front = m_back; m_back = tmp; diff --git a/MAC/APL/PIC/RSPDriver/src/GetRegisterStateCmd.cc b/MAC/APL/PIC/RSPDriver/src/GetRegisterStateCmd.cc new file mode 100644 index 00000000000..741d231c27c --- /dev/null +++ b/MAC/APL/PIC/RSPDriver/src/GetRegisterStateCmd.cc @@ -0,0 +1,95 @@ +//# +//# GetRegisterStateCmd.cc: implementation of the GetRegisterStateCmd class +//# +//# 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 <APL/RSP_Protocol/RSP_Protocol.ph> + +#include <APL/RTCCommon/PSAccess.h> +#include <blitz/array.h> + +#include "StationSettings.h" +#include "GetRegisterStateCmd.h" + +using namespace blitz; +using namespace LOFAR; +using namespace RSP; +using namespace RSP_Protocol; +using namespace RTC; + +GetRegisterStateCmd::GetRegisterStateCmd(GCFEvent& event, GCFPortInterface& port, Operation oper) +{ + m_event = new RSPGetclockEvent(event); + + setOperation(oper); + setPeriod(0); + setPort(port); +} + +GetRegisterStateCmd::~GetRegisterStateCmd() +{ + delete m_event; +} + +void GetRegisterStateCmd::ack(CacheBuffer& cache) +{ + RSPGetregisterstateackEvent ack; + + ack.timestamp = getTimestamp(); + ack.status = SUCCESS; + + ack.state = cache.getCache().getState(); + + getPort()->send(ack); +} + +void GetRegisterStateCmd::apply(CacheBuffer& /*cache*/, bool /*setModFlag*/) +{ + /* intentionally left empty */ +} + +void GetRegisterStateCmd::complete(CacheBuffer& cache) +{ + ack(cache); +} + +const RTC::Timestamp& GetRegisterStateCmd::getTimestamp() const +{ + return m_event->timestamp; +} + +void GetRegisterStateCmd::setTimestamp(const RTC::Timestamp& timestamp) +{ + m_event->timestamp = timestamp; +} + +bool GetRegisterStateCmd::validate() const +{ + return (true); +} + +bool GetRegisterStateCmd::readFromCache() const +{ + return m_event->cache; +} diff --git a/MAC/APL/PIC/RSPDriver/src/GetRegisterStateCmd.h b/MAC/APL/PIC/RSPDriver/src/GetRegisterStateCmd.h new file mode 100644 index 00000000000..37046bb66f2 --- /dev/null +++ b/MAC/APL/PIC/RSPDriver/src/GetRegisterStateCmd.h @@ -0,0 +1,92 @@ +//# -*- mode: c++ -*- +//# +//# GetRegisterStateCmd.h: Beamformer Weights settings command. +//# +//# 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$ + +#ifndef GETREGISTERSTATECMD_H_ +#define GETREGISTERSTATECMD_H_ + +#include "Command.h" +#include <APL/RSP_Protocol/RSP_Protocol.ph> + +#include <Common/LofarTypes.h> +#include <GCF/TM/GCF_Control.h> + +namespace LOFAR { + namespace RSP { + + class GetRegisterStateCmd : public Command + { + public: + /** + * Constructors for a GetRegisterStateCmd object. + */ + GetRegisterStateCmd(GCFEvent& event, GCFPortInterface& port, Operation oper); + + /* Destructor for GetRegisterStateCmd. */ + virtual ~GetRegisterStateCmd(); + + /** + * Acknowledge the command by sending the appropriate + * response on m_port. + */ + virtual void ack(CacheBuffer& cache); + + /** + * Make necessary changes to the cache for the next synchronization. + * Any changes will be sent to the RSP boards. + */ + virtual void apply(CacheBuffer& cache, bool setModFlag = true); + + /** + * Complete the command by sending the appropriate response on + * the m_answerport; + */ + virtual void complete(CacheBuffer& cache); + + /*@{*/ + /** + * get timestamp of the event + */ + virtual const RTC::Timestamp& getTimestamp() const; + virtual void setTimestamp(const RTC::Timestamp& timestamp); + /*@}*/ + + /** + * Validate the event that underlies the command. + */ + virtual bool validate() const; + + /** + * Return true if value should be read from cache. + */ + bool readFromCache() const; + + private: + GetRegisterStateCmd(); + + RSPGetclockEvent* m_event; + }; + }; +}; + +#endif /* GETREGISTERSTATECMD_H_ */ diff --git a/MAC/APL/PIC/RSPDriver/src/Makefile.am b/MAC/APL/PIC/RSPDriver/src/Makefile.am index 6a98b500e77..3aded99f863 100644 --- a/MAC/APL/PIC/RSPDriver/src/Makefile.am +++ b/MAC/APL/PIC/RSPDriver/src/Makefile.am @@ -128,6 +128,10 @@ RSPDriver_SOURCES = \ GetClocksCmd.cc \ UpdClocksCmd.h \ UpdClocksCmd.cc \ + GetRegisterStateCmd.h \ + GetRegisterStateCmd.cc \ + UpdRegisterStateCmd.h \ + UpdRegisterStateCmd.cc \ \ SyncAction.h \ SyncAction.cc \ diff --git a/MAC/APL/PIC/RSPDriver/src/RCUProtocolWrite.cc b/MAC/APL/PIC/RSPDriver/src/RCUProtocolWrite.cc index 3f1ac6270d8..d99a7aaa191 100644 --- a/MAC/APL/PIC/RSPDriver/src/RCUProtocolWrite.cc +++ b/MAC/APL/PIC/RSPDriver/src/RCUProtocolWrite.cc @@ -66,7 +66,7 @@ namespace LOFAR { #define N_WRITES 2 // 2 writes, one for protocol register, one to clear results register RCUProtocolWrite::RCUProtocolWrite(GCFPortInterface& board_port, int board_id) - : SyncAction(board_port, board_id, StationSettings::instance()->nrBlpsPerBoard() * MEPHeader::N_POL * N_WRITES) // *N_POL for X and Y + : SyncAction(board_port, board_id, StationSettings::instance()->nrRcusPerBoard() * N_WRITES) // *N_POL for X and Y { memset(&m_hdr, 0, sizeof(MEPHeader)); } @@ -78,10 +78,11 @@ RCUProtocolWrite::~RCUProtocolWrite() void RCUProtocolWrite::sendrequest() { - uint8 global_rcu = (getBoardId() * StationSettings::instance()->nrBlpsPerBoard() * MEPHeader::N_POL) + (getCurrentIndex() / N_WRITES); + uint8 global_rcu = (getBoardId() * StationSettings::instance()->nrRcusPerBoard()) + (getCurrentIndex() / N_WRITES); // skip update if the RCU settings have not been modified - if (RTC::RegisterState::MODIFIED != Cache::getInstance().getState().rcuprotocol().get(global_rcu)) { + if (RTC::RegisterState::WRITE != Cache::getInstance().getState().rcuprotocol().get(global_rcu)) { + Cache::getInstance().getState().rcuprotocol().unmodified(global_rcu); setContinue(true); return; } @@ -152,9 +153,12 @@ GCFEvent::TResult RCUProtocolWrite::handleack(GCFEvent& event, GCFPortInterface& EPAWriteackEvent ack(event); + uint8 global_rcu = (getBoardId() * StationSettings::instance()->nrRcusPerBoard()) + (getCurrentIndex() / N_WRITES); + if (!ack.hdr.isValidAck(m_hdr)) { LOG_ERROR("RCUProtocolWrite::handleack: invalid ack"); + Cache::getInstance().getState().rcuprotocol().write_error(global_rcu); return GCFEvent::NOT_HANDLED; } @@ -162,8 +166,7 @@ GCFEvent::TResult RCUProtocolWrite::handleack(GCFEvent& event, GCFPortInterface& // Mark modification as applied when write of RCU result register has completed - uint8 global_rcu = (getBoardId() * StationSettings::instance()->nrRcusPerBoard()) + (getCurrentIndex() / N_WRITES); - Cache::getInstance().getState().rcuprotocol().applied(global_rcu); + Cache::getInstance().getState().rcuprotocol().schedule_read(global_rcu); } diff --git a/MAC/APL/PIC/RSPDriver/src/RCUResultRead.cc b/MAC/APL/PIC/RSPDriver/src/RCUResultRead.cc index 2da3d21ab7e..8b1b4fb40f7 100644 --- a/MAC/APL/PIC/RSPDriver/src/RCUResultRead.cc +++ b/MAC/APL/PIC/RSPDriver/src/RCUResultRead.cc @@ -38,10 +38,11 @@ using namespace LOFAR; using namespace RSP; using namespace EPA_Protocol; -#define RESULT_DELAY_PERIOD 2 +#define RCURESULTREAD_DELAY 2 RCUResultRead::RCUResultRead(GCFPortInterface& board_port, int board_id) - : SyncAction(board_port, board_id, StationSettings::instance()->nrBlpsPerBoard() * MEPHeader::N_POL) // *N_POL for X and Y + : SyncAction(board_port, board_id, StationSettings::instance()->nrBlpsPerBoard() * MEPHeader::N_POL), // *N_POL for X and Y + m_delay(0) { memset(&m_hdr, 0, sizeof(MEPHeader)); } @@ -56,11 +57,17 @@ void RCUResultRead::sendrequest() uint8 global_rcu = (getBoardId() * StationSettings::instance()->nrBlpsPerBoard() * MEPHeader::N_POL) + getCurrentIndex(); // skip update if the RCU settings have not been applied yet - if (RTC::RegisterState::APPLIED != Cache::getInstance().getState().rcuprotocol().get(global_rcu)) - { + if (RTC::RegisterState::READ != Cache::getInstance().getState().rcuprotocol().get(global_rcu)) { + setContinue(true); + return; + } + + // delay TDSRESULTREAD_DELAY periods + if (m_delay++ < RCURESULTREAD_DELAY) { setContinue(true); return; } + m_delay = 0; // set appropriate header MEPHeader::FieldsType hdr; @@ -92,23 +99,25 @@ GCFEvent::TResult RCUResultRead::handleack(GCFEvent& event, GCFPortInterface& /* EPARcuResultEvent ack(event); + uint8 global_rcu = (getBoardId() * StationSettings::instance()->nrBlpsPerBoard() * MEPHeader::N_POL) + getCurrentIndex(); + if (!ack.hdr.isValidAck(m_hdr)) { LOG_ERROR("RCUResultRead::handleack: invalid ack"); - return GCFEvent::NOT_HANDLED; + Cache::getInstance().getState().rcuprotocol().read_error(global_rcu); + return GCFEvent::HANDLED; } - uint8 global_rcu = (getBoardId() * StationSettings::instance()->nrBlpsPerBoard() * MEPHeader::N_POL) + getCurrentIndex(); - // reverse and copy control bytes into i2c_result RCUSettings::Control& rcucontrol = Cache::getInstance().getBack().getRCUSettings()()((global_rcu)); uint32 control = htonl(rcucontrol.getRaw()); memcpy(RCUProtocolWrite::i2c_result + 1, &control, 3); if (0 == memcmp(RCUProtocolWrite::i2c_result, ack.result, sizeof(RCUProtocolWrite::i2c_result))) { - Cache::getInstance().getState().rcuprotocol().confirmed(global_rcu); + Cache::getInstance().getState().rcuprotocol().read_ack(global_rcu); } else { - LOG_ERROR("RCUResultRead::handleack: unexpected I2C result response"); + LOG_WARN("RCUResultRead::handleack: unexpected I2C result response"); + Cache::getInstance().getState().rcuprotocol().read_error(global_rcu); } return GCFEvent::HANDLED; diff --git a/MAC/APL/PIC/RSPDriver/src/RCUResultRead.h b/MAC/APL/PIC/RSPDriver/src/RCUResultRead.h index 52ed9ebf25f..98cc3e888d5 100644 --- a/MAC/APL/PIC/RSPDriver/src/RCUResultRead.h +++ b/MAC/APL/PIC/RSPDriver/src/RCUResultRead.h @@ -60,6 +60,7 @@ namespace LOFAR { private: EPA_Protocol::MEPHeader m_hdr; + int m_delay; // used to delay reading back results }; }; }; diff --git a/MAC/APL/PIC/RSPDriver/src/RCUWrite.cc b/MAC/APL/PIC/RSPDriver/src/RCUWrite.cc index f190ba21d03..fab2b40895d 100644 --- a/MAC/APL/PIC/RSPDriver/src/RCUWrite.cc +++ b/MAC/APL/PIC/RSPDriver/src/RCUWrite.cc @@ -51,8 +51,10 @@ void RCUWrite::sendrequest() uint8 global_blp = (getBoardId() * StationSettings::instance()->nrBlpsPerBoard()) + getCurrentIndex(); // skip update if the neither of the RCU's settings have been modified - if (RTC::RegisterState::MODIFIED != Cache::getInstance().getState().rcusettings().get(global_blp * 2) - && RTC::RegisterState::MODIFIED != Cache::getInstance().getState().rcusettings().get(global_blp * 2 + 1)) { + if (RTC::RegisterState::WRITE != Cache::getInstance().getState().rcusettings().get(global_blp * 2) + && RTC::RegisterState::WRITE != Cache::getInstance().getState().rcusettings().get(global_blp * 2 + 1)) { + Cache::getInstance().getState().rcusettings().unmodified(global_blp * 2); + Cache::getInstance().getState().rcusettings().unmodified(global_blp * 2 + 1); setContinue(true); return; } @@ -89,16 +91,18 @@ GCFEvent::TResult RCUWrite::handleack(GCFEvent& event, GCFPortInterface& /*port* EPAWriteackEvent ack(event); + uint8 global_blp = (getBoardId() * StationSettings::instance()->nrBlpsPerBoard()) + getCurrentIndex(); + if (!ack.hdr.isValidAck(m_hdr)) { LOG_ERROR("RCUWrite::handleack: invalid ack"); + Cache::getInstance().getState().rcusettings().write_error(global_blp * 2); + Cache::getInstance().getState().rcusettings().write_error(global_blp * 2 + 1); return GCFEvent::NOT_HANDLED; } - uint8 global_blp = (getBoardId() * StationSettings::instance()->nrBlpsPerBoard()) + getCurrentIndex(); - - Cache::getInstance().getState().rcusettings().confirmed(global_blp * 2); - Cache::getInstance().getState().rcusettings().confirmed(global_blp * 2 + 1); + Cache::getInstance().getState().rcusettings().write_ack(global_blp * 2); + Cache::getInstance().getState().rcusettings().write_ack(global_blp * 2 + 1); return GCFEvent::HANDLED; } diff --git a/MAC/APL/PIC/RSPDriver/src/RSPDriver.cc b/MAC/APL/PIC/RSPDriver/src/RSPDriver.cc index c77e964690c..8f315690ecf 100644 --- a/MAC/APL/PIC/RSPDriver/src/RSPDriver.cc +++ b/MAC/APL/PIC/RSPDriver/src/RSPDriver.cc @@ -65,6 +65,8 @@ #include "SetClocksCmd.h" #include "GetClocksCmd.h" #include "UpdClocksCmd.h" +#include "GetRegisterStateCmd.h" +#include "UpdRegisterStateCmd.h" #include "RSUWrite.h" #include "BSWrite.h" @@ -364,6 +366,7 @@ void RSPDriver::addAllSyncActions() } } + // order is important; TDSProtocolWrite should be added before TDSResultRead if (1 == GET_CONFIG("RSPDriver.WRITE_TDS_PROTOCOL", i)) { TDSProtocolWrite* tdsprotocolwrite = new TDSProtocolWrite(m_board[boardid], boardid); @@ -572,6 +575,7 @@ void RSPDriver::addAllSyncActions() } } + // order is important; RCUProtocolWrite should go before RCUResultRead if (1 == GET_CONFIG("RSPDriver.WRITE_RCU_PROTOCOL", i)) { RCUProtocolWrite* rcuprotocolwrite = new RCUProtocolWrite(m_board[boardid], boardid); @@ -967,6 +971,18 @@ GCFEvent::TResult RSPDriver::enabled(GCFEvent& event, GCFPortInterface& port) case RSP_UNSUBCLOCK: rsp_unsubclock(event, port); break; + + case RSP_GETREGISTERSTATE: + rsp_getregisterstate(event, port); + break; + + case RSP_SUBREGISTERSTATE: + rsp_subregisterstate(event, port); + break; + + case RSP_UNSUBREGISTERSTATE: + rsp_unsubregisterstate(event, port); + break; case F_TIMER: { @@ -2014,6 +2030,93 @@ void RSPDriver::rsp_unsubclock(GCFEvent& event, GCFPortInterface& port) port.send(ack); } +// +// rsp_getregisterstate (event, port) +// +void RSPDriver::rsp_getregisterstate(GCFEvent& event, GCFPortInterface& port) +{ + Ptr<GetRegisterStateCmd> command = new GetRegisterStateCmd(event, port, Command::READ); + + if (!command->validate()) + { + LOG_ERROR("GETREGISTERSTATE: invalid parameter"); + + RSPGetregisterstateackEvent ack; + ack.timestamp = Timestamp(0,0); + ack.status = FAILURE; + port.send(ack); + return; + } + + // if null timestamp get value from the cache and acknowledge immediately + if ( (Timestamp(0,0) == command->getTimestamp()) + && (true == command->readFromCache())) + { + command->setTimestamp(Cache::getInstance().getFront().getTimestamp()); + command->ack(Cache::getInstance().getFront()); + } + else + { + (void)m_scheduler.enter(Ptr<Command>(&(*command))); + } +} + +// +// rsp_subregisterstate (event, port) +// +void RSPDriver::rsp_subregisterstate(GCFEvent& event, GCFPortInterface& port) +{ + Ptr<UpdRegisterStateCmd> command = new UpdRegisterStateCmd(event, port, Command::READ); + + RSPSubregisterstateackEvent ack; + + if (!command->validate()) + { + LOG_ERROR("SUBREGISTERSTATE: invalid parameter"); + + ack.timestamp = m_scheduler.getCurrentTime(); + ack.status = FAILURE; + ack.handle = 0; + + port.send(ack); + return; + } + else + { + ack.timestamp = m_scheduler.getCurrentTime(); + ack.status = SUCCESS; + ack.handle = (uint32)&(*command); + port.send(ack); + } + + (void)m_scheduler.enter(Ptr<Command>(&(*command)), + Scheduler::PERIODIC); +} + +// +// rsp_unsubregisterstate (event, port) +// +void RSPDriver::rsp_unsubregisterstate(GCFEvent& event, GCFPortInterface& port) +{ + RSPUnsubregisterstateEvent unsub(event); + + RSPUnsubregisterstateackEvent ack; + ack.timestamp = m_scheduler.getCurrentTime(); + ack.status = FAILURE; + ack.handle = unsub.handle; + + if (m_scheduler.remove_subscription(port, unsub.handle) > 0) + { + ack.status = SUCCESS; + } + else + { + LOG_ERROR("UNSUBREGISTERSTATE: failed to remove subscription"); + } + + port.send(ack); +} + // // main (argc, argv) // diff --git a/MAC/APL/PIC/RSPDriver/src/RSPDriver.conf.in b/MAC/APL/PIC/RSPDriver/src/RSPDriver.conf.in index c26746745a9..d21a1c4980f 100644 --- a/MAC/APL/PIC/RSPDriver/src/RSPDriver.conf.in +++ b/MAC/APL/PIC/RSPDriver/src/RSPDriver.conf.in @@ -41,7 +41,7 @@ RSPDriver.SOFTPPS=0 # #RSPDriver.MAC_ADDR_0=00:00:00:00:00:08 # lofar27:eth2:00:50:04:32:B8:5C -#RSPDriver.MAC_ADDR_0=00:50:04:32:B8:5C +#RSPDriver.MAC_ADDR_0=00:30:48:2D:82:F6 RSPDriver.MAC_ADDR_0=10:FA:00:00:13:00 RSPDriver.MAC_ADDR_1=10:FA:00:00:12:00 RSPDriver.MAC_ADDR_2=00:00:00:00:00:03 diff --git a/MAC/APL/PIC/RSPDriver/src/RSPDriver.h b/MAC/APL/PIC/RSPDriver/src/RSPDriver.h index 5eeee6466fe..6199db4461e 100644 --- a/MAC/APL/PIC/RSPDriver/src/RSPDriver.h +++ b/MAC/APL/PIC/RSPDriver/src/RSPDriver.h @@ -142,10 +142,15 @@ namespace LOFAR { void rsp_getversions(GCFEvent& event, GCFPortInterface &port); void rsp_getconfig(GCFEvent& event, GCFPortInterface &port); + void rsp_setclock(GCFEvent& event, GCFPortInterface &port); void rsp_getclock(GCFEvent& event, GCFPortInterface &port); void rsp_subclock(GCFEvent& event, GCFPortInterface &port); void rsp_unsubclock(GCFEvent& event, GCFPortInterface &port); + + void rsp_getregisterstate(GCFEvent& event, GCFPortInterface &port); + void rsp_subregisterstate(GCFEvent& event, GCFPortInterface &port); + void rsp_unsubregisterstate(GCFEvent& event, GCFPortInterface &port); /*@}*/ private: diff --git a/MAC/APL/PIC/RSPDriver/src/RSUWrite.cc b/MAC/APL/PIC/RSPDriver/src/RSUWrite.cc index d4f7bf63f9d..872ff3ea0de 100644 --- a/MAC/APL/PIC/RSPDriver/src/RSUWrite.cc +++ b/MAC/APL/PIC/RSPDriver/src/RSUWrite.cc @@ -62,7 +62,8 @@ void RSUWrite::sendrequest() reset.hdr.set(MEPHeader::RSU_RESET_HDR); // cache modified? - if (RTC::RegisterState::MODIFIED != Cache::getInstance().getState().rsuclear().get(getBoardId())) { + if (RTC::RegisterState::WRITE != Cache::getInstance().getState().rsuclear().get(getBoardId())) { + Cache::getInstance().getState().rsuclear().unmodified(getBoardId()); setContinue(true); return; } @@ -99,10 +100,13 @@ GCFEvent::TResult RSUWrite::handleack(GCFEvent& event, GCFPortInterface& /*port* if (!ack.hdr.isValidAck(m_hdr)) { LOG_ERROR("RSUWrite::handleack: invalid ack"); + Cache::getInstance().getState().rsuclear().write_error(getBoardId()); return GCFEvent::NOT_HANDLED; } - Cache::getInstance().getState().rsuclear().confirmed(getBoardId()); + Cache::getInstance().getState().rsuclear().write_ack(getBoardId()); + + Cache::getInstance().getState().force(); // force read/write of all register after clear return GCFEvent::HANDLED; } diff --git a/MAC/APL/PIC/RSPDriver/src/SSRead.cc b/MAC/APL/PIC/RSPDriver/src/SSRead.cc index 9fcb60b969f..79d2641221e 100644 --- a/MAC/APL/PIC/RSPDriver/src/SSRead.cc +++ b/MAC/APL/PIC/RSPDriver/src/SSRead.cc @@ -49,9 +49,6 @@ SSRead::~SSRead() void SSRead::sendrequest() { - uint8 global_blp = (getBoardId() * StationSettings::instance()->nrBlpsPerBoard()) + getCurrentIndex(); - Cache::getInstance().getState().ss().modified(global_blp); - EPAReadEvent ssread; ssread.hdr.set(MEPHeader::SS_SELECT_HDR, 1 << getCurrentIndex(), MEPHeader::READ); @@ -79,7 +76,7 @@ GCFEvent::TResult SSRead::handleack(GCFEvent& event, GCFPortInterface& /*port*/) uint8 global_blp = (getBoardId() * StationSettings::instance()->nrBlpsPerBoard()) + getCurrentIndex(); if (!ss.hdr.isValidAck(m_hdr)) { - Cache::getInstance().getState().ss().applied(global_blp); + Cache::getInstance().getState().ss().read_error(global_blp); LOG_ERROR("SSRead::handleack: invalid ack"); return GCFEvent::NOT_HANDLED; } @@ -115,7 +112,7 @@ GCFEvent::TResult SSRead::handleack(GCFEvent& event, GCFPortInterface& /*port*/) = subbands(Range::all(), 1); // y } - Cache::getInstance().getState().ss().confirmed(global_blp); + Cache::getInstance().getState().ss().read_ack(global_blp); return GCFEvent::HANDLED; } diff --git a/MAC/APL/PIC/RSPDriver/src/SSWrite.cc b/MAC/APL/PIC/RSPDriver/src/SSWrite.cc index 7ecdf28fbbf..4691d537802 100644 --- a/MAC/APL/PIC/RSPDriver/src/SSWrite.cc +++ b/MAC/APL/PIC/RSPDriver/src/SSWrite.cc @@ -58,7 +58,7 @@ void SSWrite::sendrequest() global_blp)); // mark modified - Cache::getInstance().getState().ss().modified(global_blp); + //Cache::getInstance().getState().ss().write_now(global_blp); // send subband select message EPASsSelectEvent ss; @@ -96,13 +96,13 @@ GCFEvent::TResult SSWrite::handleack(GCFEvent& event, GCFPortInterface& /*port*/ if (!ack.hdr.isValidAck(m_hdr)) { - Cache::getInstance().getState().ss().applied(global_blp); + Cache::getInstance().getState().ss().write_error(global_blp); LOG_ERROR("SSWrite::handleack: invalid ack"); return GCFEvent::NOT_HANDLED; } - Cache::getInstance().getState().ss().confirmed(global_blp); + Cache::getInstance().getState().ss().write_ack(global_blp); return GCFEvent::HANDLED; } diff --git a/MAC/APL/PIC/RSPDriver/src/Scheduler.cc b/MAC/APL/PIC/RSPDriver/src/Scheduler.cc index d10c512b94e..a101bd9eabc 100644 --- a/MAC/APL/PIC/RSPDriver/src/Scheduler.cc +++ b/MAC/APL/PIC/RSPDriver/src/Scheduler.cc @@ -451,6 +451,9 @@ void Scheduler::resetSync(GCFPortInterface& port) void Scheduler::completeSync() { + // print current state for all registers + Cache::getInstance().getState().print(cout); + // swap the buffers // new data from the boards which was in the back buffers // will end up in the front buffers. @@ -458,6 +461,12 @@ void Scheduler::completeSync() // complete any outstanding commands completeCommands(); + + // clear from DONE to IDLE state + Cache::getInstance().getState().clear(); + + // schedule next update + Cache::getInstance().getState().schedule(); // if IDLE transition to READ or CHECK } void Scheduler::completeCommands() diff --git a/MAC/APL/PIC/RSPDriver/src/SetClocksCmd.cc b/MAC/APL/PIC/RSPDriver/src/SetClocksCmd.cc index e77ae13a5ca..e45cf1ecf23 100644 --- a/MAC/APL/PIC/RSPDriver/src/SetClocksCmd.cc +++ b/MAC/APL/PIC/RSPDriver/src/SetClocksCmd.cc @@ -64,9 +64,9 @@ void SetClocksCmd::apply(CacheBuffer& cache, bool setModFlag) { cache.getClock() = m_event->clock; if (setModFlag) { - cache.getCache().getState().bs().modified(); + cache.getCache().getState().bs().write(); } - cache.getCache().getState().tds().modified(); + cache.getCache().getState().tds().write(); } void SetClocksCmd::complete(CacheBuffer& /*cache*/) diff --git a/MAC/APL/PIC/RSPDriver/src/SetRCUCmd.cc b/MAC/APL/PIC/RSPDriver/src/SetRCUCmd.cc index 82dc5b77f45..127e1f767b0 100644 --- a/MAC/APL/PIC/RSPDriver/src/SetRCUCmd.cc +++ b/MAC/APL/PIC/RSPDriver/src/SetRCUCmd.cc @@ -70,10 +70,10 @@ void SetRCUCmd::apply(CacheBuffer& cache, bool setModFlag) cache.getRCUSettings()()(cache_rcu) = m_event->settings()(0); if (setModFlag) { // reset BS if needed - cache.getCache().getState().bs().modified(cache_rcu / MEPHeader::N_POL); + cache.getCache().getState().bs().write(cache_rcu / MEPHeader::N_POL); - cache.getCache().getState().rcusettings().modified(cache_rcu); - cache.getCache().getState().rcuprotocol().modified(cache_rcu); + cache.getCache().getState().rcusettings().write(cache_rcu); + cache.getCache().getState().rcuprotocol().write(cache_rcu); } } } diff --git a/MAC/APL/PIC/RSPDriver/src/SetRSUCmd.cc b/MAC/APL/PIC/RSPDriver/src/SetRSUCmd.cc index 3e9b52416af..ba65a79f13f 100644 --- a/MAC/APL/PIC/RSPDriver/src/SetRSUCmd.cc +++ b/MAC/APL/PIC/RSPDriver/src/SetRSUCmd.cc @@ -70,7 +70,7 @@ void SetRSUCmd::apply(CacheBuffer& cache, bool setModFlag) cache.getRSUSettings()()(cache_rsp) = m_event->settings()(0); if (setModFlag) { - cache.getCache().getState().rsuclear().modified(cache_rsp); + cache.getCache().getState().rsuclear().write(cache_rsp); } } } diff --git a/MAC/APL/PIC/RSPDriver/src/SetWGCmd.cc b/MAC/APL/PIC/RSPDriver/src/SetWGCmd.cc index 0ca8016eccc..6f1bacb99d8 100644 --- a/MAC/APL/PIC/RSPDriver/src/SetWGCmd.cc +++ b/MAC/APL/PIC/RSPDriver/src/SetWGCmd.cc @@ -69,9 +69,9 @@ void SetWGCmd::apply(CacheBuffer& cache, bool setModFlag) if (setModFlag) { // reset BS if needed - cache.getCache().getState().bs().modified(cache_rcu / MEPHeader::N_POL); + cache.getCache().getState().bs().write(cache_rcu / MEPHeader::N_POL); - cache.getCache().getState().diagwgsettings().modified(cache_rcu); + cache.getCache().getState().diagwgsettings().write(cache_rcu); } } } diff --git a/MAC/APL/PIC/RSPDriver/src/SetWeightsCmd.cc b/MAC/APL/PIC/RSPDriver/src/SetWeightsCmd.cc index 6525d0ac188..694f0aa2ba7 100644 --- a/MAC/APL/PIC/RSPDriver/src/SetWeightsCmd.cc +++ b/MAC/APL/PIC/RSPDriver/src/SetWeightsCmd.cc @@ -90,8 +90,8 @@ void SetWeightsCmd::apply(CacheBuffer& cache, bool setModFlag) m_event->weights()(0, input_rcu, Range::all()); if (setModFlag) { - cache.getCache().getState().bf().modified(cache_rcu * MEPHeader::N_PHASE); - cache.getCache().getState().bf().modified(cache_rcu * MEPHeader::N_PHASE + 1); + cache.getCache().getState().bf().write(cache_rcu * MEPHeader::N_PHASE); + cache.getCache().getState().bf().write(cache_rcu * MEPHeader::N_PHASE + 1); } input_rcu++; diff --git a/MAC/APL/PIC/RSPDriver/src/SstRead.cc b/MAC/APL/PIC/RSPDriver/src/SstRead.cc index 6b2483e71ec..237cf95afa4 100644 --- a/MAC/APL/PIC/RSPDriver/src/SstRead.cc +++ b/MAC/APL/PIC/RSPDriver/src/SstRead.cc @@ -54,7 +54,7 @@ void SstRead::sendrequest() EPAReadEvent sstread; uint8 global_blp = (getBoardId() * StationSettings::instance()->nrBlpsPerBoard()) + (getCurrentIndex() / SST_N_FRAGMENTS); - Cache::getInstance().getState().sst().modified(global_blp); + Cache::getInstance().getState().sst().read(global_blp); uint16 byteoffset = (getCurrentIndex() % SST_N_FRAGMENTS) * MEPHeader::FRAGMENT_SIZE; @@ -107,7 +107,7 @@ GCFEvent::TResult SstRead::handleack(GCFEvent& event, GCFPortInterface& /*port*/ if (!ack.hdr.isValidAck(m_hdr)) { - Cache::getInstance().getState().sst().applied(global_blp); + Cache::getInstance().getState().sst().read_error(global_blp); LOG_ERROR("SstRead::handleack: invalid ack"); return GCFEvent::NOT_HANDLED; } @@ -124,7 +124,7 @@ GCFEvent::TResult SstRead::handleack(GCFEvent& event, GCFPortInterface& /*port*/ if (MEPHeader::SST_POWER != ack.hdr.m_fields.addr.regid) { - Cache::getInstance().getState().sst().applied(global_blp); + Cache::getInstance().getState().sst().read_error(global_blp); LOG_ERROR("invalid sst ack"); return GCFEvent::HANDLED; } @@ -142,7 +142,7 @@ GCFEvent::TResult SstRead::handleack(GCFEvent& event, GCFPortInterface& /*port*/ // y-pol subband statistics: copy and convert to double cache(global_blp * 2 + 1, fragment_range) = convert_uint32_to_double(stats(Range::all(), 1)); - Cache::getInstance().getState().sst().confirmed(global_blp); + Cache::getInstance().getState().sst().read_ack(global_blp); return GCFEvent::HANDLED; } diff --git a/MAC/APL/PIC/RSPDriver/src/StatusRead.cc b/MAC/APL/PIC/RSPDriver/src/StatusRead.cc index 4b7916443f6..00cdc3510d9 100644 --- a/MAC/APL/PIC/RSPDriver/src/StatusRead.cc +++ b/MAC/APL/PIC/RSPDriver/src/StatusRead.cc @@ -51,7 +51,7 @@ StatusRead::~StatusRead() void StatusRead::sendrequest() { - Cache::getInstance().getState().sys().modified(getBoardId()); + Cache::getInstance().getState().sys().read(getBoardId()); // send read status request to check status of the write EPAReadEvent rspstatus; @@ -78,7 +78,7 @@ GCFEvent::TResult StatusRead::handleack(GCFEvent& event, GCFPortInterface& /*por if (!ack.hdr.isValidAck(m_hdr)) { - Cache::getInstance().getState().sys().applied(getBoardId()); + Cache::getInstance().getState().sys().read_error(getBoardId()); LOG_ERROR("StatusRead::handleack: invalid ack"); return GCFEvent::NOT_HANDLED; } @@ -110,7 +110,7 @@ GCFEvent::TResult StatusRead::handleack(GCFEvent& event, GCFPortInterface& /*por LOG_WARN(formatString("RSP[%02d]: slice_count mismatch", getBoardId())); } - Cache::getInstance().getState().sys().confirmed(getBoardId()); + Cache::getInstance().getState().sys().read_ack(getBoardId()); return GCFEvent::HANDLED; } diff --git a/MAC/APL/PIC/RSPDriver/src/TDSProtocolWrite.cc b/MAC/APL/PIC/RSPDriver/src/TDSProtocolWrite.cc index c6ed5bd8928..97d4317ee90 100644 --- a/MAC/APL/PIC/RSPDriver/src/TDSProtocolWrite.cc +++ b/MAC/APL/PIC/RSPDriver/src/TDSProtocolWrite.cc @@ -145,8 +145,9 @@ void TDSProtocolWrite::sendrequest() void* buf = 0; // skip update if the Clocks settings have not been modified - if (RTC::RegisterState::MODIFIED != Cache::getInstance().getState().tds().get(getBoardId())) + if (RTC::RegisterState::WRITE != Cache::getInstance().getState().tds().get(getBoardId())) { + Cache::getInstance().getState().tds().unmodified(getBoardId()); setContinue(true); return; } @@ -215,13 +216,14 @@ GCFEvent::TResult TDSProtocolWrite::handleack(GCFEvent& event, GCFPortInterface& if (!ack.hdr.isValidAck(m_hdr)) { LOG_ERROR("TDSProtocolWrite::handleack: invalid ack"); + Cache::getInstance().getState().tds().write_error(getBoardId()); return GCFEvent::NOT_HANDLED; } // Mark register modification as applied // Still needs to be confirmed by TDSRegisterRead if (0 == m_remaining) { - Cache::getInstance().getState().tds().applied(getBoardId()); + Cache::getInstance().getState().tds().schedule_read(getBoardId()); } return GCFEvent::HANDLED; diff --git a/MAC/APL/PIC/RSPDriver/src/TDSResultRead.cc b/MAC/APL/PIC/RSPDriver/src/TDSResultRead.cc index 316ed51caec..310bfb9b71c 100644 --- a/MAC/APL/PIC/RSPDriver/src/TDSResultRead.cc +++ b/MAC/APL/PIC/RSPDriver/src/TDSResultRead.cc @@ -53,7 +53,7 @@ TDSResultRead::~TDSResultRead() void TDSResultRead::sendrequest() { // skip update if the Clocks settings have not been modified - if (RTC::RegisterState::APPLIED != Cache::getInstance().getState().tds().get(getBoardId())) + if (RTC::RegisterState::READ != Cache::getInstance().getState().tds().get(getBoardId())) { setContinue(true); return; @@ -133,9 +133,12 @@ GCFEvent::TResult TDSResultRead::handleack(GCFEvent& event, GCFPortInterface& /* printbin(ack.result, sizeof(tds_160MHz_result)); idiff = imemcmp(tds_160MHz_result, ack.result, sizeof(tds_160MHz_result)); if (-1 == idiff) { - Cache::getInstance().getState().tds().confirmed(getBoardId()); + Cache::getInstance().getState().tds().read_ack(getBoardId()); } else { LOG_ERROR(formatString("TDSResultRead::handleack (160MHz): unexpected I2C result response, first mismatch @ %d", idiff)); + + // try to write again + Cache::getInstance().getState().tds().read_error(getBoardId()); } break; @@ -144,9 +147,12 @@ GCFEvent::TResult TDSResultRead::handleack(GCFEvent& event, GCFPortInterface& /* printbin(ack.result, sizeof(tds_200MHz_result)); idiff = imemcmp(tds_200MHz_result, ack.result, sizeof(tds_200MHz_result)); if (-1 == idiff) { - Cache::getInstance().getState().tds().confirmed(getBoardId()); + Cache::getInstance().getState().tds().read_ack(getBoardId()); } else { LOG_ERROR(formatString("TDSResultRead::handleack (200MHz): unexpected I2C result response, first mismatch @ %d", idiff)); + + // try to write again + Cache::getInstance().getState().tds().read_error(getBoardId()); } break; @@ -155,9 +161,12 @@ GCFEvent::TResult TDSResultRead::handleack(GCFEvent& event, GCFPortInterface& /* printbin(ack.result, sizeof(tds_off_result)); idiff = imemcmp(tds_off_result, ack.result, sizeof(tds_off_result)); if (-1 == idiff) { - Cache::getInstance().getState().tds().confirmed(getBoardId()); + Cache::getInstance().getState().tds().read_ack(getBoardId()); } else { LOG_ERROR(formatString("TDSResultRead::handleack (OFF): unexpected I2C result response, first mismatch @ %d", idiff)); + + // try to write again + Cache::getInstance().getState().tds().read_error(getBoardId()); } break; } diff --git a/MAC/APL/PIC/RSPDriver/src/UpdClocksCmd.cc b/MAC/APL/PIC/RSPDriver/src/UpdClocksCmd.cc index 93f87ca31bd..cd4c713779d 100644 --- a/MAC/APL/PIC/RSPDriver/src/UpdClocksCmd.cc +++ b/MAC/APL/PIC/RSPDriver/src/UpdClocksCmd.cc @@ -73,7 +73,7 @@ void UpdClocksCmd::complete(CacheBuffer& cache) // only send ack if clock setting has been applied to all boards bool sendack = true; for (int cache_rsp = 0; cache_rsp < StationSettings::instance()->nrRspBoards(); cache_rsp++) { - if (RTC::RegisterState::APPLIED != cache.getCache().getState().tds().get(cache_rsp)) { + if (RTC::RegisterState::DONE != cache.getCache().getState().tds().get(cache_rsp)) { sendack = false; } } diff --git a/MAC/APL/PIC/RSPDriver/src/UpdRegisterStateCmd.cc b/MAC/APL/PIC/RSPDriver/src/UpdRegisterStateCmd.cc new file mode 100644 index 00000000000..109fca9897f --- /dev/null +++ b/MAC/APL/PIC/RSPDriver/src/UpdRegisterStateCmd.cc @@ -0,0 +1,89 @@ +//# UpdRegisterStateCmd.cc: implementation of the UpdRegisterStateCmd class +//# +//# 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 <APL/RSP_Protocol/RSP_Protocol.ph> +#include <APL/RTCCommon/PSAccess.h> +#include <blitz/array.h> + +#include "StationSettings.h" +#include "UpdRegisterStateCmd.h" + +using namespace blitz; +using namespace LOFAR; +using namespace RSP; +using namespace RSP_Protocol; +using namespace RTC; + +UpdRegisterStateCmd::UpdRegisterStateCmd(GCFEvent& event, GCFPortInterface& port, Operation oper) +{ + m_event = new RSPSubclockEvent(event); + + setOperation(oper); + setPeriod(m_event->period); + setPort(port); +} + +UpdRegisterStateCmd::~UpdRegisterStateCmd() +{ + delete m_event; +} + +void UpdRegisterStateCmd::ack(CacheBuffer& /*cache*/) +{ + // intentionally left empty +} + +void UpdRegisterStateCmd::apply(CacheBuffer& /*cache*/, bool /*setModFlag*/) +{ + // no-op +} + +void UpdRegisterStateCmd::complete(CacheBuffer& cache) +{ + RSPUpdregisterstateEvent ack; + + ack.timestamp = getTimestamp(); + ack.status = SUCCESS; + ack.handle = (uint32)this; // opaque pointer used to refer to the subscription + + ack.state = cache.getCache().getState(); + + getPort()->send(ack); +} + +const Timestamp& UpdRegisterStateCmd::getTimestamp() const +{ + return m_event->timestamp; +} + +void UpdRegisterStateCmd::setTimestamp(const Timestamp& timestamp) +{ + m_event->timestamp = timestamp; +} + +bool UpdRegisterStateCmd::validate() const +{ + return (true); +} diff --git a/MAC/APL/PIC/RSPDriver/src/UpdRegisterStateCmd.h b/MAC/APL/PIC/RSPDriver/src/UpdRegisterStateCmd.h new file mode 100644 index 00000000000..0193e38598e --- /dev/null +++ b/MAC/APL/PIC/RSPDriver/src/UpdRegisterStateCmd.h @@ -0,0 +1,86 @@ +//# -*- mode: c++ -*- +//# +//# UpdRegisterStateCmd.h: Get communication status of all registers +//# +//# 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$ + +#ifndef UPDREGISTERSTATECMD_H_ +#define UPDREGISTERSTATECMD_H_ + +#include "Command.h" +#include <APL/RSP_Protocol/RSP_Protocol.ph> + +#include <Common/LofarTypes.h> +#include <GCF/TM/GCF_Control.h> + +namespace LOFAR { + namespace RSP { + + class UpdRegisterStateCmd : public Command + { + public: + /** + * Constructors for a UpdRegisterStateCmd object. + */ + UpdRegisterStateCmd(GCFEvent& event, GCFPortInterface& port, Operation oper); + + /* Destructor for UpdRegisterStateCmd. */ + virtual ~UpdRegisterStateCmd(); + + /** + * Acknowledge the command by sending the appropriate + * response on m_port. + */ + virtual void ack(CacheBuffer& cache); + + /** + * Make necessary changes to the cache for the next synchronization. + * Any changes will be sent to the RSP boards. + */ + virtual void apply(CacheBuffer& cache, bool setModFlag = true); + + /** + * Complete the command by sending the appropriate response on + * the m_answerport; + */ + virtual void complete(CacheBuffer& cache); + + /*@{*/ + /** + * get timestamp of the event + */ + virtual const RTC::Timestamp& getTimestamp() const; + virtual void setTimestamp(const RTC::Timestamp& timestamp); + /*@}*/ + + /** + * Range check the parameters of the event. + */ + virtual bool validate() const; + + private: + UpdRegisterStateCmd(); + RSPSubclockEvent* m_event; + }; + }; +}; + +#endif /* UPDREGISTERSTATECMD_H_ */ diff --git a/MAC/APL/PIC/RSPDriver/src/WGWrite.cc b/MAC/APL/PIC/RSPDriver/src/WGWrite.cc index aeef57eada1..cdfd48bc443 100644 --- a/MAC/APL/PIC/RSPDriver/src/WGWrite.cc +++ b/MAC/APL/PIC/RSPDriver/src/WGWrite.cc @@ -55,7 +55,8 @@ void WGWrite::sendrequest() { uint8 global_rcu = (getBoardId() * StationSettings::instance()->nrBlpsPerBoard() * MEPHeader::N_POL) + (getCurrentIndex() / N_REGISTERS); - if (RTC::RegisterState::MODIFIED != Cache::getInstance().getState().diagwgsettings().get(global_rcu)) { + if (RTC::RegisterState::WRITE != Cache::getInstance().getState().diagwgsettings().get(global_rcu)) { + Cache::getInstance().getState().diagwgsettings().unmodified(global_rcu); setContinue(true); return; } @@ -141,11 +142,12 @@ GCFEvent::TResult WGWrite::handleack(GCFEvent& event, GCFPortInterface& /*port*/ if (!ack.hdr.isValidAck(m_hdr)) { LOG_ERROR("WGWrite::handleack: invalid ack"); + Cache::getInstance().getState().diagwgsettings().write_error(getCurrentIndex() / N_REGISTERS); return GCFEvent::NOT_HANDLED; } // change state to indicate that it has been applied in the hardware - Cache::getInstance().getState().diagwgsettings().confirmed(getCurrentIndex() / N_REGISTERS); + Cache::getInstance().getState().diagwgsettings().write_ack(getCurrentIndex() / N_REGISTERS); return GCFEvent::HANDLED; } diff --git a/MAC/APL/PIC/RSPDriver/src/XstRead.cc b/MAC/APL/PIC/RSPDriver/src/XstRead.cc index 35f28c74992..3968175fd49 100644 --- a/MAC/APL/PIC/RSPDriver/src/XstRead.cc +++ b/MAC/APL/PIC/RSPDriver/src/XstRead.cc @@ -60,7 +60,7 @@ void XstRead::sendrequest() // uint16 offset = GET_CONFIG("RSPDriver.XST_FIRST_RSP_BOARD", i) * MEPHeader::XLET_SIZE; - Cache::getInstance().getState().xst().modified(getBoardId()); + Cache::getInstance().getState().xst().read(getBoardId()); if (m_regid < MEPHeader::XST_STATS || m_regid >= MEPHeader::XST_NR_STATS) { @@ -155,14 +155,14 @@ GCFEvent::TResult XstRead::handleack(GCFEvent& event, GCFPortInterface& /*port*/ if (!ack.hdr.isValidAck(m_hdr)) { - Cache::getInstance().getState().xst().applied(getBoardId()); + Cache::getInstance().getState().xst().read_error(getBoardId()); LOG_ERROR("XstRead::handleack: invalid ack"); return GCFEvent::NOT_HANDLED; } if (ack.hdr.m_fields.addr.regid >= MEPHeader::XST_NR_STATS) { - Cache::getInstance().getState().xst().applied(getBoardId()); + Cache::getInstance().getState().xst().read_error(getBoardId()); LOG_ERROR("invalid xst ack"); return GCFEvent::HANDLED; } @@ -193,7 +193,7 @@ GCFEvent::TResult XstRead::handleack(GCFEvent& event, GCFPortInterface& /*port*/ cache(rcu % MEPHeader::N_POL, 0, rcu / MEPHeader::N_POL, dst_range) = convert_cuint32_to_cdouble(xststats(Range::all(), 0)); cache(rcu % MEPHeader::N_POL, 1, rcu / MEPHeader::N_POL, dst_range) = convert_cuint32_to_cdouble(xststats(Range::all(), 1)); - Cache::getInstance().getState().xst().confirmed(getBoardId()); + Cache::getInstance().getState().xst().read_ack(getBoardId()); return GCFEvent::HANDLED; } diff --git a/MAC/APL/PIC/RSPDriver/src/rspctl.cc b/MAC/APL/PIC/RSPDriver/src/rspctl.cc index ef60e59e0ed..4ff916032b2 100644 --- a/MAC/APL/PIC/RSPDriver/src/rspctl.cc +++ b/MAC/APL/PIC/RSPDriver/src/rspctl.cc @@ -52,6 +52,7 @@ //# rspctl --clocks [--select=<set>] # get or set the clock frequency of clocks //# rspctl --version [--select=<set>] # get version information //# rspctl --rspclear [--select=<set>] # clear FPGA registers on selected rspboards +//# rspctl --regstate # show update status of all registers once every second //# #include <lofar_config.h> @@ -100,46 +101,46 @@ static void usage(); * Function to convert the complex semi-floating point representation used by the * EPA firmware to a complex<double>. */ -BZ_DECLARE_FUNCTION_RET(convert_to_powerangle, complex<double>) -inline complex<double> convert_to_powerangle(complex<double> val) +BZ_DECLARE_FUNCTION_RET(convert_to_amplphase, complex<double>) +inline complex<double> convert_to_amplphase(complex<double> val) { - double angle = 0.0; - double power = real(val)*real(val) + imag(val)*imag(val); + double phase = 0.0; + double amplitude = real(val)*real(val) + imag(val)*imag(val); - if (power > 0.0) + if (amplitude > 0.0) { - power = 12 + 5*log10(power); // adjust scaling to allow comparison to subband statistics + amplitude = 12 + 5*log10(amplitude); // adjust scaling to allow comparison to subband statistics } if (0.0 == real(val)) { if (imag(val) > 0) - angle = 90.0; + phase = 90.0; else if (imag(val) < 0) - angle = 270; + phase = 270; } else { - angle = 45.0 * atan(imag(val)/real(val)) / atan(1.0); + phase = 45.0 * atan(imag(val)/real(val)) / atan(1.0); if (real(val) > 0.0) { if (imag(val) < 0) - angle += 360.0; + phase += 360.0; } else - angle += 180.0; + phase += 180.0; } - return complex<double>(power, angle); + return complex<double>(amplitude, phase); } -BZ_DECLARE_FUNCTION_RET(convert_to_powerangle_from_int16, complex<double>) -inline complex<double> convert_to_powerangle_from_int16(complex<int16> int16val) +BZ_DECLARE_FUNCTION_RET(convert_to_amplphase_from_int16, complex<double>) +inline complex<double> convert_to_amplphase_from_int16(complex<int16> int16val) { // scale and convert from int16 to double in range (-1,1] complex<double> cdval = complex<double>((double)real(int16val)/(1<<14), @@ -230,7 +231,7 @@ GCFEvent::TResult WeightsCommand::ack(GCFEvent& e) ackweights.resize(ack.weights().shape()); // convert to amplitude and angle - ackweights = convert_to_powerangle_from_int16(ack.weights()); + ackweights = convert_to_amplphase_from_int16(ack.weights()); int rcuin = 0; for (int rcuout = 0; rcuout < get_ndevices(); rcuout++) @@ -614,6 +615,76 @@ GCFEvent::TResult ClocksCommand::ack(GCFEvent& e) return GCFEvent::HANDLED; } +// +// RegisterStateCommand +// +RegisterStateCommand::RegisterStateCommand(GCFPortInterface& port) : + Command(port), m_subscriptionhandle(0) +{ +} + +void RegisterStateCommand::send() +{ + if (getMode()) + { + // GET == SUBSCRIBE + RSPSubregisterstateEvent subregstate; + + subregstate.timestamp = Timestamp(0,0); + subregstate.period = 1; // once every second + + m_rspport.send(subregstate); + } + else + { + // GET not supported + LOG_FATAL("RegisterStateCommand: GET not supported"); + exit(EXIT_FAILURE); + } +} + +GCFEvent::TResult RegisterStateCommand::ack(GCFEvent& e) +{ + if (RSP_SUBREGISTERSTATEACK == e.signal) + { + RSPSubregisterstateackEvent ack(e); + if (SUCCESS != ack.status) + { + logMessage(cerr,"Error: RSP_UPDREGISTERSTATE command failed."); + exit(EXIT_FAILURE); + } + } + + if (RSP_UPDREGISTERSTATE != e.signal) return GCFEvent::NOT_HANDLED; + + RSPUpdregisterstateEvent upd(e); + + if (SUCCESS == upd.status) + { + std::ostringstream logStream; + logStream << "registerstate update at " << upd.timestamp << endl; + upd.state.print(logStream); + logMessage(cout,logStream.str()); + } + else + { + logMessage(cerr, "Error: register state update failed."); + } + + return GCFEvent::HANDLED; +} + +void RegisterStateCommand::stop() +{ + if (getMode()) + { + // UNSUBSCRIBE + RSPUnsubregisterstateEvent unsubregstate; + unsubregstate.handle = m_subscriptionhandle; + m_rspport.send(unsubregstate); + } +} + WGCommand::WGCommand(GCFPortInterface& port) : Command(port), m_frequency(0.0), @@ -842,7 +913,7 @@ GCFEvent::TResult StatusCommand::ack(GCFEvent& event) } StatisticsBaseCommand::StatisticsBaseCommand(GCFPortInterface& port) : FECommand(port), - m_subscriptionHandle(0), + m_subscriptionhandle(0), m_duration(0), m_endTime(), m_integration(1), @@ -897,7 +968,7 @@ void StatisticsCommand::stop() { // UNSUBSCRIBE RSPUnsubstatsEvent unsubstats; - unsubstats.handle = m_subscriptionHandle; + unsubstats.handle = m_subscriptionhandle; m_rspport.send(unsubstats); } } @@ -1145,7 +1216,7 @@ void XCStatisticsCommand::stop() { // UNSUBSCRIBE RSPUnsubxcstatsEvent unsubxcstats; - unsubxcstats.handle = m_subscriptionHandle; + unsubxcstats.handle = m_subscriptionhandle; m_rspport.send(unsubxcstats); } } @@ -1185,7 +1256,7 @@ void XCStatisticsCommand::capture_xcstatistics(Array<complex<double>, 4>& stats, { blitz::Array<complex<double>, 4> pastats; pastats.resize(m_stats.shape()); - pastats = convert_to_powerangle(m_stats); + pastats = convert_to_amplphase(m_stats); for (int i = 0; i < pastats.extent(firstDim) * pastats.extent(thirdDim); i++) { @@ -1302,7 +1373,7 @@ GCFEvent::TResult XCStatisticsCommand::ack(GCFEvent& e) } else { - m_subscriptionHandle = ack.handle; + m_subscriptionhandle = ack.handle; } return GCFEvent::HANDLED; @@ -1539,6 +1610,8 @@ GCFEvent::TResult RSPCtl::docommand(GCFEvent& e, GCFPortInterface& port) case RSP_SETCLOCKACK: case RSP_GETCLOCKACK: case RSP_GETSTATUSACK: + case RSP_SUBREGISTERSTATEACK: + case RSP_UPDREGISTERSTATE: status = m_command->ack(e); // handle the acknowledgement break; @@ -1661,6 +1734,7 @@ static void usage() cout << "rspctl --clocks=<int> # get or set the clock frequency of clocks in Hz" << endl; cout << "rspctl --version [--select=<set>] # get version information" << endl; cout << "rspctl --rspclear [--select=<set>] # clear FPGA registers on RSPboard" << endl; + cout << "rspctl --regstate # show update status of all registers once every second" << endl; } Command* RSPCtl::parse_options(int argc, char** argv) @@ -1704,6 +1778,7 @@ Command* RSPCtl::parse_options(int argc, char** argv) { "version", no_argument, 0, 'v' }, // { "rspreset", optional_argument, 0, 'R' }, { "rspclear", optional_argument, 0, 'C' }, + { "regstate", no_argument, 0, 'S' }, { "help", no_argument, 0, 'h' }, #ifdef ENABLE_RSPFE { "feport", required_argument, 0, 'f' }, @@ -2096,6 +2171,14 @@ Command* RSPCtl::parse_options(int argc, char** argv) } break; + case 'S': // --regstate + { + if (command) delete command; + RegisterStateCommand* regstatecommand = new RegisterStateCommand(m_server); + command = regstatecommand; + } + break; + case 'v': // --version { if (command) diff --git a/MAC/APL/PIC/RSPDriver/src/rspctl.h b/MAC/APL/PIC/RSPDriver/src/rspctl.h index 1556a82ac2e..1f4befe433c 100644 --- a/MAC/APL/PIC/RSPDriver/src/rspctl.h +++ b/MAC/APL/PIC/RSPDriver/src/rspctl.h @@ -43,7 +43,7 @@ namespace LOFAR { namespace rspctl { // - // class Command :base class for control commands towards the RSPDriver. + // class Command :base class for control commands towards the RSPDriver. // class Command { public: @@ -184,9 +184,9 @@ namespace LOFAR { int m_ndevices; }; - // - // Class FECommand - // + // + // Class FECommand + // class FECommand : public Command { public: @@ -230,11 +230,11 @@ namespace LOFAR { virtual void logMessage(ostream& stream, const string& message) { if(m_feClient.isConnected()) - { - RSPFEStatusUpdateEvent statusUpdateEvent; - statusUpdateEvent.status = message; - m_feClient.send(statusUpdateEvent); - } + { + RSPFEStatusUpdateEvent statusUpdateEvent; + statusUpdateEvent.status = message; + m_feClient.send(statusUpdateEvent); + } stream << message << endl; } #else @@ -253,9 +253,9 @@ namespace LOFAR { GCFTCPPort m_feClient; }; - // - // class WeightsCommand - // + // + // class WeightsCommand + // class WeightsCommand : public Command { public: @@ -278,9 +278,9 @@ namespace LOFAR { int m_type; }; - // - // class SubbandsCommand - // + // + // class SubbandsCommand + // class SubbandsCommand : public Command { public: @@ -302,9 +302,9 @@ namespace LOFAR { int m_type; }; - // - // class RCUCommand - // + // + // class RCUCommand + // class RCUCommand : public Command { public: @@ -324,9 +324,9 @@ namespace LOFAR { RCUSettings::Control m_control; }; - // - // class RSUCommand - // + // + // class RSUCommand + // class RSUCommand : public Command { public: @@ -346,9 +346,9 @@ namespace LOFAR { RSUSettings::ResetControl m_control; }; - // - // class WGCommand - // + // + // class WGCommand + // class WGCommand : public Command { public: @@ -377,12 +377,12 @@ namespace LOFAR { double m_frequency; uint8 m_phase; uint32 m_amplitude; - uint8 m_mode; + uint8 m_mode; }; - // - // class StatisticsBaseCommand - // + // + // class StatisticsBaseCommand + // class StatisticsBaseCommand : public FECommand { public: @@ -427,7 +427,7 @@ namespace LOFAR { return m_file[rcu]; } protected: - uint32 m_subscriptionHandle; + uint32 m_subscriptionhandle; uint32 m_duration; RTC::Timestamp m_endTime; uint32 m_integration; @@ -437,9 +437,9 @@ namespace LOFAR { private: }; - // - // class Statistics - // + // + // class Statistics + // class StatisticsCommand : public StatisticsBaseCommand { public: @@ -462,9 +462,9 @@ namespace LOFAR { blitz::Array<double, 2> m_stats; }; - // - // class XCStatisticsCommand - // + // + // class XCStatisticsCommand + // class XCStatisticsCommand : public StatisticsBaseCommand { public: @@ -482,26 +482,26 @@ namespace LOFAR { blitz::Array<std::complex<double>, 4> m_stats; }; - // - // class StatusCommand - // + // + // class StatusCommand + // class StatusCommand : public Command { public: - StatusCommand(GCFPortInterface& port); - virtual ~StatusCommand() {} - virtual void send(); - virtual GCFEvent::TResult ack(GCFEvent& e); - blitz::Array<SystemStatus, 1>& board() { // just pass reference to user - return m_board; - } + StatusCommand(GCFPortInterface& port); + virtual ~StatusCommand() {} + virtual void send(); + virtual GCFEvent::TResult ack(GCFEvent& e); + blitz::Array<SystemStatus, 1>& board() { // just pass reference to user + return m_board; + } private: - blitz::Array<RSP_Protocol::SystemStatus, 1> m_board; + blitz::Array<RSP_Protocol::SystemStatus, 1> m_board; }; - // - // class ClockCommand - // + // + // class ClockCommand + // class ClocksCommand : public Command { public: @@ -519,9 +519,25 @@ namespace LOFAR { uint32 m_clock; }; - // - // class VersionCommand - // + // + // class RegisterStateCommand + // + class RegisterStateCommand : public Command + { + public: + RegisterStateCommand(GCFPortInterface& port); + virtual ~RegisterStateCommand() {} + virtual void send(); + virtual GCFEvent::TResult ack(GCFEvent& e); + void stop(); + protected: + uint32 m_subscriptionhandle; + private: + }; + + // + // class VersionCommand + // class VersionCommand : public Command { public: @@ -536,9 +552,9 @@ namespace LOFAR { /** * Controller class for rspctl */ - // - // class RSPCtl - // + // + // class RSPCtl + // class RSPCtl : public GCFTask { public: @@ -588,13 +604,13 @@ namespace LOFAR { // dimensions of the connected hardware int m_nrcus; int m_nrspboards; - int m_maxrspboards; + int m_maxrspboards; // commandline parameters int m_argc; char** m_argv; - int32 m_instancenr; + int32 m_instancenr; }; }; diff --git a/MAC/APL/PIC/RSPDriver/test/EPAStub.cc b/MAC/APL/PIC/RSPDriver/test/EPAStub.cc index c2d0bc3b2c7..e3e8270faa2 100644 --- a/MAC/APL/PIC/RSPDriver/test/EPAStub.cc +++ b/MAC/APL/PIC/RSPDriver/test/EPAStub.cc @@ -405,8 +405,6 @@ GCFEvent::TResult EPAStub::connected(GCFEvent& event, GCFPortInterface& port) case EPA_RSR_STATUS: case EPA_RSR_VERSION: case EPA_DIAG_RESULTS: - case EPA_RCU_RESULT: - case EPA_TDS_RESULT: { // log invalid write events EPAWriteEvent write(event); @@ -431,12 +429,14 @@ GCFEvent::TResult EPAStub::connected(GCFEvent& event, GCFPortInterface& port) case EPA_SST_STATS: case EPA_RCU_SETTINGS: case EPA_RCU_PROTOCOL: + case EPA_RCU_RESULT: case EPA_CR_CONTROL: case EPA_XST_STATS: case EPA_CDO_SETTINGS: case EPA_CDO_HEADER: case EPA_BS_NOFSAMPLESPERSYNC: case EPA_TDS_PROTOCOL: + case EPA_TDS_RESULT: case EPA_TBB_CONTROL: { EPAWriteEvent write(event); diff --git a/MAC/APL/PIC/RSPDriver/test/EPAStub.conf.in b/MAC/APL/PIC/RSPDriver/test/EPAStub.conf.in index f698478aeae..0cb7f95a450 100644 --- a/MAC/APL/PIC/RSPDriver/test/EPAStub.conf.in +++ b/MAC/APL/PIC/RSPDriver/test/EPAStub.conf.in @@ -3,15 +3,14 @@ # # -# MAC address of lofar27, eth2, 00:0A:5E:46:5D:ED # This sets the destination MAC address of the EPA response events # -EPAStub.MAC_ADDR_RSPDRIVER=00:50:04:32:B8:5C +EPAStub.MAC_ADDR_RSPDRIVER=00:30:48:2D:82:F6 # # Interface on which to listen for RSPDriver events # -EPAStub.IF_NAME=eth2 +EPAStub.IF_NAME=eth0 # # Number of BLP's per RSP board diff --git a/MAC/APL/PIC/RSP_Protocol/include/APL/RSP_Protocol/AllRegisterState.h b/MAC/APL/PIC/RSP_Protocol/include/APL/RSP_Protocol/AllRegisterState.h index 7ba63305830..66386960f47 100644 --- a/MAC/APL/PIC/RSP_Protocol/include/APL/RSP_Protocol/AllRegisterState.h +++ b/MAC/APL/PIC/RSP_Protocol/include/APL/RSP_Protocol/AllRegisterState.h @@ -65,43 +65,52 @@ namespace LOFAR { // to force initial update // sys_state.resize(nrRspBoards); - sys_state.modified(); - bf_state.resize(nrRcus * EPA_Protocol::MEPHeader::N_PHASE); // XR, XI, YR, YI - bf_state.modified(); - ss_state.resize(nrBlps); - ss_state.modified(); - rcusettings_state.resize(nrRcus); - rcusettings_state.modified(); - rcuprotocol_state.resize(nrRcus); - rcuprotocol_state.modified(); - rsuclear_state.resize(nrRspBoards); - rsuclear_state.clear(); - diagwgsettings_state.resize(nrRcus); - diagwgsettings_state.modified(); - sst_state.resize(nrBlps); - sst_state.modified(); - bst_state.resize(nrRspBoards); - bst_state.modified(); - xst_state.resize(nrRspBoards); - xst_state.modified(); - cdo_state.resize(nrRspBoards); - cdo_state.modified(); - bs_state.resize(nrBlps); - bs_state.modified(); - tds_state.resize(nrRspBoards); - tds_state.modified(); + + force(); + } + + void force() { + sys_state.read(); + bf_state.write(); + ss_state.write(); + rcusettings_state.write(); + rcuprotocol_state.write(); + rsuclear_state.write(); + diagwgsettings_state.write(); + sst_state.read(); + bst_state.read(); + xst_state.read(); + cdo_state.write(); + bs_state.write(); + tds_state.write(); + } + + void schedule() { + sys_state.read(); + bf_state.write(); + ss_state.write(); + rcusettings_state.check(); + rcuprotocol_state.check(); + rsuclear_state.check(); + diagwgsettings_state.check(); + sst_state.read(); + bst_state.read(); + xst_state.read(); + cdo_state.check(); + bs_state.check(); + tds_state.check(); } void clear() { @@ -123,7 +132,7 @@ namespace LOFAR { void print(std::ostream& out) const { out << " "; for (int i = 0; i < m_nrcus * EPA_Protocol::MEPHeader::N_POL; i++) { - out << (i % 10); + out << (i % 10) << " "; } out << endl; out << "System Status "; sys_state.print(out); diff --git a/MAC/APL/PIC/RSP_Protocol/src/AllRegisterState.cc b/MAC/APL/PIC/RSP_Protocol/src/AllRegisterState.cc index 1d64bdacf86..7e4e029fff1 100644 --- a/MAC/APL/PIC/RSP_Protocol/src/AllRegisterState.cc +++ b/MAC/APL/PIC/RSP_Protocol/src/AllRegisterState.cc @@ -53,20 +53,19 @@ unsigned int AllRegisterState::pack (void* buffer) { unsigned int offset = 0; - offset = - sys_state.pack(buffer) - + bf_state.pack(buffer) - + ss_state.pack(buffer) - + rcusettings_state.pack(buffer) - + rcuprotocol_state.pack(buffer) - + rsuclear_state.pack(buffer) - + diagwgsettings_state.pack(buffer) - + sst_state.pack(buffer) - + bst_state.pack(buffer) - + xst_state.pack(buffer) - + cdo_state.pack(buffer) - + bs_state.pack(buffer) - + tds_state.pack(buffer); + offset += sys_state.pack((char*)buffer + offset); + offset += bf_state.pack((char*)buffer + offset); + offset += ss_state.pack((char*)buffer + offset); + offset += rcusettings_state.pack((char*)buffer + offset); + offset += rcuprotocol_state.pack((char*)buffer + offset); + offset += rsuclear_state.pack((char*)buffer + offset); + offset += diagwgsettings_state.pack((char*)buffer + offset); + offset += sst_state.pack((char*)buffer + offset); + offset += bst_state.pack((char*)buffer + offset); + offset += xst_state.pack((char*)buffer + offset); + offset += cdo_state.pack((char*)buffer + offset); + offset += bs_state.pack((char*)buffer + offset); + offset += tds_state.pack((char*)buffer + offset); return offset; } @@ -75,20 +74,19 @@ unsigned int AllRegisterState::unpack(void *buffer) { unsigned int offset = 0; - offset = - sys_state.unpack(buffer) - + bf_state.unpack(buffer) - + ss_state.unpack(buffer) - + rcusettings_state.unpack(buffer) - + rcuprotocol_state.unpack(buffer) - + rsuclear_state.unpack(buffer) - + diagwgsettings_state.unpack(buffer) - + sst_state.unpack(buffer) - + bst_state.unpack(buffer) - + xst_state.unpack(buffer) - + cdo_state.unpack(buffer) - + bs_state.unpack(buffer) - + tds_state.unpack(buffer); + offset += sys_state.unpack((char*)buffer + offset); + offset += bf_state.unpack((char*)buffer + offset); + offset += ss_state.unpack((char*)buffer + offset); + offset += rcusettings_state.unpack((char*)buffer + offset); + offset += rcuprotocol_state.unpack((char*)buffer + offset); + offset += rsuclear_state.unpack((char*)buffer + offset); + offset += diagwgsettings_state.unpack((char*)buffer + offset); + offset += sst_state.unpack((char*)buffer + offset); + offset += bst_state.unpack((char*)buffer + offset); + offset += xst_state.unpack((char*)buffer + offset); + offset += cdo_state.unpack((char*)buffer + offset); + offset += bs_state.unpack((char*)buffer + offset); + offset += tds_state.unpack((char*)buffer + offset); return offset; } -- GitLab