diff --git a/.gitattributes b/.gitattributes index 08fa95ec694398af46c97846693a07e88de74b16..bcd410b9068a71a5a36024505bed990935ea6678 100644 --- a/.gitattributes +++ b/.gitattributes @@ -155,7 +155,6 @@ MAC/Config/mac.ns -text svneol=native#application/octet-stream MAC/Config/mac.top -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/autogen/protocol.tpl -text svneol=native#application/octet-stream MAC/GCF/GCFCommon/src/Makefile.am -text svneol=native#application/octet-stream MAC/GCF/Makefile.am -text svneol=native#application/octet-stream MAC/GCF/README -text svneol=native#application/octet-stream diff --git a/MAC/GCF/GCFCommon/autogen/protocol.tpl b/MAC/GCF/GCFCommon/autogen/protocol.tpl deleted file mode 100644 index fc8197f8ac9db87ee906409903333eeb68c67e13..0000000000000000000000000000000000000000 --- a/MAC/GCF/GCFCommon/autogen/protocol.tpl +++ /dev/null @@ -1,90 +0,0 @@ -[+ AutoGen5 template ph +] -// -[+ (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 signal_name +][+ prefix_ucase +]_[+ (get "signal") +][+ ENDDEF +] -[+ DEFINE signal_id +][+ signal_name +]_ID[+ ENDDEF +] -[+ DEFINE struct_name +][+ prefix_cap +][+ (string-capitalize! (get "signal")) +]Event[+ ENDDEF +] -[+ DEFINE struct_decl +][+ struct_name +] : public GCFEvent[+ ENDDEF +] -[+ DEFINE protocol_name +][+ (string-upcase (base-name)) +][+ ENDDEF +] -[+ DEFINE param +][+ (get "type") +] [+ (get "name") +][+ IF (exist? "dim")+][[+ (get "dim") +]][+ ENDIF +][+ enddef +] -[+ DEFINE param_arg +][+ (get "type") +] [+ (get "name") +]_arg[+ IF (exist? "dim")+][[+ (get "dim") +]][+ ENDIF +][+ enddef +] -[+ DEFINE param_init +][+ IF (exist? "init") +],[+ (get "name") +]([+ (get "init") +])[+ ENDIF +][+ enddef +] -[+ (out-pop) +] -// -// [+ (base-name) +].h: [+ description +] -// -// Copyright (C) 2003 -// ASTRON (Netherlands Foundation for Research in Astronomy) -// P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl -// -[+ (lgpl "This program" "ASTRON" "// ") +] -// -// $Id$ -// - -#ifndef [+ protocol_name +]_H -#define [+ protocol_name +]_H - -#include <string.h> // needed for memcpy -#include <GCF/GCF_TMProtocols.h> -[+ FOR include "" +] -#include [+ (get "include") +][+ ENDFOR +] - -[+ (get "prelude") +] - -namespace [+ (base-name) +] -{ - // - // 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 +] - -[+ FOR event "" +][+ IF (< 0 (count "param")) +] - struct [+ struct_decl +] - { - [+ struct_name +]([+ FOR param "," +] - [+ param_arg +][+ ENDFOR +]) - : GCFEvent([+ signal_name +]),[+ FOR param "," +] - [+ (get "name") +]([+ IF (not (exist? "dim")) +][+ (get "name") +]_arg[+ ENDIF +])[+ ENDFOR +] - { - length = sizeof([+ struct_name +]); - - [+ FOR param "" +] - [+ IF (exist? "dim") +]memcpy([+ (get "name") +], [+ (get "name") +]_arg, [+ (get "dim") +] * sizeof([+ (get "type") +]));[+ ENDIF +][+ ENDFOR +] - } - - [+ struct_name +]() : GCFEvent([+ signal_name +])[+ FOR param "" +][+ param_init +][+ ENDFOR +] - { - length = sizeof([+ struct_name +]); - } - [+ FOR param ";" +] - [+ param +][+ ENDFOR +]; - }; -[+ ENDIF +][+ ENDFOR +] - -} // namespace [+ (base-name) +] - -using namespace [+ (base-name) +]; - -#ifdef DECLARE_SIGNAL_NAMES - -const char* [+ protocol_name +]_signalnames[] = { - "[+ protocol_name +]: invalid signal",[+ FOR event "," +] - "[+ signal_name +]"[+ ENDFOR +] -}; - -#else - -// extern declaration of protocol event names -extern const char* [+ protocol_name +]_signalnames[]; - -#endif - -#endif diff --git a/MAC/GCF/GCFCommon/src/Utils.cc b/MAC/GCF/GCFCommon/src/Utils.cc index f0deac807560f75ffce7bb9b1f044481c7149038..5e516a610befef3a196bed3b10447e28ae69a3d3 100644 --- a/MAC/GCF/GCFCommon/src/Utils.cc +++ b/MAC/GCF/GCFCommon/src/Utils.cc @@ -8,51 +8,24 @@ Utils::Utils() Utils::~Utils() {} -unsigned int Utils::unpackString(char* pStringData, string& value) +void Utils::getPropertyListString(string& propListString, + const list<string>& propertyList) { - unsigned int stringLength(0); - memcpy((void *) &stringLength, pStringData, SLEN_FIELD_SIZE); - value.clear(); - value.append(pStringData + SLEN_FIELD_SIZE, stringLength); - return stringLength + SLEN_FIELD_SIZE; -} - -unsigned int Utils::packString(const string& value, char* buffer, unsigned int maxBufferSize) -{ - unsigned int neededBufLength = value.size() + SLEN_FIELD_SIZE; - assert(neededBufLength < maxBufferSize); - unsigned int stringLength(value.size()); - memcpy(buffer, (void *) &stringLength, SLEN_FIELD_SIZE); - memcpy(buffer + SLEN_FIELD_SIZE, (void *) value.c_str(), value.size()); - return neededBufLength; -} - -unsigned short Utils::getStringDataLength(char* pStringData) -{ - unsigned int stringLength(0); - memcpy((void *) &stringLength, pStringData, SLEN_FIELD_SIZE); - return stringLength + SLEN_FIELD_SIZE; -} - -unsigned int Utils::packPropertyList(list<string>& propertyList, char* buffer, unsigned int maxBufferSize) -{ - string allPropNames; - for (list<string>::iterator iter = propertyList.begin(); + propListString.clear(); + for (list<string>::const_iterator iter = propertyList.begin(); iter != propertyList.end(); ++iter) { - allPropNames += *iter; - allPropNames += '|'; + propListString += *iter; + propListString += '|'; } - - return packString(allPropNames, buffer, maxBufferSize); } -void Utils::unpackPropertyList(char* pListData, list<string>& propertyList) +void Utils::getPropertyListFromString(list<string>& propertyList, + const string& propListString) { - unsigned int dataLength; - memcpy((void *) &dataLength, pListData, SLEN_FIELD_SIZE); + unsigned int dataLength = propListString.length(); char propertyData[dataLength + 1]; - memcpy(propertyData, pListData + SLEN_FIELD_SIZE, dataLength); + memcpy(propertyData, propListString.c_str(), dataLength); propertyData[dataLength] = 0; propertyList.clear(); if (dataLength > 0) diff --git a/MAC/GCF/GCFCommon/src/Utils.h b/MAC/GCF/GCFCommon/src/Utils.h index a85ad82678b4c4278bdbc9f5306b166b6ec9732b..64754a5f4aec236ac75d872198dc886507d4967f 100644 --- a/MAC/GCF/GCFCommon/src/Utils.h +++ b/MAC/GCF/GCFCommon/src/Utils.h @@ -11,19 +11,10 @@ class Utils Utils(); ~Utils(); - static unsigned int packString(const string& value, - char* buffer, - unsigned int maxBufferSize); - - static unsigned int unpackString(char* pStringData, - string& value); - - static unsigned short getStringDataLength(char* pStringData); - static const unsigned int SLEN_FIELD_SIZE = sizeof(unsigned int); - static unsigned int packPropertyList(list<string>& propertyList, - char* buffer, - unsigned int maxBufferSize); - static void unpackPropertyList(char* pListData, list<string>& propertyList); + static void getPropertyListString(string& propListString, + const list<string>& propertyList); + static void getPropertyListFromString(list<string>& propertyList, + const string& propListString); static bool isValidPropName(const char* propName); }; diff --git a/MAC/GCF/Services/PI/src/GPI_Controller.cc b/MAC/GCF/Services/PI/src/GPI_Controller.cc index 34f9273b12464443273abb7663245b018a8b457a..f3f8389a42850f4def8ad8cc7ed469e4f6fef92d 100644 --- a/MAC/GCF/Services/PI/src/GPI_Controller.cc +++ b/MAC/GCF/Services/PI/src/GPI_Controller.cc @@ -47,19 +47,19 @@ GCFEvent::TResult GPIController::initial(GCFEvent& e, GCFPortInterface& p) switch (e.signal) { - case F_INIT_SIG: + case F_INIT: break; - case F_ENTRY_SIG: - case F_TIMER_SIG: + case F_ENTRY: + case F_TIMER: _ssPortProvider.open(); break; - case F_CONNECTED_SIG: + case F_CONNECTED: TRAN(GPIController::connected); break; - case F_DISCONNECTED_SIG: + case F_DISCONNECTED: if (&p == &_ssPortProvider) _ssPortProvider.setTimer(1.0); // try again after 1 second break; @@ -78,14 +78,14 @@ GCFEvent::TResult GPIController::connected(GCFEvent& e, GCFPortInterface& p) switch (e.signal) { - case F_DISCONNECTED_SIG: + case F_DISCONNECTED: if (&p == &_ssPortProvider) { // TODO: find out this implies problems for the concrete ports too or not } break; - case F_ACCEPT_REQ_SIG: + case F_ACCEPT_REQ: { GPISupervisoryServer* pNewSS = new GPISupervisoryServer(*this); pNewSS->start(); @@ -93,7 +93,7 @@ GCFEvent::TResult GPIController::connected(GCFEvent& e, GCFPortInterface& p) break; } - case F_TIMER_SIG: + case F_TIMER: { GCFTimerEvent* pTimer = static_cast<GCFTimerEvent*>(&e); if (pTimer->arg) diff --git a/MAC/GCF/Services/PI/src/GPI_PValue.h b/MAC/GCF/Services/PI/src/GPI_PValue.h new file mode 100644 index 0000000000000000000000000000000000000000..ddf8a5346d7e174474aa515046279c631fd83044 --- /dev/null +++ b/MAC/GCF/Services/PI/src/GPI_PValue.h @@ -0,0 +1,88 @@ +//# GPI_PValue.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 GPI_PVALUE_H +#define GPI_PVALUE_H + +#ifdef SWIG +%module GPIPValue +%include std_string.i +%typemap(in) std::string* ($*1_ltype tempstr) { + char * temps; int templ; + if (PyString_AsStringAndSize($input, &temps, &templ)) return NULL; + tempstr = $*1_ltype(temps, templ); + $1 = &tempstr; +} +%typemap(out) std::string* { + $result = PyString_FromStringAndSize($1->data(), $1->length()); +} +%{ +#include "GPI_PValue.h" +%} +#endif + +#include <GCF/GCF_Event.h> +#include <GCF/GCF_PValue.h> + +class GPIPValue : public GCFTransportable +{ + public: + GPIPValue() : _pValue(0), _unpacked(false) {}; + GPIPValue(const GCFPValue& value) : _pValue(&value), _unpacked(false) {}; + + virtual ~GPIPValue() + { + if (_unpacked) delete _pValue; + } + +#ifdef SWIG + protected: +#endif + + unsigned int pack(char* buffer) + { + assert(_pValue); + return _pValue->pack(buffer); + } + unsigned int unpack(char* buffer) + { + assert(!_pValue); + _unpacked = true; + _pValue = GCFPValue::unpackValue(buffer); + return _pValue->getSize(); + } + unsigned int getSize() + { + assert(_pValue); + return _pValue->getSize(); + } + +#ifdef SWIG + public: +#endif + const GCFPValue* _pValue; + + private: + bool _unpacked; +}; + +#endif diff --git a/MAC/GCF/Services/PI/src/GPI_PropertySet.cc b/MAC/GCF/Services/PI/src/GPI_PropertySet.cc index c7fe6356ccce925a749d33c75797ac47251d2433..0d0297d55b35a632fbe6b4d0040cbc1023e7ddb2 100644 --- a/MAC/GCF/Services/PI/src/GPI_PropertySet.cc +++ b/MAC/GCF/Services/PI/src/GPI_PropertySet.cc @@ -51,75 +51,73 @@ void GPIPropertySet::propSubscribed(const string& /*propName*/) _counter--; if (_counter == 0 && _tmpSubsList.size() == 0) { - PAPropertieslinkedEvent paPlE(0, PA_NO_ERROR); - unsigned int scopeDataLength = Utils::packString(_scope, _buffer, MAX_BUF_SIZE); - paPlE.result = convertPIToPAResult(_tmpPIResult); - paPlE.length += scopeDataLength; + PAPropertiesLinkedEvent responseOut; + responseOut.result = convertPIToPAResult(_tmpPIResult); + responseOut.scope = _scope; _state = REGISTERED; - _ss.getPAPort().send(paPlE, _buffer, scopeDataLength); + _ss.getPAPort().send(responseOut); } } void GPIPropertySet::propValueChanged(const string& propName, const GCFPValue& value) { - PIValuechangedEvent e(_scope.length()); - unsigned int dataLength = Utils::packString(propName, _buffer, MAX_BUF_SIZE); - dataLength += value.pack(_buffer + dataLength, MAX_BUF_SIZE - dataLength); - e.length += dataLength; - _ss.getPort().send(e, _buffer, dataLength); + PIValueChangedEvent indicationOut; + indicationOut.scopeLength = _scope.length(); + indicationOut.name = propName; + indicationOut.value._pValue = &value; + _ss.getPort().send(indicationOut); } -void GPIPropertySet::registerScope(GCFEvent& e) +void GPIPropertySet::registerScope(PIRegisterScopeEvent& requestIn) { - PARegisterscopeEvent pae(0); - forwardMsgToPA(pae, e); + PARegisterScopeEvent requestOut; + requestOut.scope = requestIn.scope; + forwardMsgToPA(requestOut); } void GPIPropertySet::registerCompleted(TPAResult result) { - PIScoperegisteredEvent piSrE(PI_NO_ERROR); + PIScopeRegisteredEvent responseOut; + responseOut.scope = _scope; + responseOut.result = convertPAToPIResult(result); assert(_ss.getPort().isConnected()); - unsigned int scopeDataLength = Utils::packString(_scope, _buffer, MAX_BUF_SIZE); - piSrE.result = convertPAToPIResult(result); - piSrE.length += scopeDataLength; - _ss.getPort().send(piSrE, _buffer, scopeDataLength); + _ss.getPort().send(responseOut); if (result == PA_NO_ERROR) { _state = REGISTERED; } } -void GPIPropertySet::unregisterScope(GCFEvent& e) +void GPIPropertySet::unregisterScope(PIUnregisterScopeEvent& requestIn) { - PAUnregisterscopeEvent pae(0); - forwardMsgToPA(pae, e); + PAUnregisterScopeEvent requestOut; + requestOut.scope = requestIn.scope; _state = UNREGISTERING; + forwardMsgToPA(requestOut); } void GPIPropertySet::unregisterCompleted(TPAResult result) { - PIScopeunregisteredEvent piSurE(PI_NO_ERROR); - assert(_ss.getPort().isConnected()); assert(_state == UNREGISTERING); - unsigned int scopeDataLength = Utils::packString(_scope, _buffer, MAX_BUF_SIZE); - piSurE.result = convertPAToPIResult(result); - piSurE.length += scopeDataLength; - _ss.getPort().send(piSurE, _buffer, scopeDataLength); + PIScopeUnregisteredEvent responseOut; + responseOut.scope = _scope; + responseOut.result = convertPAToPIResult(result); + assert(_ss.getPort().isConnected()); + _ss.getPort().send(responseOut); } -void GPIPropertySet::linkProperties(PALinkpropertiesEvent& e) +void GPIPropertySet::linkProperties(PALinkPropertiesEvent& e) { assert(_state == REGISTERED || _state == UNREGISTERING); if (_state == REGISTERED) { - GCFEvent piLpE(PI_LINKPROPERTIES); - char* pData = ((char*)&e) + sizeof(PALinkpropertiesEvent); - unsigned int dataLength = e.length - sizeof(PALinkpropertiesEvent); - piLpE.length += dataLength; + PILinkPropertiesEvent requestOut; + requestOut.scope = e.scope; + requestOut.propList = e.propList; _state = LINKING; - _ss.getPort().send(piLpE, pData, dataLength); + _ss.getPort().send(requestOut); } else { @@ -129,15 +127,15 @@ void GPIPropertySet::linkProperties(PALinkpropertiesEvent& e) } } -bool GPIPropertySet::propertiesLinked(TPIResult result, char* pData) +bool GPIPropertySet::propertiesLinked(PIPropertiesLinkedEvent& responseIn) { if (_state == LINKING) - { - Utils::unpackPropertyList(pData, _tmpSubsList); + { + Utils::getPropertyListFromString(_tmpSubsList, responseIn.propList); assert(_counter == 0); - if (result != PI_PROP_SET_GONE) + if (responseIn.result != PI_PROP_SET_GONE) { - _tmpPIResult = result; + _tmpPIResult = responseIn.result; return retrySubscriptions(); } } @@ -178,12 +176,11 @@ bool GPIPropertySet::retrySubscriptions() // no more asyncronous subscription responses will be expected and // no more properties needed to be subscribed // so we can return a response to the PA - PAPropertieslinkedEvent paPlE(0, PA_NO_ERROR); - unsigned int scopeDataLength = Utils::packString(_scope, _buffer, MAX_BUF_SIZE); - paPlE.result = convertPIToPAResult(_tmpPIResult); - paPlE.length += scopeDataLength; + PAPropertiesLinkedEvent responseOut; + responseOut.result = PA_NO_ERROR; + responseOut.scope = _scope; _state = REGISTERED; - _ss.getPAPort().send(paPlE, _buffer, scopeDataLength); + _ss.getPAPort().send(responseOut); retry = false; } } @@ -194,18 +191,17 @@ bool GPIPropertySet::retrySubscriptions() return retry; } -void GPIPropertySet::unlinkProperties(PAUnlinkpropertiesEvent& e) +void GPIPropertySet::unlinkProperties(PAUnlinkPropertiesEvent& requestIn) { assert(_state == REGISTERED || _state == UNREGISTERING); if (_state == REGISTERED) { - GCFEvent piUlpE(PI_UNLINKPROPERTIES); - char* pData = ((char*)&e) + sizeof(PAUnlinkpropertiesEvent); - unsigned int dataLength = e.length - sizeof(PAUnlinkpropertiesEvent); - piUlpE.length += dataLength; + PIUnlinkPropertiesEvent requestOut; + requestOut.scope = requestIn.scope; + requestOut.propList = requestIn.propList; _state = UNLINKING; - _ss.getPort().send(piUlpE, pData, dataLength); + _ss.getPort().send(requestOut); } else { @@ -215,11 +211,12 @@ void GPIPropertySet::unlinkProperties(PAUnlinkpropertiesEvent& e) } } -void GPIPropertySet::propertiesUnlinked(TPIResult result, char* pData) +void GPIPropertySet::propertiesUnlinked(PIPropertiesUnlinkedEvent& responseIn) { if (_state == UNLINKING) { - Utils::unpackPropertyList(pData, _tmpSubsList); + Utils::getPropertyListFromString(_tmpSubsList, responseIn.propList); + for (list<string>::iterator iter = _tmpSubsList.begin(); iter != _tmpSubsList.end(); ++iter) { @@ -234,34 +231,22 @@ void GPIPropertySet::propertiesUnlinked(TPIResult result, char* pData) } if (exists(fullName)) { - TGCFResult result = unsubscribeProp(fullName); - assert(result == GCF_NO_ERROR); + TGCFResult gcfResult = unsubscribeProp(fullName); + assert(gcfResult == GCF_NO_ERROR); } } - PAPropertiesunlinkedEvent paPulE(0, PA_NO_ERROR); - unsigned int scopeDataLength = Utils::packString(_scope, _buffer, MAX_BUF_SIZE); - paPulE.result = convertPIToPAResult(result); - paPulE.length += scopeDataLength; + PAPropertiesUnlinkedEvent responseOut; + responseOut.result = convertPIToPAResult(responseIn.result); + responseOut.scope = responseIn.scope; _state = REGISTERED; - _ss.getPAPort().send(paPulE, _buffer, scopeDataLength); + _ss.getPAPort().send(responseOut); } } -void GPIPropertySet::forwardMsgToPA(GCFEvent& pae, GCFEvent& pie) +void GPIPropertySet::forwardMsgToPA(GCFEvent& msg) { if (_ss.getPAPort().isConnected()) { - unsigned int pieDataLength = pie.length - sizeof(GCFEvent); - pae.length += pieDataLength; - _ss.getPAPort().send(pae, ((char*)&pie) + sizeof(GCFEvent), pieDataLength); + _ss.getPAPort().send(msg); } } - -void GPIPropertySet::replyMsgToSS(GCFEvent& e, char* pScopeData) -{ - assert(_ss.getPort().isConnected()); - unsigned short scopeDataLength = Utils::getStringDataLength(pScopeData); - e.length += scopeDataLength; - _ss.getPort().send(e, pScopeData, scopeDataLength); -} - diff --git a/MAC/GCF/Services/PI/src/GPI_PropertySet.h b/MAC/GCF/Services/PI/src/GPI_PropertySet.h index 4540fbb3767e5d7c22c5fc53b8062cea1cc0eb5a..db7a31f69870c483e774e55aa5558b80331265f5 100644 --- a/MAC/GCF/Services/PI/src/GPI_PropertySet.h +++ b/MAC/GCF/Services/PI/src/GPI_PropertySet.h @@ -24,6 +24,7 @@ #define GPI_PROPERTYSET_H #include <PA_Protocol.ph> +#include "PI_Protocol.ph" #include "GPI_Defines.h" #include <Common/lofar_list.h> @@ -50,17 +51,17 @@ class GPIPropertySet : public GCFPropertyProxy _tmpPIResult(PI_NO_ERROR) {} virtual ~GPIPropertySet() {assert(_state == UNREGISTERING);} - void registerScope(GCFEvent& e); + void registerScope(PIRegisterScopeEvent& e); void registerCompleted(TPAResult result); - void unregisterScope(GCFEvent& e); + void unregisterScope(PIUnregisterScopeEvent& e); void unregisterCompleted(TPAResult result); - void linkProperties(PALinkpropertiesEvent& request); + void linkProperties(PALinkPropertiesEvent& requestIn); bool retrySubscriptions(); - bool propertiesLinked(TPIResult result, char* pData); - void unlinkProperties(PAUnlinkpropertiesEvent& request); - void propertiesUnlinked(TPIResult result, char* pData); + bool propertiesLinked(PIPropertiesLinkedEvent& responseIn); + void unlinkProperties(PAUnlinkPropertiesEvent& requestIn); + void propertiesUnlinked(PIPropertiesUnlinkedEvent& responseIn); private: void propSubscribed(const string& propName); @@ -69,8 +70,7 @@ class GPIPropertySet : public GCFPropertyProxy void propValueChanged(const string& propName, const GCFPValue& value); private: //helper methods - void forwardMsgToPA(GCFEvent& pae, GCFEvent& pie); - void replyMsgToSS(GCFEvent& e, char* pScopeData); + void forwardMsgToPA(GCFEvent& msg); private: GPIPropertySet(); @@ -97,10 +97,8 @@ class GPIPropertySet : public GCFPropertyProxy TScopeState _state; private: - static const unsigned int MAX_BUF_SIZE = 5000; unsigned int _counter; TPIResult _tmpPIResult; - char _buffer[MAX_BUF_SIZE]; list<string> _tmpSubsList; }; #endif diff --git a/MAC/GCF/Services/PI/src/GPI_SupervisoryServer.cc b/MAC/GCF/Services/PI/src/GPI_SupervisoryServer.cc index c96f71cc7cd8ac8bca817075e641abb20dfc8662..420105b4f145076d8c49329e0c87f588e60efa2c 100644 --- a/MAC/GCF/Services/PI/src/GPI_SupervisoryServer.cc +++ b/MAC/GCF/Services/PI/src/GPI_SupervisoryServer.cc @@ -24,9 +24,8 @@ #include "GPI_Controller.h" #include "GPI_PropertySet.h" #include <Utils.h> -#include <GCF/GCF_PValue.h> +#include "GPI_PValue.h" -#define DECLARE_SIGNAL_NAMES #include "PI_Protocol.ph" #include <PA_Protocol.ph> @@ -56,22 +55,22 @@ GCFEvent::TResult GPISupervisoryServer::initial(GCFEvent& e, GCFPortInterface& p switch (e.signal) { - case F_INIT_SIG: + case F_INIT: break; - case F_ENTRY_SIG: + case F_ENTRY: _controller.getPortProvider().accept(_ssPort); // intential fall through - case F_TIMER_SIG: + case F_TIMER: _propertyAgent.open(); break; - case F_CONNECTED_SIG: + case F_CONNECTED: if (_ssPort.isConnected()) TRAN(GPISupervisoryServer::operational); break; - case F_DISCONNECTED_SIG: + case F_DISCONNECTED: p.setTimer(1.0); // try again after 1 second break; @@ -86,27 +85,25 @@ GCFEvent::TResult GPISupervisoryServer::initial(GCFEvent& e, GCFPortInterface& p GCFEvent::TResult GPISupervisoryServer::operational(GCFEvent& e, GCFPortInterface& p) { GCFEvent::TResult status = GCFEvent::HANDLED; - static string scope = ""; - static char* pData = 0; static GPIPropertySet* pPropertySet = 0; static int timerID = -1; switch (e.signal) { - case F_CONNECTED_SIG: + case F_CONNECTED: if (&p == &_propertyAgent) { - PARegisterscopeEvent rse(0); + PARegisterScopeEvent requestOut; for (TScopeRegister::iterator iter = _scopeRegister.begin(); iter != _scopeRegister.end(); ++iter) { - rse.length = sizeof(GCFEvent) + Utils::packString(iter->first, _buffer, MAX_BUF_SIZE); - _propertyAgent.send(rse, _buffer, rse.length - sizeof(GCFEvent)); + requestOut.scope = iter->first; + _propertyAgent.send(requestOut); } } break; - case F_DISCONNECTED_SIG: + case F_DISCONNECTED: if (&_propertyAgent == &p) { p.setTimer(1.0); // try again after 1 second @@ -118,7 +115,7 @@ GCFEvent::TResult GPISupervisoryServer::operational(GCFEvent& e, GCFPortInterfac } break; - case F_TIMER_SIG: + case F_TIMER: if (&_propertyAgent == &p) { p.open(); // try again @@ -139,128 +136,121 @@ GCFEvent::TResult GPISupervisoryServer::operational(GCFEvent& e, GCFPortInterfac } break; - case PI_REGISTERSCOPE: + case PI_REGISTER_SCOPE: { - pData = ((char*)&e) + sizeof(GCFEvent); - if (!findPropertySet(pData, scope)) + PIRegisterScopeEvent requestIn(e); + if (!findPropertySet(requestIn.scope)) { - pPropertySet = new GPIPropertySet(*this, scope); - _scopeRegister[scope] = pPropertySet; - pPropertySet->registerScope(e); + pPropertySet = new GPIPropertySet(*this, requestIn.scope); + _scopeRegister[requestIn.scope] = pPropertySet; + pPropertySet->registerScope(requestIn); } else { - PIScoperegisteredEvent response(PI_SCOPE_ALREADY_REGISTERED); - unsigned int scopeDataLength = Utils::packString(scope, _buffer, MAX_BUF_SIZE); - response.length += scopeDataLength; - _ssPort.send(response, _buffer, scopeDataLength); + PIScopeRegisteredEvent responseOut; + responseOut.result = PI_SCOPE_ALREADY_REGISTERED; + responseOut.scope = requestIn.scope; + _ssPort.send(responseOut); } LOFAR_LOG_INFO(PI_STDOUT_LOGGER, ( "SS-REQ: Register scope %s", - scope.c_str())); + requestIn.scope.c_str())); break; } - case PA_SCOPEREGISTERED: + case PA_SCOPE_REGISTERED: { - PAScoperegisteredEvent* pResponse = static_cast<PAScoperegisteredEvent*>(&e); - assert(pResponse); - pData = ((char*)&e) + sizeof(PAScoperegisteredEvent); - pPropertySet = findPropertySet(pData, scope); + PAScopeRegisteredEvent responseIn(e); + + pPropertySet = findPropertySet(responseIn.scope); LOFAR_LOG_INFO(PI_STDOUT_LOGGER, ( "PA-RESP: Scope %s is registered", - scope.c_str())); + responseIn.scope.c_str())); if (pPropertySet) { - pPropertySet->registerCompleted(pResponse->result); + pPropertySet->registerCompleted(responseIn.result); } else { // in case a scope is gone due to a crash in a controller application on // the RTC - if (pResponse->result == PA_NO_ERROR) + if (responseIn.result == PA_NO_ERROR) { - GCFEvent paUrsE(PA_UNREGISTERSCOPE); - unsigned int scopeDataLength = scope.length() + Utils::SLEN_FIELD_SIZE; - paUrsE.length += scopeDataLength; - _propertyAgent.send(paUrsE, pData, scopeDataLength); + PAUnregisterScopeEvent requestOut; + requestOut.scope = responseIn.scope; + _propertyAgent.send(requestOut); } LOFAR_LOG_TRACE(PI_STDOUT_LOGGER, ( "Property set with scope %d was deleted in the meanwhile", - scope.c_str())); + responseIn.scope.c_str())); } break; } - case PI_UNREGISTERSCOPE: + case PI_UNREGISTER_SCOPE: { - pData = ((char*)&e) + sizeof(GCFEvent); - pPropertySet = findPropertySet(pData, scope); + PIUnregisterScopeEvent requestIn(e); + pPropertySet = findPropertySet(requestIn.scope); LOFAR_LOG_INFO(PI_STDOUT_LOGGER, ( "SS-REQ: Unregister scope %s", - scope.c_str())); + requestIn.scope.c_str())); assert(pPropertySet); - pPropertySet->unregisterScope(e); + pPropertySet->unregisterScope(requestIn); break; } - case PA_SCOPEUNREGISTERED: + case PA_SCOPE_UNREGISTERED: { - PAScopeunregisteredEvent* pResponse = static_cast<PAScopeunregisteredEvent*>(&e); - assert(pResponse); - pData = ((char*)&e) + sizeof(PAScopeunregisteredEvent); - pPropertySet = findPropertySet(pData, scope); + PAScopeUnregisteredEvent responseIn(e); + pPropertySet = findPropertySet(responseIn.scope); LOFAR_LOG_INFO(PI_STDOUT_LOGGER, ( "PA-RESP: Scope %s is unregistered", - scope.c_str())); + responseIn.scope.c_str())); if (pPropertySet) { - pPropertySet->unregisterCompleted(pResponse->result); + pPropertySet->unregisterCompleted(responseIn.result); delete pPropertySet; } - _scopeRegister.erase(scope); + _scopeRegister.erase(responseIn.scope); break; } - case PA_LINKPROPERTIES: + case PA_LINK_PROPERTIES: { - PALinkpropertiesEvent* pRequest = static_cast<PALinkpropertiesEvent*>(&e); - assert(pRequest); - pData = ((char*)&e) + sizeof(PALinkpropertiesEvent); - pPropertySet = findPropertySet(pData, scope); + PALinkPropertiesEvent requestIn(e); + pPropertySet = findPropertySet(requestIn.scope); LOFAR_LOG_INFO(PI_STDOUT_LOGGER, ( "PA-REQ: Link properties on scope %s", - scope.c_str())); + requestIn.scope.c_str())); if (pPropertySet) { - pPropertySet->linkProperties(*pRequest); + pPropertySet->linkProperties(requestIn); } else { - PAPropertieslinkedEvent response(0, PA_PROP_SET_GONE); - replyMsgToPA(response, pData); + PAPropertiesLinkedEvent responseOut; + responseOut.result = PA_PROP_SET_GONE; + responseOut.scope = requestIn.scope; + replyMsgToPA(responseOut); LOFAR_LOG_TRACE(PI_STDOUT_LOGGER, ( "Property set with scope %d was deleted in the meanwhile", - scope.c_str())); + responseOut.scope.c_str())); } break; } - case PI_PROPERTIESLINKED: + case PI_PROPERTIES_LINKED: { - PIPropertieslinkedEvent* pResponse = static_cast<PIPropertieslinkedEvent*>(&e); - assert(pResponse); - pData = ((char*)&e) + sizeof(PIPropertieslinkedEvent); - pPropertySet = findPropertySet(pData, scope); - pData += Utils::getStringDataLength(pData); + PIPropertiesLinkedEvent responseIn(e); + pPropertySet = findPropertySet(responseIn.scope); if (pPropertySet) { - bool mustRetry = pPropertySet->propertiesLinked(pResponse->result, pData); + bool mustRetry = pPropertySet->propertiesLinked(responseIn); if (mustRetry && timerID == -1) { timerID = _ssPort.setTimer(0.0); @@ -268,55 +258,48 @@ GCFEvent::TResult GPISupervisoryServer::operational(GCFEvent& e, GCFPortInterfac } break; } - case PA_UNLINKPROPERTIES: + case PA_UNLINK_PROPERTIES: { - PAUnlinkpropertiesEvent* pRequest = static_cast<PAUnlinkpropertiesEvent*>(&e); - assert(pRequest); - pData = ((char*)&e) + sizeof(PAUnlinkpropertiesEvent); - pPropertySet = findPropertySet(pData, scope); + PAUnlinkPropertiesEvent requestIn(e); + pPropertySet = findPropertySet(requestIn.scope); LOFAR_LOG_INFO(PI_STDOUT_LOGGER, ( "PA-REQ: Unlink properties on scope %s", - scope.c_str())); + requestIn.scope.c_str())); if (pPropertySet) { - pPropertySet->unlinkProperties(*pRequest); + pPropertySet->unlinkProperties(requestIn); } else { - PAPropertiesunlinkedEvent response(0, PA_PROP_SET_GONE); - replyMsgToPA(response, pData); + PAPropertiesUnlinkedEvent responseOut; + responseOut.result = PA_PROP_SET_GONE; + responseOut.scope = requestIn.scope; + replyMsgToPA(responseOut); LOFAR_LOG_TRACE(PI_STDOUT_LOGGER, ( "Property set with scope %d was deleted in the meanwhile", - scope.c_str())); + responseOut.scope.c_str())); } break; } - case PI_PROPERTIESUNLINKED: + case PI_PROPERTIES_UNLINKED: { - PIPropertiesunlinkedEvent* pResponse = static_cast<PIPropertiesunlinkedEvent*>(&e); - assert(pResponse); - pData = ((char*)&e) + sizeof(PIPropertiesunlinkedEvent); - pPropertySet = findPropertySet(pData, scope); - pData += Utils::getStringDataLength(pData); + PIPropertiesUnlinkedEvent responseIn(e); + pPropertySet = findPropertySet(responseIn.scope); if (pPropertySet) { - pPropertySet->propertiesUnlinked(pResponse->result, pData); + pPropertySet->propertiesUnlinked(responseIn); } break; } - case PI_VALUESET: + case PI_VALUE_SET: { - string propName; - pData = ((char*)&e) + sizeof(GCFEvent); - unsigned int propDataLength = Utils::unpackString(pData, propName); - unsigned int valueBufLength = e.length - propDataLength - sizeof(GCFEvent); - GCFPValue* pValue = GCFPValue::unpackValue(pData + propDataLength, valueBufLength); + PIValueSetEvent requestIn(e); + const GCFPValue* pValue = requestIn.value._pValue; if (pValue) { - _controller.getPropertyProxy().setPropValue(propName, *pValue); - delete pValue; + _controller.getPropertyProxy().setPropValue(requestIn.name, *pValue); } break; } @@ -335,11 +318,11 @@ GCFEvent::TResult GPISupervisoryServer::closing(GCFEvent& e, GCFPortInterface& p switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: _propertyAgent.close(); break; - case F_DISCONNECTED_SIG: + case F_DISCONNECTED: if (&p == &_propertyAgent) { _controller.close(*this); @@ -354,22 +337,16 @@ GCFEvent::TResult GPISupervisoryServer::closing(GCFEvent& e, GCFPortInterface& p return status; } -GPIPropertySet* GPISupervisoryServer::findPropertySet(char* pScopeData, string& scope) +GPIPropertySet* GPISupervisoryServer::findPropertySet(string& scope) { - if (pScopeData != 0) - { - Utils::unpackString(pScopeData, scope); - } TScopeRegister::iterator iter = _scopeRegister.find(scope); return (iter != _scopeRegister.end() ? iter->second : 0); } -void GPISupervisoryServer::replyMsgToPA(GCFEvent& e, const string& scope) +void GPISupervisoryServer::replyMsgToPA(GCFEvent& e) { if (_propertyAgent.isConnected()) { - unsigned int scopeDataLength = Utils::packString(scope, _buffer, MAX_BUF_SIZE); - e.length += scopeDataLength; - _propertyAgent.send(e, _buffer, scopeDataLength); + _propertyAgent.send(e); } } diff --git a/MAC/GCF/Services/PI/src/GPI_SupervisoryServer.h b/MAC/GCF/Services/PI/src/GPI_SupervisoryServer.h index adb3ecad7c47f6b26bad530e9247893978ed8535..4a675b7a8d9e039568a91ff5d723f2492701b5a6 100644 --- a/MAC/GCF/Services/PI/src/GPI_SupervisoryServer.h +++ b/MAC/GCF/Services/PI/src/GPI_SupervisoryServer.h @@ -47,8 +47,8 @@ class GPISupervisoryServer : public GCFTask inline GCFTCPPort& getPAPort() {return _propertyAgent;} private: // helper methods - GPIPropertySet* findPropertySet(char* pScopeData, string& scope); - void replyMsgToPA(GCFEvent& e, const string& scope); + GPIPropertySet* findPropertySet(string& scope); + void replyMsgToPA(GCFEvent& e); private: // state methods GCFEvent::TResult initial (GCFEvent& e, GCFPortInterface& p); @@ -71,8 +71,6 @@ class GPISupervisoryServer : public GCFTask TScopeRegister _scopeRegister; private: // admin. data members - static const unsigned int MAX_BUF_SIZE = 5000; - char _buffer[MAX_BUF_SIZE]; }; #endif diff --git a/MAC/GCF/Services/PI/src/Makefile.am b/MAC/GCF/Services/PI/src/Makefile.am index 41430c4b6a8f5db74580ca61a7b0342bc942fafa..41e0695a2fd0fa1d7308af3e7da5b65b485eeaab 100644 --- a/MAC/GCF/Services/PI/src/Makefile.am +++ b/MAC/GCF/Services/PI/src/Makefile.am @@ -1,7 +1,7 @@ AUTOGEN = autogen SUFFIXES = .ph %.ph: %.prot - $(AUTOGEN) -L $(top_srcdir)/GCFCommon/autogen $< && \ + $(AUTOGEN) -L $(top_srcdir)/../MACCommon/autogen $< && \ chmod a+w $@ DOCHDRS = \ @@ -17,7 +17,9 @@ libpi_la_SOURCES= $(DOCHDRS) \ GPI_Controller.cc \ GPI_SupervisoryServer.cc \ GPI_PropertyProxy.cc \ - GPI_PropertySet.cc + GPI_PropertySet.cc \ + PI_Protocol.cc \ + $(top_builddir)/CoreComps/PA/src/PA_Protocol.cc libpi_la_CPPFLAGS= -I$(top_srcdir)/GCFCommon/src \ -I$(top_srcdir)/CoreComps/TM/src \ diff --git a/MAC/GCF/Services/PI/src/PI_Protocol.prot b/MAC/GCF/Services/PI/src/PI_Protocol.prot index 76ecb9fc5974ec236a3219e3a8a0173e08b43f13..840222e69ddd43ef2f0d3977e6dfdf88df9e192a 100644 --- a/MAC/GCF/Services/PI/src/PI_Protocol.prot +++ b/MAC/GCF/Services/PI/src/PI_Protocol.prot @@ -5,10 +5,12 @@ autogen definitions protocol; description = "Protocol definition for the Supervisory Server(ERTC)/Property Interface(MAC/GCF)"; prefix = "PI"; // for the signal names - +id = "(F_GCF_PROTOCOL + 3)"; // specify extra include files // e.g. //include = '<sys/time.h>'; +include = '<GPI_Defines.h>'; +include = '<GPI_PValue.h>'; // An "event" has a "signal" and a "dir" (direction) // and zero or more "param"s. @@ -16,84 +18,139 @@ prefix = "PI"; // for the signal names // A "param" has a "name" and a "type". // -prelude = << PRELUDE_END -enum { - PI_PROTOCOL = (F_GCF_PROTOCOL + 3) -}; -#include <GPI_Defines.h> -PRELUDE_END; - -event = { - signal = NAME; - dir = IN; -}; - event = { - signal = REGISTERSCOPE; + signal = REGISTER_SCOPE; dir = IN; + param = { + name = "scope"; + type = "string"; + }; }; event = { - signal = UNREGISTERSCOPE; + signal = UNREGISTER_SCOPE; dir = IN; + param = { + name = "scope"; + type = "string"; + }; }; event = { - signal = SCOPEREGISTERED; + signal = SCOPE_REGISTERED; dir = OUT; param = { name = "result"; type = "TPIResult"; }; + param = { + name = "scope"; + type = "string"; + }; + }; event = { - signal = SCOPEUNREGISTERED; + signal = SCOPE_UNREGISTERED; dir = OUT; param = { name = "result"; type = "TPIResult"; }; + param = { + name = "scope"; + type = "string"; + }; }; event = { - signal = LINKPROPERTIES; + signal = LINK_PROPERTIES; dir = OUT; + param = { + name = "scope"; + type = "string"; + }; + param = { + name = "propList"; + type = "string"; + }; }; event = { - signal = UNLINKPROPERTIES; + signal = UNLINK_PROPERTIES; dir = OUT; + param = { + name = "scope"; + type = "string"; + }; + param = { + name = "propList"; + type = "string"; + }; }; event = { - signal = PROPERTIESLINKED; + signal = PROPERTIES_LINKED; dir = IN; param = { name = "result"; type = "TPIResult"; }; + param = { + name = "scope"; + type = "string"; + }; + param = { + name = "propList"; + type = "string"; + }; }; event = { - signal = PROPERTIESUNLINKED; + signal = PROPERTIES_UNLINKED; dir = IN; param = { name = "result"; type = "TPIResult"; }; + param = { + name = "scope"; + type = "string"; + }; + param = { + name = "propList"; + type = "string"; + }; }; event = { - signal = VALUESET; + signal = VALUE_SET; dir = IN; + param = { + name = "name"; + type = "string"; + }; + param = { + name = "value"; + type = "GPIPValue"; + userdefined; + }; }; event = { - signal = VALUECHANGED; + signal = VALUE_CHANGED; dir = OUT; param = { name = "scopeLength"; type = "unsigned short"; }; + param = { + name = "name"; + type = "string"; + }; + param = { + name = "value"; + type = "GPIPValue"; + userdefined; + }; }; \ No newline at end of file diff --git a/MAC/GCF/Services/PMLlite/src/GCF/GCF_RTAnswer.h b/MAC/GCF/Services/PMLlite/src/GCF/GCF_RTAnswer.h index 83e9d3b230751e00c6ef5935dd3747f7ca43a62e..121ddbcb134556e501c8d8385027a0cd878dd203 100644 --- a/MAC/GCF/Services/PMLlite/src/GCF/GCF_RTAnswer.h +++ b/MAC/GCF/Services/PMLlite/src/GCF/GCF_RTAnswer.h @@ -81,10 +81,10 @@ class GCFRTAnswer * ... * switch (e.signal) * { - * case F_ENTRY_SIG: + * case F_ENTRY: * break; * - * case F_MYPLOADED_SIG: + * case F_MYPLOADED: * { * // The event always sould be casted by the static_cast operator * GCFMYPropAnswerEvent* pResponse = static_cast<GCFMYPropAnswerEvent*>(&e); @@ -118,7 +118,7 @@ class GCFRTAnswer /// implementations like TCP. struct GCFPropValueEvent : public GCFEvent { - /// @param sig can only be F_VCHANGEMSG_SIG + /// @param sig can only be F_VCHANGEMSG GCFPropValueEvent(unsigned short sig) : GCFEvent(sig) { length = sizeof(GCFPropValueEvent); @@ -127,12 +127,12 @@ struct GCFPropValueEvent : public GCFEvent const char* pPropName; ///< Pointer to the string of the property name bool internal; ///< Indicates whether the internal/owned/my ///< (GCFRTMyProperty) - ///< property has changed (not used with F_VGETRESP_SIG) + ///< property has changed (not used with F_VGETRESP) }; struct GCFMYPropAnswerEvent : public GCFEvent { - /// @param sig can only be F_MYPLOADED_SIG, F_MYPUNLOADED_SIG + /// @param sig can only be F_MYPLOADED, F_MYPUNLOADED GCFMYPropAnswerEvent(unsigned short sig) : GCFEvent(sig) { length = sizeof(GCFMYPropAnswerEvent); @@ -154,9 +154,9 @@ enum { F_MYPUNLOADED_ID, }; -#define F_VCHANGEMSG_SIG F_SIGNAL(F_PML_PROTOCOL, F_VCHANGEMSG_ID, F_IN) -#define F_MYPLOADED_SIG F_SIGNAL(F_PML_PROTOCOL, F_MYPLOADED_ID, F_IN) -#define F_MYPUNLOADED_SIG F_SIGNAL(F_PML_PROTOCOL, F_MYPUNLOADED_ID, F_IN) +#define F_VCHANGEMSG F_SIGNAL(F_PML_PROTOCOL, F_VCHANGEMSG_ID, F_IN) +#define F_MYPLOADED F_SIGNAL(F_PML_PROTOCOL, F_MYPLOADED_ID, F_IN) +#define F_MYPUNLOADED F_SIGNAL(F_PML_PROTOCOL, F_MYPUNLOADED_ID, F_IN) extern const char* F_PML_PROTOCOL_signalnames[]; diff --git a/MAC/GCF/Services/PMLlite/src/GCF/GCF_RTMyProperty.h b/MAC/GCF/Services/PMLlite/src/GCF/GCF_RTMyProperty.h index 7d94054c40f1d751181fd21f7b1e960c3788ba05..863b39076280aa8ac695b23d4991a9ed87cef6e8 100644 --- a/MAC/GCF/Services/PMLlite/src/GCF/GCF_RTMyProperty.h +++ b/MAC/GCF/Services/PMLlite/src/GCF/GCF_RTMyProperty.h @@ -64,7 +64,7 @@ class GCFRTMyProperty //@{ /** Access mode can be: GCF_READABLE_PROP and/or GCF_WRITABLE_PROP * NOTE: If both modes are set and the property is linked, the setValue - * method call results immediate in a F_VCHANGEMSG_SIG answer event. This + * method call results immediate in a F_VCHANGEMSG answer event. This * on its turn copies the current to the old value and the changed value to * current value. This means that the current value from before the setValue * will not be available after the answer event is received (old value is diff --git a/MAC/GCF/Services/PMLlite/src/GCF_RTAnswer.cc b/MAC/GCF/Services/PMLlite/src/GCF_RTAnswer.cc index 12e1af41ae265c295a31a5fac4c532e0f2f2f06c..536ec03521a6f7fd65492f089c290a760359cad4 100644 --- a/MAC/GCF/Services/PMLlite/src/GCF_RTAnswer.cc +++ b/MAC/GCF/Services/PMLlite/src/GCF_RTAnswer.cc @@ -28,7 +28,7 @@ const char* F_PML_PROTOCOL_signalnames[] = { "F_PML_PROTOCOL: invalid signal", - "F_VCHANGEMSG_SIG (IN)", - "F_MYPLOADED_SIG (IN)", - "F_MYPUNLOADED_SIG (IN)", + "F_VCHANGEMSG (IN)", + "F_MYPLOADED (IN)", + "F_MYPUNLOADED (IN)", }; diff --git a/MAC/GCF/Services/PMLlite/src/GCF_RTMyProperty.cc b/MAC/GCF/Services/PMLlite/src/GCF_RTMyProperty.cc index 1beedaaad3a366afc75e469d8712c951483b5371..fd631c62179b2e317b02ac0c8bb368a851119130 100644 --- a/MAC/GCF/Services/PMLlite/src/GCF_RTMyProperty.cc +++ b/MAC/GCF/Services/PMLlite/src/GCF_RTMyProperty.cc @@ -174,7 +174,7 @@ void GCFRTMyProperty::valueChanged (const GCFPValue& value) result = _pCurValue->copy(value); assert(result == GCF_NO_ERROR); - GCFPropValueEvent e(F_VCHANGEMSG_SIG); + GCFPropValueEvent e(F_VCHANGEMSG); e.pValue = &value; string fullName(getFullName()); e.pPropName = fullName.c_str(); diff --git a/MAC/GCF/Services/PMLlite/src/GCF_RTMyPropertySet.cc b/MAC/GCF/Services/PMLlite/src/GCF_RTMyPropertySet.cc index 2e1ae25c6e857a8cde8cd4b97b7602661d0b0100..6b0cd599955999eb5415c74011e0bdc606740987 100644 --- a/MAC/GCF/Services/PMLlite/src/GCF_RTMyPropertySet.cc +++ b/MAC/GCF/Services/PMLlite/src/GCF_RTMyPropertySet.cc @@ -193,7 +193,7 @@ void GCFRTMyPropertySet::scopeRegistered (TGCFResult result) _scope.c_str())); } - dispatchAnswer(F_MYPLOADED_SIG, result); + dispatchAnswer(F_MYPLOADED, result); } void GCFRTMyPropertySet::scopeUnregistered (TGCFResult result) @@ -208,7 +208,7 @@ void GCFRTMyPropertySet::scopeUnregistered (TGCFResult result) "PI-RESP: Scope %s unregistered", _scope.c_str())); - dispatchAnswer(F_MYPUNLOADED_SIG, result); + dispatchAnswer(F_MYPUNLOADED, result); } void GCFRTMyPropertySet::linkProperties(list<string>& properties) diff --git a/MAC/GCF/Services/PMLlite/src/GPM_RTController.cc b/MAC/GCF/Services/PMLlite/src/GPM_RTController.cc index c53b4cee76861b7bcd5f4173c9d2f83e729c5eab..ff6b382a6c50a6960dc90cf1bfd17df2ac60552d 100644 --- a/MAC/GCF/Services/PMLlite/src/GPM_RTController.cc +++ b/MAC/GCF/Services/PMLlite/src/GPM_RTController.cc @@ -24,7 +24,6 @@ #include "GCF_RTMyPropertySet.h" #include <stdio.h> #include <Utils.h> -#define DECLARE_SIGNAL_NAMES #include <PI_Protocol.ph> static string sPMLTaskName("PMLlite"); @@ -66,9 +65,10 @@ TPMResult GPMRTController::registerScope(GCFRTMyPropertySet& propSet) else { _propertySets[propSet.getScope()] = &propSet; - - GCFEvent e(PI_REGISTERSCOPE); - sendMyPropSetMsg(e, propSet.getScope()); + + PIRegisterScopeEvent requestOut; + requestOut.scope = propSet.getScope(); + sendMsgToPI(requestOut); } return result; } @@ -82,8 +82,9 @@ TPMResult GPMRTController::unregisterScope(GCFRTMyPropertySet& propSet, // calls this method if (propSet.isLoaded()) { - GCFEvent e(PI_UNREGISTERSCOPE); - sendMyPropSetMsg(e, propSet.getScope()); + PIUnregisterScopeEvent requestOut; + requestOut.scope = propSet.getScope(); + sendMsgToPI(requestOut); } if (permanent) { @@ -97,48 +98,40 @@ void GPMRTController::propertiesLinked(const string& scope, list<string>& propsToSubscribe, TPIResult result) { - PIPropertieslinkedEvent e(result); - sendMyPropSetMsg(e, scope, propsToSubscribe); + PIPropertiesLinkedEvent responseOut; + responseOut.result = result; + responseOut.scope = scope; + Utils::getPropertyListString(responseOut.propList, propsToSubscribe); + sendMsgToPI(responseOut); } void GPMRTController::propertiesUnlinked(const string& scope, list<string>& propsToUnsubscribe, TPIResult result) { - PIPropertiesunlinkedEvent e(result); - sendMyPropSetMsg(e, scope, propsToUnsubscribe); + PIPropertiesUnlinkedEvent responseOut; + responseOut.result = result; + responseOut.scope = scope; + Utils::getPropertyListString(responseOut.propList, propsToUnsubscribe); + sendMsgToPI(responseOut); } void GPMRTController::valueSet(const string& propName, const GCFPValue& value) { if (_supervisoryServer.isConnected()) { - GCFEvent e(PI_VALUESET); - unsigned int dataLength = Utils::packString(propName, _buffer, MAX_BUF_SIZE); - dataLength += value.pack(_buffer + dataLength, MAX_BUF_SIZE - dataLength); - e.length += dataLength; - _supervisoryServer.send(e, _buffer, dataLength); + PIValueSetEvent indicationOut; + indicationOut.name = propName; + indicationOut.value._pValue = &value; + _supervisoryServer.send(indicationOut); } } -void GPMRTController::sendMyPropSetMsg(GCFEvent& e, const string& scope, list<string>& props) +void GPMRTController::sendMsgToPI(GCFEvent& e) { if (_supervisoryServer.isConnected()) { - unsigned short dataLength = Utils::packString(scope, _buffer, MAX_BUF_SIZE); - dataLength += Utils::packPropertyList(props, _buffer + dataLength, MAX_BUF_SIZE - dataLength); - e.length += dataLength; - _supervisoryServer.send(e, _buffer, dataLength); - } -} - -void GPMRTController::sendMyPropSetMsg(GCFEvent& e, const string& scope) -{ - if (_supervisoryServer.isConnected()) - { - unsigned short dataLength = Utils::packString(scope, _buffer, MAX_BUF_SIZE); - e.length += dataLength; - _supervisoryServer.send(e, _buffer, dataLength); + _supervisoryServer.send(e); } } @@ -148,19 +141,19 @@ GCFEvent::TResult GPMRTController::initial(GCFEvent& e, GCFPortInterface& /*p*/) switch (e.signal) { - case F_INIT_SIG: + case F_INIT: break; - case F_ENTRY_SIG: - case F_TIMER_SIG: + case F_ENTRY: + case F_TIMER: _supervisoryServer.open(); break; - case F_CONNECTED_SIG: + case F_CONNECTED: TRAN(GPMRTController::connected); break; - case F_DISCONNECTED_SIG: + case F_DISCONNECTED: _supervisoryServer.setTimer(1.0); // try again after 1 second break; @@ -176,44 +169,40 @@ GCFEvent::TResult GPMRTController::connected(GCFEvent& e, GCFPortInterface& /*p* { GCFEvent::TResult status = GCFEvent::HANDLED; TGCFResult result; - static char* pData = 0; - static string scope = ""; switch (e.signal) { - case F_DISCONNECTED_SIG: + case F_DISCONNECTED: LOFAR_LOG_WARN(PML_STDOUT_LOGGER, ( "Connection lost to Supervisory Server")); TRAN(GPMRTController::initial); break; - case F_ENTRY_SIG: + case F_ENTRY: { - GCFEvent rse(PI_REGISTERSCOPE); + PIRegisterScopeEvent requestOut; for (TPropertySets::iterator iter = _propertySets.begin(); iter != _propertySets.end(); ++iter) { - sendMyPropSetMsg(rse, iter->first); + requestOut.scope = iter->first; + sendMsgToPI(requestOut); } break; } - case PI_SCOPEREGISTERED: + case PI_SCOPE_REGISTERED: { - PIScoperegisteredEvent* pResponse = static_cast<PIScoperegisteredEvent*>(&e); - assert(pResponse); - pData = ((char*)&e) + sizeof(PIScoperegisteredEvent); - Utils::unpackString(pData, scope); - if (pResponse->result == PI_SCOPE_ALREADY_REGISTERED) + PIScopeRegisteredEvent responseIn(e); + if (responseIn.result == PI_SCOPE_ALREADY_REGISTERED) { LOFAR_LOG_INFO(PML_STDOUT_LOGGER, ( "A property set with scope %s already exists in the system", - scope.c_str())); + responseIn.scope.c_str())); } - result = (pResponse->result == PI_NO_ERROR ? GCF_NO_ERROR : GCF_MYPROPSLOAD_ERROR); - GCFRTMyPropertySet* pPropertySet = _propertySets[scope]; + result = (responseIn.result == PI_NO_ERROR ? GCF_NO_ERROR : GCF_MYPROPSLOAD_ERROR); + GCFRTMyPropertySet* pPropertySet = _propertySets[responseIn.scope]; if (result != GCF_NO_ERROR) { - _propertySets.erase(scope); + _propertySets.erase(responseIn.scope); } if (pPropertySet) { @@ -222,97 +211,89 @@ GCFEvent::TResult GPMRTController::connected(GCFEvent& e, GCFPortInterface& /*p* break; } - case PI_SCOPEUNREGISTERED: + case PI_SCOPE_UNREGISTERED: { - PIScopeunregisteredEvent* pResponse = static_cast<PIScopeunregisteredEvent*>(&e); - assert(pResponse); - pData = ((char*)&e) + sizeof(PIScopeunregisteredEvent); - Utils::unpackString(pData, scope); - GCFRTMyPropertySet* pPropertySet = _propertySets[scope]; - result = (pResponse->result == PI_NO_ERROR ? GCF_NO_ERROR : GCF_MYPROPSUNLOAD_ERROR); + PIScopeUnregisteredEvent responseIn(e); + GCFRTMyPropertySet* pPropertySet = _propertySets[responseIn.scope]; + result = (responseIn.result == PI_NO_ERROR ? GCF_NO_ERROR : GCF_MYPROPSUNLOAD_ERROR); if (pPropertySet) { - _propertySets.erase(scope); + _propertySets.erase(responseIn.scope); pPropertySet->scopeUnregistered(result); } break; } - case PI_LINKPROPERTIES: + case PI_LINK_PROPERTIES: { - pData = ((char*)&e) + sizeof(GCFEvent); - unsigned int scopeDataLength = Utils::unpackString(pData, scope); - string linkListData(pData + scopeDataLength + Utils::SLEN_FIELD_SIZE, - e.length - sizeof(GCFEvent) - scopeDataLength - Utils::SLEN_FIELD_SIZE); - list<string> propertyList; + PILinkPropertiesEvent requestIn(e); LOFAR_LOG_INFO(PML_STDOUT_LOGGER, ( "PI-REQ: Link properties %s on scope %s", - linkListData.c_str(), - scope.c_str())); - Utils::unpackPropertyList(pData + scopeDataLength, propertyList); - GCFRTMyPropertySet* pPropertySet = _propertySets[scope]; + requestIn.propList.c_str(), + requestIn.scope.c_str())); + + GCFRTMyPropertySet* pPropertySet = _propertySets[requestIn.scope]; if (pPropertySet) { + list<string> propertyList; + Utils::getPropertyListFromString(propertyList, requestIn.propList); pPropertySet->linkProperties(propertyList); } else { LOFAR_LOG_TRACE(PML_STDOUT_LOGGER, ( "Property set with scope %d was deleted in the meanwhile", - scope.c_str())); - PIPropertieslinkedEvent e(PI_PROP_SET_GONE); - sendMyPropSetMsg(e, scope); + requestIn.scope.c_str())); + + PIPropertiesLinkedEvent responseOut; + responseOut.result = PI_PROP_SET_GONE; + responseOut.scope = requestIn.scope; + sendMsgToPI(responseOut); } break; } - case PI_UNLINKPROPERTIES: + case PI_UNLINK_PROPERTIES: { - pData = ((char*)&e) + sizeof(GCFEvent); - unsigned int scopeDataLength = Utils::unpackString(pData, scope); - string unlinkListData(pData + scopeDataLength + Utils::SLEN_FIELD_SIZE, - e.length - sizeof(GCFEvent) - scopeDataLength - Utils::SLEN_FIELD_SIZE); + PIUnlinkPropertiesEvent requestIn(e); LOFAR_LOG_INFO(PML_STDOUT_LOGGER, ( "PI-REQ: Unlink properties %s on scope %s", - unlinkListData.c_str(), - scope.c_str())); - list<string> propertyList; - Utils::unpackPropertyList(pData + scopeDataLength, propertyList); - GCFRTMyPropertySet* pPropertySet = _propertySets[scope]; + requestIn.propList.c_str(), + requestIn.scope.c_str())); + + GCFRTMyPropertySet* pPropertySet = _propertySets[requestIn.scope]; if (pPropertySet) { + list<string> propertyList; + Utils::getPropertyListFromString(propertyList, requestIn.propList); pPropertySet->unlinkProperties(propertyList); } else { LOFAR_LOG_TRACE(PML_STDOUT_LOGGER, ( "Property set with scope %d was deleted in the meanwhile", - scope.c_str())); - PIPropertiesunlinkedEvent e(PI_PROP_SET_GONE); - sendMyPropSetMsg(e, scope); + requestIn.scope.c_str())); + + PIPropertiesUnlinkedEvent responseOut; + responseOut.result = PI_PROP_SET_GONE; + responseOut.scope = requestIn.scope; + sendMsgToPI(responseOut); } break; } - case PI_VALUECHANGED: + case PI_VALUE_CHANGED: { - PIValuechangedEvent* pMsg = static_cast<PIValuechangedEvent*>(&e); - assert(pMsg); - pData = ((char*)&e) + sizeof(PIValuechangedEvent); - string propName; - unsigned int propDataLength = Utils::unpackString(pData, propName); - scope.assign(propName, 0, pMsg->scopeLength); + PIValueChangedEvent indicationIn(e); LOFAR_LOG_INFO(PML_STDOUT_LOGGER, ( "SS-MSG: Property %s changed", - propName.c_str())); - + indicationIn.name.c_str())); + string scope; + scope.assign(indicationIn.name, 0, indicationIn.scopeLength); GCFRTMyPropertySet* pPropertySet = _propertySets[scope]; if (pPropertySet) { - unsigned int valueBufLength = e.length - propDataLength - sizeof(PIValuechangedEvent); - GCFPValue* pValue = GCFPValue::unpackValue(pData + propDataLength, valueBufLength); - assert(pValue); - pPropertySet->valueChanged(propName, *pValue); - delete pValue; + assert(indicationIn.value._pValue); + pPropertySet->valueChanged(indicationIn.name, *indicationIn.value._pValue); } else { diff --git a/MAC/GCF/Services/PMLlite/src/GPM_RTController.h b/MAC/GCF/Services/PMLlite/src/GPM_RTController.h index 0d00bd002ea4fe66e5d78983d4d61d691f49e2a5..bc8100a0dc59c68d3c95af89b3fe6fdca362f0ba 100644 --- a/MAC/GCF/Services/PMLlite/src/GPM_RTController.h +++ b/MAC/GCF/Services/PMLlite/src/GPM_RTController.h @@ -72,11 +72,7 @@ class GPMRTController : public GCFTask GCFEvent::TResult connected (GCFEvent& e, GCFPortInterface& p); private: // helper methods - void sendMyPropSetMsg (GCFEvent& e, - const string& scope, - list<string>& props); - void sendMyPropSetMsg (GCFEvent& e, - const string& scope); + void sendMsgToPI (GCFEvent& e); private: // data members GCFPort _supervisoryServer; @@ -85,7 +81,5 @@ class GPMRTController : public GCFTask unsigned int _counter; typedef map<string, GCFRTMyPropertySet*> TPropertySets; TPropertySets _propertySets; - static const unsigned short MAX_BUF_SIZE = 5000; - char _buffer[MAX_BUF_SIZE]; }; #endif diff --git a/MAC/GCF/Services/PMLlite/src/Makefile.am b/MAC/GCF/Services/PMLlite/src/Makefile.am index 9c577280050307845fa0e034c1bb8e647dd79969..71df717a03bb56d44e2dc9e234bf48af1d2dcfcb 100644 --- a/MAC/GCF/Services/PMLlite/src/Makefile.am +++ b/MAC/GCF/Services/PMLlite/src/Makefile.am @@ -1,3 +1,9 @@ +AUTOGEN = autogen +SUFFIXES = .ph +%.ph: $(top_srcdir)/Services/PI/src/%.prot + $(AUTOGEN) -L $(top_srcdir)/../MACCommon/autogen $< && \ + chmod a+w $@ + pkginclude_HEADERS = \ GCF/GCF_RTAnswer.h \ GCF/GCF_RTMyProperty.h \ @@ -13,7 +19,8 @@ libpmllite_la_SOURCES= $(DOCHDRS) \ GCF_RTAnswer.cc \ GCF_RTMyProperty.cc \ GCF_RTMyPropertySet.cc \ - GPM_RTController.cc + GPM_RTController.cc \ + PI_Protocol.cc libpmllite_la_CPPFLAGS= -I$(top_srcdir)/GCFCommon/src \ -I$(top_srcdir)/CoreComps/TM/src \ @@ -22,5 +29,11 @@ libpmllite_la_CPPFLAGS= -I$(top_srcdir)/GCFCommon/src \ -I$(top_builddir)/Services/SupServer/src \ -I$(top_srcdir)/Services/PMLlite/src/GCF +BUILT_SOURCES = \ + PI_Protocol.ph + +EXTRA_DIST = \ + PI_Protocol.ph + include $(lofar_sharedir)/Makefile.common diff --git a/MAC/GCF/Services/SupServer/src/GSS_Controller.cc b/MAC/GCF/Services/SupServer/src/GSS_Controller.cc index 51f4d6d20a5c07cf358bdea3e84443c17835aadc..19bf372327bca6200811de7fb21437c3f9bc2d76 100644 --- a/MAC/GCF/Services/SupServer/src/GSS_Controller.cc +++ b/MAC/GCF/Services/SupServer/src/GSS_Controller.cc @@ -26,8 +26,6 @@ #include "GSS_Defines.h" #include <GCF/GCF_Control.h> #include <Utils.h> -#define DEBUG_SIGNAL -#define DECLARE_SIGNAL_NAMES #include <PI_Protocol.ph> static string ssName = "SS"; @@ -60,24 +58,24 @@ GCFEvent::TResult GSSController::initial_state(GCFEvent& e, GCFPortInterface& p) switch (e.signal) { - case F_INIT_SIG: + case F_INIT: break; - case F_ENTRY_SIG: + case F_ENTRY: _scPortProvider.open(); // intentional fall through - case F_TIMER_SIG: + case F_TIMER: _propertyInterface.open(); break; - case F_CONNECTED_SIG: + case F_CONNECTED: if (_scPortProvider.isConnected()) { TRAN(GSSController::operational_state); } break; - case F_DISCONNECTED_SIG: + case F_DISCONNECTED: if (&p == &_scPortProvider) assert(0); else if (&p == &_propertyInterface) p.setTimer(1.0); // try again after 1 second break; @@ -93,25 +91,23 @@ GCFEvent::TResult GSSController::initial_state(GCFEvent& e, GCFPortInterface& p) GCFEvent::TResult GSSController::operational_state(GCFEvent& e, GCFPortInterface& p) { GCFEvent::TResult status = GCFEvent::HANDLED; - static string scope = ""; - static char* pData = 0; switch (e.signal) { - case F_CONNECTED_SIG: + case F_CONNECTED: if (&p == &_propertyInterface) { - GCFEvent rse(PI_REGISTERSCOPE); + PIRegisterScopeEvent requestOut; for (TScopeRegister::iterator iter = _scopeRegister.begin(); iter != _scopeRegister.end(); ++iter) { - rse.length = sizeof(GCFEvent) + Utils::packString(iter->first, _buffer, MAX_BUF_SIZE); - _propertyInterface.send(rse, _buffer, rse.length - sizeof(GCFEvent)); + requestOut.scope = iter->first; + _propertyInterface.send(requestOut); } } break; - case F_DISCONNECTED_SIG: + case F_DISCONNECTED: assert(&_scPortProvider != &p); if (&_propertyInterface == &p) { @@ -123,15 +119,15 @@ GCFEvent::TResult GSSController::operational_state(GCFEvent& e, GCFPortInterface _scPortProvider.setTimer(0, 0, 0, 0, &p); // cleanup scope-port relations and raport it to te PI list<string> scopesToBeDeleted; - GCFEvent urse(PI_UNREGISTERSCOPE); + PIUnregisterScopeEvent requestOut; for (TScopeRegister::iterator iter = _scopeRegister.begin(); iter != _scopeRegister.end(); ++iter) { if (iter->second == &p) { scopesToBeDeleted.push_back(iter->first); - urse.length = sizeof(GCFEvent) + Utils::packString(iter->first, _buffer, MAX_BUF_SIZE); - _propertyInterface.send(urse, _buffer, urse.length - sizeof(GCFEvent)); + requestOut.scope = iter->first; + _propertyInterface.send(requestOut); } } for (list<string>::iterator iter = scopesToBeDeleted.begin(); @@ -143,7 +139,7 @@ GCFEvent::TResult GSSController::operational_state(GCFEvent& e, GCFPortInterface } break; - case F_ACCEPT_REQ_SIG: + case F_ACCEPT_REQ: { GCFTCPPort* pNewPMLPort = new GCFTCPPort(); pNewPMLPort->init(*this, "ss", GCFPortInterface::SPP, PI_PROTOCOL); @@ -159,7 +155,7 @@ GCFEvent::TResult GSSController::operational_state(GCFEvent& e, GCFPortInterface break; } - case F_TIMER_SIG: + case F_TIMER: if (&_propertyInterface == &p) { p.open(); // try again @@ -183,128 +179,135 @@ GCFEvent::TResult GSSController::operational_state(GCFEvent& e, GCFPortInterface } break; - case PI_REGISTERSCOPE: + case PI_REGISTER_SCOPE: { - pData = ((char*)&e) + sizeof(GCFEvent); - if (!findScope(pData, scope)) + PIRegisterScopeEvent requestIn(e); + if (!findScope(requestIn.scope)) { - forwardMsgToPI(e); + sendMsgToPI(requestIn); // creates a new scope entry - _scopeRegister[scope] = &p; + _scopeRegister[requestIn.scope] = &p; } else { - PIScoperegisteredEvent response(PI_SCOPE_ALREADY_REGISTERED); - replyMsgToPMLlite(response, p, pData); + PIScopeRegisteredEvent responseOut; + responseOut.result = PI_SCOPE_ALREADY_REGISTERED; + responseOut.scope = requestIn.scope; + replyMsgToPMLlite(responseOut, p); } LOFAR_LOG_INFO(SS_STDOUT_LOGGER, ( "PMLlite-REQ: Register scope %s", - scope.c_str())); + requestIn.scope.c_str())); break; } - case PI_SCOPEREGISTERED: + case PI_SCOPE_REGISTERED: { - PIScoperegisteredEvent* pResponse = static_cast<PIScoperegisteredEvent*>(&e); - assert(pResponse); - pData = ((char*)&e) + sizeof(PIScoperegisteredEvent); + PIScopeRegisteredEvent responseIn(e); + char logMsg[] = "PI-RESP: Scope %s is registered"; - if (!forwardMsgToPMLlite(e, pData, scope, logMsg) && - pResponse->result == PI_NO_ERROR) + if (!forwardMsgToPMLlite(responseIn, responseIn.scope, logMsg) && + responseIn.result == PI_NO_ERROR) { - GCFEvent urse(PI_UNREGISTERSCOPE); - unsigned short scopeDataLength = scope.length() + Utils::SLEN_FIELD_SIZE; - urse.length += scopeDataLength; - _propertyInterface.send(urse, pData, scopeDataLength); + PIUnregisterScopeEvent requestOut; + requestOut.scope = responseIn.scope; + _propertyInterface.send(requestOut); } - if (pResponse->result != PI_NO_ERROR) + if (responseIn.result != PI_NO_ERROR) { - _scopeRegister.erase(scope); + _scopeRegister.erase(responseIn.scope); } break; } - case PI_UNREGISTERSCOPE: + case PI_UNREGISTER_SCOPE: { - pData = ((char*)&e) + sizeof(GCFEvent); - if (!findScope(pData, scope)) + PIUnregisterScopeEvent requestIn(e); + if (!findScope(requestIn.scope)) { - forwardMsgToPI(e); + sendMsgToPI(requestIn); } else { - PIScopeunregisteredEvent response(PI_PROP_SET_GONE); - replyMsgToPMLlite(response, p, pData); + PIScopeUnregisteredEvent responseOut; + responseOut.result = PI_PROP_SET_GONE; + responseOut.scope = requestIn.scope; + replyMsgToPMLlite(responseOut, p); } LOFAR_LOG_INFO(SS_STDOUT_LOGGER, ( "PMLlite-REQ: Unregister scope %s", - scope.c_str())); + requestIn.scope.c_str())); break; } - case PI_SCOPEUNREGISTERED: + case PI_SCOPE_UNREGISTERED: { - PIScopeunregisteredEvent* pResponse = static_cast<PIScopeunregisteredEvent*>(&e); - assert(pResponse); - pData = ((char*)&e) + sizeof(PIScopeunregisteredEvent); + PIScopeUnregisteredEvent responseIn(e); char logMsg[] = "PI-RESP: Scope %s is unregistered"; - forwardMsgToPMLlite(e, pData, scope, logMsg); + forwardMsgToPMLlite(responseIn, responseIn.scope, logMsg); // deletes the scope entry - _scopeRegister.erase(scope); + _scopeRegister.erase(responseIn.scope); break; } - case PI_LINKPROPERTIES: + case PI_LINK_PROPERTIES: { - pData = ((char*)&e) + sizeof(GCFEvent); + PILinkPropertiesEvent requestIn(e); char logMsg[] = "PI-REQ: Link properties on scope %s"; - if (!forwardMsgToPMLlite(e, pData, scope, logMsg)) + if (!forwardMsgToPMLlite(requestIn, requestIn.scope, logMsg)) { - PIPropertieslinkedEvent response(PI_PROP_SET_GONE); - replyMsgToPI(response, pData); + PIPropertiesLinkedEvent responseOut; + responseOut.result = PI_PROP_SET_GONE; + responseOut.scope = requestIn.scope; + sendMsgToPI(responseOut); } break; } - case PI_PROPERTIESLINKED: - forwardMsgToPI(e); + case PI_PROPERTIES_LINKED: + { + PIPropertiesLinkedEvent responseIn(e); + sendMsgToPI(responseIn); break; - - case PI_UNLINKPROPERTIES: + } + case PI_UNLINK_PROPERTIES: { - pData = ((char*)&e) + sizeof(GCFEvent); + PIUnlinkPropertiesEvent requestIn(e); char logMsg[] = "PI-REQ: Unlink properties on scope %s"; - if (!forwardMsgToPMLlite(e, pData, scope, logMsg)) + if (!forwardMsgToPMLlite(requestIn, requestIn.scope, logMsg)) { - PIPropertieslinkedEvent response(PI_PROP_SET_GONE); - replyMsgToPI(response, pData); + PIPropertiesLinkedEvent responseOut; + responseOut.result = PI_PROP_SET_GONE; + responseOut.scope = requestIn.scope; + sendMsgToPI(responseOut); } break; } - case PI_PROPERTIESUNLINKED: - forwardMsgToPI(e); + case PI_PROPERTIES_UNLINKED: + { + PIPropertiesUnlinkedEvent responseIn(e); + sendMsgToPI(responseIn); break; - - case PI_VALUESET: - forwardMsgToPI(e); + } + case PI_VALUE_SET: + { + PIValueSetEvent indicationIn(e); + sendMsgToPI(indicationIn); break; - - case PI_VALUECHANGED: + } + case PI_VALUE_CHANGED: { - PIValuechangedEvent* pMsg = static_cast<PIValuechangedEvent*>(&e); - assert(pMsg); - char* pPropNameData = ((char*)&e) + sizeof(PIValuechangedEvent); - string propName; - Utils::unpackString(pPropNameData, propName); - scope.assign(propName, 0, pMsg->scopeLength); + PIValueChangedEvent indicationIn(e); + string scope; + scope.assign(indicationIn.name, 0, indicationIn.scopeLength); LOFAR_LOG_INFO(SS_STDOUT_LOGGER, ( "PI-MSG: Property %s changed", - propName.c_str())); + indicationIn.name.c_str())); GCFPortInterface* pPort = _scopeRegister[scope]; if (pPort) { assert(pPort->isConnected()); - pPort->send(e); + pPort->send(indicationIn); } break; } @@ -316,14 +319,13 @@ GCFEvent::TResult GSSController::operational_state(GCFEvent& e, GCFPortInterface return status; } -bool GSSController::findScope(char* pData, string& scope) +bool GSSController::findScope(string& scope) { - Utils::unpackString(pData, scope); TScopeRegister::iterator iter = _scopeRegister.find(scope); return (iter != _scopeRegister.end()); } -void GSSController::forwardMsgToPI(GCFEvent& e) +void GSSController::sendMsgToPI(GCFEvent& e) { if (_propertyInterface.isConnected()) { @@ -331,20 +333,9 @@ void GSSController::forwardMsgToPI(GCFEvent& e) } } -void GSSController::replyMsgToPI(GCFEvent& e, const string& scope) -{ - if (_propertyInterface.isConnected()) - { - unsigned int scopeDataLength = Utils::packString(scope, _buffer, MAX_BUF_SIZE); - e.length += scopeDataLength; - _propertyInterface.send(e, _buffer, scopeDataLength); - } -} - -bool GSSController::forwardMsgToPMLlite(GCFEvent& e, char* pData, string& scope, char* logMsg) +bool GSSController::forwardMsgToPMLlite(GCFEvent& e, string& scope, char* logMsg) { bool result(false); - Utils::unpackString(pData, scope); LOFAR_LOG_INFO(SS_STDOUT_LOGGER, ( logMsg, @@ -366,10 +357,8 @@ bool GSSController::forwardMsgToPMLlite(GCFEvent& e, char* pData, string& scope, return result; } -void GSSController::replyMsgToPMLlite(GCFEvent& e, GCFPortInterface& p, char* pData) +void GSSController::replyMsgToPMLlite(GCFEvent& e, GCFPortInterface& p) { assert(p.isConnected()); - unsigned short scopeDataLength = Utils::getStringDataLength(pData); - e.length += scopeDataLength; - p.send(e, pData, scopeDataLength); + p.send(e); } diff --git a/MAC/GCF/Services/SupServer/src/GSS_Controller.h b/MAC/GCF/Services/SupServer/src/GSS_Controller.h index 0a13c0cf91a7bf68298d1e882d058fd5d65e523c..b177c6fb3137b7955c63a9d6ef2c246ef30fe0fc 100644 --- a/MAC/GCF/Services/SupServer/src/GSS_Controller.h +++ b/MAC/GCF/Services/SupServer/src/GSS_Controller.h @@ -52,23 +52,20 @@ class GSSController : public GCFTask GCFEvent::TResult operational_state(GCFEvent& e, GCFPortInterface& p); private: // private methods - bool findScope(char* pScopeData, string& scope); - void forwardMsgToPI(GCFEvent& e); - void replyMsgToPI(GCFEvent& e, const string& scope); - bool forwardMsgToPMLlite(GCFEvent& e, char* pScopeData, string& scope, char* logMsg); - void replyMsgToPMLlite(GCFEvent& e, GCFPortInterface& p, char* pScopeData); + bool findScope(string& scope); + void sendMsgToPI(GCFEvent& e); + bool forwardMsgToPMLlite(GCFEvent& e, string& scope, char* logMsg); + void replyMsgToPMLlite(GCFEvent& e, GCFPortInterface& p); private: // data members - static const unsigned int MAX_NR_OF_CLIENTS = 64; - static const unsigned int MAX_BUF_SIZE = 5000; + static const unsigned int MAX_NR_OF_CLIENTS = 64; GCFTCPPort* _supClientPorts[MAX_NR_OF_CLIENTS]; typedef map<string /*scope*/, GCFPortInterface*> TScopeRegister; TScopeRegister _scopeRegister; GCFTCPPort _scPortProvider; GCFTCPPort _propertyInterface; - char _buffer[MAX_BUF_SIZE]; }; #endif diff --git a/MAC/GCF/Services/SupServer/src/Makefile.am b/MAC/GCF/Services/SupServer/src/Makefile.am index f9e03786dcae1c69f2fcc3f25d7b7c91d42d569e..164e5fc69fb5ca3ac1cc3f99f17131a04bf1eb94 100644 --- a/MAC/GCF/Services/SupServer/src/Makefile.am +++ b/MAC/GCF/Services/SupServer/src/Makefile.am @@ -1,7 +1,7 @@ AUTOGEN = autogen SUFFIXES = .ph %.ph: $(top_srcdir)/Services/PI/src/%.prot - $(AUTOGEN) -L $(top_srcdir)/GCFCommon/autogen $< && \ + $(AUTOGEN) -L $(top_srcdir)/../MACCommon/autogen $< && \ chmod a+w $@ DOCHDRS = \ @@ -11,7 +11,8 @@ DOCHDRS = \ noinst_LTLIBRARIES = libsupserver.la libsupserver_la_SOURCES= $(DOCHDRS) \ - GSS_Controller.cc + GSS_Controller.cc \ + PI_Protocol.cc libsupserver_la_CPPFLAGS= -I$(top_srcdir)/GCFCommon/src \ -I$(top_srcdir)/CoreComps/TM/src \ diff --git a/MAC/GCF/_CoreComps/PA/src/GPA_Controller.cc b/MAC/GCF/_CoreComps/PA/src/GPA_Controller.cc index 44e29351bd2367d620c4e3ba6e8a8c3285ec7513..425b7bbe47cd8641c5e7e0133fc1abfdcae0ec93 100644 --- a/MAC/GCF/_CoreComps/PA/src/GPA_Controller.cc +++ b/MAC/GCF/_CoreComps/PA/src/GPA_Controller.cc @@ -23,7 +23,6 @@ #include <GPA_Controller.h> #include <stdio.h> #include <Utils.h> -#define DECLARE_SIGNAL_NAMES #include <PA_Protocol.ph> #define CHECK_REQUEST(p, e) \ @@ -55,19 +54,19 @@ GCFEvent::TResult GPAController::initial(GCFEvent& e, GCFPortInterface& p) switch (e.signal) { - case F_INIT_SIG: + case F_INIT: break; - case F_ENTRY_SIG: - case F_TIMER_SIG: + case F_ENTRY: + case F_TIMER: _pmlPortProvider.open(); break; - case F_CONNECTED_SIG: + case F_CONNECTED: TRAN(GPAController::connected); break; - case F_DISCONNECTED_SIG: + case F_DISCONNECTED: if (&p == &_pmlPortProvider) _pmlPortProvider.setTimer(1.0); // try again after 1 second break; @@ -86,7 +85,7 @@ GCFEvent::TResult GPAController::connected(GCFEvent& e, GCFPortInterface& p) switch (e.signal) { - case F_DISCONNECTED_SIG: + case F_DISCONNECTED: if (&p == &_pmlPortProvider) { _scopeManager.deleteAllScopes(); @@ -106,7 +105,7 @@ GCFEvent::TResult GPAController::connected(GCFEvent& e, GCFPortInterface& p) } break; - case F_CLOSED_SIG: + case F_CLOSED: { CHECK_REQUEST(p, e) list<string> deletedScopes; @@ -125,68 +124,53 @@ GCFEvent::TResult GPAController::connected(GCFEvent& e, GCFPortInterface& p) } break; } - case F_CONNECTED_SIG: + case F_CONNECTED: _pmlPorts.push_back(&p); break; - case PA_LOADAPC: + case PA_LOAD_APC: { CHECK_REQUEST(p, e) - loadAPC((char*)(&e) + sizeof(PALoadapcEvent)); + loadAPC(e); break; } - case PA_UNLOADAPC: + case PA_UNLOAD_APC: { CHECK_REQUEST(p, e) - unloadAPC((char*)(&e) + sizeof(PAUnloadapcEvent)); + unloadAPC(e); break; } - case PA_RELOADAPC: + case PA_RELOAD_APC: { CHECK_REQUEST(p, e) - reloadAPC((char*)(&e) + sizeof(PAReloadapcEvent)); + reloadAPC(e); break; } - case PA_REGISTERSCOPE: + case PA_REGISTER_SCOPE: { - PARegisterscopeEvent* pRequest = static_cast<PARegisterscopeEvent*>(&e); - assert(pRequest); - string scope; - unsigned int scopeDataLength = Utils::unpackString((char*)(&e) + sizeof(PARegisterscopeEvent), scope); + PARegisterScopeEvent request(e); LOFAR_LOG_INFO(PA_STDOUT_LOGGER, ( "PML-REQ: Register scope %s", - scope.c_str())); - PAScoperegisteredEvent response(pRequest->seqnr, PA_NO_ERROR); - response.result = _scopeManager.registerScope(scope, p); - response.length += scopeDataLength; - p.send(response, (char*)(&e) + sizeof(PARegisterscopeEvent), scopeDataLength); + request.scope.c_str())); + PAScopeRegisteredEvent response; + response.result = _scopeManager.registerScope(request.scope, p); + response.scope = request.scope; + p.send(response); break; } - case PA_UNREGISTERSCOPE: + case PA_UNREGISTER_SCOPE: { CHECK_REQUEST(p, e) - unregisterScope((char*)(&e) + sizeof(PAUnregisterscopeEvent)); + unregisterScope(e); break; } - case PA_PROPERTIESLINKED: - { - PAPropertieslinkedEvent* pResponse = static_cast<PAPropertieslinkedEvent*>(&e); - assert(pResponse); - if (pResponse->result != PA_NO_ERROR && _curResult == PA_NO_ERROR) - _curResult = pResponse->result; - propertiesLinked((char*)(&e) + sizeof(PAPropertieslinkedEvent)); + case PA_PROPERTIES_LINKED: + propertiesLinked(e); break; - } - case PA_PROPERTIESUNLINKED: - { - PAPropertiesunlinkedEvent* pResponse = static_cast<PAPropertiesunlinkedEvent*>(&e); - assert(pResponse); - if (pResponse->result != PA_NO_ERROR && _curResult == PA_NO_ERROR) - _curResult = pResponse->result; - propertiesUnlinked((char*)(&e) + sizeof(PAPropertiesunlinkedEvent)); + case PA_PROPERTIES_UNLINKED: + propertiesUnlinked(e); break; - } - case F_ACCEPT_REQ_SIG: + case F_ACCEPT_REQ: { GCFTCPPort* pNewPMLPort = new GCFTCPPort(); pNewPMLPort->init(*this, "pa", GCFPortInterface::SPP, PA_PROTOCOL); @@ -194,7 +178,7 @@ GCFEvent::TResult GPAController::connected(GCFEvent& e, GCFPortInterface& p) break; } - case F_TIMER_SIG: + case F_TIMER: { if (&p == &_pmlPortProvider) { @@ -259,7 +243,7 @@ void GPAController::allPropertiesDeletedByScope() if (pPort) { - if (pEvent->signal == F_CLOSED_SIG) + if (pEvent->signal == F_CLOSED) { _requestManager.deleteRequestsOfPort(*pPort); _pmlPortProvider.setTimer(0, 0, 0, 0, (void*) pPort); @@ -273,19 +257,17 @@ void GPAController::allPropertiesDeletedByScope() dispatch(*pEvent, *pPort); } } - else if (pEvent->signal == PA_UNREGISTERSCOPE) + else if (pEvent->signal == PA_UNREGISTER_SCOPE) { if (pPort->isConnected()) { - PAUnregisterscopeEvent* pRequest = static_cast<PAUnregisterscopeEvent*>(pEvent); - assert(pRequest); - PAScopeunregisteredEvent response(pRequest->seqnr, _curResult); - // reuse the request data (scope) for the response - unsigned short bufLength(pRequest->length - sizeof(PAUnregisterscopeEvent)); - char* buffer = ((char*) pRequest) + sizeof(PAUnregisterscopeEvent); + PAUnregisterScopeEvent request(*pEvent); + + PAScopeUnregisteredEvent response; + response.result = _curResult; + response.scope = request.scope; _isBusy = true; - response.length += bufLength; - pPort->send(response, buffer, bufLength); + pPort->send(response); } doNextRequest(); } @@ -310,14 +292,16 @@ void GPAController::doNextRequest() } } -void GPAController::loadAPC(char* actionData) +void GPAController::loadAPC(GCFEvent& e) { const list<TAPCProperty>* propsFromAPC; - unpackAPCActionData(actionData); + PALoadApcEvent request(e); + _curApcName = request.name; + _curScope = request.scope; LOFAR_LOG_INFO(PA_STDOUT_LOGGER, ( "PML-REQ: Load APC %s with scope %s", - _curApcName.c_str(), _curScope.c_str())); - _apcFileReader.readFile(_curApcName, _curScope); + request.name.c_str(), request.scope.c_str())); + _apcFileReader.readFile(request.name, request.scope); propsFromAPC = &_apcFileReader.getProperties(); _usecountManager.incrementUsecount(*propsFromAPC); if (!_usecountManager.waitForAsyncResponses()) @@ -329,29 +313,32 @@ void GPAController::apcLoaded(TPAResult result) const list<TAPCProperty>* pPropsFromAPC; pPropsFromAPC = &_apcFileReader.getProperties(); - GCFEvent* pEvent = _requestManager.getOldestRequest(); - assert(pEvent); - PALoadapcEvent* pLoadapcE = static_cast<PALoadapcEvent*> (pEvent); - assert(pLoadapcE); + GCFEvent* pRequestEvent = _requestManager.getOldestRequest(); + assert(pRequestEvent); + PALoadApcEvent request(*pRequestEvent); - if (pLoadapcE->loadDefaults && result == PA_NO_ERROR ) + if (request.loadDefaults && result == PA_NO_ERROR ) result = _usecountManager.setDefaults(*pPropsFromAPC); if (result != PA_NO_ERROR && _curResult == PA_NO_ERROR) _curResult = result; - PAApcloadedEvent e(pLoadapcE->seqnr, _curResult); - sendAPCActionResponse(e); + PAApcLoadedEvent response; + response.seqnr = request.seqnr; + response.result = _curResult; + sendAPCActionResponse(response); } -void GPAController::unloadAPC(char* actionData) +void GPAController::unloadAPC(GCFEvent& e) { const list<TAPCProperty>* pPropsFromAPC; - unpackAPCActionData(actionData); + PAUnloadApcEvent request(e); + _curApcName = request.name; + _curScope = request.scope; LOFAR_LOG_INFO(PA_STDOUT_LOGGER, ( "PML-REQ: Unload APC %s with scope %s", - _curApcName.c_str(), _curScope.c_str())); - _apcFileReader.readFile(_curApcName, _curScope); + request.name.c_str(), request.scope.c_str())); + _apcFileReader.readFile(request.name, request.scope); pPropsFromAPC = &_apcFileReader.getProperties(); _usecountManager.decrementUsecount(*pPropsFromAPC); if (!_usecountManager.waitForAsyncResponses()) @@ -360,22 +347,27 @@ void GPAController::unloadAPC(char* actionData) void GPAController::apcUnloaded(TPAResult result) { - GCFEvent* pEvent = _requestManager.getOldestRequest(); - PAUnloadapcEvent* pUnloadapcE = static_cast<PAUnloadapcEvent*> (pEvent); + GCFEvent* pRequestEvent = _requestManager.getOldestRequest(); + assert(pRequestEvent); + PAUnloadApcEvent request(*pRequestEvent); if (result != PA_NO_ERROR && _curResult == PA_NO_ERROR) _curResult = result; - PAApcunloadedEvent e(pUnloadapcE->seqnr, _curResult); - sendAPCActionResponse(e); + PAApcUnloadedEvent response; + response.seqnr = request.seqnr; + response.result = _curResult; + sendAPCActionResponse(response); } -void GPAController::reloadAPC(char* actionData) +void GPAController::reloadAPC(GCFEvent& e) { const list<TAPCProperty>* pPropsFromAPC; - unpackAPCActionData(actionData); + PAReloadApcEvent request(e); + _curApcName = request.name; + _curScope = request.scope; LOFAR_LOG_INFO(PA_STDOUT_LOGGER, ( "PML-REQ: Reload APC %s with scope %s", - _curApcName.c_str(), _curScope.c_str())); - _apcFileReader.readFile(_curApcName, _curScope); + request.name.c_str(), request.scope.c_str())); + _apcFileReader.readFile(request.name, request.scope); pPropsFromAPC = &_apcFileReader.getProperties(); TPAResult result = _usecountManager.setDefaults(*pPropsFromAPC); @@ -383,48 +375,51 @@ void GPAController::reloadAPC(char* actionData) if (result != PA_NO_ERROR && _curResult == PA_NO_ERROR) _curResult = result; - GCFEvent* pEvent = _requestManager.getOldestRequest(); - PAReloadapcEvent* pReloadapcE = static_cast<PAReloadapcEvent*> (pEvent); - PAApcreloadedEvent e(pReloadapcE->seqnr, _curResult); - sendAPCActionResponse(e); + PAApcReloadedEvent response; + response.seqnr = request.seqnr; + response.result = _curResult; + sendAPCActionResponse(response); } -void GPAController::unregisterScope(char* pScopeData) +void GPAController::unregisterScope(GCFEvent& e) { - string scope; - Utils::unpackString(pScopeData, scope); + PAUnregisterScopeEvent request(e); LOFAR_LOG_INFO(PA_STDOUT_LOGGER, ( "PML-REQ: Unregister scope %s", - scope.c_str())); + request.scope.c_str())); list<string> subScopes; - _scopeManager.getSubScopes(scope, subScopes); - _usecountManager.deletePropertiesByScope(scope, subScopes); - _scopeManager.unregisterScope(scope); + _scopeManager.getSubScopes(request.scope, subScopes); + _usecountManager.deletePropertiesByScope(request.scope, subScopes); + _scopeManager.unregisterScope(request.scope); if (!_usecountManager.waitForAsyncResponses()) allPropertiesDeletedByScope(); } -void GPAController::propertiesLinked(char* pResponseData) +void GPAController::propertiesLinked(GCFEvent& e) { - string scope; - Utils::unpackString(pResponseData, scope); + PAPropertiesLinkedEvent response(e); + + if (response.result != PA_NO_ERROR && _curResult == PA_NO_ERROR) + _curResult = response.result; LOFAR_LOG_INFO(PA_STDOUT_LOGGER, ( "PML-RESP: Properties linked on scope %s", - scope.c_str())); - _scopeManager.propertiesLinked(scope); + response.scope.c_str())); + _scopeManager.propertiesLinked(response.scope); } -void GPAController::propertiesUnlinked(char* pResponseData) +void GPAController::propertiesUnlinked(GCFEvent& e) { - string scope; - Utils::unpackString(pResponseData, scope); + PAPropertiesUnlinkedEvent response(e); + + if (response.result != PA_NO_ERROR && _curResult == PA_NO_ERROR) + _curResult = response.result; LOFAR_LOG_INFO(PA_STDOUT_LOGGER, ( "PML-RESP: Properties unlinked on scope %s", - scope.c_str())); - _scopeManager.propertiesUnlinked(scope); + response.scope.c_str())); + _scopeManager.propertiesUnlinked(response.scope); } void GPAController::sendAPCActionResponse(GCFEvent& e) @@ -438,9 +433,3 @@ void GPAController::sendAPCActionResponse(GCFEvent& e) } doNextRequest(); } - -void GPAController::unpackAPCActionData(char* pActionData) -{ - unsigned int dataLength = Utils::unpackString(pActionData, _curApcName); - Utils::unpackString(pActionData + dataLength, _curScope); -} diff --git a/MAC/GCF/_CoreComps/PA/src/GPA_Controller.h b/MAC/GCF/_CoreComps/PA/src/GPA_Controller.h index e601229c23869c3a874fea66a60227248197941e..bbab66c258128d8a1d8d807164f5b05075899129 100644 --- a/MAC/GCF/_CoreComps/PA/src/GPA_Controller.h +++ b/MAC/GCF/_CoreComps/PA/src/GPA_Controller.h @@ -58,16 +58,15 @@ class GPAController : public GCFTask friend class GPAScopeManager; void doNextRequest(); bool mayContinue(GCFEvent& e, GCFPortInterface& p); - void loadAPC(char* actionData); + void loadAPC(GCFEvent& e); void apcLoaded(TPAResult result); - void unloadAPC(char* actionData); + void unloadAPC(GCFEvent& e); void apcUnloaded(TPAResult result); - void reloadAPC(char* actionData); - void unregisterScope(char* pScopeData); - void propertiesLinked(char* pResponseData); - void propertiesUnlinked(char* pResponseData); + void reloadAPC(GCFEvent& e); + void unregisterScope(GCFEvent& e); + void propertiesLinked(GCFEvent& e); + void propertiesUnlinked(GCFEvent& e); void sendAPCActionResponse(GCFEvent& e); - void unpackAPCActionData(char* pActionData); private: // state methods GCFEvent::TResult initial(GCFEvent& e, GCFPortInterface& p); diff --git a/MAC/GCF/_CoreComps/PA/src/GPA_RequestManager.cc b/MAC/GCF/_CoreComps/PA/src/GPA_RequestManager.cc index 889bc20acbbaf5accf7eb697e10dd40d7faf3bad..645774f009b873db3f006fb7c9ba12b0c8dbcc09 100644 --- a/MAC/GCF/_CoreComps/PA/src/GPA_RequestManager.cc +++ b/MAC/GCF/_CoreComps/PA/src/GPA_RequestManager.cc @@ -36,9 +36,8 @@ void GPARequestManager::registerRequest(GCFPortInterface& requestPort, const GCF { TRequest request; request.pRPort = &requestPort; - char* buffer = new char[e.length]; - memcpy(buffer, (const char*) &e, e.length); - request.pEvent = (GCFEvent*) buffer; + request.pEvent = new char[sizeof(e) + e.length]; + memcpy(request.pEvent, (const char*) &e, sizeof(e) + e.length); _requests.push_back(request); } @@ -48,7 +47,7 @@ GCFEvent* GPARequestManager::getOldestRequest() if (_requests.size() > 0) { TRequest* pRequest = &_requests.front(); - return pRequest->pEvent; + return (GCFEvent*) (pRequest->pEvent); } else return 0; diff --git a/MAC/GCF/_CoreComps/PA/src/GPA_RequestManager.h b/MAC/GCF/_CoreComps/PA/src/GPA_RequestManager.h index 881ffc229e9fa2d066e3278a3564811cdc50f8c1..00621fdac5fc16384792424cafb304145096defa 100644 --- a/MAC/GCF/_CoreComps/PA/src/GPA_RequestManager.h +++ b/MAC/GCF/_CoreComps/PA/src/GPA_RequestManager.h @@ -53,7 +53,7 @@ class GPARequestManager typedef struct { GCFPortInterface* pRPort; - GCFEvent* pEvent; + char* pEvent; } TRequest; list<TRequest> _requests; diff --git a/MAC/GCF/_CoreComps/PA/src/GPA_ScopeManager.cc b/MAC/GCF/_CoreComps/PA/src/GPA_ScopeManager.cc index 7714199010fcdfe41476140b4db0239a24825ab8..07563de07eca9d4dec0f2198936b49bc65c503ae 100644 --- a/MAC/GCF/_CoreComps/PA/src/GPA_ScopeManager.cc +++ b/MAC/GCF/_CoreComps/PA/src/GPA_ScopeManager.cc @@ -43,7 +43,7 @@ TPAResult GPAScopeManager::linkProperties(list<string>& propList) resetScopeList(); result = fillScopeLists(propList); - PALinkpropertiesEvent e(0); + PALinkPropertiesEvent e; sendUnLinkEvents(e); return result; } @@ -55,7 +55,7 @@ TPAResult GPAScopeManager::unlinkProperties(list<string>& propList) _counter = 0; resetScopeList(); result = fillScopeLists(propList); - PAUnlinkpropertiesEvent e(0); + PAUnlinkPropertiesEvent e; sendUnLinkEvents(e); return result; } @@ -212,22 +212,16 @@ TPAResult GPAScopeManager::fillScopeLists(list<string>& propList) void GPAScopeManager::sendUnLinkEvents(GCFEvent& e) { TScopeData* pScopeData; - const string* pScope; list<string>* pPropList; - unsigned int oldEventLength(e.length); - - static const unsigned int MAX_BUF_SIZE = 5000; - static char buffer[MAX_BUF_SIZE]; for (TScopeListIter iter = _scopeList.begin(); iter != _scopeList.end(); ++iter) { - pScope = &iter->first; pScopeData = &iter->second; - assert(pScopeData); pPropList = &pScopeData->propList; + assert(pPropList); if (pPropList->size() > 0) { pScopeData->respond = false; @@ -235,27 +229,27 @@ void GPAScopeManager::sendUnLinkEvents(GCFEvent& e) if (pPort->isConnected()) { _counter++; - unsigned int dataLength = Utils::packString(*pScope, buffer, MAX_BUF_SIZE); - char* pPropListStart = buffer + dataLength; - dataLength += Utils::packPropertyList(*pPropList, buffer + dataLength, MAX_BUF_SIZE - dataLength); - assert(dataLength < MAX_BUF_SIZE); - buffer[dataLength] = 0; - if (e.signal == PA_LINKPROPERTIES) + if (e.signal == PA_LINK_PROPERTIES) { + PALinkPropertiesEvent* pLP = (PALinkPropertiesEvent*) &e; + pLP->scope = *(&iter->first); + Utils::getPropertyListString(pLP->propList, *pPropList); LOFAR_LOG_INFO(PA_STDOUT_LOGGER, ( "REQ: Link properties %s on scope %s", - pPropListStart + Utils::SLEN_FIELD_SIZE, - pScope->c_str())); + pLP->propList.c_str(), + pLP->scope.c_str())); } else { + PALinkPropertiesEvent* pULP = (PALinkPropertiesEvent*) &e; + pULP->scope = *(&iter->first); + Utils::getPropertyListString(pULP->propList, *pPropList); LOFAR_LOG_INFO(PA_STDOUT_LOGGER, ( "REQ: Unlink properties %s on scope %s", - pPropListStart + Utils::SLEN_FIELD_SIZE, - pScope->c_str())); + pULP->propList.c_str(), + pULP->scope.c_str())); } - e.length = oldEventLength + dataLength; - pPort->send(e, buffer, dataLength); + pPort->send(e); } } } diff --git a/MAC/GCF/_CoreComps/PA/src/Makefile.am b/MAC/GCF/_CoreComps/PA/src/Makefile.am index 678c1d52170f6fcad5e0f70ef060a5ba120d23c4..221bd367981813bcebfac9732c69666972336795 100644 --- a/MAC/GCF/_CoreComps/PA/src/Makefile.am +++ b/MAC/GCF/_CoreComps/PA/src/Makefile.am @@ -1,7 +1,7 @@ AUTOGEN = autogen SUFFIXES = .ph %.ph: %.prot - $(AUTOGEN) -L $(top_srcdir)/GCFCommon/autogen $< && \ + $(AUTOGEN) -L $(top_srcdir)/../MACCommon/autogen $< && \ chmod a+w $@ DOCHDRS = \ @@ -19,7 +19,8 @@ libpa_la_SOURCES= $(DOCHDRS) \ GPA_ScopeManager.cc \ GPA_UsecountManager.cc \ GPA_RequestManager.cc \ - GPA_APCFileReader.cc + GPA_APCFileReader.cc \ + PA_Protocol.cc libpa_la_CPPFLAGS= -I$(top_srcdir)/GCFCommon/src \ -I$(top_srcdir)/CoreComps/TM/src \ diff --git a/MAC/GCF/_CoreComps/PA/src/PA_Protocol.prot b/MAC/GCF/_CoreComps/PA/src/PA_Protocol.prot index c0a0e3ab6bbe6cf29b6904f5b27520ed41efcb30..dbe7845be0df4b2f3cb86d4b117da57a84b84454 100644 --- a/MAC/GCF/_CoreComps/PA/src/PA_Protocol.prot +++ b/MAC/GCF/_CoreComps/PA/src/PA_Protocol.prot @@ -5,17 +5,10 @@ autogen definitions protocol; description = "Protocol for the PA server"; prefix = "PA"; // for the signal names +id = "(F_GCF_PROTOCOL + 1)"; // specify extra include files -// e.g. -include = '<sys/time.h>'; - -prelude = << PRELUDE_END -enum { - PA_PROTOCOL = (F_GCF_PROTOCOL + 1) -}; -#include <GPA_Defines.h> -PRELUDE_END; +include = '<GPA_Defines.h>'; // // An "event" has a "signal" and a "dir" (direction) @@ -24,7 +17,7 @@ PRELUDE_END; // A "param" has a "name" and a "type". // event = { - signal = LOADAPC; + signal = LOAD_APC; dir = IN; param = { name = "seqnr"; @@ -34,28 +27,52 @@ event = { name = "loadDefaults"; type = "bool"; }; + param = { + name = "scope"; + type = "string"; + }; + param = { + name = "name"; + type = "string"; + }; }; event = { - signal = UNLOADAPC; + signal = UNLOAD_APC; dir = IN; param = { name = "seqnr"; type = "unsigned int"; }; + param = { + name = "scope"; + type = "string"; + }; + param = { + name = "name"; + type = "string"; + }; }; event = { - signal = RELOADAPC; + signal = RELOAD_APC; dir = IN; param = { name = "seqnr"; type = "unsigned int"; }; + param = { + name = "scope"; + type = "string"; + }; + param = { + name = "name"; + type = "string"; + }; }; event = { - signal = APCLOADED; + signal = APC_LOADED; dir = OUT; param = { name = "seqnr"; @@ -68,7 +85,7 @@ event = { }; event = { - signal = APCUNLOADED; + signal = APC_UNLOADED; dir = OUT; param = { name = "seqnr"; @@ -81,7 +98,7 @@ event = { }; event = { - signal = APCRELOADED; + signal = APC_RELOADED; dir = OUT; param = { name = "seqnr"; @@ -94,89 +111,97 @@ event = { }; event = { - signal = REGISTERSCOPE; + signal = REGISTER_SCOPE; dir = IN; param = { - name = "seqnr"; - type = "unsigned int"; + name = "scope"; + type = "string"; }; }; event = { - signal = UNREGISTERSCOPE; + signal = UNREGISTER_SCOPE; dir = IN; param = { - name = "seqnr"; - type = "unsigned int"; + name = "scope"; + type = "string"; }; }; event = { - signal = SCOPEREGISTERED; + signal = SCOPE_REGISTERED; dir = OUT; - param = { - name = "seqnr"; - type = "unsigned int"; - }; param = { name = "result"; type = "TPAResult"; }; + param = { + name = "scope"; + type = "string"; + }; }; event = { - signal = SCOPEUNREGISTERED; + signal = SCOPE_UNREGISTERED; dir = OUT; - param = { - name = "seqnr"; - type = "unsigned int"; - }; param = { name = "result"; type = "TPAResult"; }; + param = { + name = "scope"; + type = "string"; + }; }; event = { - signal = LINKPROPERTIES; + signal = LINK_PROPERTIES; dir = OUT; param = { - name = "seqnr"; - type = "unsigned int"; + name = "scope"; + type = "string"; + }; + param = { + name = "propList"; + type = "string"; }; }; event = { - signal = UNLINKPROPERTIES; + signal = UNLINK_PROPERTIES; dir = OUT; param = { - name = "seqnr"; - type = "unsigned int"; + name = "scope"; + type = "string"; + }; + param = { + name = "propList"; + type = "string"; }; }; event = { - signal = PROPERTIESLINKED; + signal = PROPERTIES_LINKED; dir = IN; - param = { - name = "seqnr"; - type = "unsigned int"; - }; param = { name = "result"; type = "TPAResult"; }; + param = { + name = "scope"; + type = "string"; + }; }; event = { - signal = PROPERTIESUNLINKED; + signal = PROPERTIES_UNLINKED; dir = IN; - param = { - name = "seqnr"; - type = "unsigned int"; - }; param = { name = "result"; type = "TPAResult"; }; + param = { + name = "scope"; + type = "string"; + }; }; diff --git a/MAC/GCF/_CoreComps/PA/test/GPA_Controller.cc b/MAC/GCF/_CoreComps/PA/test/GPA_Controller.cc index ba7296f589bc92cb2881387a6db19a219a5790d1..371c87a7445c06059c8544bc92d426abd9902759 100644 --- a/MAC/GCF/_CoreComps/PA/test/GPA_Controller.cc +++ b/MAC/GCF/_CoreComps/PA/test/GPA_Controller.cc @@ -60,19 +60,19 @@ int GPAController::initial(GCFEvent& e, GCFPortInterface& p) switch (e.signal) { - case F_INIT_SIG: + case F_INIT: break; - case F_ENTRY_SIG: - case F_TIMER_SIG: + case F_ENTRY: + case F_TIMER: _pmlPortProvider.open(); break; - case F_CONNECTED_SIG: + case F_CONNECTED: TRAN(&GPAController::connected); break; - case F_DISCONNECTED_SIG: + case F_DISCONNECTED: if (&p == &_pmlPortProvider) _pmlPortProvider.setTimer(1.0); // try again after 1 second break; @@ -91,7 +91,7 @@ int GPAController::connected(GCFEvent& e, GCFPortInterface& p) switch (e.signal) { - case F_DISCONNECTED_SIG: + case F_DISCONNECTED: if (&p == &_pmlPortProvider) { _scopeManager.deleteAllScopes(); @@ -126,7 +126,7 @@ int GPAController::connected(GCFEvent& e, GCFPortInterface& p) } break; - case F_CONNECTED_SIG: + case F_CONNECTED: _pmlPorts.push_back(&p); break; @@ -182,7 +182,7 @@ int GPAController::connected(GCFEvent& e, GCFPortInterface& p) propertiesUnlinked((char*)response + sizeof(PAPropertiesunlinkedEvent)); break; } - case F_ACCEPT_REQ_SIG: + case F_ACCEPT_REQ: { GCFTCPPort* pNewPMLPort = new GCFTCPPort(); pNewPMLPort->init(*this, "pa", GCFPortInterface::SPP, PA_PROTOCOL); @@ -190,7 +190,7 @@ int GPAController::connected(GCFEvent& e, GCFPortInterface& p) break; } - case F_TIMER_SIG: + case F_TIMER: { if (&p == &_pmlPortProvider) { @@ -234,7 +234,7 @@ void GPAController::allPropertiesDeletedByScope() if (pPort) { - if (pEvent->signal == F_DISCONNECTED_SIG) + if (pEvent->signal == F_DISCONNECTED) { _counter--; if (_counter == 0) diff --git a/MAC/GCF/_CoreComps/PML/src/GCF_Answer.cc b/MAC/GCF/_CoreComps/PML/src/GCF_Answer.cc index fff8e86b21ae285df1894d306bd7f9307864938c..22a954c51fbd011b889e8641c62590fa49767498 100644 --- a/MAC/GCF/_CoreComps/PML/src/GCF_Answer.cc +++ b/MAC/GCF/_CoreComps/PML/src/GCF_Answer.cc @@ -28,13 +28,13 @@ const char* F_PML_PROTOCOL_signalnames[] = { "F_PML_PROTOCOL: invalid signal", - "F_SUBCRIBED_SIG (IN)", - "F_UNSUBCRIBED_SIG (IN)", - "F_VCHANGEMSG_SIG (IN)", - "F_VGETRESP_SIG (IN)", - "F_APCLOADED_SIG (IN)", - "F_APCUNLOADED_SIG (IN)", - "F_APCRELOADED_SIG (IN)", - "F_MYPLOADED_SIG (IN)", - "F_MYPUNLOADED_SIG (IN)", + "F_SUBCRIBED (IN)", + "F_UNSUBCRIBED (IN)", + "F_VCHANGEMSG (IN)", + "F_VGETRESP (IN)", + "F_APCLOADED (IN)", + "F_APCUNLOADED (IN)", + "F_APCRELOADED (IN)", + "F_MYPLOADED (IN)", + "F_MYPUNLOADED (IN)", }; diff --git a/MAC/GCF/_CoreComps/PML/src/GCF_Apc.cc b/MAC/GCF/_CoreComps/PML/src/GCF_Apc.cc index ba9a69438a11f4f36a36fae4340a9e298eee1548..38bdb6f37d4e0a17bbb7793d5338ae96d833af28 100644 --- a/MAC/GCF/_CoreComps/PML/src/GCF_Apc.cc +++ b/MAC/GCF/_CoreComps/PML/src/GCF_Apc.cc @@ -169,7 +169,7 @@ void GCFApc::loaded (TGCFResult result) "PA-RESP: Apc %s loaded with scope %s", _name.c_str(), _scope.c_str())); - dispatchAnswer(F_APCLOADED_SIG, result); + dispatchAnswer(F_APCLOADED, result); } void GCFApc::unloaded(TGCFResult result) @@ -187,7 +187,7 @@ void GCFApc::unloaded(TGCFResult result) "PA-RESP: Apc %s unloaded with scope %s", _name.c_str(), _scope.c_str())); - dispatchAnswer(F_APCUNLOADED_SIG, result); + dispatchAnswer(F_APCUNLOADED, result); } void GCFApc::reloaded(TGCFResult result) @@ -201,7 +201,7 @@ void GCFApc::reloaded(TGCFResult result) "PA-RESP: Apc %s reloaded with scope %s", _name.c_str(), _scope.c_str())); - dispatchAnswer(F_APCRELOADED_SIG, result); + dispatchAnswer(F_APCRELOADED, result); } TGCFResult GCFApc::setName (const string name) diff --git a/MAC/GCF/_CoreComps/PML/src/GCF_MyProperty.cc b/MAC/GCF/_CoreComps/PML/src/GCF_MyProperty.cc index ee36b81019cb02ccc87b6202ad86b7ec313d3a96..dd816455b3b3086e7c3ab818cdc1bfe77381a793 100644 --- a/MAC/GCF/_CoreComps/PML/src/GCF_MyProperty.cc +++ b/MAC/GCF/_CoreComps/PML/src/GCF_MyProperty.cc @@ -224,7 +224,7 @@ void GCFMyProperty::valueChanged (const GCFPValue& value) result = _pCurValue->copy(value); assert(result == GCF_NO_ERROR); - GCFPropValueEvent e(F_VCHANGEMSG_SIG); + GCFPropValueEvent e(F_VCHANGEMSG); e.pValue = &value; string fullName(getFullName()); e.pPropName = fullName.c_str(); diff --git a/MAC/GCF/_CoreComps/PML/src/GCF_MyPropertySet.cc b/MAC/GCF/_CoreComps/PML/src/GCF_MyPropertySet.cc index 05ed8742351101594417c8e3d032ea690240d8be..c7b6e0e77b341fa59cb70021a06fdc1665041411 100644 --- a/MAC/GCF/_CoreComps/PML/src/GCF_MyPropertySet.cc +++ b/MAC/GCF/_CoreComps/PML/src/GCF_MyPropertySet.cc @@ -224,7 +224,7 @@ void GCFMyPropertySet::scopeRegistered (TGCFResult result) getScope().c_str())); } - dispatchAnswer(F_MYPLOADED_SIG, result); + dispatchAnswer(F_MYPLOADED, result); } void GCFMyPropertySet::scopeUnregistered (TGCFResult result) @@ -239,7 +239,7 @@ void GCFMyPropertySet::scopeUnregistered (TGCFResult result) "PA-RESP: Scope %s unregistered", getScope().c_str())); - dispatchAnswer(F_MYPUNLOADED_SIG, result); + dispatchAnswer(F_MYPUNLOADED, result); } void GCFMyPropertySet::linkProperties(list<string>& properties) diff --git a/MAC/GCF/_CoreComps/PML/src/GCF_PropertyBase.cc b/MAC/GCF/_CoreComps/PML/src/GCF_PropertyBase.cc index 8a8feb09564b64d4dd7c42610721e3eeeb31ed22..5e4790b1ccab0b2642d91e2ed0c30c94468b6213 100644 --- a/MAC/GCF/_CoreComps/PML/src/GCF_PropertyBase.cc +++ b/MAC/GCF/_CoreComps/PML/src/GCF_PropertyBase.cc @@ -60,14 +60,14 @@ void GCFPropertyBase::dispatchAnswer(GCFEvent& answer) void GCFPropertyBase::subscribed () { - GCFPropAnswerEvent e(F_SUBSCRIBED_SIG); + GCFPropAnswerEvent e(F_SUBSCRIBED); e.pPropName = _name.c_str(); dispatchAnswer(e); } void GCFPropertyBase::valueChanged (const GCFPValue& value) { - GCFPropValueEvent e(F_VCHANGEMSG_SIG); + GCFPropValueEvent e(F_VCHANGEMSG); e.pValue = &value; e.pPropName = _name.c_str(); e.internal = false; @@ -76,7 +76,7 @@ void GCFPropertyBase::valueChanged (const GCFPValue& value) void GCFPropertyBase::valueGet (const GCFPValue& value) { - GCFPropValueEvent e(F_VGETRESP_SIG); + GCFPropValueEvent e(F_VGETRESP); e.pValue = &value; e.pPropName = _name.c_str(); dispatchAnswer(e); diff --git a/MAC/GCF/_CoreComps/PML/src/GPM_Controller.cc b/MAC/GCF/_CoreComps/PML/src/GPM_Controller.cc index 72cc3741d3e8a470b611763a5cf602147ffde748..a441ddff2c43103bb60fe2745b35d714558dbc9b 100644 --- a/MAC/GCF/_CoreComps/PML/src/GPM_Controller.cc +++ b/MAC/GCF/_CoreComps/PML/src/GPM_Controller.cc @@ -25,7 +25,6 @@ #include <GCF/GCF_Apc.h> #include <stdio.h> #include <Utils.h> -#define DECLARE_SIGNAL_NAMES #include <PA_Protocol.ph> static string sPMLTaskName("PML"); @@ -42,7 +41,6 @@ GPMController::GPMController() : // initialize the port _propertyAgent.init(*this, "client", GCFPortInterface::SAP, PA_PROTOCOL); - memset(_buffer, '0', MAX_BUF_SIZE); } GPMController::~GPMController() @@ -64,12 +62,23 @@ TPMResult GPMController::loadAPC(GCFApc& apc, bool loadDefaults) { TPMResult result(PM_NO_ERROR); - unsigned short seqnr = getFreeSeqnrForApcRequest(); - _apcList[seqnr] = &apc; - - PALoadapcEvent e(seqnr, loadDefaults); - sendAPCRequest(e, apc); - + if (_propertyAgent.isConnected()) + { + unsigned short seqnr = getFreeSeqnrForApcRequest(); + _apcList[seqnr] = &apc; + + PALoadApcEvent request; + request.seqnr = seqnr; + request.loadDefaults = loadDefaults; + request.name = apc.getName(); + request.scope = apc.getScope(); + + _propertyAgent.send(request); + } + else + { + result = PM_PA_NOTCONNECTED; + } return result; } @@ -77,12 +86,22 @@ TPMResult GPMController::unloadAPC(GCFApc& apc) { TPMResult result(PM_NO_ERROR); - unsigned short seqnr = getFreeSeqnrForApcRequest(); - _apcList[seqnr] = &apc; + if (_propertyAgent.isConnected()) + { + unsigned short seqnr = getFreeSeqnrForApcRequest(); + _apcList[seqnr] = &apc; - PAUnloadapcEvent e(seqnr); - sendAPCRequest(e, apc); - + PAUnloadApcEvent request; + request.seqnr = seqnr; + request.name = apc.getName(); + request.scope = apc.getScope(); + + _propertyAgent.send(request); + } + else + { + result = PM_PA_NOTCONNECTED; + } return result; } @@ -90,12 +109,22 @@ TPMResult GPMController::reloadAPC(GCFApc& apc) { TPMResult result(PM_NO_ERROR); - unsigned short seqnr = getFreeSeqnrForApcRequest(); - _apcList[seqnr] = &apc; - - PAReloadapcEvent e(seqnr); - sendAPCRequest(e, apc); - + if (_propertyAgent.isConnected()) + { + unsigned short seqnr = getFreeSeqnrForApcRequest(); + _apcList[seqnr] = &apc; + + PAReloadApcEvent request; + request.seqnr = seqnr; + request.name = apc.getName(); + request.scope = apc.getScope(); + + _propertyAgent.send(request); + } + else + { + result = PM_PA_NOTCONNECTED; + } return result; } @@ -125,17 +154,6 @@ unsigned short GPMController::getFreeSeqnrForApcRequest() const return seqnr; } -void GPMController::sendAPCRequest(GCFEvent& e, const GCFApc& apc) -{ - if (_propertyAgent.isConnected()) - { - unsigned int dataLength = Utils::packString(apc.getName(), _buffer, MAX_BUF_SIZE); - dataLength += Utils::packString(apc.getScope(), _buffer + dataLength, MAX_BUF_SIZE - dataLength); - e.length += dataLength; - _propertyAgent.send(e, _buffer, dataLength); - } -} - TPMResult GPMController::registerScope(GCFMyPropertySet& propSet) { TPMResult result(PM_NO_ERROR); @@ -148,8 +166,12 @@ TPMResult GPMController::registerScope(GCFMyPropertySet& propSet) { _propertySets[propSet.getScope()] = &propSet; - PARegisterscopeEvent e(0); - sendMyPropSetMsg(e, propSet.getScope()); + if (_propertyAgent.isConnected()) + { + PARegisterScopeEvent request; + request.scope = propSet.getScope(); + _propertyAgent.send(request); + } } return result; } @@ -161,10 +183,11 @@ TPMResult GPMController::unregisterScope(GCFMyPropertySet& propSet, // prop set could be unloaded in case of destruction of the propSet // calls this method - if (propSet.isLoaded()) + if (propSet.isLoaded() && _propertyAgent.isConnected()) { - PAUnregisterscopeEvent e(0); - sendMyPropSetMsg(e, propSet.getScope()); + PAUnregisterScopeEvent request; + request.scope = propSet.getScope(); + _propertyAgent.send(request); } if (permanent) { @@ -179,23 +202,23 @@ void GPMController::propertiesLinked(const string& scope, TPAResult result) _counter--; LOFAR_LOG_DEBUG(PML_STDOUT_LOGGER, ( "Link request %d counter", _counter)); - PAPropertieslinkedEvent e(0, result); - sendMyPropSetMsg(e, scope); + if (_propertyAgent.isConnected()) + { + PAPropertiesLinkedEvent response; + response.result = result; + response.scope = scope; + _propertyAgent.send(response); + } } void GPMController::propertiesUnlinked(const string& scope, TPAResult result) -{ - PAPropertiesunlinkedEvent e(0, result); - sendMyPropSetMsg(e, scope); -} - -void GPMController::sendMyPropSetMsg(GCFEvent& e, const string& scope) { if (_propertyAgent.isConnected()) { - unsigned int dataLength = Utils::packString(scope, _buffer, MAX_BUF_SIZE); - e.length += dataLength; - _propertyAgent.send(e, _buffer, dataLength); + PAPropertiesUnlinkedEvent response; + response.result = result; + response.scope = scope; + _propertyAgent.send(response); } } @@ -205,19 +228,19 @@ GCFEvent::TResult GPMController::initial(GCFEvent& e, GCFPortInterface& /*p*/) switch (e.signal) { - case F_INIT_SIG: + case F_INIT: break; - case F_ENTRY_SIG: - case F_TIMER_SIG: + case F_ENTRY: + case F_TIMER: _propertyAgent.open(); break; - case F_CONNECTED_SIG: + case F_CONNECTED: TRAN(GPMController::connected); break; - case F_DISCONNECTED_SIG: + case F_DISCONNECTED: _propertyAgent.setTimer(1.0); // try again after 1 second break; @@ -233,55 +256,54 @@ GCFEvent::TResult GPMController::connected(GCFEvent& e, GCFPortInterface& /*p*/) { GCFEvent::TResult status = GCFEvent::HANDLED; TGCFResult result; - static char* pData = 0; - static string scope = ""; switch (e.signal) { - case F_DISCONNECTED_SIG: + case F_DISCONNECTED: LOFAR_LOG_WARN(PML_STDOUT_LOGGER, ( "Connection lost to Property Agent")); TRAN(GPMController::initial); break; - case F_ENTRY_SIG: + case F_ENTRY: { - PARegisterscopeEvent rse(0); + PARegisterScopeEvent regRequest; for (TPropertySets::iterator iter = _propertySets.begin(); iter != _propertySets.end(); ++iter) { - sendMyPropSetMsg(rse, iter->first); + regRequest.scope = iter->first; + _propertyAgent.send(regRequest); } - PALoadapcEvent lae(0, false); + PALoadApcEvent apcRequest; + apcRequest.loadDefaults = false; GCFApc* pApc; for (TApcList::iterator iter = _apcList.begin(); iter != _apcList.end(); ++iter) { pApc = iter->second; assert(pApc); - lae.seqnr = iter->first; - lae.loadDefaults = pApc->mustLoadDefaults(); - sendAPCRequest(lae, *pApc); + apcRequest.seqnr = iter->first; + apcRequest.loadDefaults = pApc->mustLoadDefaults(); + apcRequest.name = pApc->getName(); + apcRequest.scope = pApc->getScope(); + _propertyAgent.send(apcRequest); } break; } - case PA_SCOPEREGISTERED: + case PA_SCOPE_REGISTERED: { - PAScoperegisteredEvent* pResponse = static_cast<PAScoperegisteredEvent*>(&e); - assert(pResponse); - pData = (char*)(&e) + sizeof(PAScoperegisteredEvent); - Utils::unpackString(pData, scope); - if (pResponse->result == PA_SCOPE_ALREADY_REGISTERED) + PAScopeRegisteredEvent response(e); + if (response.result == PA_SCOPE_ALREADY_REGISTERED) { LOFAR_LOG_INFO(PML_STDOUT_LOGGER, ( "A property set with scope %s already exists in the system", - scope.c_str())); + response.scope.c_str())); } - result = (pResponse->result == PA_NO_ERROR ? GCF_NO_ERROR : GCF_MYPROPSLOAD_ERROR); - GCFMyPropertySet* pPropertySet = _propertySets[scope]; + result = (response.result == PA_NO_ERROR ? GCF_NO_ERROR : GCF_MYPROPSLOAD_ERROR); + GCFMyPropertySet* pPropertySet = _propertySets[response.scope]; if (result != GCF_NO_ERROR) { - _propertySets.erase(scope); + _propertySets.erase(response.scope); } if (pPropertySet) { @@ -290,36 +312,30 @@ GCFEvent::TResult GPMController::connected(GCFEvent& e, GCFPortInterface& /*p*/) break; } - case PA_SCOPEUNREGISTERED: + case PA_SCOPE_UNREGISTERED: { - PAScopeunregisteredEvent* pResponse = static_cast<PAScopeunregisteredEvent*>(&e); - assert(pResponse); - pData = (char*)(&e) + sizeof(PAScopeunregisteredEvent); - Utils::unpackString(pData, scope); - GCFMyPropertySet* pPropertySet = _propertySets[scope]; - result = (pResponse->result == PA_NO_ERROR ? GCF_NO_ERROR : GCF_MYPROPSUNLOAD_ERROR); + PAScopeUnregisteredEvent response(e); + GCFMyPropertySet* pPropertySet = _propertySets[response.scope]; + result = (response.result == PA_NO_ERROR ? GCF_NO_ERROR : GCF_MYPROPSUNLOAD_ERROR); if (pPropertySet) { - _propertySets.erase(scope); + _propertySets.erase(response.scope); pPropertySet->scopeUnregistered(result); } break; } - case PA_LINKPROPERTIES: + case PA_LINK_PROPERTIES: { - pData = (char*)(&e) + sizeof(PALinkpropertiesEvent); - unsigned int scopeDataLength = Utils::unpackString(pData, scope); - string linkListData(pData + scopeDataLength + Utils::SLEN_FIELD_SIZE, - e.length - sizeof(PALinkpropertiesEvent) - scopeDataLength - Utils::SLEN_FIELD_SIZE); + PALinkPropertiesEvent request(e); list<string> propertyList; + Utils::getPropertyListFromString(propertyList, request.propList); LOFAR_LOG_INFO(PML_STDOUT_LOGGER, ( "PA-REQ: Link properties %s on scope %s", - linkListData.c_str(), - scope.c_str())); + request.propList.c_str(), + request.scope.c_str())); - Utils::unpackPropertyList(pData + scopeDataLength, propertyList); - GCFMyPropertySet* pPropertySet = _propertySets[scope]; + GCFMyPropertySet* pPropertySet = _propertySets[request.scope]; if (pPropertySet) { if (_counter == 0) @@ -333,25 +349,24 @@ GCFEvent::TResult GPMController::connected(GCFEvent& e, GCFPortInterface& /*p*/) { LOFAR_LOG_TRACE(PML_STDOUT_LOGGER, ( "Property set with scope %d was deleted in the meanwhile", - scope.c_str())); - PAPropertieslinkedEvent e(0, PA_PROP_SET_GONE); - sendMyPropSetMsg(e, scope); + request.scope.c_str())); + PAPropertiesLinkedEvent response; + response.result = PA_PROP_SET_GONE; + response.scope = request.scope; + _propertyAgent.send(response); } break; } - case PA_UNLINKPROPERTIES: + case PA_UNLINK_PROPERTIES: { - pData = (char*)(&e) + sizeof(PAUnlinkpropertiesEvent); - unsigned int scopeDataLength = Utils::unpackString(pData, scope); - string unlinkListData(pData + scopeDataLength + Utils::SLEN_FIELD_SIZE, - e.length - sizeof(PALinkpropertiesEvent) - scopeDataLength - Utils::SLEN_FIELD_SIZE); + PAUnlinkPropertiesEvent request(e); + list<string> propertyList; + Utils::getPropertyListFromString(propertyList, request.propList); LOFAR_LOG_INFO(PML_STDOUT_LOGGER, ( "PA-REQ: Unlink properties %s on scope %s", - unlinkListData.c_str(), - scope.c_str())); - list<string> propertyList; - Utils::unpackPropertyList(pData + scopeDataLength, propertyList); - GCFMyPropertySet* pPropertySet = _propertySets[scope]; + request.propList.c_str(), + request.scope.c_str())); + GCFMyPropertySet* pPropertySet = _propertySets[request.scope]; if (pPropertySet) { pPropertySet->unlinkProperties(propertyList); @@ -360,56 +375,54 @@ GCFEvent::TResult GPMController::connected(GCFEvent& e, GCFPortInterface& /*p*/) { LOFAR_LOG_TRACE(PML_STDOUT_LOGGER, ( "Property set with scope %d was deleted in the meanwhile", - scope.c_str())); - PAPropertiesunlinkedEvent e(0, PA_PROP_SET_GONE); - sendMyPropSetMsg(e, scope); + request.scope.c_str())); + PAPropertiesUnlinkedEvent response; + response.result = PA_PROP_SET_GONE; + response.scope = request.scope; + _propertyAgent.send(response); } break; } - case PA_APCLOADED: + case PA_APC_LOADED: { - PAApcloadedEvent* pResponse = static_cast<PAApcloadedEvent*>(&e); - assert(pResponse); - result = (pResponse->result == PA_NO_ERROR ? GCF_NO_ERROR : GCF_APCLOAD_ERROR); - GCFApc* pApc = _apcList[pResponse->seqnr]; + PAApcLoadedEvent response(e); + result = (response.result == PA_NO_ERROR ? GCF_NO_ERROR : GCF_APCLOAD_ERROR); + GCFApc* pApc = _apcList[response.seqnr]; if (pApc) { - logResult(pResponse->result, *pApc); - _apcList.erase(pResponse->seqnr); + logResult(response.result, *pApc); + _apcList.erase(response.seqnr); pApc->loaded(result); } break; } - case PA_APCUNLOADED: + case PA_APC_UNLOADED: { - PAApcunloadedEvent* pResponse = static_cast<PAApcunloadedEvent*>(&e); - assert(pResponse); - result = (pResponse->result == PA_NO_ERROR ? GCF_NO_ERROR : GCF_APCUNLOAD_ERROR); - GCFApc* pApc = _apcList[pResponse->seqnr]; + PAApcUnloadedEvent response(e); + result = (response.result == PA_NO_ERROR ? GCF_NO_ERROR : GCF_APCUNLOAD_ERROR); + GCFApc* pApc = _apcList[response.seqnr]; if (pApc) { - logResult(pResponse->result, *pApc); - _apcList.erase(pResponse->seqnr); + logResult(response.result, *pApc); + _apcList.erase(response.seqnr); pApc->unloaded(result); } break; } - case PA_APCRELOADED: + case PA_APC_RELOADED: { - PAApcreloadedEvent* pResponse = static_cast<PAApcreloadedEvent*>(&e); - assert(pResponse); - result = (pResponse->result == PA_NO_ERROR ? GCF_NO_ERROR : GCF_APCRELOAD_ERROR); - GCFApc* pApc = _apcList[pResponse->seqnr]; + PAApcReloadedEvent response(e); + result = (response.result == PA_NO_ERROR ? GCF_NO_ERROR : GCF_APCRELOAD_ERROR); + GCFApc* pApc = _apcList[response.seqnr]; if (pApc) { - logResult(pResponse->result, *pApc); - _apcList.erase(pResponse->seqnr); + logResult(response.result, *pApc); + _apcList.erase(response.seqnr); pApc->reloaded(result); } break; } - case F_DISPATCHED_SIG: - case F_TIMER_SIG: + case F_TIMER: for (TPropertySets::iterator iter = _propertySets.begin(); iter != _propertySets.end(); ++iter) { diff --git a/MAC/GCF/_CoreComps/PML/src/GPM_Controller.h b/MAC/GCF/_CoreComps/PML/src/GPM_Controller.h index eecf9f4d4c2bfc20589241ef2b898964f4e64083..51bb0b59d15669c486689642eb869fd0a96a3be7 100644 --- a/MAC/GCF/_CoreComps/PML/src/GPM_Controller.h +++ b/MAC/GCF/_CoreComps/PML/src/GPM_Controller.h @@ -73,14 +73,7 @@ class GPMController : public GCFTask GCFEvent::TResult connected (GCFEvent& e, GCFPortInterface& p); private: // helper methods - void unpackPropertyList (char* pListData, - list<string>& propertyList); unsigned short getFreeSeqnrForApcRequest () const; - void sendAPCRequest (GCFEvent& e, - const GCFApc& apc); - - void sendMyPropSetMsg (GCFEvent& e, - const string& scope); private: // data members GCFPort _propertyAgent; @@ -91,7 +84,5 @@ class GPMController : public GCFTask private: // admin members unsigned int _counter; - static const unsigned int MAX_BUF_SIZE = 5000; - char _buffer[MAX_BUF_SIZE]; }; #endif diff --git a/MAC/GCF/_CoreComps/PML/src/Makefile.am b/MAC/GCF/_CoreComps/PML/src/Makefile.am index 535c840b036592337f0416c2693b9e1088ce04d2..e32aa27beae6e72e9bb3f6c08a7229a8fd3b6b05 100644 --- a/MAC/GCF/_CoreComps/PML/src/Makefile.am +++ b/MAC/GCF/_CoreComps/PML/src/Makefile.am @@ -1,3 +1,9 @@ +AUTOGEN = autogen +SUFFIXES = .ph +%.ph: $(top_srcdir)/CoreComps/PA/src/%.prot + $(AUTOGEN) -L $(top_srcdir)/../MACCommon/autogen $< && \ + chmod a+w $@ + include_HEADERS = DOCHDRS = $(include_HEADERS) \ @@ -18,7 +24,8 @@ libpml_la_SOURCES= $(DOCHDRS) \ GCF_Answer.cc \ GPM_Controller.cc \ GPM_PropertyService.cc \ - GCF_PropertyProxy.cc + GCF_PropertyProxy.cc \ + PA_Protocol.cc libpml_la_CPPFLAGS= -I$(top_srcdir)/GCFCommon/src \ -I$(top_srcdir)/CoreComps/TM/src \ @@ -26,5 +33,11 @@ libpml_la_CPPFLAGS= -I$(top_srcdir)/GCFCommon/src \ -I$(top_srcdir)/CoreComps/PA/src \ -I$(top_builddir)/CoreComps/PA/src +BUILT_SOURCES = \ + PA_Protocol.ph + +EXTRA_DIST = \ + PA_Protocol.ph + include $(lofar_sharedir)/Makefile.common diff --git a/MAC/GCF/_CoreComps/SAL/src/GCF_PVBool.cc b/MAC/GCF/_CoreComps/SAL/src/GCF_PVBool.cc index 58e5b34dd3a66e03878d67e46a66e38914b454ba..3e2ec18523992dc68413ecfb97e0462b5e322581 100644 --- a/MAC/GCF/_CoreComps/SAL/src/GCF_PVBool.cc +++ b/MAC/GCF/_CoreComps/SAL/src/GCF_PVBool.cc @@ -23,11 +23,11 @@ #include <GCF/GCF_PVBool.h> -unsigned int GCFPVBool::unpack(const char* valBuf, unsigned int maxBufSize) +unsigned int GCFPVBool::unpack(const char* valBuf) { unsigned int result(0); - unsigned int unpackedBytes = unpackBase(valBuf, maxBufSize); - if (maxBufSize >= unpackedBytes + 1) + unsigned int unpackedBytes = unpackBase(valBuf); + if (unpackedBytes > 0) { _value = (valBuf[unpackedBytes] == 1 ? true : false); result = unpackedBytes + 1; @@ -35,11 +35,11 @@ unsigned int GCFPVBool::unpack(const char* valBuf, unsigned int maxBufSize) return result; } -unsigned int GCFPVBool::pack(char* valBuf, unsigned int maxBufSize) const +unsigned int GCFPVBool::pack(char* valBuf) const { unsigned int result(0); - unsigned int packedBytes = packBase(valBuf, maxBufSize); - if (maxBufSize >= packedBytes + 1) + unsigned int packedBytes = packBase(valBuf); + if (packedBytes > 0) { valBuf[packedBytes] = (_value ? 1 : 0); result = packedBytes + 1; diff --git a/MAC/GCF/_CoreComps/SAL/src/GCF_PVChar.cc b/MAC/GCF/_CoreComps/SAL/src/GCF_PVChar.cc index d5446292a278e3cc29b1fe52ae6eeb80269a9971..bcdc1a7d1b5ce86c4f02026ee429b777fe7754f5 100644 --- a/MAC/GCF/_CoreComps/SAL/src/GCF_PVChar.cc +++ b/MAC/GCF/_CoreComps/SAL/src/GCF_PVChar.cc @@ -23,11 +23,11 @@ #include <GCF/GCF_PVChar.h> -unsigned int GCFPVChar::unpack(const char* valBuf, unsigned int maxBufSize) +unsigned int GCFPVChar::unpack(const char* valBuf) { unsigned int result(0); - unsigned int unpackedBytes = unpackBase(valBuf, maxBufSize); - if (maxBufSize >= unpackedBytes + 1) + unsigned int unpackedBytes = unpackBase(valBuf); + if (unpackedBytes > 0) { _value = valBuf[unpackedBytes]; result = unpackedBytes + 1; @@ -36,11 +36,11 @@ unsigned int GCFPVChar::unpack(const char* valBuf, unsigned int maxBufSize) } /** No descriptions */ -unsigned int GCFPVChar::pack(char* valBuf, unsigned int maxBufSize) const +unsigned int GCFPVChar::pack(char* valBuf) const { unsigned int result(0); - unsigned int packedBytes = packBase(valBuf, maxBufSize); - if (maxBufSize >= packedBytes + 1) + unsigned int packedBytes = packBase(valBuf); + if (packedBytes > 0) { valBuf[packedBytes] = _value; result = packedBytes + 1; diff --git a/MAC/GCF/_CoreComps/SAL/src/GCF_PVDouble.cc b/MAC/GCF/_CoreComps/SAL/src/GCF_PVDouble.cc index bf4d9ceb79189abdcc60ac2bc6716856eecb195d..8cbb68596009eb687c9ba0423ca171da924db9dd 100644 --- a/MAC/GCF/_CoreComps/SAL/src/GCF_PVDouble.cc +++ b/MAC/GCF/_CoreComps/SAL/src/GCF_PVDouble.cc @@ -23,11 +23,11 @@ #include <GCF/GCF_PVDouble.h> -unsigned int GCFPVDouble::unpack(const char* valBuf, unsigned int maxBufSize) +unsigned int GCFPVDouble::unpack(const char* valBuf) { unsigned int result(0); - unsigned int unpackedBytes = unpackBase(valBuf, maxBufSize); - if (maxBufSize >= unpackedBytes + sizeof(double)) + unsigned int unpackedBytes = unpackBase(valBuf); + if (unpackedBytes > 0) { memcpy((void *) &_value, valBuf + unpackedBytes, sizeof(double)); result = sizeof(double) + unpackedBytes; @@ -35,11 +35,11 @@ unsigned int GCFPVDouble::unpack(const char* valBuf, unsigned int maxBufSize) return result; } -unsigned int GCFPVDouble::pack(char* valBuf, unsigned int maxBufSize) const +unsigned int GCFPVDouble::pack(char* valBuf) const { unsigned int result(0); - unsigned int packedBytes = packBase(valBuf, maxBufSize); - if (maxBufSize >= packedBytes + sizeof(double)) + unsigned int packedBytes = packBase(valBuf); + if (packedBytes > 0) { memcpy(valBuf + packedBytes, (void *) &_value, sizeof(double)); result = sizeof(double) + packedBytes; diff --git a/MAC/GCF/_CoreComps/SAL/src/GCF_PVDynArr.cc b/MAC/GCF/_CoreComps/SAL/src/GCF_PVDynArr.cc index 3c9059eca01a92ef0cfc5e7e47fa9ea271777b69..a590794689a87c61899d2ae9948575a61944cb37 100644 --- a/MAC/GCF/_CoreComps/SAL/src/GCF_PVDynArr.cc +++ b/MAC/GCF/_CoreComps/SAL/src/GCF_PVDynArr.cc @@ -41,11 +41,11 @@ GCFPVDynArr::~GCFPVDynArr() cleanup(); } -unsigned int GCFPVDynArr::unpack(const char* valBuf, unsigned int maxBufSize) +unsigned int GCFPVDynArr::unpack(const char* valBuf) { unsigned int result(0); - unsigned int unpackedBytes = unpackBase(valBuf, maxBufSize); - if (maxBufSize >= unpackedBytes + sizeof(unsigned int)) + unsigned int unpackedBytes = unpackBase(valBuf); + if (unpackedBytes > 0) { cleanup(); unsigned int arraySize(0); @@ -57,7 +57,7 @@ unsigned int GCFPVDynArr::unpack(const char* valBuf, unsigned int maxBufSize) { pNewValue = GCFPValue::createMACTypeObject((TMACValueType) (getType() | LPT_DYNARR)); - curUnpackedBytes = pNewValue->unpack(valBuf + unpackedBytes, maxBufSize - unpackedBytes); + curUnpackedBytes = pNewValue->unpack(valBuf + unpackedBytes); if (curUnpackedBytes > 0) { unpackedBytes += curUnpackedBytes; @@ -74,11 +74,11 @@ unsigned int GCFPVDynArr::unpack(const char* valBuf, unsigned int maxBufSize) return result; } -unsigned int GCFPVDynArr::pack(char* valBuf, unsigned int maxBufSize) const +unsigned int GCFPVDynArr::pack(char* valBuf) const { unsigned int result(0); - unsigned int packedBytes = packBase(valBuf, maxBufSize); - if (maxBufSize >= packedBytes + sizeof(unsigned int)) + unsigned int packedBytes = packBase(valBuf); + if (packedBytes > 0) { unsigned int arraySize(_values.size()); memcpy(valBuf + packedBytes, (void *) &arraySize, sizeof(unsigned int)); @@ -87,7 +87,7 @@ unsigned int GCFPVDynArr::pack(char* valBuf, unsigned int maxBufSize) const for (GCFPValueArray::const_iterator iter = _values.begin(); iter != _values.end(); ++iter) { - curPackedBytes = (*iter)->pack(valBuf + packedBytes, maxBufSize - packedBytes); + curPackedBytes = (*iter)->pack(valBuf + packedBytes); packedBytes += curPackedBytes; if (curPackedBytes == 0) { @@ -100,6 +100,19 @@ unsigned int GCFPVDynArr::pack(char* valBuf, unsigned int maxBufSize) const return result; } +unsigned int GCFPVDynArr::getSize() const +{ + unsigned int totalSize(sizeof(unsigned int)); + + for (GCFPValueArray::const_iterator iter = _values.begin(); + iter != _values.end(); ++iter) + { + totalSize += (*iter)->getSize(); + } + totalSize += getBaseSize(); + return totalSize; +} + TGCFResult GCFPVDynArr::setValue(const string value) { TGCFResult result(GCF_NO_ERROR); diff --git a/MAC/GCF/_CoreComps/SAL/src/GCF_PVInteger.cc b/MAC/GCF/_CoreComps/SAL/src/GCF_PVInteger.cc index 25fe6df728d026f1f763c5e270ea6f4a02362f08..ded9ab292eba3511fcf5c74d51ac2cbc57c4836b 100644 --- a/MAC/GCF/_CoreComps/SAL/src/GCF_PVInteger.cc +++ b/MAC/GCF/_CoreComps/SAL/src/GCF_PVInteger.cc @@ -23,11 +23,11 @@ #include <GCF/GCF_PVInteger.h> -unsigned int GCFPVInteger::unpack(const char* valBuf, unsigned int maxBufSize) +unsigned int GCFPVInteger::unpack(const char* valBuf) { unsigned int result(0); - unsigned int unpackedBytes = unpackBase(valBuf, maxBufSize); - if (maxBufSize >= unpackedBytes + sizeof(int)) + unsigned int unpackedBytes = unpackBase(valBuf); + if (unpackedBytes > 0) { memcpy((void*) &_value, valBuf + unpackedBytes, sizeof(int)); result = sizeof(int) + unpackedBytes; @@ -35,11 +35,11 @@ unsigned int GCFPVInteger::unpack(const char* valBuf, unsigned int maxBufSize) return result; } -unsigned int GCFPVInteger::pack(char* valBuf, unsigned int maxBufSize) const +unsigned int GCFPVInteger::pack(char* valBuf) const { unsigned int result(0); - unsigned int packedBytes = packBase(valBuf, maxBufSize); - if (maxBufSize >= packedBytes + sizeof(int)) + unsigned int packedBytes = packBase(valBuf); + if (packedBytes > 0) { memcpy(valBuf + packedBytes, (void*) &_value, sizeof(int)); result = sizeof(int) + packedBytes; diff --git a/MAC/GCF/_CoreComps/SAL/src/GCF_PVString.cc b/MAC/GCF/_CoreComps/SAL/src/GCF_PVString.cc index c3eb1fe385cad8b18dd376ee7452e83d3f7263d1..d7f1438875ac4a1ddf420cc1ceebf96d3ee0837b 100644 --- a/MAC/GCF/_CoreComps/SAL/src/GCF_PVString.cc +++ b/MAC/GCF/_CoreComps/SAL/src/GCF_PVString.cc @@ -23,29 +23,26 @@ #include <GCF/GCF_PVString.h> -unsigned int GCFPVString::unpack(const char* valBuf, unsigned int maxBufSize) +unsigned int GCFPVString::unpack(const char* valBuf) { unsigned int result(0); - unsigned int unpackedBytes = unpackBase(valBuf, maxBufSize); - if (maxBufSize >= unpackedBytes + sizeof(unsigned int)) + unsigned int unpackedBytes = unpackBase(valBuf); + if (unpackedBytes > 0) { unsigned int stringLength(0); memcpy((void *) &stringLength, valBuf + unpackedBytes, sizeof(unsigned int)); unpackedBytes += sizeof(unsigned int); - if (maxBufSize >= unpackedBytes + stringLength) - { - _value.assign(valBuf + unpackedBytes, stringLength); - result = unpackedBytes + stringLength; - } + _value.assign(valBuf + unpackedBytes, stringLength); + result = unpackedBytes + stringLength; } return result; } -unsigned int GCFPVString::pack(char* valBuf, unsigned int maxBufSize) const +unsigned int GCFPVString::pack(char* valBuf) const { unsigned int result(0); - unsigned int packedBytes = packBase(valBuf, maxBufSize); - if (maxBufSize >= packedBytes + sizeof(unsigned int) + _value.length()) + unsigned int packedBytes = packBase(valBuf); + if (packedBytes > 0) { unsigned int stringLength(_value.length()); memcpy(valBuf + packedBytes, (void *) &stringLength, sizeof(unsigned int)); diff --git a/MAC/GCF/_CoreComps/SAL/src/GCF_PVUnsigned.cc b/MAC/GCF/_CoreComps/SAL/src/GCF_PVUnsigned.cc index b137c5b5f9e9512c4017b8236c07d1cdb14caa80..bd8d1bc26ab7594533e2035f5166b6c126cb793a 100644 --- a/MAC/GCF/_CoreComps/SAL/src/GCF_PVUnsigned.cc +++ b/MAC/GCF/_CoreComps/SAL/src/GCF_PVUnsigned.cc @@ -23,11 +23,11 @@ #include <GCF/GCF_PVUnsigned.h> -unsigned int GCFPVUnsigned::unpack(const char* valBuf, unsigned int maxBufSize) +unsigned int GCFPVUnsigned::unpack(const char* valBuf) { unsigned int result(0); - unsigned int unpackedBytes = unpackBase(valBuf, maxBufSize); - if (maxBufSize >= unpackedBytes + sizeof(unsigned int)) + unsigned int unpackedBytes = unpackBase(valBuf); + if (unpackedBytes > 0) { memcpy((void*) &_value, valBuf + unpackedBytes, sizeof(unsigned int)); result = sizeof(unsigned int) + unpackedBytes; @@ -35,11 +35,11 @@ unsigned int GCFPVUnsigned::unpack(const char* valBuf, unsigned int maxBufSize) return result; } -unsigned int GCFPVUnsigned::pack(char* valBuf, unsigned int maxBufSize) const +unsigned int GCFPVUnsigned::pack(char* valBuf) const { unsigned int result(0); - unsigned int packedBytes = packBase(valBuf, maxBufSize); - if (maxBufSize >= packedBytes + sizeof(unsigned int)) + unsigned int packedBytes = packBase(valBuf); + if (packedBytes > 0) { memcpy(valBuf + packedBytes, (void*) &_value, sizeof(unsigned int)); result = sizeof(unsigned int) + packedBytes; diff --git a/MAC/GCF/_CoreComps/SAL/src/GCF_PValue.cc b/MAC/GCF/_CoreComps/SAL/src/GCF_PValue.cc index 51466eefa1a73c78bdb23a507e8d91c17ea998f7..3ce4a1acb70354a3ba5df28fe6fe1f77b5f99376 100644 --- a/MAC/GCF/_CoreComps/SAL/src/GCF_PValue.cc +++ b/MAC/GCF/_CoreComps/SAL/src/GCF_PValue.cc @@ -55,12 +55,12 @@ GCFPValue* GCFPValue::createMACTypeObject(TMACValueType type) case LPT_STRING: pResult = new GCFPVString(); break; -/* case LPT_BIT32: - pResult = new GCFPVBit32(); - break; - case LPT_REF: +/* case LPT_REF: pResult = new GCFPVRef(); break; + case LPT_BIT32: + pResult = new GCFPVBit32(); + break; case LPT_BLOB: pResult = new GCFPVBlob(); break; @@ -85,14 +85,13 @@ GCFPValue* GCFPValue::createMACTypeObject(TMACValueType type) return pResult; } -GCFPValue* GCFPValue::unpackValue(const char* valBuf, unsigned int maxBufSize) +GCFPValue* GCFPValue::unpackValue(const char* valBuf) { - assert(maxBufSize > 1); GCFPValue* pValue = createMACTypeObject((TMACValueType) *valBuf); if (pValue) { - unsigned int readLength = pValue->unpack(valBuf, maxBufSize); - if (maxBufSize != readLength) + unsigned int readLength = pValue->unpack(valBuf); + if (readLength == 0) { delete pValue; pValue = 0; @@ -101,28 +100,19 @@ GCFPValue* GCFPValue::unpackValue(const char* valBuf, unsigned int maxBufSize) return pValue; } -unsigned int GCFPValue::unpackBase(const char* valBuf, unsigned int maxBufSize) +unsigned int GCFPValue::unpackBase(const char* valBuf) { - if (maxBufSize >= 1) - { - assert(_type == (TMACValueType) *valBuf); - return 1; - } - else - { - return 0; - } + assert(_type == (TMACValueType) *valBuf); + // the type was already set, because it was set on construction of this class + // at this moment only the type will be unpacked, later maybe a timestamp can + // be assigned to a value. + return 1; } -unsigned int GCFPValue::packBase(char* valBuf, unsigned int maxBufSize) const +unsigned int GCFPValue::packBase(char* valBuf) const { - if (maxBufSize >= 1) - { - valBuf[0] = _type; - return 1; - } - else - { - return 0; - } + valBuf[0] = _type; + // at this moment only the type will be packed, later maybe a timestamp can + // be assigned to a value. + return 1; } diff --git a/MAC/GCF/_CoreComps/SAL/src/GSA_SCADAHandler.cc b/MAC/GCF/_CoreComps/SAL/src/GSA_SCADAHandler.cc index 0843010b676ac99bcff97725b6147d0bbccd6f60..7bdf7e2a7faa9b2ff30ae19f547123cff9a661b2 100644 --- a/MAC/GCF/_CoreComps/SAL/src/GSA_SCADAHandler.cc +++ b/MAC/GCF/_CoreComps/SAL/src/GSA_SCADAHandler.cc @@ -55,30 +55,9 @@ void GSASCADAHandler::stop() _running = false; } -void GSASCADAHandler::registerTask(GCFTask& task) -{ - _registerdTasks.push_back(&task); -} - -void GSASCADAHandler::unregisterTask(GCFTask& task) -{ - _registerdTasks.remove(&task); -} - void GSASCADAHandler::workProc() { _pvssApi.workProc(); - list<GCFTask*> tempRegisteredTasks(_registerdTasks.begin(), _registerdTasks.end()); - GCFTask* pTask; - for (list<GCFTask*>::iterator iter = tempRegisteredTasks.begin(); - iter != tempRegisteredTasks.end(); ++iter) - { - GCFEvent e(F_DISPATCHED_SIG); - GCFDummyPort p(pTask, "SCADA", 0); - pTask = *iter; - assert(pTask); - pTask->dispatch(e, p); - } } TSAResult GSASCADAHandler::isOperational() diff --git a/MAC/GCF/_CoreComps/SAL/src/GSA_SCADAHandler.h b/MAC/GCF/_CoreComps/SAL/src/GSA_SCADAHandler.h index 6103c00c86476375c70499cd43daccbde402aa12..2d2c3dd5bda70e59efd166cc3e9d03d6219b089c 100644 --- a/MAC/GCF/_CoreComps/SAL/src/GSA_SCADAHandler.h +++ b/MAC/GCF/_CoreComps/SAL/src/GSA_SCADAHandler.h @@ -42,8 +42,6 @@ class GSASCADAHandler : GCFHandler void workProc (); void stop (); TSAResult isOperational (); - void registerTask (GCFTask& task); - void unregisterTask (GCFTask& task); private: GSASCADAHandler (); @@ -57,6 +55,5 @@ class GSASCADAHandler : GCFHandler GSAPvssApi _pvssApi; bool _running; - list<GCFTask*> _registerdTasks; }; #endif diff --git a/MAC/GCF/_CoreComps/SAL/test/Echo.cc b/MAC/GCF/_CoreComps/SAL/test/Echo.cc index 374f0f47888d1e9522510ebf7997456d0fed178a..38c927f80efc2fd496b05c0afbf41c1d0894f3cf 100644 --- a/MAC/GCF/_CoreComps/SAL/test/Echo.cc +++ b/MAC/GCF/_CoreComps/SAL/test/Echo.cc @@ -24,7 +24,6 @@ #include "Echo.h" #include <GCF/GCF_PVBool.h> #include <GCF/GCF_PVChar.h> -#define DECLARE_SIGNAL_NAMES #include "Echo_Protocol.ph" @@ -43,24 +42,24 @@ GCFEvent::TResult Echo::initial(GCFEvent& e, GCFPortInterface& /*p*/) switch (e.signal) { - case F_INIT_SIG: + case F_INIT: { break; } - case F_ENTRY_SIG: + case F_ENTRY: server.open(); break; - case F_CONNECTED_SIG: + case F_CONNECTED: { TRAN(Echo::connected); break; } - case F_DISCONNECTED_SIG: + case F_DISCONNECTED: server.setTimer(1.0); // try again after 1 second break; - case F_TIMER_SIG: + case F_TIMER: server.open(); // try again break; @@ -79,7 +78,7 @@ GCFEvent::TResult Echo::connected(GCFEvent& e, GCFPortInterface& /*p*/) switch (e.signal) { - case F_DISCONNECTED_SIG: + case F_DISCONNECTED: service.deleteProp(propName); service.deleteProp(propName + "_test"); cout << "Lost connection to client" << endl; @@ -88,9 +87,9 @@ GCFEvent::TResult Echo::connected(GCFEvent& e, GCFPortInterface& /*p*/) case ECHO_PING: { - EchoPingEvent* ping = static_cast<EchoPingEvent*>(&e); + EchoPingEvent ping(e); - switch (ping->seqnr % 13) + switch (ping.seqnr % 13) { case 0: service.createProp(propName, GCFPValue::LPT_BOOL); @@ -157,13 +156,14 @@ GCFEvent::TResult Echo::connected(GCFEvent& e, GCFPortInterface& /*p*/) } - cout << "PING received (seqnr=" << ping->seqnr << ")" << endl; + cout << "PING received (seqnr=" << ping.seqnr << ")" << endl; timeval echo_time; gettimeofday(&echo_time, 0); - EchoEchoEvent echo(ping->seqnr, - ping->ping_time, - echo_time); + EchoEchoEvent echo; + echo.seqnr = ping.seqnr; + echo.ping_time = ping.ping_time; + echo.echo_time = echo_time; server.send(echo); diff --git a/MAC/GCF/_CoreComps/SAL/test/Echo_Protocol.prot b/MAC/GCF/_CoreComps/SAL/test/Echo_Protocol.prot index 51abac0129d4184fe0fbde024682a0fde1c9d8cb..8bb47fbd8f896d266f0319b81d07a071e5f1e7e5 100644 --- a/MAC/GCF/_CoreComps/SAL/test/Echo_Protocol.prot +++ b/MAC/GCF/_CoreComps/SAL/test/Echo_Protocol.prot @@ -5,17 +5,12 @@ 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>'; -prelude = << PRELUDE_END -enum { - ECHO_PROTOCOL = F_APL_PROTOCOL -}; -PRELUDE_END; - // // An "event" has a "signal" and a "dir" (direction) // and zero or more "param"s. diff --git a/MAC/GCF/_CoreComps/SAL/test/Makefile.am b/MAC/GCF/_CoreComps/SAL/test/Makefile.am index 985b887b75a8da38824521359ce39602fa4b2155..2393fc435b419d09521940ed446898c9f3f717be 100644 --- a/MAC/GCF/_CoreComps/SAL/test/Makefile.am +++ b/MAC/GCF/_CoreComps/SAL/test/Makefile.am @@ -6,7 +6,7 @@ check_PROGRAMS = echoapp ping TESTS = #echoapp ping -echoapp_SOURCES = Echo.cc Service.cc +echoapp_SOURCES = Echo.cc Service.cc Echo_Protocol.cc echoapp_LDADD = ../src/libsal.la \ $(top_builddir)/CoreComps/TM/src/libtm.la \ $(top_builddir)/GCFCommon/src/libgcfcommon.la @@ -15,7 +15,7 @@ echoapp_DEPENDENCIES = ../src/libsal.la $(LOFAR_DEPEND) \ $(top_builddir)/CoreComps/TM/src/libtm.la echoapp_CPPFLAGS= $(cppflags) -ping_SOURCES = Ping.cc +ping_SOURCES = Ping.cc Echo_Protocol.cc ping_LDADD = \ $(top_builddir)/CoreComps/TM/src/libtm.la \ $(top_builddir)/GCFCommon/src/libgcfcommon.la @@ -27,7 +27,7 @@ ping_CPPFLAGS= $(cppflags) AUTOGEN = autogen SUFFIXES = .ph %.ph: %.prot - $(AUTOGEN) -L $(top_srcdir)/GCFCommon/autogen $< && \ + $(AUTOGEN) -L $(top_srcdir)/../MACCommon/autogen $< && \ chmod a+w $@ BUILT_SOURCES = \ diff --git a/MAC/GCF/_CoreComps/SAL/test/Ping.cc b/MAC/GCF/_CoreComps/SAL/test/Ping.cc index f491ba89b3008590cfde11a08e74c8ecc8bbee0d..eb22c3672ec23d7e76e2f3c4dae12bafbf8c419a 100644 --- a/MAC/GCF/_CoreComps/SAL/test/Ping.cc +++ b/MAC/GCF/_CoreComps/SAL/test/Ping.cc @@ -23,7 +23,6 @@ // #include "Ping.h" -#define DECLARE_SIGNAL_NAMES #include "Echo_Protocol.ph" @@ -59,14 +58,14 @@ GCFEvent::TResult Ping::initial(GCFEvent& e, GCFPortInterface& /*port*/) switch (e.signal) { - case F_INIT_SIG: + case F_INIT: break; - case F_ENTRY_SIG: + case F_ENTRY: client.open(); break; - case F_CONNECTED_SIG: + case F_CONNECTED: // start ping_timer // - after 1 second @@ -76,11 +75,11 @@ GCFEvent::TResult Ping::initial(GCFEvent& e, GCFPortInterface& /*port*/) TRAN(Ping::connected); break; - case F_DISCONNECTED_SIG: + case F_DISCONNECTED: (void)client.setTimer(1.0); // try connect again after 1 second break; - case F_TIMER_SIG: + case F_TIMER: client.open(); break; @@ -99,41 +98,27 @@ GCFEvent::TResult Ping::connected(GCFEvent& e, GCFPortInterface& /*p*/) static int seqnr = 0; switch (e.signal) + { + case F_TIMER: { - case F_TIMER_SIG: - { -#ifndef HUMAN_PORT - - timeval ping_time; - - // create PingEvent - gettimeofday(&ping_time, 0); - EchoPingEvent ping(seqnr++, - ping_time); - - // send the event - client.send(ping); - - cout << "PING sent (seqnr=" << ping.seqnr << ")" << endl; - -#else - - gettimeofday(&g_ping_time, 0); - GCFEvent ping(ECHO_PING); - - // send the event - client.send(ping); - - cout << "PING sent" << endl; - -#endif - - TRAN(Ping::awaiting_echo); // wait for the echo - } + 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_SIG: + } + case F_DISCONNECTED: //(void)client.open(); // try to reopen (void)client.cancelTimer(ping_timer); @@ -155,26 +140,26 @@ GCFEvent::TResult Ping::awaiting_echo(GCFEvent& e, GCFPortInterface& /*p*/) GCFEvent::TResult status = GCFEvent::HANDLED; switch (e.signal) - { - case F_TIMER_SIG: + { + case F_TIMER: cout << "Missed echo dead-line." << endl; break; case ECHO_ECHO: - { - timeval echo_time; - gettimeofday(&echo_time, 0); - - EchoEchoEvent* echo = static_cast<EchoEchoEvent*>(&e); - - cout << "ECHO received (seqnr=" << echo->seqnr << "): elapsed = " - << time_elapsed(&(echo->ping_time), &echo_time) << " sec."<< endl; - - TRAN(Ping::connected); - } + { + 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_SIG: + case F_DISCONNECTED: (void)client.cancelTimer(ping_timer); TRAN(Ping::initial); break; diff --git a/MAC/GCF/_CoreComps/TM/src/GCF_Event.cc b/MAC/GCF/_CoreComps/TM/src/GCF_Event.cc new file mode 100644 index 0000000000000000000000000000000000000000..ef9f808bc6515fe0a68857e4fe269f54f65383a2 --- /dev/null +++ b/MAC/GCF/_CoreComps/TM/src/GCF_Event.cc @@ -0,0 +1,89 @@ +//# 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 <GCF/GCF_Event.h> + +using namespace std; + +GCFEvent::~GCFEvent() +{ + if (_buffer) delete [] _buffer; +} + +void* GCFEvent::pack(unsigned int& packsize) +{ + memcpy(_buffer, &signal, sizeof(signal)); + memcpy(_buffer + sizeof(signal), &length, sizeof(length)); + packsize = sizeof(signal) + sizeof(length); + return _buffer; +} + +void GCFEvent::resizeBuf(unsigned int requiredSize) +{ + 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, unsigned int& offset, unsigned int& memberDim, unsigned int sizeofMemberType) +{ + void* seqPtr(0); + memcpy(&memberDim, data + offset, sizeof(unsigned int)); + seqPtr = data + offset + sizeof(unsigned int); + offset += sizeof(unsigned int) + memberDim * sizeofMemberType; + return seqPtr; +} + +unsigned int GCFEvent::packMember(unsigned int offset, const void* member, unsigned int memberDim, unsigned int sizeofMemberType) +{ + assert(_buffer); + memcpy(_buffer + offset, &memberDim, sizeof(memberDim)); + offset += sizeof(memberDim); + memcpy(_buffer + offset, member, memberDim * sizeofMemberType); + return (memberDim * sizeofMemberType) + sizeof(memberDim); +} + +unsigned int GCFEvent::unpackString(string& value, char* buffer) +{ + unsigned int stringLength(0); + memcpy((void *) &stringLength, buffer, + sizeof(unsigned int)); + value.clear(); + value.append(buffer + sizeof(unsigned int), stringLength); + return stringLength + sizeof(unsigned int); +} + +unsigned int GCFEvent::packString(char* buffer, const string& value) +{ + unsigned int neededBufLength = value.size() + sizeof(unsigned int); + unsigned int stringLength(value.size()); + memcpy(buffer, (void *) &stringLength, + sizeof(unsigned int)); + memcpy(buffer + sizeof(unsigned int), (void *) value.c_str(), value.size()); + return neededBufLength; +} diff --git a/MAC/GCF/_CoreComps/TM/src/GCF_Fsm.cc b/MAC/GCF/_CoreComps/TM/src/GCF_Fsm.cc index 984f119962228b8e823d99c47ae25040575bdf46..c885c8c8b8eb59f0647fb1676540b49c0af81a9f 100644 --- a/MAC/GCF/_CoreComps/TM/src/GCF_Fsm.cc +++ b/MAC/GCF/_CoreComps/TM/src/GCF_Fsm.cc @@ -28,13 +28,13 @@ GCFDummyPort GCFFsm::_gcfPort(0, "GCFFSM", F_FSM_PROTOCOL); void GCFFsm::initFsm() { GCFEvent e; - e.signal = F_ENTRY_SIG; + e.signal = F_ENTRY; (void)(this->*_state)(e, _gcfPort); // entry signal - e.signal = F_INIT_SIG; + e.signal = F_INIT; if (GCFEvent::HANDLED != (this->*_state)(e, _gcfPort)) // initial transition { LOFAR_LOG_FATAL(TM_STDOUT_LOGGER, ( - "Fsm::init: initial transition F_SIGNAL(F_FSM_PROTOCOL, F_INIT_SIG) not handled.")); + "Fsm::init: initial transition F_SIGNAL(F_FSM_PROTOCOL, F_INIT) not handled.")); exit(1); // EXIT } } @@ -42,7 +42,7 @@ void GCFFsm::initFsm() void GCFFsm::tran(State target, const char* from, const char* to) { GCFEvent e; - e.signal = F_EXIT_SIG; + e.signal = F_EXIT; (void)(this->*_state)(e, _gcfPort); // exit signal LOFAR_LOG_TRACE(TM_STDOUT_LOGGER, ( @@ -52,6 +52,6 @@ void GCFFsm::tran(State target, const char* from, const char* to) _state = target; // state transition - e.signal = F_ENTRY_SIG; + e.signal = F_ENTRY; (void)(this->*_state)(e, _gcfPort); // entry signal } diff --git a/MAC/GCF/_CoreComps/TM/src/GCF_TMProtocols.cc b/MAC/GCF/_CoreComps/TM/src/GCF_TMProtocols.cc index 1915f084abea3390ecd44fda966784ca0b1a4561..796a710da5496a200c769a887c43151d95f99a1e 100644 --- a/MAC/GCF/_CoreComps/TM/src/GCF_TMProtocols.cc +++ b/MAC/GCF/_CoreComps/TM/src/GCF_TMProtocols.cc @@ -28,9 +28,9 @@ const char* F_FSM_PROTOCOL_names[] = { "F_FSM_PROTOCOL: invalid signal", - "F_ENTRY_SIG (IN)", - "F_EXIT_SIG (IN)", - "F_INIT_SIG (IN)", + "F_ENTRY (IN)", + "F_EXIT (IN)", + "F_INIT (IN)", }; /** @@ -39,15 +39,15 @@ const char* F_FSM_PROTOCOL_names[] = const char* F_PORT_PROTOCOL_names[] = { "F_PORT_PROTOCOL: invalid signal", - "F_CONNECT_SIG (OUT)", - "F_CONNECTED_SIG (IN)", - "F_DISCONNECTED_SIG (IN)", - "F_CLOSED_SIG (IN)", - "F_TIMER_SIG (IN)", - "F_DATAIN_SIG (IN)", - "F_DATAOUT_SIG (IN)", - "F_RAW_SIG (IN_OUT)", - "F_ACCEPT_REQ_SIG(IN)", - "F_DISPACHTED_SIG(IN)", + "F_CONNECT (OUT)", + "F_CONNECTED (IN)", + "F_DISCONNECTED (IN)", + "F_CLOSED (IN)", + "F_TIMER (IN)", + "F_DATAIN (IN)", + "F_DATAOUT (IN)", + "F_RAW_DATA (IN_OUT)", + "F_ACCEPT_REQ (IN)", + "F_DISPACHTED (IN)", }; diff --git a/MAC/GCF/_CoreComps/TM/src/Makefile.am b/MAC/GCF/_CoreComps/TM/src/Makefile.am index a6411f44a39064b8700e3dc19a5c46e9ee591479..d7a3c41b722d9998f5570ed4aa89a34444425dc5 100644 --- a/MAC/GCF/_CoreComps/TM/src/Makefile.am +++ b/MAC/GCF/_CoreComps/TM/src/Makefile.am @@ -19,6 +19,7 @@ libtm_la_SOURCES= \ GCF_Fsm.cc \ GCF_TMProtocols.cc \ GCF_Task.cc \ + GCF_Event.cc \ PortInterface/GCF_Port.cc \ PortInterface/GCF_RawPort.cc \ PortInterface/GCF_PeerAddr.cc \ diff --git a/MAC/GCF/_CoreComps/TM/src/PortInterface/GCF_Port.cc b/MAC/GCF/_CoreComps/TM/src/PortInterface/GCF_Port.cc index ba2d30e6e328e110bd72424ecdfe2180ba924976..1c05880cc0ebfc5a3161dd836eb90f27294e83e8 100644 --- a/MAC/GCF/_CoreComps/TM/src/PortInterface/GCF_Port.cc +++ b/MAC/GCF/_CoreComps/TM/src/PortInterface/GCF_Port.cc @@ -194,9 +194,9 @@ int GCFPort::close() /** * ::send */ -ssize_t GCFPort::send(const GCFEvent& e, void* buf, size_t count) +ssize_t GCFPort::send(GCFEvent& e) { - if (F_RAW_SIG != e.signal) + if (F_RAW_DATA != e.signal) { LOFAR_LOG_TRACE(TM_STDOUT_LOGGER, ( "Sending event '%s' for task %s on port %s", @@ -236,76 +236,9 @@ ssize_t GCFPort::send(const GCFEvent& e, void* buf, size_t count) getTask()->evtstr(e), _name.c_str())); return -1; // RETURN } - - iovec buffers[2]; - buffers[0].iov_base = (void*)&e; - buffers[0].iov_len = e.length - count; - buffers[1].iov_base = buf; - buffers[1].iov_len = count; - - return _pSlave->sendv(GCFEvent(F_RAW_SIG), buffers, (count > 0 ? 2 : 1)); - -} - -/** - * ::sendv - */ -ssize_t GCFPort::sendv(const GCFEvent& e, const iovec buffers[], int n) -{ - if (F_RAW_SIG != e.signal) - { - LOFAR_LOG_TRACE(TM_STDOUT_LOGGER, ( - "Sending event '%s' for task %s on port %s", - getTask()->evtstr(e), - getTask()->getName().c_str(), - getName().c_str())); - } - - if (SPP == getType()) - { - if (F_EVT_INOUT(e) & F_IN) - { - LOFAR_LOG_ERROR(TM_STDOUT_LOGGER, ( - "Trying to send IN event '%s' on SPP " - "port '%s'; discarding this event.", - getTask()->evtstr(e), _name.c_str())); - return -1; // RETURN - } - } - else if (SAP == getType()) - { - if (F_EVT_INOUT(e) & F_OUT) - { - LOFAR_LOG_ERROR(TM_STDOUT_LOGGER, ( - "Trying to send OUT event '%s' on SAP " - "port '%s'; discarding this event.", - getTask()->evtstr(e), _name.c_str())); - return -1; // RETURN - } - } - else if (MSPP == _type) - { - LOFAR_LOG_ERROR(TM_STDOUT_LOGGER, ( - "Trying to send event '%s' by means of the portprovider: %s (MSPP). " - "Not supported yet", - getTask()->evtstr(e), _name.c_str())); - return -1; // RETURN - } - - iovec* newbufs = new iovec[n+1]; - newbufs[0].iov_base = (void*)&e; - newbufs[0].iov_len = e.length; - for (int i = 1; i < n+1; i++) - { - newbufs[i].iov_base = buffers[i-1].iov_base; - newbufs[i].iov_len = buffers[i-1].iov_len; - } - - int status = _pSlave->sendv(GCFEvent(F_RAW_SIG), newbufs, n+1); - delete [] newbufs; + return _pSlave->send(e); - return status; } /** @@ -317,15 +250,6 @@ ssize_t GCFPort::recv(void* buf, size_t count) return _pSlave->recv(buf, count); } -/** - * ::recvv - */ -ssize_t GCFPort::recvv(iovec buffers[], int n) -{ - if (!_pSlave) return -1; - return _pSlave->recvv(buffers, n); -} - /** * ::setTimer */ diff --git a/MAC/GCF/_CoreComps/TM/src/PortInterface/GCF_RawPort.cc b/MAC/GCF/_CoreComps/TM/src/PortInterface/GCF_RawPort.cc index b5d6d29c026d1229225ac5dba9df8d35935ffb15..533fa655351686c57f60d517925a770e0ce3c1fa 100644 --- a/MAC/GCF/_CoreComps/TM/src/PortInterface/GCF_RawPort.cc +++ b/MAC/GCF/_CoreComps/TM/src/PortInterface/GCF_RawPort.cc @@ -30,9 +30,9 @@ #include <GTM_Defines.h> #include <Timer/GTM_TimerHandler.h> -static GCFEvent disconnected_event(F_DISCONNECTED_SIG); -static GCFEvent connected_event (F_CONNECTED_SIG); -static GCFEvent closed_event (F_CLOSED_SIG); +static GCFEvent disconnected_event(F_DISCONNECTED); +static GCFEvent connected_event (F_CONNECTED); +static GCFEvent closed_event (F_CLOSED); GCFRawPort::GCFRawPort(GCFTask& task, string& name, @@ -74,33 +74,35 @@ GCFEvent::TResult GCFRawPort::dispatch(GCFEvent& event) { GCFEvent::TResult status = GCFEvent::NOT_HANDLED; assert(_pTask); - if ((F_DATAIN_SIG != event.signal) && - (F_DATAOUT_SIG != event.signal) && + if ((F_DATAIN != event.signal) && + (F_DATAOUT != event.signal) && (F_EVT_PROTOCOL(event) != F_FSM_PROTOCOL) && (F_EVT_PROTOCOL(event) != F_PORT_PROTOCOL)) { LOFAR_LOG_INFO(TM_STDOUT_LOGGER, ( "%s receives '%s' on port '%s'", - _pTask->getName().c_str(), _pTask->evtstr(event), _name.c_str())); + _pTask->getName().c_str(), + _pTask->evtstr(event), + (isSlave() ? _pMaster->getName().c_str() : _name.c_str()))); } switch (event.signal) { - case F_CONNECTED_SIG: + case F_CONNECTED: LOFAR_LOG_INFO(TM_STDOUT_LOGGER, ( "port '%s' of task %s is connected!", _name.c_str(), _pTask->getName().c_str())); _isConnected = true; break; - case F_DISCONNECTED_SIG: - case F_CLOSED_SIG: + case F_DISCONNECTED: + case F_CLOSED: LOFAR_LOG_INFO(TM_STDOUT_LOGGER, ( "port '%s' of task %s is %s!", _name.c_str(), _pTask->getName().c_str(), - (event.signal == F_CLOSED_SIG ? "closed" : "disconnected"))); + (event.signal == F_CLOSED ? "closed" : "disconnected"))); _isConnected = false; break; - case F_TIMER_SIG: + case F_TIMER: { GCFTimerEvent* pTE = static_cast<GCFTimerEvent*>(&event); if (&disconnected_event == pTE->arg || @@ -111,7 +113,7 @@ GCFEvent::TResult GCFRawPort::dispatch(GCFEvent& event) } break; } - case F_DATAIN_SIG: + case F_DATAIN: { if (!isTransportRawData()) { @@ -278,31 +280,34 @@ void GCFRawPort::schedule_connected() GCFEvent::TResult GCFRawPort::recvEvent() { GCFEvent::TResult status = GCFEvent::NOT_HANDLED; + GCFEvent e; - ssize_t bytesRead = recv(&e, sizeof(e)); - assert(bytesRead == sizeof(e)); + ssize_t bytesRead = recv(&e.signal, sizeof(e.signal)); + assert(bytesRead == sizeof(e.signal)); + bytesRead = recv(&e.length, sizeof(e.length)); + assert(bytesRead == sizeof(e.length)); - if (e.length - sizeof(e) > 0) + if (e.length > 0) { GCFEvent* full_event = 0; - char* event_buf = 0; - event_buf = (char*)malloc(e.length); + char* event_buf = new char[sizeof(e) + e.length]; full_event = (GCFEvent*)event_buf; memcpy(event_buf, &e, sizeof(e)); - - // recv the rest of the message (payload) - ssize_t payloadLength = e.length - sizeof(e); - + + event_buf += sizeof(e); + bytesRead = 0; + ssize_t payloadLength = e.length; do { bytesRead += recv(event_buf + bytesRead, payloadLength); payloadLength = e.length - bytesRead; } while (payloadLength > 0); - + status = dispatch(*full_event); - free(event_buf); + event_buf -= sizeof(e); + delete [] event_buf; } else { diff --git a/MAC/GCF/_CoreComps/TM/src/Socket/GCF_ETHRawPort.cc b/MAC/GCF/_CoreComps/TM/src/Socket/GCF_ETHRawPort.cc index 67cad304ac09955ed0afe274c674c97dda1c6171..1edbab3bf642ffce912030bb7f9417357a9b08da 100644 --- a/MAC/GCF/_CoreComps/TM/src/Socket/GCF_ETHRawPort.cc +++ b/MAC/GCF/_CoreComps/TM/src/Socket/GCF_ETHRawPort.cc @@ -110,68 +110,27 @@ int GCFETHRawPort::open() return retval; } -ssize_t GCFETHRawPort::send(const GCFEvent& e, void* buf, size_t count) +ssize_t GCFETHRawPort::send(GCFEvent& e) { size_t written = 0; - if (MSPP == getType()) - return 0; // no messages can be send by this type of port - - iovec* newbufs(0); - if (F_RAW_SIG != e.signal) - { - iovec buffers[2]; - buffers[0].iov_base = (void*)&e; - buffers[0].iov_len = e.length - count; - buffers[1].iov_base = buf; - buffers[1].iov_len = count; - newbufs = buffers; - sendv(GCFEvent(F_RAW_SIG), buffers, (count > 0 ? 2 : 1)); - } - else - { - if ((written = _pSocket->send(buf, count)) != count) - { - LOFAR_LOG_DEBUG(TM_STDOUT_LOGGER, ( - "truncated send: %s", - strerror(errno))); - - schedule_disconnected(); - - written = 0; - } - } - - return written; -} + assert(_pSocket); -ssize_t GCFETHRawPort::sendv(const GCFEvent& e, const iovec buffers[], int n) -{ - size_t written = 0; - size_t count = 0; if (MSPP == getType()) return 0; // no messages can be send by this type of port - - if (F_RAW_SIG != e.signal) - { - count = e.length; - if ((written = _pSocket->send((void*)&e, e.length)) != count) - { - LOFAR_LOG_DEBUG(TM_STDOUT_LOGGER, ( - "truncated send: %s", - strerror(errno))); - } - } - for (int i = 0; i < n; i++) + unsigned int packsize; + void* buf = e.pack(packsize); + + if ((written = _pSocket->send(buf, packsize)) != packsize) { - count += buffers[i].iov_len; - if ((written += _pSocket->send(buffers[i].iov_base, buffers[i].iov_len)) != count) - { - LOFAR_LOG_DEBUG(TM_STDOUT_LOGGER, ( - "truncated send: %s", - strerror(errno))); - } + LOFAR_LOG_DEBUG(TM_STDOUT_LOGGER, ( + "truncated send: %s", + strerror(errno))); + + schedule_disconnected(); + + written = 0; } return written; @@ -182,13 +141,6 @@ ssize_t GCFETHRawPort::recv(void* buf, size_t count) return _pSocket->recv(buf, count); } -ssize_t GCFETHRawPort::recvv(iovec /*buffers*/[], int /*n*/) -{ - LOFAR_LOG_FATAL(TM_STDOUT_LOGGER, ( - "recvv: not implemented")); - return -1; -} - void GCFETHRawPort::setAddr(const char* ifname, const char* destMac) { diff --git a/MAC/GCF/_CoreComps/TM/src/Socket/GCF_ETHRawPort.h b/MAC/GCF/_CoreComps/TM/src/Socket/GCF_ETHRawPort.h index f653dedcc75f29e0521f021364e8e05576d65cf3..df1e05535b7c4b5c62fa7cf7c0d2555979a872ae 100644 --- a/MAC/GCF/_CoreComps/TM/src/Socket/GCF_ETHRawPort.h +++ b/MAC/GCF/_CoreComps/TM/src/Socket/GCF_ETHRawPort.h @@ -75,12 +75,8 @@ class GCFETHRawPort : public GCFRawPort /** * send/recv functions */ - virtual ssize_t send(const GCFEvent& event, - void* buf = 0, size_t count = 0); - virtual ssize_t sendv(const GCFEvent& e, - const iovec buffers[], int n); - virtual ssize_t recv(void* buf, size_t count); - virtual ssize_t recvv(iovec buffers[], int n); + virtual ssize_t send(GCFEvent& event); + virtual ssize_t recv(void* buf, size_t count); // EOF GCFPortInterface methods diff --git a/MAC/GCF/_CoreComps/TM/src/Socket/GCF_TCPPort.cc b/MAC/GCF/_CoreComps/TM/src/Socket/GCF_TCPPort.cc index f58a0fddb202b7f003a9434cc3d5e19177c36bef..bfb8237b1ebefc614b5e6b53e0a18c04adef1afc 100644 --- a/MAC/GCF/_CoreComps/TM/src/Socket/GCF_TCPPort.cc +++ b/MAC/GCF/_CoreComps/TM/src/Socket/GCF_TCPPort.cc @@ -28,6 +28,7 @@ #include <PortInterface/GTM_NameService.h> #include <PortInterface/GTM_TopologyService.h> #include <Socket/GTM_TCPServerSocket.h> +#include <errno.h> GCFTCPPort::GCFTCPPort(GCFTask& task, string name, @@ -136,7 +137,7 @@ int GCFTCPPort::open() return result; } -ssize_t GCFTCPPort::send(const GCFEvent& e, void* buf, size_t count) +ssize_t GCFTCPPort::send(GCFEvent& e) { size_t written = 0; @@ -145,66 +146,29 @@ ssize_t GCFTCPPort::send(const GCFEvent& e, void* buf, size_t count) if (MSPP == getType()) return 0; // no messages can be send by this type of port - iovec* newbufs(0); - if (F_RAW_SIG != e.signal) - { - LOFAR_LOG_TRACE(TM_STDOUT_LOGGER, ( - "Sending event '%s' for task %s on port %s", - getTask()->evtstr(e), - getTask()->getName().c_str(), - getName().c_str())); + + unsigned int packsize; + void* buf = e.pack(packsize); - iovec buffers[2]; - buffers[0].iov_base = (void*)&e; - buffers[0].iov_len = e.length - count; - buffers[1].iov_base = buf; - buffers[1].iov_len = count; - newbufs = buffers; - sendv(GCFEvent(F_RAW_SIG), buffers, (count > 0 ? 2 : 1)); - } - else + if (!isSlave()) { - if ((written = _pSocket->send(buf, count)) != count) - { - LOFAR_LOG_DEBUG(TM_STDOUT_LOGGER, ("truncated send")); - } - } - - return written; -} - -ssize_t GCFTCPPort::sendv(const GCFEvent& e, const iovec buffers[], int n) -{ - size_t written = 0; - size_t count = 0; - assert(_pSocket); - if (MSPP == getType()) - return 0; // no messages can be send by this type of port - - - if (F_RAW_SIG != e.signal) - { LOFAR_LOG_TRACE(TM_STDOUT_LOGGER, ( - "Sending event '%s' for task %s on port %s", + "Sending event '%s' for task %s on port '%s'", getTask()->evtstr(e), getTask()->getName().c_str(), getName().c_str())); - count = e.length; - if ((written = _pSocket->send((void*)&e, e.length)) != count) - { - LOFAR_LOG_DEBUG(TM_STDOUT_LOGGER, ("truncated sendv")); - } } - - for (int i = 0; i < n; i++) + if ((written = _pSocket->send(buf, packsize)) != packsize) { - count += buffers[i].iov_len; - if ((written += _pSocket->send(buffers[i].iov_base, buffers[i].iov_len)) != count) - { - LOFAR_LOG_DEBUG(TM_STDOUT_LOGGER, ("truncated sendv")); - } + LOFAR_LOG_DEBUG(TM_STDOUT_LOGGER, ( + "truncated send: %s", + strerror(errno))); + + schedule_disconnected(); + + written = 0; } - + return written; } @@ -214,11 +178,6 @@ ssize_t GCFTCPPort::recv(void* buf, size_t count) return _pSocket->recv(buf, count); } -ssize_t GCFTCPPort::recvv(iovec buffers[], int n) -{ - return 0;//_pSocket->recvv_n(buffers, n); -} - int GCFTCPPort::close() { _pSocket->close(); diff --git a/MAC/GCF/_CoreComps/TM/src/Socket/GTM_Socket.cc b/MAC/GCF/_CoreComps/TM/src/Socket/GTM_Socket.cc index 446936c32309e9e4a9616afda6e690dcf14cf15f..b6d2fb17755429c831044cf573261643b269f021 100644 --- a/MAC/GCF/_CoreComps/TM/src/Socket/GTM_Socket.cc +++ b/MAC/GCF/_CoreComps/TM/src/Socket/GTM_Socket.cc @@ -81,12 +81,12 @@ void GTMSocket::workProc() { if (bytesRead == 0) { - GCFEvent e(F_DISCONNECTED_SIG); + GCFEvent e(F_DISCONNECTED); _port.dispatch(e); } else { - GCFEvent e(F_DATAIN_SIG); + GCFEvent e(F_DATAIN); _port.dispatch(e); } } diff --git a/MAC/GCF/_CoreComps/TM/src/Socket/GTM_TCPServerSocket.cc b/MAC/GCF/_CoreComps/TM/src/Socket/GTM_TCPServerSocket.cc index 6117c0f3f6943a69e766d36a6202ef59c2302357..fe70044b4c4dd313447a0e0d869ee44e362a7f87 100644 --- a/MAC/GCF/_CoreComps/TM/src/Socket/GTM_TCPServerSocket.cc +++ b/MAC/GCF/_CoreComps/TM/src/Socket/GTM_TCPServerSocket.cc @@ -93,7 +93,7 @@ void GTMTCPServerSocket::workProc() { if (_isProvider) { - GCFEvent acceptReqEvent(F_ACCEPT_REQ_SIG); + GCFEvent acceptReqEvent(F_ACCEPT_REQ); _port.dispatch(acceptReqEvent); } else @@ -113,7 +113,7 @@ void GTMTCPServerSocket::workProc() if (_pTCPServerSocket->getFD() >= 0) { - GCFEvent connectedEvent(F_CONNECTED_SIG); + GCFEvent connectedEvent(F_CONNECTED); _port.dispatch(connectedEvent); } // else ignore further connect requests diff --git a/MAC/GCF/_CoreComps/TM/test/Echo.cc b/MAC/GCF/_CoreComps/TM/test/Echo.cc index eae0e1e0227d2cfe0b15ad7170c4bae22d8fa042..12fce122dbd6a3a958a04d9e57f474ed13b87a60 100644 --- a/MAC/GCF/_CoreComps/TM/test/Echo.cc +++ b/MAC/GCF/_CoreComps/TM/test/Echo.cc @@ -22,10 +22,8 @@ // $Id$ #include "Echo.h" -#define DECLARE_SIGNAL_NAMES #include "Echo_Protocol.ph" - Echo::Echo(string name) : GCFTask((State)&Echo::initial, name) { // register the protocol for debugging purposes @@ -41,22 +39,22 @@ GCFEvent::TResult Echo::initial(GCFEvent& e, GCFPortInterface& /*p*/) switch (e.signal) { - case F_INIT_SIG: + case F_INIT: break; - case F_ENTRY_SIG: + case F_ENTRY: server.open(); break; - case F_CONNECTED_SIG: + case F_CONNECTED: TRAN(Echo::connected); break; - case F_DISCONNECTED_SIG: + case F_DISCONNECTED: server.setTimer(1.0); // try again after 1 second break; - case F_TIMER_SIG: + case F_TIMER: server.open(); // try again break; @@ -73,44 +71,36 @@ GCFEvent::TResult Echo::connected(GCFEvent& e, GCFPortInterface& /*p*/) GCFEvent::TResult status = GCFEvent::HANDLED; switch (e.signal) - { - case F_DISCONNECTED_SIG: + { + case F_DISCONNECTED: cout << "Lost connection to client" << endl; TRAN(Echo::initial); break; case ECHO_PING: - { - -#ifndef HUMAN_PORT - - EchoPingEvent* ping = static_cast<EchoPingEvent*>(&e); - - cout << "PING received (seqnr=" << ping->seqnr << ")" << endl; - - timeval echo_time; - gettimeofday(&echo_time, 0); - EchoEchoEvent echo(ping->seqnr, - ping->ping_time, - echo_time); - -#else - - cout << "PING received" << endl; - - GCFEvent echo(ECHO_ECHO); - -#endif - server.send(echo); + { - cout << "ECHO sent" << endl; - } + EchoPingEvent ping(e); + + 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; } diff --git a/MAC/GCF/_CoreComps/TM/test/Echo_Protocol.prot b/MAC/GCF/_CoreComps/TM/test/Echo_Protocol.prot index 51abac0129d4184fe0fbde024682a0fde1c9d8cb..5c4d6de8b6558860b10c7093b1bfb352181c485f 100644 --- a/MAC/GCF/_CoreComps/TM/test/Echo_Protocol.prot +++ b/MAC/GCF/_CoreComps/TM/test/Echo_Protocol.prot @@ -5,17 +5,11 @@ 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>'; -prelude = << PRELUDE_END -enum { - ECHO_PROTOCOL = F_APL_PROTOCOL -}; -PRELUDE_END; - // // An "event" has a "signal" and a "dir" (direction) // and zero or more "param"s. diff --git a/MAC/GCF/_CoreComps/TM/test/Makefile.am b/MAC/GCF/_CoreComps/TM/test/Makefile.am index de90199d7ade4119e2acec0ba7d4399b656188e7..8cc33f010445b8ef8b2f68c4bafcd85a2c9ca4e2 100644 --- a/MAC/GCF/_CoreComps/TM/test/Makefile.am +++ b/MAC/GCF/_CoreComps/TM/test/Makefile.am @@ -2,14 +2,14 @@ check_PROGRAMS = echoapp ping TESTS = #echoapp ping -echoapp_SOURCES = Echo.cc +echoapp_SOURCES = Echo.cc Echo_Protocol.cc echoapp_LDADD = ../src/libtm.la \ $(top_builddir)/GCFCommon/src/libgcfcommon.la echoapp_DEPENDENCIES = ../src/libtm.la $(LOFAR_DEPEND) \ $(top_builddir)/GCFCommon/src/libgcfcommon.la -ping_SOURCES = Ping.cc +ping_SOURCES = Ping.cc Echo_Protocol.cc ping_LDADD = ../src/libtm.la \ $(top_builddir)/GCFCommon/src/libgcfcommon.la ping_DEPENDENCIES = ../src/libtm.la $(LOFAR_DEPEND) \ @@ -18,7 +18,7 @@ ping_DEPENDENCIES = ../src/libtm.la $(LOFAR_DEPEND) \ AUTOGEN = autogen SUFFIXES = .ph %.ph: %.prot - $(AUTOGEN) -L $(top_srcdir)/GCFCommon/autogen $< && \ + $(AUTOGEN) -L $(top_srcdir)/../MACCommon/autogen $< && \ chmod a+w $@ BUILT_SOURCES = \ diff --git a/MAC/GCF/_CoreComps/TM/test/Ping.cc b/MAC/GCF/_CoreComps/TM/test/Ping.cc index 6dcf7a3e4e1ff600bfc345cdab7f87fa4010d4f3..e2cc53aa32db436360a70fc64b4a72e2929f8448 100644 --- a/MAC/GCF/_CoreComps/TM/test/Ping.cc +++ b/MAC/GCF/_CoreComps/TM/test/Ping.cc @@ -23,10 +23,8 @@ // #include "Ping.h" -#define DECLARE_SIGNAL_NAMES #include "Echo_Protocol.ph" - /** * Function to calculate the elapsed time between two tiemval's. */ @@ -59,28 +57,28 @@ GCFEvent::TResult Ping::initial(GCFEvent& e, GCFPortInterface& /*port*/) switch (e.signal) { - case F_INIT_SIG: + case F_INIT: break; - case F_ENTRY_SIG: + case F_ENTRY: client.open(); break; - case F_CONNECTED_SIG: + case F_CONNECTED: // start ping_timer // - after 1 second - // - every 40 seconds + // - every 2 seconds ping_timer = client.setTimer(1.0, 2.0); TRAN(Ping::connected); break; - case F_DISCONNECTED_SIG: + case F_DISCONNECTED: (void)client.setTimer(1.0); // try connect again after 1 second break; - case F_TIMER_SIG: + case F_TIMER: client.open(); break; @@ -99,41 +97,28 @@ GCFEvent::TResult Ping::connected(GCFEvent& e, GCFPortInterface& /*p*/) static int seqnr = 0; switch (e.signal) + { + case F_TIMER: { - case F_TIMER_SIG: - { - -#ifndef HUMAN_PORT - - timeval ping_time; - - // create PingEvent - gettimeofday(&ping_time, 0); - EchoPingEvent ping(seqnr++, - ping_time); - - // send the event - client.send(ping); - - cout << "PING sent (seqnr=" << ping.seqnr << ")" << endl; - -#else - - gettimeofday(&g_ping_time, 0); - GCFEvent ping(ECHO_PING); - - // send the event - client.send(ping); - - cout << "PING sent" << endl; + + 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; -#endif - TRAN(Ping::awaiting_echo); // wait for the echo - } + TRAN(Ping::awaiting_echo); // wait for the echo break; - - case F_DISCONNECTED_SIG: + } + case F_DISCONNECTED: //(void)client.open(); // try to reopen (void)client.cancelTimer(ping_timer); @@ -155,26 +140,25 @@ GCFEvent::TResult Ping::awaiting_echo(GCFEvent& e, GCFPortInterface& /*p*/) GCFEvent::TResult status = GCFEvent::HANDLED; switch (e.signal) - { - case F_TIMER_SIG: + { + case F_TIMER: cout << "Missed echo dead-line." << endl; break; case ECHO_ECHO: - { - timeval echo_time; - gettimeofday(&echo_time, 0); - - EchoEchoEvent* echo = static_cast<EchoEchoEvent*>(&e); - - cout << "ECHO received (seqnr=" << echo->seqnr << "): elapsed = " - << time_elapsed(&(echo->ping_time), &echo_time) << " sec."<< endl; - - TRAN(Ping::connected); - } + { + 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_SIG: + } + case F_DISCONNECTED: (void)client.cancelTimer(ping_timer); TRAN(Ping::initial); break; diff --git a/MAC/GCF/src/GCF_Answer.h b/MAC/GCF/src/GCF_Answer.h index 74e38e7b89460e3621e787a09f982e6980241427..e3506a099958a2fa828db88bf62a4e6a74a69e7d 100644 --- a/MAC/GCF/src/GCF_Answer.h +++ b/MAC/GCF/src/GCF_Answer.h @@ -82,10 +82,10 @@ class GCFAnswer * ... * switch (e.signal) * { - * case F_ENTRY_SIG: + * case F_ENTRY: * break; * - * case F_MYPLOADED_SIG: + * case F_MYPLOADED: * { * // The event always sould be casted by the static_cast operator * GCFMYPropAnswerEvent* pResponse = static_cast<GCFMYPropAnswerEvent*>(&e); @@ -119,7 +119,7 @@ class GCFAnswer /// implementations like TCP. struct GCFPropValueEvent : public GCFEvent { - /// @param sig can only be F_VCHANGEMSG_SIG, F_VGETRESP_SIG + /// @param sig can only be F_VCHANGEMSG, F_VGETRESP GCFPropValueEvent(unsigned short sig) : GCFEvent(sig) { length = sizeof(GCFPropValueEvent); @@ -128,12 +128,12 @@ struct GCFPropValueEvent : public GCFEvent const char* pPropName; ///< Pointer to the string of the property name bool internal; ///< Indicates whether the internal/owned/my ///< (GCFMyProperty) or an other (GCFProperty) - ///< property has changed (not used with F_VGETRESP_SIG) + ///< property has changed (not used with F_VGETRESP) }; struct GCFPropAnswerEvent : public GCFEvent { - /// @param sig can only be F_SUBSCRIBED_SIG + /// @param sig can only be F_SUBSCRIBED GCFPropAnswerEvent(unsigned short sig) : GCFEvent(sig) { length = sizeof(GCFPropAnswerEvent); @@ -143,7 +143,7 @@ struct GCFPropAnswerEvent : public GCFEvent struct GCFAPCAnswerEvent : public GCFEvent { - /// @param sig can only be F_APCLOADED_SIG, F_APCUNLOADED_SIG, F_APCRELOADED_SIG + /// @param sig can only be F_APCLOADED, F_APCUNLOADED, F_APCRELOADED GCFAPCAnswerEvent(unsigned short sig) : GCFEvent(sig) { length = sizeof(GCFAPCAnswerEvent); @@ -156,7 +156,7 @@ struct GCFAPCAnswerEvent : public GCFEvent struct GCFMYPropAnswerEvent : public GCFEvent { - /// @param sig can only be F_MYPLOADED_SIG, F_MYPUNLOADED_SIG + /// @param sig can only be F_MYPLOADED, F_MYPUNLOADED GCFMYPropAnswerEvent(unsigned short sig) : GCFEvent(sig) { length = sizeof(GCFMYPropAnswerEvent); @@ -184,15 +184,15 @@ enum { F_MYPUNLOADED_ID, }; -#define F_SUBSCRIBED_SIG F_SIGNAL(F_PML_PROTOCOL, F_SUBSCRIBED_ID, F_IN) -#define F_UNSUBSCRIBED_SIG F_SIGNAL(F_PML_PROTOCOL, F_UNSUBSCRIBED_ID, F_IN) -#define F_VCHANGEMSG_SIG F_SIGNAL(F_PML_PROTOCOL, F_VCHANGEMSG_ID, F_IN) -#define F_VGETRESP_SIG F_SIGNAL(F_PML_PROTOCOL, F_VGETRESP_ID, F_IN) -#define F_APCLOADED_SIG F_SIGNAL(F_PML_PROTOCOL, F_APCLOADED_ID, F_IN) -#define F_APCUNLOADED_SIG F_SIGNAL(F_PML_PROTOCOL, F_APCUNLOADED_ID, F_IN) -#define F_APCRELOADED_SIG F_SIGNAL(F_PML_PROTOCOL, F_APCRELOADED_ID, F_IN) -#define F_MYPLOADED_SIG F_SIGNAL(F_PML_PROTOCOL, F_MYPLOADED_ID, F_IN) -#define F_MYPUNLOADED_SIG F_SIGNAL(F_PML_PROTOCOL, F_MYPUNLOADED_ID, F_IN) +#define F_SUBSCRIBED F_SIGNAL(F_PML_PROTOCOL, F_SUBSCRIBED_ID, F_IN) +#define F_UNSUBSCRIBED F_SIGNAL(F_PML_PROTOCOL, F_UNSUBSCRIBED_ID, F_IN) +#define F_VCHANGEMSG F_SIGNAL(F_PML_PROTOCOL, F_VCHANGEMSG_ID, F_IN) +#define F_VGETRESP F_SIGNAL(F_PML_PROTOCOL, F_VGETRESP_ID, F_IN) +#define F_APCLOADED F_SIGNAL(F_PML_PROTOCOL, F_APCLOADED_ID, F_IN) +#define F_APCUNLOADED F_SIGNAL(F_PML_PROTOCOL, F_APCUNLOADED_ID, F_IN) +#define F_APCRELOADED F_SIGNAL(F_PML_PROTOCOL, F_APCRELOADED_ID, F_IN) +#define F_MYPLOADED F_SIGNAL(F_PML_PROTOCOL, F_MYPLOADED_ID, F_IN) +#define F_MYPUNLOADED F_SIGNAL(F_PML_PROTOCOL, F_MYPUNLOADED_ID, F_IN) extern const char* F_PML_PROTOCOL_signalnames[]; diff --git a/MAC/GCF/src/GCF_Event.h b/MAC/GCF/src/GCF_Event.h index fee4c3a3a7e88c25b3bd09f0b7c8b218c1f8990d..54892a0a10e1bf4fcd79c9a445eacecc7bc148fd 100644 --- a/MAC/GCF/src/GCF_Event.h +++ b/MAC/GCF/src/GCF_Event.h @@ -23,7 +23,17 @@ #ifndef GCF_EVENT_H #define GCF_EVENT_H +#include <assert.h> #include <sys/types.h> +#include <string> + +#ifdef SWIG +%module GCFEvent +%{ +#include "GCF_Event.h" +%} +#endif + /** * This struct is the base event data container to exchange messages between two * tasks. @@ -43,38 +53,82 @@ * file and the nested key-value pairs from the specification file. This header * file contains definitions of GCFEvent sub classes, one for each event. */ -struct GCFEvent +class GCFEvent { + public: GCFEvent() : - signal(0), pad0(0), length(sizeof(GCFEvent)) + signal(0), length(0), _unpackDone(false), _buffer(0), + _base(0), _upperbound(0) {} GCFEvent(unsigned short sig) : - signal(sig), pad0(0), length(sizeof(GCFEvent)) + signal(sig), length(0), _unpackDone(false), _buffer(0), + _base(0), _upperbound(0) {} - + + virtual ~GCFEvent(); + enum TResult { ERROR = -1, HANDLED = 0, NOT_HANDLED = 1}; - /** - * @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 | S | 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 - */ - unsigned short signal; // lsb contains signal id (0-255) - // msb contains protocol id (0-255) - unsigned short pad0; // DO NOT USE - size_t length; // length of the event (should be <= SSIZE_MAX) + virtual void* pack(unsigned int& packsize); + + static unsigned int unpackString(std::string& value, char* buffer); + static unsigned int packString(char* buffer, const std::string& value); + + /** + * @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 | S | 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 + */ +#ifdef SWIG +%immutable; +#endif + unsigned short signal; // lsb contains signal id (0-255) + // msb contains protocol id (0-255) + size_t length; // payload length of the event (thus excl. signal and length) should be <= SSIZE_MAX) +#ifdef SWIG +%mutable; +#endif + + protected: // member functions + GCFEvent(GCFEvent& e) : + signal(e.signal), length(e.length), _unpackDone(true), _buffer(0), + _base(&e), _upperbound(0) + {} + + void resizeBuf(unsigned int requiredSize); + void* unpackMember(char* data, unsigned int& offset, unsigned int& memberDim, unsigned int sizeofMemberType); + unsigned int packMember(unsigned int offset, const void* member, unsigned int memberDim, unsigned int sizeofMemberType); + + protected: // data members + bool _unpackDone; + char* _buffer; + GCFEvent* _base; + + private: + GCFEvent& operator= (GCFEvent& e); + 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; }; /** @@ -88,4 +142,5 @@ struct GCFEvent #define F_EVT_PROTOCOL(e) (((e).signal & F_EVT_PROTOCOL_MASK) >> 8) #define F_EVT_SIGNAL(e) ((e).signal & F_EVT_SIGNAL_MASK) + #endif diff --git a/MAC/GCF/src/GCF_Fsm.h b/MAC/GCF/src/GCF_Fsm.h index ec687f5e245c782ebfa188619cb633db35f53bfe..9308752a9c66264db49a4907ca8d8c6693576061 100644 --- a/MAC/GCF/src/GCF_Fsm.h +++ b/MAC/GCF/src/GCF_Fsm.h @@ -51,19 +51,11 @@ class GCFDummyPort : public GCFPortInterface inline int close () {return 0;} inline int open () {return 0;} - inline ssize_t send (const GCFEvent& /*event*/, - void* /*buf*/ = 0, - size_t /*count*/ = 0) + inline ssize_t send (GCFEvent& /*event*/) { return 0; } - inline ssize_t sendv (const GCFEvent& /*event*/, - const iovec /*buffers*/[], - int /*n*/) - { - return 0; - } inline ssize_t recv (void* /*buf*/, size_t /*count*/) @@ -71,13 +63,6 @@ class GCFDummyPort : public GCFPortInterface return 0; } - inline ssize_t recvv (iovec /*buffers*/[], - int /*n*/) - { - - return 0; - } - inline long setTimer (long /*delay_sec*/, long /*delay_usec*/, long /*interval_sec*/, diff --git a/MAC/GCF/src/GCF_PVBool.h b/MAC/GCF/src/GCF_PVBool.h index 754441865933fc7462cbd8d6711e81e50981ed08..23ea355a72cf9574738f85753fec77fe0c6f2e56 100644 --- a/MAC/GCF/src/GCF_PVBool.h +++ b/MAC/GCF/src/GCF_PVBool.h @@ -33,7 +33,7 @@ class GCFPVBool : public GCFPValue { public: - GCFPVBool (bool val = false) : GCFPValue(LPT_BOOL), _value(val) {;} + explicit GCFPVBool (bool val = false) : GCFPValue(LPT_BOOL), _value(val) {;} virtual ~GCFPVBool () {;} /** Changes the value of this object */ @@ -55,10 +55,11 @@ class GCFPVBool : public GCFPValue /** @see GCFPValue::copy() */ virtual TGCFResult copy (const GCFPValue& value); - virtual unsigned int unpack(const char* valBuf, unsigned int bufLength); + virtual unsigned int unpack(const char* valBuf); - virtual unsigned int pack(char* valBuf, unsigned int maxBufSize) const; - + virtual unsigned int pack(char* valBuf) const; + + virtual unsigned int getSize() const { return 1 + getBaseSize(); } private: // Private attributes /** The value */ diff --git a/MAC/GCF/src/GCF_PVChar.h b/MAC/GCF/src/GCF_PVChar.h index 59e3c7cc913fcf185d6acd33b1ba87e0ce78adf4..c62379930ae80331e0c6b79797f3141ddcbb82e7 100644 --- a/MAC/GCF/src/GCF_PVChar.h +++ b/MAC/GCF/src/GCF_PVChar.h @@ -32,7 +32,7 @@ class GCFPVChar : public GCFPValue { public: - GCFPVChar (char val = 0) : GCFPValue(LPT_CHAR), _value(val) {;} + explicit GCFPVChar (char val = 0) : GCFPValue(LPT_CHAR), _value(val) {;} virtual ~GCFPVChar () {;} /** Changes the value of this object */ @@ -54,10 +54,12 @@ class GCFPVChar : public GCFPValue /** @see GCFPValue::copy() */ virtual TGCFResult copy (const GCFPValue& value); - virtual unsigned int unpack(const char* valBuf, unsigned int bufLength); - - virtual unsigned int pack(char* valBuf, unsigned int maxBufSize) const; + virtual unsigned int unpack(const char* valBuf); + virtual unsigned int pack(char* valBuf) const; + + virtual unsigned int getSize() const { return sizeof(char) + getBaseSize(); } + private: // Private attributes /** The value */ char _value; diff --git a/MAC/GCF/src/GCF_PVDouble.h b/MAC/GCF/src/GCF_PVDouble.h index de67368a438c7c5c37fedced2f1431070f7d3176..8c2b566db692c36eee11e92168b64c50d9a68669 100644 --- a/MAC/GCF/src/GCF_PVDouble.h +++ b/MAC/GCF/src/GCF_PVDouble.h @@ -33,7 +33,7 @@ class GCFPVDouble : public GCFPValue { public: - GCFPVDouble (double val = 0.0) : GCFPValue(LPT_DOUBLE), _value(val) {;} + explicit GCFPVDouble (double val = 0.0) : GCFPValue(LPT_DOUBLE), _value(val) {;} virtual ~GCFPVDouble () {;} /** Changes the value of this object */ @@ -55,10 +55,12 @@ class GCFPVDouble : public GCFPValue /** @see GCFPValue::copy() */ virtual TGCFResult copy (const GCFPValue& value); - virtual unsigned int unpack(const char* valBuf, unsigned int bufLength); + virtual unsigned int unpack(const char* valBuf); - virtual unsigned int pack(char* valBuf, unsigned int maxBufSize) const; + virtual unsigned int pack(char* valBuf) const; + virtual unsigned int getSize() const { return sizeof(double) + getBaseSize(); } + private: // Private attributes /** */ volatile double _value; diff --git a/MAC/GCF/src/GCF_PVDynArr.h b/MAC/GCF/src/GCF_PVDynArr.h index c960888548aa77b8fce6c491a66de3c785323782..21804fdd4c28cf95451bdd582f164f762b5c99f9 100644 --- a/MAC/GCF/src/GCF_PVDynArr.h +++ b/MAC/GCF/src/GCF_PVDynArr.h @@ -36,8 +36,8 @@ typedef vector<GCFPValue*> GCFPValueArray; class GCFPVDynArr : public GCFPValue { public: - GCFPVDynArr(TMACValueType itemType, const GCFPValueArray& val); - GCFPVDynArr(TMACValueType itemType); + explicit GCFPVDynArr(TMACValueType itemType, const GCFPValueArray& val); + explicit GCFPVDynArr(TMACValueType itemType); virtual ~GCFPVDynArr(); /** Changes the value of this object */ @@ -60,10 +60,12 @@ class GCFPVDynArr : public GCFPValue /** @see GCFPValue::copy() */ virtual TGCFResult copy(const GCFPValue& value); - virtual unsigned int unpack(const char* valBuf, unsigned int bufLength); + virtual unsigned int unpack(const char* valBuf); - virtual unsigned int pack(char* valBuf, unsigned int maxBufSize) const; + virtual unsigned int pack(char* valBuf) const; + virtual unsigned int getSize() const; + private: // help members /** cleanup the array item objects */ void cleanup(); diff --git a/MAC/GCF/src/GCF_PVInteger.h b/MAC/GCF/src/GCF_PVInteger.h index 03da4f6b875031c9886dd6d1f3188cdef1fac65d..346bee44bb20ea07f4dfe2ca0886ebe3af1fa525 100644 --- a/MAC/GCF/src/GCF_PVInteger.h +++ b/MAC/GCF/src/GCF_PVInteger.h @@ -32,7 +32,7 @@ class GCFPVInteger : public GCFPValue { public: - GCFPVInteger (int val = 0) : GCFPValue(LPT_INTEGER), _value(val) {;} + explicit GCFPVInteger (int val = 0) : GCFPValue(LPT_INTEGER), _value(val) {;} virtual ~GCFPVInteger () {;} /** Changes the value of this object */ @@ -54,10 +54,12 @@ class GCFPVInteger : public GCFPValue /** @see GCFPValue::copy() */ virtual TGCFResult copy (const GCFPValue& value); - virtual unsigned int unpack(const char* valBuf, unsigned int bufLength); + virtual unsigned int unpack(const char* valBuf); - virtual unsigned int pack(char* valBuf, unsigned int maxBufSize) const; + virtual unsigned int pack(char* valBuf) const; + virtual unsigned int getSize() const { return sizeof(int) + getBaseSize(); } + private: // Private attributes /** The value */ int _value; diff --git a/MAC/GCF/src/GCF_PVString.h b/MAC/GCF/src/GCF_PVString.h index 770e008efa0df8b8900965bbfe41e28aa065fb28..fe280a56ee51bdc6d129078c1b4ea038e305324c 100644 --- a/MAC/GCF/src/GCF_PVString.h +++ b/MAC/GCF/src/GCF_PVString.h @@ -32,7 +32,7 @@ class GCFPVString : public GCFPValue { public: - GCFPVString(string val = "") : GCFPValue(LPT_STRING), _value(val) {;} + explicit GCFPVString(string val = "") : GCFPValue(LPT_STRING), _value(val) {;} virtual ~GCFPVString() {;} /** Changes the value of this object */ @@ -47,10 +47,12 @@ class GCFPVString : public GCFPValue /** @see GCFPValue::copy() */ virtual TGCFResult copy(const GCFPValue& value); - virtual unsigned int unpack(const char* valBuf, unsigned int bufLength); + virtual unsigned int unpack(const char* valBuf); - virtual unsigned int pack(char* valBuf, unsigned int maxBufSize) const; + virtual unsigned int pack(char* valBuf) const; + virtual unsigned int getSize() const { return sizeof(unsigned int) + _value.length() + getBaseSize(); } + private: // Private attributes /** The value*/ string _value; diff --git a/MAC/GCF/src/GCF_PVUnsigned.h b/MAC/GCF/src/GCF_PVUnsigned.h index 965947cff18817c7ef96e6340d61ea8d8b0fd256..c21112ab95d5547b7aa467dadce4be055f2973c1 100644 --- a/MAC/GCF/src/GCF_PVUnsigned.h +++ b/MAC/GCF/src/GCF_PVUnsigned.h @@ -32,7 +32,7 @@ class GCFPVUnsigned : public GCFPValue { public: - GCFPVUnsigned(unsigned int val = 0) : GCFPValue(LPT_UNSIGNED), _value(val) {;} + explicit GCFPVUnsigned(unsigned int val = 0) : GCFPValue(LPT_UNSIGNED), _value(val) {;} virtual ~GCFPVUnsigned() {;} /** Changes the value of this object */ @@ -54,10 +54,12 @@ class GCFPVUnsigned : public GCFPValue /** @see GCFPValue::copy() */ virtual TGCFResult copy(const GCFPValue& value); - virtual unsigned int unpack(const char* valBuf, unsigned int bufLength); + virtual unsigned int unpack(const char* valBuf); - virtual unsigned int pack(char* valBuf, unsigned int maxBufSize) const; + virtual unsigned int pack(char* valBuf) const; + virtual unsigned int getSize() const { return sizeof(unsigned int) + getBaseSize(); } + private: // Private attributes /** The value */ unsigned int _value; diff --git a/MAC/GCF/src/GCF_PValue.h b/MAC/GCF/src/GCF_PValue.h index 5048bc8af113c370e2cb9284f5a2e2201df193dc..f44074970de5c2635f77bcf457a8b286e8978d3f 100644 --- a/MAC/GCF/src/GCF_PValue.h +++ b/MAC/GCF/src/GCF_PValue.h @@ -52,7 +52,7 @@ class GCFPValue * Sets the type ID for each subclassed property value type class * @param type MAC property type ID */ - GCFPValue (TMACValueType type) : _type(type) {}; + explicit GCFPValue (TMACValueType type) : _type(type) {}; /** * The destructor @@ -100,16 +100,20 @@ class GCFPValue */ static GCFPValue* createMACTypeObject (TMACValueType type); - static GCFPValue* unpackValue (const char* valBuf, unsigned int maxBufSize); + static GCFPValue* unpackValue (const char* valBuf); - virtual unsigned int unpack(const char* valBuf, unsigned int maxBufSize) = 0; + virtual unsigned int unpack(const char* valBuf) = 0; - virtual unsigned int pack(char* valBuf, unsigned int maxBufSize) const = 0; + virtual unsigned int pack(char* valBuf) const = 0; + + virtual unsigned int getSize() const = 0; protected: - unsigned int unpackBase(const char* valBuf, unsigned int maxBufSize); + unsigned int unpackBase(const char* valBuf); - unsigned int packBase(char* valBuf, unsigned int maxBufSize) const; + unsigned int packBase(char* valBuf) const; + + unsigned int getBaseSize() const { return 1; } private: // private data members /** Holds MAC property value type ID*/ diff --git a/MAC/GCF/src/GCF_Port.h b/MAC/GCF/src/GCF_Port.h index 7ad7276350a0183e404882a23cac5e96a6aa3432..606da9d2acdd85c55bacb47840f88c3e36bdcd76 100644 --- a/MAC/GCF/src/GCF_Port.h +++ b/MAC/GCF/src/GCF_Port.h @@ -75,16 +75,9 @@ class GCFPort : public GCFPortInterface /** * send/recv functions */ - virtual ssize_t send (const GCFEvent& event, - void* buf = 0, - size_t count = 0); - virtual ssize_t sendv (const GCFEvent& event, - const iovec buffers[], - int n); + virtual ssize_t send (GCFEvent& event); virtual ssize_t recv (void* buf, size_t count); - virtual ssize_t recvv (iovec buffers[], - int n); /** * Timer functions. diff --git a/MAC/GCF/src/GCF_PortInterface.h b/MAC/GCF/src/GCF_PortInterface.h index f865ecb9ecfbe080017ec254b1303a90511ecbe0..64d3ec48c8e1e678e3ebf1bfc341e9911cefe3a3 100644 --- a/MAC/GCF/src/GCF_PortInterface.h +++ b/MAC/GCF/src/GCF_PortInterface.h @@ -76,17 +76,10 @@ class GCFPortInterface /** * send/recv functions */ - virtual ssize_t send (const GCFEvent& event, - void* buf = 0, - size_t count = 0) = 0; - virtual ssize_t sendv (const GCFEvent& event, - const iovec buffers[], - int n) = 0; + virtual ssize_t send (GCFEvent& event) = 0; virtual ssize_t recv (void* buf, size_t count) = 0; - virtual ssize_t recvv (iovec buffers[], - int n) = 0; /** * Timer functions. diff --git a/MAC/GCF/src/GCF_TCPPort.h b/MAC/GCF/src/GCF_TCPPort.h index 4f3605c0c81cb05381d41201631c03d3c87ee6f2..61499375a24950f357235712cb0e9888d28f6b67 100644 --- a/MAC/GCF/src/GCF_TCPPort.h +++ b/MAC/GCF/src/GCF_TCPPort.h @@ -63,16 +63,9 @@ class GCFTCPPort : public GCFRawPort /** * send/recv functions */ - virtual ssize_t send (const GCFEvent& event, - void* buf = 0, - size_t count = 0); - virtual ssize_t sendv (const GCFEvent& e, - const iovec buffers[], - int n); + virtual ssize_t send (GCFEvent& event); virtual ssize_t recv (void* buf, size_t count); - virtual ssize_t recvv (iovec buffers[], - int n); public: // addr is local address if getType == (M)SPP diff --git a/MAC/GCF/src/GCF_TMProtocols.h b/MAC/GCF/src/GCF_TMProtocols.h index c854fbeb38153120ce82b613a0b322a134a00794..497b0a6af201dc9cab9fac9ea3084b494c999e85 100644 --- a/MAC/GCF/src/GCF_TMProtocols.h +++ b/MAC/GCF/src/GCF_TMProtocols.h @@ -70,9 +70,9 @@ enum { }; // convenience macros -#define F_ENTRY_SIG F_SIGNAL(F_FSM_PROTOCOL, F_ENTRY_ID, F_IN) -#define F_EXIT_SIG F_SIGNAL(F_FSM_PROTOCOL, F_EXIT_ID, F_IN) -#define F_INIT_SIG F_SIGNAL(F_FSM_PROTOCOL, F_INIT_ID, F_IN) +#define F_ENTRY F_SIGNAL(F_FSM_PROTOCOL, F_ENTRY_ID, F_IN) +#define F_EXIT F_SIGNAL(F_FSM_PROTOCOL, F_EXIT_ID, F_IN) +#define F_INIT F_SIGNAL(F_FSM_PROTOCOL, F_INIT_ID, F_IN) extern const char* F_FSM_PROTOCOL_names[]; // defined in GCF_Protocols.cc @@ -88,35 +88,33 @@ enum { F_TIMER_ID, // timer expired F_DATAIN_ID, // data available for reading F_DATAOUT_ID, // space available to write - F_RAW_ID, // no event!, only the data is sent (used with direct ports) + F_RAW_DATA_ID, // no event!, only the data is sent (used with direct ports) F_ACCEPT_REQ_ID, // indicatation of the port provider to the user about a client connect request (SAP) - F_DISPATCHED_ID // SCADA API has dispachted (read/write on own ports) right now }; -#define F_CONNECT_SIG F_SIGNAL(F_PORT_PROTOCOL, F_CONNECT_ID, F_IN) -#define F_CONNECTED_SIG F_SIGNAL(F_PORT_PROTOCOL, F_CONNECTED_ID, F_IN) -#define F_DISCONNECTED_SIG F_SIGNAL(F_PORT_PROTOCOL, F_DISCONNECTED_ID, F_IN) -#define F_CLOSED_SIG F_SIGNAL(F_PORT_PROTOCOL, F_CLOSED_ID, F_IN) -#define F_TIMER_SIG F_SIGNAL(F_PORT_PROTOCOL, F_TIMER_ID, F_IN) -#define F_DATAIN_SIG F_SIGNAL(F_PORT_PROTOCOL, F_DATAIN_ID, F_IN) -#define F_DATAOUT_SIG F_SIGNAL(F_PORT_PROTOCOL, F_DATAOUT_ID, F_IN) -#define F_RAW_SIG F_SIGNAL(F_PORT_PROTOCOL, F_RAW_ID, F_INOUT) -#define F_ACCEPT_REQ_SIG F_SIGNAL(F_PORT_PROTOCOL, F_ACCEPT_REQ_ID, F_IN) -#define F_DISPATCHED_SIG F_SIGNAL(F_PORT_PROTOCOL, F_DISPATCHED_ID, F_IN) +#define F_CONNECT F_SIGNAL(F_PORT_PROTOCOL, F_CONNECT_ID, F_IN) +#define F_CONNECTED F_SIGNAL(F_PORT_PROTOCOL, F_CONNECTED_ID, F_IN) +#define F_DISCONNECTED F_SIGNAL(F_PORT_PROTOCOL, F_DISCONNECTED_ID, F_IN) +#define F_CLOSED F_SIGNAL(F_PORT_PROTOCOL, F_CLOSED_ID, F_IN) +#define F_TIMER F_SIGNAL(F_PORT_PROTOCOL, F_TIMER_ID, F_IN) +#define F_DATAIN F_SIGNAL(F_PORT_PROTOCOL, F_DATAIN_ID, F_IN) +#define F_DATAOUT F_SIGNAL(F_PORT_PROTOCOL, F_DATAOUT_ID, F_IN) +#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) extern const char* F_PORT_PROTOCOL_names[]; // defined in GCF_TMProtocols.cc struct GCFTimerEvent : public GCFEvent { - GCFTimerEvent() : GCFEvent(F_TIMER_SIG) + GCFTimerEvent() : GCFEvent(F_TIMER) { length = sizeof(GCFTimerEvent); } - long sec; - long usec; + long sec; + long usec; unsigned long id; - void* arg; + const void* arg; }; #endif diff --git a/MAC/MACCommon/autogen/protocol.tpl b/MAC/MACCommon/autogen/protocol.tpl index 9b392fadfaf8ca95144e2228ce00e5dba440867f..887e9f6dbd965efb60689337bb22c15a2ffb14d4 100644 --- a/MAC/MACCommon/autogen/protocol.tpl +++ b/MAC/MACCommon/autogen/protocol.tpl @@ -1,18 +1,21 @@ -[+ AutoGen5 template ph +] +[+ 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 struct_name +][+ prefix_cap +][+ (string-capitalize! (get "signal")) +]Event[+ ENDDEF +] -[+ DEFINE struct_decl +][+ struct_name +] : public GCFEvent[+ 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 GCFEvent[+ ENDDEF +] [+ DEFINE protocol_name +][+ (string-upcase (base-name)) +][+ ENDDEF +] -[+ DEFINE param +][+ (get "type") +] [+ (get "name") +][+ IF (exist? "dim")+][[+ (get "dim") +]][+ ENDIF +][+ enddef +] -[+ DEFINE param_arg +][+ (get "type") +] [+ (get "name") +]_arg[+ IF (exist? "dim")+][[+ (get "dim") +]][+ ENDIF +][+ 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) +].h: [+ description +] +// [+ (base-name) +].[+ (suffix) +]: [+ description +] // // Copyright (C) 2003 // ASTRON (Netherlands Foundation for Research in Astronomy) @@ -22,67 +25,180 @@ // // $Id$ // +[+ IF (== (suffix) "cc") +] +#include "[+ (base-name) +].ph" + +using namespace [+ (base-name) +]; +const char* [+ protocol_name +]_signalnames[] = +{ + "[+ protocol_name +]: invalid signal",[+ FOR event "," +] + "[+ signal_name +] ([+ (get "dir") +])"[+ ENDFOR +] +}; +[+ ELSE +] #ifndef [+ protocol_name +]_H #define [+ protocol_name +]_H +#ifdef SWIG +%module [+ (base-name) +] +%include GCF/GCF_Event.h +%include carrays.i +%include std_string.i +%include typemaps.i +%include array_typemaps.i +[+ FOR include "" +] +%include [+ (get "include") +][+ ENDFOR +] +[+ FOR unbounded_array_types "" +][+ FOR type "" +] +%array_class([+ (get "type") +], [+ (string-substitute (get "type") '( " " )' ( "_" )) +]_array) +[+ ENDFOR +][+ ENDFOR +] +%{ +#include "[+ (base-name) +].ph"[+ FOR include "" +] +#include [+ (get "include") +][+ ENDFOR +] #include <GCF/GCF_TMProtocols.h> +%} +#else [+ FOR include "" +] #include [+ (get "include") +][+ ENDFOR +] +#include <GCF/GCF_TMProtocols.h> +#include <string> +#endif -[+ (get "prelude") +] - -namespace [+ (base-name) +] -{ - // - // 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 +] - -[+ FOR event "" +][+ IF (< 0 (count "param")) +] - struct [+ struct_decl +] - { - [+ struct_name +]([+ FOR param "," +] - [+ param_arg +][+ ENDFOR +]) - : GCFEvent([+ signal_name +]),[+ FOR param "," +] - [+ (get "name") +]([+ IF (not (exist? "dim")) +][+ (get "name") +]_arg[+ ENDIF +])[+ ENDFOR +] - { - length = sizeof([+ struct_name +]); - - [+ FOR param "" +] - [+ IF (exist? "dim") +]memcpy([+ (get "name") +], [+ (get "name") +]_arg, [+ (get "dim") +]);[+ ENDIF +][+ ENDFOR +] - } - - [+ struct_name +]() : GCFEvent([+ signal_name +]) - { - length = sizeof([+ struct_name +]); - } - [+ FOR param ";" +] - [+ param +][+ ENDFOR +]; - }; -[+ ENDIF +][+ ENDFOR +] - -} // namespace [+ (base-name) +] - -using namespace [+ (base-name) +]; - -#ifdef DECLARE_SIGNAL_NAMES +// +// Define protocol ID +// +enum { + [+ protocol_name +] = [+ protocol_id +] +}; -const char* [+ protocol_name +]_signalnames[] = { - "[+ protocol_name +]: invalid signal",[+ FOR event "," +] - "[+ signal_name +]"[+ ENDFOR +] +// +// Define protocol message types +// +enum { [+ FOR event "," +] + [+ signal_id +][+ IF (= 0 (for-index)) +] = 1[+ ENDIF +][+ ENDFOR event +] }; -#else +[+ FOR event "" +] +#define [+ prefix_ucase +]_[+ (get "signal") +] F_SIGNAL([+ protocol_name +], [+ prefix_ucase +]_[+ (get "signal") +]_ID, F_[+ (get "dir")+])[+ ENDFOR event +] // extern declaration of protocol event names +#ifndef SWIG extern const char* [+ protocol_name +]_signalnames[]; - #endif +namespace [+ (base-name) +] +{[+ 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' are supported") +][+ ENDIF +][+ ENDFOR +] + class [+ event_class_decl +] + { + public: + [+ event_class_name +](GCFEvent& e); + [+ event_class_name +](); + virtual ~[+ event_class_name +](); + + [+ FOR param ";" +] + [+ IF (== (get "type") "string") +]std::[+ ENDIF +][+ event_class_member +][+ IF (*== (get "type") "[]") +]; unsigned int [+ (get "name") +]Dim[+ ENDIF +][+ ENDFOR +]; + + void* pack(unsigned int& 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 +](GCFEvent& e) + : GCFEvent(e)[+ FOR param "" +][+ IF (or (*== (get "type") "[]") (*== (get "type") "*")) +], + [+ (get "name") +](0)[+ ENDIF +][+ IF (*== (get "type") "[]") +], + [+ (get "name") +]Dim(0)[+ ENDIF +][+ ENDFOR +] +{ + unpack(); +} + +[+ event_class_name +]::[+ event_class_name +]() + : GCFEvent([+ signal_name +])[+ FOR param "" +][+ IF (or (*== (get "type") "[]") (*== (get "type") "*")) +], + [+ (get "name") +](0)[+ ENDIF +][+ IF (*== (get "type") "[]") +], + [+ (get "name") +]Dim(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(unsigned int& packsize) +{ + [+ FOR param "" +][+ IF (or (*== (get "type") "[]") (*== (get "type") "*")) +]assert([+ (get "name") +]);[+ ENDIF +] + [+ ENDFOR +] + unsigned int requiredSize = [+ IF (not (exist? "noheader")) +]sizeof(signal) + sizeof(length) + [+ 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(unsigned int)[+ ELSE +]sizeof([+ (get "name") +])[+ ENDIF+] + [+ ELIF (*== (get "type") "[]") +]sizeof([+ (get "name") +]Dim) + ([+ (get "name") +]Dim * sizeof([+ (get "name") +][0])) + [+ ELSE +]sizeof([+ (get "name") +])[+ ENDIF +][+ ENDFOR +]; + + resizeBuf(requiredSize); + unsigned int offset = 0; + [+ IF (not (exist? "noheader")) +] + 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 += packMember(offset, [+ (get "name") +].c_str(), [+ (get "name") +].length(), sizeof(char)); + [+ ELSE +] + memcpy(_buffer + offset, &[+ (get "name") +], sizeof([+ (get "type") +])); + offset += sizeof([+ (get "type") +]); + [+ ENDIF +] + [+ ELIF (*== (get "type") "[]") +] + offset += packMember(offset, [+ (get "name") +], [+ (get "name") +]Dim, sizeof([+ (get "name") +][0])); + [+ ELSE +] + memcpy(_buffer + offset, [+ (get "name") +], sizeof([+ (get "name") +])); + offset += sizeof([+ (get "name") +]); + [+ ENDIF +][+ ENDFOR +] + + packsize = offset; + return _buffer; +} + +void [+ event_class_name +]::unpack() +{ + [+ IF (not (exist? "noheader")) +] + if (length > 0) + { + unsigned int offset = sizeof(GCFEvent); + char* data = (char*) _base; + [+ 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 += 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") +]Dim, sizeof([+ (get "name") +][0])); + [+ ELSE +] + memcpy([+ (get "name") +], (data + offset), sizeof([+ (get "name") +])); + offset += sizeof([+ (get "name") +]); + [+ ENDIF +][+ ENDFOR +] + }[+ ENDIF +] +}[+ ENDIF +][+ ENDFOR +] +[+ IF (= (suffix) "ph") +] +} // namespace [+ (base-name) +] + + +using namespace [+ (base-name) +]; + #endif +[+ ENDIF +] diff --git a/MAC/Test/GCF/src/Application1.cc b/MAC/Test/GCF/src/Application1.cc index f9b61525ab58df0df146080204536748bb3b78ef..3bb36e78c3f636b75add9b22f3fb18345e3cdd32 100644 --- a/MAC/Test/GCF/src/Application1.cc +++ b/MAC/Test/GCF/src/Application1.cc @@ -49,7 +49,7 @@ GCFEvent::TResult Application::initial(GCFEvent& e, GCFPortInterface& /*p*/) switch (e.signal) { - case F_INIT_SIG: + case F_INIT: _supTask1.getPort().init(_supTask1, "client", GCFPortInterface::SAP, TST_PROTOCOL); _supTask2.getPort().init(_supTask2, "client", GCFPortInterface::SAP, TST_PROTOCOL); TRAN(Application::test401); @@ -70,7 +70,7 @@ GCFEvent::TResult Application::test101(GCFEvent& e, GCFPortInterface& p) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: if (_propertySetA1.load() != GCF_NO_ERROR) { failed(101); @@ -82,7 +82,7 @@ GCFEvent::TResult Application::test101(GCFEvent& e, GCFPortInterface& p) } break; - case F_MYPLOADED_SIG: + case F_MYPLOADED: { GCFMYPropAnswerEvent* pResponse = static_cast<GCFMYPropAnswerEvent*>(&e); assert(pResponse); @@ -100,7 +100,7 @@ GCFEvent::TResult Application::test101(GCFEvent& e, GCFPortInterface& p) ready = true; break; } - case F_TIMER_SIG: + case F_TIMER: if (!ready) {failed(101); ready = true;} else TRAN(Application::test102); break; @@ -120,7 +120,7 @@ GCFEvent::TResult Application::test102(GCFEvent& e, GCFPortInterface& p) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: if (_propertySetA1.unload() != GCF_NO_ERROR) { failed(102); @@ -132,7 +132,7 @@ GCFEvent::TResult Application::test102(GCFEvent& e, GCFPortInterface& p) } break; - case F_MYPUNLOADED_SIG: + case F_MYPUNLOADED: { GCFMYPropAnswerEvent* pResponse = static_cast<GCFMYPropAnswerEvent*>(&e); assert(pResponse); @@ -151,7 +151,7 @@ GCFEvent::TResult Application::test102(GCFEvent& e, GCFPortInterface& p) break; } - case F_TIMER_SIG: + case F_TIMER: if (!ready) {failed(102); ready = true;} else TRAN(Application::test103); break; @@ -171,7 +171,7 @@ GCFEvent::TResult Application::test103(GCFEvent& e, GCFPortInterface& p) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: if (_propertySetB1.load() != GCF_NO_ERROR) { failed(103); @@ -188,7 +188,7 @@ GCFEvent::TResult Application::test103(GCFEvent& e, GCFPortInterface& p) } break; - case F_MYPLOADED_SIG: + case F_MYPLOADED: { GCFMYPropAnswerEvent* pResponse = static_cast<GCFMYPropAnswerEvent*>(&e); assert(pResponse); @@ -208,7 +208,7 @@ GCFEvent::TResult Application::test103(GCFEvent& e, GCFPortInterface& p) ready = true; break; } - case F_TIMER_SIG: + case F_TIMER: if (!ready) {failed(103); ready = true;} else TRAN(Application::test104); break; @@ -228,7 +228,7 @@ GCFEvent::TResult Application::test104(GCFEvent& e, GCFPortInterface& p) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: if (_propertySetA1.load() != GCF_NO_ERROR) { failed(104); @@ -241,7 +241,7 @@ GCFEvent::TResult Application::test104(GCFEvent& e, GCFPortInterface& p) _counter = 1; break; - case F_MYPLOADED_SIG: + case F_MYPLOADED: { GCFMYPropAnswerEvent* pResponse = static_cast<GCFMYPropAnswerEvent*>(&e); assert(pResponse); @@ -305,7 +305,7 @@ GCFEvent::TResult Application::test104(GCFEvent& e, GCFPortInterface& p) } break; } - case F_MYPUNLOADED_SIG: + case F_MYPUNLOADED: { GCFMYPropAnswerEvent* pResponse = static_cast<GCFMYPropAnswerEvent*>(&e); assert(pResponse); @@ -369,7 +369,7 @@ GCFEvent::TResult Application::test104(GCFEvent& e, GCFPortInterface& p) } break; } - case F_TIMER_SIG: + case F_TIMER: if (!ready) {failed(104); ready = true;} else TRAN(Application::test105); break; @@ -389,7 +389,7 @@ GCFEvent::TResult Application::test105(GCFEvent& e, GCFPortInterface& p) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: if (_propertySetA1.load() != GCF_NO_ERROR) { failed(105); @@ -399,7 +399,7 @@ GCFEvent::TResult Application::test105(GCFEvent& e, GCFPortInterface& p) _counter = 1; break; - case F_MYPLOADED_SIG: + case F_MYPLOADED: { GCFMYPropAnswerEvent* pResponse = static_cast<GCFMYPropAnswerEvent*>(&e); assert(pResponse); @@ -434,14 +434,15 @@ GCFEvent::TResult Application::test105(GCFEvent& e, GCFPortInterface& p) } break; } - case F_TIMER_SIG: + case F_TIMER: if (!ready) {failed(105); ready = true;} else TRAN(Application::test201); break; - case F_EXIT_SIG: + case F_EXIT: { - TSTTestreadyEvent r(105); + TSTTestreadyEvent r; + r.testnr = 105; if (_supTask1.getPort().isConnected()) _supTask1.getPort().send(r); break; @@ -460,16 +461,15 @@ GCFEvent::TResult Application::test201(GCFEvent& e, GCFPortInterface& /*p*/) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: skipped(201); TRAN(Application::test202); break; case TST_TESTREADY: { - TSTTestreadyEvent* pIndication = static_cast<TSTTestreadyEvent*>(&e); - assert(pIndication); - _curRemoteTestNr = pIndication->testnr; + TSTTestreadyEvent indicationIn(e); + _curRemoteTestNr = indicationIn.testnr; break; } @@ -487,16 +487,15 @@ GCFEvent::TResult Application::test202(GCFEvent& e, GCFPortInterface& /*p*/) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: skipped(202); TRAN(Application::test203); break; case TST_TESTREADY: { - TSTTestreadyEvent* pIndication = static_cast<TSTTestreadyEvent*>(&e); - assert(pIndication); - _curRemoteTestNr = pIndication->testnr; + TSTTestreadyEvent indicationIn(e); + _curRemoteTestNr = indicationIn.testnr; break; } @@ -514,16 +513,15 @@ GCFEvent::TResult Application::test203(GCFEvent& e, GCFPortInterface& /*p*/) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: skipped(203); TRAN(Application::test204); break; case TST_TESTREADY: { - TSTTestreadyEvent* pIndication = static_cast<TSTTestreadyEvent*>(&e); - assert(pIndication); - _curRemoteTestNr = pIndication->testnr; + TSTTestreadyEvent indicationIn(e); + _curRemoteTestNr = indicationIn.testnr; break; } @@ -541,16 +539,15 @@ GCFEvent::TResult Application::test204(GCFEvent& e, GCFPortInterface& /*p*/) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: skipped(204); TRAN(Application::test205); break; case TST_TESTREADY: { - TSTTestreadyEvent* pIndication = static_cast<TSTTestreadyEvent*>(&e); - assert(pIndication); - _curRemoteTestNr = pIndication->testnr; + TSTTestreadyEvent indicationIn(e); + _curRemoteTestNr = indicationIn.testnr; break; } @@ -570,14 +567,14 @@ GCFEvent::TResult Application::test205(GCFEvent& e, GCFPortInterface& p) { case TST_TESTREADY: { - TSTTestreadyEvent* pIndication = static_cast<TSTTestreadyEvent*>(&e); - assert(pIndication); + TSTTestreadyEvent indicationIn(e); if (_curRemoteTestNr == 0) - _curRemoteTestNr = pIndication->testnr; + _curRemoteTestNr = indicationIn.testnr; + //intentional fall through else break; } - case F_ENTRY_SIG: + case F_ENTRY: if (_curRemoteTestNr == 0) break; if (_apcT1.load() != GCF_NO_ERROR) { @@ -587,7 +584,7 @@ GCFEvent::TResult Application::test205(GCFEvent& e, GCFPortInterface& p) _counter = 1; break; - case F_APCLOADED_SIG: + case F_APCLOADED: { GCFAPCAnswerEvent* pResponse = static_cast<GCFAPCAnswerEvent*>(&e); assert(pResponse); @@ -607,7 +604,8 @@ GCFEvent::TResult Application::test205(GCFEvent& e, GCFPortInterface& p) } else { - TSTTestreadyEvent r(205); + TSTTestreadyEvent r; + r.testnr = 205; _supTask1.getPort().send(r); } } @@ -617,7 +615,7 @@ GCFEvent::TResult Application::test205(GCFEvent& e, GCFPortInterface& p) break; } - case F_APCUNLOADED_SIG: + case F_APCUNLOADED: { GCFAPCAnswerEvent* pResponse = static_cast<GCFAPCAnswerEvent*>(&e); assert(pResponse); @@ -640,9 +638,10 @@ GCFEvent::TResult Application::test205(GCFEvent& e, GCFPortInterface& p) break; } - case F_EXIT_SIG: + case F_EXIT: { - TSTTestreadyEvent r(205); + TSTTestreadyEvent r; + r.testnr = 205; _supTask1.getPort().send(r); break; } @@ -660,15 +659,14 @@ GCFEvent::TResult Application::test206(GCFEvent& e, GCFPortInterface& p) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: _counter = 0; break; case TST_TESTREADY: { - TSTTestreadyEvent* pIndication = static_cast<TSTTestreadyEvent*>(&e); - assert(pIndication); - _curRemoteTestNr = pIndication->testnr; + TSTTestreadyEvent indicationIn(e); + _curRemoteTestNr = indicationIn.testnr; if (_apcT1.load() != GCF_NO_ERROR) { failed(206); @@ -680,7 +678,7 @@ GCFEvent::TResult Application::test206(GCFEvent& e, GCFPortInterface& p) } break; } - case F_APCLOADED_SIG: + case F_APCLOADED: { GCFAPCAnswerEvent* pResponse = static_cast<GCFAPCAnswerEvent*>(&e); assert(pResponse); @@ -699,7 +697,8 @@ GCFEvent::TResult Application::test206(GCFEvent& e, GCFPortInterface& p) } else { - TSTTestreadyEvent r(206); + TSTTestreadyEvent r; + r.testnr = 206; _supTask1.getPort().send(r); _counter++; } @@ -708,7 +707,7 @@ GCFEvent::TResult Application::test206(GCFEvent& e, GCFPortInterface& p) break; } - case F_APCUNLOADED_SIG: + case F_APCUNLOADED: { GCFAPCAnswerEvent* pResponse = static_cast<GCFAPCAnswerEvent*>(&e); assert(pResponse); @@ -729,9 +728,10 @@ GCFEvent::TResult Application::test206(GCFEvent& e, GCFPortInterface& p) break; } - case F_EXIT_SIG: + case F_EXIT: { - TSTTestreadyEvent r(206); + TSTTestreadyEvent r; + r.testnr = 206; _supTask1.getPort().send(r); break; } @@ -750,16 +750,15 @@ GCFEvent::TResult Application::test207(GCFEvent& e, GCFPortInterface& /*p*/) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: skipped(207); TRAN(Application::test208); break; case TST_TESTREADY: { - TSTTestreadyEvent* pIndication = static_cast<TSTTestreadyEvent*>(&e); - assert(pIndication); - _curRemoteTestNr = pIndication->testnr; + TSTTestreadyEvent indicationIn(e); + _curRemoteTestNr = indicationIn.testnr; break; } @@ -779,11 +778,11 @@ GCFEvent::TResult Application::test208(GCFEvent& e, GCFPortInterface& p) { case TST_TESTREADY: { - TSTTestreadyEvent* pIndication = static_cast<TSTTestreadyEvent*>(&e); - assert(pIndication); - _curRemoteTestNr = pIndication->testnr; + TSTTestreadyEvent indicationIn(e); + _curRemoteTestNr = indicationIn.testnr; + //intentional fall through } - case F_ENTRY_SIG: + case F_ENTRY: if (_curRemoteTestNr != 208) break; if (_apcT3.load(false) != GCF_NO_ERROR) { @@ -795,7 +794,7 @@ GCFEvent::TResult Application::test208(GCFEvent& e, GCFPortInterface& p) _counter = 1; } break; - case F_APCLOADED_SIG: + case F_APCLOADED: { GCFAPCAnswerEvent* pResponse = static_cast<GCFAPCAnswerEvent*>(&e); assert(pResponse); @@ -827,7 +826,7 @@ GCFEvent::TResult Application::test208(GCFEvent& e, GCFPortInterface& p) break; } - case F_APCUNLOADED_SIG: + case F_APCUNLOADED: { GCFAPCAnswerEvent* pResponse = static_cast<GCFAPCAnswerEvent*>(&e); assert(pResponse); @@ -862,7 +861,7 @@ GCFEvent::TResult Application::test209(GCFEvent& e, GCFPortInterface& /*p*/) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: break; default: @@ -879,7 +878,7 @@ GCFEvent::TResult Application::test210(GCFEvent& e, GCFPortInterface& /*p*/) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: break; default: @@ -898,7 +897,7 @@ GCFEvent::TResult Application::test301(GCFEvent& e, GCFPortInterface& p) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: if (_propertySetB1.unload() != GCF_NO_ERROR) { failed(301); @@ -908,7 +907,7 @@ GCFEvent::TResult Application::test301(GCFEvent& e, GCFPortInterface& p) _counter = 1; break; - case F_MYPUNLOADED_SIG: + case F_MYPUNLOADED: { GCFMYPropAnswerEvent* pResponse = static_cast<GCFMYPropAnswerEvent*>(&e); assert(pResponse); @@ -930,7 +929,7 @@ GCFEvent::TResult Application::test301(GCFEvent& e, GCFPortInterface& p) break; } - case F_MYPLOADED_SIG: + case F_MYPLOADED: { GCFMYPropAnswerEvent* pResponse = static_cast<GCFMYPropAnswerEvent*>(&e); assert(pResponse); @@ -1045,7 +1044,7 @@ GCFEvent::TResult Application::test302(GCFEvent& e, GCFPortInterface& p) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: _apcT1.setAnswer(&_supTask1.getAnswerObj()); if (_apcT1.load(false) != GCF_NO_ERROR) { @@ -1054,7 +1053,7 @@ GCFEvent::TResult Application::test302(GCFEvent& e, GCFPortInterface& p) } break; - case F_APCLOADED_SIG: + case F_APCLOADED: { GCFAPCAnswerEvent* pResponse = static_cast<GCFAPCAnswerEvent*>(&e); assert(pResponse); @@ -1080,7 +1079,7 @@ GCFEvent::TResult Application::test302(GCFEvent& e, GCFPortInterface& p) } break; } - case F_VGETRESP_SIG: + case F_VGETRESP: { GCFPropValueEvent* pResponse = static_cast<GCFPropValueEvent*>(&e); assert(pResponse); @@ -1163,7 +1162,7 @@ GCFEvent::TResult Application::test302(GCFEvent& e, GCFPortInterface& p) } break; } - case F_VCHANGEMSG_SIG: + case F_VCHANGEMSG: { GCFPropValueEvent* pResponse = static_cast<GCFPropValueEvent*>(&e); assert(pResponse); @@ -1183,9 +1182,10 @@ GCFEvent::TResult Application::test302(GCFEvent& e, GCFPortInterface& p) } break; } - case F_EXIT_SIG: + case F_EXIT: { - TSTTestreadyEvent r(302); + TSTTestreadyEvent r; + r.testnr = 302; _supTask1.getPort().send(r); break; } @@ -1204,14 +1204,13 @@ GCFEvent::TResult Application::test303(GCFEvent& e, GCFPortInterface& p) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: break; case TST_TESTREADY: { - TSTTestreadyEvent* pIndication = static_cast<TSTTestreadyEvent*>(&e); - assert(pIndication); - _curRemoteTestNr = pIndication->testnr; + TSTTestreadyEvent indicationIn(e); + _curRemoteTestNr = indicationIn.testnr; if (_curRemoteTestNr == 303) { GCFPVInteger iv(22); @@ -1223,7 +1222,7 @@ GCFEvent::TResult Application::test303(GCFEvent& e, GCFPortInterface& p) } break; } - case F_VCHANGEMSG_SIG: + case F_VCHANGEMSG: { GCFPropValueEvent* pResponse = static_cast<GCFPropValueEvent*>(&e); assert(pResponse); @@ -1258,7 +1257,7 @@ GCFEvent::TResult Application::test304(GCFEvent& e, GCFPortInterface& p) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: _counter = 0; if (_apcT3.load(false) != GCF_NO_ERROR) { @@ -1267,7 +1266,7 @@ GCFEvent::TResult Application::test304(GCFEvent& e, GCFPortInterface& p) } break; - case F_APCLOADED_SIG: + case F_APCLOADED: { GCFAPCAnswerEvent* pResponse = static_cast<GCFAPCAnswerEvent*>(&e); assert(pResponse); @@ -1297,7 +1296,7 @@ GCFEvent::TResult Application::test304(GCFEvent& e, GCFPortInterface& p) } break; } - case F_SUBSCRIBED_SIG: + case F_SUBSCRIBED: { GCFPropAnswerEvent* pResponse = static_cast<GCFPropAnswerEvent*>(&e); assert(pResponse); @@ -1307,7 +1306,8 @@ GCFEvent::TResult Application::test304(GCFEvent& e, GCFPortInterface& p) _counter--; if (_counter == 0) { - TSTTestreadyEvent r(304); + TSTTestreadyEvent r; + r.testnr = 304; _supTask1.getPort().send(r); } } @@ -1318,7 +1318,7 @@ GCFEvent::TResult Application::test304(GCFEvent& e, GCFPortInterface& p) } break; } - case F_VCHANGEMSG_SIG: + case F_VCHANGEMSG: { GCFPropValueEvent* pResponse = static_cast<GCFPropValueEvent*>(&e); assert(pResponse); @@ -1358,9 +1358,8 @@ GCFEvent::TResult Application::test304(GCFEvent& e, GCFPortInterface& p) } case TST_TESTREADY: { - TSTTestreadyEvent* pIndication = static_cast<TSTTestreadyEvent*>(&e); - assert(pIndication); - _curRemoteTestNr = pIndication->testnr; + TSTTestreadyEvent indicationIn(e); + _curRemoteTestNr = indicationIn.testnr; break; } @@ -1386,11 +1385,11 @@ GCFEvent::TResult Application::test305(GCFEvent& e, GCFPortInterface& p) { case TST_TESTREADY: { - TSTTestreadyEvent* pIndication = static_cast<TSTTestreadyEvent*>(&e); - assert(pIndication); - _curRemoteTestNr = pIndication->testnr; + TSTTestreadyEvent indicationIn(e); + _curRemoteTestNr = indicationIn.testnr; + //intentional fall through } - case F_ENTRY_SIG: + case F_ENTRY: if (_curRemoteTestNr != 305) break; _counter = 0; if (propertyAHJP00_1.subscribe() != GCF_NO_ERROR) @@ -1400,7 +1399,7 @@ GCFEvent::TResult Application::test305(GCFEvent& e, GCFPortInterface& p) } break; - case F_SUBSCRIBED_SIG: + case F_SUBSCRIBED: { GCFPropAnswerEvent* pResponse = static_cast<GCFPropAnswerEvent*>(&e); assert(pResponse); @@ -1416,7 +1415,8 @@ GCFEvent::TResult Application::test305(GCFEvent& e, GCFPortInterface& p) } else if (&p == &_supTask2.getPort()) { - TSTTestreadyEvent r(305); + TSTTestreadyEvent r; + r.testnr = 305; _supTask1.getPort().send(r); } } @@ -1428,7 +1428,7 @@ GCFEvent::TResult Application::test305(GCFEvent& e, GCFPortInterface& p) break; } - case F_VCHANGEMSG_SIG: + case F_VCHANGEMSG: { GCFPropValueEvent* pResponse = static_cast<GCFPropValueEvent*>(&e); assert(pResponse); @@ -1476,11 +1476,11 @@ GCFEvent::TResult Application::test306(GCFEvent& e, GCFPortInterface& /*p*/) { case TST_TESTREADY: { - TSTTestreadyEvent* pIndication = static_cast<TSTTestreadyEvent*>(&e); - assert(pIndication); - _curRemoteTestNr = pIndication->testnr; + TSTTestreadyEvent indicationIn(e); + _curRemoteTestNr = indicationIn.testnr; + //intentional fall through } - case F_ENTRY_SIG: + case F_ENTRY: if (_curRemoteTestNr != 306) break; if (propertyACP1.subscribe() != GCF_NO_ERROR) @@ -1490,7 +1490,7 @@ GCFEvent::TResult Application::test306(GCFEvent& e, GCFPortInterface& /*p*/) } break; - case F_SUBSCRIBED_SIG: + case F_SUBSCRIBED: { GCFPropAnswerEvent* pResponse = static_cast<GCFPropAnswerEvent*>(&e); assert(pResponse); @@ -1512,7 +1512,7 @@ GCFEvent::TResult Application::test306(GCFEvent& e, GCFPortInterface& /*p*/) break; } - case F_VCHANGEMSG_SIG: + case F_VCHANGEMSG: { GCFPropValueEvent* pResponse = static_cast<GCFPropValueEvent*>(&e); assert(pResponse); @@ -1550,9 +1550,10 @@ GCFEvent::TResult Application::test306(GCFEvent& e, GCFPortInterface& /*p*/) break; } - case F_EXIT_SIG: + case F_EXIT: { - TSTTestreadyEvent r(306); + TSTTestreadyEvent r; + r.testnr = 306; _supTask1.getPort().send(r); break; } @@ -1570,22 +1571,23 @@ GCFEvent::TResult Application::test401(GCFEvent& e, GCFPortInterface& p) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: _supTask1.getPort().init(_supTask1, "client", GCFPortInterface::SAP, TST_PROTOCOL); _supTask1.getPort().open(); break; - case F_TIMER_SIG: + case F_TIMER: _supTask1.getPort().open(); break; - case F_CONNECTED_SIG: + case F_CONNECTED: { - TSTTestreqEvent r(401); + TSTTestreqEvent r; + r.testnr = 401; _supTask1.getPort().send(r); break; } - case F_DISCONNECTED_SIG: + case F_DISCONNECTED: if (&p == &_supTask1.getPort()) _supTask1.getPort().setTimer(1.0); // try again after 1 second break; @@ -1611,24 +1613,25 @@ GCFEvent::TResult Application::test402(GCFEvent& e, GCFPortInterface& p) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: closing = true; break; - case F_TIMER_SIG: + case F_TIMER: if (&p == &_supTask1.getPort()) _supTask1.getPort().open(); if (&p == &_supTask2.getPort()) _supTask2.getPort().open(); break; - case F_CONNECTED_SIG: + case F_CONNECTED: { if (_supTask1.getPort().isConnected()) { if (_supTask2.getPort().isConnected()) { - TSTTestreqEvent r(402); + TSTTestreqEvent r; + r.testnr = 402; _supTask1.getPort().send(r); } else @@ -1637,7 +1640,7 @@ GCFEvent::TResult Application::test402(GCFEvent& e, GCFPortInterface& p) break; } - case F_DISCONNECTED_SIG: + case F_DISCONNECTED: if (closing) { _supTask2.getPort().init(_supTask2, "client", GCFPortInterface::SAP, TST_PROTOCOL); @@ -1656,12 +1659,14 @@ GCFEvent::TResult Application::test402(GCFEvent& e, GCFPortInterface& p) case TST_TESTRESP: if (&p == &_supTask1.getPort()) { - TSTTestreqEvent r(402); + TSTTestreqEvent r; + r.testnr = 402; _supTask2.getPort().send(r); } else { - TSTTestreadyEvent r(402); + TSTTestreadyEvent r; + r.testnr = 402; _supTask1.getPort().send(r); } break; @@ -1688,12 +1693,12 @@ GCFEvent::TResult Application::test501(GCFEvent& e, GCFPortInterface& /*p*/) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: apc1.load(false); _counter = 0; break; - case F_APCLOADED_SIG: + case F_APCLOADED: { GCFAPCAnswerEvent* pResponse = static_cast<GCFAPCAnswerEvent*>(&e); assert(pResponse); @@ -1704,7 +1709,7 @@ GCFEvent::TResult Application::test501(GCFEvent& e, GCFPortInterface& /*p*/) } break; } - case F_APCUNLOADED_SIG: + case F_APCUNLOADED: { GCFAPCAnswerEvent* pResponse = static_cast<GCFAPCAnswerEvent*>(&e); assert(pResponse); @@ -1713,7 +1718,8 @@ GCFEvent::TResult Application::test501(GCFEvent& e, GCFPortInterface& /*p*/) { if (apc2.unload() != GCF_NO_ERROR) { - TSTTestreadyEvent r(501); + TSTTestreadyEvent r; + r.testnr = 501; if (_supTask1.getPort().isConnected()) _supTask1.getPort().send(r); passed(501); @@ -1722,7 +1728,8 @@ GCFEvent::TResult Application::test501(GCFEvent& e, GCFPortInterface& /*p*/) } else { - TSTTestreadyEvent r(501); + TSTTestreadyEvent r; + r.testnr = 501; if (_supTask1.getPort().isConnected()) _supTask1.getPort().send(r); passed(501); @@ -1730,7 +1737,7 @@ GCFEvent::TResult Application::test501(GCFEvent& e, GCFPortInterface& /*p*/) } break; } - case F_TIMER_SIG: + case F_TIMER: { GCFTimerEvent* pTIM = static_cast<GCFTimerEvent*>(&e); assert(pTIM); @@ -1773,7 +1780,7 @@ GCFEvent::TResult Application::finished(GCFEvent& e, GCFPortInterface& /*p*/) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: fprintf(stderr, "Ready with tests: passed %d, failed %d\n", _passed, _failed); GCFTask::stop(); break; diff --git a/MAC/Test/GCF/src/Application2.cc b/MAC/Test/GCF/src/Application2.cc index b5df4ed110e98381e4e18c96a0080ff436e5a1fa..f0b575f7d7f56e760db745bc0a6fd0b15ebce2c6 100644 --- a/MAC/Test/GCF/src/Application2.cc +++ b/MAC/Test/GCF/src/Application2.cc @@ -49,7 +49,7 @@ GCFEvent::TResult Application::initial(GCFEvent& e, GCFPortInterface& /*p*/) switch (e.signal) { - case F_INIT_SIG: + case F_INIT: _supTask3.getPort().init(_supTask3, "server", GCFPortInterface::SPP, TST_PROTOCOL); TRAN(Application::test401); break; @@ -68,16 +68,15 @@ GCFEvent::TResult Application::test101(GCFEvent& e, GCFPortInterface& /*p*/) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: skipped(101); TRAN(Application::test102); break; case TST_TESTREADY: { - TSTTestreadyEvent* pIndication = static_cast<TSTTestreadyEvent*>(&e); - assert(pIndication); - _curRemoteTestNr = pIndication->testnr; + TSTTestreadyEvent indicationIn(e); + _curRemoteTestNr = indicationIn.testnr; break; } default: @@ -94,16 +93,15 @@ GCFEvent::TResult Application::test102(GCFEvent& e, GCFPortInterface& /*p*/) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: skipped(102); TRAN(Application::test103); break; case TST_TESTREADY: { - TSTTestreadyEvent* pIndication = static_cast<TSTTestreadyEvent*>(&e); - assert(pIndication); - _curRemoteTestNr = pIndication->testnr; + TSTTestreadyEvent indicationIn(e); + _curRemoteTestNr = indicationIn.testnr; break; } default: @@ -120,16 +118,15 @@ GCFEvent::TResult Application::test103(GCFEvent& e, GCFPortInterface& /*p*/) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: skipped(103); TRAN(Application::test104); break; case TST_TESTREADY: { - TSTTestreadyEvent* pIndication = static_cast<TSTTestreadyEvent*>(&e); - assert(pIndication); - _curRemoteTestNr = pIndication->testnr; + TSTTestreadyEvent indicationIn(e); + _curRemoteTestNr = indicationIn.testnr; break; } default: @@ -150,14 +147,14 @@ GCFEvent::TResult Application::test104(GCFEvent& e, GCFPortInterface& p) { case TST_TESTREADY: { - TSTTestreadyEvent* pIndication = static_cast<TSTTestreadyEvent*>(&e); - assert(pIndication); + TSTTestreadyEvent indicationIn(e); if (_curRemoteTestNr == 0) - _curRemoteTestNr = pIndication->testnr; + _curRemoteTestNr = indicationIn.testnr; + //intentional fall through else break; } - case F_ENTRY_SIG: + case F_ENTRY: if (_curRemoteTestNr == 0) break; if (_propertySetC1.load() != GCF_NO_ERROR) { @@ -171,7 +168,7 @@ GCFEvent::TResult Application::test104(GCFEvent& e, GCFPortInterface& p) } break; - case F_MYPLOADED_SIG: + case F_MYPLOADED: { GCFMYPropAnswerEvent* pResponse = static_cast<GCFMYPropAnswerEvent*>(&e); assert(pResponse); @@ -207,7 +204,7 @@ GCFEvent::TResult Application::test104(GCFEvent& e, GCFPortInterface& p) } break; } - case F_MYPUNLOADED_SIG: + case F_MYPUNLOADED: { GCFMYPropAnswerEvent* pResponse = static_cast<GCFMYPropAnswerEvent*>(&e); assert(pResponse); @@ -243,7 +240,7 @@ GCFEvent::TResult Application::test104(GCFEvent& e, GCFPortInterface& p) } break; } - case F_TIMER_SIG: + case F_TIMER: if (!ready) {failed(104); ready = true;} else TRAN(Application::test105); break; @@ -263,7 +260,7 @@ GCFEvent::TResult Application::test105(GCFEvent& e, GCFPortInterface& p) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: if (_propertySetC1.load() != GCF_NO_ERROR) { failed(105); @@ -275,7 +272,7 @@ GCFEvent::TResult Application::test105(GCFEvent& e, GCFPortInterface& p) } break; - case F_MYPLOADED_SIG: + case F_MYPLOADED: { GCFMYPropAnswerEvent* pResponse = static_cast<GCFMYPropAnswerEvent*>(&e); assert(pResponse); @@ -312,9 +309,8 @@ GCFEvent::TResult Application::test105(GCFEvent& e, GCFPortInterface& p) case TST_TESTREADY: { - TSTTestreadyEvent* pIndication = static_cast<TSTTestreadyEvent*>(&e); - assert(pIndication); - _curRemoteTestNr = pIndication->testnr; + TSTTestreadyEvent indicationIn(e); + _curRemoteTestNr = indicationIn.testnr; break; } default: @@ -334,11 +330,11 @@ GCFEvent::TResult Application::test201(GCFEvent& e, GCFPortInterface& p) { case TST_TESTREADY: { - TSTTestreadyEvent* pIndication = static_cast<TSTTestreadyEvent*>(&e); - assert(pIndication); - _curRemoteTestNr = pIndication->testnr; + TSTTestreadyEvent indicationIn(e); + _curRemoteTestNr = indicationIn.testnr; + //intentional fall through } - case F_ENTRY_SIG: + case F_ENTRY: if (_curRemoteTestNr != 105) break; if (_apcT1.load() != GCF_NO_ERROR) { @@ -352,7 +348,7 @@ GCFEvent::TResult Application::test201(GCFEvent& e, GCFPortInterface& p) } break; - case F_APCLOADED_SIG: + case F_APCLOADED: { GCFAPCAnswerEvent* pResponse = static_cast<GCFAPCAnswerEvent*>(&e); assert(pResponse); @@ -375,7 +371,7 @@ GCFEvent::TResult Application::test201(GCFEvent& e, GCFPortInterface& p) } break; } - case F_APCUNLOADED_SIG: + case F_APCUNLOADED: { GCFAPCAnswerEvent* pResponse = static_cast<GCFAPCAnswerEvent*>(&e); assert(pResponse); @@ -398,7 +394,7 @@ GCFEvent::TResult Application::test201(GCFEvent& e, GCFPortInterface& p) } break; } - case F_TIMER_SIG: + case F_TIMER: if (!ready) {failed(201); ready = true;} else TRAN(Application::test202); break; @@ -418,7 +414,7 @@ GCFEvent::TResult Application::test202(GCFEvent& e, GCFPortInterface& p) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: if (_apcT1.load(false) != GCF_NO_ERROR) { failed(202); @@ -431,7 +427,7 @@ GCFEvent::TResult Application::test202(GCFEvent& e, GCFPortInterface& p) } break; - case F_APCLOADED_SIG: + case F_APCLOADED: { GCFAPCAnswerEvent* pResponse = static_cast<GCFAPCAnswerEvent*>(&e); assert(pResponse); @@ -455,7 +451,7 @@ GCFEvent::TResult Application::test202(GCFEvent& e, GCFPortInterface& p) } break; } - case F_TIMER_SIG: + case F_TIMER: if (!ready) {failed(202); ready = true;} else TRAN(Application::test203); break; @@ -474,7 +470,7 @@ GCFEvent::TResult Application::test203(GCFEvent& e, GCFPortInterface& p) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: if (_apcT1.unload() != GCF_NO_ERROR) { failed(203); @@ -486,7 +482,7 @@ GCFEvent::TResult Application::test203(GCFEvent& e, GCFPortInterface& p) } break; - case F_APCUNLOADED_SIG: + case F_APCUNLOADED: { GCFAPCAnswerEvent* pResponse = static_cast<GCFAPCAnswerEvent*>(&e); assert(pResponse); @@ -522,7 +518,7 @@ GCFEvent::TResult Application::test204(GCFEvent& e, GCFPortInterface& p) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: if (_apcT1.load() != GCF_NO_ERROR) { failed(204); @@ -534,7 +530,7 @@ GCFEvent::TResult Application::test204(GCFEvent& e, GCFPortInterface& p) } break; - case F_APCLOADED_SIG: + case F_APCLOADED: { GCFAPCAnswerEvent* pResponse = static_cast<GCFAPCAnswerEvent*>(&e); assert(pResponse); @@ -557,7 +553,7 @@ GCFEvent::TResult Application::test204(GCFEvent& e, GCFPortInterface& p) } break; } - case F_APCRELOADED_SIG: + case F_APCRELOADED: { GCFAPCAnswerEvent* pResponse = static_cast<GCFAPCAnswerEvent*>(&e); assert(pResponse); @@ -595,18 +591,18 @@ GCFEvent::TResult Application::test205(GCFEvent& e, GCFPortInterface& p) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: { - TSTTestreadyEvent r(204); + TSTTestreadyEvent r; + r.testnr = 204; assert(_pSTPort1); _pSTPort1->send(r); break; } case TST_TESTREADY: { - TSTTestreadyEvent* pIndication = static_cast<TSTTestreadyEvent*>(&e); - assert(pIndication); - _curRemoteTestNr = pIndication->testnr; + TSTTestreadyEvent indicationIn(e); + _curRemoteTestNr = indicationIn.testnr; if (started) { if (ready) TRAN(Application::test206) @@ -627,7 +623,7 @@ GCFEvent::TResult Application::test205(GCFEvent& e, GCFPortInterface& p) } break; } - case F_APCUNLOADED_SIG: + case F_APCUNLOADED: { GCFAPCAnswerEvent* pResponse = static_cast<GCFAPCAnswerEvent*>(&e); assert(pResponse); @@ -665,7 +661,7 @@ GCFEvent::TResult Application::test206(GCFEvent& e, GCFPortInterface& p) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: _counter = 0; if (_apcT1.load() != GCF_NO_ERROR) { @@ -680,9 +676,8 @@ GCFEvent::TResult Application::test206(GCFEvent& e, GCFPortInterface& p) case TST_TESTREADY: { - TSTTestreadyEvent* pIndication = static_cast<TSTTestreadyEvent*>(&e); - assert(pIndication); - _curRemoteTestNr = pIndication->testnr; + TSTTestreadyEvent indicationIn(e); + _curRemoteTestNr = indicationIn.testnr; if (_counter == 2) { if (_apcT1.unload() != GCF_NO_ERROR) @@ -694,7 +689,7 @@ GCFEvent::TResult Application::test206(GCFEvent& e, GCFPortInterface& p) } break; } - case F_APCLOADED_SIG: + case F_APCLOADED: { GCFAPCAnswerEvent* pResponse = static_cast<GCFAPCAnswerEvent*>(&e); assert(pResponse); @@ -715,7 +710,7 @@ GCFEvent::TResult Application::test206(GCFEvent& e, GCFPortInterface& p) } break; } - case F_APCRELOADED_SIG: + case F_APCRELOADED: { GCFAPCAnswerEvent* pResponse = static_cast<GCFAPCAnswerEvent*>(&e); @@ -727,14 +722,15 @@ GCFEvent::TResult Application::test206(GCFEvent& e, GCFPortInterface& p) (pResponse->result == GCF_NO_ERROR) && (&p == &_supTask3.getPort())) { - TSTTestreadyEvent r(206); + TSTTestreadyEvent r; + r.testnr = 206; assert(_pSTPort1); _pSTPort1->send(r); } } break; } - case F_APCUNLOADED_SIG: + case F_APCUNLOADED: { GCFAPCAnswerEvent* pResponse = static_cast<GCFAPCAnswerEvent*>(&e); assert(pResponse); @@ -771,14 +767,14 @@ GCFEvent::TResult Application::test207(GCFEvent& e, GCFPortInterface& p) { case TST_TESTREADY: { - TSTTestreadyEvent* pIndication = static_cast<TSTTestreadyEvent*>(&e); - assert(pIndication); + TSTTestreadyEvent indicationIn(e); if (_curRemoteTestNr == 0) - _curRemoteTestNr = pIndication->testnr; + _curRemoteTestNr = indicationIn.testnr; + //intentional fall through else break; } - case F_ENTRY_SIG: + case F_ENTRY: if (_curRemoteTestNr == 0) break; if (_apcT1a.load(false) != GCF_NO_ERROR) { @@ -791,7 +787,7 @@ GCFEvent::TResult Application::test207(GCFEvent& e, GCFPortInterface& p) } break; - case F_APCLOADED_SIG: + case F_APCLOADED: { GCFAPCAnswerEvent* pResponse = static_cast<GCFAPCAnswerEvent*>(&e); assert(pResponse); @@ -814,7 +810,7 @@ GCFEvent::TResult Application::test207(GCFEvent& e, GCFPortInterface& p) } break; } - case F_APCUNLOADED_SIG: + case F_APCUNLOADED: { GCFAPCAnswerEvent* pResponse = static_cast<GCFAPCAnswerEvent*>(&e); assert(pResponse); @@ -850,7 +846,7 @@ GCFEvent::TResult Application::test208(GCFEvent& e, GCFPortInterface& p) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: if (_apcT1b.load(false) != GCF_NO_ERROR) { failed(208); @@ -862,7 +858,7 @@ GCFEvent::TResult Application::test208(GCFEvent& e, GCFPortInterface& p) } break; - case F_APCLOADED_SIG: + case F_APCLOADED: { GCFAPCAnswerEvent* pResponse = static_cast<GCFAPCAnswerEvent*>(&e); assert(pResponse); @@ -890,7 +886,7 @@ GCFEvent::TResult Application::test208(GCFEvent& e, GCFPortInterface& p) } break; } - case F_APCUNLOADED_SIG: + case F_APCUNLOADED: { GCFAPCAnswerEvent* pResponse = static_cast<GCFAPCAnswerEvent*>(&e); assert(pResponse); @@ -912,9 +908,10 @@ GCFEvent::TResult Application::test208(GCFEvent& e, GCFPortInterface& p) break; } - case F_EXIT_SIG: + case F_EXIT: { - TSTTestreadyEvent r(208); + TSTTestreadyEvent r; + r.testnr = 208; assert(_pSTPort1); _pSTPort1->send(r); break; @@ -935,14 +932,13 @@ GCFEvent::TResult Application::test209(GCFEvent& e, GCFPortInterface& p) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: break; case TST_TESTREADY: { - TSTTestreadyEvent* pIndication = static_cast<TSTTestreadyEvent*>(&e); - assert(pIndication); - _curRemoteTestNr = pIndication->testnr; + TSTTestreadyEvent indicationIn(e); + _curRemoteTestNr = indicationIn.testnr; _apcT3.setScope("A_C"); if (_apcT3.load(false) != GCF_NO_ERROR) { @@ -955,7 +951,7 @@ GCFEvent::TResult Application::test209(GCFEvent& e, GCFPortInterface& p) } break; } - case F_APCLOADED_SIG: + case F_APCLOADED: { GCFAPCAnswerEvent* pResponse = static_cast<GCFAPCAnswerEvent*>(&e); assert(pResponse); @@ -992,7 +988,7 @@ GCFEvent::TResult Application::test210(GCFEvent& e, GCFPortInterface& /*p*/) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: break; default: @@ -1009,16 +1005,15 @@ GCFEvent::TResult Application::test301(GCFEvent& e, GCFPortInterface& /*p*/) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: skipped(301); TRAN(Application::test302); break; case TST_TESTREADY: { - TSTTestreadyEvent* pIndication = static_cast<TSTTestreadyEvent*>(&e); - assert(pIndication); - _curRemoteTestNr = pIndication->testnr; + TSTTestreadyEvent indicationIn(e); + _curRemoteTestNr = indicationIn.testnr; break; } @@ -1036,16 +1031,15 @@ GCFEvent::TResult Application::test302(GCFEvent& e, GCFPortInterface& /*p*/) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: skipped(302); TRAN(Application::test303); break; case TST_TESTREADY: { - TSTTestreadyEvent* pIndication = static_cast<TSTTestreadyEvent*>(&e); - assert(pIndication); - _curRemoteTestNr = pIndication->testnr; + TSTTestreadyEvent indicationIn(e); + _curRemoteTestNr = indicationIn.testnr; break; } @@ -1067,11 +1061,11 @@ GCFEvent::TResult Application::test303(GCFEvent& e, GCFPortInterface& p) { case TST_TESTREADY: { - TSTTestreadyEvent* pIndication = static_cast<TSTTestreadyEvent*>(&e); - assert(pIndication); - _curRemoteTestNr = pIndication->testnr; + TSTTestreadyEvent indicationIn(e); + _curRemoteTestNr = indicationIn.testnr; + //intentional fall through } - case F_ENTRY_SIG: + case F_ENTRY: if (_curRemoteTestNr != 302) break; if (_apcT1.load(false) != GCF_NO_ERROR) { @@ -1084,7 +1078,7 @@ GCFEvent::TResult Application::test303(GCFEvent& e, GCFPortInterface& p) } break; - case F_APCLOADED_SIG: + case F_APCLOADED: { GCFAPCAnswerEvent* pResponse = static_cast<GCFAPCAnswerEvent*>(&e); assert(pResponse); @@ -1107,14 +1101,15 @@ GCFEvent::TResult Application::test303(GCFEvent& e, GCFPortInterface& p) break; } - case F_SUBSCRIBED_SIG: + case F_SUBSCRIBED: { GCFPropAnswerEvent* pResponse = static_cast<GCFPropAnswerEvent*>(&e); assert(pResponse); if ((strcmp(pResponse->pPropName, "A_C_P1") == 0) && (&p == &_supTask3.getPort())) { - TSTTestreadyEvent r(303); + TSTTestreadyEvent r; + r.testnr = 303; assert(_pSTPort1); _pSTPort1->send(r); } @@ -1126,7 +1121,7 @@ GCFEvent::TResult Application::test303(GCFEvent& e, GCFPortInterface& p) break; } - case F_VCHANGEMSG_SIG: + case F_VCHANGEMSG: { GCFPropValueEvent* pResponse = static_cast<GCFPropValueEvent*>(&e); assert(pResponse); @@ -1145,7 +1140,7 @@ GCFEvent::TResult Application::test303(GCFEvent& e, GCFPortInterface& p) } break; } - case F_EXIT_SIG: + case F_EXIT: propertyACP1.unsubscribe(); break; default: @@ -1165,11 +1160,11 @@ GCFEvent::TResult Application::test304(GCFEvent& e, GCFPortInterface& p) { case TST_TESTREADY: { - TSTTestreadyEvent* pIndication = static_cast<TSTTestreadyEvent*>(&e); - assert(pIndication); - _curRemoteTestNr = pIndication->testnr; + TSTTestreadyEvent indicationIn(e); + _curRemoteTestNr = indicationIn.testnr; + //intentional fall through } - case F_ENTRY_SIG: + case F_ENTRY: { _counter = 0; if (_curRemoteTestNr != 304) break; @@ -1197,7 +1192,7 @@ GCFEvent::TResult Application::test304(GCFEvent& e, GCFPortInterface& p) _counter = 0; break; } - case F_VCHANGEMSG_SIG: + case F_VCHANGEMSG: { GCFPropValueEvent* pResponse = static_cast<GCFPropValueEvent*>(&e); assert(pResponse); @@ -1254,7 +1249,7 @@ GCFEvent::TResult Application::test305(GCFEvent& e, GCFPortInterface& p) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: _counter = 0; if (_apcT3.load(false) != GCF_NO_ERROR) { @@ -1263,7 +1258,7 @@ GCFEvent::TResult Application::test305(GCFEvent& e, GCFPortInterface& p) } break; - case F_APCLOADED_SIG: + case F_APCLOADED: { GCFAPCAnswerEvent* pResponse = static_cast<GCFAPCAnswerEvent*>(&e); assert(pResponse); @@ -1285,14 +1280,15 @@ GCFEvent::TResult Application::test305(GCFEvent& e, GCFPortInterface& p) } break; } - case F_SUBSCRIBED_SIG: + case F_SUBSCRIBED: { GCFPropAnswerEvent* pResponse = static_cast<GCFPropAnswerEvent*>(&e); assert(pResponse); if ((strcmp(pResponse->pPropName, "A_H_J_P00") == 0) && (&p == &_supTask3.getPort())) { - TSTTestreadyEvent r(305); + TSTTestreadyEvent r; + r.testnr = 305; assert(_pSTPort1); _pSTPort1->send(r); } @@ -1305,9 +1301,8 @@ GCFEvent::TResult Application::test305(GCFEvent& e, GCFPortInterface& p) } case TST_TESTREADY: { - TSTTestreadyEvent* pIndication = static_cast<TSTTestreadyEvent*>(&e); - assert(pIndication); - _curRemoteTestNr = pIndication->testnr; + TSTTestreadyEvent indicationIn(e); + _curRemoteTestNr = indicationIn.testnr; if (_curRemoteTestNr == 305) { GCFPVDouble dv(3.12); @@ -1320,7 +1315,7 @@ GCFEvent::TResult Application::test305(GCFEvent& e, GCFPortInterface& p) } break; } - case F_VCHANGEMSG_SIG: + case F_VCHANGEMSG: { GCFPropValueEvent* pResponse = static_cast<GCFPropValueEvent*>(&e); assert(pResponse); @@ -1363,7 +1358,7 @@ GCFEvent::TResult Application::test306(GCFEvent& e, GCFPortInterface& p) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: if (_propertySetB4.load() != GCF_NO_ERROR) { failed(306); @@ -1371,7 +1366,7 @@ GCFEvent::TResult Application::test306(GCFEvent& e, GCFPortInterface& p) } break; - case F_MYPLOADED_SIG: + case F_MYPLOADED: { GCFMYPropAnswerEvent* pResponse = static_cast<GCFMYPropAnswerEvent*>(&e); assert(pResponse); @@ -1394,7 +1389,7 @@ GCFEvent::TResult Application::test306(GCFEvent& e, GCFPortInterface& p) } break; } - case F_APCLOADED_SIG: + case F_APCLOADED: { GCFAPCAnswerEvent* pResponse = static_cast<GCFAPCAnswerEvent*>(&e); assert(pResponse); @@ -1416,14 +1411,15 @@ GCFEvent::TResult Application::test306(GCFEvent& e, GCFPortInterface& p) } break; } - case F_SUBSCRIBED_SIG: + case F_SUBSCRIBED: { GCFPropAnswerEvent* pResponse = static_cast<GCFPropAnswerEvent*>(&e); assert(pResponse); if ((strcmp(pResponse->pPropName, "A_K_P1") == 0) && (&p == &_supTask3.getPort())) { - TSTTestreadyEvent r(306); + TSTTestreadyEvent r; + r.testnr = 306; _counter = 0; assert(_pSTPort1); _pSTPort1->send(r); @@ -1435,7 +1431,7 @@ GCFEvent::TResult Application::test306(GCFEvent& e, GCFPortInterface& p) } break; } - case F_VCHANGEMSG_SIG: + case F_VCHANGEMSG: { GCFPropValueEvent* pResponse = static_cast<GCFPropValueEvent*>(&e); assert(pResponse); @@ -1464,9 +1460,8 @@ GCFEvent::TResult Application::test306(GCFEvent& e, GCFPortInterface& p) case TST_TESTREADY: { - TSTTestreadyEvent* pIndication = static_cast<TSTTestreadyEvent*>(&e); - assert(pIndication); - _curRemoteTestNr = pIndication->testnr; + TSTTestreadyEvent indicationIn(e); + _curRemoteTestNr = indicationIn.testnr; if (_curRemoteTestNr != 306) break; if (nrOfSucceded == 1000) { @@ -1495,26 +1490,27 @@ GCFEvent::TResult Application::test401(GCFEvent& e, GCFPortInterface& p) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: _supTask3.getPort().init(_supTask3, "server", GCFPortInterface::SPP, TST_PROTOCOL); _supTask3.getPort().open(); break; - case F_TIMER_SIG: + case F_TIMER: _supTask3.getPort().open(); break; - case F_CONNECTED_SIG: + case F_CONNECTED: break; - case F_DISCONNECTED_SIG: + case F_DISCONNECTED: if (&p == &_supTask3.getPort()) _supTask3.getPort().setTimer(1.0); // try again after 1 second break; case TST_TESTREQ: { - TSTTestrespEvent r(401); + TSTTestrespEvent r; + r.testnr = 401; _supTask3.getPort().send(r); passed(401); TRAN(Application::test402); @@ -1538,20 +1534,20 @@ GCFEvent::TResult Application::test402(GCFEvent& e, GCFPortInterface& p) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: closing = true; _supTask3.getPort().close(); break; - case F_TIMER_SIG: + case F_TIMER: _port.open(); break; - case F_CONNECTED_SIG: + case F_CONNECTED: _counter = 0; break; - case F_ACCEPT_REQ_SIG: + case F_ACCEPT_REQ: if (_pSTPort1 == 0) { _pSTPort1 = new GCFTCPPort(); @@ -1566,7 +1562,7 @@ GCFEvent::TResult Application::test402(GCFEvent& e, GCFPortInterface& p) } break; - case F_DISCONNECTED_SIG: + case F_DISCONNECTED: if (closing) { _port.init(_supTask3, "server", GCFPortInterface::MSPP, TST_PROTOCOL); @@ -1580,7 +1576,7 @@ GCFEvent::TResult Application::test402(GCFEvent& e, GCFPortInterface& p) } break; - case F_CLOSED_SIG: + case F_CLOSED: _port.init(_supTask3, "server", GCFPortInterface::MSPP, TST_PROTOCOL); _port.open(); closing = false; @@ -1588,7 +1584,8 @@ GCFEvent::TResult Application::test402(GCFEvent& e, GCFPortInterface& p) case TST_TESTREQ: { - TSTTestrespEvent r(402); + TSTTestrespEvent r; + r.testnr = 402; _counter++; if (_counter == 1) { @@ -1603,12 +1600,14 @@ GCFEvent::TResult Application::test402(GCFEvent& e, GCFPortInterface& p) break; } case TST_TESTREADY: + { + TSTTestreadyEvent r(e); assert(_pSTPort1); - _pSTPort1->send(e); + _pSTPort1->send(r); passed(402); TRAN(Application::test101); break; - + } default: status = GCFEvent::NOT_HANDLED; break; @@ -1625,12 +1624,11 @@ GCFEvent::TResult Application::finished(GCFEvent& e, GCFPortInterface& /*p*/) { case TST_TESTREADY: { - TSTTestreadyEvent* pIndication = static_cast<TSTTestreadyEvent*>(&e); - assert(pIndication); - _curRemoteTestNr = pIndication->testnr; + TSTTestreadyEvent indicationIn(e); + _curRemoteTestNr = indicationIn.testnr; //intentional fall through } - case F_ENTRY_SIG: + case F_ENTRY: if (_curRemoteTestNr != 501) break; fprintf(stderr, "Ready with tests: passed %d, failed %d\n", _passed, _failed); GCFTask::stop(); diff --git a/MAC/Test/GCF/src/Echo_Protocol.prot b/MAC/Test/GCF/src/Echo_Protocol.prot index 7d35992eebd2e59f91dc6a1c117962a43bf09cbf..d557fb005f9e2b0392cd278f708c6ec402677bea 100644 --- a/MAC/Test/GCF/src/Echo_Protocol.prot +++ b/MAC/Test/GCF/src/Echo_Protocol.prot @@ -5,17 +5,12 @@ 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>'; -prelude = << PRELUDE_END -enum { - ECHO_PROTOCOL = F_APL_PROTOCOL -}; -PRELUDE_END; - // // An "event" has a "signal" and a "dir" (direction) // and zero or more "param"s. diff --git a/MAC/Test/GCF/src/Makefile.am b/MAC/Test/GCF/src/Makefile.am index 7002315e069a8e30f98eaf4262e4c2bbe0e04247..e6259ab8612cff32a1e3ec89c3f69ae5fd072d69 100644 --- a/MAC/Test/GCF/src/Makefile.am +++ b/MAC/Test/GCF/src/Makefile.am @@ -1,7 +1,7 @@ AUTOGEN = autogen SUFFIXES = .ph %.ph: %.prot - $(AUTOGEN) -L $(top_srcdir)/../../GCF/GCFCommon/autogen $< && \ + $(AUTOGEN) -L $(top_srcdir)/../../MACCommon/autogen $< && \ chmod a+w $@ libgcftest_la_DOCHDRS = \ @@ -19,10 +19,12 @@ noinst_LTLIBRARIES = libgcftest.la libgcfrttest.la libgcftest_la_SOURCES= $(libgcftest_la_DOCHDRS) \ SupervisedTask.cc \ PropertyProxy.cc \ - Answer.cc + Answer.cc \ + TST_Protocol.cc libgcfrttest_la_SOURCES= $(libgcfrttest_la_DOCHDRS) \ - RTAnswer.cc + RTAnswer.cc \ + Echo_Protocol.cc bin_PROGRAMS = Application1 Application2 RTEcho RTPing diff --git a/MAC/Test/GCF/src/RTDefines.h b/MAC/Test/GCF/src/RTDefines.h index d164d2f31a9bff2ad53cc1f8fd7f5f27f8ca82b9..5c1297a105d2f67dab63a2a65a38090a528fdb18 100644 --- a/MAC/Test/GCF/src/RTDefines.h +++ b/MAC/Test/GCF/src/RTDefines.h @@ -11,12 +11,267 @@ const TProperty echoPingPSETprops[] = { {"maxSeqNr", GCFPValue::LPT_INTEGER, GCF_WRITABLE_PROP, "100"}, - {"seqNr", GCFPValue::LPT_UNSIGNED, GCF_READABLE_PROP, "0"}, + {"seqNr000", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr001", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr002", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr003", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr004", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr005", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr006", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr007", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr008", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr009", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr010", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr011", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr012", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr013", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr014", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr015", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr016", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr017", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr018", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr019", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr020", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr021", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr022", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr023", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr024", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr025", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr026", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr027", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr028", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr029", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr030", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr031", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr032", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr033", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr034", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr035", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr036", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr037", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr038", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr039", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr040", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr041", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr042", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr043", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr044", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr045", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr046", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr047", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr048", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr049", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr050", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr051", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr052", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr053", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr054", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr055", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr056", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr057", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr058", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr059", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr060", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr061", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr062", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr063", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr064", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr065", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr066", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr067", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr068", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr069", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr070", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr071", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr072", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr073", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr074", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr075", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr076", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr077", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr078", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr079", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr080", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr081", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr082", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr083", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr084", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr085", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr086", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr087", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr088", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr089", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr090", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr091", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr092", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr093", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr094", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr095", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr096", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr097", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr098", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr099", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr100", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr101", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr102", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr103", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr104", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr105", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr106", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr107", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr108", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr109", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr110", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr111", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr112", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr113", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr114", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr115", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr116", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr117", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr118", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr119", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr120", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr121", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr122", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr123", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr124", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr125", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr126", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr127", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr128", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr129", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr130", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr131", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr132", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr133", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr134", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr135", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr136", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr137", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr138", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr139", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr140", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr141", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr142", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr143", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr144", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr145", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr146", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr147", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr148", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr149", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr150", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr151", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr152", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr153", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr154", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr155", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr156", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr157", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr158", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr159", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr160", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr161", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr162", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr163", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr164", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr165", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr166", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr167", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr168", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr169", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr170", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr171", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr172", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr173", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr174", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr175", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr176", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr177", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr178", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr179", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr180", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr181", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr182", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr183", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr184", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr185", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr186", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr187", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr188", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr189", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr190", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr191", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr192", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr193", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr194", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr195", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr196", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr197", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr198", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr199", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr200", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr201", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr202", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr203", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr204", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr205", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr206", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr207", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr208", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr209", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr210", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr211", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr212", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr213", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr214", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr215", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr216", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr217", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr218", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr219", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr220", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr221", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr222", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr223", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr224", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr225", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr226", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr227", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr228", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr229", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr230", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr231", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr232", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr233", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr234", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr235", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr236", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr237", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr238", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr239", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr240", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr241", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr242", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr243", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr244", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr245", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr246", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr247", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr248", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr249", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr250", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr251", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr252", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr253", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr254", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, + {"seqNr255", GCFPValue::LPT_DOUBLE, GCF_READABLE_PROP, "0"}, }; const TPropertySet echoPingPSET = { - 2, "B_RT", echoPingPSETprops + (sizeof(echoPingPSETprops)/sizeof(TProperty)), "B_RT", echoPingPSETprops }; // echoPingPSET: end diff --git a/MAC/Test/GCF/src/RTEcho.cc b/MAC/Test/GCF/src/RTEcho.cc index ddbaef6a711e446736a2bc2c4807be1b0a147824..e96155e459fe5af79e2807acd794ab6f6d087a9f 100644 --- a/MAC/Test/GCF/src/RTEcho.cc +++ b/MAC/Test/GCF/src/RTEcho.cc @@ -21,12 +21,8 @@ // // $Id$ -// we want F_DEBUG_SIGNAL to show the signals -#define DEBUG_SIGNAL - #include "RTEcho.h" #include <stdio.h> -#define DECLARE_SIGNAL_NAMES #include "Echo_Protocol.ph" Echo::Echo(string name) : GCFTask((State)&Echo::initial, name) @@ -44,22 +40,22 @@ GCFEvent::TResult Echo::initial(GCFEvent& e, GCFPortInterface& /*p*/) switch (e.signal) { - case F_INIT_SIG: + case F_INIT: break; - case F_ENTRY_SIG: + case F_ENTRY: _server.open(); break; - case F_CONNECTED_SIG: + case F_CONNECTED: TRAN(Echo::connected); break; - case F_DISCONNECTED_SIG: + case F_DISCONNECTED: _server.setTimer(1.0); // try again after 1 second break; - case F_TIMER_SIG: + case F_TIMER: _server.open(); // try again break; @@ -78,7 +74,7 @@ GCFEvent::TResult Echo::connected(GCFEvent& e, GCFPortInterface& /*p*/) switch (e.signal) { - case F_DISCONNECTED_SIG: + case F_DISCONNECTED: printf("Lost connection to client\n"); TRAN(Echo::initial); break; @@ -86,15 +82,16 @@ GCFEvent::TResult Echo::connected(GCFEvent& e, GCFPortInterface& /*p*/) case ECHO_PING: { - EchoPingEvent* ping = static_cast<EchoPingEvent*>(&e); + EchoPingEvent ping(e); - printf("PING received (seqnr=%d)\n", ping->seqnr); + printf("PING received (seqnr=%d)\n", ping.seqnr); timeval echoTime; gettimeofday(&echoTime, 0); - EchoEchoEvent echo(ping->seqnr, - ping->pingTime, - echoTime); + EchoEchoEvent echo; + echo.seqnr = ping.seqnr; + echo.pingTime = ping.pingTime; + echo.echoTime = echoTime; _server.send(echo); diff --git a/MAC/Test/GCF/src/RTPing.cc b/MAC/Test/GCF/src/RTPing.cc index ee370b53b8a3e240957c5a58cfd1ef483df8e36a..2728f2065d53f0bbf57437da0fa7d965c4c6e138 100644 --- a/MAC/Test/GCF/src/RTPing.cc +++ b/MAC/Test/GCF/src/RTPing.cc @@ -22,16 +22,12 @@ // $Id$ // -// we want F_DEBUG_SIGNAL to show the signals -#define DEBUG_SIGNAL - #include "RTPing.h" #include "RTDefines.h" #include <GCF/GCF_PVInteger.h> -#include <GCF/GCF_PVUnsigned.h> +#include <GCF/GCF_PVDouble.h> #include <GCF/CmdLine.h> #include <stdio.h> -#define DECLARE_SIGNAL_NAMES #include "Echo_Protocol.ph" /** @@ -69,15 +65,15 @@ GCFEvent::TResult Ping::initial(GCFEvent& e, GCFPortInterface& /*p*/) switch (e.signal) { - case F_INIT_SIG: + case F_INIT: break; - case F_ENTRY_SIG: + case F_ENTRY: _echoPingPSET.load(); _client.open(); break; - case F_CONNECTED_SIG: + case F_CONNECTED: // start ping_timer // - after 1 second @@ -88,15 +84,15 @@ GCFEvent::TResult Ping::initial(GCFEvent& e, GCFPortInterface& /*p*/) } break; - case F_DISCONNECTED_SIG: + case F_DISCONNECTED: _client.setTimer(1.0); // try connect again after 1 second break; - case F_TIMER_SIG: + case F_TIMER: _client.open(); break; - case F_MYPLOADED_SIG: + case F_MYPLOADED: { if (_client.isConnected() && _echoPingPSET.isLoaded()) { @@ -104,7 +100,7 @@ GCFEvent::TResult Ping::initial(GCFEvent& e, GCFPortInterface& /*p*/) } break; } - case F_EXIT_SIG: + case F_EXIT: _pingTimer = _client.setTimer(1.0, 0.1); break; default: @@ -124,7 +120,7 @@ GCFEvent::TResult Ping::connected(GCFEvent& e, GCFPortInterface& /*p*/) switch (e.signal) { - case F_ENTRY_SIG: + case F_ENTRY: { GCFPVInteger* pMaxSeqProp = static_cast<GCFPVInteger*>(_echoPingPSET["maxSeqNr"].getValue()); assert(pMaxSeqProp); @@ -132,7 +128,7 @@ GCFEvent::TResult Ping::connected(GCFEvent& e, GCFPortInterface& /*p*/) delete pMaxSeqProp; // was created by the first getValue() - clone of current value break; } - case F_VCHANGEMSG_SIG: + case F_VCHANGEMSG: { GCFPropValueEvent* pResponse = static_cast<GCFPropValueEvent*>(&e); assert(pResponse); @@ -144,26 +140,32 @@ GCFEvent::TResult Ping::connected(GCFEvent& e, GCFPortInterface& /*p*/) } break; } - case F_TIMER_SIG: + case F_TIMER: { timeval pingTime; // create PingEvent gettimeofday(&pingTime, 0); - EchoPingEvent ping(seqnr++, - pingTime); + EchoPingEvent ping; + ping.seqnr = seqnr++, + ping.pingTime = pingTime; // send the event _client.send(ping); - _echoPingPSET["seqNr"].setValue(GCFPVUnsigned(ping.seqnr)); + char seqNrName[9]; + for (unsigned int i = 0; i < 256; i++) + { + sprintf(seqNrName, "seqNr%03d", i); + _echoPingPSET[seqNrName].setValue(GCFPVDouble(ping.seqnr)); + } if (seqnr >= maxSeqNr) seqnr = 0; printf("PING sent (seqnr=%d)\n", ping.seqnr); TRAN(Ping::awaiting_echo); // wait for the echo break; } - case F_DISCONNECTED_SIG: + case F_DISCONNECTED: (void)_client.cancelTimer(_pingTimer); seqnr = 0; @@ -184,7 +186,7 @@ GCFEvent::TResult Ping::awaiting_echo(GCFEvent& e, GCFPortInterface& /*p*/) switch (e.signal) { - case F_TIMER_SIG: + case F_TIMER: printf("Missed echo dead-line.\n"); break; @@ -193,15 +195,15 @@ GCFEvent::TResult Ping::awaiting_echo(GCFEvent& e, GCFPortInterface& /*p*/) timeval echoTime; gettimeofday(&echoTime, 0); - EchoEchoEvent* echo = static_cast<EchoEchoEvent*>(&e); + EchoEchoEvent echo(e); - printf ("ECHO received (seqnr=%d): elapsed = %f sec.\n", echo->seqnr, - time_elapsed(&(echo->pingTime), &echoTime)); + printf ("ECHO received (seqnr=%d): elapsed = %f sec.\n", echo.seqnr, + time_elapsed(&(echo.pingTime), &echoTime)); TRAN(Ping::connected); break; } - case F_DISCONNECTED_SIG: + case F_DISCONNECTED: (void)_client.cancelTimer(_pingTimer); TRAN(Ping::initial); break; diff --git a/MAC/Test/GCF/src/SupervisedTask.cc b/MAC/Test/GCF/src/SupervisedTask.cc index 21fbf018e554c2d5b0d0551adbdaf09bee63f32c..4b449a8ed97ed5befffca5858fdb652490337641 100644 --- a/MAC/Test/GCF/src/SupervisedTask.cc +++ b/MAC/Test/GCF/src/SupervisedTask.cc @@ -25,21 +25,21 @@ int SupervisedTask::initial(GCFEvent& e, GCFPortInterface& p) void SupervisedTask::propSubscribed(const string& propName) { - GCFPropAnswerEvent e(F_SUBSCRIBED_SIG); + GCFPropAnswerEvent e(F_SUBSCRIBED); e.pPropName = propName.c_str(); _application.dispatch(e, _port); } void SupervisedTask::propUnsubscribed(const string& propName) { - GCFPropAnswerEvent e(F_UNSUBSCRIBED_SIG); + GCFPropAnswerEvent e(F_UNSUBSCRIBED); e.pPropName = propName.c_str(); _application.dispatch(e, _port); } void SupervisedTask::propValueChanged(const string& propName, const GCFPValue& value) { - GCFPropValueEvent e(F_VCHANGEMSG_SIG); + GCFPropValueEvent e(F_VCHANGEMSG); e.pValue = &value; e.pPropName = propName.c_str(); e.internal = false; @@ -48,7 +48,7 @@ void SupervisedTask::propValueChanged(const string& propName, const GCFPValue& v void SupervisedTask::valueGet(const string& propName, const GCFPValue& value) { - GCFPropValueEvent e(F_VGETRESP_SIG); + GCFPropValueEvent e(F_VGETRESP); e.pValue = &value; e.pPropName = propName.c_str(); e.internal = false; diff --git a/MAC/Test/GCF/src/TST_Protocol.prot b/MAC/Test/GCF/src/TST_Protocol.prot index 0650d9d52da03dfc9727cf86a3873113d4c6e495..1e1ff09d10f2e427b57b24e73fd3362fdada142c 100644 --- a/MAC/Test/GCF/src/TST_Protocol.prot +++ b/MAC/Test/GCF/src/TST_Protocol.prot @@ -5,18 +5,12 @@ autogen definitions protocol; description = "Protocol for the TEST server"; prefix = "TST"; // for the signal names +id = "0x3f"; // specify extra include files // e.g. include = '<sys/time.h>'; -prelude = << PRELUDE_END -enum { - TST_PROTOCOL = 0x3f -}; - -PRELUDE_END; - // // An "event" has a "signal" and a "dir" (direction) // and zero or more "param"s.