Skip to content

Commit 4d3e6af

Browse files
committed
separate NDPluginPva and NDPluginPVXS and converters entirely
1 parent 303819c commit 4d3e6af

12 files changed

+182
-180
lines changed

ADApp/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ ifeq ($(WITH_PVA), YES)
1616
DIRS += ntndArrayConverterSrc
1717
ntndArrayConverterSrc_DEPEND_DIRS += ADSrc
1818
pluginSrc_DEPEND_DIRS += ntndArrayConverterSrc
19+
else ifeq ($(WITH_PVXS), YES)
20+
DIRS += ntndArrayConverterSrc
21+
ntndArrayConverterSrc_DEPEND_DIRS += ADSrc
22+
pluginSrc_DEPEND_DIRS += ntndArrayConverterSrc
1923
endif
2024

2125
DIRS += op

ADApp/commonDriverMakefile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,7 @@ ifeq ($(WITH_QSRV),YES)
2323
PROD_LIBS += qsrv
2424
endif
2525

26-
ifeq ($(WITH_PVXS),YES)
27-
$(DBD_NAME)_DBD += NDPluginPva.dbd
28-
PROD_LIBS += pvxs
29-
PROD_LIBS += ntndArrayConverter
30-
else ifeq ($(WITH_PVA),YES)
26+
ifeq ($(WITH_PVA),YES)
3127
$(DBD_NAME)_DBD += NDPluginPva.dbd
3228
$(DBD_NAME)_DBD += PVAServerRegister.dbd
3329
PROD_LIBS += ntndArrayConverter
@@ -41,6 +37,12 @@ else ifeq ($(WITH_PVA),YES)
4137
endif
4238
endif
4339

40+
ifeq ($(WITH_PVXS),YES)
41+
$(DBD_NAME)_DBD += NDPluginPvxs.dbd
42+
PROD_LIBS += pvxs
43+
PROD_LIBS += ntndArrayConverterPvxs
44+
endif
45+
4446
ifeq ($(WITH_NETCDF),YES)
4547
$(DBD_NAME)_DBD += NDFileNetCDF.dbd
4648
ifeq ($(NETCDF_EXTERNAL),NO)

ADApp/commonLibraryMakefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,19 @@
33
LIB_LIBS += ADBase
44
LIB_LIBS += asyn
55

6-
ifeq ($(WITH_PVXS),YES)
7-
LIB_LIBS += pvxs
8-
LIB_LIBS += ntndArrayConverter
9-
else ifeq ($(WITH_PVA),YES)
6+
ifeq ($(WITH_PVA),YES)
107
LIB_LIBS += ntndArrayConverter
118
LIB_LIBS += nt
129
LIB_LIBS += pvDatabase
1310
LIB_LIBS += pvAccess
1411
LIB_LIBS += pvData
1512
endif
1613

14+
ifeq ($(WITH_PVXS),YES)
15+
LIB_LIBS += ntndArrayConverterPvxs
16+
LIB_LIBS += pvxs
17+
endif
18+
1719
ifeq ($(WITH_NETCDF),YES)
1820
ifeq ($(NETCDF_EXTERNAL),NO)
1921
LIB_LIBS += netCDF

ADApp/ntndArrayConverterSrc/Makefile

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,26 @@ include $(TOP)/configure/CONFIG
44
# ADD MACRO DEFINITIONS AFTER THIS LINE
55
#=============================
66

7-
LIBRARY_IOC += ntndArrayConverter
8-
INC += ntndArrayConverterAPI.h
7+
ifeq ($(WITH_PVA), YES)
8+
LIBRARY_IOC += ntndArrayConverter
9+
INC += ntndArrayConverter.h
10+
LIB_SRCS += ntndArrayConverter.cpp
11+
LIB_LIBS += pvData
12+
LIB_LIBS += nt
13+
endif
14+
915
ifeq ($(WITH_PVXS), YES)
10-
INC += ntndArrayConverter.h
11-
LIB_SRCS += ntndArrayConverter_pvxs.cpp
12-
USR_CPPFLAGS += -DHAVE_PVXS
13-
else
14-
INC += ntndArrayConverter.h
15-
LIB_SRCS += ntndArrayConverter.cpp
16+
LIBRARY_IOC += ntndArrayConverterPvxs
17+
INC += ntndArrayConverterPvxs.h
18+
LIB_SRCS += ntndArrayConverterPvxs.cpp
19+
LIB_LIBS += pvxs
1620
endif
1721

22+
INC += ntndArrayConverterAPI.h
1823
USR_CPPFLAGS += -DBUILDING_ntndArrayConverter_API
19-
2024
LIB_LIBS += ADBase
21-
22-
ifeq ($(WITH_PVXS),YES)
23-
LIB_LIBS += pvxs
24-
else
25-
LIB_LIBS += pvData
26-
LIB_LIBS += nt
27-
endif
2825
LIB_LIBS += asyn
2926
LIB_LIBS += $(EPICS_BASE_IOC_LIBS)
30-
3127
#=============================
3228

