diff --git a/.gitattributes b/.gitattributes index 6a1a66ca4f731787bc115442a749bae36b99f3c3..e44a1fb2038e157e8d3328b8c0d6d2989cb4c920 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3174,6 +3174,7 @@ MAC/GCF/LogSys/KVLogSys/src/KVL_Protocol.prot -text svneol=native#application/oc MAC/GCF/LogSys/KVLogSys/src/KeyValueLoggerSys.conf.in -text svneol=native#application/octet-stream MAC/GCF/LogSys/KVLogSys/src/KeyValueLoggerSys.log_prop.in -text svneol=native#application/octet-stream MAC/GCF/PVSS/src/GCF_DynTypes.h -text +MAC/GCF/PVSS/src/GCF_PVTypes.cc -text MAC/GCF/PVSS/test/tPVSSservice.dpl -text MAC/GCF/README -text svneol=native#application/octet-stream MAC/GCF/RTDB/include/GCF/RTDB/GCF_RTDBPort.h -text diff --git a/MAC/GCF/PVSS/include/GCF/PVSS/GCF_PVDateTime.h b/MAC/GCF/PVSS/include/GCF/PVSS/GCF_PVDateTime.h index e073f96830b03b73ec2d92fdc8ca0f754a7b2eff..30480dd19d96efd29717d90a03242f2b3065724e 100644 --- a/MAC/GCF/PVSS/include/GCF/PVSS/GCF_PVDateTime.h +++ b/MAC/GCF/PVSS/include/GCF/PVSS/GCF_PVDateTime.h @@ -45,6 +45,7 @@ public: /** Changes the value of this object */ virtual TGCFResult setValue(double newVal); + void setValue(time_t newVal, uint16 milliSec = 0); /** * Changes the value of this object by means of a stringbuffer, @@ -92,7 +93,7 @@ inline bool GCFPVDateTime::operator==(const GCFPValue& that) const { (getValue() == ((GCFPVDateTime *) &that)->getValue())); } - } // namespace Common + } // namespace PVS } // namespace GCF } // namespace LOFAR #endif diff --git a/MAC/GCF/PVSS/include/GCF/PVSS/GCF_PVDouble.h b/MAC/GCF/PVSS/include/GCF/PVSS/GCF_PVDouble.h index a502d226e2026475048c5d0465d90a5ff36c5951..a4fe7d5e58eebfe582b95a130c841bcc5b6fe4ff 100644 --- a/MAC/GCF/PVSS/include/GCF/PVSS/GCF_PVDouble.h +++ b/MAC/GCF/PVSS/include/GCF/PVSS/GCF_PVDouble.h @@ -45,7 +45,7 @@ class GCFPVDouble : public GCFPValue virtual ~GCFPVDouble () {;} /** Changes the value of this object */ - void setValue ( const double newVal) {_value = newVal;}; + void setValue (const double newVal) {_value = newVal;}; /** * Changes the value of this object by means of a stringbuffer, diff --git a/MAC/GCF/PVSS/include/GCF/PVSS/GCF_PVDynArr.h b/MAC/GCF/PVSS/include/GCF/PVSS/GCF_PVDynArr.h index 05fbade35831ea5da6a1918abf2baa6ef60e3261..ccb0c3e731d3489a9285b17a6f7261f89fc4a95b 100644 --- a/MAC/GCF/PVSS/include/GCF/PVSS/GCF_PVDynArr.h +++ b/MAC/GCF/PVSS/include/GCF/PVSS/GCF_PVDynArr.h @@ -79,6 +79,9 @@ class GCFPVDynArr : public GCFPValue // add value to the dynarray void push_back(GCFPValue* newElem) { _values.push_back(newElem); } + + // return number of elements + size_t count() const { return(_values.size()); } private: /// @see GCFPValue::unpack() diff --git a/MAC/GCF/PVSS/include/GCF/PVSS/GCF_PVTypes.h b/MAC/GCF/PVSS/include/GCF/PVSS/GCF_PVTypes.h index a64ba5ce4420775b3203175d60f1ed834ef6a94f..c4b6808b27e1d7d82ab52a307d9e0a82efb951f4 100644 --- a/MAC/GCF/PVSS/include/GCF/PVSS/GCF_PVTypes.h +++ b/MAC/GCF/PVSS/include/GCF/PVSS/GCF_PVTypes.h @@ -34,4 +34,23 @@ #include <GCF/PVSS/GCF_PVString.h> #include <GCF/PVSS/GCF_PVUnsigned.h> +namespace LOFAR { + namespace GCF { + namespace PVSS { + +GCFPValue* createPValue(const bool someVal); +GCFPValue* createPValue(const char someVal); +GCFPValue* createPValue(const uint someVal); +GCFPValue* createPValue(const int someVal); +GCFPValue* createPValue(const float someVal); +GCFPValue* createPValue(const double someVal); +GCFPValue* createPValue(const char* someVal); +GCFPValue* createPValue(const string& someVal); +GCFPValue* createPValue(const time_t someVal); + + } // namespace PVS + } // namespace GCF +} // namespace LOFAR + + #endif diff --git a/MAC/GCF/PVSS/include/GCF/PVSS/GCF_PValue.h b/MAC/GCF/PVSS/include/GCF/PVSS/GCF_PValue.h index e5ef3519463894e9ae57b5ccee46baac919f776e..955e73dc1c7230ba213ece9d825decb39db11456 100644 --- a/MAC/GCF/PVSS/include/GCF/PVSS/GCF_PValue.h +++ b/MAC/GCF/PVSS/include/GCF/PVSS/GCF_PValue.h @@ -171,7 +171,8 @@ inline ostream& operator<< (ostream& os, const GCFPValue& gv) return (os); } - } // namespace Common + + } // namespace PVSS } // namespace GCF } // namespace LOFAR diff --git a/MAC/GCF/PVSS/src/CMakeLists.txt b/MAC/GCF/PVSS/src/CMakeLists.txt index deafcfd65fe095bae60864eff04b7ed3cf1deca8..36ddeab61b1cbe83709e0500ed50e1f9af68610e 100644 --- a/MAC/GCF/PVSS/src/CMakeLists.txt +++ b/MAC/GCF/PVSS/src/CMakeLists.txt @@ -21,6 +21,7 @@ lofar_add_library(gcfpvss GCF_PVUnsigned.cc GCF_PVDynArr.cc GCF_PVBlob.cc + GCF_PVTypes.cc GSA_SCADAHandler.cc GSA_PvssApi.cc GSA_Resources.cc diff --git a/MAC/GCF/PVSS/src/GCF_PVDateTime.cc b/MAC/GCF/PVSS/src/GCF_PVDateTime.cc index e62d10546729fd99b73f9ee699b681e61bfe9963..a286ead47bd8f143889a897a06f27d93d7f8fbc9 100644 --- a/MAC/GCF/PVSS/src/GCF_PVDateTime.cc +++ b/MAC/GCF/PVSS/src/GCF_PVDateTime.cc @@ -89,6 +89,15 @@ TGCFResult GCFPVDateTime::setValue(double newVal) return (GCF_NO_ERROR); } +// +// setValue(time_t) +// +void GCFPVDateTime::setValue(time_t newVal, uint16 milliSec) +{ + itsSeconds = newVal; + itsMilli = milliSec % 1000; +} + // // setValue(string) diff --git a/MAC/GCF/PVSS/src/GCF_PVTypes.cc b/MAC/GCF/PVSS/src/GCF_PVTypes.cc new file mode 100644 index 0000000000000000000000000000000000000000..97ba0606b0b8970a8e4b180989e1991339e2fe73 --- /dev/null +++ b/MAC/GCF/PVSS/src/GCF_PVTypes.cc @@ -0,0 +1,53 @@ +//# GCF_PVTypes.cc: +//# +//# Copyright (C) 2014 +//# ASTRON (Netherlands Foundation for Research in Astronomy) +//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +//# +//# This program is free software; you can redistribute it and/or modify +//# it under the terms of the GNU General Public License as published by +//# the Free Software Foundation; either version 2 of the License, or +//# (at your option) any later version. +//# +//# This program is distributed in the hope that it will be useful, +//# but WITHOUT ANY WARRANTY; without even the implied warranty of +//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//# GNU General Public License for more details. +//# +//# You should have received a copy of the GNU General Public License +//# along with this program; if not, write to the Free Software +//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +//# +//# $Id: GCF_PVString.cc 22948 2012-11-23 08:54:47Z loose $ + + +#include <lofar_config.h> + +#include <GCF/PVSS/GCF_PVTypes.h> +#include <GCF/PVSS/GCF_Defines.h> + +namespace LOFAR { + namespace GCF { + namespace PVSS { + +#define CREATE_AND_INIT_PVALUE(type, className, value) \ +{ \ + GCFPValue* p = GCFPValue::createMACTypeObject(type); \ + ASSERTSTR(p, "Creation of object of type " << type << " failed"); \ + ((className*)p)->setValue(value); \ + return (p); \ +} + +GCFPValue* createPValue(const bool someVal) CREATE_AND_INIT_PVALUE(LPT_BOOL, GCFPVBool, someVal) +GCFPValue* createPValue(const char someVal) CREATE_AND_INIT_PVALUE(LPT_CHAR, GCFPVChar, someVal) +GCFPValue* createPValue(const uint someVal) CREATE_AND_INIT_PVALUE(LPT_UNSIGNED, GCFPVUnsigned,someVal) +GCFPValue* createPValue(const int someVal) CREATE_AND_INIT_PVALUE(LPT_INTEGER, GCFPVInteger, someVal) +GCFPValue* createPValue(const float someVal) CREATE_AND_INIT_PVALUE(LPT_DOUBLE, GCFPVDouble, someVal) +GCFPValue* createPValue(const double someVal) CREATE_AND_INIT_PVALUE(LPT_DOUBLE, GCFPVDouble, someVal) +GCFPValue* createPValue(const char* someVal) CREATE_AND_INIT_PVALUE(LPT_STRING, GCFPVString, someVal) +GCFPValue* createPValue(const string& someVal) CREATE_AND_INIT_PVALUE(LPT_STRING, GCFPVString, someVal) +GCFPValue* createPValue(const time_t someVal) CREATE_AND_INIT_PVALUE(LPT_DATETIME, GCFPVDateTime,someVal) + + } // namespace Common + } // namespace GCF +} // namespace LOFAR diff --git a/MAC/GCF/RTDB/src/DPservice.cc b/MAC/GCF/RTDB/src/DPservice.cc index 224a5bee154ca907d19e00d0ba422dffe2b8e826..529b86739e758e03ce53fccd403b5d927c7c4a55 100644 --- a/MAC/GCF/RTDB/src/DPservice.cc +++ b/MAC/GCF/RTDB/src/DPservice.cc @@ -94,6 +94,7 @@ PVSSresult DPservice::setValue (const string& DPname, // write value to it. if (valueObj->setValue(value) != GCF_NO_ERROR) { LOG_WARN_STR("Could not set value for DP " << DPname); + delete valueObj; if (wantAnswer) { itsExtResponse->dpeValueSet(DPname, SA_SETPROP_FAILED); } @@ -101,7 +102,9 @@ PVSSresult DPservice::setValue (const string& DPname, } // finally write value to the database. - return (itsService->dpeSet(DPname, *valueObj, timestamp, wantAnswer)); + PVSSresult result = itsService->dpeSet(DPname, *valueObj, timestamp, wantAnswer); + delete valueObj; + return (result); } PVSSresult DPservice::setValue (const string& DPname,