#define AGHAF_DYNAMIC_LIBRARY_INIT
#include <iostream>
#include <string>
#include <unordered_map>
struct pair_hash {
template <class T1, class T2>
std::size_t operator()(const std::pair<T1, T2>& pair) const {
return std::hash<T1>()(pair.first) ^ std::hash<T2>()(pair.second);
}
};
std::unordered_map<std::pair<std::string, std::string>,
AGHAF_Device, pair_hash>
devices;
void deviceEvent_callback(void* event, void* userContext) {
(void)userContext;
break;
std::pair<std::string, std::string> key(productNumber, serialNumber);
break;
&device);
devices.insert(
std::pair<std::pair<std::string, std::string>,
AGHAF_Device>(
key, device));
} break;
auto it = devices.find(key);
if (it != devices.end()) {
devices.erase(it);
}
} break;
break;
}
} break;
}
}
int main() {
#ifdef _WIN32
AGHAF_loadLibrary(AGHAF_DEFAULT_FILENAME);
#endif
std::string input;
while (input != "exit") {
std::cin >> input;
}
#ifdef _WIN32
AGHAF_unloadLibrary();
#endif
return 0;
}
@ AGHAF_TypeCanEvent
Event from CAN.
Definition aghaf_global.h:114
@ AGHAF_TypeEthernetEvent
Event from Ethernet.
Definition aghaf_global.h:113
@ AGHAF_TypeDoCanEvent
Event from DOCAN.
Definition aghaf_global.h:115
@ AGHAF_TypeNoEvent
No event. Event is invalid.
Definition aghaf_global.h:111
@ AGHAF_TypeDeviceEvent
Event from Device.
Definition aghaf_global.h:112
@ AGHAF_Device_Present
A device was present.
Definition aghaf_global.h:106
@ AGHAF_Device_Leave
A device was disconnected from this PC.
Definition aghaf_global.h:105
@ AGHAF_Device_Arrival
A device was connected to this PC.
Definition aghaf_global.h:104
@ AGHAF_Device_noEvent
No event. Event is invalid.
Definition aghaf_global.h:103
char const * AGHAF_DeviceEvent_getSerialNumber(AGHAF_Event event)
return the serial number from the device which emitted the device event
void AGHAF_uninitialize(void)
Uninitialize Aghaf library.
char const * AGHAF_DeviceEvent_getProductNumber(AGHAF_Event event)
return the product number from the device which emitted the device event
AGHAF_DeviceEvent
device event fot hotplug management
Definition aghaf_global.h:102
AGHAF_Status AGHAF_deregisterCallback(AGHAF_Callback callback)
Deregister a callback.
AGHAF_Status AGHAF_registerCallback(AGHAF_Callback callback, void *userContext)
Register a callback for the device event.
void * AGHAF_Device
handle on an exxotest device
Definition aghaf_global.h:87
char const * AGHAF_DeviceEvent_getProductName(AGHAF_Event event)
return the product name from the device which emitted the device event
void AGHAF_initialize(void)
Initialize Aghaf library.
AGHAF_Status AGHAF_getDeviceBySN(char const *productNumber, char const *serialNumber, AGHAF_Device *device)
Return the handle on the specified device.
AGHAF_Status AGHAF_Event_getInfo(AGHAF_Event event, AGHAF_EventInfo *info)
AGHAF_Event_getInfo.
generic stucture to read an event in a callback
Definition aghaf_global.h:141
AGHAF_TypeEvent type
Definition aghaf_global.h:142
uint32_t event
Definition aghaf_global.h:144