Skip to content

Commit

Permalink
Add support for 64-bit integers.
Browse files Browse the repository at this point in the history
  • Loading branch information
smarsching committed Mar 2, 2019
1 parent 7b1552c commit 5ff4e7f
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 3 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ EPICS Records

This device support supports the `aai`, `aao`, `ai`, `ao`, `bi`, `bo`, `longin`,
`longout`, `mbbi`, `mbbo`, `mbbiDirect`, `mbboDirect`, `stringin`, and `stringout`
records. When using EPICS Base 3.16 or newer, the `lsi` and `lso` records are
supported as well.
records. When using EPICS Base 3.16 or newer, the `int64in`, `int64out`, `lsi`
and `lso` records are supported as well.

The `DTYP` is `ChimeraTK` for all record types.

Expand All @@ -207,7 +207,8 @@ process variables or registers exist.
The *data-type* is optional and specifies the data type of the underlying
process variable or register. In most cases, the best data-type is detected
automatically. If explicitly specified, the data type must be `int8`, `uint8`,
`int16`, `uint16`, `int32`, `uint32`, `float`, `double`, or `string`.
`int16`, `uint16`, `int32`, `uint32`, `int64`, `uint64`, `float`, `double`, or
`string`.

The *options* are optional and are a list of comma-separated strings.

Expand All @@ -230,6 +231,8 @@ specifying the data type as part of the address. When using the ChimeraTK
Control System Adapter, the data type of the PV is fixed and thus the record's
data type must be set to match it.

The `aai` and `aao` records do not support the `int64` and `uint64` data-types.

#### `lsi` and `lso` record

