35 #include <unordered_map> 38 #include "../DCS_Utils/include/DCS_ModuleUtils.h" 40 #include "H:\Data\C++\DCScan-ModulesAPI\DCS_Acquisition\include\DCS_ModuleAcquisition.h" 41 #include "H:\Data\C++\DCScan-ModulesAPI\DCS_Core\include\DCS_ModuleCore.h" 42 #include "H:\Data\C++\DCScan-ModulesAPI\DCS_EngineControl\include\DCS_ModuleEngineControl.h" 44 #define SV_CALL_NULL 0x0 45 #define SV_CALL_DCS_DAQ_NewAIVChannel 0x1 46 #define SV_CALL_DCS_DAQ_DeleteAIVChannel 0x2 47 #define SV_CALL_DCS_DAQ_StartAIAcquisition 0x3 48 #define SV_CALL_DCS_DAQ_StopAIAcquisition 0x4 49 #define SV_CALL_DCS_Threading_GetMaxHardwareConcurrency 0x5 50 #define SV_CALL_DCS_Control_IssueGenericCommand 0x6 51 #define SV_CALL_DCS_Control_IssueGenericCommandResponse 0x7 54 #define SV_ARG_NULL 0x0 55 #define SV_ARG_DCS_DAQ_ChannelRef 0x1 56 #define SV_ARG_DCS_Control_UnitTarget 0x2 57 #define SV_ARG_DCS_DAQ_ChannelLimits 0x3 58 #define SV_ARG_DCS_f64 0x4 59 #define SV_ARG_DCS_Utils_BasicString 0x5 61 #define SV_RET_VOID 0x0 62 #define SV_RET_DCS_Utils_BasicString 0x1 63 #define SV_RET_DCS_u16 0x2 66 #define SV_EVT_DCS_DAQ_PeakDetectWithAngleEvent 0x1 67 #define SV_EVT_DCS_DAQ_VoltageEvent 0x2 68 #define SV_EVT_DCS_Network_Message_FibSeqEvt 0x3 94 auto it =
id.find(func_signature);
98 LOG_ERROR(
"Function signature (%s) not found.", func_signature);
102 typedef void (*EventCallbackFunc)(
u8* data,
u8* userData);
109 memcpy(buffer, &
id,
sizeof(
u8));
111 evt_callbacks.emplace(
id, f);
112 evt_userData.emplace(
id, userData);
122 memcpy(buffer, &
id,
sizeof(
u8));
126 evt_callbacks.erase(
id);
127 evt_userData.erase(
id);
134 static DCS_API const EventCallbackFunc GetEventCallback(
u8 id)
137 return evt_callbacks.at(
id);
138 LOG_ERROR(
"Event id -> %d. No callback found.",
id);
142 static DCS_API const bool CheckEvent(
u8 id)
145 return subscriptions.at(
id);
149 static DCS_API const u8 GetEvent(
const char* func)
151 return evt_named_func.at(func);
158 return evt_userData.at(
id);
165 subscriptions[id] =
true;
171 subscriptions[id] =
false;
178 static inline T convert_from_byte(
const unsigned char* data,
i32 offset,
i32 size)
186 return *((T*)(data + offset));
190 static inline void convert_to_byte(T value,
unsigned char* buffer,
i32 offset,
i32 size)
197 memcpy(&buffer[offset], (
unsigned char*)&value,
sizeof(T));
200 inline static std::unordered_map<const char*, u16>
id =
202 {
"DCS::DAQ::NewAIVChannel", 0x1},
203 {
"DCS::DAQ::DeleteAIVChannel", 0x2},
204 {
"DCS::DAQ::StartAIAcquisition", 0x3},
205 {
"DCS::DAQ::StopAIAcquisition", 0x4},
206 {
"DCS::Threading::GetMaxHardwareConcurrency", 0x5},
207 {
"DCS::Control::IssueGenericCommand", 0x6},
208 {
"DCS::Control::IssueGenericCommandResponse", 0x7}
211 inline static std::unordered_map<u8, bool> subscriptions =
218 inline static std::unordered_map<const char*, u8> evt_named_func =
225 inline static std::unordered_map<u16, const char*> r_id_debug =
227 {0x1,
"SV_CALL_DCS_DAQ_NewAIVChannel"},
228 {0x2,
"SV_CALL_DCS_DAQ_DeleteAIVChannel"},
229 {0x3,
"SV_CALL_DCS_DAQ_StartAIAcquisition"},
230 {0x4,
"SV_CALL_DCS_DAQ_StopAIAcquisition"},
231 {0x5,
"SV_CALL_DCS_Threading_GetMaxHardwareConcurrency"},
232 {0x6,
"SV_CALL_DCS_Control_IssueGenericCommand"},
233 {0x7,
"SV_CALL_DCS_Control_IssueGenericCommandResponse"}
236 inline static std::unordered_map<u8, EventCallbackFunc> evt_callbacks;
237 inline static std::unordered_map<u8, u8*> evt_userData;
267 rv = std::any_cast<T>(args.at(i));
269 catch(
const std::bad_any_cast& e)
271 LOG_ERROR(
"Bad SVParams getArg(%d) %s.", i, e.what());
283 static const SVParams GetParamsFromData(
const unsigned char* payload,
i32 size);
294 template<
typename... Args>
297 std::vector<std::any> p = {args...};
299 memcpy(buffer, &fcode,
sizeof(
u16));
330 auto A0_v = std::any_cast<
DCS::f64>(p.at(0));
332 cpyArgToBuffer(buffer, (
u8*)&A0_v, A0_t,
sizeof(
DCS::f64), it);
356 LOG_ERROR(
"GetDataFromParams() function code (fcode) not found.");
357 LOG_ERROR(
"Maybe function signature naming is invalid, or function does not take any arguments.");
366 SVParams(
u16 fc, std::vector<std::any> args) : fcode(fc), args(args) { }
369 static void cpyArgToBuffer(
unsigned char* buffer,
u8* value,
u8 type,
i32 argSize,
i32& it);
373 #pragma warning( push ) 374 #pragma warning( disable : 4251 ) 375 std::vector<std::any> args;
376 #pragma warning( pop ) 379 #pragma pack(push, 1) #define SV_ARG_DCS_DAQ_ChannelLimits
Refers to argument DCS::DAQ::ChannelLimits
Definition: registry.h:57
#define SV_EVT_DCS_DAQ_PeakDetectWithAngleEvent
A event refering to DCS::DAQ::PeakDetectWithAngleEvent
Definition: registry.h:66
static DCS_API const i32 RemoveEvent(unsigned char *buffer, u8 id)
Set up event to unsubscribe by ID SV_EVT_*.
Definition: registry.h:120
#define DCS_API
Defines the export interface acessible via the dll-interface. Only important for SHARED LIB Compile M...
Definition: exports.h:116
Holds messages return types.
Definition: registry.h:383
static DCS_API const i32 SetupEvent(unsigned char *buffer, u8 id, EventCallbackFunc f, u8 *userData=nullptr)
Set up event to subscribe by ID SV_EVT_*.
Definition: registry.h:107
UnitTarget
Enumerates the diferent devices acessible via COM/USB ports.
Definition: DCS_ModuleEngineControl.h:31
#define SV_ARG_DCS_f64
Refers to argument DCS::f64
Definition: registry.h:58
#define SV_EVT_DCS_DAQ_VoltageEvent
A event refering to DCS::DAQ::VoltageEvent
Definition: registry.h:67
double f64
Equivalent to double.
Definition: DCS_ModuleUtils.h:61
#define SV_ARG_DCS_DAQ_ChannelRef
Refers to argument DCS::DAQ::ChannelRef
Definition: registry.h:55
A very simple string buffer to hold char values. Used for string information manipulations via tcp/ip...
Definition: DCS_ModuleUtils.h:121
Autogenerated class responsible for registering any function calls that might be requested via tcp/ip...
Definition: registry.h:81
#define SV_CALL_DCS_Control_IssueGenericCommandResponse
A call to DCS::Control::IssueGenericCommandResponse
Definition: registry.h:51
unsigned short u16
Equivalent to uint_16t.
Definition: DCS_ModuleUtils.h:56
signed long i32
Equivalent to int_32t.
Definition: DCS_ModuleUtils.h:53
#define SV_ARG_DCS_Control_UnitTarget
Refers to argument DCS::Control::UnitTarget
Definition: registry.h:56
#define SV_ARG_DCS_Utils_BasicString
Refers to argument DCS::Utils::BasicString
Definition: registry.h:59
#define SV_CALL_DCS_DAQ_DeleteAIVChannel
A call to DCS::DAQ::DeleteAIVChannel
Definition: registry.h:46
signed char i8
Equivalent to int_8t.
Definition: DCS_ModuleUtils.h:57
#define SV_CALL_DCS_Control_IssueGenericCommand
A call to DCS::Control::IssueGenericCommand
Definition: registry.h:50
ChannelRef
Classifies a channel reference connector for the DAQ.
Definition: DCS_ModuleAcquisition.h:40
Definition: registry.h:70
#define SV_CALL_DCS_DAQ_NewAIVChannel
A call to DCS::DAQ::NewAIVChannel
Definition: registry.h:45
const T getArg(u64 i) const
Get the i'th positional argument. Mostly internal use.
Definition: registry.h:262
#define LOG_ERROR(msg,...)
Alias to LOG_LVL(Error, msg, VA_ARGS)
Definition: DCS_ModuleUtils.h:37
static DCS_API const u16 Get(const char *func_signature)
Get a function id [SV_CALL_*] by function name. Syntax: ["ns::func"] Example: "DCS::Threading::GetMax...
Definition: registry.h:91
Channel measurement numeric limits.
Definition: DCS_ModuleAcquisition.h:56
unsigned long long u64
Equivalent to uint_64t.
Definition: DCS_ModuleUtils.h:52
#define SV_CALL_DCS_DAQ_StartAIAcquisition
A call to DCS::DAQ::StartAIAcquisition
Definition: registry.h:47
unsigned char u8
Equivalent to uint_8t.
Definition: DCS_ModuleUtils.h:58
Auto-generated class that allows for buffer <-> parameters conversion.
Definition: registry.h:243
#define SV_EVT_DCS_Network_Message_FibSeqEvt
A event refering to DCS::Network::Message::FibSeqEvt
Definition: registry.h:68
static i32 GetDataFromParams(unsigned char *buffer, u16 fcode, Args...args)
Fill a byte buffer with a list of arguments. use this function to populate the buffer passed to DCS::...
Definition: registry.h:295
const u16 getFunccode() const
Retrieve the function code of the currently held parameter list.
Definition: registry.h:250