EVA ICS v4 C++ SDK
eva4-ffi-sdk.hpp
1 #ifndef EVA4_FFI_SDK_HPP
2 #define EVA4_FFI_SDK_HPP
3 
4 #define EVA4_CCP_SDK_VERSION "0.0.1"
5 
6 #include <iostream>
7 #include <chrono>
8 #include <thread>
9 #include <msgpack.hpp>
10 #include "eva4-common.h"
11 #include "eva4-ffi.h"
12 
16 namespace eva {
17 
18  const uint16_t ABI_VERSION = 1;
19 
20  using namespace std;
21 
25  namespace vars {
26 
27  using namespace std;
28 
29  const auto sleepStep = chrono::milliseconds(100);
30 
34  struct TimeoutConfig {
36  chrono::milliseconds startup;
38  chrono::milliseconds shutdown;
40  chrono::milliseconds _default;
41 
42  void msgpack_unpack(msgpack::object o) {
43  if (o.type != msgpack::type::MAP) {
44  throw msgpack::type_error();
45  }
46  msgpack::object_kv* p = o.via.map.ptr;
47  msgpack::object_kv* const pend = o.via.map.ptr + o.via.map.size;
48 
49  for (; p != pend; ++p) {
50  if (p->key.as<std::string>() == "startup") {
51  startup = chrono::milliseconds((int32_t)(p->val.as<double>() * 1000));
52  } else if (p->key.as<std::string>() == "shutdown") {
53  shutdown = chrono::milliseconds((int32_t)(p->val.as<double>() * 1000));
54  } else if (p->key.as<std::string>() == "default") {
55  _default = chrono::milliseconds((int32_t)(p->val.as<double>() * 1000));
56  }
57  }
58  }
59  };
60 
64  struct CoreInfo {
65  uint64_t build;
66  string version;
67  uint16_t eapi_version;
68  string path;
69  bool active;
70 
71  MSGPACK_DEFINE_MAP(build, version, eapi_version, path, active);
72  };
73 
79  template<typename T>struct Initial {
80  uint16_t version;
81  string system_name;
82  string id;
83  string data_path;
84  TimeoutConfig timeout;
85  CoreInfo core;
86  T config;
87  string user;
88  bool fail_mode;
89  bool fips;
90  bool call_tracing;
91 
92  MSGPACK_DEFINE_MAP(version, system_name, id, data_path,
93  timeout, core, config, user, fail_mode, fips, call_tracing);
94 
100  chrono::milliseconds getTimeout() {
101  return this->timeout._default;
102  }
103 
109  string evaDir() {
110  return this->core.path;
111  }
112  };
113 
117  enum ItemKind {
118  Unit,
119  Sensor,
120  LVar,
121  LMacro,
122  Any
123  };
124 
125  struct errorMapStr : public map<int16_t, string>
126  {
127  errorMapStr()
128  {
129  this->operator[](-32001) = "Not found";
130  this->operator[](-32002) = "Access denied";
131  this->operator[](-32003) = "System error";
132  this->operator[](-32004) = "Other";
133  this->operator[](-32005) = "Not ready";
134  this->operator[](-32006) = "Unsupported";
135  this->operator[](-32007) = "Core error";
136  this->operator[](-32008) = "Timeout";
137  this->operator[](-32009) = "Invalid data";
138  this->operator[](-32010) = "Function failed";
139  this->operator[](-32011) = "Aborted";
140  this->operator[](-32012) = "Resource already existS";
141  this->operator[](-32013) = "Busy";
142  this->operator[](-32014) = "Method not implemented";
143  this->operator[](-32015) = "Token restricted";
144  this->operator[](-32016) = "I/O";
145  this->operator[](-32017) = "Registry";
146  this->operator[](-32018) = "evaHI auth required";
147  this->operator[](-32022) = "Access denied more data required";
148  this->operator[](-32700) = "Parse error";
149  this->operator[](-32600) = "Invalid request";
150  this->operator[](-32601) = "Method not found";
151  this->operator[](-32602) = "Invalid params";
152  this->operator[](-32603) = "Internal RPC";
153  this->operator[](-32113) = "Bus client not registered";
154  this->operator[](-32114) = "Bus data";
155  this->operator[](-32115) = "Bus io";
156  this->operator[](-32116) = "Bus other";
157  this->operator[](-32117) = "Bus not supported";
158  this->operator[](-32118) = "Bus busy";
159  this->operator[](-32119) = "Bus not delivered";
160  this->operator[](-32120) = "Bus timeout";
161  this->operator[](-32121) = "Bus access";
162  };
163  };
164 
169 
170  struct itemKindMap : public map<string, ItemKind>
171  {
172  itemKindMap()
173  {
174  this->operator[]("unit") = Unit;
175  this->operator[]("sensor") = Sensor;
176  this->operator[]("lvar") = LVar;
177  this->operator[]("lmacro") = LMacro;
178  this->operator[]("+") = Any;
179  };
180  };
181 
182  struct itemKindMapStr : public map<ItemKind, string>
183  {
185  {
186  this->operator[](Unit) = "unit";
187  this->operator[](Sensor) = "sensor";
188  this->operator[](LVar) = "lvar";
189  this->operator[](LMacro) = "lmacro";
190  this->operator[](Any) = "+";
191  };
192  };
193 
202  };
203 
207  class Exception : public exception {
208  public:
214  Exception(int16_t code) {
215  this->code = code;
216  stringstream ss;
217  auto i = vars::errorMap.find(code);
218  if (i != vars::errorMap.end()) {
219  ss << i->second << ' ';
220  }
221  ss << '(' << this->code << ')';
222  this->msg = ss.str();
223  }
224  char * what() {
225  return (char *)this->msg.c_str();
226  }
230  void log() {
231  cerr << this->msg << endl << flush;
232  }
238  void log(string context) {
239  cerr << context << ": " << this->msg << endl << flush;
240  }
241  int16_t code;
242  private:
243  string msg;
244  };
245 
249  struct RawItemStatus {
250  int16_t status;
251 
252  MSGPACK_DEFINE_MAP(status);
253  };
254 
260  template <typename T>
261  struct RawItemState {
262  int16_t status;
263  T value;
264 
265  MSGPACK_DEFINE_MAP(status, value);
266  };
267 
271  struct CallParamsId {
272  string i;
273 
274  MSGPACK_DEFINE_MAP(i);
275  };
276 
277  atomic<int32_t (*)(int16_t op_code, struct EvaFFIBuffer* payload)> svc_op_fn(nullptr);
278 
279  stringstream packStrings(vector<string>& strings) {
280  stringstream ss;
281  for (const auto& s : strings) {
282  ss << s;
283  ss.put(0);
284  }
285  return ss;
286  }
287 
293  int32_t svcOp(int16_t op_code) {
294  return svc_op_fn ? svc_op_fn(op_code, nullptr) : EVA_ERR_CODE_NOT_READY;
295  }
296 
303  int32_t svcOpSS(int16_t op_code, stringstream& ss) {
304  size_t size = ss.tellp();
305  char* buf = (char *)malloc(size);
306  struct EvaFFIBuffer payload = EvaFFIBuffer { size, buf, size };
307  memcpy(payload.data, ss.str().c_str(), size);
308  int32_t res = svc_op_fn(op_code, &payload);
309  free(buf);
310  return res;
311  }
312 
318  bool active() {
319  return svcOp(EVA_FFI_SVC_OP_IS_ACTIVE) == 1;
320  }
321 
328  void c2e(int16_t code) {
329  if (code < EVA_OK) {
330  throw Exception(code);
331  }
332  }
333 
341  void subscribe(vector<string>& topics) {
342  stringstream ss = packStrings(topics);
343  c2e(svcOpSS(EVA_FFI_SVC_OP_SUBSCRIBE_TOPIC, ss));
344  }
345 
353  void subscribe(string topic) {
354  stringstream ss;
355  ss << topic;
356  c2e(svcOpSS(EVA_FFI_SVC_OP_SUBSCRIBE_TOPIC, ss));
357  }
358 
366  void unsubscribe(vector<string>& topics) {
367  stringstream ss = packStrings(topics);
368  c2e(svcOpSS(EVA_FFI_SVC_OP_UNSUBSCRIBE_TOPIC, ss));
369  }
370 
378  void unsubscribe(string topic) {
379  stringstream ss;
380  ss << topic;
381  c2e(svcOpSS(EVA_FFI_SVC_OP_UNSUBSCRIBE_TOPIC, ss));
382  }
383 
394  template <typename T> void publish(string topic, T data) {
395  stringstream ss;
396  ss << topic;
397  ss.put(0);
398  msgpack::pack(ss, data);
399  c2e(svcOpSS(EVA_FFI_SVC_OP_PUBLISH_TOPIC, ss));
400  }
401 
405  class OID {
406  public:
407  OID() {
408  this->kind = vars::ItemKind::Any;
409  this->i = string();
410  this->path = string();
411  this->rawTopic = string();
412  }
420  OID(string s) {
421  this->parse(s, false);
422  }
431  OID(string s, bool fromPath) {
432  this->parse(s, fromPath);
433  }
439  string fullId() {
440  return this->i.substr(this->pos + 1);
441  }
447  void markOk() {
448  publish(this->rawTopic, RawItemStatus{ EVA_ITEM_STATUS_OK });
449  }
455  void markError() {
456  publish(this->rawTopic, RawItemStatus{ EVA_ITEM_STATUS_ERROR });
457  }
467  template<typename T> void setState(T value) {
468  publish(this->rawTopic, RawItemState<T>{ EVA_ITEM_STATUS_OK, value });
469  }
473  string i;
475  string path;
477  string rawTopic;
478  bool operator==(const OID& other) const {
479  return this->i==other.i;
480  }
481  private:
482  void parse(string s, bool fromPath) {
483  char sep = fromPath?'/':':';
484  size_t pos = s.find(sep);
485  if (pos == string::npos) {
486  string opk = fromPath?"oid path":"oid";
487  throw invalid_argument("invalid " + opk + ": " + s);
488  }
489  string sKind = s.substr(0, pos);
490  auto i = vars::itemMapK.find(sKind);
491  if (i == vars::itemMapK.end()) {
492  throw invalid_argument("invalid oid kind: " + s);
493  }
494  string full_id = s.substr(pos + 1);
495  this->kind = i->second;
496  this->i = fromPath?sKind+":"+full_id:s;
497  this->path = fromPath?s:sKind+"/"+full_id;
498  this->rawTopic = EVA_RAW_STATE_TOPIC + this->path;
499  }
500  size_t pos;
501  };
502 
503  ostream& operator<<(ostream &strm, const OID &o) {
504  return strm << o.i;
505  }
506 
507  thread_local stringstream result_buf;
508 
509  size_t rp() {
510  return result_buf.tellp();
511  }
512 
516  namespace controller {
517 
518  using namespace std;
519 
520  typedef uint8_t uuidBuf[16];
521 
523  uint8_t status;
524  uuidBuf uuid;
525 
526  MSGPACK_DEFINE_MAP(uuid, status)
527  };
528 
530  uint8_t status;
531  string out;
532  int8_t exitcode;
533  uuidBuf uuid;
534 
535  MSGPACK_DEFINE_MAP(uuid, status, out, exitcode)
536  };
537 
539  uint8_t status;
540  string err;
541  int8_t exitcode;
542  uuidBuf uuid;
543 
544  MSGPACK_DEFINE_MAP(uuid, status, err, exitcode)
545  };
546 
552  template <typename V> struct UnitActionParams {
553  V value;
554 
555  MSGPACK_DEFINE_MAP(value)
556  };
557 
563  template <typename T> struct ActionData {
564  uuidBuf uuid;
565  string i;
566  uint32_t timeout;
567  uint8_t priority;
568  T params;
569 
570  MSGPACK_DEFINE_MAP(uuid,i,timeout,priority,params)
571  };
572 
573  struct ActionDataOID {
574  string i;
575 
576  MSGPACK_DEFINE_MAP(i)
577  };
578 
584  template <typename T> class Action {
585  public:
592  copy(begin(a.uuid), end(a.uuid), begin(this->uuid));
593  this->oid = a.i;
594  this->timeout = chrono::microseconds(a.timeout);
595  this->priority = a.priority;
596  this->params = a.params;
597  this->topic = string(EVA_ACTION_STATUS_TOPIC) + this->oid.path;
598  }
604  void markPending() {
605  this->markAction(EVA_ACTION_STATUS_PENDING);
606  }
612  void markRunning() {
613  this->markAction(EVA_ACTION_STATUS_RUNNING);
614  }
622  void markCompleted(string out) {
623  BusActionStatusCompleted a = { EVA_ACTION_STATUS_COMPLETED, out, 0 };
624  copy(begin(this->uuid), end(this->uuid), begin(a.uuid));
625  publish<BusActionStatusCompleted>(this->topic, a);
626  }
635  void markFailed(string err, int8_t exitcode) {
636  BusActionStatusError a { EVA_ACTION_STATUS_FAILED, err, exitcode };
637  copy(begin(this->uuid), end(this->uuid), begin(a.uuid));
638  publish<BusActionStatusError>(this->topic, a);
639  }
645  void markCanceled() {
646  this->markAction(EVA_ACTION_STATUS_CANCELED);
647  }
653  void markTerminated() {
654  this->markAction(EVA_ACTION_STATUS_TERMINATED);
655  }
657  uuidBuf uuid;
661  chrono::microseconds timeout;
663  uint8_t priority;
666  private:
667  string topic;
668  void markAction(uint8_t status) {
669  BusActionStatusShort a { status };
670  copy(begin(this->uuid), end(this->uuid), begin(a.uuid));
671  publish<BusActionStatusShort>(this->topic, a);
672  }
673  };
674 
675  };
676 
677  struct SvcMethodParam {
678  bool required;
679 
680  MSGPACK_DEFINE_MAP(required);
681  };
682 
683  struct SvcMethod {
684  string description;
685  map<string, SvcMethodParam> params;
686 
687  MSGPACK_DEFINE_MAP(description, params);
688  };
689 
694  public:
698  ServiceMethod(string name) {
699  this->name = name;
700  this->description= "";
701  }
706  ServiceMethod(string name, string description) {
707  this->name = name;
708  this->description= description;
709  }
715  ServiceMethod required(string name) {
716  this->params.insert(pair<string, SvcMethodParam>(name, SvcMethodParam { required: true }));
717  return *this;
718  }
724  ServiceMethod optional(string name) {
725  this->params.insert(pair<string, SvcMethodParam>(name, SvcMethodParam { required: false }));
726  return *this;
727  }
728  string name;
729  string description;
730  map<string, SvcMethodParam> params;
731  };
732 
736  struct ServiceInfo {
742  ServiceInfo(string author, string version, string description) {
743  this->author = author;
744  this->version = version;
745  this->description = description;
746  }
754  methods.insert(pair<string, SvcMethod>(method.name, SvcMethod {method.description, method.params}));
755  return *this;
756  }
757  string author;
758  string version;
759  string description;
760  map<string, SvcMethod> methods;
761 
762  MSGPACK_DEFINE_MAP(author, version, description, methods);
763  };
764 
776  template <typename T> vars::Initial<T> unpackInitial(EvaFFIBuffer *buf) {
777  msgpack::object_handle oh = msgpack::unpack(buf->data, buf->len);
778  msgpack::object const& obj = oh.get();
779  auto p = obj.as<vars::Initial<T>>();
780  return p;
781  }
782 
786  class Frame {
787  public:
791  Frame(EvaFFIFrame* r) {
792  this->r = r;
793  }
797  string primary_sender() {
798  return string(this->r->primary_sender);
799  }
803  string topic() {
804  return string(this->r->topic);
805  }
809  bool hasPayload() {
810  return this->r->payload_size > 0;
811  }
817  msgpack::object_handle unpack() {
818  msgpack::object_handle oh = msgpack::unpack(this->r->payload, this->r->payload_size);
819  return oh;
820  }
821  private:
822  EvaFFIFrame* r;
823  };
824 
828  class RpcEvent {
829  public:
833  RpcEvent(EvaFFIRpcEvent* r) {
834  this->r = r;
835  }
839  string primary_sender() {
840  return string(this->r->primary_sender);
841  }
845  string parse_method() {
846  return string(this->r->method, this->r->method_size);
847  }
851  bool hasPayload() {
852  return this->r->payload_size > 0;
853  }
859  msgpack::object_handle unpack() {
860  msgpack::object_handle oh = msgpack::unpack(this->r->payload, this->r->payload_size);
861  return oh;
862  }
871  if (this->hasPayload()) {
872  msgpack::object_handle oh=this->unpack();
873  msgpack::object const& obj = oh.get();
874  auto a = obj.as<controller::ActionDataOID>();
875  return OID(a.i);
876  } else {
877  throw Exception(EVA_ERR_CODE_INVALID_PARAMS);
878  }
879  }
890  if (this->hasPayload()) {
891  msgpack::object_handle oh=this->unpack();
892  msgpack::object const& obj = oh.get();
894  return a;
895  } else {
896  throw Exception(EVA_ERR_CODE_INVALID_PARAMS);
897  }
898  }
899  private:
900  EvaFFIRpcEvent* r;
901  };
902 
906  class RpcResult {
907  public:
908  RpcResult(int32_t res) {
909  if (res > 0) {
910  size_t size = (size_t)res;
911  char* data = (char *)malloc(size);
912  this->buf = EvaFFIBuffer { size, data, size };
913  this->code = 0;
914  this->size = size;
915  this->getCallResult();
916  this->data = data;
917  } else {
918  this->code = (int16_t)res;
919  this->size = 0;
920  }
921  }
925  bool hasPayload() {
926  return this->size > 0;
927  }
933  msgpack::object_handle unpack() {
934  msgpack::object_handle oh = msgpack::unpack(this->buf.data, this->buf.len);
935  return oh;
936  }
937  ~RpcResult() {
938  free(this->data);
939  }
940  int16_t code;
941  size_t size;
942  EvaFFIBuffer buf;
943  private:
944  void getCallResult() {
945  int16_t code = svc_op_fn(EVA_FFI_SVC_OP_GET_RPC_RESULT, &this->buf);
946  if (code != EVA_OK) {
947  this->size = 0;
948  this->code = EVA_ERR_CODE_CORE_ERROR;
949  }
950  }
951  char* data;
952  };
953 
967  template <typename T> RpcResult rpcCall(string target, string method, T params) {
968  stringstream ss;
969  ss << target;
970  ss.put(0);
971  ss << method;
972  ss.put(0);
973  msgpack::pack(ss, params);
974  int32_t res = svcOpSS(EVA_FFI_SVC_OP_RPC_CALL, ss);
975  c2e(res);
976  RpcResult rpc_result = RpcResult(res);
977  return rpc_result;
978  }
979 
990  RpcResult rpcCall(string target, string method) {
991  stringstream ss;
992  ss << target;
993  ss.put(0);
994  ss << method;
995  int32_t res = svcOpSS(EVA_FFI_SVC_OP_RPC_CALL, ss);
996  c2e(res);
997  RpcResult rpc_result = RpcResult(res);
998  return rpc_result;
999  }
1000 
1010  template<typename T> int32_t result(T payload) {
1011  msgpack::pack(result_buf, payload);
1012  return result_buf.tellp();
1013  }
1014 
1020  void terminate() {
1021  c2e(svcOp(EVA_FFI_SVC_OP_TERMINATE));
1022  }
1023 
1028  void poc() {
1029  stringstream ss;
1030  c2e(svcOpSS(EVA_FFI_SVC_OP_POC, ss));
1031  }
1032 
1039  void poc(string message) {
1040  stringstream ss;
1041  ss << message;
1042  c2e(svcOpSS(EVA_FFI_SVC_OP_POC, ss));
1043  }
1044 
1051  void poc(exception& e) {
1052  stringstream ss;
1053  ss << e.what();
1054  c2e(svcOpSS(EVA_FFI_SVC_OP_POC, ss));
1055  }
1056 
1064  void poc(exception& e, string context) {
1065  stringstream ss;
1066  ss << context;
1067  ss << ' ';
1068  ss << e.what();
1069  c2e(svcOpSS(EVA_FFI_SVC_OP_POC, ss));
1070  }
1071 
1072  struct coreStatus {
1073  bool active = false;
1074 
1075  MSGPACK_DEFINE_MAP(active);
1076  };
1077 
1083  bool coreActive() {
1084  RpcResult r = rpcCall("eva.core", "test");
1085  msgpack::object_handle oh = r.unpack();
1086  msgpack::object const& obj = oh.get();
1087  auto p = obj.as<coreStatus>();
1088  return p.active;
1089  }
1090 
1096  void waitCore() {
1097  while (!coreActive()) {
1098  this_thread::sleep_for(vars::sleepStep);
1099  }
1100  }
1101 
1109  void waitCore(chrono::milliseconds timeout) {
1110  const auto waitUntil = chrono::steady_clock::now() + timeout;
1111  while (!coreActive()) {
1112  this_thread::sleep_for(vars::sleepStep);
1113  if (chrono::steady_clock::now() >= waitUntil) {
1114  throw Exception(EVA_ERR_CODE_TIMEOUT);
1115  }
1116  }
1117  }
1118 
1122  namespace log {
1123 
1129  void trace(string message) {
1130  stringstream ss;
1131  ss << message;
1132  svcOpSS(EVA_FFI_SVC_OP_LOG_TRACE, ss);
1133  }
1134 
1140  void debug(string message) {
1141  stringstream ss;
1142  ss << message;
1143  svcOpSS(EVA_FFI_SVC_OP_LOG_DEBUG, ss);
1144  }
1145 
1151  void info(string message) {
1152  stringstream ss;
1153  ss << message;
1154  svcOpSS(EVA_FFI_SVC_OP_LOG_INFO, ss);
1155  }
1156 
1162  void warn(string message) {
1163  stringstream ss;
1164  ss << message;
1165  svcOpSS(EVA_FFI_SVC_OP_LOG_WARN, ss);
1166  }
1167 
1173  void error(string message) {
1174  stringstream ss;
1175  ss << message;
1176  svcOpSS(EVA_FFI_SVC_OP_LOG_ERROR, ss);
1177  }
1178 
1184  void o(string message) {
1185  cout << message << endl << flush;
1186  }
1187 
1193  void e(string message) {
1194  cerr << message << endl << flush;
1195  }
1196 
1203  void e(exception& e, string context) {
1204  cerr << context << ": " << e.what() << endl << flush;
1205  }
1206 
1212  void e(exception& e) {
1213  cerr << e.what() << endl << flush;
1214  }
1215 
1216  }
1217 
1218  namespace internal {
1219 
1220  extern "C" {
1221 
1222  int16_t eva_svc_get_result(struct EvaFFIBuffer *ebuf) {
1223  size_t size = eva::result_buf.tellp();
1224  if (size > ebuf->max) return EVA_ERR_CODE_ABORTED;
1225  ebuf->len = size;
1226  memcpy(ebuf->data, result_buf.str().c_str(), size);
1227  result_buf.str(string());
1228  return EVA_OK;
1229  }
1230 
1231  int16_t eva_svc_set_op_fn(uint16_t abi_version, int32_t (*f)(int16_t, struct EvaFFIBuffer*)) {
1232  if (abi_version != ABI_VERSION) {
1233  return EVA_ERR_CODE_UNSUPPORTED;
1234  }
1235  svc_op_fn = f;
1236  return EVA_OK;
1237  }
1238 
1239  }
1240 
1241  };
1242 
1243 }
1244 
1245 #endif
eva::vars::TimeoutConfig
Definition: eva4-ffi-sdk.hpp:34
eva::log::e
void e(string message)
Definition: eva4-ffi-sdk.hpp:1193
eva::OID::rawTopic
string rawTopic
Definition: eva4-ffi-sdk.hpp:477
eva::controller::Action::markPending
void markPending()
Definition: eva4-ffi-sdk.hpp:604
eva::vars::TimeoutConfig::startup
chrono::milliseconds startup
Definition: eva4-ffi-sdk.hpp:36
eva::vars::itemMapK
itemKindMap itemMapK
Definition: eva4-ffi-sdk.hpp:197
eva::Frame::hasPayload
bool hasPayload()
Definition: eva4-ffi-sdk.hpp:809
eva::RpcEvent::asUnitAction
controller::Action< controller::UnitActionParams< T > > asUnitAction()
Definition: eva4-ffi-sdk.hpp:889
eva::ServiceInfo::ServiceInfo
ServiceInfo(string author, string version, string description)
Definition: eva4-ffi-sdk.hpp:742
eva::log::error
void error(string message)
Definition: eva4-ffi-sdk.hpp:1173
eva::OID::markOk
void markOk()
Definition: eva4-ffi-sdk.hpp:447
eva::vars::TimeoutConfig::_default
chrono::milliseconds _default
Definition: eva4-ffi-sdk.hpp:40
eva::controller::Action::priority
uint8_t priority
Definition: eva4-ffi-sdk.hpp:663
eva
Definition: eva4-ffi-sdk.hpp:16
eva::vars::Initial::getTimeout
chrono::milliseconds getTimeout()
Definition: eva4-ffi-sdk.hpp:100
eva::RpcEvent::RpcEvent
RpcEvent(EvaFFIRpcEvent *r)
Definition: eva4-ffi-sdk.hpp:833
eva::RawItemStatus
Definition: eva4-ffi-sdk.hpp:249
eva::vars::errorMapStr
Definition: eva4-ffi-sdk.hpp:125
eva::log::info
void info(string message)
Definition: eva4-ffi-sdk.hpp:1151
eva::unpackInitial
vars::Initial< T > unpackInitial(EvaFFIBuffer *buf)
Definition: eva4-ffi-sdk.hpp:776
eva::ServiceMethod::optional
ServiceMethod optional(string name)
Definition: eva4-ffi-sdk.hpp:724
eva::vars::TimeoutConfig::shutdown
chrono::milliseconds shutdown
Definition: eva4-ffi-sdk.hpp:38
eva::controller::Action::oid
OID oid
Definition: eva4-ffi-sdk.hpp:659
eva::ServiceMethod::required
ServiceMethod required(string name)
Definition: eva4-ffi-sdk.hpp:715
eva::result
int32_t result(T payload)
Definition: eva4-ffi-sdk.hpp:1010
eva::OID::OID
OID(string s)
Definition: eva4-ffi-sdk.hpp:420
eva::controller::Action::Action
Action(ActionData< T > a)
Definition: eva4-ffi-sdk.hpp:591
eva::ServiceMethod::ServiceMethod
ServiceMethod(string name)
Definition: eva4-ffi-sdk.hpp:698
eva::vars::itemMapS
itemKindMapStr itemMapS
Definition: eva4-ffi-sdk.hpp:201
eva::Frame::Frame
Frame(EvaFFIFrame *r)
Definition: eva4-ffi-sdk.hpp:791
eva::log::debug
void debug(string message)
Definition: eva4-ffi-sdk.hpp:1140
eva::RpcEvent::unpack
msgpack::object_handle unpack()
Definition: eva4-ffi-sdk.hpp:859
eva::RpcEvent::asUnitActionOID
OID asUnitActionOID()
Definition: eva4-ffi-sdk.hpp:870
eva::controller::BusActionStatusShort
Definition: eva4-ffi-sdk.hpp:522
eva::OID::fullId
string fullId()
Definition: eva4-ffi-sdk.hpp:439
eva::poc
void poc()
Definition: eva4-ffi-sdk.hpp:1028
eva::log::trace
void trace(string message)
Definition: eva4-ffi-sdk.hpp:1129
eva::controller::UnitActionParams
Definition: eva4-ffi-sdk.hpp:552
eva::controller::Action::markTerminated
void markTerminated()
Definition: eva4-ffi-sdk.hpp:653
eva::Exception::log
void log()
Definition: eva4-ffi-sdk.hpp:230
eva::OID::markError
void markError()
Definition: eva4-ffi-sdk.hpp:455
eva::vars::errorMap
errorMapStr errorMap
Definition: eva4-ffi-sdk.hpp:168
eva::controller::ActionDataOID
Definition: eva4-ffi-sdk.hpp:573
eva::ServiceInfo::addMethod
ServiceInfo addMethod(ServiceMethod method)
Definition: eva4-ffi-sdk.hpp:753
eva::RpcResult
Definition: eva4-ffi-sdk.hpp:906
eva::vars::itemKindMap
Definition: eva4-ffi-sdk.hpp:170
eva::OID::i
string i
Definition: eva4-ffi-sdk.hpp:473
eva::active
bool active()
Definition: eva4-ffi-sdk.hpp:318
eva::RpcEvent
Definition: eva4-ffi-sdk.hpp:828
eva::svcOpSS
int32_t svcOpSS(int16_t op_code, stringstream &ss)
Definition: eva4-ffi-sdk.hpp:303
eva::controller::Action::params
T params
Definition: eva4-ffi-sdk.hpp:665
eva::controller::Action::markCompleted
void markCompleted(string out)
Definition: eva4-ffi-sdk.hpp:622
eva::vars::itemKindMapStr
Definition: eva4-ffi-sdk.hpp:182
eva::controller::BusActionStatusError
Definition: eva4-ffi-sdk.hpp:538
eva::vars::Initial::evaDir
string evaDir()
Definition: eva4-ffi-sdk.hpp:109
eva::vars::ItemKind
ItemKind
Definition: eva4-ffi-sdk.hpp:117
eva::ServiceMethod
Definition: eva4-ffi-sdk.hpp:693
eva::Exception::log
void log(string context)
Definition: eva4-ffi-sdk.hpp:238
eva::RpcEvent::hasPayload
bool hasPayload()
Definition: eva4-ffi-sdk.hpp:851
eva::Frame::unpack
msgpack::object_handle unpack()
Definition: eva4-ffi-sdk.hpp:817
eva::svcOp
int32_t svcOp(int16_t op_code)
Definition: eva4-ffi-sdk.hpp:293
eva::Exception
Definition: eva4-ffi-sdk.hpp:207
eva::OID::path
string path
Definition: eva4-ffi-sdk.hpp:475
eva::Exception::Exception
Exception(int16_t code)
Definition: eva4-ffi-sdk.hpp:214
eva::controller::BusActionStatusCompleted
Definition: eva4-ffi-sdk.hpp:529
eva::c2e
void c2e(int16_t code)
Definition: eva4-ffi-sdk.hpp:328
eva::ServiceMethod::ServiceMethod
ServiceMethod(string name, string description)
Definition: eva4-ffi-sdk.hpp:706
eva::RpcEvent::primary_sender
string primary_sender()
Definition: eva4-ffi-sdk.hpp:839
eva::rpcCall
RpcResult rpcCall(string target, string method, T params)
Definition: eva4-ffi-sdk.hpp:967
eva::terminate
void terminate()
Definition: eva4-ffi-sdk.hpp:1020
eva::controller::Action::markCanceled
void markCanceled()
Definition: eva4-ffi-sdk.hpp:645
eva::subscribe
void subscribe(vector< string > &topics)
Definition: eva4-ffi-sdk.hpp:341
eva::waitCore
void waitCore()
Definition: eva4-ffi-sdk.hpp:1096
eva::RpcEvent::parse_method
string parse_method()
Definition: eva4-ffi-sdk.hpp:845
eva::log::warn
void warn(string message)
Definition: eva4-ffi-sdk.hpp:1162
eva::log::o
void o(string message)
Definition: eva4-ffi-sdk.hpp:1184
eva::OID::OID
OID(string s, bool fromPath)
Definition: eva4-ffi-sdk.hpp:431
eva::controller::Action
Definition: eva4-ffi-sdk.hpp:584
eva::vars::CoreInfo
Definition: eva4-ffi-sdk.hpp:64
eva::controller::Action::markRunning
void markRunning()
Definition: eva4-ffi-sdk.hpp:612
eva::RawItemState
Definition: eva4-ffi-sdk.hpp:261
eva::RpcResult::hasPayload
bool hasPayload()
Definition: eva4-ffi-sdk.hpp:925
eva::CallParamsId
Definition: eva4-ffi-sdk.hpp:271
eva::controller::Action::markFailed
void markFailed(string err, int8_t exitcode)
Definition: eva4-ffi-sdk.hpp:635
eva::coreActive
bool coreActive()
Definition: eva4-ffi-sdk.hpp:1083
eva::unsubscribe
void unsubscribe(vector< string > &topics)
Definition: eva4-ffi-sdk.hpp:366
eva::controller::Action::uuid
uuidBuf uuid
Definition: eva4-ffi-sdk.hpp:657
eva::SvcMethod
Definition: eva4-ffi-sdk.hpp:683
eva::Frame::topic
string topic()
Definition: eva4-ffi-sdk.hpp:803
eva::ServiceInfo
Definition: eva4-ffi-sdk.hpp:736
eva::vars::Initial
Definition: eva4-ffi-sdk.hpp:79
eva::Frame
Definition: eva4-ffi-sdk.hpp:786
eva::OID::kind
vars::ItemKind kind
Definition: eva4-ffi-sdk.hpp:471
eva::SvcMethodParam
Definition: eva4-ffi-sdk.hpp:677
eva::controller::ActionData
Definition: eva4-ffi-sdk.hpp:563
eva::coreStatus
Definition: eva4-ffi-sdk.hpp:1072
eva::OID
Definition: eva4-ffi-sdk.hpp:405
eva::RpcResult::unpack
msgpack::object_handle unpack()
Definition: eva4-ffi-sdk.hpp:933
eva::Frame::primary_sender
string primary_sender()
Definition: eva4-ffi-sdk.hpp:797
eva::controller::Action::timeout
chrono::microseconds timeout
Definition: eva4-ffi-sdk.hpp:661
eva::publish
void publish(string topic, T data)
Definition: eva4-ffi-sdk.hpp:394
eva::OID::setState
void setState(T value)
Definition: eva4-ffi-sdk.hpp:467
The official SDK for EVA ICS
Technical documentation: https://info.bma.ai/en/actual/eva4/sdk/cpp/
© Bohemia Automation / Altertech