The `lsi` and `lso` record are only supported when using EPICS Base 3.16 or
Expand Down
6 changes: 6 additions & 0 deletions chimeraTKApp/src/ChimeraTK/EPICS/ArrayRecordDeviceSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ class ArrayRecordDeviceSupportTrait : public RecordDeviceSupportBase {
checkFtvl(DBF_DOUBLE);
} else if (this->valueType == typeid(std::string)) {
checkFtvl(DBF_STRING);
} else if (this->valueType == typeid(std::int64_t)) {
throw std::invalid_argument(
"The value type int64 is not support by this record.");
} else if (this->valueType == typeid(std::uint64_t)) {
throw std::invalid_argument(
"The value type uint64 is not support by this record.");
} else {
throw std::logic_error(
std::string("Unexpected value type: ") + valueType.name());
Expand Down
19 changes: 19 additions & 0 deletions chimeraTKApp/src/ChimeraTK/EPICS/RecordDeviceSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ extern "C" {
}

#if EPICS_VERSION > 3 || (EPICS_VERSION == 3 && EPICS_REVISION >= 16)
# define CHIMERATK_EPICS_INT64_SUPPORTED 1
# define CHIMERATK_EPICS_LONG_STRING_SUPPORTED 1
#endif

Expand All @@ -37,6 +38,10 @@ extern "C" {
#include <aoRecord.h>
#include <biRecord.h>
#include <boRecord.h>
#ifdef CHIMERATK_EPICS_INT64_SUPPORTED
# include <int64inRecord.h>
# include <int64outRecord.h>
#endif // CHIMERATK_EPICS_INT64_SUPPORTED
#include <longinRecord.h>
#include <longoutRecord.h>
#ifdef CHIMERATK_EPICS_LONG_STRING_SUPPORTED
Expand Down Expand Up @@ -103,6 +108,20 @@ struct RecordDeviceSupportTypeHelper<::boRecord> {
FixedScalarRecordDeviceSupport<::boRecord>;
};

#ifdef CHIMERATK_EPICS_INT64_SUPPORTED
template<>
struct RecordDeviceSupportTypeHelper<::int64inRecord> {
using type =
FixedScalarRecordDeviceSupport<::int64inRecord>;
};

template<>
struct RecordDeviceSupportTypeHelper<::int64outRecord> {
using type =
FixedScalarRecordDeviceSupport<::int64outRecord>;
};
#endif // CHIMERATK_EPICS_INT64_SUPPORTED

template<>
struct RecordDeviceSupportTypeHelper<::longinRecord> {
using type =
Expand Down
8 changes: 8 additions & 0 deletions chimeraTKApp/src/ChimeraTK/EPICS/RecordDeviceSupportBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ class RecordDeviceSupportBase {
return F<std::int32_t>()();
} else if (this->valueType == typeid(std::uint32_t)) {
return F<std::uint32_t>()();
} else if (this->valueType == typeid(std::int64_t)) {
return F<std::int64_t>()();
} else if (this->valueType == typeid(std::uint64_t)) {
return F<std::uint64_t>()();
} else if (this->valueType == typeid(float)) {
return F<float>()();
} else if (this->valueType == typeid(double)) {
Expand Down Expand Up @@ -198,6 +202,10 @@ class RecordDeviceSupportBase {
return F<std::int32_t>()(std::forward<Args>(args)...);
} else if (valueType == typeid(std::uint32_t)) {
return F<std::uint32_t>()(std::forward<Args>(args)...);
} else if (valueType == typeid(std::int64_t)) {
return F<std::int64_t>()(std::forward<Args>(args)...);
} else if (valueType == typeid(std::uint64_t)) {
return F<std::uint64_t>()(std::forward<Args>(args)...);
} else if (valueType == typeid(float)) {
return F<float>()(std::forward<Args>(args)...);
} else if (valueType == typeid(double)) {
Expand Down
2 changes: 2 additions & 0 deletions chimeraTKApp/src/ControlSystemAdapterPVProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ ControlSystemAdapterPVProvider::ControlSystemAdapterPVProvider(
this->insertCreatePVSupportFunc<std::uint16_t>();
this->insertCreatePVSupportFunc<std::int32_t>();
this->insertCreatePVSupportFunc<std::uint32_t>();
this->insertCreatePVSupportFunc<std::int64_t>();
this->insertCreatePVSupportFunc<std::uint64_t>();
this->insertCreatePVSupportFunc<float>();
this->insertCreatePVSupportFunc<double>();
this->insertCreatePVSupportFunc<std::string>();
Expand Down
2 changes: 2 additions & 0 deletions chimeraTKApp/src/DeviceAccessPVProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ DeviceAccessPVProvider::DeviceAccessPVProvider(
this->insertCreatePVSupportFunc<std::uint16_t>();
this->insertCreatePVSupportFunc<std::int32_t>();
this->insertCreatePVSupportFunc<std::uint32_t>();
this->insertCreatePVSupportFunc<std::int64_t>();
this->insertCreatePVSupportFunc<std::uint64_t>();
this->insertCreatePVSupportFunc<float>();
this->insertCreatePVSupportFunc<double>();
this->insertCreatePVSupportFunc<std::string>();
Expand Down
1 change: 1 addition & 0 deletions chimeraTKApp/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ DBD += ChimeraTK-ControlSystemAdapter-EPICS.dbd

ChimeraTK-ControlSystemAdapter-EPICS_DBD += common.dbd
ifdef BASE_3_16
ChimeraTK-ControlSystemAdapter-EPICS_DBD += int64.dbd
ChimeraTK-ControlSystemAdapter-EPICS_DBD += longString.dbd
endif

Expand Down
4 changes: 4 additions & 0 deletions chimeraTKApp/src/RecordAddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,10 @@ class Parser {
return typeid(std::int32_t);
} else if (accept("uint32")) {
return typeid(std::uint32_t);
} else if (accept("int64")) {
return typeid(std::int64_t);
} else if (accept("uint64")) {
return typeid(std::uint64_t);
} else if (accept("float")) {
return typeid(float);
} else if (accept("double")) {
Expand Down
2 changes: 2 additions & 0 deletions chimeraTKApp/src/int64.dbd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
device(int64in,INST_IO,devInt64inChimeraTK,"ChimeraTK")
device(int64out,INST_IO,devInt64outChimeraTK,"ChimeraTK")
14 changes: 14 additions & 0 deletions chimeraTKApp/src/recordDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,20 @@ epicsExportAddress(dset, devBiChimeraTK);
auto devBoChimeraTK = deviceSupportStruct<::boRecord>();
epicsExportAddress(dset, devBoChimeraTK);

#ifdef CHIMERATK_EPICS_INT64_SUPPORTED
/**
* int64in record type.
*/
auto devInt64inChimeraTK = deviceSupportStruct<::int64inRecord>();
epicsExportAddress(dset, devInt64inChimeraTK);

/**
* int64out record type.
*/
auto devInt64outChimeraTK = deviceSupportStruct<::int64outRecord>();
epicsExportAddress(dset, devInt64outChimeraTK);
#endif // CHIMERATK_EPICS_INT64_SUPPORTED

/**
* longin record type.
*/
Expand Down

0 comments on commit 5ff4e7f

Please sign in to comment.