From 5bd2e5dfb1da1b59e0e29021efeb82f99a3b130c Mon Sep 17 00:00:00 2001 From: cvs <sdos@astron.nl> Date: Mon, 24 Oct 2005 15:02:52 +0000 Subject: [PATCH] %lofarcvsmv%: Moved to LOFAR/MAC/APL/PAC/BS_Protocol/src --- MAC/APL/PAC/BeamServer/src/BS_Protocol.prot | 161 ------------------ .../PAC/BeamServer/src/Beamlet2SubbandMap.cc | 96 ----------- MAC/APL/PAC/BeamServer/src/Pointing.cc | 131 -------------- 3 files changed, 388 deletions(-) delete mode 100644 MAC/APL/PAC/BeamServer/src/BS_Protocol.prot delete mode 100644 MAC/APL/PAC/BeamServer/src/Beamlet2SubbandMap.cc delete mode 100644 MAC/APL/PAC/BeamServer/src/Pointing.cc diff --git a/MAC/APL/PAC/BeamServer/src/BS_Protocol.prot b/MAC/APL/PAC/BeamServer/src/BS_Protocol.prot deleted file mode 100644 index 13305bc59c3..00000000000 --- a/MAC/APL/PAC/BeamServer/src/BS_Protocol.prot +++ /dev/null @@ -1,161 +0,0 @@ -// -// Protocol definition for the Beam Server Protocol -// -autogen definitions protocol; - -description = "Protocol for the Beam Server"; -prefix = "BS"; // for the signal names -id = "(LOFAR::GCF::TM::F_APL_PROTOCOL+10)"; - -// specify extra include files -// e.g. -include = '<sys/time.h>'; -include = '"Beamlet2SubbandMap.h"'; -include = '"Pointing.h"'; -include = '<APL/RTCCommon/Timestamp.h>'; - -prelude = << PRELUDE_END - - enum { - SUCCESS = 0, - ERR_RANGE, // range error in message parameters - ERR_BEAMALLOC, // could not allocate beam - ERR_BEAMFREE, // could not free beam - }; - -PRELUDE_END; - -// -// An "event" has a "signal" and a "dir" (direction) -// and zero or more "param"s. -// "dir" can be one of "IN" or "OUT". -// A "param" has a "name" and a "type". -// -event = { - signal = BEAMALLOC; - dir = IN; - - param = { // name of the beam (nodeid) - name = "name"; - type = "string"; - }; - - // Name of the station receptor group (SRG) on which this beam will be allocated. - // The SRG determines the sampling frequency and nyquist_zone. - param = { - name = "subarrayname"; - type = "string"; - }; - - // how the subbands should be allocated to which beamlets - // e.g. - // beamlet 0 -> subband 384 - // beamlet 1 -> subband 385 - // beamlet 2 -> subband 386 - // etc. - param = { - name = "allocation"; - type = "Beamlet2SubbandMap"; - userdefined; - }; -}; - -event = { - signal = BEAMALLOCACK; - dir = OUT; - param = { - name = "handle"; - type = "uint32"; - }; - param = { - name = "status"; - type = "int16"; - }; -}; - -event = { - signal = BEAMMODIFY; - dir = IN; - - // handle to the beam, previously received in BEAMALLOCACK - param = { - name = "handle"; - type = "uint32"; - }; - - // New mapping of beamlets to subbands, the left-hand side of - // the mapping (the beamlets) must be identical to the left-hand - // side of the mapping specified in the BEAMALLOC event. - // Only the subbands can be modified, not the beamlets allocated. - param = { - name = "allocation"; - type = "Beamlet2SubbandMap"; - userdefined; - }; -}; - -event = { - signal = BEAMMODIFYACK; - dir = OUT; - - // handle - param = { - name = "handle"; - type = "uint32"; - }; - param = { - name = "status"; - type = "int16"; - }; -}; - -event = { - signal = BEAMFREE; - dir = IN; - param = { - name = "handle"; - type = "uint32"; - }; -}; - -event = { - signal = BEAMFREEACK; - dir = OUT; - param = { - name = "handle"; - type = "uint32"; - }; - param = { - name = "status"; - type = "int16"; - }; -}; - -event = { - signal = BEAMPOINTTO; - dir = IN; - param = { - name = "handle"; - type = "uint32"; - }; - param = { - name = "pointing"; - type = "Pointing"; - userdefined; - }; -/* - param = { - // time at which the new direction should be effective - name = "timestamp"; - type = "RTC::Timestamp"; - }; - param = { - name = "type"; // BS_Protocol::J2000, AZEL or LOFAR_LMN - type = "int16"; - }; - param = { - name = "angle"; - type = "double[2]"; - }; -*/ -}; diff --git a/MAC/APL/PAC/BeamServer/src/Beamlet2SubbandMap.cc b/MAC/APL/PAC/BeamServer/src/Beamlet2SubbandMap.cc deleted file mode 100644 index f095663239e..00000000000 --- a/MAC/APL/PAC/BeamServer/src/Beamlet2SubbandMap.cc +++ /dev/null @@ -1,96 +0,0 @@ -//# Beamlet2SubbandMap.h: implementation of the Beamlet2SubbandMap 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 "Beamlet2SubbandMap.h" -#include <APL/RTCCommon/Marshalling.h> - -using namespace LOFAR; -using namespace BS_Protocol; -using namespace std; -using namespace blitz; - -unsigned int Beamlet2SubbandMap::getSize() -{ - // 1-dimensional array has 1 int32 for length - // map is converted to array of uint16 of 2 * map.size() elements - return sizeof(int32) + (m_beamlet2subband.size() * sizeof(uint16) * 2); -} - -unsigned int Beamlet2SubbandMap::pack (void* buffer) -{ - /** - * the map is sent as a blitz array - */ - blitz::Array<uint16, 1> maparray; - unsigned int offset = 0; - - maparray.resize(m_beamlet2subband.size() * 2); // resize the array - maparray = 0; - - // convert map to Blitz array - map<uint16, uint16>::iterator it; - int i = 0; - for (it = m_beamlet2subband.begin(); it != m_beamlet2subband.end(); ++it, i+=2) { - maparray(i) = it->first; - maparray(i+1) = it->second; - } - - MSH_PACK_ARRAY(buffer, offset, maparray, uint16); - - return offset; -} - -unsigned int Beamlet2SubbandMap::unpack(void *buffer) -{ - /** - * the map is received as a blitz array - */ - blitz::Array<uint16, 1> maparray; - unsigned int offset = 0; - - MSH_UNPACK_ARRAY(buffer, offset, maparray, uint16, 1); - - // convert Blitz array to map - ASSERT(0 == maparray.extent(firstDim) % 2); - m_beamlet2subband.clear(); - for (int i = 0; i < maparray.extent(firstDim) / 2; i++) { - m_beamlet2subband[maparray(i*2)] = maparray(i*2+1); - } - - return offset; -} - -bitset<EPA_Protocol::MEPHeader::N_SUBBANDS> Beamlet2SubbandMap::getAsBitset() const -{ - bitset<EPA_Protocol::MEPHeader::N_SUBBANDS> result; - - for (map<uint16, uint16>::const_iterator it = m_beamlet2subband.begin(); - it != m_beamlet2subband.end(); ++it) { - result.set(it->second); - } - - return result; -} - diff --git a/MAC/APL/PAC/BeamServer/src/Pointing.cc b/MAC/APL/PAC/BeamServer/src/Pointing.cc deleted file mode 100644 index ceb7ca5622e..00000000000 --- a/MAC/APL/PAC/BeamServer/src/Pointing.cc +++ /dev/null @@ -1,131 +0,0 @@ -//# ABSPointing.cc: implementation of the ABS::Pointing 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 "Pointing.h" - -using namespace LOFAR; -using namespace BS_Protocol; -using namespace AMC; - -Pointing::Pointing() : m_angle0(0.0), m_angle1(0.0), m_time(), m_type(LOFAR_LMN) -{ -} - -Pointing::Pointing(double angle0, double angle1, RTC::Timestamp time, Type type) : - m_angle0(angle0), m_angle1(angle1), m_time(time), m_type(type) -{} - -Pointing::~Pointing() -{} - -Pointing Pointing::convertToLMN(Converter* conv, EarthCoord* pos) -{ - SkyCoord result = SkyCoord(angle0(), angle1()); // start with current coordinates - double - mjd = 0.0, - fraction = 0.0, - l = 0.0, - m = 0.0, - n = 0.0; - - switch (getType()) { - - case J2000: - /* convert J2000 to LMN */ - ASSERT(conv && pos); - time().convertToMJD(mjd, fraction); - - result = conv->j2000ToAzel(SkyCoord(angle0(), angle1()), *pos, TimeCoord(mjd, fraction)); - - /* now convert from azel to lmn by falling through to AZEL label */ - /* Note: break intentionally omitted */ - - case AZEL: - /* convert AZEL to LMN */ - LOG_DEBUG_STR("azel=(" << result.angle0() << ", " << result.angle1() << ")"); - - l = -::cos(result.angle1()) * ::sin(result.angle0()); - m = ::cos(result.angle1()) * ::cos(result.angle0()); - n = ::sin(result.angle1()); - LOG_DEBUG_STR("lmn=(" << l << ", " << m << ", " << n << ")"); - result = SkyCoord(l,m); - break; - - case LOFAR_LMN: - /* coordinates are already in LMN format */ - break; - - default: - LOG_FATAL("invalid switch value"); - exit(EXIT_FAILURE); - break; - } - - /* return LOFAR_LMN pointing */ - return Pointing(result.angle0(), - result.angle1(), - time(), - LOFAR_LMN); -} - -unsigned int Pointing::getSize() -{ - return (sizeof(double) * 2) + m_time.getSize() + sizeof(uint8); -} - -unsigned int Pointing::pack (void* buffer) -{ - unsigned int offset = 0; - - memcpy((char*)buffer + offset, &m_angle0, sizeof(double)); - offset += sizeof(double); - memcpy((char*)buffer + offset, &m_angle1, sizeof(double)); - offset += sizeof(double); - offset += m_time.pack((char*)buffer + offset); - uint8 type = m_type; - memcpy((char*)buffer + offset, &type, sizeof(uint8)); - offset += sizeof(uint8); - - return offset; -} - -unsigned int Pointing::unpack(void *buffer) -{ - unsigned int offset = 0; - - memcpy(&m_angle0, (char*)buffer + offset, sizeof(double)); - offset += sizeof(double); - memcpy(&m_angle1, (char*)buffer + offset, sizeof(double)); - offset += sizeof(double); - offset += m_time.unpack((char*)buffer + offset); - uint8 type = 0; - memcpy(&type, (char*)buffer + offset, sizeof(uint8)); - m_type = (Type)type; - offset += sizeof(uint8); - - return offset; -} - - -- GitLab