3#ifndef RT_TASKS_GLOBALS_H
4#define RT_TASKS_GLOBALS_H
15 #define LIBRARY_EXPORT __declspec(dllexport)
16 #define LIBRARY_IMPORT __declspec(dllimport)
17#elif defined(__linux__)
18 #define LIBRARY_EXPORT __attribute__((visibility("default")))
19 #define LIBRARY_IMPORT __attribute__((visibility("default")))
21 #define LIBRARY_EXPORT
22 #define LIBRARY_IMPORT
25#define NAME(name) name
26#define CONCAT(left, right) left ## right
27#define RSI_TASK(name) \
28 void CONCAT(name, Core)(RSI::RapidCode::RealTimeTasks::GlobalData*); \
29 extern "C" LIBRARY_EXPORT int32_t NAME(name)(RSI::RapidCode::RealTimeTasks::GlobalData* data, char* buffer, const uint32_t size) { return CallFunction(CONCAT(name, Core), data, buffer, size); } \
30 void CONCAT(name, Core)(RSI::RapidCode::RealTimeTasks::GlobalData* data)
32template<
typename FunctionType>
40 catch(
const std::exception& error)
43 std::snprintf(buffer, size,
"%s", error.what());
48 std::snprintf(buffer, size,
"Unknown error occurred in task.");
71 GlobalData() { std::memset(
this, 0,
sizeof(*
this)); }
72 GlobalData(GlobalData&& other) { std::memcpy(
this, &other,
sizeof(*
this)); }
75 RSI_GLOBAL(int64_t, counter);
78 RSI_GLOBAL(
double, average);
81inline constexpr GlobalMetadataMap<RSI::RapidCode::RealTimeTasks::GlobalMaxSize> GlobalMetadata(
83 REGISTER_GLOBAL(counter),
84 REGISTER_GLOBAL(average),
92 return GlobalMetadata[name].offset;
94 static_assert(std::is_same<
decltype(&
GlobalMemberOffsetGet), GlobalMemberOffsetGetter>::value,
"GlobalMemberOffsetGet function signature does not match GlobalMemberOffsetGetter type.");
96 LIBRARY_EXPORT int32_t GlobalNamesFill(
const char* names[], int32_t capacity)
99 for (; index < GlobalMetadata.Size() && index < capacity; ++index)
101 names[index] = GlobalMetadata[index].key;
105 static_assert(std::is_same<
decltype(&GlobalNamesFill), GlobalNamesGetter>::value,
"GlobalNamesGet function signature does not match GlobalNamesGetter type.");
107 LIBRARY_EXPORT std::int32_t GlobalMemberTypeGet(
const char*
const name)
109 return static_cast<std::int32_t
>(GlobalMetadata[name].type);
111 static_assert(std::is_same<
decltype(&GlobalMemberTypeGet), GlobalMemberTypeGetter>::value,
"GlobalMemberTypeGet function signature does not match GlobalMemberTypeGetter type.");
114static_assert(
sizeof(
GlobalData) <= RSI::RapidCode::RealTimeTasks::GlobalMaxSize,
"GlobalData struct is too large.");
123 LIBRARY_IMPORT
RSI::RapidCode::Axis* AxisGet(
const int32_t axisIndex,
char* errorBuffer,
const uint32_t errorBufferSize);
124 LIBRARY_IMPORT RSI::RapidCode::RapidCodeNetworkNode* NetworkNodeGet(
const int32_t index,
char* errorBuffer,
const uint32_t errorBufferSize);
125 LIBRARY_IMPORT
RSI::RapidCode::MultiAxis* MultiAxisGet(
const int32_t index,
char* errorBuffer,
const uint32_t errorBufferSize);
128template<
typename FunctionType,
typename ... Args>
129auto RTObjectGet(FunctionType&& func, Args&& ... args)
131 char errorBuffer[256] = {};
132 auto object = std::forward<FunctionType>(func)(std::forward<Args>(args)..., errorBuffer,
sizeof(errorBuffer));
133 if (
object ==
nullptr) {
throw std::runtime_error(errorBuffer); };
136inline auto RTMotionControllerGet() {
return RTObjectGet(MotionControllerGet); }
137inline auto RTAxisGet(
const int32_t index) {
return RTObjectGet(AxisGet, index); }
138inline auto RTMultiAxisGet(
const int32_t index) {
return RTObjectGet(MultiAxisGet, index); }
139inline auto RTNetworkNodeGet(
const int32_t index) {
return RTObjectGet(NetworkNodeGet, index); }
Represents a single axis of motion control. This class provides an interface for commanding motion,...
Represents the RMP soft motion controller. This class provides an interface to general controller con...
Represents multiple axes of motion control, allows you to map two or more Axis objects together for e...
The RealTimeTasks namespace.
LIBRARY_EXPORT int32_t GlobalMemberOffsetGet(const char *const name)
@[RTTasksGlobalData]