3329
include $(TOP)/configure/RULES
Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#ifndef HAVE_PVXS
21
#include <math.h>
32

43
#include <ntndArrayConverterAPI.h>
@@ -67,76 +66,3 @@ class NTNDARRAYCONVERTER_API NTNDArrayConverter
6766
};
6867

6968
typedef std::tr1::shared_ptr<NTNDArrayConverter> NTNDArrayConverterPtr;
70-
#else
71-
#include <math.h>
72-
73-
#include <ntndArrayConverterAPI.h>
74-
#include <NDArray.h>
75-
#include <pvxs/data.h>
76-
#include <typeindex>
77-
#include <typeinfo>
78-
#include <unordered_map>
79-
80-
typedef struct NTNDArrayInfo
81-
{
82-
int ndims;
83-
size_t dims[ND_ARRAY_MAX_DIMS];
84-
size_t nElements, totalBytes;
85-
int bytesPerElement;
86-
NDColorMode_t colorMode;
87-
NDDataType_t dataType;
88-
std::string codec;
89-
90-
struct
91-
{
92-
int dim;
93-
size_t size, stride;
94-
}x, y, color;
95-
}NTNDArrayInfo_t;
96-
97-
class NTNDARRAYCONVERTER_API NTNDArrayConverter
98-
{
99-
public:
100-
NTNDArrayConverter(pvxs::Value value);
101-
NTNDArrayInfo_t getInfo (void);
102-
void toArray (NDArray *dest);
103-
void fromArray (NDArray *src);
104-
105-
private:
106-
pvxs::Value m_value;
107-
std::unordered_map<std::type_index, NDAttrDataType_t> m_typeMap;
108-
std::unordered_map<std::type_index, std::string> m_fieldNameMap;
109-
std::unordered_map<std::type_index, pvxs::ArrayType> m_arrayTypeMap;
110-
NDColorMode_t getColorMode (void);
111-
112-
template <typename arrayType>
113-
void toValue (NDArray *dest);
114-
void toValue (NDArray *dest);
115-
116-
void toDimensions (NDArray *dest);
117-
void toTimeStamp (NDArray *dest);
118-
void toDataTimeStamp (NDArray *dest);
119-
120-
template <typename valueType>
121-
void toAttribute (NDArray *dest, pvxs::Value attribute);
122-
void toStringAttribute (NDArray *dest, pvxs::Value attribute);
123-
void toUndefinedAttribute (NDArray *dest, pvxs::Value attribute);
124-
void toAttributes (NDArray *dest);
125-
126-
template <typename arrayType>
127-
void fromValue (NDArray *src);
128-
void fromValue (NDArray *src);
129-
130-
void fromDimensions (NDArray *src);
131-
void fromTimeStamp (NDArray *src);
132-
void fromDataTimeStamp (NDArray *src);
133-
134-
template <typename valueType>
135-
void fromAttribute (pvxs::Value destValue, NDAttribute *src);
136-
void fromStringAttribute (pvxs::Value destValue, NDAttribute *src);
137-
void fromAttributes (NDArray *src);
138-
};
139-
140-
typedef std::shared_ptr<NTNDArrayConverter> NTNDArrayConverterPtr;
141-
142-
#endif

ADApp/ntndArrayConverterSrc/ntndArrayConverterPvxs.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#include "ntndArrayConverter.h"
1+
#include "ntndArrayConverterPvxs.h"
22
#include <stdio.h>
33
#include <string.h>
44
#include <iostream>
55
using namespace std;
66

