diff --git a/MAC/GCF/PVSS/include/GCF/PVSS/PVSSinfo.h b/MAC/GCF/PVSS/include/GCF/PVSS/PVSSinfo.h index 34db928c61287d88b0e32ac158a9040307137b30..78ff2ad1ed65cb3b90ea1e3af2d7f5e6dd9ae74b 100644 --- a/MAC/GCF/PVSS/include/GCF/PVSS/PVSSinfo.h +++ b/MAC/GCF/PVSS/include/GCF/PVSS/PVSSinfo.h @@ -45,23 +45,23 @@ public: static bool isValidPropName(const char* propName); static bool isValidScope (const char* propName); - static const string getSystemName(int8 sysnr); + static const string getSystemName(uint sysnr); static const string& getLocalSystemName(); - static int8 getLocalSystemId(); - static int8 getSysId(const string& name); - static int8 getLastEventSysId(); + static uint getLocalSystemId(); + static uint getSysId(const string& name); + static uint getLastEventSysId(); static const string& getProjectName(); static timeval getLastEventTimestamp(); - static uint8 getLastEventManNum(); - static uint8 getOwnManNum(); - static uint8 getLastEventManType(); + static uint getLastEventManNum(); + static uint getOwnManNum(); + static uint getLastEventManType(); static TGCFResult getTypeStruct(const string& typeName, - list<TPropertyInfo>& propInfo, - int8 sysNr = getLocalSystemId()); + list<TPropertyInfo>& propInfo, + uint sysNr = getLocalSystemId()); static void getAllProperties(const string& typeFilter, const string& dpFitler, vector<string>& foundProperties); @@ -72,10 +72,10 @@ private: friend class PVSSservice; static string _sysName; static string _projName; - static int8 _lastSysNr; + static uint _lastSysNr; static timeval _lastTimestamp; - static uint8 _lastManNum; - static uint8 _lastManType; + static uint _lastManNum; + static uint _lastManType; // Construction methods // Don't allow to (con/de)struct an instance of this class @@ -90,7 +90,7 @@ private: // </group> }; -inline int8 PVSSinfo::getLastEventSysId() +inline uint PVSSinfo::getLastEventSysId() { return _lastSysNr; } @@ -100,12 +100,12 @@ inline timeval PVSSinfo::getLastEventTimestamp() return _lastTimestamp; } -inline uint8 PVSSinfo::getLastEventManNum() +inline uint PVSSinfo::getLastEventManNum() { return _lastManNum; } -inline uint8 PVSSinfo::getLastEventManType() +inline uint PVSSinfo::getLastEventManType() { return _lastManType; } diff --git a/MAC/GCF/PVSS/src/PVSSinfo.cc b/MAC/GCF/PVSS/src/PVSSinfo.cc index 4b97b390c9646b967d8531d7903cd4ca319c85d7..7f312ffb3398cf7840f7c5bdf37bb35d68dfac0e 100644 --- a/MAC/GCF/PVSS/src/PVSSinfo.cc +++ b/MAC/GCF/PVSS/src/PVSSinfo.cc @@ -37,10 +37,10 @@ namespace LOFAR { string PVSSinfo::_sysName = ""; string PVSSinfo::_projName = ""; -int8 PVSSinfo::_lastSysNr = 0; +uint PVSSinfo::_lastSysNr = 0; timeval PVSSinfo::_lastTimestamp= {0, 0}; -uint8 PVSSinfo::_lastManNum = 0; -uint8 PVSSinfo::_lastManType = 0; +uint PVSSinfo::_lastManNum = 0; +uint PVSSinfo::_lastManType = 0; TMACValueType macValueTypes[] = { @@ -129,7 +129,7 @@ TMACValueType PVSSinfo::getMACTypeId (const string& dpeName) { // first find out whether there is a system name specified or not vector<string> splittedDpeName = StringUtil::split(dpeName, ':'); - int8 sysNr = getSysId(dpeName); + uint sysNr = getSysId(dpeName); if (sysNr == 0) { sysNr = PVSSinfo::getLocalSystemId(); } @@ -161,15 +161,15 @@ const string& PVSSinfo::getLocalSystemName() // // getLocalSystemId() // -int8 PVSSinfo::getLocalSystemId() +uint PVSSinfo::getLocalSystemId() { - return ((int) Resources::getSystem()); + return((int)Resources::getSystem()); } // // getSystemName(sysnr) // -const string PVSSinfo::getSystemName(int8 sysnr) +const string PVSSinfo::getSystemName(uint sysnr) { CharString sysName; if (Manager::getSystemName(sysnr, sysName) == PVSS_TRUE) { @@ -193,18 +193,18 @@ const string& PVSSinfo::getProjectName() // // getSysId(name) // -int8 PVSSinfo::getSysId(const string& name) +uint PVSSinfo::getSysId(const string& name) { string::size_type index = name.find(':'); if (index == string::npos) { index = name.length(); } CharString sysName(name.c_str(), index); - int sysNr; + uint sysNr; // workaround - start DpIdentifier dpId; Manager::getId(sysName + ":", dpId); - sysNr = dpId.getSystem(); + sysNr = (int)dpId.getSystem(); // workaround - end /* DpIdentificationResult res; @@ -219,7 +219,7 @@ int8 PVSSinfo::getSysId(const string& name) // // getOwnManNum() // -uint8 PVSSinfo::getOwnManNum() +uint PVSSinfo::getOwnManNum() { return (Resources::getManNum()); } @@ -305,7 +305,7 @@ void buildTypeStructTree(const string path, const DpType* pType, const DpElement // TGCFResult PVSSinfo::getTypeStruct(const string& typeName, list<TPropertyInfo>& propInfos, - int8 sysNr) + uint sysNr) { propInfos.clear(); @@ -314,8 +314,8 @@ TGCFResult PVSSinfo::getTypeStruct(const string& typeName, DpType* pType; if (Manager::getTypeId(pvssTypeName, typeId, sysNr) == PVSS_FALSE) { string sysName = getSystemName(sysNr); - LOG_ERROR(formatString("PVSS could not find type %s on system %s", - typeName.c_str(), sysName.c_str())); + LOG_ERROR(formatString("PVSS could not find type %s on system %s(%d)", + typeName.c_str(), sysName.c_str(), sysNr)); return(GCF_PVSS_ERROR); } diff --git a/MAC/GCF/PVSS/test/Makefile.am b/MAC/GCF/PVSS/test/Makefile.am index 297fd8aa4aa8214e5a0146ea70713e7439adf9fb..0946feff8362c0d6f6f1dfd3360a553c07afc8cc 100644 --- a/MAC/GCF/PVSS/test/Makefile.am +++ b/MAC/GCF/PVSS/test/Makefile.am @@ -1,6 +1,6 @@ AM_CPPFLAGS = -I$(top_srcdir)/PVSS/src -check_PROGRAMS = tPVSSservice tPerformance tPVSSconnect tMonitorState +check_PROGRAMS = tPVSSservice tPerformance tPVSSconnect tMonitorState tPVSSinfo TESTS = tPVSSservice @@ -16,6 +16,10 @@ tPVSSconnect_SOURCES = $(BUILT_SOURCES) tPVSSconnect.cc tPVSSconnect_LDADD = ../src/libgcfpvss.la $(LOFAR_DEPEND) tPVSSconnect_DEPENDENCIES = ../src/libgcfpvss.la $(LOFAR_DEPEND) +tPVSSinfo_SOURCES = $(BUILT_SOURCES) tPVSSinfo.cc Response.cc +tPVSSinfo_LDADD = ../src/libgcfpvss.la $(LOFAR_DEPEND) +tPVSSinfo_DEPENDENCIES = ../src/libgcfpvss.la $(LOFAR_DEPEND) + tMonitorState_SOURCES = $(BUILT_SOURCES) tMonitorState.cc Response.cc tMonitorState_LDADD = ../src/libgcfpvss.la $(LOFAR_DEPEND) tMonitorState_DEPENDENCIES = ../src/libgcfpvss.la $(LOFAR_DEPEND) diff --git a/MAC/GCF/PVSS/test/tPVSSinfo.cc b/MAC/GCF/PVSS/test/tPVSSinfo.cc new file mode 100644 index 0000000000000000000000000000000000000000..66d65d1164ce92430f42edbc8b013565cfcadadd --- /dev/null +++ b/MAC/GCF/PVSS/test/tPVSSinfo.cc @@ -0,0 +1,119 @@ +// +// tPVSSinfo.cc: Test prog for manual testing queries +// +// Copyright (C) 2008 +// ASTRON (Netherlands Foundation for Research in Astronomy) +// P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// $Id$ + +#include <lofar_config.h> +#include <Common/LofarLogger.h> +#include <Common/Exception.h> +#include <GCF/PVSS/GCF_PVTypes.h> +#include <GCF/PVSS/PVSSinfo.h> +#include "tPVSSservice.h" +#include "tPVSSinfo.h" +#include "Response.h" + +namespace LOFAR { + namespace GCF { + using namespace TM; + namespace PVSS { + + +tPVSSinfo::tPVSSinfo(const string& name) : + GCFTask((State)&tPVSSinfo::initial, name), + itsService(0), + itsResponse(0), + itsTimerPort(0) +{ + registerProtocol(F_FSM_PROTOCOL, F_FSM_PROTOCOL_STRINGS); + itsResponse = new Response; + itsTimerPort = new GCFTimerPort(*this, "timerPort"); +} + +tPVSSinfo::~tPVSSinfo() +{ + if (itsService) { + delete itsService; + } + if (itsResponse) { + delete itsResponse; + } + if (itsTimerPort) { + delete itsTimerPort; + } +} + +// +// initial (event, port) +// +GCFEvent::TResult tPVSSinfo::initial(GCFEvent& e, GCFPortInterface& /*p*/) +{ + LOG_DEBUG_STR("initial:" << eventName(e)); + GCFEvent::TResult status = GCFEvent::HANDLED; + + switch (e.signal) { + case F_ENTRY: + break; + + case F_INIT: { + itsService = new PVSSservice(itsResponse); + PVSSresult result; + + try { + cout << "getLocalSystemId : " << (int)PVSSinfo::getLocalSystemId() << endl; + cout << "getLocalSystemName: " << PVSSinfo::getLocalSystemName() << endl; + cout << "getSystemName(Id) : " << PVSSinfo::getSystemName(PVSSinfo::getLocalSystemId()) << endl; + cout << "getSystemId(Name) : " << (int)PVSSinfo::getSysId(PVSSinfo::getLocalSystemName()) << endl; + cout << "getProjectName : " << PVSSinfo::getProjectName() << endl; + cout << "getOwnManNum : " << (int)PVSSinfo::getOwnManNum() << endl; + } + catch (Exception& except) { + cout << "One of the PVSS-calls went wrong" << endl; + } + GCFScheduler::instance()->stop(); + } + break; + + default: + status = GCFEvent::NOT_HANDLED; + break; + } + + return status; +} + + } // namespace PVSS + } // namespace GCF +} // namespace LOFAR + + +using namespace LOFAR::GCF; + +int main(int argc, char* argv[]) +{ + TM::GCFScheduler::instance()->init(argc, argv); + + PVSS::tPVSSinfo test_task("infoTest"); + test_task.start(); // make initial transition + + TM::GCFScheduler::instance()->run(); + + return 0; +} diff --git a/MAC/GCF/PVSS/test/tPVSSinfo.h b/MAC/GCF/PVSS/test/tPVSSinfo.h new file mode 100644 index 0000000000000000000000000000000000000000..cc16955ff861b3d08009c649c6c9b986b75a353f --- /dev/null +++ b/MAC/GCF/PVSS/test/tPVSSinfo.h @@ -0,0 +1,58 @@ +// tPVSSinfo.h: Test prog for manual testing PVSS queries. +// +// Copyright (C) 2008 +// ASTRON (Netherlands Foundation for Research in Astronomy) +// P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// $Id$ +// + +#ifndef _TPVSSINFO_H +#define _TPVSSINFO_H + +#include <GCF/TM/GCF_Control.h> +#include <GCF/PVSS/PVSSservice.h> +#include <GCF/PVSS/PVSSresponse.h> + +namespace LOFAR { + namespace GCF { + using TM::GCFTask; + using TM::GCFTimerPort; + namespace PVSS { +/** + * The tPVSSinfo task receives ECHO_PING events from the Ping task and + * returns an ECHO_ECHO event for each ECHO_PING event received. + */ +class tPVSSinfo : public GCFTask +{ +public: + tPVSSinfo (const string& name); + virtual ~tPVSSinfo(); + + GCFEvent::TResult initial (GCFEvent& e, GCFPortInterface& p); + +private: + PVSSservice* itsService;; + PVSSresponse* itsResponse; + GCFTimerPort* itsTimerPort; +}; + + } // namespace PVSS + } // namespace GCF +} // namespace LOFAR + +#endif diff --git a/MAC/GCF/RTDB/src/RTDB_PropertySet.cc b/MAC/GCF/RTDB/src/RTDB_PropertySet.cc index 997771a4c44f6b92db24d940fdd168e83443a267..a64fd7bbdac1acb786f496c3ac54f2ffc723c6ca 100644 --- a/MAC/GCF/RTDB/src/RTDB_PropertySet.cc +++ b/MAC/GCF/RTDB/src/RTDB_PropertySet.cc @@ -274,7 +274,7 @@ string RTDBPropertySet::getFullScope () const void RTDBPropertySet::_createAllProperties() { // Get ID of this PVSS database - int8 sysNr = PVSSinfo::getSysId(itsScope); + int sysNr = PVSSinfo::getSysId(itsScope); if (sysNr == 0) { sysNr = PVSSinfo::getLocalSystemId(); }