diff --git a/.gitattributes b/.gitattributes index 9329f49d561f0beb76f795b97c0aefcab97d50ee..9c31886ac0b7c43e57f58a41e876c12e3769026e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -209,7 +209,12 @@ MAC/GCF/_PAL/PA/src/Makefile.am -text svneol=native#application/octet-stream MAC/GCF/_PAL/PA/src/PA_Protocol.prot -text svneol=native#application/octet-stream MAC/GCF/_PAL/PML/Makefile.am -text svneol=native#application/octet-stream MAC/GCF/_PAL/PML/src/Makefile.am -text svneol=native#application/octet-stream +MAC/GCF/_PAL/SAL/Makefile.am -text svneol=native#application/octet-stream MAC/GCF/_PAL/SAL/src/Makefile.am -text svneol=native#application/octet-stream +MAC/GCF/_PAL/SAL/test/Echo_Protocol.prot -text svneol=native#application/octet-stream +MAC/GCF/_PAL/SAL/test/Makefile.am -text svneol=native#application/octet-stream +MAC/GCF/_PAL/SAL/test/tutorial.ns.in -text svneol=native#application/octet-stream +MAC/GCF/_PAL/SAL/test/tutorial.top.in -text svneol=native#application/octet-stream MAC/GCF/_PAL/bootstrap -text svneol=native#application/octet-stream MAC/GCF/_PAL/configure.in -text svneol=native#application/octet-stream MAC/GCF/configure.in -text svneol=native#application/octet-stream diff --git a/MAC/GCF/_PAL/PA/src/GPA_Main.cc b/MAC/GCF/_PAL/PA/src/GPA_Main.cc index 20d7cf7d493c662e27fdeb74e956510393433b3d..cd45148a133579e7f7894228eab3c5d264a21c2f 100644 --- a/MAC/GCF/_PAL/PA/src/GPA_Main.cc +++ b/MAC/GCF/_PAL/PA/src/GPA_Main.cc @@ -21,7 +21,7 @@ //# $Id$ #include <GPA_Controller.h> -#include <GCF/GCF_Control.h> +#include <GCF/TM/GCF_Control.h> int main(int argC, char *argV[]) { diff --git a/MAC/GCF/_PAL/PA/src/GPA_PropertySet.cc b/MAC/GCF/_PAL/PA/src/GPA_PropertySet.cc index 2c245b9bdb479954fce7e763f056e3a1d5296a09..7ace302df437c050f26146bbcb458bdbae3b08bf 100644 --- a/MAC/GCF/_PAL/PA/src/GPA_PropertySet.cc +++ b/MAC/GCF/_PAL/PA/src/GPA_PropertySet.cc @@ -26,6 +26,11 @@ #include <stdio.h> #include <unistd.h> +bool operator == (const GPAPropertySet::TPSClient& a, const GPAPropertySet::TPSClient& b) +{ + return (a.pPSClientPort == b.pPSClientPort); +} + GPAPropertySet::GPAPropertySet(GPAController& controller, GCFPortInterface& serverPort) : _controller(controller), @@ -332,7 +337,7 @@ void GPAPropertySet::unload(PAUnloadPropSetEvent& request, const GCFPortInterfac pPSClient->count--; if (pPSClient->count == 0) { - _psClients.erase(*pPSClient); + _psClients.remove(*pPSClient); } } break; @@ -348,6 +353,7 @@ void GPAPropertySet::unload(PAUnloadPropSetEvent& request, const GCFPortInterfac void GPAPropertySet::configure(PAConfPropSetEvent& request) { + //TODO: implement configure } void GPAPropertySet::linked(PAPropSetLinkedEvent& response) @@ -467,7 +473,8 @@ void GPAPropertySet::dpDeleted(const string& /*dpName*/) void GPAPropertySet::linkPropSet() { assert(dpeExists(_name)); - assert(_serverPort.isConnected()); + //TODO: what if connection is realy disabled + assert(_serverPort.isConnected()); PALinkPropSetEvent linkRequest; linkRequest.scope = _name; _serverPort.send(linkRequest); @@ -476,6 +483,7 @@ void GPAPropertySet::linkPropSet() void GPAPropertySet::unlinkPropSet() { assert(dpeExists(_name)); + //TODO: what if connection is realy disabled assert(_serverPort.isConnected()); PAUnlinkPropSetEvent unlinkRequest; unlinkRequest.scope = _name; diff --git a/MAC/GCF/_PAL/PA/src/GPA_PropertySet.h b/MAC/GCF/_PAL/PA/src/GPA_PropertySet.h index 29a87e7df9bd579b7ecb83d2ca97c8f54c289224..bd67161c38ec62f9e9c24f13874aa6394316ffa2 100644 --- a/MAC/GCF/_PAL/PA/src/GPA_PropertySet.h +++ b/MAC/GCF/_PAL/PA/src/GPA_PropertySet.h @@ -42,6 +42,12 @@ class GPAPropertySet : public GSAService GPAPropertySet(GPAController& controller, GCFPortInterface& serverPort); virtual ~GPAPropertySet(); + typedef struct + { + GCFPortInterface* pPSClientPort; + unsigned short count; + } TPSClient; + void enable(PARegisterScopeEvent& request); void disable(PAUnregisterScopeEvent& request); void load(PALoadPropSetEvent& request, GCFPortInterface& p); @@ -66,12 +72,6 @@ class GPAPropertySet : public GSAService inline void dpeUnsubscribed(const string& /*propName*/) {}; private: // helper methods - typedef struct - { - GCFPortInterface* pPSClientPort; - unsigned short count; - operator == - } TPSClient; void linkPropSet(); void unlinkPropSet(); @@ -95,5 +95,4 @@ class GPAPropertySet : public GSAService TPAResult _savedResult; unsigned short _savedSeqnr; }; - #endif diff --git a/MAC/GCF/_PAL/PA/src/GPA_RequestManager.cc b/MAC/GCF/_PAL/PA/src/GPA_RequestManager.cc index 645774f009b873db3f006fb7c9ba12b0c8dbcc09..a366282c3a6b86cf644d4bb05a6c260945a51cce 100644 --- a/MAC/GCF/_PAL/PA/src/GPA_RequestManager.cc +++ b/MAC/GCF/_PAL/PA/src/GPA_RequestManager.cc @@ -21,7 +21,7 @@ //# $Id$ #include "GPA_RequestManager.h" -#include <GCF/GCF_Event.h> +#include <GCF/TM/GCF_Event.h> GPARequestManager::GPARequestManager() { diff --git a/MAC/GCF/_PAL/PML/src/GCF_ExtProperty.cc b/MAC/GCF/_PAL/PML/src/GCF_ExtProperty.cc index 9ce34c9f4e9de0df91d2b1bd04389345ded05675..5da7ccfa0439e9877daa5ef221e7b43d4693d530 100644 --- a/MAC/GCF/_PAL/PML/src/GCF_ExtProperty.cc +++ b/MAC/GCF/_PAL/PML/src/GCF_ExtProperty.cc @@ -27,12 +27,11 @@ GCFExtProperty::GCFExtProperty (const TProperty& propInfo) : GCFProperty(propInfo, 0), - _isSubscribed(false), - _isBusy(false) + _isSubscribed(false) { if (!Utils::isValidPropName(propInfo.propName)) { - LOFAR_LOG_WARN(PML_STDOUT_LOGGER, ( + LOG_WARN(LOFAR::formatString ( "Property %s meets not the name convention! Set to \"\"", propInfo.propName)); } @@ -41,12 +40,11 @@ GCFExtProperty::GCFExtProperty (const TProperty& propInfo) : GCFExtProperty::GCFExtProperty (const TProperty& propInfo, GCFExtPropertySet& propertySet) : GCFProperty(propInfo, &propertySet), - _isSubscribed(false), - _isBusy(false) + _isSubscribed(false) { if (!Utils::isValidPropName(propInfo.propName)) { - LOFAR_LOG_WARN(PML_STDOUT_LOGGER, ( + LOG_WARN(LOFAR::formatString ( "Property %s meets not the name convention! Set to \"\"", propInfo.propName)); } diff --git a/MAC/GCF/_PAL/PML/src/GCF_ExtPropertySet.cc b/MAC/GCF/_PAL/PML/src/GCF_ExtPropertySet.cc index e6c9b4015aefa76710304c3a43802b9bf8376c81..cad4ec8ffe2489a7062bae8945f865cfeb22bd54 100644 --- a/MAC/GCF/_PAL/PML/src/GCF_ExtPropertySet.cc +++ b/MAC/GCF/_PAL/PML/src/GCF_ExtPropertySet.cc @@ -23,6 +23,8 @@ #include <GCF/PAL/GCF_ExtPropertySet.h> #include <GCF/PAL/GCF_Property.h> #include <GCF/PAL/GCF_ExtProperty.h> +#include "GPM_Controller.h" +#include <GCF/Utils.h> GCFExtPropertySet::GCFExtPropertySet(const char* name, const TPropertySet& propSetInfo, @@ -33,7 +35,7 @@ GCFExtPropertySet::GCFExtPropertySet(const char* name, loadPropSetIntoRam(); } -GCFProperty* GCFExtPropertySet::createPropObject(TProperty& propInfo) const +GCFProperty* GCFExtPropertySet::createPropObject(TProperty& propInfo) { return new GCFExtProperty(propInfo, *this); } @@ -44,14 +46,14 @@ TGCFResult GCFExtPropertySet::load() if (_isBusy) { - LOFAR_LOG_INFO(PML_STDOUT_LOGGER, ( + LOG_INFO(LOFAR::formatString ( "This property set with Instance name (%s) is busy with an action. Ignored!", getScope().c_str())); result = GCF_BUSY; } else if (_isLoaded) { - LOFAR_LOG_INFO(PML_STDOUT_LOGGER, ( + LOG_INFO(LOFAR::formatString ( "This instance of the property set with Instance name (%s) is already loaded. Ignored!", getScope().c_str())); result = GCF_ALREADY_LOADED; @@ -59,7 +61,7 @@ TGCFResult GCFExtPropertySet::load() else if (getScope().length() == 0 || !Utils::isValidPropName(getScope().c_str())) { - LOFAR_LOG_INFO(PML_STDOUT_LOGGER, ( + LOG_INFO(LOFAR::formatString ( "Instance name not set or meets not the naming convention (%s). Ignored!", getScope().c_str())); result = GCF_NO_PROPER_DATA; @@ -87,14 +89,14 @@ TGCFResult GCFExtPropertySet::unload() if (_isBusy) { - LOFAR_LOG_INFO(PML_STDOUT_LOGGER, ( + LOG_INFO(LOFAR::formatString ( "This property set with Instance name (%s) is busy with an action. Ignored!", getScope().c_str())); result = GCF_BUSY; } else if (!_isLoaded) { - LOFAR_LOG_INFO(PML_STDOUT_LOGGER, ( + LOG_INFO(LOFAR::formatString ( "This instance of the property set with Instance name (%s) was not loaded here. Ignored!", getScope().c_str())); result = GCF_NOT_LOADED; @@ -103,7 +105,7 @@ TGCFResult GCFExtPropertySet::unload() _scope.length() == 0 || !Utils::isValidPropName(_scope.c_str())) { - LOFAR_LOG_INFO(PML_STDOUT_LOGGER, ( + LOG_INFO(LOFAR::formatString ( "APC name or scope not set or scope (%s) meets not the naming convention. Ignored!", _scope.c_str())); result = GCF_NO_PROPER_DATA; @@ -113,7 +115,7 @@ TGCFResult GCFExtPropertySet::unload() GPMController* pController = GPMController::instance(); assert(pController); _loadDefaults = false; - LOFAR_LOG_INFO(PML_STDOUT_LOGGER, ( + LOG_INFO(LOFAR::formatString ( "REQ: Unload ext. property set %s", getScope().c_str())); TPMResult pmResult = pController->unloadPropSet(*this); @@ -134,7 +136,7 @@ TGCFResult GCFExtPropertySet::requestValue(const string propName) const } else { - LOFAR_LOG_INFO(PML_STDOUT_LOGGER, ( + LOG_INFO(LOFAR::formatString ( "This property set has no property '%s'. Ignored!", propName.c_str())); return GCF_PROP_NOT_IN_SET; @@ -150,7 +152,7 @@ TGCFResult GCFExtPropertySet::subscribe(const string propName) const } else { - LOFAR_LOG_INFO(PML_STDOUT_LOGGER, ( + LOG_INFO(LOFAR::formatString ( "This property set has no property '%s'. Ignored!", propName.c_str())); return GCF_PROP_NOT_IN_SET; @@ -166,7 +168,7 @@ TGCFResult GCFExtPropertySet::unsubscribe(const string propName) const } else { - LOFAR_LOG_INFO(PML_STDOUT_LOGGER, ( + LOG_INFO(LOFAR::formatString ( "This property set has no property '%s'. Ignored!", propName.c_str())); return GCF_PROP_NOT_IN_SET; diff --git a/MAC/GCF/_PAL/PML/src/GCF_MyProperty.cc b/MAC/GCF/_PAL/PML/src/GCF_MyProperty.cc index f808a16d2a024b1be175dbedb58f89686b460a03..29b844078fbea8f16f80c8e33d545af7aa2be3f2 100644 --- a/MAC/GCF/_PAL/PML/src/GCF_MyProperty.cc +++ b/MAC/GCF/_PAL/PML/src/GCF_MyProperty.cc @@ -38,7 +38,7 @@ GCFMyProperty::GCFMyProperty(const TProperty& propInfo, _pCurValue = GCFPValue::createMACTypeObject((GCFPValue::TMACValueType) propInfo.type); assert(_pCurValue); _pOldValue = _pCurValue->clone(); - if (propertyFields.defaultValue) + if (propInfo.defaultValue) { _pCurValue->setValue(propInfo.defaultValue); } @@ -203,7 +203,7 @@ void GCFMyProperty::subscribed () { assert(!_isLinked); _isLinked = true; - _propertySet.linked(); + _propertySet.linked(*this); } } diff --git a/MAC/GCF/_PAL/PML/src/GCF_MyPropertySet.cc b/MAC/GCF/_PAL/PML/src/GCF_MyPropertySet.cc index 3c93c03b3602a0266c00406a86cece8585226468..0e9adba07cd84121f727e3de5fdf931e2a58dce5 100644 --- a/MAC/GCF/_PAL/PML/src/GCF_MyPropertySet.cc +++ b/MAC/GCF/_PAL/PML/src/GCF_MyPropertySet.cc @@ -48,7 +48,7 @@ GCFMyPropertySet::~GCFMyPropertySet () pController->unregisterScope(*this, true); } -GCFProperty* GCFMyPropertySet::createPropObject(TProperty& propInfo) const +GCFProperty* GCFMyPropertySet::createPropObject(TProperty& propInfo) { return new GCFMyProperty(propInfo, *this); } diff --git a/MAC/GCF/_PAL/PML/src/GCF_Property.cc b/MAC/GCF/_PAL/PML/src/GCF_Property.cc index e230ddded40ad4c76a99450badf196d9290694e5..f78d2c130309f7b3ae0e690e0f5519fa4a665deb 100644 --- a/MAC/GCF/_PAL/PML/src/GCF_Property.cc +++ b/MAC/GCF/_PAL/PML/src/GCF_Property.cc @@ -26,10 +26,11 @@ #include <GPM_PropertyService.h> GCFProperty::GCFProperty (const TProperty& propInfo, GCFPropertySet* pPropertySet) : + _isBusy(false), _pPropertySet(pPropertySet), _pAnswerObj(0), - _propInfo(propInfo), - _pPropService(0) + _pPropService(0), + _propInfo(propInfo) { _pPropService = new GPMPropertyService(*this); } diff --git a/MAC/GCF/_PAL/PML/src/GCF_PropertyBase.cc b/MAC/GCF/_PAL/PML/src/GCF_PropertyBase.cc deleted file mode 100644 index 5e4790b1ccab0b2642d91e2ed0c30c94468b6213..0000000000000000000000000000000000000000 --- a/MAC/GCF/_PAL/PML/src/GCF_PropertyBase.cc +++ /dev/null @@ -1,83 +0,0 @@ -//# GCF_PropertyBase.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 <GCF/GCF_PropertyBase.h> -#include <GCF/GCF_PropertySetBase.h> -#include <GCF/GCF_Answer.h> - -GCFPropertyBase::~GCFPropertyBase() -{ - assert (_pPropertySet == 0); -} - -const string GCFPropertyBase::getFullName () const -{ - if (_pPropertySet == 0) - { - return _name; - } - else - { - string scope = _pPropertySet->getScope(); - if (scope.length() == 0) - { - return _name; - } - else - { - string fullName = scope + GCF_PROP_NAME_SEP + _name; - return fullName; - } - } -} - -void GCFPropertyBase::dispatchAnswer(GCFEvent& answer) -{ - if (_pAnswerObj != 0) - { - _pAnswerObj->handleAnswer(answer); - } -} - -void GCFPropertyBase::subscribed () -{ - GCFPropAnswerEvent e(F_SUBSCRIBED); - e.pPropName = _name.c_str(); - dispatchAnswer(e); -} - -void GCFPropertyBase::valueChanged (const GCFPValue& value) -{ - GCFPropValueEvent e(F_VCHANGEMSG); - e.pValue = &value; - e.pPropName = _name.c_str(); - e.internal = false; - dispatchAnswer(e); -} - -void GCFPropertyBase::valueGet (const GCFPValue& value) -{ - GCFPropValueEvent e(F_VGETRESP); - e.pValue = &value; - e.pPropName = _name.c_str(); - dispatchAnswer(e); -} diff --git a/MAC/GCF/_PAL/PML/src/GCF_PropertySetBase.cc b/MAC/GCF/_PAL/PML/src/GCF_PropertySetBase.cc deleted file mode 100644 index 915d98c460b49f6f92e0d91d282b589c538fc962..0000000000000000000000000000000000000000 --- a/MAC/GCF/_PAL/PML/src/GCF_PropertySetBase.cc +++ /dev/null @@ -1,157 +0,0 @@ -//# GCF_PropertySetBase.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 <GCF/GCF_PropertySetBase.h> -#include <GCF/GCF_PropertySet.h> -#include <GCF/GCF_PropertyBase.h> -#include <Utils.h> -#include <GPM_Defines.h> - -GCFPropertySetBase::GCFPropertySetBase (string scope, - GCFAnswer* pAnswerObj) : - _pAnswerObj(pAnswerObj), - _scope(scope), - _dummyProperty("", this) -{ - if (!Utils::isValidPropName(scope.c_str())) - { - LOG_WARN(LOFAR::formatString ( - "Scope %s meets not the name convention! Set to \"\"", - scope.c_str())); - _scope = ""; - } -} - - -GCFPropertySetBase::~GCFPropertySetBase() -{ - clearAllProperties(); - _dummyProperty.resetPropSetRef(); -} - -GCFPropertyBase* GCFPropertySetBase::getProperty (const string propName) const -{ - string shortPropName(propName); - cutScope(shortPropName); - - TPropertyList::const_iterator iter = _properties.find(shortPropName); - - if (iter != _properties.end()) - { - return iter->second; - } - else - { - return 0; - } -} - -GCFPropertyBase& GCFPropertySetBase::operator[] (const string propName) -{ - GCFPropertyBase* pProperty = getProperty(propName); - if (!pProperty) - { - pProperty = &_dummyProperty; - } - return *pProperty; -} - -TGCFResult GCFPropertySetBase::setValue (const string propName, - const GCFPValue& value) -{ - GCFPropertyBase* pProperty = getProperty(propName); - if (pProperty) - { - return pProperty->setValue(value); - } - else - { - return GCF_PROP_NOT_IN_SET; - } -} - -void GCFPropertySetBase::setAnswer (GCFAnswer* pAnswerObj) -{ - GCFPropertyBase* pProperty; - for (TPropertyList::iterator iter = _properties.begin(); - iter != _properties.end(); ++iter) - { - pProperty = iter->second; - assert(pProperty); - pProperty->setAnswer(pAnswerObj); - } - _pAnswerObj = pAnswerObj; -} - -bool GCFPropertySetBase::exists (const string propName) const -{ - GCFPropertyBase* pProperty = getProperty(propName); - if (pProperty) - { - return pProperty->exists(); - } - else - { - return false; - } -} - -void GCFPropertySetBase::addProperty(const string& propName, GCFPropertyBase& prop) -{ - assert(propName.length() > 0); - - string shortPropName(propName); - cutScope(shortPropName); - - TPropertyList::iterator iter = _properties.find(shortPropName); - if (iter == _properties.end()) - { - _properties[shortPropName] = ∝ - } -} - -bool GCFPropertySetBase::cutScope(string& propName) const -{ - bool scopeFound(false); - - if (propName.find(_scope) == 0) - { - // plus 1 means erase the GCF_PROP_NAME_SEP after scope too - propName.erase(0, _scope.size() + 1); - scopeFound = true; - } - - return scopeFound; -} - -void GCFPropertySetBase::clearAllProperties() -{ - GCFPropertyBase* pProperty; - for (TPropertyList::iterator iter = _properties.begin(); - iter != _properties.end(); ++iter) - { - pProperty = iter->second; - assert(pProperty); - pProperty->resetPropSetRef(); - delete pProperty; - } -} diff --git a/MAC/GCF/_PAL/PML/src/GPM_Defines.h b/MAC/GCF/_PAL/PML/src/GPM_Defines.h index 0237926e54032c260841885ec6c84aa1f2a3b049..3b287394a494579f1edf66b0b9e2a2a3db741f48 100644 --- a/MAC/GCF/_PAL/PML/src/GPM_Defines.h +++ b/MAC/GCF/_PAL/PML/src/GPM_Defines.h @@ -23,9 +23,9 @@ #ifndef GPM_DEFINES_H #define GPM_DEFINES_H -#define LOFARLOGGER_PACKAGE "MAC.GCF.PAL.PML.Logger" +//#define LOFARLOGGER_PACKAGE "MAC.GCF.PAL.PML.Logger" -#include <GCFCommon/GCF_Defines.h> +#include <GCF/GCF_Defines.h> enum TPMResult { PM_NO_ERROR, diff --git a/MAC/GCF/_PAL/PML/src/Makefile.am b/MAC/GCF/_PAL/PML/src/Makefile.am index e32aa27beae6e72e9bb3f6c08a7229a8fd3b6b05..25f5b2cf4b3bc63bb718b116bf0ba67d5e9c57f5 100644 --- a/MAC/GCF/_PAL/PML/src/Makefile.am +++ b/MAC/GCF/_PAL/PML/src/Makefile.am @@ -1,37 +1,55 @@ AUTOGEN = autogen SUFFIXES = .ph -%.ph: $(top_srcdir)/CoreComps/PA/src/%.prot - $(AUTOGEN) -L $(top_srcdir)/../MACCommon/autogen $< && \ +%.ph: $(top_srcdir)/PA/src/%.prot + $(AUTOGEN) -L $(top_srcdir)/../../MACCommon/autogen $< && \ chmod a+w $@ -include_HEADERS = - -DOCHDRS = $(include_HEADERS) \ +pkgincludedir = $(includedir)/GCF/PAL +pkginclude_HEADERS = \ + ../include/GCF/PAL/GCF_ExtProperty.h \ + ../include/GCF/PAL/GCF_Property.h \ + ../include/GCF/PAL/GCF_MyProperty.h \ + ../include/GCF/PAL/GCF_ExtPropertySet.h \ + ../include/GCF/PAL/GCF_PropertySet.h \ + ../include/GCF/PAL/GCF_MyPropertySet.h \ + ../include/GCF/PAL/GCF_Answer.h \ + ../include/GCF/PAL/GCF_PropertyProxy.h + +DOCHDRS = $(pkginclude_HEADERS) \ GPM_Controller.h \ GPM_PropertyService.h \ + GPM_PropertyProxy.h \ GPM_Defines.h - + +lib_LTLIBRARIES = libgcfpal.la + +libgcfpal_la_SOURCES= +libgcfpal_la_LIBADD= libpml.la\ + $(top_builddir)/SAL/src/libsal.la + +libgcfpal_la_DEPENDENCIES= libpml.la $(LOFAR_DEPEND) \ + $(top_builddir)/SAL/src/libsal.la + + noinst_LTLIBRARIES = libpml.la libpml_la_SOURCES= $(DOCHDRS) \ - GCF_PropertyBase.cc \ + GCF_ExtProperty.cc \ GCF_Property.cc \ GCF_MyProperty.cc \ - GCF_PropertySetBase.cc \ + GCF_ExtPropertySet.cc \ GCF_PropertySet.cc \ GCF_MyPropertySet.cc \ - GCF_Apc.cc \ GCF_Answer.cc \ GPM_Controller.cc \ GPM_PropertyService.cc \ GCF_PropertyProxy.cc \ + GPM_PropertyProxy.cc \ PA_Protocol.cc -libpml_la_CPPFLAGS= -I$(top_srcdir)/GCFCommon/src \ - -I$(top_srcdir)/CoreComps/TM/src \ - -I$(top_srcdir)/CoreComps/SAL/src \ - -I$(top_srcdir)/CoreComps/PA/src \ - -I$(top_builddir)/CoreComps/PA/src +libpml_la_CPPFLAGS= -I$(top_srcdir)/include \ + -I$(top_srcdir)/SAL/src \ + -I$(top_srcdir)/PA/src BUILT_SOURCES = \ PA_Protocol.ph diff --git a/MAC/GCF/_PAL/SAL/Makefile.am b/MAC/GCF/_PAL/SAL/Makefile.am new file mode 100644 index 0000000000000000000000000000000000000000..9bf2d143595794132d5d2ed7c6d8445e652462be --- /dev/null +++ b/MAC/GCF/_PAL/SAL/Makefile.am @@ -0,0 +1,3 @@ +SUBDIRS=src test + +include $(lofar_sharedir)/Makefile.common diff --git a/MAC/GCF/_PAL/SAL/test/Echo.cc b/MAC/GCF/_PAL/SAL/test/Echo.cc new file mode 100644 index 0000000000000000000000000000000000000000..e2b5b7d0f6a1f2f3deb70e32d1895b2f1b05c9ef --- /dev/null +++ b/MAC/GCF/_PAL/SAL/test/Echo.cc @@ -0,0 +1,192 @@ +// +// Echo.cc: Implementation of the Echo task class. +// +// Copyright (C) 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 "Echo.h" +#include <GCF/GCF_PVBool.h> +#include <GCF/GCF_PVChar.h> +#include <Common/lofar_iostream.h> +#include "Echo_Protocol.ph" + + +Echo::Echo(string name) : GCFTask((State)&Echo::initial, name) +{ + // register the protocol for debugging purposes + registerProtocol(ECHO_PROTOCOL, ECHO_PROTOCOL_signalnames); + + // initialize the port + server.init(*this, "server", GCFPortInterface::SPP, ECHO_PROTOCOL); +} + +GCFEvent::TResult Echo::initial(GCFEvent& e, GCFPortInterface& /*p*/) +{ + GCFEvent::TResult status = GCFEvent::HANDLED; + + switch (e.signal) + { + case F_INIT: + { + break; + } + case F_ENTRY: + server.open(); + break; + + case F_CONNECTED: + { + TRAN(Echo::connected); + break; + } + case F_DISCONNECTED: + server.setTimer(1.0); // try again after 1 second + break; + + case F_TIMER: + server.open(); // try again + break; + + default: + status = GCFEvent::NOT_HANDLED; + break; + } + + return status; +} + +GCFEvent::TResult Echo::connected(GCFEvent& e, GCFPortInterface& /*p*/) +{ + GCFEvent::TResult status = GCFEvent::HANDLED; + static string propName("Test_Prop"); + + switch (e.signal) + { + case F_DISCONNECTED: + service.deleteProp(propName); + service.deleteProp(propName + "_test"); + cout << "Lost connection to client" << endl; + TRAN(Echo::initial); + break; + + case ECHO_PING: + { + EchoPingEvent ping(e); + + switch (ping.seqnr % 13) + { + case 0: + service.createProp(propName, GCFPValue::LPT_BOOL); + break; + case 1: + service.createProp(propName + "_test", GCFPValue::LPT_CHAR); + break; + case 2: + service.subscribe(propName); + break; + case 3: + service.subscribe(propName + "_test"); + break; + case 4: + service.get(propName); + break; + case 5: + { + GCFPVBool wrongTestVal(true); + service.set(propName + "_test", wrongTestVal); + GCFPVChar goodTestVal('A'); + service.set(propName + "_test", goodTestVal); + break; + } + case 6: + service.unsubscribe(propName + "_test1"); + service.unsubscribe(propName + "_test"); + service.unsubscribe(propName); + break; + case 7: + { + GCFPVChar testVal('B'); + service.set(propName + "_test", testVal); + break; + } + case 8: + { + service.subscribe(propName); + service.unsubscribe(propName); + GCFPVBool testVal(true); + service.set(propName, testVal); + break; + } + case 9: + service.subscribe(propName); + break; + case 10: + service.get(propName); + service.unsubscribe(propName); + break; + case 11: + { + service.subscribe(propName); + service.unsubscribe(propName); + service.subscribe(propName); + GCFPVBool testVal(false); + service.set(propName, testVal); + break; + } + case 12: + service.deleteProp(propName); + service.deleteProp(propName + "_test"); + break; + } + + + cout << "PING received (seqnr=" << ping.seqnr << ")" << endl; + + timeval echo_time; + gettimeofday(&echo_time, 0); + EchoEchoEvent echo; + echo.seqnr = ping.seqnr; + echo.ping_time = ping.ping_time; + echo.echo_time = echo_time; + + server.send(echo); + + cout << "ECHO sent" << endl; + break; + } + default: + status = GCFEvent::NOT_HANDLED; + break; + } + + return status; +} + +int main(int argc, char* argv[]) +{ + GCFTask::init(argc, argv); + + Echo echo_task("ECHO"); + echo_task.start(); // make initial transition + + GCFTask::run(); + + return 0; +} diff --git a/MAC/GCF/_PAL/SAL/test/Echo.h b/MAC/GCF/_PAL/SAL/test/Echo.h new file mode 100644 index 0000000000000000000000000000000000000000..fd28c77ffc8858a17748e629d4ebf2f0e93125b8 --- /dev/null +++ b/MAC/GCF/_PAL/SAL/test/Echo.h @@ -0,0 +1,74 @@ +// +// Echo.h: Definition of the Echo task class. +// +// Copyright (C) 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 _ECHO_H_ +#define _ECHO_H_ + +#include <GCF/GCF_Control.h> +#include "Service.h" +#include <Common/lofar_string.h> + +/** + * The Echo task receives ECHO_PING events from the Ping task and + * returns an ECHO_ECHO event for each ECHO_PING event received. + */ +class Echo : public GCFTask +{ + public: + + /** + * The constructor for the Echo task. + * @param name The name of this task. By differentiating in the name, multiple + * instances of the same task can be created and addressed. + */ + Echo (string name); + + /** + * The initial state handler. This handler is passed to the FTask constructor + * to indicate that the F_INIT event which starts the state machine is handled + * by this handler. + * @param e The event that was received and needs to be handled by the state + * handler. + * @param p The port interface (see @a FPortInterface) on which the event + * was received. + */ + GCFEvent::TResult initial (GCFEvent& e, GCFPortInterface& p); + + /** + * The "connected" state is reached when a Ping client is connected. + */ + GCFEvent::TResult connected(GCFEvent& e, GCFPortInterface& p); + + private: + + /** + * The Echo task acts as a server for Ping tasks to use. Event from the Ping + * task are received on the server port. And reply events to the Ping task + * are sent through the server port. + */ + GCFPort server; + Service service; +}; + +#endif diff --git a/MAC/GCF/_PAL/SAL/test/Echo_Protocol.prot b/MAC/GCF/_PAL/SAL/test/Echo_Protocol.prot new file mode 100644 index 0000000000000000000000000000000000000000..8bb47fbd8f896d266f0319b81d07a071e5f1e7e5 --- /dev/null +++ b/MAC/GCF/_PAL/SAL/test/Echo_Protocol.prot @@ -0,0 +1,48 @@ +// +// Protocol definition for the Echo server +// +autogen definitions protocol; + +description = "Protocol for the Echo server"; +prefix = "Echo"; // for the signal names +id = "F_APL_PROTOCOL"; + +// specify extra include files +// e.g. +include = '<sys/time.h>'; + +// +// 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 = PING; + dir = IN; + param = { + name = "seqnr"; + type = "unsigned int"; + }; + param = { + name = "ping_time"; + type = "timeval"; + }; +}; + +event = { + signal = ECHO; + dir = OUT; + param = { + name = "seqnr"; + type = "unsigned int"; + }; + param = { + name = "ping_time"; + type = "timeval"; + }; + param = { + name = "echo_time"; + type = "timeval"; + }; +}; diff --git a/MAC/GCF/_PAL/SAL/test/Makefile.am b/MAC/GCF/_PAL/SAL/test/Makefile.am new file mode 100644 index 0000000000000000000000000000000000000000..0c53b9ca53f05365a1a949a80a15697965f18a12 --- /dev/null +++ b/MAC/GCF/_PAL/SAL/test/Makefile.am @@ -0,0 +1,47 @@ +cppflags = -I$(top_srcdir)/CoreComps/SAL/src + +check_PROGRAMS = echoapp ping + +TESTS = #echoapp ping + +echoapp_SOURCES = Echo.cc Service.cc Echo_Protocol.cc +echoapp_LDADD = ../src/libsal.la $(LOFAR_DEPEND) +echoapp_DEPENDENCIES = ../src/libsal.la $(LOFAR_DEPEND) +echoapp_CPPFLAGS = $(cppflags) + +ping_SOURCES = Ping.cc Echo_Protocol.cc +ping_LDADD = ../src/libsal.la $(LOFAR_DEPEND) +ping_DEPENDENCIES = ../src/libsal.la $(LOFAR_DEPEND) +ping_CPPFLAGS= $(cppflags) + +AUTOGEN = autogen +SUFFIXES = .ph +%.ph: %.prot + $(AUTOGEN) -L $(top_srcdir)/../../MACCommon/autogen $< && \ + chmod a+w $@ + +BUILT_SOURCES = \ + Echo_Protocol.ph \ + tutorial.ns \ + tutorial.top \ + log4cplus.properties + +EXTRA_DIST = \ + Echo_Protocol.ph \ + tutorial.ns \ + tutorial.top \ + log4cplus.properties + +%.properties: $(MAC_CONFIG)/%.properties + cp $< $@ + +%.ns: %.ns.in + cp $< $@ + +%.top: %.top.in + cp $< $@ + +include $(lofar_sharedir)/Makefile.common + + + diff --git a/MAC/GCF/_PAL/SAL/test/Ping.cc b/MAC/GCF/_PAL/SAL/test/Ping.cc new file mode 100644 index 0000000000000000000000000000000000000000..c836c868bef68f23e569c66a237d59a04956879a --- /dev/null +++ b/MAC/GCF/_PAL/SAL/test/Ping.cc @@ -0,0 +1,186 @@ +// +// Ping.cc: Implementation of the Ping task class. +// +// Copyright (C) 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 "Ping.h" +#include "Echo_Protocol.ph" +#include <Common/lofar_iostream.h> + +/** + * Function to calculate the elapsed time between two tiemval's. + */ +static double time_elapsed(timeval* start, timeval* stop) +{ + return stop->tv_sec-start->tv_sec + + (stop->tv_usec-start->tv_usec)/(double)1e6; +} + +Ping::Ping(string name) + : GCFTask((State)&Ping::initial, name), ping_timer(-1) +{ + // register the port for debug tracing + registerProtocol(ECHO_PROTOCOL, ECHO_PROTOCOL_signalnames); + + /** + * Initialize the "client" port + * - Pass the this pointer, because this port belongs to + * this task. + * - Give it the name "client". + * - This is a Service Access Port which uses the + * ECHO_PROTOCOL + */ + client.init(*this, "client", GCFPortInterface::SAP, ECHO_PROTOCOL); +} + +GCFEvent::TResult Ping::initial(GCFEvent& e, GCFPortInterface& /*port*/) +{ + GCFEvent::TResult status = GCFEvent::HANDLED; + + switch (e.signal) + { + case F_INIT: + break; + + case F_ENTRY: + client.open(); + break; + + case F_CONNECTED: + + // start ping_timer + // - after 1 second + // - every 40 seconds + ping_timer = client.setTimer(1.0, 2.0); + + TRAN(Ping::connected); + break; + + case F_DISCONNECTED: + (void)client.setTimer(1.0); // try connect again after 1 second + break; + + case F_TIMER: + client.open(); + break; + + default: + status = GCFEvent::NOT_HANDLED; + break; + } + + return status; +} + +GCFEvent::TResult Ping::connected(GCFEvent& e, GCFPortInterface& /*p*/) +{ + GCFEvent::TResult status = GCFEvent::HANDLED; + + static int seqnr = 0; + + switch (e.signal) + { + case F_TIMER: + { + + timeval ping_time; + + // create PingEvent + gettimeofday(&ping_time, 0); + EchoPingEvent ping; + ping.seqnr = seqnr++; + ping.ping_time = ping_time; + + // send the event + client.send(ping); + + cout << "PING sent (seqnr=" << ping.seqnr << ")" << endl; + + TRAN(Ping::awaiting_echo); // wait for the echo + break; + } + case F_DISCONNECTED: + + //(void)client.open(); // try to reopen + (void)client.cancelTimer(ping_timer); + + seqnr = 0; + TRAN(Ping::initial); + break; + + default: + status = GCFEvent::NOT_HANDLED; + break; + } + + return status; +} + +GCFEvent::TResult Ping::awaiting_echo(GCFEvent& e, GCFPortInterface& /*p*/) +{ + GCFEvent::TResult status = GCFEvent::HANDLED; + + switch (e.signal) + { + case F_TIMER: + cout << "Missed echo dead-line." << endl; + break; + + case ECHO_ECHO: + { + timeval echo_time; + gettimeofday(&echo_time, 0); + + EchoEchoEvent echo(e); + + cout << "ECHO received (seqnr=" << echo.seqnr << "): elapsed = " + << time_elapsed(&(echo.ping_time), &echo_time) << " sec."<< endl; + + TRAN(Ping::connected); + break; + } + + case F_DISCONNECTED: + (void)client.cancelTimer(ping_timer); + TRAN(Ping::initial); + break; + + default: + status = GCFEvent::NOT_HANDLED; + break; + } + + return status; +} + +int main(int argc, char** argv) +{ + GCFTask::init(argc, argv); + + Ping ping_task("PING"); + + ping_task.start(); // make initial transition + + GCFTask::run(); + + return 0; +} diff --git a/MAC/GCF/_PAL/SAL/test/Ping.h b/MAC/GCF/_PAL/SAL/test/Ping.h new file mode 100644 index 0000000000000000000000000000000000000000..665647fb610a62df640023c8b6ed7d5f8f9db91c --- /dev/null +++ b/MAC/GCF/_PAL/SAL/test/Ping.h @@ -0,0 +1,85 @@ +// +// Ping.h: Definition of the Ping task class. +// +// Copyright (C) 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 _PING_H_ +#define _PING_H_ + +#include <GCF/GCF_Control.h> +#include <sys/time.h> + +/** + * The Ping task sends ECHO_PING events to the Echo task and expects + * ECHO_ECHO events in return. + */ +class Ping : public GCFTask +{ + public: + + /** + * The constructor for the Ping task. + * @param name The name of this task. This name is used for looking up + * connection establishment information from the FNameService and FAppTopology + * configuration files. + */ + Ping (string name); + + /** + * Handler for the initial state. This handler is passed to the constructor + * of the FTask class to indicate that it should be sent the F_INIT signal + * which indicates the start of the state-machine. + * @return FEvent::HANDLED or FEvent::NOT_HANDLED to indicate whether the + * event has been handled or not. + */ + GCFEvent::TResult initial (GCFEvent& e, GCFPortInterface& p); + + /** + * The "connected" state is reached when the Ping client has made a + * connection with the Echo server. + */ + GCFEvent::TResult connected (GCFEvent& e, GCFPortInterface& p); + + /** + * The "awaiting_echo" state is reached when an ECHO_PING event has + * been sent, but the ECHO_ECHO event has not been received yet. + * When the ECHO_ECHO event has been received a transition to the + * "connected" state is made. + */ + GCFEvent::TResult awaiting_echo(GCFEvent& e, GCFPortInterface& p); + + private: + + /** + * The Ping task is a client to the Echo task. The "client" port can be used + * to send events to and receive events from the Echo task. + */ + GCFPort client; + + /** + * Ping messages are sent every 1 second. This variables holds the + * timer_id of that timer to enable cancelation of the timer + * in fault situations. + */ + long ping_timer; // remember ping timer id to be able to cancel it +}; + +#endif diff --git a/MAC/GCF/_PAL/SAL/test/Service.cc b/MAC/GCF/_PAL/SAL/test/Service.cc new file mode 100644 index 0000000000000000000000000000000000000000..71854e30e4f97ce887cced8999ab0a19a4a31816 --- /dev/null +++ b/MAC/GCF/_PAL/SAL/test/Service.cc @@ -0,0 +1,74 @@ +#include "Service.h" + +TSAResult Service::createProp(const string& propName, + GCFPValue::TMACValueType macType) +{ + return GSAService::createProp(propName, macType); +} + +TSAResult Service::deleteProp(const string& propName) +{ + return GSAService::deleteProp(propName); +} + +TSAResult Service::subscribe(const string& propName) +{ + return GSAService::subscribe(propName); +} + +TSAResult Service::unsubscribe(const string& propName) +{ + return GSAService::unsubscribe(propName); +} + +TSAResult Service::get(const string& propName) +{ + return GSAService::get(propName); +} + +TSAResult Service::set(const string& propName, const GCFPValue& value) +{ + return GSAService::set(propName, value); +} + +bool Service::exists(const string& propName) +{ + return GSAService::exists(propName); +} + + +void Service::propCreated(const string& propName) +{ + LOG_DEBUG(LOFAR::formatString ( + "Property '%s' created", propName.c_str())); +} + +void Service::propDeleted(const string& propName) +{ + LOG_DEBUG(LOFAR::formatString ( + "Property '%s' deleted", propName.c_str())); +} + +void Service::propSubscribed(const string& propName) +{ + LOG_DEBUG(LOFAR::formatString ( + "Property '%s' subscribed", propName.c_str())); +} + +void Service::propUnsubscribed(const string& propName) +{ + LOG_DEBUG(LOFAR::formatString ( + "Property '%s' unsubscribed", propName.c_str())); +} + +void Service::propValueGet(const string& propName, const GCFPValue& /*value*/) +{ + LOG_DEBUG(LOFAR::formatString ( + "Value of property '%s' get", propName.c_str())); +} + +void Service::propValueChanged(const string& propName, const GCFPValue& /*value*/) +{ + LOG_DEBUG(LOFAR::formatString ( + "Value of property '%s' changed", propName.c_str())); +} diff --git a/MAC/GCF/_PAL/SAL/test/Service.h b/MAC/GCF/_PAL/SAL/test/Service.h new file mode 100644 index 0000000000000000000000000000000000000000..08a3f20123c28c00619232c7587e090fe7c8cc93 --- /dev/null +++ b/MAC/GCF/_PAL/SAL/test/Service.h @@ -0,0 +1,27 @@ +#include <GSA_Service.h> + +class Service : public GSAService +{ + public: + Service() {}; + virtual ~Service() {}; + + virtual TSAResult createProp(const string& propName, + GCFPValue::TMACValueType macType); + virtual TSAResult deleteProp(const string& propName); + virtual TSAResult subscribe(const string& propName); + virtual TSAResult unsubscribe(const string& propName); + virtual TSAResult get(const string& propName); + virtual TSAResult set(const string& propName, const GCFPValue& value); + virtual bool exists(const string& propName); + + protected: + virtual void propCreated(const string& propName); + virtual void propDeleted(const string& propName); + virtual void propSubscribed(const string& propName); + virtual void propUnsubscribed(const string& propName); + virtual void propValueGet(const string& propName, const GCFPValue& value); + virtual void propValueChanged(const string& propName, const GCFPValue& value); + + private: +}; diff --git a/MAC/GCF/_PAL/SAL/test/tutorial.ns.in b/MAC/GCF/_PAL/SAL/test/tutorial.ns.in new file mode 100644 index 0000000000000000000000000000000000000000..22fa27785ad736c1b02789ada4e2ab0209f45ff6 --- /dev/null +++ b/MAC/GCF/_PAL/SAL/test/tutorial.ns.in @@ -0,0 +1,38 @@ +# +# Name service configuration file. +# +# This file contains name and configuration information +# for tasks and their ports. +# +# For each task the host on which the task runs is specified +# with the 'host' attribute e.g.: +# +# [TASK_A] +# host=localhost +# +# For each SAP port the port type (TCP or UDP) can be +# specified with the .type' attribute e.g.: +# +# [TASK_B] +# host=localhost +# mysap.type=TCP +# +# For each SPP port the port type (.type), portnumber (.port) +# and host on which to find the SPP port (.host) can +# be specified e.g. +# +# [TASK_C] +# host=localhost +# myspp.type=UDP +# myspp.host=remotehost.remote.org +# myspp.port=20033 +# + +[PING] +host=localhost +client.type=TCP # SAP + +[ECHO] +host=localhost +server.port=20032 # SPP +server.type=TCP diff --git a/MAC/GCF/_PAL/SAL/test/tutorial.top.in b/MAC/GCF/_PAL/SAL/test/tutorial.top.in new file mode 100644 index 0000000000000000000000000000000000000000..755aad4549ce56313b8c4212219f8524d6545d62 --- /dev/null +++ b/MAC/GCF/_PAL/SAL/test/tutorial.top.in @@ -0,0 +1,27 @@ +# +# Each task is a block like this: +# +# [TaskName] +# +# For each task a specification is given of how to +# connect a task's SAP's to the remote tasks SPP like this: +# +# [TaskName] +# local_SAP_port_name = remote_task_name:remote_SPP_port_name +# +# Connections are initiated by the SAP and accepted +# by the SPP. Although establishing the connection +# is directional from SAP to SPP, the data transport +# via the ports is bidirectional. +# + +# +# Connect SAP port 'client' of task 'PING' to +# SPP port 'server' of task 'ECHO' +# + +[PING] +client=ECHO:server + +[ECHO] +# has no SAP's diff --git a/MAC/GCF/_PAL/include/GCF/PAL/GCF_Answer.h b/MAC/GCF/_PAL/include/GCF/PAL/GCF_Answer.h index 2a34a7c16c2b93558dab530ecbfd21b9fc39dbcc..bee8e1dda892a9742b1f4e5800af107dd34852f4 100644 --- a/MAC/GCF/_PAL/include/GCF/PAL/GCF_Answer.h +++ b/MAC/GCF/_PAL/include/GCF/PAL/GCF_Answer.h @@ -24,9 +24,9 @@ #ifndef GCF_ANSWER_H #define GCF_ANSWER_H -#include <GCF/GCF_TMProtocols.h> #include <GCF/GCF_Defines.h> -#include <GCF/GCF_Event.h> +#include <GCF/TM/GCF_Protocols.h> +#include <GCF/TM/GCF_Event.h> /** * This is an abstract class, which provides the possibility to handle @@ -141,16 +141,6 @@ struct GCFPropAnswerEvent : public GCFEvent const char* pPropName; }; -struct GCFConfAnswerEvent : public GCFPropSetAnswerEvent -{ - /// @param sig can only be F_PS_CONFIGURED - GCFConfAnswerEvent(unsigned short sig) : GCFPropSetAnswerEvent(sig) - { - length = sizeof(GCFConfAnswerEvent); - } - const char* pApcName; ///< Pointer to the name string of the APC (excl. path and extension) -}; - struct GCFPropSetAnswerEvent : public GCFEvent { /// @param sig can only be F_MYPS_ENABLED, F_MYPS_DISABLED, F_EXTPS_LOADED, F_EXTPS_UNLOADED @@ -164,6 +154,16 @@ struct GCFPropSetAnswerEvent : public GCFEvent ///< GCF_EXTPS_LOAD_ERROR, GCF_EXTPS_UNLOAD_ERROR, GCF_PS_CONFIGURE_ERROR }; +struct GCFConfAnswerEvent : public GCFPropSetAnswerEvent +{ + /// @param sig can only be F_PS_CONFIGURED + GCFConfAnswerEvent(unsigned short sig) : GCFPropSetAnswerEvent(sig) + { + length = sizeof(GCFConfAnswerEvent); + } + const char* pApcName; ///< Pointer to the name string of the APC (excl. path and extension) +}; + enum { F_PML_PROTOCOL = F_GCF_PROTOCOL + 2, }; diff --git a/MAC/GCF/_PAL/include/GCF/PAL/GCF_ExtProperty.h b/MAC/GCF/_PAL/include/GCF/PAL/GCF_ExtProperty.h index 3885a6f4d6641dfc5337a9f897daf5065e368c93..902b639bae7eca53019962da74cdd1c850326974 100644 --- a/MAC/GCF/_PAL/include/GCF/PAL/GCF_ExtProperty.h +++ b/MAC/GCF/_PAL/include/GCF/PAL/GCF_ExtProperty.h @@ -23,7 +23,7 @@ #ifndef GCF_EXTPROPERTY_H #define GCF_EXTPROPERTY_H -#include <GCF/GCFCommon/GCF_Defines.h> +#include <GCF/GCF_Defines.h> #include <GCF/PAL/GCF_Property.h> class GCFExtPropertySet; diff --git a/MAC/GCF/_PAL/include/GCF/PAL/GCF_ExtPropertySet.h b/MAC/GCF/_PAL/include/GCF/PAL/GCF_ExtPropertySet.h index 3188f2d56fceb2d6a00507eb9470ed1a2b746b64..f47b50688d2d78fbe518589c2bcf6f0b6fc19d63 100644 --- a/MAC/GCF/_PAL/include/GCF/PAL/GCF_ExtPropertySet.h +++ b/MAC/GCF/_PAL/include/GCF/PAL/GCF_ExtPropertySet.h @@ -24,7 +24,7 @@ #define GCF_EXTPROPERTYSET_H #include <GCF/GCF_Defines.h> -#include <GCF/GCF_PropertySet.h> +#include <GCF/PAL/GCF_PropertySet.h> /** * This class represents a property set of properties specified in an APC. It @@ -105,10 +105,10 @@ class GCFExtPropertySet : public GCFPropertySet //@} private: // helper methods - GCFProperty* createPropObject(TProperty& propInfo) const; + GCFProperty* createPropObject(TProperty& propInfo); private: // data members - _isLoaded; + bool _isLoaded; }; #endif diff --git a/MAC/GCF/_PAL/include/GCF/PAL/GCF_MyProperty.h b/MAC/GCF/_PAL/include/GCF/PAL/GCF_MyProperty.h index be2d3b08a5c7148879f3ad101b4b37296fb79dc2..dd0b5a853ded65e4f9e0966d2280af0f317c06a7 100644 --- a/MAC/GCF/_PAL/include/GCF/PAL/GCF_MyProperty.h +++ b/MAC/GCF/_PAL/include/GCF/PAL/GCF_MyProperty.h @@ -25,7 +25,7 @@ #include <GCF/GCF_PValue.h> #include <GCF/GCF_Defines.h> -#include <GCF/GCF_PropertyBase.h> +#include <GCF/PAL/GCF_Property.h> class GCFMyPropertySet; @@ -51,7 +51,7 @@ class GCFMyPropertySet; * the get(Old)Value methods are simply synchronous actions. */ -class GCFMyProperty : public GCFPropertyBase +class GCFMyProperty : public GCFProperty { public: GCFPValue* getValue () const; diff --git a/MAC/GCF/_PAL/include/GCF/PAL/GCF_MyPropertySet.h b/MAC/GCF/_PAL/include/GCF/PAL/GCF_MyPropertySet.h index 36fb8394abb58b31b98897dc9bff4a7a6ab8b4c2..25347bab7b52295f2db64f7f741e5b38e155c76f 100644 --- a/MAC/GCF/_PAL/include/GCF/PAL/GCF_MyPropertySet.h +++ b/MAC/GCF/_PAL/include/GCF/PAL/GCF_MyPropertySet.h @@ -23,8 +23,8 @@ #ifndef GCF_MYPROPERTYSET_H #define GCF_MYPROPERTYSET_H -#include <GCF/GCF_PropertySet.h> #include <GCF/GCF_Defines.h> +#include <GCF/PAL/GCF_PropertySet.h> #include <Common/lofar_list.h> @@ -89,11 +89,7 @@ class GCFMyPropertySet : public GCFPropertySet TGCFResult setValue (const string propName, ///< can be specified with or without the scope const string value); - - inline TGCFResult setValue (const string propName, ///< can be specified with or without the scope - const GCFPValue& value) - { return GCFPropertySetBase::setValue(propName, value); } - + //@{ /** * @param propName can be specified with or without the scope @@ -118,7 +114,7 @@ class GCFMyPropertySet : public GCFPropertySet private: // helper methods void retryLinking (); void init(); - GCFProperty* createPropObject(TProperty& propInfo) const; + GCFProperty* createPropObject(TProperty& propInfo); private: GCFMyPropertySet (); diff --git a/MAC/GCF/_PAL/include/GCF/PAL/GCF_Property.h b/MAC/GCF/_PAL/include/GCF/PAL/GCF_Property.h index 489e8389b4cf80f746acba39a2bfe7431ef884a7..3a74d678b2ce28c48d6f4d0801ef2fc110771ec5 100644 --- a/MAC/GCF/_PAL/include/GCF/PAL/GCF_Property.h +++ b/MAC/GCF/_PAL/include/GCF/PAL/GCF_Property.h @@ -23,13 +23,13 @@ #ifndef GCF_PROPERTY_H #define GCF_PROPERTY_H -#include <GCF/GCF_PropertyProxy.h> #include <GCF/GCF_Defines.h> class GPMPropertyService; class GCFPropertySet; class GCFAnswer; class GCFEvent; +class GCFPValue; /** * This is the base class for 2 types of properties. The owned (GCFMyProperty) @@ -47,8 +47,8 @@ class GCFEvent; class GCFProperty { public: - inline const string& getName () const - { return propInfo.propName;} + inline const string getName () const + { return _propInfo.propName;} /// @return the given property name including the scope of the related property set virtual const string getFullName () const; @@ -80,7 +80,6 @@ class GCFProperty GCFProperty (const TProperty& propInfo, GCFPropertySet* pPropertySet); virtual ~GCFProperty (); - protected: virtual TGCFResult subscribe (); virtual TGCFResult unsubscribe (); @@ -92,6 +91,9 @@ class GCFProperty virtual void valueGet (const GCFPValue& value); + protected: // helper attr. + bool _isBusy; + private: friend class GPMPropertyService; inline void propSubscribed (const string& propName) @@ -113,7 +115,7 @@ class GCFProperty { assert(propName == getFullName()); valueChanged(value); } private: - friend class GCFPropertySetBase; + friend class GCFPropertySet; inline void resetPropSetRef () { _pPropertySet = 0; } @@ -126,13 +128,12 @@ class GCFProperty //@} private: // data members - GCFPropertySetBase* _pPropertySet; + GCFPropertySet* _pPropertySet; GCFAnswer* _pAnswerObj; string _name; GPMPropertyService* _pPropService; private: // admin. data members - bool _isBusy; const TProperty& _propInfo; }; #endif diff --git a/MAC/GCF/_PAL/include/GCF/PAL/GCF_PropertyBase.h b/MAC/GCF/_PAL/include/GCF/PAL/GCF_PropertyBase.h deleted file mode 100644 index 15a48b62a3181a795c397fe6fcb2faebdbd77717..0000000000000000000000000000000000000000 --- a/MAC/GCF/_PAL/include/GCF/PAL/GCF_PropertyBase.h +++ /dev/null @@ -1,155 +0,0 @@ -//# GCF_PropertyBase.h: -//# -//# 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_PROPERTYBASE_H -#define GCF_PROPERTYBASE_H - -#include <GCF/GCF_PropertyProxy.h> -#include <GCF/GCF_Defines.h> - -class GCFPropertySetBase; -class GCFAnswer; -class GCFEvent; - -/** - * This is the base class for 2 types of properties. The owned (GCFMyProperty) - * and the external (GCFProperty) property. This class manages the: - * - name of the property, which points, together with the scopes of the - * related property set, to a property in the SCADA DB - * - answer object, which will be used for responses and indications from the - * SCADA system if specified. - * - * It uses the GCFPropertyProxy interface and provides the possibility to create - * and manage property objects by its name, which refers to one single SCADA - * property if existing. -*/ - -class GCFPropertyBase : public GCFPropertyProxy -{ - public: - inline const string& getName () const - { return _name;} - - /// @return the given property name including the scope of the related property set - virtual const string getFullName () const; - - /** - * Asynchronous action - * Performs a get operation on the SCADA DB - * @return can be GCF_NO_ERROR or GCF_PML_ERROR - */ - inline virtual TGCFResult requestValue () - { return requestPropValue(getFullName()); } - - /** - * Synchronous (!) action - * Performs a set operation on the SCADA DB - * @return can be GCF_NO_ERROR or GCF_PML_ERROR - */ - inline virtual TGCFResult setValue(const GCFPValue& value) - { return setPropValue(getFullName(), value); } - - /** - * Synchronous (!) action - * Checks whether the property exists in the SCADA DB or not - */ - inline virtual bool exists () - { return GCFPropertyProxy::exists(getFullName()); } - - inline virtual void setAnswer (GCFAnswer* pAnswerObj) - {_pAnswerObj = pAnswerObj;} - - protected: - GCFPropertyBase (string propName, - GCFPropertySetBase* pPropertySet) : - _pPropertySet(pPropertySet), - _pAnswerObj(0), - _name(propName) - {;} - virtual ~GCFPropertyBase (); - - protected: - inline virtual TGCFResult subscribe () - { return subscribeProp(getFullName()); } - - inline virtual TGCFResult unsubscribe () - { return unsubscribeProp(getFullName()); } - - virtual void dispatchAnswer(GCFEvent& answer); - - virtual void subscribed (); - - virtual void valueChanged (const GCFPValue& value); - - virtual void valueGet (const GCFPValue& value); - - private: - inline TGCFResult subscribeProp (const string& propName) - { return GCFPropertyProxy::subscribeProp (propName); } - - inline TGCFResult unsubscribeProp (const string& propName) - { return GCFPropertyProxy::unsubscribeProp (propName); } - - inline TGCFResult requestPropValue (const string& propName) - { return GCFPropertyProxy::requestPropValue (propName); } - - inline TGCFResult setPropValue (const string& propName, - const GCFPValue& value) - { return GCFPropertyProxy::setPropValue (propName, value); } - - inline void propSubscribed (const string& propName) - { assert(propName == getFullName()); subscribed(); } - - /** - * does nothing (but still in the GCF API) - * because unsubscribe isn't asynchronous in the SCADA API - */ - inline void propUnsubscribed (const string& propName) - { assert(propName == getFullName()); } - - inline void propValueGet (const string& propName, - const GCFPValue& value) - { assert(propName == getFullName()); valueGet(value); } - - inline void propValueChanged (const string& propName, - const GCFPValue& value) - { assert(propName == getFullName()); valueChanged(value); } - - private: - friend class GCFPropertySetBase; - inline void resetPropSetRef () - { _pPropertySet = 0; } - - private: - GCFPropertyBase(); - //@{ - /// Copy contructors. Don't allow copying this object. - GCFPropertyBase (const GCFPropertyBase&); - GCFPropertyBase& operator= (const GCFPropertyBase&); - //@} - - private: // data members - GCFPropertySetBase* _pPropertySet; - GCFAnswer* _pAnswerObj; - string _name; -}; -#endif diff --git a/MAC/GCF/_PAL/include/GCF/PAL/GCF_PropertySet.h b/MAC/GCF/_PAL/include/GCF/PAL/GCF_PropertySet.h index d86298a138a743d0b24f169f664e150efc30ab17..f9478754de3024aff239c2c16ebd4c6b2f4fcf8a 100644 --- a/MAC/GCF/_PAL/include/GCF/PAL/GCF_PropertySet.h +++ b/MAC/GCF/_PAL/include/GCF/PAL/GCF_PropertySet.h @@ -24,8 +24,9 @@ #define GCF_PROPERTYSET_H #include <GCF/GCF_Defines.h> -#include <GCF/GCF_Property.h> +#include <GCF/PAL/GCF_Property.h> +#include <Common/lofar_map.h> class GCFAnswer; class GCFPValue; @@ -82,12 +83,12 @@ class GCFPropertySet GCFAnswer* pAnswerObj); protected: // helper methods - virtual GCFProperty* createPropObject(TProperty& propInfo) const = 0; - void loadPropSetIntoRAM(); + virtual GCFProperty* createPropObject(TProperty& propInfo) = 0; + void loadPropSetIntoRam(); void dispatchAnswer (unsigned short sig, TGCFResult result); protected: // helper attributes - typedef map<string /*propName*/, GCFPropertyBase*> TPropertyList; + typedef map<string /*propName*/, GCFProperty*> TPropertyList; TPropertyList _properties; bool _isBusy; diff --git a/MAC/GCF/_PAL/include/GCF/PAL/GCF_PropertySetBase.h b/MAC/GCF/_PAL/include/GCF/PAL/GCF_PropertySetBase.h deleted file mode 100644 index 6e770c4bd383b2e43eb25b83bfce1f3ba4dd1c95..0000000000000000000000000000000000000000 --- a/MAC/GCF/_PAL/include/GCF/PAL/GCF_PropertySetBase.h +++ /dev/null @@ -1,100 +0,0 @@ -//# GCF_PropertySetBase.h: -//# -//# 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_PROPERTYSETBASE_H -#define GCF_PROPERTYSETBASE_H - -#include <GCF/GCF_Defines.h> -#include <GCF/GCF_PropertyBase.h> - -class GCFPropertyBase; -class GCFAnswer; -class GCFPValue; - -/** - * This class is the base class for the 2 types of property set containers. It - * implements a number of generic features of a property set (like scope - * management, property container). -*/ - -class GCFPropertySetBase -{ - public: - virtual ~GCFPropertySetBase (); - - inline const string& getScope () const - { return _scope; } - - /** - * Searches the property specified by the propName param - * @param propName with or without the scope - * @returns 0 if not in this property set - */ - GCFPropertyBase* getProperty (const string propName) const; - - /** - * Searches the property specified by the propName param - * @param propName with or without the scope - * @returns a dummy port if property could not be found - */ - virtual GCFPropertyBase& operator[] (const string propName); - - /** - * Searches the property specified by the propName param - * @param propName with or without the scope - * @returns 0 if not in this property set - */ - virtual TGCFResult setValue (const string propName, - const GCFPValue& value); - - virtual void setAnswer (GCFAnswer* pAnswerObj); - - virtual bool exists (const string propName) const; - - protected: - GCFPropertySetBase (string scope, - GCFAnswer* pAnswerObj); - void addProperty(const string& propName, GCFPropertyBase& prop); - void clearAllProperties(); - inline GCFAnswer* getAnswerObj() const - { return _pAnswerObj; } - - protected: - typedef map<string /*propName*/, GCFPropertyBase*> TPropertyList; - TPropertyList _properties; - - private: // helper methods - bool cutScope(string& propName) const; - - private: - GCFPropertySetBase(); - - /// Don't allow copying this object. - GCFPropertySetBase (const GCFPropertySetBase&); - GCFPropertySetBase& operator= (const GCFPropertySetBase&); - - private: - GCFAnswer* _pAnswerObj; - string _scope; - GCFPropertyBase _dummyProperty; -}; -#endif