11 #include <libtrap/trap.h>
21 : m_interfaceID(interfaceID)
23 , m_prioritizedDataPointer(nullptr)
30 const void* receivedData;
31 uint16_t dataSize = 0;
40 if (errorCode == TRAP_E_TIMEOUT) {
43 if (errorCode == TRAP_E_FORMAT_CHANGED) {
58 if (errorCode == TRAP_E_OK) {
61 if (errorCode == TRAP_E_NOT_INITIALIZED) {
62 throw std::runtime_error(
63 "UnirecInputInterface::receive() has failed. Trap interface is not initialized.");
65 if (errorCode == TRAP_E_TERMINATED) {
66 throw std::runtime_error(
67 "UnirecInputInterface::receive() has failed. Trap interface is terminated.");
69 if (errorCode == TRAP_E_NOT_SELECTED) {
70 throw std::runtime_error(
71 "UnirecInputInterface::receive() has failed. Interface ID out of range.");
73 throw std::runtime_error(
74 "UnirecInputInterface::receive() has failed. Return code: " + std::to_string(errorCode)
75 +
", msg: " + trap_last_error_msg);
80 int ret = trap_set_required_fmt(
m_interfaceID, TRAP_FMT_UNIREC, templateSpecification.c_str());
81 if (ret != TRAP_E_OK) {
82 throw std::runtime_error(
83 "UnirecInputInterface::setRequieredFormat() has failed. Unable to set required "
93 const char* spec =
nullptr;
95 int ret = trap_get_data_fmt(TRAPIFC_INPUT,
m_interfaceID, &dataType, &spec);
96 if (ret != TRAP_E_OK) {
97 throw std::runtime_error(
98 "UnirecInputInterface::changeTemplate() has failed. Data format was not "
109 throw std::runtime_error(
110 "UnirecInputInterface::changeTemplate() has failed. Template could not be "
115 if (ret != TRAP_E_OK) {
116 throw std::runtime_error(
"UnirecInputInterface::changeTemplate() has failed.");
122 trap_ifcctl(TRAPIFC_INPUT,
m_interfaceID, TRAPCTL_SETTIMEOUT, timeout);
129 struct input_ifc_stats ifcStats = {};
An exception that is thrown when the end of the input stream is reached.
Provides a view into a UniRec record.
ur_template_t * ur_define_fields_and_update_template(const char *ifc_data_fmt, ur_template_t *tmplt)
Defined new fields and expand an UniRec template Define new fields (function ur_define_set_of_fields)...
void ur_free_template(ur_template_t *tmplt)
Destroy UniRec template Free all memory allocated for a template created previously by ur_create_temp...
#define ur_set_input_template(ifc, tmplt)
Set UniRec template to input interface.