7-
NTNDArrayConverter::NTNDArrayConverter (pvxs::Value value) : m_value(value) {
7+
NTNDArrayConverterPvxs::NTNDArrayConverterPvxs (pvxs::Value value) : m_value(value) {
88
m_typeMap = {
99
{typeid(int8_t), NDAttrDataType_t::NDAttrInt8},
1010
{typeid(uint8_t), NDAttrDataType_t::NDAttrUInt8},
@@ -45,7 +45,7 @@ NTNDArrayConverter::NTNDArrayConverter (pvxs::Value value) : m_value(value) {
4545

4646
}
4747

48-
NDColorMode_t NTNDArrayConverter::getColorMode (void)
48+
NDColorMode_t NTNDArrayConverterPvxs::getColorMode (void)
4949
{
5050
auto attributes = m_value["attribute"].as<pvxs::shared_array<const pvxs::Value>>();
5151
NDColorMode_t colorMode = NDColorMode_t::NDColorModeMono;
@@ -58,7 +58,7 @@ NDColorMode_t NTNDArrayConverter::getColorMode (void)
5858
return colorMode;
5959
}
6060

61-
NTNDArrayInfo_t NTNDArrayConverter::getInfo (void)
61+
NTNDArrayInfo_t NTNDArrayConverterPvxs::getInfo (void)
6262
{
6363
NTNDArrayInfo_t info = {0};
6464

@@ -174,7 +174,7 @@ NTNDArrayInfo_t NTNDArrayConverter::getInfo (void)
174174
return info;
175175
}
176176

177-
void NTNDArrayConverter::toArray (NDArray *dest)
177+
void NTNDArrayConverterPvxs::toArray (NDArray *dest)
178178
{
179179
toValue(dest);
180180
toDimensions(dest);
@@ -185,7 +185,7 @@ void NTNDArrayConverter::toArray (NDArray *dest)
185185
dest->uniqueId = m_value["uniqueId"].as<int32_t>();
186186
}
187187

188-
void NTNDArrayConverter::fromArray (NDArray *src)
188+
void NTNDArrayConverterPvxs::fromArray (NDArray *src)
189189
{
190190
fromValue(src);
191191
fromDimensions(src);
@@ -197,7 +197,7 @@ void NTNDArrayConverter::fromArray (NDArray *src)
197197
}
198198

199199
template <typename arrayType>
200-
void NTNDArrayConverter::toValue (NDArray *dest)
200+
void NTNDArrayConverterPvxs::toValue (NDArray *dest)
201201
{
202202
NTNDArrayInfo_t info = getInfo();
203203
dest->codec.name = info.codec;
@@ -213,7 +213,7 @@ void NTNDArrayConverter::toValue (NDArray *dest)
213213
dest->compressedSize = info.totalBytes;
214214
}
215215

216-
void NTNDArrayConverter::toValue (NDArray *dest)
216+
void NTNDArrayConverterPvxs::toValue (NDArray *dest)
217217
{
218218
switch (m_value["value->"].type().code) {
219219
case pvxs::TypeCode::Int8A: {toValue<int8_t>(dest); break;}
@@ -230,7 +230,7 @@ void NTNDArrayConverter::toValue (NDArray *dest)
230230
}
231231
}
232232

233-
void NTNDArrayConverter::toDimensions (NDArray *dest)
233+
void NTNDArrayConverterPvxs::toDimensions (NDArray *dest)
234234
{
235235
auto dims = m_value["dimension"].as<pvxs::shared_array<const pvxs::Value>>();
236236
dest->ndims = (int)dims.size();
@@ -245,7 +245,7 @@ void NTNDArrayConverter::toDimensions (NDArray *dest)
245245
}
246246
}
247247

248-
void NTNDArrayConverter::toTimeStamp (NDArray *dest)
248+
void NTNDArrayConverterPvxs::toTimeStamp (NDArray *dest)
249249
{
250250
// NDArray uses EPICS time, pvAccess uses Posix time, need to convert
251251
dest->epicsTS.secPastEpoch = (epicsUInt32)
@@ -254,7 +254,7 @@ void NTNDArrayConverter::toTimeStamp (NDArray *dest)
254254
m_value["timeStamp.nanoseconds"].as<uint32_t>();
255255
}
256256

257-
void NTNDArrayConverter::toDataTimeStamp (NDArray *dest)
257+
void NTNDArrayConverterPvxs::toDataTimeStamp (NDArray *dest)
258258
{
259259
// NDArray uses EPICS time, pvAccess uses Posix time, need to convert
260260
dest->timeStamp = (epicsFloat64)
@@ -264,7 +264,7 @@ void NTNDArrayConverter::toDataTimeStamp (NDArray *dest)
264264
}
265265

266266
template <typename valueType>
267-
void NTNDArrayConverter::toAttribute (NDArray *dest, pvxs::Value attribute)
267+
void NTNDArrayConverterPvxs::toAttribute (NDArray *dest, pvxs::Value attribute)
268268
{
269269
auto name = attribute["name"].as<std::string>();
270270
auto desc = attribute["descriptor"].as<std::string>();
@@ -277,7 +277,7 @@ void NTNDArrayConverter::toAttribute (NDArray *dest, pvxs::Value attribute)
277277
dest->pAttributeList->add(attr);
278278
}
279279

280-
void NTNDArrayConverter::toStringAttribute (NDArray *dest, pvxs::Value attribute)
280+
void NTNDArrayConverterPvxs::toStringAttribute (NDArray *dest, pvxs::Value attribute)
281281
{
282282
auto name = attribute["name"].as<std::string>();
283283
auto desc = attribute["descriptor"].as<std::string>();
@@ -289,7 +289,7 @@ void NTNDArrayConverter::toStringAttribute (NDArray *dest, pvxs::Value attribute
289289
dest->pAttributeList->add(attr);
290290
}
291291

292-
void NTNDArrayConverter::toUndefinedAttribute (NDArray *dest, pvxs::Value attribute)
292+
void NTNDArrayConverterPvxs::toUndefinedAttribute (NDArray *dest, pvxs::Value attribute)
293293
{
294294
auto name = attribute["name"].as<std::string>();
295295
auto desc = attribute["descriptor"].as<std::string>();
@@ -300,7 +300,7 @@ void NTNDArrayConverter::toUndefinedAttribute (NDArray *dest, pvxs::Value attrib
300300
dest->pAttributeList->add(attr);
301301
}
302302

303-
void NTNDArrayConverter::toAttributes (NDArray *dest)
303+
void NTNDArrayConverterPvxs::toAttributes (NDArray *dest)
304304
{
305305
auto attributes = m_value["attribute"].as<pvxs::shared_array<const pvxs::Value>>();
306306
for (int i=0; i<attributes.size(); i++) {
@@ -325,7 +325,7 @@ void NTNDArrayConverter::toAttributes (NDArray *dest)
325325
}
326326

327327
template <typename dataType>
328-
void NTNDArrayConverter::fromValue(NDArray *src) {
328+
void NTNDArrayConverterPvxs::fromValue(NDArray *src) {
329329
NDArrayInfo_t arrayInfo;
330330
src->getInfo(&arrayInfo);
331331

@@ -344,7 +344,7 @@ void NTNDArrayConverter::fromValue(NDArray *src) {
344344
m_value["codec.parameters"] = (int32_t) src->dataType;
345345
}
346346

347-
void NTNDArrayConverter::fromValue (NDArray *src) {
347+
void NTNDArrayConverterPvxs::fromValue (NDArray *src) {
348348
switch(src->dataType) {
349349
case NDInt8: {fromValue<int8_t>(src); break;};
350350
case NDUInt8: {fromValue<uint8_t>(src); break;};
@@ -362,7 +362,7 @@ void NTNDArrayConverter::fromValue (NDArray *src) {
362362
}
363363
}
364364

365-
void NTNDArrayConverter::fromDimensions (NDArray *src) {
365+
void NTNDArrayConverterPvxs::fromDimensions (NDArray *src) {
366366
pvxs::shared_array<pvxs::Value> dims;
367367
dims.resize(src->ndims);
368368

@@ -377,7 +377,7 @@ void NTNDArrayConverter::fromDimensions (NDArray *src) {
377377
m_value["dimension"] = dims.freeze();
378378
}
379379

380-
void NTNDArrayConverter::fromDataTimeStamp (NDArray *src) {
380+
void NTNDArrayConverterPvxs::fromDataTimeStamp (NDArray *src) {
381381
double seconds = floor(src->timeStamp);
382382
double nanoseconds = (src->timeStamp - seconds)*1e9;
383383
// pvAccess uses Posix time, NDArray uses EPICS time, need to convert
@@ -386,28 +386,28 @@ void NTNDArrayConverter::fromDataTimeStamp (NDArray *src) {
386386
m_value["dataTimeStamp.nanoseconds"] = nanoseconds;
387387
}
388388

389-
void NTNDArrayConverter::fromTimeStamp (NDArray *src) {
389+
void NTNDArrayConverterPvxs::fromTimeStamp (NDArray *src) {
390390
// pvAccess uses Posix time, NDArray uses EPICS time, need to convert
391391
m_value["timeStamp.secondsPastEpoch"] = src->epicsTS.secPastEpoch + POSIX_TIME_AT_EPICS_EPOCH;
392392
m_value["timeStamp.nanoseconds"] = src->epicsTS.nsec;
393393
}
394394

395395
template <typename valueType>
396-
void NTNDArrayConverter::fromAttribute (pvxs::Value destValue, NDAttribute *src)
396+
void NTNDArrayConverterPvxs::fromAttribute (pvxs::Value destValue, NDAttribute *src)
397397
{
398398
valueType value;
399399
src->getValue(src->getDataType(), (void*)&value);
400400
destValue["value"] = value;
401401
}
402402

403-
void NTNDArrayConverter::fromStringAttribute (pvxs::Value destValue, NDAttribute *src)
403+
void NTNDArrayConverterPvxs::fromStringAttribute (pvxs::Value destValue, NDAttribute *src)
404404
{
405405
const char *value;
406406
src->getValue(src->getDataType(), (void*)&value);
407407
destValue["value"] = std::string(value);
408408
}
409409

410-
void NTNDArrayConverter::fromAttributes (NDArray *src)
410+
void NTNDArrayConverterPvxs::fromAttributes (NDArray *src)
411411
{
412412
NDAttributeList *srcList = src->pAttributeList;
413413
NDAttribute *attr = NULL;

0 commit comments

Comments
 (0)