Skip to content
Snippets Groups Projects
Commit 4373f8fd authored by Pieter Donker's avatar Pieter Donker
Browse files

Bug 335: further development of RSPDriver

parent 296a713d
No related branches found
No related tags found
No related merge requests found
//# GetLatencyCmd.cc: implementation of the GetLatencyCmd 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 "GetLatencyCmd.h"
using namespace blitz;
using namespace LOFAR;
using namespace RSP;
using namespace RSP_Protocol;
using namespace RTC;
GetLatencyCmd::GetLatencyCmd(GCFEvent& event, GCFPortInterface& port, Operation oper) :
Command("GetVersion", port, oper)
{
m_event = new RSPGetlatencyEvent(event);
}
GetLatencyCmd::~GetLatencyCmd()
{
delete m_event;
}
void GetLatencyCmd::ack(CacheBuffer& cache)
{
RSPGetlatencyackEvent ack;
ack.timestamp = getTimestamp();
ack.status = RSP_SUCCESS;
ack.latencys().resize(cache.getLatencys()().extent(firstDim));
ack.latencys() = cache.getLatencys()();
getPort()->send(ack);
}
void GetLatencyCmd::apply(CacheBuffer& /*cache*/, bool /*setModFlag*/)
{
/* intentionally left empty */
}
void GetLatencyCmd::complete(CacheBuffer& cache)
{
ack(cache);
}
const Timestamp& GetLatencyCmd::getTimestamp() const
{
return m_event->timestamp;
}
void GetLatencyCmd::setTimestamp(const Timestamp& timestamp)
{
m_event->timestamp = timestamp;
}
bool GetLatencyCmd::validate() const
{
return true;
}
bool GetLatencyCmd::readFromCache() const
{
return m_event->cache;
}
//# -*- mode: c++ -*-
//#
//# GetLatencyCmd.h: 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 GETLATENCYCMD_H_
#define GETLATENCYCMD_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 GetLatencyCmd : public Command
{
public:
/**
* Constructors for a GetLatencyCmd object.
*/
GetLatencyCmd(GCFEvent& event, GCFPortInterface& port, Operation oper);
/* Destructor for GetVersionsCmd. */
virtual ~GetLatencyCmd();
/**
* 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.
*/
virtual bool readFromCache() const;
private:
GetLatencyCmd();
RSPGetlatencyEvent* m_event;
};
};
};
#endif /* GETLATENCYCMD_H_ */
//# LatencyRead.cc: implementation of the TDSStatusRead 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 <Common/LofarConstants.h>
#include <APL/RSP_Protocol/EPA_Protocol.ph>
#include <APL/RTCCommon/PSAccess.h>
#include <string.h>
#include "LatencyRead.h"
#include "Cache.h"
#include "StationSettings.h"
#include <netinet/in.h>
#include <blitz/array.h>
namespace LOFAR {
namespace RSP {
using namespace EPA_Protocol;
using namespace blitz;
using namespace RTC;
//
// LatencyRead(port, boardID)
//
LatencyRead::LatencyRead(GCFPortInterface& board_port, int board_id):
SyncAction(board_port, board_id, 1)
{
memset(&m_hdr, 0, sizeof(MEPHeader));
}
//
// ~LatencyRead()
//
LatencyRead::~LatencyRead()
{
/* TODO: delete event? */
}
//
// sendrequest()
//
void LatencyRead::sendrequest()
{
// send read event
EPAReadEvent latencyread;
latencyread.hdr.set(MEPHeader::RAD_LATENCY_HDR, MEPHeader::DST_RSP, MEPHeader::READ);
m_hdr = latencyread.hdr; // remember header to match with ack
getBoardPort().send(latencyread);
}
//
// sendrequest_status
//
void LatencyRead::sendrequest_status()
{
// intentionally left empty
}
//
// handleack(event, port)
//
GCFEvent::TResult LatencyRead::handleack(GCFEvent& event, GCFPortInterface& /*port*/)
{
// is this the message type we are waiting for?
if (EPA_RAD_LAT != event.signal) {
LOG_WARN("LatencyRead::handleack:: unexpected ack");
return GCFEvent::NOT_HANDLED;
}
// convert to TDSResultEvent
EPARadLatEvent ack(event);
if (!ack.hdr.isValidAck(m_hdr)) {
LOG_ERROR("LatencyRead::handleack: invalid ack");
return GCFEvent::NOT_HANDLED;
}
Cache::getInstance().getBack().getLatencys()()(getBoardId()) = ack.latency;
return GCFEvent::HANDLED;
}
} // namespace RSP
} // namespace LOFAR
//# -*- mode: c++ -*-
//#
//# LatencyRead.h: Synchronize rcu settings with RSP hardware.
//#
//# 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 LATENCYREAD_H_
#define LATENCYREAD_H_
#include <APL/RSP_Protocol/MEPHeader.h>
#include "SyncAction.h"
namespace LOFAR {
namespace RSP {
class LatencyRead : public SyncAction
{
public:
/**
* Constructors for a LatencyRead object.
*/
LatencyRead(GCFPortInterface& board_port, int board_id);
/* Destructor for LatencyRead. */
virtual ~LatencyRead();
/**
* Send the write message.
*/
virtual void sendrequest();
/**
* Send the read request.
*/
virtual void sendrequest_status();
/**
* Handle the read result.
*/
virtual GCFEvent::TResult handleack(GCFEvent& event, GCFPortInterface& port);
private:
EPA_Protocol::MEPHeader m_hdr;
};
};
};
#endif /* LATENCYREAD_H_ */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment