diff --git a/.gitattributes b/.gitattributes index bc10dae9306822b16defa0684e2168650a3167fe..8eee3d45796adcd3ee62d5b5e2245e662a757c24 100644 --- a/.gitattributes +++ b/.gitattributes @@ -395,12 +395,6 @@ MAC/Docs/PVSS-Readme.doc -text MAC/Drivers/spid/tools/Makefile -text svneol=native#application/octet-stream MAC/Drivers/spid/tools/Makefile.am -text svneol=native#application/octet-stream MAC/GCF/DEPENDENCIES -text svneol=native#application/octet-stream -MAC/GCF/GCFCommon/Makefile.am -text svneol=native#application/octet-stream -MAC/GCF/GCFCommon/bootstrap -text svneol=native#application/octet-stream -MAC/GCF/GCFCommon/configure.in -text svneol=native#application/octet-stream -MAC/GCF/GCFCommon/include/GCF/GCF_Defines.h -text -MAC/GCF/GCFCommon/pvss/scripts/libs/gcf-common.ctl -text svneol=native#application/octet-stream -MAC/GCF/GCFCommon/src/Makefile.am -text svneol=native#application/octet-stream MAC/GCF/LogSys/CLP/Makefile.am -text svneol=native#application/octet-stream MAC/GCF/LogSys/CLP/src/CodeLoggingProcessor.log_prop.in -text svneol=native#application/octet-stream MAC/GCF/LogSys/CLP/src/Makefile.am -text svneol=native#application/octet-stream @@ -417,8 +411,6 @@ MAC/GCF/TM/Makefile.am -text svneol=native#application/octet-stream MAC/GCF/TM/bootstrap -text svneol=native#application/octet-stream MAC/GCF/TM/configure.in -text svneol=native#application/octet-stream MAC/GCF/TM/src/Makefile.am -text svneol=native#application/octet-stream -MAC/GCF/TM/src/ServiceBroker/Makefile.am -text svneol=native#application/octet-stream -MAC/GCF/TM/src/ServiceBroker/SB_Protocol.prot -text svneol=native#application/octet-stream MAC/GCF/TM/test/Echo_Protocol.prot -text svneol=native#application/octet-stream MAC/GCF/TM/test/tGCFTask1.cc -text MAC/GCF/TM/test/tGCFTask2.cc -text diff --git a/.gitignore b/.gitignore index 2274c5a3971f5aea29b548bd84cf92c189dac3ee..0cbd842e60cd8802e35d42f00fe52750e4e43a1e 100644 --- a/.gitignore +++ b/.gitignore @@ -305,9 +305,6 @@ MAC/Deployment/lofarconf MAC/Drivers/spid/Makefile.common MAC/Drivers/spid/autoconf_share MAC/Drivers/spid/lofarconf -MAC/GCF/GCFCommon/Makefile.common -MAC/GCF/GCFCommon/autoconf_share -MAC/GCF/GCFCommon/lofarconf MAC/GCF/LogSys/Makefile.common MAC/GCF/LogSys/autoconf_share MAC/GCF/LogSys/lofarconf diff --git a/MAC/GCF/GCFCommon/GCFCommon.spec.in b/MAC/GCF/GCFCommon/GCFCommon.spec.in deleted file mode 100644 index 8fe3d22737e60bd26ece7ea9c05324b1b6974526..0000000000000000000000000000000000000000 --- a/MAC/GCF/GCFCommon/GCFCommon.spec.in +++ /dev/null @@ -1,161 +0,0 @@ -# -*- Mode:rpm-spec -*- -# GCFCommon.spec.in -# - -############################################################################## -# -# Preamble -# -############################################################################## - -Summary: GCFCommon provides a number of basic/common classes for all packages in MAC (like MAC types). - -%define release @RPM_RELEASE@ -%define version @VERSION@ -%define pkgname @PACKAGE@ -%define pkgdir %{pkgname}-%{version}-%{release} -%define prefix /opt/lofar -%define configure_args @RPM_CONFIGURE_ARGS@ -##define build_kernel_version @BUILD_KERNEL_VERSION@ - -Name: %{pkgname} -Version: %{version} -Release: %{release} -Copyright: LGPL -Group: Application/System -Source: %{pkgname}-%{version}.tar.gz -BuildRoot: %{_tmppath}/%{pkgdir}-root -URL: http://www.astron.nl -Prefix: %{prefix} -BuildArchitectures: i386 # Target platforms, i.e., i586 -Requires: Common >= 2.2 -Requires: APS >= 2.0 -Packager: %{packager} -Distribution: The LOFAR project -Vendor: ASTRON - -AutoReqProv: no - -%description - -GCFCommon provides a number of basic/common classes for all packages in MAC (like MAC types). - -############################################################################## -# -# prep -# -############################################################################## -%prep -echo $prefix - -# create the build directory, untar the source -%setup - -############################################################################## -# -# build -# -############################################################################## -%build -./configure %{configure_args} --prefix=%{prefix} && make - -############################################################################## -# -# install -# -############################################################################## -%install -# To make things work with BUILDROOT -if [ "$RPM_BUILD_ROOT" != "%{_tmppath}/%{pkgdir}-root" ] -then - echo - echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ - echo @ @ - echo @ RPM_BUILD_ROOT is not what I expected. Please clean it yourself. @ - echo @ @ - echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ - echo -else - echo Cleaning RPM_BUILD_ROOT: "$RPM_BUILD_ROOT" - rm -rf "$RPM_BUILD_ROOT" -fi -mkdir -p $RPM_BUILD_ROOT%{prefix} -make DESTDIR="$RPM_BUILD_ROOT" install - -#uninstall - -############################################################################## -# -# verify -# -############################################################################## -#verify - -############################################################################## -# -# clean -# -############################################################################## -%clean -# Call me paranoid, but I do not want to be responsible for nuking -# someone's harddrive! -if [ "$RPM_BUILD_ROOT" != "%{_tmppath}/%{pkgdir}-root" ] -then - echo - echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ - echo @ @ - echo @ RPM_BUILD_ROOT is not what I expected. Please clean it yourself. @ - echo @ @ - echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ - echo -else - echo Cleaning RPM_BUILD_ROOT: "$RPM_BUILD_ROOT" - rm -rf "$RPM_BUILD_ROOT" -fi - -############################################################################## -# -# files -# -############################################################################## - -# empty 'files' means all distributed files -%files -%defattr(-, root, root) -%{prefix} - -# Your application file list goes here -# %{prefix}/lib/lib*.so* - -# Documentation -# doc COPYING ChangeLog README AUTHORS NEWS -# doc doc/* - -# link the module to the correct path -%post - -# before uninstall -%preun - -# after uninstall -%postun - -############################################################################## -# -# package devel -# -############################################################################## - -#package devel -#Summary: Development files for %{pkgname} -#Group: Applications/System -#description devel -#Development files for %{pkgname}. - -#files devel - -# Your development files go here -# Programmers documentation goes here -#doc doc - -# end of file diff --git a/MAC/GCF/GCFCommon/Makefile.am b/MAC/GCF/GCFCommon/Makefile.am deleted file mode 100644 index 4f351897eddcfab518bd3952ab84a83befbd79a5..0000000000000000000000000000000000000000 --- a/MAC/GCF/GCFCommon/Makefile.am +++ /dev/null @@ -1,14 +0,0 @@ -SUBDIRS=src include pvss - -pkgextdir = $(prefix)/config/$(PACKAGE) -pkgext_DATA = pkgext pkgextcppflags pkgextcxxflags pkgextldflags - -#DISTCHECK_CONFIGURE_FLAGS=\ -# --with-common=$(prefix) # "common" is an example - -EXTRA_DIST = \ - Makefile.common \ - GCFCommon.spec \ - autoconf_share/compiletool - -include $(top_srcdir)/Makefile.common diff --git a/MAC/GCF/GCFCommon/bootstrap b/MAC/GCF/GCFCommon/bootstrap deleted file mode 100755 index 06f18cde1dbfd6912ef7d927c4d35d25c7137a62..0000000000000000000000000000000000000000 --- a/MAC/GCF/GCFCommon/bootstrap +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -../../../autoconf_share/bootstrap ../../../autoconf_share diff --git a/MAC/GCF/GCFCommon/configure.in b/MAC/GCF/GCFCommon/configure.in deleted file mode 100644 index 682e302d3ffce831b4d828f10a8b0b85fad261f5..0000000000000000000000000000000000000000 --- a/MAC/GCF/GCFCommon/configure.in +++ /dev/null @@ -1,57 +0,0 @@ -dnl -dnl Process this file with autoconf to produce a configure script. -dnl -AC_INIT(include/GCF/GCF_ServiceInfo.h) -dnl AC_CONFIG_AUX_DIR(config) -dnl AM_CONFIG_HEADER(config/config.h) -AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(GCFCommon, 6.1, no-define) - -dnl Initialize for LOFAR (may set compilers) -lofar_INIT - -dnl Checks for programs. -AC_PROG_AWK -AC_PROG_YACC -AC_PROG_CC -AC_PROG_CXX -AM_PROG_LEX -AC_PROG_INSTALL -AC_PROG_LN_S -AC_DISABLE_SHARED -AC_PROG_LIBTOOL - -dnl Checks for libraries. - -dnl Checks for header files. -AC_HEADER_STDC -AC_CHECK_HEADERS(unistd.h) - -dnl Checks for typedefs, structures, and compiler characteristics. -AC_C_CONST -AC_TYPE_SIZE_T - -dnl Checks for library functions. -AC_FUNC_VPRINTF - -dnl -dnl Check for LOFAR specific things -dnl -lofar_GENERAL -lofar_INTERNAL(LCS/Common, Common, , 1, Common/LofarTypes.h,,) -lofar_INTERNAL(LCS/ACC/APS, APS, , 1, APS/ParameterSet.h,,) - -dnl -dnl Output Makefiles -dnl -AC_OUTPUT( -src/Makefile -test/Makefile -include/Makefile -include/GCF/Makefile -pvss/Makefile -pvss/scripts/Makefile -pvss/scripts/libs/Makefile -Makefile -GCFCommon.spec -) diff --git a/MAC/GCF/GCFCommon/include/GCF/CmdLine.h b/MAC/GCF/GCFCommon/include/GCF/CmdLine.h deleted file mode 100644 index cca5d3abf742bf1b239fea5e67b65bee7d7c6a84..0000000000000000000000000000000000000000 --- a/MAC/GCF/GCFCommon/include/GCF/CmdLine.h +++ /dev/null @@ -1,228 +0,0 @@ -/*------------------------------------------------------ - CCmdLine - - A utility for parsing command lines. - - Copyright (C) 1999 Chris Losinger, Smaller Animals Software. - http://www.smalleranimals.com - - This software is provided 'as-is', without any express - or implied warranty. In no event will the authors be - held liable for any damages arising from the use of this software. - - Permission is granted to anyone to use this software - for any purpose, including commercial applications, and - to alter it and redistribute it freely, subject to the - following restrictions: - - 1. The origin of this software must not be misrepresented; - you must not claim that you wrote the original software. - If you use this software in a product, an acknowledgment - in the product documentation would be appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, - and must not be misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. - - ------------------------- - - Example : - - Our example application uses a command line that has two - required switches and two optional switches. The app should abort - if the required switches are not present and continue with default - values if the optional switches are not present. - - Sample command line : - MyApp.exe -p1 text1 text2 -p2 "this is a big argument" -opt1 -55 -opt2 - - Switches -p1 and -p2 are required. - p1 has two arguments and p2 has one. - - Switches -opt1 and -opt2 are optional. - opt1 requires a numeric argument. - opt2 has no arguments. - - Also, assume that the app displays a 'help' screen if the '-h' switch - is present on the command line. - - #include "CmdLine.h" - - void main(int argc, char **argv) - { - // our cmd line parser object - CCmdLine cmdLine; - - // parse argc,argv - if (cmdLine.SplitLine(argc, argv) < 1) - { - // no switches were given on the command line, abort - ASSERT(0); - exit(-1); - } - - // test for the 'help' case - if (cmdLine.HasSwitch("-h")) - { - show_help(); - exit(0); - } - - // get the required arguments - string p1_1, p1_2, p2_1; - // if any of these fail, we'll end up in the catch() block - p1_1 = cmdLine.GetArgument("-p1", 0); - p1_2 = cmdLine.GetArgument("-p1", 1); - p2_1 = cmdLine.GetArgument("-p2", 0); - - - // get the optional parameters - - // convert to an int, default to '100' - int iOpt1Val = atoi(cmdLine.GetSafeArgument("-opt1", 0, 100)); - - // since opt2 has no arguments, just test for the presence of - // the '-opt2' switch - bool bOptVal2 = cmdLine.HasSwitch("-opt2"); - - .... and so on.... - - } - - If this class is used in an MFC application, string is CString, else - it uses the STL 'string' type. - - If this is an MFC app, you can use the __argc and __argv macros from - you CYourWinApp::InitInstance function in place of the standard argc - and argv variables. - -------------------------------------------------------*/ -#ifndef GCF_CMDLINE_H -#define GCF_CMDLINE_H - -// tell the compiler to shut up -#pragma warning(disable:4786) - -#include <Common/lofar_map.h> -#include <Common/lofar_string.h> -#include <Common/lofar_vector.h> - -using std::string; -using std::vector; -using std::map; - -namespace LOFAR -{ - namespace GCF - { - namespace Common - { - -// handy little container for our argument vector -struct CCmdParam -{ - vector<string> m_strings; -}; - -// this class is actually a map of strings to vectors -typedef map<string, CCmdParam> _CCmdLine; - -// the command line parser class -class CCmdLine : public _CCmdLine -{ - -public: - /*------------------------------------------------------ - int CCmdLine::SplitLine(int argc, char **argv) - - parse the command line into switches and arguments. - - returns number of switches found - ------------------------------------------------------*/ - int SplitLine(int argc, char **argv); - - /*------------------------------------------------------ - bool CCmdLine::HasSwitch(const char *pSwitch) - - was the switch found on the command line ? - - ex. if the command line is : app.exe -a p1 p2 p3 -b p4 -c -d p5 - - call return - ---- ------ - cmdLine.HasSwitch("-a") true - cmdLine.HasSwitch("-z") false - ------------------------------------------------------*/ - bool HasSwitch(const char *pSwitch); - - /*------------------------------------------------------ - - string CCmdLine::GetSafeArgument(const char *pSwitch, int iIdx, const char *pDefault) - - fetch an argument associated with a switch . if the parameter at - index iIdx is not found, this will return the default that you - provide. - - example : - - command line is : app.exe -a p1 p2 p3 -b p4 -c -d p5 - - call return - ---- ------ - cmdLine.GetSafeArgument("-a", 0, "zz") p1 - cmdLine.GetSafeArgument("-a", 1, "zz") p2 - cmdLine.GetSafeArgument("-b", 0, "zz") p4 - cmdLine.GetSafeArgument("-b", 1, "zz") zz - - ------------------------------------------------------*/ - - string GetSafeArgument(const char *pSwitch, unsigned int iIdx, const char *pDefault = 0); - - /*------------------------------------------------------ - - string CCmdLine::GetArgument(const char *pSwitch, int iIdx) - - fetch a argument associated with a switch. - - example : - - command line is : app.exe -a p1 p2 p3 -b p4 -c -d p5 - - call return - ---- ------ - cmdLine.GetArgument("-a", 0) p1 - cmdLine.GetArgument("-b", 1) returns an empty string - - ------------------------------------------------------*/ - string GetArgument(const char *pSwitch, unsigned int iIdx); - - /*------------------------------------------------------ - int CCmdLine::GetArgumentCount(const char *pSwitch) - - returns the number of arguments found for a given switch. - - returns -1 if the switch was not found - - ------------------------------------------------------*/ - int GetArgumentCount(const char *pSwitch); - -protected: - /*------------------------------------------------------ - - protected member function - test a parameter to see if it's a switch : - - switches are of the form : -x - where 'x' is one or more characters. - the first character of a switch must be non-numeric! - - ------------------------------------------------------*/ - bool IsSwitch(const char *pParam); -}; - } // namespace Common - } // namespace GCF -} // namespace LOFAR - -#endif diff --git a/MAC/GCF/GCFCommon/include/GCF/GCF_Defines.h b/MAC/GCF/GCFCommon/include/GCF/GCF_Defines.h deleted file mode 100755 index 5373684b63e967b9ed1205f747a642cc3af4540c..0000000000000000000000000000000000000000 --- a/MAC/GCF/GCFCommon/include/GCF/GCF_Defines.h +++ /dev/null @@ -1,171 +0,0 @@ -//# GCF_Defines.h: preprocessor definitions of various constants -//# -//# Copyright (C) 2002-2003 -//# 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: GCF_Defines.h 10435 2007-08-02 21:38:38Z overeem $ - -#ifndef GCF_DEFINES_H -#define GCF_DEFINES_H - -#include <Common/LofarLogger.h> - -#include <Common/lofar_list.h> -#include <Common/lofar_map.h> -#include <Common/lofar_vector.h> - -using std::string; -using std::list; -using std::map; -using std::vector; - -namespace LOFAR { - namespace GCF { - namespace Common { - -// This header file will be included by each GCF API class header and provides -// therefore a number of defines, structs or macro's. They can/must be used when -// calling a GCF API class memberfunction. - -#define GCF_SYS_NAME_SEP ':' // separates the databasename from the ppropertyname -#define GCF_PROP_NAME_SEP '.' // separates the levels in property sets -#define GCF_SCOPE_NAME_SEP '_' // separates the levels in structure of property sets - -// possible results of GCF api class member calls. -enum TGCFResult -{ - GCF_NO_ERROR, - GCF_UNKNOWN_ERROR, - GCF_PML_ERROR, - GCF_EXTPS_LOAD_ERROR, - GCF_PS_CONFIGURE_ERROR, - GCF_EXTPS_UNLOAD_ERROR, - GCF_MYPS_ENABLE_ERROR, - GCF_MYPS_DISABLE_ERROR, - GCF_VALUESTRING_NOT_VALID, - GCF_DIFFERENT_TYPES, - GCF_BUSY, - GCF_ALREADY_LOADED, - GCF_NOT_LOADED, - GCF_PROP_NOT_VALID, - GCF_PROP_WRONG_TYPE, - GCF_PROP_NOT_IN_SET, - GCF_NO_PROPER_DATA, - GCF_SCOPE_ALREADY_REG, - GCF_ALREADY_SUBSCRIBED, - GCF_NOT_SUBSCRIBED, - GCF_WRONG_STATE, - GCF_PVSS_ERROR, -}; - -typedef unsigned char TAccessMode; - -#define GCF_READABLE_PROP 1 // means monitorable -#define GCF_WRITABLE_PROP 2 // means controllable -#define GCF_READWRITE_PROP (GCF_READABLE_PROP | GCF_WRITABLE_PROP) - -// struct for initalize properties with accessMode and/or defaultValue -// if defaultValue == 0 no default value will be set -struct TPropertyConfig -{ - char* propName; - TAccessMode accessMode; - char* defaultValue; -}; - -// start macro of a list of configurations of properties belonging to the same -// property set -#define PROPERTYCONFIGLIST_BEGIN(_name_) \ -const TPropertyConfig _name_[] = \ -{ - -// config item of the list of configurations of properties belonging to the same -// property set -#define PROPERTYCONFIGLIST_ITEM(_propname_,_flags_,_default_) \ -{_propname_,_flags_,_default_}, - -// end macro of a list of configurations of properties belonging to the same -// property set -#define PROPERTYCONFIGLIST_END \ -{0,0,0} \ -}; - -/** - * The enumeration of possible MAC property types - * In case a dynamic array will be used the type ID enumeration starts on - * 0x80. - * END_* are only delimeters - */ -typedef enum TMACValueType -{ - NO_LPT, LPT_BOOL, LPT_CHAR, LPT_UNSIGNED, LPT_INTEGER, - LPT_BIT32, LPT_BLOB, LPT_REF, LPT_DOUBLE, LPT_DATETIME, - LPT_STRING, END_LPT, - LPT_DYNARR = 0x80, LPT_DYNBOOL, LPT_DYNCHAR, LPT_DYNUNSIGNED, LPT_DYNINTEGER, - LPT_DYNBIT32, LPT_DYNBLOB, LPT_DYNREF, LPT_DYNDOUBLE, LPT_DYNDATETIME, - LPT_DYNSTRING, END_DYNLPT -}; - -// struct which holds the information about a property (name, type) -// the information is retrieved from PVSS and converted to this struct or set by -// the user -struct TPropertyInfo -{ - string propName; - TMACValueType type; - TPropertyInfo() : propName(), type(NO_LPT) {}; - TPropertyInfo(const char* pPropName, TMACValueType atype) : propName(pPropName), type(atype) {}; - TPropertyInfo(const TPropertyInfo& other) - { - if (this != &other) - { - type = other.type; - propName.replace(0, string::npos, other.propName); - } - }; -}; - -// PropertySet category -typedef enum TPSCategory -{ - // corresponding DP does not exists - // will be created on the first load request - PS_CAT_TEMPORARY, - // corresponding DP must exists - // only the usecount will be increased on load - PS_CAT_PERMANENT, - // corresponding DP must exists - // will be loaded automatically right after handled enable request in the PA - PS_CAT_PERM_AUTOLOAD, - // corresponding DP does not exists - // will be loaded automatically right after handled enable request in the PA - PS_CAT_TEMP_AUTOLOAD, -}; - -enum TKVLOrigin -{ - KVL_NO_ORIGIN, - KVL_ORIGIN_MAC, - KVL_ORIGIN_SHM, - KVL_ORIGIN_OPERATOR -}; - - } // namespace Common - } // namespace GCF -} // namespace LOFAR -#endif diff --git a/MAC/GCF/GCFCommon/include/GCF/GCF_ServiceInfo.h b/MAC/GCF/GCFCommon/include/GCF/GCF_ServiceInfo.h deleted file mode 100644 index 75eac9643f7e20395194619a8ea890dc552c765e..0000000000000000000000000000000000000000 --- a/MAC/GCF/GCFCommon/include/GCF/GCF_ServiceInfo.h +++ /dev/null @@ -1,79 +0,0 @@ -//# GCF_ServiceInfo.h: Contains all information about the MAC services. -//# -//# 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 GCFCOMMON_SERVICEINFO_H -#define GCFCOMMON_SERVICEINFO_H - -// \file GCF_ServiceInfo.h -// Contains all information about the MAC services. - -//# Never #include <config.h> or #include <lofar_config.h> in a header file! -//# Includes - -// Avoid 'using namespace' in headerfiles - -namespace LOFAR { - namespace GCFCommon { - -// \addtogroup gcfcommon -// @{ - -// The two only well-known ports of whole MAC. -#define MAC_CODELOGGING_PORT 23999 -#define MAC_SERVICEBROKER_PORT 24000 - -// Define names for the services -#define MAC_SVCMASK_RSPDRIVER "RSPDriver%s:acceptor_v3" -#define MAC_SVCMASK_CALSERVER "CalServer%s:acceptor_v2" -#define MAC_SVCMASK_BEAMSERVER "BeamServer%s:acceptor_v2" -#define MAC_SVCMASK_TBBDRIVER "TBBDriver%s:acceptor" -#define MAC_SVCMASK_RSPCTLFE "RSPCtlFE%s:acceptor" - -// Define names for the daemons -#define MAC_SVCMASK_SERVICEBROKER "ServiceBroker%s:v1.0" -#define MAC_SVCMASK_STARTDAEMON "StartDaemon%s:v1.0" -#define MAC_SVCMASK_LOGPROC "LogProcessor%s:v1.0" -#define MAC_SVCMASK_KVTLOGGER "KVTLogger%s:v1.0" - -// Define names for all controllers -#define MAC_SVCMASK_SCHEDULERCTRL "MACScheduler%s:v1.0" -#define MAC_SVCMASK_OBSERVATIONCTRL "Observation%s:v1.0" -#define MAC_SVCMASK_BEAMDIRECTIONCTRL "BeamDirection%s:v1.0" -#define MAC_SVCMASK_GROUPCTRL "RingControl%s:v1.0" -#define MAC_SVCMASK_STATIONCTRL "StationControl%s:v1.0" -#define MAC_SVCMASK_DIGITALBOARDCTRL "DigitalBoardCtrl%s:v1.0" -#define MAC_SVCMASK_BEAMCTRL "BeamCtrl%s:v1.0" -#define MAC_SVCMASK_CALIBRATIONCTRL "CalibrationCtrl%s:v1.0" -#define MAC_SVCMASK_TBBCTRL "TBBCtrl%s:v1.0" -#define MAC_SVCMASK_STATIONINFRACTRL "StationInfraCtrl%s:v1.0" - - -// Define names for GCF test applications -#define MAC_SVCMASK_GCFTEST_ST3SERVER "ST3%s:server" -#define MAC_SVCMASK_GCFTEST_ST3PROVIDER "ST3%s:provider" -#define MAC_SVCMASK_APLTEST_CTLRMENU "ControllerTestMenu%s:v1.0" - -// @} - } // namespace GCFCommon -} // namespace LOFAR - -#endif diff --git a/MAC/GCF/GCFCommon/include/GCF/Makefile.am b/MAC/GCF/GCFCommon/include/GCF/Makefile.am deleted file mode 100644 index 32e2ae4dddb079e54d0ba3c06028179732f2441e..0000000000000000000000000000000000000000 --- a/MAC/GCF/GCFCommon/include/GCF/Makefile.am +++ /dev/null @@ -1,11 +0,0 @@ -pkgincludedir = $(includedir)/GCF -pkginclude_HEADERS = \ - CmdLine.h \ - Utils.h \ - GCF_Defines.h \ - GCF_ServiceInfo.h \ - Thread.h \ - Mutex.h - -include $(top_srcdir)/Makefile.common - diff --git a/MAC/GCF/GCFCommon/include/GCF/Mutex.h b/MAC/GCF/GCFCommon/include/GCF/Mutex.h deleted file mode 100644 index 28d2af2d79fa5db3ccafae6a39944e14799b79ec..0000000000000000000000000000000000000000 --- a/MAC/GCF/GCFCommon/include/GCF/Mutex.h +++ /dev/null @@ -1,377 +0,0 @@ -//# Mutex.h: Thread mutex 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$ - -#ifndef MUTEX_H -#define MUTEX_H - -//# Includes -#include <GCF/Thread.h> -#include <Common/LofarLogger.h> -namespace LOFAR -{ - namespace GCF - { - namespace Thread - { -// declare a functional Mutex only when USE_THREADS is defined. -// Otherwise, declare just a skeleton class (to keep, e.g., declarations -// consistent) -#ifdef USE_THREADS - - //##ModelId=3D1049B40332 -class Mutex -{ -public: - // This is completely non-portable, but pthread.h has me confused - // In any event, mutex type implementation is OS-dependent (and we can - // always do recursion and error-checking in the Mutex class itself) - //##ModelId=3DB935A103A1 - typedef enum { DEFAULT = PTHREAD_MUTEX_TIMED_NP, - FAST = DEFAULT, - RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP, - ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP } MutexKind; - - //##ModelId=3DB935A103C9 - typedef enum { TRY=1 } MutexOptions; - - //##ModelId=3D1049B40396 - - class Lock - { - public: - //##ModelId=5571A783FEED - Lock(); - - //##ModelId=A15218DBFEED - Lock(const Lock &right); - - Lock & operator = (const Lock &right); - - //##ModelId=3DB935A30335 - Lock (pthread_mutex_t &mutex, int options = 0); - - //##ModelId=3DB935A40034 - Lock (const Thread::Mutex &mutex, int options = 0); - - //##ModelId=3DB935A4012E - ~Lock(); - - - //##ModelId=D5165FA7FEED - bool locked () const; - - //##ModelId=18054E53FEED - operator bool () const; - - //##ModelId=E5D40595FEED - bool operator ! () const; - - //##ModelId=E2FBE0C8FEED - int release (); - - //##ModelId=D8B60901FEED - void release_without_unlock (); - - //##Documentation - //## lock() releases current mutex (if any), then obtains - //## a lock on the new mutex - int lock (const Thread::Mutex &mutex, int options = 0); - - //##ModelId=3D19CF980270 - //##Documentation - //## relock() works the othe way around: first obtains a lock - //## on the new mutex, then releases the current one - int relock (const Thread::Mutex &mutex, int options = 0); - - // Additional Public Declarations - //##ModelId=3DB935A401EC - const char * debug (int = 1,const string & = "",const char * = 0 ) const - { return "Mutex::Lock"; } - //##ModelId=3DB935A4039B - string sdebug (int = 1,const string & = "",const char * = 0 ) const - { return debug(); } - private: - - //##ModelId=5FDF0A36FEED - void init (const pthread_mutex_t &mtx, int options = 0); - - private: - // Data Members for Class Attributes - - //##ModelId=3D10514502E9 - pthread_mutex_t *pmutex; - - }; - - //##ModelId=70B8C5D3FEED - Mutex (int kind = RECURSIVE); - - //##ModelId=3D10B976039C - Mutex (const Mutex &right); - - //##ModelId=3DB935A5020C - ~Mutex(); - - - //##ModelId=3D10BC47035F - Mutex & operator = (const Mutex &right); - - //##ModelId=D4F415F7FEED - int lock () const; - - //##ModelId=4304D0E8FEED - int unlock () const; - - //##ModelId=A4649BF5FEED - int trylock () const; - -public: - // Additional Public Declarations - friend class Lock; - - //##ModelId=3DB935A5023E - const char * debug (int = 1,const string & = "",const char * = 0 ) const - { return "Mutex"; } - //##ModelId=3DB935A50388 - string sdebug (int = 1,const string & = "",const char * = 0 ) const - { return debug(); } -protected: - - //##ModelId=9C882969FEED - void init (int kind); - - // Data Members for Class Attributes - - //##ModelId=3D10515D008B - mutable pthread_mutex_t mutex; - -}; - -//##ModelId=5571A783FEED -inline Mutex::Lock::Lock() - : pmutex(0) -{ -} - -inline Mutex::Lock::Lock(const Mutex::Lock &right) -{ - if( right.pmutex ) - init(*right.pmutex,0); - else - pmutex = 0; - -} - -inline Mutex::Lock & Mutex::Lock::operator =(const Mutex::Lock &right) -{ - if( pmutex ) - pthread_mutex_unlock(pmutex); - init(*right.pmutex,0); - return *this; -} - -//##ModelId=3DB935A30335 -inline Mutex::Lock::Lock (pthread_mutex_t &mutex, int options) -{ - init(mutex,options); -} - -//##ModelId=3DB935A40034 -inline Mutex::Lock::Lock (const Thread::Mutex &mutex, int options) -{ - init(mutex.mutex,options); -} - - -//##ModelId=3DB935A4012E -inline Mutex::Lock::~Lock() -{ - if( pmutex ) - pthread_mutex_unlock(pmutex); -} - -inline void Mutex::Lock::init (const pthread_mutex_t &mtx, int options) -{ - pmutex = const_cast<pthread_mutex_t *>(&mtx); - if( options == TRY ) - { - LOG_DEBUG(formatString ("init: try-locking mutex @%08X",(int)pmutex)); - if( pthread_mutex_trylock(pmutex) < 0 ) - pmutex = 0; - } - else - { - LOG_DEBUG(formatString ("init: locking mutex @%08X",(int)pmutex)); - pthread_mutex_lock(pmutex); - } - LOG_DEBUG(formatString ("init: locked mutex @%08X",(int)pmutex)); -} - -//##ModelId=D5165FA7FEED -inline bool Mutex::Lock::locked () const -{ - return pmutex != 0; -} - -//##ModelId=18054E53FEED -inline Mutex::Lock::operator bool () const -{ - return locked(); -} - -//##ModelId=E5D40595FEED -inline bool Mutex::Lock::operator ! () const -{ - return !locked(); -} - -//##ModelId=E2FBE0C8FEED -inline int Mutex::Lock::release () -{ - LOG_DEBUG(formatString ("release: unlocking mutex @%08X",(int)pmutex)); - int ret = pmutex ? pthread_mutex_unlock(pmutex) : 0; - pmutex = 0; - return ret; -} - -//##ModelId=D8B60901FEED -inline void Mutex::Lock::release_without_unlock () -{ - LOG_DEBUG(formatString ("release: relasing w/o unlock mutex @%08X",(int)pmutex)); - pmutex = 0; -} - -//##ModelId=3D19CF980270 -inline int Mutex::Lock::relock (const Thread::Mutex &mutex, int options) -{ - pthread_mutex_t *old = pmutex; - init(mutex.mutex,options); - if( old ) - { - LOG_DEBUG(formatString ("relock: unlocking old mutex @%08X",(int)old)); - pthread_mutex_unlock(old); - } - return 0; -} - -inline int Mutex::Lock::lock (const Thread::Mutex &mutex, int options) -{ - release(); - init(mutex.mutex,options); - return 0; -} - -// Class Thread::Mutex - -//##ModelId=70B8C5D3FEED -inline Mutex::Mutex (int kind) -{ - init(kind); -} - -//##ModelId=3D10B976039C -inline Mutex::Mutex (const Mutex &right) -{ - init(right.mutex.__m_kind); -} - - -//##ModelId=3DB935A5020C -inline Mutex::~Mutex() -{ - pthread_mutex_destroy(&mutex); -} - -//##ModelId=9C882969FEED -inline void Mutex::init (int kind) -{ - pthread_mutexattr_t attr = { kind }; - pthread_mutex_init(&mutex,&attr); - LOG_DEBUG(formatString ("initialized mutex %08x kind %d",(int)&mutex,kind)); -} - -//##ModelId=3D10BC47035F -inline Mutex & Mutex::operator = (const Mutex &right) -{ - pthread_mutex_destroy(&mutex); - init(right.mutex.__m_kind); - return *this; -} - -//##ModelId=D4F415F7FEED -inline int Mutex::lock () const -{ - LOG_DEBUG(formatString ("%d: locking mutex %08x",(int)self().id(),(int)&mutex)); - int ret = pthread_mutex_lock(&mutex); - LOG_DEBUG(formatString ("%d: locked mutex %08x: %d",(int)self().id(),(int)&mutex,ret)); - return ret; -} - -//##ModelId=4304D0E8FEED -inline int Mutex::unlock () const -{ - int ret = pthread_mutex_unlock(&mutex); - LOG_DEBUG(formatString ("%d: unlocked mutex %08x: %d",(int)self().id(),(int)&mutex,ret)); - return ret; -} - -//##ModelId=A4649BF5FEED -inline int Mutex::trylock () const -{ - return pthread_mutex_trylock(&mutex); -} - -// Class Thread::Mutex::Lock - -// Class Thread::Mutex - -#else // no-threads configuration -class Mutex -{ -public: - class Lock - { - public: - Lock () {} - Lock (pthread_mutex_t &, int = 0) {}; - Lock (const Thread::Mutex &, int = 0) {}; - - bool locked () const { return false; }; - operator bool () const { return false;}; - bool operator ! () const { return false; }; - int release () { return 0; }; - void release_without_unlock () {}; - int relock (const Thread::Mutex &, int = 0) { return 0; } - - const char * debug (int = 1,const string & = "",const char * = 0 ) const - { return ""; } - string sdebug (int = 1,const string & = "",const char * = 0 ) const - { return debug(); } - }; -}; -#endif - - } // namespace Thread - } // namespace GCF -} // namespace LOFAR - -#endif diff --git a/MAC/GCF/GCFCommon/include/GCF/Thread.h b/MAC/GCF/GCFCommon/include/GCF/Thread.h deleted file mode 100644 index 3bc28bf135013f7f79f35a8c0ab7a1b9d9256103..0000000000000000000000000000000000000000 --- a/MAC/GCF/GCFCommon/include/GCF/Thread.h +++ /dev/null @@ -1,181 +0,0 @@ -//# Thread.h: Thread class that wraps raw pthreads. -//# -//# 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 THREAD_H -#define THREAD_H - -#ifdef USE_THREADS -#include <pthread.h> -#include <signal.h> -#endif - -namespace LOFAR -{ - namespace GCF - { - namespace Thread - { -#ifdef USE_THREADS - extern void * dummy_pvoid; - extern int dummy_int; - - //##ModelId=3D1049B401F1 - class ThrID - { - private: - //##ModelId=3D105E60038E - pthread_t id_; - - public: - //##ModelId=E3D481F0FEED - ThrID() : id_(0) {} - - //##ModelId=3DB935AD011A - ThrID (pthread_t id) : id_(id) {} - - //##ModelId=3DB935AD0160 - bool operator == (ThrID right) const - { return pthread_equal(id_,right.id_); } - //##ModelId=3DB935AD01BA - bool operator != (ThrID right) const - { return !( (*this) == right ); } - bool operator < (ThrID right) const - { return id_ < right.id_; } - bool operator <= (ThrID right) const - { return id_ <= right.id_; } - bool operator > (ThrID right) const - { return id_ > right.id_; } - bool operator >= (ThrID right) const - { return id_ >= right.id_; } - - //##ModelId=981A70A9FEED - operator pthread_t () const { return id_; } - //##ModelId=3DB935AD0250 - pthread_t id () const { return id_; } - - //##ModelId=A4925AC3FEED - ThrID & operator = (pthread_t id) - { id_ = id; return *this; } - - // Joins a thread - int join (void * &value = dummy_pvoid) - { return pthread_join(id_,&value); } - // Cancels a thread - int cancel () - { return pthread_cancel(id_); } - // Detaches a thread - int detach () - { return pthread_detach(id_); } - // Sends a signal to a thread - int kill (int sig) - { return pthread_kill(id_,sig); } - - //##ModelId=98935E61FEED - static ThrID self () - { return ThrID(pthread_self()); } - }; - - - class Attributes - { - private: - pthread_attr_t attr; - - public: - typedef enum - { - JOINABLE = PTHREAD_CREATE_JOINABLE, - DETACHED = PTHREAD_CREATE_DETACHED - } AttributeCode; - - Attributes () { pthread_attr_init(&attr); } - Attributes (int st) { pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr,st); } - ~Attributes () { pthread_attr_destroy(&attr); } - - operator pthread_attr_t & () { return attr; } - operator const pthread_attr_t & () const { return attr; } - operator pthread_attr_t * () { return &attr; } - operator const pthread_attr_t * () const { return &attr; } - - // query attributes - int detachState() const { int res; pthread_attr_getdetachstate(&attr,&res); return res; } - bool joinable () const { return detachState() == JOINABLE; } - bool detached () const { return detachState() == DETACHED; } - - // set attributes - Attributes & setDetachState (int st) { pthread_attr_setdetachstate(&attr,st); return *this; } - - Attributes & setJoinable () { return setDetachState(JOINABLE); } - Attributes & setDetached () { return setDetachState(DETACHED); } - - static const Attributes & Null (); - }; - - extern const Attributes _null_attributes; - - Attributes joinable (); - - Attributes detached (); - - // ----------------------------------------------------------------------- - // Thread functions - // ----------------------------------------------------------------------- - - // returns thread id of self - ThrID self (); - - // Thread::create() creates a thred - ThrID create (void * (*start)(void*),void *arg=0,const Attributes &attr = Attributes::Null()); - - // Exits a thread - void exit (void *value=0); - - // Sets the sigmask for a thread - int signalMask (int how,const sigset_t *newmask,sigset_t *oldmask = 0); - - // Sets a single signal in a thread's sigmask - int signalMask (int how,int sig,sigset_t *oldmask = 0); - - // sets the thread's cancellation state - int setCancelState (int state,int &oldstate = dummy_int); - - // sets the thread's cancellation type - int setCancelType (int type,int &oldtype = dummy_int); - - void testCancel (); - - - // constant: the null thread id - const ThrID ThrID_null; - -#else - - typedef int ThrID; - class Attributes {}; - -#endif - - } // namespace Thread - } // namespace GCF -} // namespace LOFAR -#endif diff --git a/MAC/GCF/GCFCommon/include/GCF/Utils.h b/MAC/GCF/GCFCommon/include/GCF/Utils.h deleted file mode 100644 index 88eb5456ea64e94ea8c931e142c449cc0cdf2b16..0000000000000000000000000000000000000000 --- a/MAC/GCF/GCFCommon/include/GCF/Utils.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef UTILS_H -#define UTILS_H - -#include <Common/lofar_string.h> -#include <Common/lofar_list.h> -#include <set> - -namespace LOFAR { - namespace GCF { - namespace Common { - -// Returns the full or short version of the hostname -string myHostname(bool giveFullName); - -void convListToString(std::string& listString, - const std::list<std::string>& stringList); -void convStringToList(std::list<std::string>& stringList, - const std::string& listString); -void convSetToString(std::string& setString, - const std::set<std::string>& stringSet); -void convStringToSet(std::set<std::string>& stringSet, - const std::string& setString); -bool isValidPropName(const char* propName); -bool isValidScope (const char* scopeName); - - } // namespace Common - } // namespace GCF -} // namespace LOFAR -#endif // UTILS_H diff --git a/MAC/GCF/GCFCommon/include/Makefile.am b/MAC/GCF/GCFCommon/include/Makefile.am deleted file mode 100644 index eb27ea4dbf1fab7f2625b30e3bec3e378866d755..0000000000000000000000000000000000000000 --- a/MAC/GCF/GCFCommon/include/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -SUBDIRS = GCF - -include $(top_srcdir)/Makefile.common diff --git a/MAC/GCF/GCFCommon/pvss/Makefile.am b/MAC/GCF/GCFCommon/pvss/Makefile.am deleted file mode 100644 index 0c6a23cf2fbd14b6e2ef046b1b9b63752ebb3304..0000000000000000000000000000000000000000 --- a/MAC/GCF/GCFCommon/pvss/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -SUBDIRS=scripts - -include $(top_srcdir)/Makefile.common diff --git a/MAC/GCF/GCFCommon/pvss/scripts/Makefile.am b/MAC/GCF/GCFCommon/pvss/scripts/Makefile.am deleted file mode 100644 index e545b292cc58e846a9c3ea623fbe49c433a63657..0000000000000000000000000000000000000000 --- a/MAC/GCF/GCFCommon/pvss/scripts/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -SUBDIRS=libs - -include $(top_srcdir)/Makefile.common diff --git a/MAC/GCF/GCFCommon/pvss/scripts/libs/Makefile.am b/MAC/GCF/GCFCommon/pvss/scripts/libs/Makefile.am deleted file mode 100644 index 57a9effdbf0f926284acd0f3e47eec487312fbfa..0000000000000000000000000000000000000000 --- a/MAC/GCF/GCFCommon/pvss/scripts/libs/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -pkgdatadir = $(datadir)/pvss/scripts/libs -pkgdata_DATA = gcf-common.ctl - -EXTRA_DIST = $(pkgdata_DATA) - -include $(top_srcdir)/Makefile.common - diff --git a/MAC/GCF/GCFCommon/pvss/scripts/libs/gcf-common.ctl b/MAC/GCF/GCFCommon/pvss/scripts/libs/gcf-common.ctl deleted file mode 100644 index 6a881016d658c7933c9e752e4404be8cd4f29a2d..0000000000000000000000000000000000000000 --- a/MAC/GCF/GCFCommon/pvss/scripts/libs/gcf-common.ctl +++ /dev/null @@ -1,34 +0,0 @@ - -/////////////////////////////////////////////////////////////////////////// -// Function dpAccessable: Checks whether the given dpName is accessable and -// existing (in case of a distributed system. -// -// Input : datapoint name, including systemName -// Output: TRUE, if accessable and existing, -// FALSE, if not accessable and/or not existing -/////////////////////////////////////////////////////////////////////////// -bool dpAccessable(string dpName) -{ - string dpSystemName = strrtrim(dpSubStr(dpName,DPSUB_SYS),":"); - if(getSystemName()==(dpSystemName+":")) - { - return dpExists(dpName); - } - else if (getSystemName()!=(dpSystemName+":")) - { - dyn_int distributedSystems; - dpGet("_DistManager.State.SystemNums", distributedSystems); - //Check if dpSystemName is in the distributedSystems list - if (dynlen(distributedSystems)>0) - { - for(int i=1; i<=dynlen(distributedSystems); i++) - { - if(getSystemName(distributedSystems[i])==(dpSystemName+":")) //if the system is reacheable - { - return dpExists(dpName); - } - } - } - return FALSE; - } -} diff --git a/MAC/GCF/GCFCommon/src/CmdLine.cc b/MAC/GCF/GCFCommon/src/CmdLine.cc deleted file mode 100644 index 4f4e548980dd73e52436377dc8862a1417592429..0000000000000000000000000000000000000000 --- a/MAC/GCF/GCFCommon/src/CmdLine.cc +++ /dev/null @@ -1,274 +0,0 @@ -/*------------------------------------------------------ - CCmdLine - - A utility for parsing command lines. - - Copyright (C) 1999 Chris Losinger, Smaller Animals Software. - http://www.smalleranimals.com - - This software is provided 'as-is', without any express - or implied warranty. In no event will the authors be - held liable for any damages arising from the use of this software. - - Permission is granted to anyone to use this software - for any purpose, including commercial applications, and - to alter it and redistribute it freely, subject to the - following restrictions: - - 1. The origin of this software must not be misrepresented; - you must not claim that you wrote the original software. - If you use this software in a product, an acknowledgment - in the product documentation would be appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, - and must not be misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. - - See SACmds.h for more info. -------------------------------------------------------*/ - -//# Always #include <lofar_config.h> first! -#include <lofar_config.h> - -#include <GCF/CmdLine.h> -#include <ctype.h> - -namespace LOFAR -{ - namespace GCF - { - namespace Common - { - -/*------------------------------------------------------ - int CCmdLine::SplitLine(int argc, char **argv) - - parse the command line into switches and arguments - - returns number of switches found -------------------------------------------------------*/ -int CCmdLine::SplitLine(int argc, char **argv) -{ - clear(); - - string curParam; // current argv[x] - - // skip the exe name (start with i = 1) - for (int i = 1; i < argc; i++) - { - // if it's a switch, start a new CCmdLine - if (IsSwitch(argv[i])) - { - curParam = argv[i]; - - string arg; - - // look at next input string to see if it's a switch or an argument - if (i + 1 < argc) - { - if (!IsSwitch(argv[i + 1])) - { - // it's an argument, not a switch - arg = argv[i + 1]; - - // skip to next - i++; - } - else - { - arg = ""; - } - } - - // add it - CCmdParam cmd; - - // only add non-empty args - if (arg != "") - { - cmd.m_strings.push_back(arg); - } - - // add the CCmdParam to 'this' - insert(CCmdLine::value_type(curParam, cmd)); - - } - else - { - // it's not a new switch, so it must be more stuff for the last switch - - // ...let's add it - CCmdLine::iterator theIterator; - - // get an iterator for the current param - theIterator = find(curParam); - if (theIterator!=end()) - { - (*theIterator).second.m_strings.push_back(argv[i]); - } - else - { - // ?? - } - } - } - - return size(); -} - -/*------------------------------------------------------ - - protected member function - test a parameter to see if it's a switch : - - switches are of the form : -x - where 'x' is one or more characters. - the first character of a switch must be non-numeric! - -------------------------------------------------------*/ - -bool CCmdLine::IsSwitch(const char *pParam) -{ - if (pParam==NULL) - return false; - - // switches must non-empty - // must have at least one character after the '-' - int len = strlen(pParam); - if (len <= 1) - { - return false; - } - - // switches always start with '-' - if (pParam[0]=='-') - { - // allow negative numbers as arguments. - // ie., don't count them as switches - return (!isdigit(pParam[1])); - } - else - { - return false; - } -} - -/*------------------------------------------------------ - bool CCmdLine::HasSwitch(const char *pSwitch) - - was the switch found on the command line ? - - ex. if the command line is : app.exe -a p1 p2 p3 -b p4 -c -d p5 - - call return - ---- ------ - cmdLine.HasSwitch("-a") true - cmdLine.HasSwitch("-z") false -------------------------------------------------------*/ - -bool CCmdLine::HasSwitch(const char *pSwitch) -{ - CCmdLine::iterator theIterator; - theIterator = find(pSwitch); - return (theIterator!=end()); -} - -/*------------------------------------------------------ - - string CCmdLine::GetSafeArgument(const char *pSwitch, int iIdx, const char *pDefault) - - fetch an argument associated with a switch . if the parameter at - index iIdx is not found, this will return the default that you - provide. - - example : - - command line is : app.exe -a p1 p2 p3 -b p4 -c -d p5 - - call return - ---- ------ - cmdLine.GetSafeArgument("-a", 0, "zz") p1 - cmdLine.GetSafeArgument("-a", 1, "zz") p2 - cmdLine.GetSafeArgument("-b", 0, "zz") p4 - cmdLine.GetSafeArgument("-b", 1, "zz") zz - -------------------------------------------------------*/ - -string CCmdLine::GetSafeArgument(const char *pSwitch, unsigned int iIdx, const char *pDefault) -{ - string sRet; - - sRet = GetArgument(pSwitch, iIdx); - if (sRet.size() == 0 && pDefault != 0) - sRet = pDefault; - - return sRet; -} - -/*------------------------------------------------------ - - string CCmdLine::GetArgument(const char *pSwitch, int iIdx) - - fetch a argument associated with a switch. - - example : - - command line is : app.exe -a p1 p2 p3 -b p4 -c -d p5 - - call return - ---- ------ - cmdLine.GetArgument("-a", 0) p1 - cmdLine.GetArgument("-b", 1) returns an empty string - -------------------------------------------------------*/ - -string CCmdLine::GetArgument(const char *pSwitch, unsigned int iIdx) -{ - if (HasSwitch(pSwitch)) - { - CCmdLine::iterator theIterator; - - theIterator = find(pSwitch); - if (theIterator!=end()) - { - if ((*theIterator).second.m_strings.size() > iIdx) - { - return (*theIterator).second.m_strings[iIdx]; - } - } - } - - return ""; -} - -/*------------------------------------------------------ - int CCmdLine::GetArgumentCount(const char *pSwitch) - - returns the number of arguments found for a given switch. - - returns -1 if the switch was not found - -------------------------------------------------------*/ - -int CCmdLine::GetArgumentCount(const char *pSwitch) -{ - int iArgumentCount = -1; - - if (HasSwitch(pSwitch)) - { - CCmdLine::iterator theIterator; - - theIterator = find(pSwitch); - if (theIterator!=end()) - { - iArgumentCount = (*theIterator).second.m_strings.size(); - } - } - - return iArgumentCount; -} - } // namespace Common - } // namespace GCF -} // namespace LOFAR diff --git a/MAC/GCF/GCFCommon/src/Makefile.am b/MAC/GCF/GCFCommon/src/Makefile.am deleted file mode 100644 index dcf702ead6a8f42a1b09e231f1f21d4939808d39..0000000000000000000000000000000000000000 --- a/MAC/GCF/GCFCommon/src/Makefile.am +++ /dev/null @@ -1,13 +0,0 @@ -DOCHDRS = GCO_Defines.h - -lib_LTLIBRARIES = libgcfcommon.la - -libgcfcommon_la_DEPENDENCIES = $(LOFAR_DEPEND) - -libgcfcommon_la_SOURCES= $(DOCHDRS) \ - CmdLine.cc \ - Utils.cc \ - Thread.cc - -include $(top_srcdir)/Makefile.common - diff --git a/MAC/GCF/GCFCommon/src/Thread.cc b/MAC/GCF/GCFCommon/src/Thread.cc deleted file mode 100644 index 568ff5eb533b57e8d26095863ffb9a82c51eeec7..0000000000000000000000000000000000000000 --- a/MAC/GCF/GCFCommon/src/Thread.cc +++ /dev/null @@ -1,94 +0,0 @@ -#include <lofar_config.h> - -#include <GCF/Thread.h> - -#include <Common/CheckConfig.h> -#ifdef USE_THREADS -CHECK_CONFIG_CC(UseThreads,yes); -#else -CHECK_CONFIG_CC(UseThreads,no); -#endif - -namespace LOFAR -{ - namespace GCF - { - namespace Thread - { -#ifdef USE_THREADS - void * dummy_pvoid; - int dummy_int; - const Attributes _null_attributes; - - const Attributes & Attributes::Null () - { return _null_attributes; } - - Attributes joinable () - { return Attributes(Attributes::JOINABLE); } - - Attributes detached () - { return Attributes(Attributes::DETACHED); } - - // ----------------------------------------------------------------------- - // Thread functions - // ----------------------------------------------------------------------- - - // returns thread id of self - ThrID self () - { - return ThrID::self(); - } - - // create creates a thread - ThrID create (void * (*start)(void*), void* arg, const Attributes& attr) - { - pthread_t id = 0; - pthread_create(&id, attr, start, arg); - return ThrID(id); - } - - // Exits a thread - void exit (void* value) - { - pthread_exit(value); - } - - // Sets the sigmask for a thread - int signalMask (int how, const sigset_t* newmask, sigset_t* oldmask) - { - return pthread_sigmask(how, newmask, oldmask); - } - - // Sets a single signal in a thread's sigmask - int signalMask (int how, int sig, sigset_t* oldmask) - { - sigset_t sset; - sigemptyset(&sset); - sigaddset(&sset, sig); - return pthread_sigmask(how, &sset, oldmask); - } - - // sets the thread's cancellation state - int setCancelState (int state, int& oldstate) - { - return pthread_setcancelstate(state, &oldstate); - } - - // sets the thread's cancellation type - int setCancelType (int type, int& oldtype) - { - return pthread_setcanceltype(type, &oldtype); - } - - void testCancel () - { - pthread_testcancel(); - } - - // Class Thread::ThrID - - // Additional Declarations -#endif - } // namespace Thread - } // namespace GCF -} // namespace LOFAR diff --git a/MAC/GCF/GCFCommon/src/Utils.cc b/MAC/GCF/GCFCommon/src/Utils.cc deleted file mode 100644 index bfff4ece8b995a690270d28c4a72d497f09703a0..0000000000000000000000000000000000000000 --- a/MAC/GCF/GCFCommon/src/Utils.cc +++ /dev/null @@ -1,98 +0,0 @@ -#include <lofar_config.h> - -#include <GCF/Utils.h> -#include <stdio.h> -#include <unistd.h> - -using std::set; - -namespace LOFAR { - namespace GCF { - namespace Common { - -// -// myHostname(giveFullname) -// -string myHostname(bool giveFullName) -{ - char fullhostname[300]; - if (gethostname(fullhostname, 300) != 0) { - return ("localhost"); - } - - if (!giveFullName) { - char* dot = strchr(fullhostname, '.'); - if (dot) { - *dot='\0'; - } - } - - return (fullhostname); -} - -void convListToString(string& listString, - const list<string>& stringList) -{ - listString.clear(); - for (list<string>::const_iterator iter = stringList.begin(); - iter != stringList.end(); ++iter) { - listString += *iter; - listString += '|'; - } -} - -void convStringToList(list<string>& stringList, - const string& listString) -{ - unsigned int dataLength = listString.length(); - char data[dataLength + 1]; - memcpy(data, listString.c_str(), dataLength); - data[dataLength] = 0; - stringList.clear(); - if (dataLength > 0) { - string stringListItem; - char* pStringListItem = strtok(data, "|"); - while (pStringListItem && dataLength > 0) { - stringListItem = pStringListItem; - pStringListItem = strtok(NULL, "|"); - dataLength -= (stringListItem.size() + 1); - stringList.push_back(stringListItem); - } - } -} - -void convSetToString(string& setString, - const set<string>& stringSet) -{ - setString.clear(); - for (set<string>::const_iterator iter = stringSet.begin(); - iter != stringSet.end(); ++iter) { - setString += *iter; - setString += '|'; - } -} - -void convStringToSet(set<string>& stringSet, - const string& setString) -{ - unsigned int dataLength = setString.length(); - char data[dataLength + 1]; - memcpy(data, setString.c_str(), dataLength); - data[dataLength] = 0; - stringSet.clear(); - if (dataLength > 0) { - string stringSetItem; - char* pStringSetItem = strtok(data, "|"); - while (pStringSetItem && dataLength > 0) { - stringSetItem = pStringSetItem; - pStringSetItem = strtok(NULL, "|"); - dataLength -= (stringSetItem.size() + 1); - stringSet.insert(stringSetItem); - } - } -} - - - } // namespace Common - } // namespace GCF -} // namespace LOFAR diff --git a/MAC/GCF/GCFCommon/src/cmdline.htm b/MAC/GCF/GCFCommon/src/cmdline.htm deleted file mode 100644 index bf4256a39e84dae27dc762c4478f3a1e02ae40ef..0000000000000000000000000000000000000000 --- a/MAC/GCF/GCFCommon/src/cmdline.htm +++ /dev/null @@ -1,146 +0,0 @@ -<!--#include virtual="header.shtml" --> - -<CENTER><H3><FONT COLOR="#AOAO99"> -CCmdLine - a class for parsing command line with or without MFC -</FONT></H3></CENTER><HR> - -<!-- Author and contact details --> -This article was contributed by <A HREF="mailto:smallest@smalleranimals.com">Chris Losinger</A>. - -<!-- Environment eg NT 4.0 SP3, VC6.0 SP1 --> -<p>Environment: All</u> - -<!-- Text / source code --> -<p> -<!-- The 'p' starts a paragraph of normal text --> - -CCmdLine is a simple way to parse a command line into <i>switches</i> and <i>arguments</i>. -Ex : -<br> -<ul> -MyApp.exe -sw1 arg1 arg2 -sw2 arg3 -sw3 -sw4 -</ul> -<br> -When using CCmdLine, "-sw1", "-sw2", "-sw3" and "-sw4" are <i>switches</i> and "arg1", "arg2" and "arg3" are <i>arguments</i>. -<p> -Parsing command lines with the standard C string functions (strlen, strcpy, etc.) or even -with the CString operators is a nightmare. But, CCmdLine makes it effortless. -<p> -CCmdLine was written for use with console apps, but can be easily used in -any application which requires command-line parsing. -<p> -CCmdLine uses STL for its collection classes, so it works in MFC -and non-MFC apps. If you are using this in an MFC app, the switches -and arguments will be returned as CStrings. If you are using this in a -non-MFC app, they will be returned as STL 'string's. -<p> -<hr> -Example : - -Assume the application we're writing uses a command line that has two -required switches and two optional switches. The app should abort -if the required switches are not present and continue with default -values if the optional switches are not present. -<ul> -Sample command line : -<br> -<pre> - MyApp.exe -p1 text1 text2 -p2 "this is a big argument" -opt1 -55 -opt2 -</pre> -Switches -p1 and -p2 are required. -<br> -p1 has two arguments and p2 has one. -<br> -<br> -Switches -opt1 and -opt2 are optional. -<br> -opt1 requires a numeric argument. -<br> -opt2 has no arguments. -<br> -<br> -Also, assume that the app displays a 'help' screen if the '-h' switch -is present on the command line. -</ul> -Here's how you can use CCmdLine to handle this : -<hr> -<!-- start a block of source code --> -<PRE><TT><FONT COLOR="#990000"> -// if this is an MFC app, uncomment this line -// #include "stdafx.h" - -#include "CmdLine.h" - -void main(int argc, char **argv) -{ - // our cmd line parser object - CCmdLine cmdLine; - - // parse the command line - // use __argc and __argv, in MFC apps - if (cmdLine.SplitLine(argc, argv) < 1) - { - // no switches were given on the command line, abort - ASSERT(0); - exit(-1); - } - - // test for the 'help' case - if (cmdLine.HasSwitch("-h")) - { - show_help(); - exit(0); - } - - // StringType is CString when using MFC, else STL's 'string' - StringType p1_1, p1_2, p2_1; - - // get the required arguments - try - { - // if any of these GetArgument calls fail, - // we'll end up in the catch() block - - // get the first -p1 argument - p1_1 = cmdLine.GetArgument("-p1", 0); - - // get the second -p1 argument - p1_2 = cmdLine.GetArgument("-p1", 1); - - // get the first -p2 argument - p2_1 = cmdLine.GetArgument("-p2", 0); - - } - catch (...) - { - // one of the required arguments was missing, abort - ASSERT(0); - exit(-1); - } - - // get the optional parameters - - // GetSafeArgument does not throw exceptions, and allows for - // the use of a default value, in case the switch is not found - // convert to an int, default to '100' - int iOpt1Val = atoi( cmdLine.GetSafeArgument( "-opt1", 0, 100 ) ); - - // since opt2 has no arguments, just test for the presence of - // the '-opt2' switch - bool bOptSwitch2 = cmdLine.HasSwitch("-opt2"); - - .... and so on.... - -} -<!-- end the block of source code --> -</FONT></TT></PRE> - -<!-- demo project --> - -<p><A HREF="cmdline.zip">Download source - 5 Kb</A> - - -<!-- Date Posted and Last update (eg August 11, 1998) --> -<p>Date Posted: June 16, 1999 - -<!--#include virtual="footer.shtml" --> \ No newline at end of file diff --git a/MAC/GCF/GCFCommon/test/Makefile.am b/MAC/GCF/GCFCommon/test/Makefile.am deleted file mode 100644 index 1fb30ad619827353362c3ac76f29a79c92de1546..0000000000000000000000000000000000000000 --- a/MAC/GCF/GCFCommon/test/Makefile.am +++ /dev/null @@ -1,14 +0,0 @@ -AM_CPPFLAGS = -I$(top_srcdir)/PVSS/src - -#check_PROGRAMS = tGCFtypes - -#TESTS = tGCFtypes - -#tGCFtypes_SOURCES = $(BUILT_SOURCES) tGCFtypes.cc -#tGCFtypes_LDADD = ../src/libgcfcommon.la $(LOFAR_DEPEND) -#tGCFtypes_DEPENDENCIES = ../src/libgcfcommon.la $(LOFAR_DEPEND) - -include $(top_srcdir)/Makefile.common - - - diff --git a/MAC/GCF/PVSS/src/PVSSinfo.cc b/MAC/GCF/PVSS/src/PVSSinfo.cc index 09de5035b929fbf70dcc601bf2d68a12b9070cd4..ba7c44f377e6c8fc73f6fcf4fefa91d75ca93add 100644 --- a/MAC/GCF/PVSS/src/PVSSinfo.cc +++ b/MAC/GCF/PVSS/src/PVSSinfo.cc @@ -22,7 +22,6 @@ #include <lofar_config.h> -#include <GCF/Utils.h> #include <GCF/PVSS/PVSSinfo.h> #include <GCF/PVSS/PVSSservice.h> #include <GCF/PVSS/PVSSresult.h> diff --git a/MAC/GCF/PVSS/test/tGCFtypes.cc b/MAC/GCF/PVSS/test/tGCFtypes.cc index 36ac46cb5e5e0cbe617953a874dd357666df45c6..ec08bcc0797739cf037ed57eb3b6e40cc0ff72cc 100644 --- a/MAC/GCF/PVSS/test/tGCFtypes.cc +++ b/MAC/GCF/PVSS/test/tGCFtypes.cc @@ -26,7 +26,6 @@ #include <GCF/GCF_PVTypes.h> using namespace LOFAR; -using namespace LOFAR::GCF::Common; int main(int argc, char* argv[]) { INIT_LOGGER(argv[0]); diff --git a/MAC/GCF/PVSS/test/tPVSSservice.cc b/MAC/GCF/PVSS/test/tPVSSservice.cc index 63ad63606df696c7dbd1889dbbb2397a92d129c5..a13b8b4726cf1cd4ab7eb269845ac69eca0b5507 100644 --- a/MAC/GCF/PVSS/test/tPVSSservice.cc +++ b/MAC/GCF/PVSS/test/tPVSSservice.cc @@ -41,7 +41,7 @@ tGSAService::tGSAService(const string& name) : itsResponse(0), itsTimerPort(0) { - TM::registerProtocol(F_FSM_PROTOCOL, F_FSM_PROTOCOL_STRINGS); + registerProtocol(F_FSM_PROTOCOL, F_FSM_PROTOCOL_STRINGS); itsResponse = new Response; itsTimerPort = new GCFTimerPort(*this, "timerPort"); } diff --git a/MAC/GCF/PVSS/test/tPerformance.cc b/MAC/GCF/PVSS/test/tPerformance.cc index 0036d9813db92985292cc25773bbd2a26e34ef59..9e773e68e8f090a9393f58b3306a5d5bde91fc6c 100644 --- a/MAC/GCF/PVSS/test/tPerformance.cc +++ b/MAC/GCF/PVSS/test/tPerformance.cc @@ -42,7 +42,7 @@ tPerformance::tPerformance(const string& name) : itsResponse(0), itsTimerPort(0) { - TM::registerProtocol(F_FSM_PROTOCOL, F_FSM_PROTOCOL_STRINGS); + registerProtocol(F_FSM_PROTOCOL, F_FSM_PROTOCOL_STRINGS); itsResponse = new PerformanceResponse; itsTimerPort = new GCFTimerPort(*this, "timerPort"); } diff --git a/MAC/GCF/RTDB/configure.in b/MAC/GCF/RTDB/configure.in index fb75dfb7d5c15863ce1c2bc886c6e55a8c09ec45..06b350cc375ddb49966ce168ea6e5f51b9a21c44 100644 --- a/MAC/GCF/RTDB/configure.in +++ b/MAC/GCF/RTDB/configure.in @@ -37,7 +37,8 @@ dnl Check for LOFAR specific things dnl lofar_GENERAL lofar_PVSS(1) -lofar_INTERNAL(LCS/Common, common, , 1, Common/LofarTypes.h,,) +lofar_INTERNAL(LCS/Common, Common, , 1, Common/LofarTypes.h,,) +lofar_INTERNAL(MAC/MACIO, MACIO, , 1, MACIO/MACServiceInfo.h,,) lofar_INTERNAL(MAC/GCF/TM, gcftm, , 1, GCF/TM/GCF_Task.h,,) lofar_INTERNAL(MAC/GCF/PVSS, gcfpvss, , 1, GCF/PVSS/PVSSservice.h,,) diff --git a/MAC/GCF/RTDB/src/DP_Protocol.prot b/MAC/GCF/RTDB/src/DP_Protocol.prot index 7983a075b73d6816ba5088b16c111d9e5e4ae3ff..94ab7e8452bf65cdaa16306069a26b6e1c533d86 100644 --- a/MAC/GCF/RTDB/src/DP_Protocol.prot +++ b/MAC/GCF/RTDB/src/DP_Protocol.prot @@ -25,7 +25,7 @@ autogen definitions protocol; description = "Protocol for passing PVSSresponses to GCF-tasks"; prefix = "DP"; // for the signal names -id = "(LOFAR::GCF::TM::F_GCF_PROTOCOL+2)"; +id = "(LOFAR::MACIO::F_GCF_PROTOCOL+2)"; // specify extra include files // e.g. @@ -49,7 +49,7 @@ prelude = << PRELUDE_END // LOST_SERVER (string DPname) // -class PValue : public GCF::TM::GCFTransportable +class PValue : public MACIO::GCFTransportable { public: PValue() : _pValue(0), _unpacked(false) {}; diff --git a/MAC/GCF/RTDB/src/DPanswer.cc b/MAC/GCF/RTDB/src/DPanswer.cc index 9fe38430bba5428278fed9bc65ee8ce6832365cd..705972a60f95de5da04431d31fc9197436fcf88a 100644 --- a/MAC/GCF/RTDB/src/DPanswer.cc +++ b/MAC/GCF/RTDB/src/DPanswer.cc @@ -21,15 +21,15 @@ //# $Id$ #include <lofar_config.h> -#include <Common/LofarLogger.h> // REO +#include <Common/LofarLogger.h> -#include <GCF/TM/GCF_Event.h> +#include <MACIO/GCF_Event.h> #include <DP_Protocol.ph> #include "DPanswer.h" namespace LOFAR { + using namespace MACIO; namespace GCF { - using TM::GCFEvent; namespace RTDB { // initialise static datamember diff --git a/MAC/GCF/RTDB/src/DPanswer.h b/MAC/GCF/RTDB/src/DPanswer.h index e74ba4c31d9dd7a4bd650d50bff58b9fa16d9a73..21f3f37ba34dc0b0c2c21292e771d663b7eb9cac 100644 --- a/MAC/GCF/RTDB/src/DPanswer.h +++ b/MAC/GCF/RTDB/src/DPanswer.h @@ -23,8 +23,9 @@ #ifndef RTDB_DP_ANSWER_H #define RTDB_DP_ANSWER_H -#include <GCF/PVSS/PVSSresponse.h> +#include <MACIO/GCF_Event.h> #include <GCF/TM/GCF_Task.h> +#include <GCF/PVSS/PVSSresponse.h> namespace LOFAR { namespace GCF { @@ -58,7 +59,7 @@ private: DPanswer& operator= (const DPanswer&); // </group> - void _dispatchEvent(TM::GCFEvent& event); + void _dispatchEvent(MACIO::GCFEvent& event); // ----- datamembers ----- TM::GCFTask* itsTask; diff --git a/MAC/GCF/RTDB/src/Makefile.am b/MAC/GCF/RTDB/src/Makefile.am index ce28daf3595b83f74a92aa35557067ea4eb0c03d..b76ab945c1c88d367361986a25d7fa0b442c76c6 100644 --- a/MAC/GCF/RTDB/src/Makefile.am +++ b/MAC/GCF/RTDB/src/Makefile.am @@ -2,10 +2,10 @@ AM_CPPFLAGS = -I$(top_builddir)/include AUTOGEN = autogen SUFFIXES = .ph %.cc: %.prot - $(AUTOGEN) --writable -L $(datadir)/GCF/TM $< + $(AUTOGEN) --writable -L $(datadir)/MACIO $< %.ph: %.prot - $(AUTOGEN) --writable -L $(datadir)/GCF/TM $< + $(AUTOGEN) --writable -L $(datadir)/MACIO $< cp $*.ph $(top_builddir)/include/GCF/RTDB/ clean-local: diff --git a/MAC/GCF/RTDB/test/tDPservice.cc b/MAC/GCF/RTDB/test/tDPservice.cc index f57b9beafe5576604073f021cae3906367520f19..6cdb9f9d7c6b73049f608f266f17e17c33ef4215 100644 --- a/MAC/GCF/RTDB/test/tDPservice.cc +++ b/MAC/GCF/RTDB/test/tDPservice.cc @@ -51,8 +51,8 @@ tDPservice::tDPservice(const string& name) : { LOG_DEBUG_STR("tDPservice(" << name << ")"); - TM::registerProtocol(F_FSM_PROTOCOL, F_FSM_PROTOCOL_STRINGS); - TM::registerProtocol(DP_PROTOCOL, DP_PROTOCOL_STRINGS); + registerProtocol(F_FSM_PROTOCOL, F_FSM_PROTOCOL_STRINGS); + registerProtocol(DP_PROTOCOL, DP_PROTOCOL_STRINGS); itsTimerPort = new GCFTimerPort(*this, "timerPort"); ASSERTSTR(itsTimerPort, "Can't allocate GCFTimerPort"); diff --git a/MAC/GCF/RTDB/test/tPropertySet.cc b/MAC/GCF/RTDB/test/tPropertySet.cc index 1f82fb3e574c9c183545b199741e1e65902cd006..4b45ada527e228142b08255e07c12bea4fff0406 100644 --- a/MAC/GCF/RTDB/test/tPropertySet.cc +++ b/MAC/GCF/RTDB/test/tPropertySet.cc @@ -48,8 +48,8 @@ tPropertySet::tPropertySet(const string& name) : { LOG_DEBUG_STR("tPropertySet(" << name << ")"); - TM::registerProtocol(F_FSM_PROTOCOL, F_FSM_PROTOCOL_STRINGS); - TM::registerProtocol(DP_PROTOCOL, DP_PROTOCOL_STRINGS); + registerProtocol(F_FSM_PROTOCOL, F_FSM_PROTOCOL_STRINGS); + registerProtocol(DP_PROTOCOL, DP_PROTOCOL_STRINGS); itsTimerPort = new GCFTimerPort(*this, "timerPort"); ASSERTSTR(itsTimerPort, "Can't allocate GCFTimerPort"); diff --git a/MAC/GCF/RTDB/test/tRTDBPerformance.cc b/MAC/GCF/RTDB/test/tRTDBPerformance.cc index c1ed6f4911aa0e25cfe5020c4c39eb1730299f9f..d72c584a71f575fd11f2c829c9c2022e129e0bba 100644 --- a/MAC/GCF/RTDB/test/tRTDBPerformance.cc +++ b/MAC/GCF/RTDB/test/tRTDBPerformance.cc @@ -44,8 +44,8 @@ tPerformance::tPerformance(const string& name) : itsResponse(0), itsTimerPort(0) { - TM::registerProtocol(F_FSM_PROTOCOL, F_FSM_PROTOCOL_STRINGS); - TM::registerProtocol(DP_PROTOCOL, DP_PROTOCOL_STRINGS); + registerProtocol(F_FSM_PROTOCOL, F_FSM_PROTOCOL_STRINGS); + registerProtocol(DP_PROTOCOL, DP_PROTOCOL_STRINGS); itsResponse = new RTDBPerfResp; itsTimerPort = new GCFTimerPort(*this, "timerPort"); } diff --git a/MAC/GCF/TM/Makefile.am b/MAC/GCF/TM/Makefile.am index ea24f76b4ddf0f25285c0ba56aff679ff398ec36..57dc2dd86f3413a69b46c6f7ab6e63da5f5afb7d 100644 --- a/MAC/GCF/TM/Makefile.am +++ b/MAC/GCF/TM/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS=autogen src test include +SUBDIRS=src test include pkgextdir = $(prefix)/config/$(PACKAGE) pkgext_DATA = pkgext pkgextcppflags pkgextcxxflags pkgextldflags diff --git a/MAC/GCF/TM/autogen/Makefile.am b/MAC/GCF/TM/autogen/Makefile.am deleted file mode 100644 index 6ead8de346a2371fc9d16bc712491a9c1b6f4098..0000000000000000000000000000000000000000 --- a/MAC/GCF/TM/autogen/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -pkgdatadir = $(datadir)/GCF/TM -pkgdata_DATA = protocol.tpl - -EXTRA_DIST = $(pkgdata_DATA) - -include $(top_srcdir)/Makefile.common - diff --git a/MAC/GCF/TM/autogen/protocol.tpl b/MAC/GCF/TM/autogen/protocol.tpl deleted file mode 100644 index a82dab78dbd7ac68100cb8fa410bab35c5d8eb7b..0000000000000000000000000000000000000000 --- a/MAC/GCF/TM/autogen/protocol.tpl +++ /dev/null @@ -1,218 +0,0 @@ -[+ AutoGen5 template ph cc +] -// -[+ (dne "// ") +][+ (out-push-add "/dev/null") +] -[+ DEFINE prefix_cap +][+ IF (exist? "prefix") +][+ (get "prefix") +][+ ENDIF +][+ ENDDEF +] -[+ DEFINE prefix_ucase +][+ IF (exist? "prefix") +][+ (string-upcase (get "prefix")) +][+ ENDIF +][+ ENDDEF +] -[+ DEFINE protocol_id +][+ IF (exist? "id") +][+ (get "id") +][+ ENDIF +][+ ENDDEF +] -[+ DEFINE signal_name +][+ prefix_ucase +]_[+ (get "signal") +][+ ENDDEF +] -[+ DEFINE signal_id +][+ signal_name +]_ID[+ ENDDEF +] -[+ DEFINE cap_signal +][+ (string-substitute (string-capitalize! (get "signal")) '( "_" )' ( "" )) +][+ ENDDEF +] -[+ DEFINE event_class_name +][+ prefix_cap +][+ cap_signal +]Event[+ ENDDEF +] -[+ DEFINE event_class_decl +][+ event_class_name +] : public GCF::TM::GCFEvent[+ ENDDEF +] -[+ DEFINE protocol_name +][+ (string-upcase (base-name)) +][+ ENDDEF +] -[+ DEFINE event_class_member_type +][+ IF (*== (get "type") "]") +][+ (substring (get "type") 0 (string-index (get "type") #\[)) +][+ ELSE +][+ (get "type") +][+ ENDIF +][+ ENDDEF +] -[+ DEFINE event_class_member +][+ event_class_member_type +][+ IF (*== (get "type") "[]") +]*[+ ENDIF +] [+ (get "name") +][+ IF (and (*== (get "type") "]") (not (*== (get "type") "[]"))) +][+ (substring (get "type") (string-index (get "type") #\[) (string-length (get "type"))) +][+ ENDIF +][+ ENDDEF +] - -[+ (out-pop) +] -// -// [+ (base-name) +].[+ (suffix) +]: [+ description +] -// -// Copyright (C) 2003-2008 -// ASTRON (Netherlands Foundation for Research in Astronomy) -// P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl -// -[+ (lgpl "This program" "ASTRON" "// ") +] -// -// $Id$ -// -[+ IF (== (suffix) "cc") +] -#include "[+ (base-name) +].ph" - -using namespace LOFAR::GCF::TM; - -const char* LOFAR::[+ (base-name) +]::[+ protocol_name +]_signalnames[] = -{ - "[+ protocol_name +]: invalid signal",[+ FOR event "," +] - "[+ signal_name +]"[+ ENDFOR +] -}; - -const char* [+ protocol_name +]_errornames[] = -{ [+ FOR error "," +] - "[+ (get "msg") +]"[+ ENDFOR error +] -}; - -const struct protocolStrings LOFAR::[+ (base-name) +]::[+ protocol-name +]_STRINGS = { - [+ (count "event") +]+1, [+ (count "error") +], - LOFAR::[+ (base-name) +]::[+ protocol_name +]_signalnames, - [+ protocol_name +]_errornames -}; -[+ ELSE +] -#ifndef [+ protocol_name +]_H -#define [+ protocol_name +]_H - -[+ FOR include "" +] -#include [+ (get "include") +][+ ENDFOR +] -#include <GCF/TM/GCF_Protocols.h> -#include <Common/LofarTypes.h> -#include <string> - -namespace LOFAR -{ - namespace [+ (base-name) +] - { - -[+ (get "prelude") +] - -// -// Define protocol ID -// -enum -{ - [+ protocol_name +] = [+ protocol_id +] -}; - -// -// Define error numbers and names -// -enum -{ [+ FOR error "," +] - [+ prefix_ucase +]_[+ (get "id") +]_ERR[+ IF (= 0 (for-index)) +] = F_ERROR([+ protocol_name +], [+ (for-index) +])[+ ENDIF +][+ ENDFOR error +] -}; - -// -// Define protocol message types -// -enum -{ [+ FOR event "," +] - [+ signal_id +][+ IF (= 0 (for-index)) +] = 1[+ ENDIF +][+ ENDFOR event +] -}; - -[+ FOR event "" +] -#define [+ prefix_ucase +]_[+ (get "signal") +] F_SIGNAL([+ protocol_name +], [+ prefix_ucase +]_[+ (get "signal") +]_ID, F_[+ (get "dir")+])[+ ENDFOR event +] - -extern const char* [+ protocol_name +]_signalnames[]; // for backwards compatibility -extern const struct LOFAR::GCF::TM::protocolStrings [+ protocol-name +]_STRINGS; - -[+ ENDIF +] -[+ FOR event "" +][+ IF (= (suffix) "ph") +][+ FOR param "" +] -[+ IF (*== (get "type") "&") +][+ (error "reference types not supported") +][+ ENDIF +] -[+ IF (and (==* (get "type") "string") (> (string-length (get "type")) 6)) +][+ (error "only scalar 'string' is supported") +][+ ENDIF +][+ ENDFOR +] - class [+ event_class_decl +] - { - public: - [+ event_class_name +](GCF::TM::GCFEvent& e); - [+ event_class_name +](); - virtual ~[+ event_class_name +](); - - [+ FOR param ";" +] - [+ IF (== (get "type") "string") +]std::[+ ENDIF +][+ event_class_member +][+ IF (*== (get "type") "[]") +]; uint32 [+ (get "name") +]NOE[+ ENDIF +][+ ENDFOR +]; - - void* pack(uint32& __packsize); - - private: - [+ event_class_name +]([+ event_class_name +]&); - [+ event_class_name +]& operator= (const [+ event_class_name +]&); - - void unpack(); - }; [+ ELSE +] -[+ event_class_name +]::[+ event_class_name +](GCF::TM::GCFEvent& e) - : GCF::TM::GCFEvent(e)[+ FOR param "" +][+ IF (or (*== (get "type") "[]") (*== (get "type") "*")) +], - [+ (get "name") +](0)[+ ENDIF +][+ IF (*== (get "type") "[]") +], - [+ (get "name") +]NOE(0)[+ ENDIF +][+ ENDFOR +] -{ - unpack(); -} - -[+ event_class_name +]::[+ event_class_name +]() - : GCF::TM::GCFEvent([+ signal_name +])[+ FOR param "" +][+ IF (or (*== (get "type") "[]") (*== (get "type") "*")) +], - [+ (get "name") +](0)[+ ENDIF +][+ IF (*== (get "type") "[]") +], - [+ (get "name") +]NOE(0)[+ ENDIF +][+ ENDFOR +] -{ -} - -[+ event_class_name +]::~[+ event_class_name +]() -{ - if (_unpackDone) - {[+ FOR param "" +][+ IF (and (exist? "userdefined") (*== (get "type") "*")) +] - if ([+ (get "name") +]) delete [+ (get "name") +];[+ ENDIF +][+ ENDFOR +] - } -} - -void* [+ event_class_name +]::pack(uint32& __packsize) -{ - [+ FOR param "" +][+ IF (or (*== (get "type") "[]") (*== (get "type") "*")) +][+ IF (*== (get "type") "[]") +]if ([+ (get "name") +]NOE > 0) [+ ENDIF +]assert([+ (get "name") +]);[+ ENDIF +] - [+ ENDFOR +] - uint32 __requiredSize = [+ IF (not (exist? "noheader")) +]sizeof(signal) + sizeof(length)[+ ELSE +]0[+ ENDIF +][+ FOR param "" +] - [+ IF (exist? "userdefined") +]+ [+ (get "name") +][+ IF (*== (get "type") "*") +]->[+ ELSE +].[+ ENDIF +]getSize() - [+ ELIF (not (*== (get "type") "]")) +]+ [+ IF (== (get "type") "string") +][+ (get "name") +].length() + sizeof(uint16)[+ ELSE +]sizeof([+ (get "name") +])[+ ENDIF+] - [+ ELIF (*== (get "type") "[]") +]+ sizeof([+ (get "name") +]NOE) + ([+ (get "name") +]NOE * sizeof([+ event_class_member_type +])) - [+ ELSE +]+ sizeof([+ (get "name") +])[+ ENDIF +][+ ENDFOR +]; - - resizeBuf(__requiredSize); - uint32 __offset = __packsize = 0; - [+ IF (not (exist? "noheader")) +] - GCF::TM::GCFEvent::pack(__offset);[+ ENDIF +] - [+ FOR param "" +] - [+ IF (exist? "userdefined") +] - __offset += [+ (get "name") +][+ IF (*== (get "type") "*") +]->[+ ELSE +].[+ ENDIF +]pack(_buffer + __offset); - [+ ELIF (not (*== (get "type") "]")) +] - [+ IF (== (get "type") "string") +] - __offset += packString(_buffer + __offset, [+ (get "name") +]); - [+ ELSE +] - memcpy(_buffer + __offset, &[+ (get "name") +], sizeof([+ (get "type") +])); - __offset += sizeof([+ (get "type") +]); - [+ ENDIF +] - [+ ELIF (*== (get "type") "[]") +] - __offset += packMember(__offset, [+ (get "name") +], [+ (get "name") +]NOE, sizeof([+ event_class_member_type +])); - [+ ELSE +] - memcpy(_buffer + __offset, [+ (get "name") +], sizeof([+ (get "name") +])); - __offset += sizeof([+ (get "name") +]); - [+ ENDIF +][+ ENDFOR +] - [+ IF (= (count "param") 0) +] - // no params in this event to pack - [+ ENDIF +] - - __packsize = __offset; - return _buffer; -} - -void [+ event_class_name +]::unpack() -{ - if (length > 0) - { - [+ IF (> (count "param") 0) +] - uint32 __offset = sizeof(GCF::TM::GCFEvent); - char* __data = (char*) _base; - [+ ELSE +] - // no params in this event to unpack - [+ ENDIF +] - [+ FOR param "" +] - [+ IF (exist? "userdefined") +] - [+ IF (*== (get "type") "*") +] - [+ (get "name") +] = new [+ (substring (get "type") 0 (string-index (get "type") #\*)) +](); - [+ ENDIF +] - __offset += [+ (get "name") +][+ IF (*== (get "type") "*") +]->[+ ELSE +].[+ ENDIF +]unpack(__data + __offset); - [+ ELIF (not (*== (get "type") "]")) +] - [+ IF (== (get "type") "string") +] - __offset += GCF::TM::GCFEvent::unpackString([+ (get "name") +], __data + __offset); - [+ ELSE +] - memcpy(&[+ (get "name") +], __data + __offset, sizeof([+ (get "type") +])); - __offset += sizeof([+ (get "type") +]); - [+ ENDIF +] - [+ ELIF (*== (get "type") "[]") +] - [+ (get "name") +] = ([+ event_class_member_type +]*) unpackMember(__data, __offset, [+ (get "name") +]NOE, sizeof([+ event_class_member_type +])); - [+ ELSE +] - memcpy([+ (get "name") +], (__data + __offset), sizeof([+ (get "name") +])); - __offset += sizeof([+ (get "name") +]); - [+ ENDIF +][+ ENDFOR +] - } -}[+ ENDIF +][+ ENDFOR +] -[+ IF (= (suffix) "ph") +] - } // namespace [+ (base-name) +] -} // namespace LOFAR - - -using namespace LOFAR::[+ (base-name) +]; - -#endif -[+ ENDIF +] diff --git a/MAC/GCF/TM/configure.in b/MAC/GCF/TM/configure.in index 1fafde746ade43cc3bd0cd8ee649853677b0af19..4b3f75bcac6ffdb4508975ef8c9eb819bf0004f3 100644 --- a/MAC/GCF/TM/configure.in +++ b/MAC/GCF/TM/configure.in @@ -1,7 +1,7 @@ dnl dnl Process this file with autoconf to produce a configure script. dnl -AC_INIT(include/GCF/TM/GCF_Event.h) +AC_INIT(include/GCF/TM/GCF_Task.h) AM_CONFIG_HEADER(config.h) AM_INIT_AUTOMAKE(GCFTM, 6.1, no-define) @@ -37,16 +37,14 @@ dnl Check for LOFAR specific things dnl lofar_GENERAL lofar_INTERNAL(LCS/Common, Common, , 1, Common/LofarTypes.h,,) -lofar_INTERNAL(LCS/ACC/APS, APS, ,1, APS/ParameterSet.h,,) -lofar_INTERNAL(MAC/GCF/GCFCommon, GCFCommon, , 1, GCF/GCF_Defines.h,,) +lofar_INTERNAL(LCS/ACC/APS, APS, , 1, APS/ParameterSet.h,,) +lofar_INTERNAL(MAC/MACIO, MACIO, , 1, MACIO/MACServiceInfo.h,,) dnl dnl Output Makefiles dnl AC_OUTPUT( -autogen/Makefile src/Makefile -src/ServiceBroker/Makefile test/Makefile include/Makefile include/GCF/TM/Makefile diff --git a/MAC/GCF/TM/include/GCF/TM/EventPort.h b/MAC/GCF/TM/include/GCF/TM/EventPort.h deleted file mode 100644 index 203e31b45892153d483a62bdd10fddf41defb3dc..0000000000000000000000000000000000000000 --- a/MAC/GCF/TM/include/GCF/TM/EventPort.h +++ /dev/null @@ -1,124 +0,0 @@ -//# EventPort.h: LCS-Common-Socket based impl of a GCF TCPPort -//# -//# Copyright (C) 2007 -//# 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 LOFAR_GCF_TM_EVENTPORT_H -#define LOFAR_GCF_TM_EVENTPORT_H - -// \file EventPort.h -// LCS-Common-Socket based impl of a GCF TCPPort - -//# Never #include <config.h> or #include <lofar_config.h> in a header file! -//# Includes -#include <Common/Net/Socket.h> -#include <GCF/TM/GCF_Event.h> - -// Avoid 'using namespace' in headerfiles - -namespace LOFAR { - namespace GCF { - namespace TM { - -// \addtogroup TM -// @{ - - -// Define states for the connection fases. -enum { - EP_CREATED = 0, - EP_SEES_SB, - EP_WAIT_FOR_SB_ANSWER, - EP_KNOWS_DEST, - EP_CONNECTING, - EP_CONNECTED, - EP_DISCONNECTED -}; - -// The EventPort class is a LCS/Common Socket based TCP port to make it -// possible for CEP applications to use the MAC protocols. -class EventPort -{ -public: - - // EventPort (servicename, type, protocol, hostname) - EventPort(const string& aServiceMask, - bool aServerSocket, - int aProtocol, - const string& aHostname = "", - bool syncCommunication = false); - - // ~EventPort - ~EventPort(); - - // connect() - bool connect(); - - // send(Event*) - bool send(GCFEvent* anEvent); - - // receive() : Event - GCFEvent* receive(); - - // getStatus() - int getStatus() { return (itsStatus); } - -private: - // static receiveEvent(aSocket) - GCFEvent* receiveEvent(Socket* aSocket); - - // static sendEvent(Socket*, Event*) - void sendEvent(Socket* aSocket, - GCFEvent* anEvent); - - // _internal routines: see source code for description - string _makeServiceName(const string& aServiceMask, int32 aNumber); - bool _setupConnection(); - int32 _askBrokerThePortNumber(); - int32 _waitForSBAnswer(); - int32 _startConnectionToPeer(); - int32 _waitForPeerResponse(); - void _peerClosedConnection(); - - EventPort(); - - // Copying is not allowed - EventPort(const EventPort& that); - EventPort& operator=(const EventPort& that); - - //# --- Datamembers --- - int32 itsPort; - string itsHost; - string itsServiceName; - Socket* itsSocket; - Socket* itsListenSocket; - Socket* itsBrokerSocket; - int32 itsStatus; - bool itsSyncComm; - bool itsIsServer; -}; - - -// @} - } // namespace TM - } // namespace GCF -} // namespace LOFAR - -#endif diff --git a/MAC/GCF/TM/include/GCF/TM/GCF_Control.h b/MAC/GCF/TM/include/GCF/TM/GCF_Control.h index 5305c6df1cf3c49bcd1c6730cd5cbdfc3dcd170f..503b4e62826cb48f90d0aa4fa548387886eda76c 100644 --- a/MAC/GCF/TM/include/GCF/TM/GCF_Control.h +++ b/MAC/GCF/TM/include/GCF/TM/GCF_Control.h @@ -27,12 +27,12 @@ #include <GCF/TM/GCF_Port.h> #include <GCF/TM/GCF_PortInterface.h> #include <GCF/TM/GCF_TCPPort.h> +#include <GCF/TM/GCF_ITCPort.h> #include <GCF/TM/GCF_ETHRawPort.h> #include <GCF/TM/GCF_DevicePort.h> #include <GCF/TM/GCF_Task.h> #include <GCF/TM/GCF_Fsm.h> #include <GCF/TM/GCF_Protocols.h> -#include <GCF/TM/GCF_Event.h> #include <GCF/TM/GCF_Handler.h> #endif /* GCF_CONTROL_H */ diff --git a/MAC/GCF/TM/include/GCF/TM/GCF_DevicePort.h b/MAC/GCF/TM/include/GCF/TM/GCF_DevicePort.h index 86981b62c774c4bad3d9dadbdffa7e1f0042b44a..5fe33d4d87f827715f8b7ecd859076fbd051afb8 100644 --- a/MAC/GCF/TM/include/GCF/TM/GCF_DevicePort.h +++ b/MAC/GCF/TM/include/GCF/TM/GCF_DevicePort.h @@ -26,16 +26,13 @@ #include <GCF/TM/GCF_RawPort.h> #include <Common/lofar_string.h> -namespace LOFAR -{ - namespace GCF - { - namespace TM - { +namespace LOFAR { + class MACIO::GCFEvent; + namespace GCF { + namespace TM { // forward declaration class GCFTask; -class GCFEvent; class GTMDevice; /** diff --git a/MAC/GCF/TM/include/GCF/TM/GCF_Event.h b/MAC/GCF/TM/include/GCF/TM/GCF_Event.h deleted file mode 100644 index 074de8df18f62e662ca3641ef66aabf990601a79..0000000000000000000000000000000000000000 --- a/MAC/GCF/TM/include/GCF/TM/GCF_Event.h +++ /dev/null @@ -1,165 +0,0 @@ -//# GCF_Event.h: finite state machine events -//# -//# Copyright (C) 2002-2003 -//# 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 GCF_EVENT_H -#define GCF_EVENT_H - -#include <Common/LofarTypes.h> -#include <Common/lofar_string.h> - -namespace LOFAR { - namespace GCF { - namespace TM { - -/** - * This class is the base event data container to exchange messages between two - * tasks. - * Application tasks will have to define their own protocol by specifying the - * contents of events that are exchanged between tasks. Creating sub class from - * GCFEvent creates application (tasks) specific events. All GCFEvent sub - * classes are generally the same except for the parameters that make the event - * unique. A protocol is a collection of events where each event has a specific - * direction (IN/OUT). To create a new protocol a protocol specification file - * must be created (with extension '.prot'). The autogen utility is then used to - * convert this specification file into a header file containing GCFEvent sub - * class definitions. - * The protocol specification consists of a list of the possible events in the - * protocol each with its own parameters (or no parameters) and with the - * direction in which the event can be sent. The autogen utility is used to - * generate a header file from this definition using a template for the header - * file and the nested key-value pairs from the specification file. This header - * file contains definitions of GCFEvent sub classes, one for each event. - */ - -#define SIZEOF_EVENT(e) ((ssize_t) (sizeof((e).signal) + sizeof((e).length) + (e).length)) - -class GCFEvent -{ - public: // constructors, destructors, operators - GCFEvent() : - signal(0), length(0), _unpackDone(false), _buffer(0), - _base(0), _upperbound(0) - {} - - GCFEvent(unsigned short sig) : - signal(sig), length(0), _unpackDone(false), _buffer(0), - _base(0), _upperbound(0) - {} - - /// destructor - virtual ~GCFEvent(); - - protected: - /// special constructor it will be call by the specialised "unpack"- - /// constructor generated by autogen - GCFEvent(GCFEvent& e) : - signal(e.signal), length(e.length), _unpackDone(true), _buffer(0), - _base(&e), _upperbound(0) - {} - - private: - GCFEvent& operator= (GCFEvent& e); - - public: // member methods - - /// result of a dispatch action - enum TResult { ERROR = -1, HANDLED = 0, NOT_HANDLED = 1}; - - /** - * packs all fields of the event into the event buffer and returns its - * pointer and the number of packed bytes (output argument - */ - virtual void* pack(uint32& packsize); - - protected: // helper methods - - uint32 unpackString(string& value, char* buffer); - uint32 packString(char* buffer, const string& value); - - void resizeBuf(uint32 requiredSize); - void* unpackMember(char* data, uint32& offset, uint32& memberNOE, uint32 sizeofMemberType); - uint32 packMember(uint32 offset, const void* member, uint32 memberNOE, uint32 sizeofMemberType); - - public: // data members - /** - * @code - * Signal format - * - * 2 most significant bits indicate direction of signal: - * F_IN = 0b01 - * F_OUT = 0b10 - * F_INOUT = 0b11 (F_IN_SIGNAL | F_OUT_SIGNAL) - * - * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ - * | O | I | P | P | P | P | P | P | S | S | S | S | S | S | S | S | - * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ - * 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 - * <- I/O-><--- protocol ---------><--------- signal --------------> - * @endcode - */ - uint16 signal; // lsb contains signal id (0-255) - // msb contains protocol id (0-255) - uint32 length; // payload length of the event (thus excl. signal and length) should be <= SSIZE_MAX) - - protected: - /// indicates wether the event is unpacked or not - bool _unpackDone; - /// the packbuffer - char* _buffer; - /** before the event can be unpacked the "base" must be set, which - * points to the received raw and not unpacked data. In memory first a - * GCFEvent object (with only signal and length) is placed followed by the - * packed buffer with size "length". This is the data of the specialized event. - */ - GCFEvent* _base; - - private: - /// upperbound of the buffer, will be used by resizeBuf method - unsigned int _upperbound; - -}; - -class GCFTransportable -{ - public: - virtual ~GCFTransportable() {} - virtual unsigned int pack(char* buffer) = 0; - virtual unsigned int unpack(char* buffer) = 0; - virtual unsigned int getSize() = 0; -}; - -/** - * Macros to aid in decoding the signal field. - */ -#define F_EVT_INOUT_MASK (0xc000) -#define F_EVT_PROTOCOL_MASK (0x3f00) -#define F_EVT_SIGNAL_MASK (0x00ff) - -#define F_EVT_INOUT(e) (((e).signal & F_EVT_INOUT_MASK) >> 14) -#define F_EVT_PROTOCOL(e) (((e).signal & F_EVT_PROTOCOL_MASK) >> 8) -#define F_EVT_SIGNAL(e) ((e).signal & F_EVT_SIGNAL_MASK) - - } // namespace TM - } // namespace GCF -} // namespace LOFAR - -#endif diff --git a/MAC/GCF/TM/include/GCF/TM/GCF_Fsm.h b/MAC/GCF/TM/include/GCF/TM/GCF_Fsm.h index 9404b4b8529bfd144fa7a62fd545a98de140b267..72ee2972b827af8061a4be727f11bd8ad229c51b 100644 --- a/MAC/GCF/TM/include/GCF/TM/GCF_Fsm.h +++ b/MAC/GCF/TM/include/GCF/TM/GCF_Fsm.h @@ -23,19 +23,17 @@ #ifndef GCF_FSM_H #define GCF_FSM_H -#include <GCF/TM/GCF_Event.h> +#include <MACIO/GCF_Event.h> #include <GCF/TM/GCF_Protocols.h> #include <GCF/TM/GCF_PortInterface.h> #include <iostream> #include <cstdlib> -namespace LOFAR -{ - namespace GCF - { - namespace TM - { +namespace LOFAR { + using MACIO::GCFEvent; + namespace GCF { + namespace TM { #define TRAN(_target_) \ { \ @@ -119,7 +117,7 @@ class GCFDummyPort : public GCFPortInterface class GCFFsm { protected: // constructors && destructors - typedef GCFEvent::TResult (GCFFsm::*State)(GCFEvent& event, GCFPortInterface& port); // ptr to state handler type + typedef MACIO::GCFEvent::TResult (GCFFsm::*State)(GCFEvent& event, GCFPortInterface& port); // ptr to state handler type explicit GCFFsm (State initial) : _state(initial) {;} @@ -133,7 +131,7 @@ class GCFFsm void initFsm (); /// dispatch incomming signals to the adapted task in the current state - GCFEvent::TResult dispatch (GCFEvent& event, + MACIO::GCFEvent::TResult dispatch (GCFEvent& event, GCFPortInterface& port) { return (this->*_state)(event, port); diff --git a/MAC/GCF/TM/include/GCF/TM/GCF_Port.h b/MAC/GCF/TM/include/GCF/TM/GCF_Port.h index cde2e744f9a83c055d77472e538044781ad40b21..5fcc0b89ea5ed5df455aa05ea8cf59f8a487a705 100644 --- a/MAC/GCF/TM/include/GCF/TM/GCF_Port.h +++ b/MAC/GCF/TM/include/GCF/TM/GCF_Port.h @@ -25,12 +25,9 @@ #include <GCF/TM/GCF_PortInterface.h> -namespace LOFAR -{ - namespace GCF - { - namespace TM - { +namespace LOFAR { + namespace GCF { + namespace TM { // forward declaration class GCFTask; @@ -92,7 +89,7 @@ class GCFPort : public GCFPortInterface /** * send/recv methods */ - virtual ssize_t send (GCFEvent& event); + virtual ssize_t send (LOFAR::MACIO::GCFEvent& event); virtual ssize_t recv (void* buf, size_t count); diff --git a/MAC/GCF/TM/include/GCF/TM/GCF_PortInterface.h b/MAC/GCF/TM/include/GCF/TM/GCF_PortInterface.h index 033de3f21bcc6da156755d80b97ed5e389c4d854..89329621a8e2afc568325e543d8b3f661bce7240 100644 --- a/MAC/GCF/TM/include/GCF/TM/GCF_PortInterface.h +++ b/MAC/GCF/TM/include/GCF/TM/GCF_PortInterface.h @@ -29,6 +29,7 @@ #include <Common/LofarTypes.h> #include <Common/lofar_string.h> +#include <MACIO/GCF_Event.h> namespace LOFAR { namespace GCF { @@ -36,7 +37,6 @@ namespace LOFAR { // forward declacations class GCFTask; -class GCFEvent; /** * This is the abstract base class for all port implementations like TCP or shared @@ -72,7 +72,7 @@ public: /** * send/recv functions */ - virtual ssize_t send (GCFEvent& event) = 0; + virtual ssize_t send (LOFAR::MACIO::GCFEvent& event) = 0; virtual ssize_t recv (void* buf, size_t count) = 0; diff --git a/MAC/GCF/TM/include/GCF/TM/GCF_Protocols.h b/MAC/GCF/TM/include/GCF/TM/GCF_Protocols.h index 5ff83954d4dedfc7b49e89dc756fbf8fc63f36e4..f261f5197dd80209d563a084ea7b5da6753752de 100644 --- a/MAC/GCF/TM/include/GCF/TM/GCF_Protocols.h +++ b/MAC/GCF/TM/include/GCF/TM/GCF_Protocols.h @@ -23,36 +23,14 @@ #ifndef GCF_PROTOCOLS_H #define GCF_PROTOCOLS_H -#include <GCF/TM/GCF_Event.h> +#include <MACIO/ProtocolDefs.h> +#include <MACIO/GCF_Event.h> namespace LOFAR { + using namespace MACIO; namespace GCF { namespace TM { -/** - * Macro to encode an event's signal from the signal id, protocal an in/out direction - */ -#define F_SIGNAL(prot, sig, inout) ( (((unsigned short)(inout) & 0x3) << 14) \ - | (((unsigned short)(prot) & 0x3f) << 8) \ - | ((unsigned short)(sig) & 0xff) \ - ) - -// Macros for encoding and decoding errornumbers -#define F_ERROR(prot, num) ( (((unsigned short)(prot) & 0x3f) * 100) + (num) ) -#define F_ERR_PROTOCOL(errID) ( ((unsigned short)(errID) / 100) & 0x3f ) -#define F_ERR_NR(errID) ( (unsigned short)(errID) % 100 ) - -/** - * Define different types of signals - */ -#define F_IN 0x01 -#define F_OUT 0x02 -#define F_INOUT (F_IN | F_OUT) - -// Macros for getting the direction from a signal -#define F_INDIR(signal) ( ((unsigned short)signal >> 14) & F_IN) -#define F_OUTDIR(signal) ( ((unsigned short)signal >> 14) & F_OUT) - /** * This enum lists all framework protocols. The application protocols should * start numbering enums at F_APPLICATION_PROTOCOL, e.g.: @@ -66,12 +44,6 @@ namespace LOFAR { * enum to guarantee application global uniqueness. * */ -enum { - F_FSM_PROTOCOL = 1, // state machine protocol (encoded in msb) - F_PORT_PROTOCOL, // port connection protocol - F_GCF_PROTOCOL, // GCF specific protocol numbers start here - F_APL_PROTOCOL = 10, // APPlication specific protocol numbers start here -}; /** * F_FSM_PROTOCOL signals @@ -89,15 +61,6 @@ enum { #define F_INIT F_SIGNAL(F_FSM_PROTOCOL, F_INIT_ID, F_IN) #define F_QUIT F_SIGNAL(F_FSM_PROTOCOL, F_QUIT_ID, F_IN) -// structure for administration of signalnames and errornames. -struct protocolStrings { - unsigned short nrSignals; - unsigned short nrErrors; - const char** signalNames; - const char** errorNames; -}; - -// defined in GCF_Protocols.cc extern const char* F_FSM_PROTOCOL_names[]; extern const struct protocolStrings F_FSM_PROTOCOL_STRINGS; @@ -127,10 +90,12 @@ enum { #define F_RAW_DATA F_SIGNAL(F_PORT_PROTOCOL, F_RAW_DATA_ID, F_INOUT) #define F_ACCEPT_REQ F_SIGNAL(F_PORT_PROTOCOL, F_ACCEPT_REQ_ID, F_IN) -// defined in GCF_Protocols.cc extern const char* F_PORT_PROTOCOL_names[]; extern const struct protocolStrings F_PORT_PROTOCOL_STRINGS; +// +// Define GCFTimerEvent +// struct GCFTimerEvent : public GCFEvent { GCFTimerEvent() : GCFEvent(F_TIMER) @@ -144,11 +109,6 @@ struct GCFTimerEvent : public GCFEvent void* arg; }; -void registerProtocol (unsigned short protID, - const struct protocolStrings& protDef); -string eventName (const GCFEvent& e); -string errorName (unsigned short errorID); - } // namespace TM } // namespace GCF } // namespace LOFAR diff --git a/MAC/GCF/TM/include/GCF/TM/GCF_RawPort.h b/MAC/GCF/TM/include/GCF/TM/GCF_RawPort.h index ac4200597e3eaac19927fabf5d9a0b9fc28d4c7e..fa609ae5c78fff85158899c336ee86bb779eb5fc 100644 --- a/MAC/GCF/TM/include/GCF/TM/GCF_RawPort.h +++ b/MAC/GCF/TM/include/GCF/TM/GCF_RawPort.h @@ -23,18 +23,16 @@ #ifndef GCF_RAWPORT_H #define GCF_RAWPORT_H +#include <MACIO/GCF_Event.h> #include <GCF/TM/GCF_PortInterface.h> -#include <GCF/TM/GCF_Event.h> #include <GCF/TM/GCF_Task.h> #include <Common/lofar_string.h> #include <Common/lofar_map.h> -namespace LOFAR -{ - namespace GCF - { - namespace TM - { +namespace LOFAR { + using MACIO::GCFEvent; + namespace GCF { + namespace TM { // forward declaration class GCFPort; diff --git a/MAC/GCF/TM/include/GCF/TM/GCF_TCPPort.h b/MAC/GCF/TM/include/GCF/TM/GCF_TCPPort.h index a8fbb7e7d4f0ffa29497eb2fc1b473fb92b41961..605a65847b770c8865e13c49e5d3ad124aeac602 100644 --- a/MAC/GCF/TM/include/GCF/TM/GCF_TCPPort.h +++ b/MAC/GCF/TM/include/GCF/TM/GCF_TCPPort.h @@ -23,22 +23,21 @@ #ifndef GCF_TCPPORT_H #define GCF_TCPPORT_H +#include <Common/SystemUtil.h> #include <GCF/TM/GCF_RawPort.h> #include <GCF/TM/GCF_TimerPort.h> -#include <GCF/Utils.h> namespace LOFAR { + class MACIO::GCFEvent; namespace GCF { - namespace SB { -class GTMServiceBroker; + class ServiceBrokerTask; } namespace TM { // forward declaration class GCFTask; -class GCFEvent; class GTMTCPSocket; /** @@ -105,7 +104,7 @@ public: // GCFTCPPort specific methods unsigned int getPortNumber(); private: // helper methods - friend class SB::GTMServiceBroker; + friend class SB::ServiceBrokerTask; void serviceRegistered(unsigned int result, unsigned int portNumber); void serviceUnregistered(); void serviceInfo(unsigned int result, unsigned int portNumber, const string& host); @@ -120,14 +119,14 @@ private: string _host; unsigned int _portNumber; bool itsFixedPortNr; - SB::GTMServiceBroker* _broker; + SB::ServiceBrokerTask* _broker; }; inline void GCFTCPPort::setHostName(const string& hostname) { // assure that hostname is never filled with localname. if (hostname.empty() || hostname == "localhost") { - _host = Common::myHostname(false); + _host = myHostname(false); } else { _host = hostname; diff --git a/MAC/GCF/TM/include/GCF/TM/GCF_TimerPort.h b/MAC/GCF/TM/include/GCF/TM/GCF_TimerPort.h index 57cec240840af49b0942d8376571b366d42b3c74..7c53e95a41a4897ca3e4bbe442ad23e1ff4a71f8 100644 --- a/MAC/GCF/TM/include/GCF/TM/GCF_TimerPort.h +++ b/MAC/GCF/TM/include/GCF/TM/GCF_TimerPort.h @@ -23,12 +23,13 @@ #ifndef GCF_TIMERPORT_H #define GCF_TIMERPORT_H +#include <MACIO/GCF_Event.h> #include <GCF/TM/GCF_RawPort.h> -#include <GCF/TM/GCF_Event.h> #include <GCF/TM/GCF_Task.h> #include <Common/lofar_string.h> namespace LOFAR { + using MACIO::GCFEvent; namespace GCF { namespace TM { diff --git a/MAC/GCF/TM/include/GCF/TM/Makefile.am b/MAC/GCF/TM/include/GCF/TM/Makefile.am index 16ebbb4aa25a9409a22e297c027c4e6dd62d3dea..0eb896c63d163c4e2467087f1ecd6443de89b0dc 100644 --- a/MAC/GCF/TM/include/GCF/TM/Makefile.am +++ b/MAC/GCF/TM/include/GCF/TM/Makefile.am @@ -3,7 +3,6 @@ pkginclude_HEADERS = \ GCF_Control.h \ GCF_DevicePort.h \ GCF_ETHRawPort.h \ - GCF_Event.h \ GCF_Fsm.h \ GCF_Handler.h \ GCF_ITCPort.h \ @@ -13,8 +12,7 @@ pkginclude_HEADERS = \ GCF_RawPort.h \ GCF_Task.h \ GCF_TCPPort.h \ - GCF_TimerPort.h \ - EventPort.h + GCF_TimerPort.h include $(top_srcdir)/Makefile.common diff --git a/MAC/GCF/TM/src/GCF_Event.cc b/MAC/GCF/TM/src/GCF_Event.cc deleted file mode 100644 index cb6ac5924a0571a3bdcd6130a683ed5e7b548ec7..0000000000000000000000000000000000000000 --- a/MAC/GCF/TM/src/GCF_Event.cc +++ /dev/null @@ -1,103 +0,0 @@ -//# GCF_Event.cc: finite state machine events -//# -//# Copyright (C) 2002-2003 -//# 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 <GCF/TM/GCF_Event.h> - -using namespace std; - -namespace LOFAR { - namespace GCF { - namespace TM { - -GCFEvent::~GCFEvent() -{ - if (_buffer) { - delete [] _buffer; - } -} - -void* GCFEvent::pack(uint32& packsize) -{ - // packs the base event fields - memcpy(_buffer, &signal, sizeof(signal)); - memcpy(_buffer + sizeof(signal), &length, sizeof(length)); - packsize = sizeof(signal) + sizeof(length); - return _buffer; -} - -void GCFEvent::resizeBuf(uint32 requiredSize) -{ - // resizes the buffer if needed - if (requiredSize > _upperbound && _buffer) { - delete [] _buffer; - _buffer = 0; - } - if (!_buffer) { - _buffer = new char[requiredSize]; - _upperbound = requiredSize; - } - length = requiredSize - sizeof(length) - sizeof(signal); -} - -void* GCFEvent::unpackMember(char* data, uint32& offset, uint32& memberNOE, uint32 sizeofMemberType) -{ - void* seqPtr(0); - memcpy(&memberNOE, data + offset, sizeof(memberNOE)); - seqPtr = data + offset + sizeof(memberNOE); - offset += sizeof(memberNOE) + (memberNOE * sizeofMemberType); - return seqPtr; -} - -uint32 GCFEvent::packMember(uint32 offset, const void* member, uint32 memberNOE, uint32 sizeofMemberType) -{ - ASSERT(_buffer); - memcpy(_buffer + offset, &memberNOE, sizeof(memberNOE)); - offset += sizeof(memberNOE); - if (memberNOE > 0) { - memcpy(_buffer + offset, member, memberNOE * sizeofMemberType); - } - return (memberNOE * sizeofMemberType) + sizeof(memberNOE); -} - -uint32 GCFEvent::unpackString(string& value, char* buffer) -{ - uint16 stringLength(0); - memcpy((void *) &stringLength, buffer, sizeof(stringLength)); - value.clear(); - value.append(buffer + sizeof(stringLength), stringLength); - return stringLength + sizeof(stringLength); -} - -uint32 GCFEvent::packString(char* buffer, const string& value) -{ - uint16 stringLength(value.size()); - uint32 neededBufLength = value.size() + sizeof(stringLength); - memcpy(buffer, (void *) &stringLength, sizeof(stringLength)); - memcpy(buffer + sizeof(stringLength), (void *) value.c_str(), value.size()); - return neededBufLength; -} - } // namespace TM - } // namespace GCF -} // namespace LOFAR diff --git a/MAC/GCF/TM/src/GCF_Fsm.cc b/MAC/GCF/TM/src/GCF_Fsm.cc index c4f117ff49440d95a90ae0a69eefdbf22b11b6cd..f30b60c23c86d12dfd426b7ffb8234b80beffff7 100644 --- a/MAC/GCF/TM/src/GCF_Fsm.cc +++ b/MAC/GCF/TM/src/GCF_Fsm.cc @@ -27,6 +27,7 @@ #include <GTM_Defines.h> namespace LOFAR { + using MACIO::GCFEvent; namespace GCF { namespace TM { diff --git a/MAC/GCF/TM/src/GCF_Task.cc b/MAC/GCF/TM/src/GCF_Task.cc index 9a846ef0b0fc8c02f103b17cdba05cc2c2242a02..929d128a3cfb7df8e00b8ab221fad2650efe80df 100644 --- a/MAC/GCF/TM/src/GCF_Task.cc +++ b/MAC/GCF/TM/src/GCF_Task.cc @@ -60,8 +60,8 @@ GCFTask::GCFTask(State initial, const string& name) : GCFFsm(initial), _name(name) { // new style registration - TM::registerProtocol(F_FSM_PROTOCOL, F_FSM_PROTOCOL_STRINGS); - TM::registerProtocol(F_PORT_PROTOCOL,F_PORT_PROTOCOL_STRINGS); + registerProtocol(F_FSM_PROTOCOL, F_FSM_PROTOCOL_STRINGS); + registerProtocol(F_PORT_PROTOCOL,F_PORT_PROTOCOL_STRINGS); } // diff --git a/MAC/GCF/TM/src/Makefile.am b/MAC/GCF/TM/src/Makefile.am index 128b2a58cdb743d7be1c182e922beb4b5be61f05..516f46840e4d3cbd5e41cceeaa42ef8df12fa5d3 100644 --- a/MAC/GCF/TM/src/Makefile.am +++ b/MAC/GCF/TM/src/Makefile.am @@ -1,9 +1,4 @@ -SUBDIRS = . ServiceBroker - -AUTOGEN = autogen -SUFFIXES = .ph -%.ph: ServiceBroker/%.prot - $(AUTOGEN) --writable -L $(top_srcdir)/autogen $< +SUBDIRS = . DOCHDRS = \ GTM_Defines.h \ @@ -16,7 +11,7 @@ DOCHDRS = \ PortImpl/GTM_ETHSocket.h \ PortImpl/GTM_Device.h \ ServiceBroker/GTM_SBTCPPort.h \ - ServiceBroker/GTM_ServiceBroker.h \ + ServiceBroker/ServiceBrokerTask.h \ $(BUILT_SOURCES) lib_LTLIBRARIES = libgcftm.la @@ -25,7 +20,6 @@ libgcftm_la_SOURCES= $(DOCHDRS) \ GCF_Fsm.cc \ GCF_Protocols.cc \ GCF_Task.cc \ - GCF_Event.cc \ Port/GCF_PortInterface.cc \ Port/GCF_Port.cc \ Port/GCF_RawPort.cc \ @@ -42,25 +36,17 @@ libgcftm_la_SOURCES= $(DOCHDRS) \ PortImpl/GTM_TCPServerSocket.cc \ PortImpl/GTM_TCPSocket.cc \ ServiceBroker/GTM_SBTCPPort.cc \ - ServiceBroker/GTM_ServiceBroker.cc \ - SB_Protocol.cc + ServiceBroker/ServiceBrokerTask.cc libgcftm_la_CPPFLAGS=-I$(top_srcdir)/src/ServiceBroker libgcftm_la_CXXFLAGS=-fmessage-length=0 -BUILT_SOURCES = SB_Protocol.ph +BUILT_SOURCES = -EXTRA_DIST = $(sysconf_DATA) +EXTRA_DIST = $(sysconf_DATA) -sysconf_DATA = \ - mac.log_prop - -%.log_prop: %.log_prop.in - cp $< $@ +sysconf_DATA = mac.log_prop -clean-local: - rm -f *.ph - include $(top_srcdir)/Makefile.common diff --git a/MAC/GCF/TM/src/Port/GCF_Port.cc b/MAC/GCF/TM/src/Port/GCF_Port.cc index b84838956c1c592fec61a041ec0bdf382e2bae42..f90eceaf1aa75c3621228bed718908d366da7465 100644 --- a/MAC/GCF/TM/src/Port/GCF_Port.cc +++ b/MAC/GCF/TM/src/Port/GCF_Port.cc @@ -23,12 +23,12 @@ #include <lofar_config.h> #include <Common/LofarLogger.h> +#include <APS/ParameterSet.h> +#include <MACIO/GCF_Event.h> #include <GCF/TM/GCF_Port.h> #include <GCF/TM/GCF_RawPort.h> #include <GCF/TM/GCF_Task.h> -#include <GCF/TM/GCF_Event.h> #include <GCF/TM/GCF_Protocols.h> -#include <APS/ParameterSet.h> #include <GTM_Defines.h> #include <GCF/TM/GCF_TCPPort.h> diff --git a/MAC/GCF/TM/src/PortImpl/GCF_ITCPort.cc b/MAC/GCF/TM/src/PortImpl/GCF_ITCPort.cc index fbf611b3b8104fd91df34089d823c2ba92ed6b46..1801a1eb067f074d6e653c3282b5600c368bce0a 100644 --- a/MAC/GCF/TM/src/PortImpl/GCF_ITCPort.cc +++ b/MAC/GCF/TM/src/PortImpl/GCF_ITCPort.cc @@ -23,12 +23,13 @@ #include <lofar_config.h> #include <Common/LofarLogger.h> +#include <MACIO/GCF_Event.h> #include <GCF/TM/GCF_Protocols.h> #include <GCF/TM/GCF_Task.h> -#include <GCF/TM/GCF_Event.h> #include <GCF/TM/GCF_ITCPort.h> namespace LOFAR { + using MACIO::GCFEvent; namespace GCF { namespace TM { diff --git a/MAC/GCF/TM/src/PortImpl/GCF_TCPPort.cc b/MAC/GCF/TM/src/PortImpl/GCF_TCPPort.cc index 3e47d67699542e8f4c5c6b0493d1b04a338ba6b6..14ca9c3bc4cda0ffc34b17c63d6e2594104f3406 100644 --- a/MAC/GCF/TM/src/PortImpl/GCF_TCPPort.cc +++ b/MAC/GCF/TM/src/PortImpl/GCF_TCPPort.cc @@ -24,13 +24,14 @@ #include <Common/LofarLogger.h> #include <Common/SystemUtil.h> +#include <MACIO/SB_Protocol.ph> #include <GCF/TM/GCF_TCPPort.h> #include <GCF/TM/GCF_Task.h> #include <GCF/TM/GCF_Protocols.h> #include <APS/ParameterSet.h> #include "GTM_TCPServerSocket.h" -#include <ServiceBroker/GTM_ServiceBroker.h> -#include <ServiceBroker/GSB_Defines.h> +#include <ServiceBroker/ServiceBrokerTask.h> +//#include <ServiceBroker/GSB_Defines.h> #include <GTM_Defines.h> #include <errno.h> @@ -93,7 +94,7 @@ GCFTCPPort::~GCFTCPPort() if (_broker) { _broker->deletePort(*this); - GTMServiceBroker::release(); + ServiceBrokerTask::release(); _broker = 0; } } @@ -185,7 +186,7 @@ bool GCFTCPPort::open() // Service name is set, use it to resolve host+port and connect. if (!_broker) { - _broker = GTMServiceBroker::instance(); + _broker = ServiceBrokerTask::instance(); } ASSERT(_broker); _broker->getServiceinfo(*this, remoteServiceName, _host); @@ -206,7 +207,7 @@ bool GCFTCPPort::open() // Note: service is NOT registered at service broker!!! } else { // portnumber not overruled by user so ask SB for a portnumber - _broker = GTMServiceBroker::instance(); + _broker = ServiceBrokerTask::instance(); ASSERT(_broker); _broker->registerService(*this); // a (dis)connect event will be scheduled @@ -220,7 +221,7 @@ bool GCFTCPPort::open() // serviceRegistered(resultToReturn, portNr) // // Log what port we use and try to open and connect to that port. -// Note: Is also called by the GTM_ServiceBroker +// Note: Is also called by the ServiceBrokerTask // void GCFTCPPort::serviceRegistered(unsigned int result, unsigned int portNumber) { @@ -251,7 +252,7 @@ void GCFTCPPort::serviceRegistered(unsigned int result, unsigned int portNumber) // // Ask servicebroker for a portnumber and try to open the port(listener) // -// Note: Is also called by the GTM_ServiceBroker +// Note: Is also called by the ServiceBrokerTask void GCFTCPPort::serviceInfo(unsigned int result, unsigned int portNumber, const string& host) { ASSERT(SAP == getType()); @@ -285,7 +286,7 @@ void GCFTCPPort::serviceInfo(unsigned int result, unsigned int portNumber, const } } -// Note: Is also called by the GTM_ServiceBroker +// Note: Is also called by the ServiceBrokerTask void GCFTCPPort::serviceGone() { _host = myHostname(false); @@ -368,7 +369,7 @@ bool GCFTCPPort::close() } // make sure a single server port is unregistered to that is can be 'connect'ed again. // NOTE: 050308 this is neccesary for EventPort but conflicts with the ServiceBroker - // functionality in GSB_Controller.cc. this is than 0x0. + // functionality in GSB_Controller.cc. this is then 0x0. // if (getType() == SPP) { // _broker->deletePort(*this); // } diff --git a/MAC/GCF/TM/src/PortImpl/GTM_Device.h b/MAC/GCF/TM/src/PortImpl/GTM_Device.h index 56d5cf35e93f7630d0733fe6695d7ae816687004..1b8df67b3469a137c539a2f44bfc724d4a543858 100644 --- a/MAC/GCF/TM/src/PortImpl/GTM_Device.h +++ b/MAC/GCF/TM/src/PortImpl/GTM_Device.h @@ -24,7 +24,7 @@ #define GTM_DEVICE_H #include <unistd.h> -#include <GCF/TM/GCF_Event.h> +//#include <MACIO/GCF_Event.h> #include "GTM_File.h" #include <Common/lofar_string.h> diff --git a/MAC/GCF/TM/src/PortImpl/GTM_ETHSocket.h b/MAC/GCF/TM/src/PortImpl/GTM_ETHSocket.h index 205853998a486ea9790389b629ad99b940d06c90..414dbec164097b8d370761bec715b872f34dd559 100644 --- a/MAC/GCF/TM/src/PortImpl/GTM_ETHSocket.h +++ b/MAC/GCF/TM/src/PortImpl/GTM_ETHSocket.h @@ -24,7 +24,7 @@ #define GTM_ETHSOCKET_H #include <unistd.h> -#include <GCF/TM/GCF_Event.h> +//#include <MACIO/GCF_Event.h> #include "GTM_File.h" #include <linux/if_packet.h> diff --git a/MAC/GCF/TM/src/PortImpl/GTM_File.h b/MAC/GCF/TM/src/PortImpl/GTM_File.h index 227431641590fc5a034722911c7768de8d798fc0..e45f820c3476da7f35fad2a706cf0af366416d57 100644 --- a/MAC/GCF/TM/src/PortImpl/GTM_File.h +++ b/MAC/GCF/TM/src/PortImpl/GTM_File.h @@ -24,14 +24,12 @@ #define GTM_FILE_H #include <unistd.h> -#include <GCF/TM/GCF_Event.h> +#include <MACIO/GCF_Event.h> -namespace LOFAR -{ - namespace GCF - { - namespace TM - { +namespace LOFAR { + using namespace MACIO; + namespace GCF { + namespace TM { // forward declaration class GTMFileHandler; @@ -88,7 +86,7 @@ class GTMFile using namespace LOFAR::GCF::TM; -inline GCFEvent::TResult GTMFile::dispatch (GCFEvent& event) +inline LOFAR::MACIO::GCFEvent::TResult GTMFile::dispatch (LOFAR::MACIO::GCFEvent& event) { return _port.dispatch(event); } diff --git a/MAC/GCF/TM/src/ServiceBroker/EventPort.cc b/MAC/GCF/TM/src/ServiceBroker/EventPort.cc deleted file mode 100644 index 9c6bda6d3974a128de720700bdbbd962e96e924e..0000000000000000000000000000000000000000 --- a/MAC/GCF/TM/src/ServiceBroker/EventPort.cc +++ /dev/null @@ -1,436 +0,0 @@ -//# EventPort.cc: (raw) socket based implementation to exchange Events -//# -//# Copyright (C) 2007 -//# 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$ - -//# Always #include <lofar_config.h> first! -#include <lofar_config.h> - -//# Includes -#include <Common/LofarLogger.h> -#include <Common/StringUtil.h> -#include <Common/hexdump.h> -#include <GCF/Utils.h> -#include <GCF/GCF_ServiceInfo.h> -#include <GCF/TM/GCF_Event.h> -#include <GCF/TM/EventPort.h> -#include <SB_Protocol.ph> -#include "GSB_Defines.h" - -namespace LOFAR { - namespace GCF { - namespace TM { - -// Note: the difference with GCF-ports is that this port is only based on the -// LCS/Common sockets and does therefor not depend on GCF_Tasks. - -static char receiveBuffer[24*4096]; - -// -// EventPort (name, type, protocol) -// -EventPort::EventPort(const string& aServiceMask, - bool aServerSocket, - int aProtocol, - const string& aHostname, - bool syncCommunication) : - itsPort (0), - itsHost (aHostname), - itsServiceName (_makeServiceName(aServiceMask, 0)), - itsSocket (0), - itsListenSocket (0), - itsBrokerSocket (0), - itsStatus (EP_CREATED), - itsSyncComm (syncCommunication), - itsIsServer (aServerSocket) -{ - if (itsHost.empty() || itsHost == "localhost") { - itsHost = Common::myHostname(false); - } - - // We always need a socket to the serviceBroker for getting a portnumber we may use. - itsBrokerSocket = new Socket("ServiceBroker", itsHost, toString(MAC_SERVICEBROKER_PORT)); - ASSERTSTR(itsBrokerSocket, "can't allocate socket to serviceBroker"); - - _setupConnection(); -} - -// -// ~EventPort -// -EventPort::~EventPort() -{ - if (itsSocket) { - itsSocket->shutdown(); - delete itsSocket; - }; - - if (itsListenSocket) { - itsListenSocket->shutdown(); - delete itsListenSocket; - }; - - if (itsBrokerSocket) { - itsBrokerSocket->shutdown(); - delete itsBrokerSocket; - }; -} - -// -// connect() -// -bool EventPort::connect() -{ - return (_setupConnection()); -} - -// -// _setupConnection() -// -// Depending of the stage that is already reached in the connection process, this -// function tries to continue from there till a connection is made. -// -// Note: all error handling is in this 'overall' routine to keep the subroutines -// that are called as easy as possible. -// -bool EventPort::_setupConnection() -{ - // test most likely state first for performance - if (itsStatus == EP_CONNECTED) { - return (true); - } - - // not connected, so we left somewhere in the connection sequence, pick the sequence - // at the right place. - - // No connection to the SB yet? - if (itsStatus == EP_CREATED) { - LOG_DEBUG ("Trying to make connection with the ServiceBroker"); - itsBrokerSocket->connect(itsSyncComm ? -1 : 500); // try to connect, wait forever or 0.5 sec - if (!itsBrokerSocket->isConnected()) { // failed? - if (itsSyncComm) { - ASSERTSTR(false, "Cannot connect to the ServiceBroker"); - } - return (false); // async socket allows failures. - } - itsStatus = EP_SEES_SB; - itsBrokerSocket->setBlocking(itsSyncComm); // no other tasks, do rest blocking - } - - // second step: ask service broker the portnumber - if (itsStatus == EP_SEES_SB) { - itsStatus += _askBrokerThePortNumber(); - if (itsStatus <= EP_SEES_SB) { - if (itsSyncComm) { - ASSERTSTR(false, "Cannot contact the ServiceBroker"); - } - return (false); // async socket allows failures. - } - } - - // third step: wait for the answer of the SB - if (itsStatus == EP_WAIT_FOR_SB_ANSWER) { - itsStatus += _waitForSBAnswer(); - if (itsStatus <= EP_WAIT_FOR_SB_ANSWER) { - if (itsSyncComm) { - ASSERTSTR(false, "Cannot contact the other party"); - } - return (false); // async socket allows failures. - } - } - - // fourth step: try to connect to the real socket. - if (itsStatus == EP_KNOWS_DEST) { - itsStatus += _startConnectionToPeer(); - if (itsStatus <= EP_KNOWS_DEST) { - if (itsSyncComm) { - ASSERTSTR(false, "Cannot contact the other party"); - } - return (false); // async socket allows failures. - } - } - - // fifth step: wait for response of connection request - if (itsStatus == EP_CONNECTING) { - itsStatus += _waitForPeerResponse(); - if (itsStatus <= EP_CONNECTING) { - if (itsSyncComm) { - ASSERTSTR(false, "Cannot contact the other party"); - } - return (false); // async socket allows failures. - } - } - - return (itsStatus == EP_CONNECTED); -} - -// -// send a message to the message broker requesting a portnumber -// -int32 EventPort::_askBrokerThePortNumber() -{ - // construct the question. - if (itsIsServer) { - // tell SB the name of our service - SBRegisterServiceEvent request; - request.seqnr = 5; // or any other number - request.servicename = itsServiceName; - - // send question - sendEvent(itsBrokerSocket, &request); - } - else { // client socket - // ask SB the portnumber of the (operational) service. - SBGetServiceinfoEvent request; - request.seqnr = 5; // or any other number - request.servicename = itsServiceName; - request.hostname = itsHost; - - // send question - sendEvent(itsBrokerSocket, &request); - } - - return (1); // goto next state -} - -// -// waitForSBAnswer() -// -// Wait until we received a response from the service broker. -// -int32 EventPort::_waitForSBAnswer() -{ - // wait for response - GCFEvent* answerEventPtr(receiveEvent(itsBrokerSocket)); - if (!answerEventPtr) { - return (0); // stay in this mode - } - - // a complete event was received, handle it. - if (itsIsServer) { - SBServiceRegisteredEvent response(*answerEventPtr); - if (response.result != 0) { - LOG_ERROR_STR("Service " << itsServiceName << " is already on the air."); - return (-1); // next time ask again - } - itsPort = response.portnumber; - LOG_DEBUG_STR("Service " << itsServiceName << " will be at port " << itsPort); - // note: keep connection with Broker so he knows we are on the air. - } - else { // client socket - SBServiceInfoEvent response(*answerEventPtr); - if (response.result != 0) { - LOG_ERROR_STR("Service " << itsServiceName << " is unknown"); - return (-1); // next time ask again - } - itsPort = response.portnumber; - LOG_DEBUG_STR("Service " << itsServiceName << " is at port " << itsPort); - - // close connection with Broker. - itsBrokerSocket->shutdown(); - itsBrokerSocket = 0; - } - - return (1); // continue with next stage -} - -// -// _startConnectionToPeer() -// -int32 EventPort::_startConnectionToPeer() -{ - // Finally we can make the real connection - if (itsIsServer) { - LOG_DEBUG_STR ("Opening listener on port " << itsPort); - itsListenSocket = new Socket(itsServiceName, toString(itsPort), Socket::TCP); - itsSocket = itsListenSocket->accept(itsSyncComm ? -1 : 500); - } - else { - LOG_DEBUG_STR ("Trying to make connection with " << itsServiceName); - itsSocket = new Socket(itsServiceName, itsHost, toString(itsPort), Socket::TCP); - itsSocket->connect(itsSyncComm ? -1 : 500); // try to connect, wait forever or 0.5 sec - } - return (1); -} - -// -// _waitForPeerResponse() -// -int32 EventPort::_waitForPeerResponse() -{ - // connection (already) successful? - if (itsSocket->isConnected()) { - itsSocket->setBlocking(itsSyncComm); - return (1); - } - - // do a retry - if (itsIsServer) { - itsSocket = itsListenSocket->accept(itsSyncComm ? -1 : 500); - } - else { - itsSocket->connect(itsSyncComm ? -1 : 500); // try to connect, wait forever or 0.5 sec - } - - return (0); -} - -// -// _peerClosedConnection() -// -void EventPort::_peerClosedConnection() -{ - // yeah.... what is wise to do here???? - ASSERTSTR(false, "Other side closed the connection, bailing out"); - -} - -// -// send(Event*) -// -bool EventPort::send(GCFEvent* anEvent) -{ - if (!_setupConnection()) { - return (false); - } - - sendEvent(itsSocket, anEvent); - return (true); -} - -// -// receive() : Event -// -GCFEvent* EventPort::receive() -{ - return (_setupConnection() ? receiveEvent(itsSocket) : 0L); -} - -// -// _makeServiceName(mask, number) -// -string EventPort::_makeServiceName(const string& aServiceMask, int32 aNumber) -{ - // NOTE: this code is copied from GCF/TM/Port/GCF_PortInterface.cc - string instanceNrStr; - if (aNumber) { - instanceNrStr = toString(aNumber); - } - - return(formatString(aServiceMask.c_str(), instanceNrStr.c_str())); -} - -// -------------------- STATIC FUNCTIONS -------------------- -// -// static sendEvent(Socket*, Event*) -// -void EventPort::sendEvent(Socket* aSocket, - GCFEvent* anEvent) -{ - // Serialize the message and write buffer to port - uint32 packSize; - void* buf = anEvent->pack(packSize); - int32 btsWritten = aSocket->write(buf, packSize); - ASSERTSTR(btsWritten == (int32)packSize, - "Only " << btsWritten << " of " << packSize << " bytes written"); -} - -// -// static receiveEvent(aSocket) -// -GCFEvent* EventPort::receiveEvent(Socket* aSocket) -{ - static int32 gBtsToRead(0); - static int32 gTotalBtsRead(0); - static int32 gReadState(0); - - GCFEvent* header ((GCFEvent*) &receiveBuffer[0]); - int32 btsRead(0); - - // first read signal (= eventtype) field - if (gReadState == 0) { - btsRead = aSocket->read((void*) &(header->signal), sizeof(header->signal)); - if (btsRead < 0) { - _peerClosedConnection(); - return (0); - } - if (btsRead != sizeof(header->signal)) { - if (aSocket->isBlocking()) { - ASSERTSTR(false, "Event-type was not received"); - } - return (0); // async socket allows failures. - } - gReadState++; - } - - // next read the length of the rest of the message - if (gReadState == 1) { - btsRead = aSocket->read((void*) &(header->length), sizeof(header->length)); - if (btsRead < 0) { - _peerClosedConnection(); - return (0); - } - if (btsRead != sizeof(header->length)) { - if (aSocket->isBlocking()) { - ASSERTSTR(false, "Event-length was not received"); - } - return (0); // async socket allows failures. - } - gReadState++; - gBtsToRead = header->length; // get size of data part - } - - // finally read the datapart of the event - if (gReadState == 2) { - LOG_DEBUG_STR("Still " << gBtsToRead << " bytes of data to get"); - - btsRead = 0; - if (gBtsToRead) { - btsRead = aSocket->read(&receiveBuffer[sizeof(GCFEvent) + gTotalBtsRead], gBtsToRead); - if (btsRead < 0) { - _peerClosedConnection(); - return (0); - } - if (btsRead != gBtsToRead) { - if (aSocket->isBlocking()) { - ASSERTSTR(false, "Only " << btsRead << " bytes of msg read: " << gBtsToRead); - } - return (0); // async socket allow failures - } - } - - if (btsRead == gBtsToRead) { // everything received? - // reset own admin - gReadState = 0; - gTotalBtsRead = 0; - gBtsToRead = 0; -// hexdump(receiveBuffer, sizeof(GCFEvent) + header->length); - return (header); - } - } - - // not all information received yet - return (0L); -} - - - } // namespace TM - } // namespace GCF -} // namespace LOFAR diff --git a/MAC/GCF/TM/src/ServiceBroker/GSB_Controller.cc b/MAC/GCF/TM/src/ServiceBroker/GSB_Controller.cc deleted file mode 100644 index b7600301350fa45b28424003139080d7d25c91d2..0000000000000000000000000000000000000000 --- a/MAC/GCF/TM/src/ServiceBroker/GSB_Controller.cc +++ /dev/null @@ -1,582 +0,0 @@ -//# GSB_Controller.cc: -//# -//# Copyright (C) 2002-2003 -//# 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/lofar_fstream.h> -#include <APS/ParameterSet.h> -#include <GCF/Utils.h> -#include <GCF/TM/GCF_Protocols.h> -#include <GCF/GCF_ServiceInfo.h> -#include <../SB_Protocol.ph> -#include <GSB_Defines.h> -#include "GSB_Controller.h" - -namespace LOFAR { - namespace GCF { - using namespace TM; - namespace SB { - -static string sSBTaskName("ServiceBrokerTask"); - -// -// xxx -// -GSBController::GSBController() : - GCFTask((State)&GSBController::initial, sSBTaskName), - itsServiceList(), - itsListener(), - itsAdminFile(), - itsLowerLimit(0), - itsUpperLimit(0), - itsNrPorts(0), - itsNrFreePorts(0) -{ - // register the protocol for debugging purposes -// registerProtocol(SB_PROTOCOL, SB_PROTOCOL_signalnames); - TM::registerProtocol(SB_PROTOCOL, SB_PROTOCOL_STRINGS); - - // allocate the listener port - itsListener.init(*this, MAC_SVCMASK_SERVICEBROKER, - GCFPortInterface::MSPP, SB_PROTOCOL); - - // read the port range I may use - readRanges(); - - // load previous registration if any - loadAdministration (itsAdminFile); -} - -// -// xxx -// -GSBController::~GSBController() -{ - LOG_DEBUG("Deleting ServiceBroker"); -} - -// -// initial(event, port) -// -GCFEvent::TResult GSBController::initial(GCFEvent& event, GCFPortInterface& port) -{ - GCFEvent::TResult status = GCFEvent::HANDLED; - - switch (event.signal) { - case F_INIT: - break; - - case F_ENTRY: - ASSERTSTR(itsListener.open(), "Cannot open listener. Another ServiceBroker already running?"); - break; - - case F_CONNECTED: - // Once listener is opened I am operational - TRAN(GSBController::operational); - break; - - case F_DISCONNECTED: - if (&port == &itsListener) - ASSERTSTR(false, "Cannot open listenerport, another ServiceBroker is running?"); - break; - - default: - status = GCFEvent::NOT_HANDLED; - break; - } - - return (status); -} - -// -// operational(event, port) -// -GCFEvent::TResult GSBController::operational(GCFEvent& event, GCFPortInterface& port) -{ - LOG_TRACE_FLOW_STR ("operation:" << eventName(event) << "@" << port.getName()); - - GCFEvent::TResult status = GCFEvent::HANDLED; - - switch (event.signal) { - case F_ENTRY: - itsListener.setTimer(300.0); // to cleanup not-reclaimed portnumbers - break; - - case F_TIMER: - cleanupOldRegistrations(); - break; - - case F_CONNECTED: - break; - - case F_ACCEPT_REQ: - acceptConnectRequest(); - break; - - case F_DISCONNECTED: - if (&port != &itsListener) { - port.close(); - } - // else //TODO: find out this can realy happend - break; - - case F_CLOSED: - releasePort(&port); - break; - - case SB_REGISTER_SERVICE: { - SBRegisterServiceEvent request(event); - SBServiceRegisteredEvent response; - response.seqnr = request.seqnr; - - // Is Service already registered? - if (findService(request.servicename, true)) { - LOG_ERROR(formatString("Service %s already exist", - request.servicename.c_str())); - response.result = SB_SERVICE_ALREADY_EXIST; - } - else { - uint16 portNr = claimPortNumber(request.servicename, &port); - if (portNr > 0) { - response.result = SB_NO_ERROR; - response.portnumber = portNr; - } - else { - LOG_ERROR(formatString ("All available port numbers are claimed (%s)", - request.servicename.c_str())); - response.result = SB_NO_FREE_PORTNR; - } - } - port.send(response); - break; - } - - case SB_UNREGISTER_SERVICE: { - SBUnregisterServiceEvent request(event); - SBServiceUnregisteredEvent response; - response.seqnr = request.seqnr; - - releaseService(request.servicename); - - response.result = SB_NO_ERROR; - port.send(response); - break; - } - - case SB_GET_SERVICEINFO: { - SBGetServiceinfoEvent request(event); - SBServiceInfoEvent response; - response.seqnr = request.seqnr; - - uint16 portNr = findService(request.servicename, true); - if (portNr) { - LOG_INFO(formatString ("Serviceinfo for %s is %d", - request.servicename.c_str(), portNr)); - response.portnumber = portNr; - response.hostname = Common::myHostname(false); - response.result = SB_NO_ERROR; - } - else { - LOG_ERROR(formatString ("Unknown service: %s", - request.servicename.c_str())); - response.result = SB_UNKNOWN_SERVICE; - } - port.send(response); - break; - } - - case SB_REREGISTER_SERVICE: { - SBReregisterServiceEvent request(event); - SBServiceReregisteredEvent response; - response.seqnr = request.seqnr; - response.servicename = request.servicename; - response.result = reRegisterService(request.servicename, request.portnumber, &port); - port.send(response); - break; - } - default: - status = GCFEvent::NOT_HANDLED; - break; - } - - return status; -} - -// -// acceptConnectRequest -// -void GSBController::acceptConnectRequest() -{ - LOG_DEBUG ("A new SB client tries to connect. Accept!!!"); - - GTMSBTCPPort* pNewSBClientPort = new GTMSBTCPPort(); - ASSERT(pNewSBClientPort); - - pNewSBClientPort->init(*this, "newClient", GCFPortInterface::SPP, SB_PROTOCOL); - itsListener.accept(*pNewSBClientPort); -} - -// -// readRanges -// -void GSBController::readRanges() -{ - ASSERTSTR (ACC::APS::globalParameterSet()->isDefined("firstPortNumber") && - ACC::APS::globalParameterSet()->isDefined("lastPortNumber"), - "Ranges not specified in ParameterSet"); - - itsLowerLimit = ACC::APS::globalParameterSet()->getUint16("firstPortNumber"); - itsUpperLimit = ACC::APS::globalParameterSet()->getUint16("lastPortNumber"); - - ASSERTSTR(itsLowerLimit < itsUpperLimit, "Invalid portnumber range specified"); - ASSERTSTR(itsLowerLimit > 1023, "Portnumbers below 1024 may not be used"); - - itsNrPorts = itsUpperLimit - itsLowerLimit; - ASSERTSTR(itsNrPorts < 1000, - "Range too large, broker can manage only 1000 ports"); - - itsServiceList = vector<TServiceInfo> (itsNrPorts); - for (uint32 idx = 0; idx < itsNrPorts; idx++) { - itsServiceList[idx].portNumber = 0; - itsServiceList[idx].serviceName = ""; - itsServiceList[idx].ownerPort = 0; - } - - itsNrFreePorts = itsNrPorts; - - LOG_INFO (formatString("Managing portnumbers %d till %d (%d)", - itsLowerLimit, itsUpperLimit, itsNrPorts)); - - // Finally read or construct name of adminfile. - if (!ACC::APS::globalParameterSet()->isDefined("adminFile")) { - itsAdminFile = "./SB.admin"; - } - else { - itsAdminFile = ACC::APS::globalParameterSet()->getString("adminFile"); - } - LOG_INFO_STR ("Using file " << itsAdminFile << " for administration"); -} - -// -// claimPortNumber(servicename, port) -// -uint16 GSBController::claimPortNumber(const string& aServiceName, - GCFPortInterface* aPort) -{ - int32 idx = 0; - - if (!itsNrFreePorts) { // must have room. - return (0); - } - - // note: an loaded registration may already be present, reuse that address - uint16 portNr = findService(aServiceName, false); - if (portNr) { - idx = portNr2Index(portNr); - } - else { - // no old loaded entry available, search free place - while (idx < itsNrPorts && itsServiceList[idx].portNumber != 0) { - idx++; - } - itsNrFreePorts--; - ASSERTSTR (idx < itsNrPorts, "Major programming error in 'claimPortNumber'!"); - } - - // assign port to service - itsServiceList[idx].portNumber = index2PortNr(idx); - itsServiceList[idx].serviceName = aServiceName; - itsServiceList[idx].ownerPort = aPort; - - // notify user. - LOG_INFO(formatString ("Portnumber %d assigned to '%s'.", - itsServiceList[idx].portNumber, aServiceName.c_str())); - LOG_INFO_STR ("Managing " << itsNrPorts - itsNrFreePorts << " ports now"); - saveAdministration (itsAdminFile); // to survive crashes - - return (itsServiceList[idx].portNumber); -} - -// -// reRegisterService(servicename, portnr) -// -TSBResult GSBController::reRegisterService(const string& servicename, uint16 oldPortNr, - GCFPortInterface* thePort) -{ - int32 idx = 0; - int32 nrElems2Check = itsNrPorts - itsNrFreePorts;// prevent checking whole array - - while (idx < itsNrPorts && nrElems2Check > 0) { - if (itsServiceList[idx].portNumber) { - nrElems2Check--; - if (itsServiceList[idx].serviceName == servicename) { - if (!itsServiceList[idx].ownerPort && itsServiceList[idx].portNumber == oldPortNr) { - itsServiceList[idx].ownerPort = thePort; - LOG_INFO_STR("Service " << servicename << " confirmed at " << oldPortNr); - saveAdministration (itsAdminFile); // to survive crashes - return (SB_NO_ERROR); - } - else { - LOG_ERROR_STR("Recovering of service " << servicename << " at " << - oldPortNr << " not possible. Service was at " << - itsServiceList[idx].portNumber); - return (SB_CANT_RECOVER); - } - } - } - idx++; - } - - // service not in our admin anymore, try to fullfill the question. - idx = portNr2Index(oldPortNr); // convert portnr to array index - if (itsServiceList[idx].ownerPort == 0) { // still free? - // assign port to service - itsServiceList[idx].portNumber = oldPortNr; - itsServiceList[idx].serviceName = servicename; - itsServiceList[idx].ownerPort = thePort; - itsNrFreePorts--; - - LOG_INFO_STR("Service " << servicename << " reregistered at " << oldPortNr); - saveAdministration (itsAdminFile); // to survive crashes - return (SB_NO_ERROR); - } - - LOG_ERROR_STR("Recovering of service " << servicename << " at " << - oldPortNr << " not possible. Portnr taken by " << - itsServiceList[idx].serviceName); - return (SB_CANT_RECOVER); -} - -// -// releaseService(servicename) -// -void GSBController::releaseService(const string& aServiceName) -{ - if (itsNrFreePorts == itsNrPorts) { // ready when nothing was claimed. - return; - } - - uint16 portNr = findService(aServiceName, false); - if (!portNr) { // unknown service? - return; - } - - int32 idx = portNr2Index(portNr); // convert portnr to array index - - LOG_INFO(formatString("Service %s(%d) unregistered", aServiceName.c_str(), portNr)); - - itsServiceList[idx].portNumber = 0; - itsServiceList[idx].serviceName = ""; - itsServiceList[idx].ownerPort = 0; - itsNrFreePorts++; - - LOG_INFO_STR ("Still managing " << itsNrPorts - itsNrFreePorts << " ports"); - - saveAdministration (itsAdminFile); // to survive crashes -} - -// -// releasePort(port) -// -void GSBController::releasePort(GCFPortInterface* aPort) -{ - if (!aPort) { // check args - return; - } - - int32 idx = 0; - int32 nrElems2Check = itsNrPorts - itsNrFreePorts;// prevent checking whole array - int32 orgCount = nrElems2Check; - - while (idx < itsNrPorts && nrElems2Check > 0) { - if (itsServiceList[idx].portNumber) { // used entry? - nrElems2Check--; - if (itsServiceList[idx].ownerPort == aPort) { - LOG_INFO(formatString("Service %s (%d) unregistered", - itsServiceList[idx].serviceName.c_str(), - itsServiceList[idx].portNumber)); - itsServiceList[idx].portNumber = 0; - itsServiceList[idx].serviceName = ""; - itsServiceList[idx].ownerPort = 0; - itsNrFreePorts++; - } - } - idx++; - } - LOG_INFO_STR ("Still managing " << itsNrPorts - itsNrFreePorts << " ports"); - - if (orgCount != (itsNrPorts - itsNrFreePorts)) { - saveAdministration (itsAdminFile); - } -} - -// -// findService(servicename) -// -uint16 GSBController::findService(const string& aServiceName, bool usedOnly) -{ - int32 idx = 0; - int32 nrElems2Check = itsNrPorts - itsNrFreePorts;// prevent checking whole array - - while (idx < itsNrPorts && nrElems2Check > 0) { - if (itsServiceList[idx].portNumber) { - nrElems2Check--; - if (itsServiceList[idx].serviceName == aServiceName) { - // only return portnumber if port is assigned also to prevent - // returning numbers of old, not-reregistered, services - return ((usedOnly && !itsServiceList[idx].ownerPort) ? 0 : - itsServiceList[idx].portNumber); - } - } - idx++; - } - - return (0); -} - -// -// saveAdministration(fileName) -// -void GSBController::saveAdministration(const string& aFileName) -{ - // Try to create the administration file. - ofstream outFile(aFileName.c_str(), ofstream::out | ofstream::trunc - | ofstream::binary); - - // If the file can not be opened warn to operator. - if (!outFile) { - LOG_WARN_STR("Unable to open file " << aFileName - << ". ServiceBroker is not powerfailure save!"); - return; - } - - LOG_DEBUG ("Saving administration"); - - uint16 writeVersion = SB_ADMIN_VERSION; - uint16 count = itsNrPorts - itsNrFreePorts; - outFile.write((char*)&writeVersion, sizeof(writeVersion)); - outFile.write((char*)&count, sizeof(count)); - outFile.write((char*)&itsLowerLimit, sizeof(itsLowerLimit)); - outFile.write((char*)&itsUpperLimit, sizeof(itsUpperLimit)); - - uint16 idx = 0; - while (idx < itsNrPorts && count > 0) { - if (itsServiceList[idx].portNumber) { - // note: the TCPport is not saved because it can not be restored. - outFile.write((char*)&itsServiceList[idx].portNumber, - sizeof(itsServiceList[idx].portNumber)); - uint16 size = itsServiceList[idx].serviceName.length() + 1; // save 0 also - char srvName[256]; - strcpy (srvName, itsServiceList[idx].serviceName.c_str()); - outFile.write((char*)&size, sizeof(size)); - outFile.write(srvName, size); - count--; - } - idx++; - } - outFile.close(); -} - -// -// loadAdministration(filename) -// -void GSBController::loadAdministration(const string& aFileName) -{ - // Try to open the adminfile. - ifstream inFile(aFileName.c_str(), ifstream::in | ifstream::binary); - if (!inFile) { - LOG_DEBUG_STR ("No old administration found(" << aFileName << ")"); - return; - } - - // read header info - uint16 readVersion; // for future version management - uint16 count; // nr of entries in the file - uint16 lowerLimit; // range settings - uint16 upperLimit; - inFile.read((char*)&readVersion, sizeof(readVersion)); - inFile.read((char*)&count, sizeof(count)); - inFile.read((char*)&lowerLimit, sizeof(lowerLimit)); - inFile.read((char*)&upperLimit, sizeof(upperLimit)); - - LOG_DEBUG_STR ("Loading " << count << " old registrations from file " << aFileName); - - while (count) { - uint16 portNumber; - inFile.read((char*)&portNumber, sizeof(portNumber)); - - uint16 size; - char servicename[256]; - inFile.read((char*)&size, sizeof(size)); - inFile.read(servicename, size); - - if (portNumber < itsLowerLimit || portNumber >= itsUpperLimit) { - LOG_DEBUG_STR ("Portnumber " << portNumber - << " not in current range, ignoring"); - } - else { - itsServiceList[portNr2Index(portNumber)].portNumber = portNumber; - itsServiceList[portNr2Index(portNumber)].serviceName = servicename; - itsServiceList[portNr2Index(portNumber)].ownerPort = 0; - itsNrFreePorts--; - LOG_DEBUG_STR ("Loading " << servicename << "@" << portNumber); - } - count--; - } - - inFile.close(); -} - -// -// cleanupOldRegistrations() -// -void GSBController::cleanupOldRegistrations() -{ - LOG_DEBUG ("Cleanup of old not reclaimed registrations"); - - bool removedSome = false; - uint16 idx = 0; - while (idx < itsNrPorts) { - if (itsServiceList[idx].portNumber && !itsServiceList[idx].ownerPort) { - LOG_DEBUG_STR ("Cleanup old " << itsServiceList[idx].serviceName - << "@" << itsServiceList[idx].portNumber); - itsServiceList[idx].portNumber = 0; - itsServiceList[idx].serviceName = ""; - itsServiceList[idx].ownerPort = 0; - itsNrFreePorts++; - removedSome = true; - } - idx++; - } - - LOG_INFO_STR ("Now managing " << itsNrPorts - itsNrFreePorts << " ports"); - - if (removedSome) { - saveAdministration(itsAdminFile); - } -} - - - } // namespace SB - } // namespace GCF -} // namespace LOFAR diff --git a/MAC/GCF/TM/src/ServiceBroker/GSB_Controller.h b/MAC/GCF/TM/src/ServiceBroker/GSB_Controller.h deleted file mode 100644 index d39dfebae91ba7f6f57cbd78caadb6c7dd7c5c3d..0000000000000000000000000000000000000000 --- a/MAC/GCF/TM/src/ServiceBroker/GSB_Controller.h +++ /dev/null @@ -1,100 +0,0 @@ -//# GSB_Controller.h: main class of the Property Agent -//# -//# Copyright (C) 2002-2003 -//# 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 GSB_CONTROLLER_H -#define GSB_CONTROLLER_H - -#include <Common/lofar_vector.h> -#include <GCF/TM/GCF_Task.h> -#include <GTM_SBTCPPort.h> -#include "GSB_Defines.h" - -namespace LOFAR { - namespace GCF { - namespace TM { - class GCFEvent; - class GCFPortInterface; - } - namespace SB { - -/** - This is the main class of the Property Agent. It uses a number of helper - classes to manage PML requests, registered scopes and use counts of created - properties. The assigned port provider supports the possibility to accept - more than one connect request from different clients (PML). -*/ - -class GSBController : public TM::GCFTask -{ -public: - GSBController(); - virtual ~GSBController(); - -private: - // state methods - TM::GCFEvent::TResult initial (TM::GCFEvent& e, TM::GCFPortInterface& p); - TM::GCFEvent::TResult operational(TM::GCFEvent& e, TM::GCFPortInterface& p); - - #define SB_ADMIN_VERSION 0x0100 - - typedef struct { - uint16 portNumber; - string serviceName; - TM::GCFPortInterface* ownerPort; - } TServiceInfo; - - void acceptConnectRequest (); - void readRanges (); - uint16 claimPortNumber (const string& aServiceName, - TM::GCFPortInterface* aPort); - TSBResult reRegisterService (const string& aServicename, uint16 portnr, - TM::GCFPortInterface* aPort); - void releaseService (const string& aServiceName); - void releasePort (TM::GCFPortInterface* aPort); - uint16 findService (const string& aServiceName, bool usedOnly); - void saveAdministration (const string& aFileName); - void loadAdministration (const string& aFileName); - void cleanupOldRegistrations(); - - // define conversions between portnumber and index. - inline uint16 portNr2Index(uint16 portNumber) - { return (portNumber - itsLowerLimit); } - inline uint16 index2PortNr(uint16 index) - { return (index + itsLowerLimit); } - - //# --- data members --- - vector<TServiceInfo> itsServiceList; // the administration - GTMSBTCPPort itsListener; // for all SB protocol messages - - string itsAdminFile; // to survive crashes - - uint16 itsLowerLimit; // lowest portnr to assign - uint16 itsUpperLimit; // assign till this number - uint16 itsNrPorts; // number of ports to manage - uint16 itsNrFreePorts; // nr of not-assigned ports - -}; - - } // namespace SB - } // namespace GCF -} // namespace LOFAR -#endif diff --git a/MAC/GCF/TM/src/ServiceBroker/GSB_Defines.h b/MAC/GCF/TM/src/ServiceBroker/GSB_Defines.h deleted file mode 100644 index ba771fdc47c9965572898f6e51225cf2a6d3b02e..0000000000000000000000000000000000000000 --- a/MAC/GCF/TM/src/ServiceBroker/GSB_Defines.h +++ /dev/null @@ -1,47 +0,0 @@ -//# GSB_Defines.h: preprocessor definitions of various constants -//# -//# Copyright (C) 2002-2003 -//# 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 SBRTICULAR 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 GSB_DEFINES_H -#define GSB_DEFINES_H - -#define LOFARLOGGER_SUBPACKAGE "SB" - -namespace LOFAR { - namespace GCF { - namespace SB { - -//class GCFPValue; - -enum TSBResult { - SB_NO_ERROR, - SB_UNKNOWN_ERROR, - SB_SERVICE_ALREADY_EXIST, - SB_NO_FREE_PORTNR, - SB_UNKNOWN_SERVICE, - SB_NO_CONNECTION, - SB_CANT_RECOVER -}; - - } // namespace SB - } // namespace GCF -} // namespace LOFAR -#endif diff --git a/MAC/GCF/TM/src/ServiceBroker/GSB_Main.cc b/MAC/GCF/TM/src/ServiceBroker/GSB_Main.cc deleted file mode 100644 index 53612ca05c7f21f1bfd778a622ea40e0fc08db76..0000000000000000000000000000000000000000 --- a/MAC/GCF/TM/src/ServiceBroker/GSB_Main.cc +++ /dev/null @@ -1,42 +0,0 @@ -//# GSB_Main.cc: -//# -//# Copyright (C) 2002-2003 -//# 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 <GSB_Controller.h> -#include <GCF/TM/GCF_Control.h> - -int main(int argc, char *argv[]) -{ - GCFTask::init(argc, argv); - - LOG_INFO("MACProcessScope: GCF.SB"); - - LOFAR::GCF::SB::GSBController serviceBroker; - - serviceBroker.start(); // make initial transition - - LOFAR::GCF::TM::GCFTask::run(); - - return 0; -} diff --git a/MAC/GCF/TM/src/ServiceBroker/GTM_SBTCPPort.cc b/MAC/GCF/TM/src/ServiceBroker/GTM_SBTCPPort.cc index cff32170ccd13e5c9419d5fc2b276494bac449e8..724d69d550aac59e7d97431739d3d13f409f0a2f 100644 --- a/MAC/GCF/TM/src/ServiceBroker/GTM_SBTCPPort.cc +++ b/MAC/GCF/TM/src/ServiceBroker/GTM_SBTCPPort.cc @@ -25,8 +25,8 @@ #include "GTM_SBTCPPort.h" #include <GTM_Defines.h> -#include "GSB_Defines.h" -#include <GCF/GCF_ServiceInfo.h> +//#include "GSB_Defines.h" +#include <MACIO/MACServiceInfo.h> #include <PortImpl/GTM_TCPServerSocket.h> #include <APS/ParameterSet.h> diff --git a/MAC/GCF/TM/src/ServiceBroker/Makefile.am b/MAC/GCF/TM/src/ServiceBroker/Makefile.am deleted file mode 100644 index a395e0a74c210b0c59c3f9e7f2fea5f564c128f7..0000000000000000000000000000000000000000 --- a/MAC/GCF/TM/src/ServiceBroker/Makefile.am +++ /dev/null @@ -1,36 +0,0 @@ -DOCHDRS = GSB_Controller.h \ - GSB_Defines.h \ - EventPort.h - -AUTOGEN = autogen -SUFFIXES = .ph -%.cc: %.prot - $(AUTOGEN) --writable -L $(top_srcdir)/autogen $< - -%.ph: %.prot - $(AUTOGEN) --writable -L $(top_srcdir)/autogen $< - -lib_LTLIBRARIES = libeventport.la - -libeventport_la_SOURCES = GSB_Defines.h SB_Protocol.ph EventPort.h \ - SB_Protocol.cc EventPort.cc ../GCF_Event.cc - -bin_PROGRAMS = ServiceBroker - -ServiceBroker_SOURCES = GSB_Controller.cc GSB_Main.cc -ServiceBroker_LDADD = $(top_builddir)/src/libgcftm.la $(LOFAR_DEPEND) -ServiceBroker_DEPENDENCIES = $(top_builddir)/src/libgcftm.la $(LOFAR_DEPEND) - -ServiceBroker_CXXFLAGS = -fmessage-length=0 - -BUILT_SOURCES = SB_Protocol.ph SB_Protocol.cc - -EXTRA_DIST = $(sysconf_DATA) - -sysconf_DATA = ServiceBroker.conf - -%.conf: ServiceBroker.conf.in - cp $< $@ - -include $(top_srcdir)/Makefile.common - diff --git a/MAC/GCF/TM/src/ServiceBroker/SB_Protocol.prot b/MAC/GCF/TM/src/ServiceBroker/SB_Protocol.prot deleted file mode 100644 index 1411ad538330f1497c4301abe95403116f2fdcd2..0000000000000000000000000000000000000000 --- a/MAC/GCF/TM/src/ServiceBroker/SB_Protocol.prot +++ /dev/null @@ -1,180 +0,0 @@ -//# SB_Protocol.prot: Protocol definition for the Service Broker Daemon -//# -//# Copyright (C) 2006 -//# 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$ - -autogen definitions protocol; - -description = "Protocol for the Service Broker deamon"; -prefix = "SB"; // for the signal names -id = "(GCF::TM::F_GCF_PROTOCOL + 3)"; - -// specify extra include files -include = '<GSB_Defines.h>'; - -prelude = << PRELUDE_END - -// The following messages are defined in the servicebroker protocol -// -// REGISTER_SERVICE (uint16 seqnr, string servicename); -// SERVICE_REGISTERED (uint16 seqnr, int32 portNumber, uint16 result); -// GET_SERVICEINFO (uint16 seqnr, string servicename, string hostname); -// SERVICE_INFO (uint16 seqnr, int32 portNumber, string hostname, uint16 result); -// UNREGISTER_SERVICE (uint16 seqnr, string servicename); -// SERVICE_UNREGISTERED(uint16 seqnr, uint16 result); -// REREGISTER_SERVICE (uint16 seqnr, string servicename, int32 portNumber); -// SERVICE_REREGISTERED(uint16 seqnr, uint16 result); -// - -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 = REGISTER_SERVICE; - dir = IN; - param = { - name = "seqnr"; - type = "uint16"; - }; - param = { - name = "servicename"; - type = "string"; - }; -}; - -event = { - signal = UNREGISTER_SERVICE; - dir = IN; - param = { - name = "seqnr"; - type = "uint16"; - }; - param = { - name = "servicename"; - type = "string"; - }; -}; - -event = { - signal = GET_SERVICEINFO; - dir = IN; - param = { - name = "seqnr"; - type = "uint16"; - }; - param = { - name = "servicename"; - type = "string"; - }; - param = { - name = "hostname"; - type = "string"; - }; -}; - -event = { - signal = SERVICE_REGISTERED; - dir = OUT; - param = { - name = "seqnr"; - type = "uint16"; - }; - param = { - name = "portnumber"; - type = "uint32"; - }; - param = { - name = "result"; - type = "GCF::SB::TSBResult"; - }; -}; - -event = { - signal = SERVICE_INFO; - dir = OUT; - param = { - name = "seqnr"; - type = "uint16"; - }; - param = { - name = "portnumber"; - type = "uint32"; - }; - param = { - name = "hostname"; - type = "string"; - }; - param = { - name = "result"; - type = "GCF::SB::TSBResult"; - }; -}; - -event = { - signal = SERVICE_UNREGISTERED; - dir = OUT; - param = { - name = "seqnr"; - type = "uint16"; - }; - param = { - name = "result"; - type = "GCF::SB::TSBResult"; - }; -}; - -event = { - signal = REREGISTER_SERVICE; - dir = IN; - param = { - name = "seqnr"; - type = "uint16"; - }; - param = { - name = "servicename"; - type = "string"; - }; - param = { - name = "portnumber"; - type = "uint32"; - }; -}; - -event = { - signal = SERVICE_REREGISTERED; - dir = OUT; - param = { - name = "seqnr"; - type = "uint16"; - }; - param = { - name = "servicename"; - type = "string"; - }; - param = { - name = "result"; - type = "GCF::SB::TSBResult"; - }; -}; diff --git a/MAC/GCF/TM/src/ServiceBroker/ServiceBroker.conf.in b/MAC/GCF/TM/src/ServiceBroker/ServiceBroker.conf.in deleted file mode 100644 index 6ff2635e84637472c0cc4298d3c1498af6bf6580..0000000000000000000000000000000000000000 --- a/MAC/GCF/TM/src/ServiceBroker/ServiceBroker.conf.in +++ /dev/null @@ -1,9 +0,0 @@ -# ParameterSet for ServiceBroker -# -#mac.gcf.sb.port=24000 -firstPortNumber = 24001 -lastPortNumber = 25000 - -# optional parameters -adminFile = ./SB.admin # is also the default name - diff --git a/MAC/GCF/TM/src/ServiceBroker/GTM_ServiceBroker.cc b/MAC/GCF/TM/src/ServiceBroker/ServiceBrokerTask.cc similarity index 89% rename from MAC/GCF/TM/src/ServiceBroker/GTM_ServiceBroker.cc rename to MAC/GCF/TM/src/ServiceBroker/ServiceBrokerTask.cc index 387d0adbf4dd6280f5e8b87cf35e098d6a94e20a..57b7f7a2e0dbbaa90f3182c775ee79c696327fcb 100644 --- a/MAC/GCF/TM/src/ServiceBroker/GTM_ServiceBroker.cc +++ b/MAC/GCF/TM/src/ServiceBroker/ServiceBrokerTask.cc @@ -1,4 +1,4 @@ -//# GTM_ServiceBroker.cc: +//# ServiceBrokerTask.cc: //# //# Copyright (C) 2002-2003 //# ASTRON (Netherlands Foundation for Research in Astronomy) @@ -22,17 +22,16 @@ #include <lofar_config.h> #include <Common/LofarLogger.h> +#include <Common/SystemUtil.h> -#include <GCF/Utils.h> -#include <SB_Protocol.ph> +#include <MACIO/SB_Protocol.ph> #include <GTM_Defines.h> -#include "GTM_ServiceBroker.h" +#include "ServiceBrokerTask.h" #include <unistd.h> namespace LOFAR { namespace GCF { using namespace TM; - using namespace Common; namespace SB { // @@ -48,29 +47,28 @@ GTMSBHandler::GTMSBHandler() } // -// GTMServiceBroker() +// ServiceBrokerTask() // -GTMServiceBroker::GTMServiceBroker() : - GCFTask((State)>MServiceBroker::operational, sSBTaskName), +ServiceBrokerTask::ServiceBrokerTask() : + GCFTask((State)&ServiceBrokerTask::operational, sSBTaskName), itsMaxResponse (15), itsTimerPort (*this, "timerport") { // register the protocol for debugging purposes -// registerProtocol(SB_PROTOCOL, SB_PROTOCOL_signalnames); - TM::registerProtocol(SB_PROTOCOL, SB_PROTOCOL_STRINGS); + registerProtocol(SB_PROTOCOL, SB_PROTOCOL_STRINGS); } // -// ~GTMServiceBroker() +// ~ServiceBrokerTask() // -GTMServiceBroker::~GTMServiceBroker() +ServiceBrokerTask::~ServiceBrokerTask() { } // // instance(temp) // -GTMServiceBroker* GTMServiceBroker::instance(bool temporary) +ServiceBrokerTask* ServiceBrokerTask::instance(bool temporary) { if (!GTMSBHandler::_pInstance) { GTMSBHandler::_pInstance = new GTMSBHandler(); @@ -88,7 +86,7 @@ GTMServiceBroker* GTMServiceBroker::instance(bool temporary) // // release() // -void GTMServiceBroker::release() +void ServiceBrokerTask::release() { ASSERT(GTMSBHandler::_pInstance); ASSERT(!GTMSBHandler::_pInstance->mayDeleted()); @@ -103,7 +101,7 @@ void GTMServiceBroker::release() // // registerService(servicePort) // -void GTMServiceBroker::registerService(GCFTCPPort& servicePort) +void ServiceBrokerTask::registerService(GCFTCPPort& servicePort) { string servicename = servicePort.makeServiceName(); @@ -128,7 +126,7 @@ void GTMServiceBroker::registerService(GCFTCPPort& servicePort) // // unregisterService(servicePort) // -void GTMServiceBroker::unregisterService(GCFTCPPort& servicePort) +void ServiceBrokerTask::unregisterService(GCFTCPPort& servicePort) { string servicename = servicePort.makeServiceName(); SBUnregisterServiceEvent request; @@ -152,7 +150,7 @@ void GTMServiceBroker::unregisterService(GCFTCPPort& servicePort) // // getServiceinfo(clientPort, remoteServiceName); // -void GTMServiceBroker::getServiceinfo(GCFTCPPort& clientPort, +void ServiceBrokerTask::getServiceinfo(GCFTCPPort& clientPort, const string& remoteServiceName, const string& hostname) { @@ -178,7 +176,7 @@ void GTMServiceBroker::getServiceinfo(GCFTCPPort& clientPort, // // deletePort(port) // -void GTMServiceBroker::deletePort(GCFTCPPort& aPort) +void ServiceBrokerTask::deletePort(GCFTCPPort& aPort) { // clean up all action that refer to this port ALiter end = itsActionList.end(); @@ -203,7 +201,7 @@ void GTMServiceBroker::deletePort(GCFTCPPort& aPort) // // _deleteBroker(Brokerport) // -void GTMServiceBroker::_deleteBroker(GTMSBTCPPort& aPort) +void ServiceBrokerTask::_deleteBroker(GTMSBTCPPort& aPort) { // remove port from admin BMiter end = itsBrokerMap.end(); @@ -221,7 +219,7 @@ void GTMServiceBroker::_deleteBroker(GTMSBTCPPort& aPort) // // _deleteService(aClientPort) // -void GTMServiceBroker::_deleteService(GCFTCPPort& aPort) +void ServiceBrokerTask::_deleteService(GCFTCPPort& aPort) { // its there a service registered at this port? SMiter service = itsServiceMap.find(&aPort); @@ -234,7 +232,7 @@ void GTMServiceBroker::_deleteService(GCFTCPPort& aPort) // // _actionName(type) // -string GTMServiceBroker::_actionName(uint16 type) const +string ServiceBrokerTask::_actionName(uint16 type) const { switch (type) { case SB_REGISTER_SERVICE: return ("RegisterService"); @@ -247,7 +245,7 @@ string GTMServiceBroker::_actionName(uint16 type) const // // _logResult // -void GTMServiceBroker::_logResult(uint16 result, +void ServiceBrokerTask::_logResult(uint16 result, const string& servicename, const string& hostname) const { @@ -288,7 +286,7 @@ void GTMServiceBroker::_logResult(uint16 result, // // _registerAction(action) // -unsigned short GTMServiceBroker::_registerAction(Action action) +unsigned short ServiceBrokerTask::_registerAction(Action action) { // reset number when list is empty if (itsActionList.empty()) { @@ -304,7 +302,7 @@ unsigned short GTMServiceBroker::_registerAction(Action action) // // _reRegisterServices(hostname) // -void GTMServiceBroker::_reRegisterServices(GCFPortInterface* brokerPort) +void ServiceBrokerTask::_reRegisterServices(GCFPortInterface* brokerPort) { // nothing to do? if (itsServiceMap.empty()) { @@ -327,7 +325,7 @@ void GTMServiceBroker::_reRegisterServices(GCFPortInterface* brokerPort) // // _doActionList(hostname) // -void GTMServiceBroker::_doActionList(const string& hostname) +void ServiceBrokerTask::_doActionList(const string& hostname) { // nothing to do? if (itsActionList.empty()) { @@ -368,7 +366,7 @@ void GTMServiceBroker::_doActionList(const string& hostname) // // _getBroker(hostname) // -GTMServiceBroker::BMiter GTMServiceBroker::_getBroker(const string& hostname) +ServiceBrokerTask::BMiter ServiceBrokerTask::_getBroker(const string& hostname) { // do we have a connection to this broker already? BMiter serviceBroker = itsBrokerMap.find(hostname); @@ -393,7 +391,7 @@ GTMServiceBroker::BMiter GTMServiceBroker::_getBroker(const string& hostname) // // _findAction(seqnr) // -GTMServiceBroker::ALiter GTMServiceBroker::_findAction(uint16 seqnr) +ServiceBrokerTask::ALiter ServiceBrokerTask::_findAction(uint16 seqnr) { ALiter end = itsActionList.end(); ALiter iter = itsActionList.begin(); @@ -410,7 +408,7 @@ GTMServiceBroker::ALiter GTMServiceBroker::_findAction(uint16 seqnr) // // _reconnectBrokers() // -void GTMServiceBroker::_reconnectBrokers() +void ServiceBrokerTask::_reconnectBrokers() { BMiter end = itsBrokerMap.end(); BMiter iter = itsBrokerMap.begin(); @@ -434,7 +432,7 @@ void GTMServiceBroker::_reconnectBrokers() // // _checkActionList(hostname); // -void GTMServiceBroker::_checkActionList(const string& hostname) +void ServiceBrokerTask::_checkActionList(const string& hostname) { LOG_TRACE_FLOW_STR("_checkActionList(" << hostname <<")"); @@ -473,7 +471,7 @@ void GTMServiceBroker::_checkActionList(const string& hostname) // // operational(event, port) // -GCFEvent::TResult GTMServiceBroker::operational(GCFEvent& event, GCFPortInterface& port) +GCFEvent::TResult ServiceBrokerTask::operational(GCFEvent& event, GCFPortInterface& port) { LOG_DEBUG_STR ("operational:" << eventName(event) << "@" << port.getName()); diff --git a/MAC/GCF/TM/src/ServiceBroker/GTM_ServiceBroker.h b/MAC/GCF/TM/src/ServiceBroker/ServiceBrokerTask.h similarity index 90% rename from MAC/GCF/TM/src/ServiceBroker/GTM_ServiceBroker.h rename to MAC/GCF/TM/src/ServiceBroker/ServiceBrokerTask.h index f0a8db8f9559f77f16d17e121941ff2587247f8d..32a93a2ecd87cb1df820e0fe0687bfdffce971e0 100644 --- a/MAC/GCF/TM/src/ServiceBroker/GTM_ServiceBroker.h +++ b/MAC/GCF/TM/src/ServiceBroker/ServiceBrokerTask.h @@ -1,4 +1,4 @@ -//# GTM_ServiceBroker.h: singleton class; bridge between controller application +//# ServiceBrokerTask.h: singleton class; bridge between controller application //# and Property Agent //# //# Copyright (C) 2002-2003 @@ -26,11 +26,13 @@ #include <Common/lofar_map.h> #include <Common/lofar_list.h> +#include <MACIO/GCF_Event.h> #include <GCF/TM/GCF_Task.h> #include "GTM_SBTCPPort.h" #include <GCF/TM/GCF_Handler.h> namespace LOFAR { + using MACIO::GCFEvent; namespace GCF { namespace SB { @@ -39,11 +41,11 @@ namespace LOFAR { class GTMSBHandler; -class GTMServiceBroker : public TM::GCFTask +class ServiceBrokerTask : public TM::GCFTask { public: - ~GTMServiceBroker (); - static GTMServiceBroker* instance(bool temporary = false); + ~ServiceBrokerTask (); + static ServiceBrokerTask* instance(bool temporary = false); static void release(); // member functions @@ -56,10 +58,10 @@ public: private: friend class GTMSBHandler; - GTMServiceBroker (); + ServiceBrokerTask (); // state methods - GCFEvent::TResult operational (TM::GCFEvent& e, TM::GCFPortInterface& p); + GCFEvent::TResult operational (GCFEvent& e, TM::GCFPortInterface& p); // helper structures and classes typedef struct action_t { @@ -126,11 +128,11 @@ public: void stop () {} private: - friend class GTMServiceBroker; + friend class ServiceBrokerTask; GTMSBHandler(); static GTMSBHandler* _pInstance; - GTMServiceBroker _controller; + ServiceBrokerTask _controller; }; } // namespace SB } // namespace GCF diff --git a/MAC/GCF/TM/src/mac.log_prop.in b/MAC/GCF/TM/src/mac.log_prop similarity index 100% rename from MAC/GCF/TM/src/mac.log_prop.in rename to MAC/GCF/TM/src/mac.log_prop diff --git a/MAC/GCF/TM/test/Echo_Protocol.prot b/MAC/GCF/TM/test/Echo_Protocol.prot index c1249177f33de45a32e083628b6c231c46dd8117..c1b64d1a323b1e38c0d527baafca4601896bf22b 100644 --- a/MAC/GCF/TM/test/Echo_Protocol.prot +++ b/MAC/GCF/TM/test/Echo_Protocol.prot @@ -5,7 +5,7 @@ autogen definitions protocol; description = "Protocol for the Echo server"; prefix = "Echo"; // for the signal names -id = "GCF::TM::F_APL_PROTOCOL"; +id = "MACIO::F_APL_PROTOCOL"; // specify extra include files // e.g. include = '<sys/time.h>'; @@ -54,4 +54,4 @@ event = { name = clockpulse; type = char; }; -}; \ No newline at end of file +}; diff --git a/MAC/GCF/TM/test/Makefile.am b/MAC/GCF/TM/test/Makefile.am index 1e777408579db2dcd1f21f5c50acc063436f86a8..7170bcf67f03efef12cbd3aa8fb8555b15f07916 100644 --- a/MAC/GCF/TM/test/Makefile.am +++ b/MAC/GCF/TM/test/Makefile.am @@ -1,10 +1,13 @@ AUTOGEN = autogen SUFFIXES = .ph %.ph: %.prot - $(AUTOGEN) --writable -L $(top_srcdir)/autogen $< + $(AUTOGEN) --writable -L $(datadir)/MACIO $< -check_PROGRAMS = tmEcho tmPing tGCFPort tProtocol tTimer \ - tGCFTask1 tGCFTask2 tGCFTask3 tGCFTask4 tGCFTask5 tEventPort +%.cc: %.prot + $(AUTOGEN) --writable -L $(datadir)/MACIO $< + +check_PROGRAMS = tmEcho tmPing tGCFPort tTimer \ + tGCFTask1 tGCFTask2 tGCFTask3 tGCFTask4 tGCFTask5 tmEcho_SOURCES = $(BUILT_SOURCES) Echo_Protocol.cc Echo.cc Echo.h tmEcho_LDADD = ../src/libgcftm.la @@ -19,17 +22,6 @@ tGCFPort_SOURCES = $(BUILT_SOURCES) Echo_Protocol.cc \ tGCFPort_LDADD = ../src/libgcftm.la tGCFPort_DEPENDENCIES = ../src/libgcftm.la $(LOFAR_DEPEND) -tProtocol_SOURCES = testprotocol.ph testprotocol.cc \ - Echo_Protocol.ph Echo_Protocol.cc \ - tProtocol.cc -tProtocol_LDADD = ../src/libgcftm.la -tProtocol_DEPENDENCIES = ../src/libgcftm.la $(LOFAR_DEPEND) - -tEventPort_SOURCES = Echo_Protocol.ph Echo_Protocol.cc \ - tEventPort.cc -tEventPort_LDADD = ../src/ServiceBroker/libeventport.la -tEventPort_DEPENDENCIES = ../src/ServiceBroker/libeventport.la $(LOFAR_DEPEND) - tTimer_SOURCES = $(BUILT_SOURCES) tTimer.cc tTimer_LDADD = ../src/libgcftm.la tTimer_DEPENDENCIES = ../src/libgcftm.la tTimer.h $(LOFAR_DEPEND) @@ -54,13 +46,12 @@ tGCFTask5_SOURCES = $(BUILT_SOURCES) tGCFTask5.cc testTask.cc tGCFTask5_LDADD = ../src/libgcftm.la tGCFTask5_DEPENDENCIES = ../src/libgcftm.la $(LOFAR_DEPEND) -BUILT_SOURCES = Echo_Protocol.ph testprotocol.ph +BUILT_SOURCES = Echo_Protocol.ph EXTRA_DIST = \ tmEcho.conf \ tmPing.conf \ - tGCFPort.conf \ - tProtocol.log_prop + tGCFPort.conf %.conf: tm-test.conf.in ln -sf $< $@ diff --git a/MAC/GCF/TM/test/tEventPort.cc b/MAC/GCF/TM/test/tEventPort.cc deleted file mode 100644 index 4d4e63dc7c25f108db08906908ebab0bbfcdffb9..0000000000000000000000000000000000000000 --- a/MAC/GCF/TM/test/tEventPort.cc +++ /dev/null @@ -1,102 +0,0 @@ -//# tEventPort.cc: Program to test the EventPort class -//# -//# Copyright (C) 2007 -//# 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 <GCF/TM/EventPort.h> -#include <GCF/GCF_ServiceInfo.h> -#include "Echo_Protocol.ph" - -using namespace LOFAR; -using namespace LOFAR::GCF; -using namespace LOFAR::GCF::TM; - -static EchoPingEvent pingEvent; -static EventPort* echoPort; - -int main (int32 argc, char*argv[]) -{ - bool syncMode; - switch (argc) { - case 2: - syncMode = (argv[1][0] == 's' || argv[1][0] == 'S'); - break; - default: - cout << "Syntax: " << argv[0] << " a | s" << endl; - cout << " the argument ('a' or 's') chooses the asynchrone or synchrone behaviour" << endl - << "of the EventPort. The synchrone mode expects the ServiceBroker and the" << endl - << "Echo server running. If not it will assert. In this mode the EventPort" << endl - << "wait forever for the answer." << endl - << "In asynchrone mode the EventPort will never complain and try forever to" << endl - << "reach each of the connection stages and receive the messages. You can" << endl - << "check the EventPort.status() to see in what state the port is." << endl; - return (1); - } - - INIT_LOGGER("tEventPort"); - - // open port - LOG_DEBUG_STR ("Operating in " << ((syncMode) ? "" : "a") << "synchrone mode."); - echoPort = new EventPort("ECHO:EchoServer", false, ECHO_PROTOCOL, "", syncMode); - - // construct event - pingEvent.seqnr = 25; - timeval pingTime; - gettimeofday(&pingTime, 0); - pingEvent.ping_time = pingTime; - - LOG_DEBUG("sending the ping event"); - if (syncMode) { - // NOTE: we could also use the while-loop of the asyncmode here. - echoPort->send(&pingEvent); - } - else { - while (!echoPort->send(&pingEvent)) { - cout << "state = " << echoPort->getStatus() << endl; - sleep (1); - ; - } - } - - LOG_DEBUG("going to wait for the answer event"); - GCFEvent* ackPtr; - if (syncMode) { - // NOTE: we could also use the while-loop of the asyncmode here. - ackPtr = echoPort->receive(); - } - else { - while (!(ackPtr = echoPort->receive())) { - cout << "state = " << echoPort->getStatus() << endl; - sleep (1); - ; - } - } - EchoEchoEvent ack(*ackPtr); - - LOG_DEBUG_STR("seqnr: " << ack.seqnr); - double delta = (1.0 * ack.echo_time.tv_sec + (ack.echo_time.tv_usec / 1000000.0)); - delta -= (1.0 * ack.ping_time.tv_sec + (ack.ping_time.tv_usec / 1000000.0)); - LOG_DEBUG_STR("dTime: " << delta << " sec"); - - return (0); -} - diff --git a/MAC/GCF/TM/test/tGCFTask1.cc b/MAC/GCF/TM/test/tGCFTask1.cc index 435a1efd105a57f847f4afcbca17f944ecac5b2a..0ba9a624547de4e35a57a15c4d7ab99673e3492c 100644 --- a/MAC/GCF/TM/test/tGCFTask1.cc +++ b/MAC/GCF/TM/test/tGCFTask1.cc @@ -25,6 +25,7 @@ //# Includes #include <Common/LofarLogger.h> +#include <MACIO/GCF_Event.h> #include <GCF/TM/GCF_Control.h> #include <unistd.h> // sleep #include "testTask.h" diff --git a/MAC/GCF/TM/test/tProtocol.cc b/MAC/GCF/TM/test/tProtocol.cc deleted file mode 100644 index 54c6e3308e89c353f97e9e3ab1f8b99dca71c234..0000000000000000000000000000000000000000 --- a/MAC/GCF/TM/test/tProtocol.cc +++ /dev/null @@ -1,61 +0,0 @@ -//# tProtocol.cc -//# -//# 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$ - -//# Always #include <lofar_config.h> first! -#include <lofar_config.h> - -//# Includes -#include <Common/LofarLogger.h> -#include "testprotocol.ph" -#include "Echo_Protocol.ph" - -using namespace LOFAR; -using namespace LOFAR::GCF::TM; - -int main (int argc, char* argv[]) -{ - INIT_LOGGER(argv[0]); - - LOG_INFO_STR ("TESTPROTOCOL has id: " << TESTPROTOCOL); - - TEST_PTCTestInEvent inEvent; - - LOG_INFO("Trying to print an errormsg before registering the protocol"); - LOG_INFO_STR("errornr: " << TEST_PTC_WINDOWS_ERR << " = " - << errorName (TEST_PTC_WINDOWS_ERR)); - LOG_INFO_STR("eventname of in-event: " << eventName(inEvent)); - - LOG_INFO("--- Registering the testprotocol ---"); - registerProtocol (TESTPROTOCOL, TESTPROTOCOL_STRINGS); - LOG_INFO(formatString("errornr: %d = %s", TEST_PTC_WINDOWS_ERR, - errorName (TEST_PTC_WINDOWS_ERR).c_str())); - LOG_INFO_STR("signalname of in-event: " << eventName(inEvent)); - - LOG_INFO ("Registering a second protocol"); - registerProtocol (ECHO_PROTOCOL, ECHO_PROTOCOL_STRINGS); - - EchoPingEvent pingEvent; - LOG_INFO_STR("signalname of ping-event: " << eventName(pingEvent)); - - return (0); -} - diff --git a/MAC/GCF/TM/test/tProtocol.log_prop b/MAC/GCF/TM/test/tProtocol.log_prop deleted file mode 100644 index 642b26cfd88e17b84221cb7b5a26e663fe77ddac..0000000000000000000000000000000000000000 --- a/MAC/GCF/TM/test/tProtocol.log_prop +++ /dev/null @@ -1,11 +0,0 @@ - -# Configure the rootLogger -log4cplus.rootLogger=DEBUG, STDOUT -# Define the STDOUT appender -log4cplus.appender.STDOUT=log4cplus::ConsoleAppender -log4cplus.appender.STDOUT.layout=log4cplus::PatternLayout -log4cplus.appender.STDOUT.layout.ConversionPattern=%-5p - %m%n - -# Define foo at level TRACE4 -#log4cplus.logger.TRC=TRACE4 - diff --git a/MAC/GCF/TM/test/testTask.h b/MAC/GCF/TM/test/testTask.h index bbf6516fc5dc90ceac93d0dbc19ce3b4e27423b2..484119a4f1b9d7b000953df26bb5d143181dcca3 100644 --- a/MAC/GCF/TM/test/testTask.h +++ b/MAC/GCF/TM/test/testTask.h @@ -28,13 +28,14 @@ //# Never #include <config.h> or #include <lofar_config.h> in a header file! //# Includes +#include <MACIO/GCF_Event.h> #include <GCF/TM/GCF_Control.h> // Avoid 'using namespace' in headerfiles namespace LOFAR { + using MACIO::GCFEvent; using GCF::TM::GCFTimerPort; - using GCF::TM::GCFEvent; using GCF::TM::GCFTask; using GCF::TM::GCFPortInterface; namespace GCF { diff --git a/MAC/GCF/TM/test/testprotocol.prot b/MAC/GCF/TM/test/testprotocol.prot deleted file mode 100644 index fab32b28692fee7f0c1a05bd7765d215592d9d24..0000000000000000000000000000000000000000 --- a/MAC/GCF/TM/test/testprotocol.prot +++ /dev/null @@ -1,85 +0,0 @@ -//# testprotocol.prot: Protocol definition to test the base functions -//# -//# Copyright (C) 2006 -//# 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$ - -autogen definitions protocol; - -description = "Protocol for testing the prtocol-programs"; -prefix = "TEST_PTC"; // for the signal names -id = "63"; - -// specify extra include files - -prelude = << PRELUDE_END - -// The following messages are defined in the servicebroker protocol -// -// TEST_IN (uint16 seqnr, string question); -// TEST_OUT (uint16 seqnr, string answer); -// - -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 = TEST_IN; - dir = IN; - param = { - name = "seqnr"; - type = "uint16"; - }; - param = { - name = "question"; - type = "string"; - }; -}; - -event = { - signal = TEST_OUT; - dir = OUT; - param = { - name = "seqnr"; - type = "uint16"; - }; - param = { - name = "answer"; - type = "string"; - }; -}; - -error = { - id = NO; - msg = "No errors"; -}; -error = { - id = RANGE; - msg = "Illegal range specified"; -}; -error = { - id = WINDOWS; - msg = "You are using Windows"; -}; - diff --git a/MAC/GCF/lofarconf.in b/MAC/GCF/lofarconf.in index 14ff8112e694f848541c7185c75aa534b3ca97bb..c81aa9ce4c0806819c188c3dc856a1906dee29de 100644 --- a/MAC/GCF/lofarconf.in +++ b/MAC/GCF/lofarconf.in @@ -1,4 +1,3 @@ -GCFCommon PVSS RTDB TM