18#define _SCL_SECURE_NO_WARNINGS
21#define strncasecmp _strnicmp
22#define strcasecmp _stricmp
27#if defined AM_DLL_IMPORT
28#define DLL_WORK_MODE __declspec(dllimport)
30#define DLL_WORK_MODE __declspec(dllexport)
33#if defined AM_DLL_IMPORT
36#define DLL_WORK_MODE __attribute__ ((visibility ("default")))
41#pragma warning(disable: 4251)
47#include "SigSum_AlgoMarkerErr.h"
51#include <unordered_map>
54#define LOCAL_SECTION LOG_APP
55#define LOCAL_LEVEL LOG_DEF_LEVEL
59#define AM_UNDEFINED_VALUE -9999.99
63 AM_TYPE_UNDEFINED = 0,
64 AM_TYPE_MEDIAL_INFRA = 1
72extern "C" class DLL_WORK_MODE
AMPoint {
75 long long timestamp = -1;
77 void set(
int _pid,
long long _timestamp) { pid = _pid; timestamp = _timestamp; }
79 void clear() { pid = -1; timestamp = -1; }
88 vector<string> args_strs;
91 int need_to_update_args = 0;
96 int get_n_msgs() {
return (
int)codes.size(); }
97 void get_messages(
int *n_msgs,
int **msgs_codes,
char ***msgs_args);
100 void insert_message(
int code,
const char *arg_ch);
112extern "C" class DLL_WORK_MODE
AMScore {
115 char *p_score_type = NULL;
116 float score = (float)AM_UNDEFINED_VALUE;
121 void get_score(
float *_score,
char **_score_type)
124 *_score_type = p_score_type;
137 void set_score_type(
char *_score_type) { p_score_type = _score_type; }
138 void set_score(
float _score) { score = _score; }
145 score = (float)AM_UNDEFINED_VALUE;
155 vector<AMScore> scores;
163 vector<string> verificationConfig;
164 map<string, int> scoresIndexs;
165 int need_to_update_scoreTypes = 0;
168 int get_patient_id() {
return point.pid; }
169 long long get_timestamp() {
return point.timestamp; }
170 int get_n_scores() {
return (
int)scores.size(); }
171 AMScore *get_am_score(
int idx) {
if (idx < 0 || idx >= scores.size())
return NULL;
return &scores[idx]; }
172 int get_score(
int idx,
float *_score,
char **_score_type) {
173 if (idx < 0 || idx >= scores.size())
return AM_FAIL_RC;
174 scores[idx].get_score(_score, _score_type);
177 AMMessages *get_score_msgs(
int idx) {
if (idx < 0 || idx >= scores.size())
return NULL;
return scores[idx].get_msgs(); }
181 void set_patient_id(
int _patient_id) { point.pid = _patient_id; }
182 void set_timestamp(
long long _timestamp) { point.timestamp = _timestamp; }
183 void set_score(
int idx,
float _score,
char *_score_type) {
if (idx >= 0 && idx < scores.size()) scores[idx].set_score(_score); scores[idx].set_score_type(_score_type); }
184 void init_scores(
int size) { scores.clear(); scores.resize(size); }
189 for (
auto element : scores)
207 long long* TimeStamps;
229 long long* TimeStamps;
248 string requestId =
"";
253 vector<AMResponse> responses;
257 vector<string> score_types_str;
258 vector<char *> score_types;
265 vector<string> verificationConfig;
268 int get_n_responses()
270 return (
int)responses.size();
272 AMResponse *get_response(
int index) {
if (index >= (
int)responses.size())
return NULL;
return &(responses[index]); }
273 int get_response_index_by_point(
int _pid,
long long _timestamp);
275 void get_score_types(
int *n_score_types,
char ***_score_types);
276 AMMessages *get_shared_messages() {
return &shared_msgs; }
277 char *get_request_id() {
return (
char *)requestId.c_str(); }
278 char *get_version() {
return (
char *)version.c_str(); }
279 int get_score(
int _pid,
long long _timestamp,
char *_score_type,
float *out_score);
280 int get_score_by_type(
int index,
char *_score_type,
float *out_score);
281 vector<char *> *get_score_type_vec_ptr() {
return &score_types; }
284 void set_request_id(
char *request_id) { requestId =
string(request_id); }
285 void set_version(
char *_version) { version =
string(_version); }
286 void insert_score_types(
char **_score_type,
int n_score_types);
287 AMResponse *create_point_response(
int _pid,
long long _timestamp);
293 for (
auto element : responses)
299 score_types_str.clear();
308extern "C" class DLL_WORK_MODE
AMRequest {
313 string requestId =
"";
317 vector<string> score_types_str;
320 vector<AMPoint> points;
324 vector<string> verificationConfig;
328 char *get_request_id() {
return (
char *)requestId.c_str(); }
329 int get_n_score_types() {
return (
int)score_types_str.size(); }
330 char *get_score_type(
int index) {
if (index >= get_n_score_types())
return NULL;
return (
char *)score_types_str[index].c_str(); }
331 int get_n_points() {
return (
int)points.size(); }
332 AMPoint *get_point(
int index) {
if (index >= get_n_points())
return NULL;
return &points[index]; }
333 int get_pid(
int index) {
if (index >= get_n_points())
return -1;
return points[index].pid; }
334 long long get_timestamp(
int index) {
if (index >= get_n_points())
return -1;
return points[index].timestamp; }
337 void set_request_id(
char *req_id) { requestId =
string(req_id); }
338 void insert_point(
int _pid,
long long _timestamp) {
AMPoint p; p.set(_pid, _timestamp); points.push_back(p); }
339 void insert_score_types(
char **_score_types,
int n_score_types) {
for (
int i = 0; i<n_score_types; i++) score_types_str.push_back(
string(_score_types[i])); }
344 for (
auto element : points)
349 score_types_str.clear();
362 string config_fname =
"";
363 vector<string> supported_score_types;
371 virtual int Load(
const char *config_f) {
return 0; }
372 virtual int Unload() {
return 0; }
373 virtual int ClearData() {
return 0; }
374 virtual int AddData(
int patient_id,
const char *signalName,
int TimeStamps_len,
long long* TimeStamps,
int Values_len,
float* Values) {
return 0; }
375 virtual int AddDataStr(
int patient_id,
const char *signalName,
int TimeStamps_len,
long long* TimeStamps,
int Values_len,
char** Values) {
return 0; }
378 vector<AMData*> data;
379 vector<string> verificationConfig;
382 int IsScoreTypeSupported(
const char *_stype);
385 int get_type() {
return (
int)type; }
386 char *get_name() {
return (
char *)name.c_str(); }
387 char *get_config() {
return (
char *)config_fname.c_str(); }
390 void set_type(
int _type) { type = (AlgoMarkerType)_type; }
391 void set_name(
const char *_name) { name =
string(_name); }
392 void set_config(
const char *_config_f) { config_fname =
string(_config_f); }
393 void add_supported_stype(
const char *stype) { supported_score_types.push_back(
string(stype)); }
396 static AlgoMarker *make_algomarker(AlgoMarkerType am_type);
410 string type_in_config_file =
"";
411 string rep_fname =
"";
412 string model_fname =
"";
415 int read_config(
string conf_f);
423 set_type((
int)AM_TYPE_MEDIAL_INFRA);
424 add_supported_stype(
"Raw");
428 int Load(
const char *config_f);
431 int AddData(
int patient_id,
const char *signalName,
int TimeStamps_len,
long long* TimeStamps,
int Values_len,
float* Values);
432 int AddDataStr(
int patient_id,
const char *signalName,
int TimeStamps_len,
long long* TimeStamps,
int Values_len,
char** Values);
440 static ofstream *logFileStream;
442 static void closeLogFile();
443 static bool TurnOnLogs;
444 static vector<string> Arguments;
445 static const char* FunctionName;
446 static bool DoesEnterFunction;
447 static void WriteToLog(
string line);
448 static void FlushLogData();
449 static void StartFunction(
const char* function);
450 static int StartFunction(
int returnValue,
const char* function);
451 static void EndFunction(
const char* function);
452 static int EndFunction(
int returnValue,
const char* function);
453 static void AddArgument(
string argumentName,
string argument);
454 static void AddArgument(
string argumentName,
char* argument);
455 static void AddArgument(
string argumentName,
int* argument);
456 static void AddArgument(
string argumentName,
float* argument);
457 static void AddArgument(
string argumentName,
long long* argument);
458 static void AddArgument(
string argumentName,
unsigned long long argument);
459 static void AddArgument(
string argumentName,
int argument);
460 static void AddArgument(
string argumentName,
float argument);
461 static void AddArgument(
string argumentName,
long long argument);
462 static void AddArgument(
string argumentName,
char** argument);
463 static void AddArgument(
string argumentName,
int** argument,
int arraySize);
464 static void AddArgument(
string argumentName,
char*** argument,
int arraySize);
465 static void AddArgument(
string argumentName,
char** argument,
int arraySize);
466 static void AddArgument(
string argumentName,
long long* argument,
int arraySize);
467 static void AddArgument(
string argumentName,
int* argument,
int arraySize);
468 static void AddArgument(
string argumentName,
float* argument,
int arraySize);
469 static void AddArgument(
string argumentName,
AlgoMarker* argument);
470 static void AddArgument(
string argumentName,
AlgoMarker** argument);
471 static void AddArgument(
string argumentName,
AMRequest* argument);
472 static void AddArgument(
string argumentName,
AMRequest** argument);
473 static void AddArgument(
string argumentName,
AMResponses* argument);
474 static void AddArgument(
string argumentName,
AMResponses** argument);
475 static void AddArgument(
string argumentName,
AMResponse* argument);
476 static void AddArgument(
string argumentName,
AMResponse** argument);
487extern "C" DLL_WORK_MODE
int AM_API_Create(
int am_type,
AlgoMarker **new_am);
490extern "C" DLL_WORK_MODE
int AM_API_Load(
AlgoMarker* pAlgoMarker,
const char *config_fname);
493extern "C" DLL_WORK_MODE
int AM_API_ClearData(
AlgoMarker* pAlgoMarker);
497extern "C" DLL_WORK_MODE
int AM_API_AddData(
AlgoMarker* pAlgoMarker,
int patient_id,
const char *signalName,
int TimeStamps_len,
long long* TimeStamps,
int Values_len,
float* Values);
501extern "C" DLL_WORK_MODE
int AM_API_AddDataStr(
AlgoMarker* pAlgoMarker,
int patient_id,
const char *signalName,
int TimeStamps_len,
long long* TimeStamps,
int Values_len,
char** Values);
505extern "C" DLL_WORK_MODE
int AM_API_CreateRequest(
char *requestId,
char **score_types,
int n_score_types,
int *patient_ids,
long long *time_stamps,
int n_points,
AMRequest **new_req);
512extern "C" DLL_WORK_MODE
int AM_API_CreateResponses(
AMResponses **new_responses);
515extern "C" DLL_WORK_MODE
int AM_API_GetResponsesNum(
AMResponses *responses);
516extern "C" DLL_WORK_MODE
int AM_API_GetSharedMessages(
AMResponses *responses,
int *n_msgs,
int **msgs_codes,
char ***msgs_args);
517extern "C" DLL_WORK_MODE
int AM_API_GetResponseIndex(
AMResponses *responses,
int _pid,
long long _timestamp);
519extern "C" DLL_WORK_MODE
int AM_API_GetResponseAtIndex(
AMResponses *responses,
int index,
AMResponse **response);
520extern "C" DLL_WORK_MODE
int AM_API_GetResponseScoresNum(
AMResponse *response,
int *n_scores);
522extern "C" DLL_WORK_MODE
int AM_API_GetResponseScoreByIndex(
AMResponse *response,
int score_index,
float *score,
char **_score_type);
523extern "C" DLL_WORK_MODE
int AM_API_GetScoreMessages(
AMResponse *response,
int score_index,
int *n_msgs,
int **msgs_codes,
char ***msgs_args);
524extern "C" DLL_WORK_MODE
int AM_API_GetResponseMessages(
AMResponse *response,
int *n_msgs,
int **msgs_codes,
char ***msgs_args);
526extern "C" DLL_WORK_MODE
int AM_API_GetResponsePoint(
AMResponse *response,
int *pid,
long long *timestamp);
528extern "C" DLL_WORK_MODE
int AM_API_GetResponsesRequestId(
AMResponses *responses,
char **requestId);
532extern "C" DLL_WORK_MODE
int AM_API_GetName(
AlgoMarker *pAlgoMArker,
char **name);
535extern "C" DLL_WORK_MODE
void AM_API_DisposeAlgoMarker(
AlgoMarker *pAlgoMarker);
538extern "C" DLL_WORK_MODE
void AM_API_DisposeRequest(
AMRequest *pRequest);
541extern "C" DLL_WORK_MODE
void AM_API_DisposeResponses(
AMResponses *responses);
543extern "C" DLL_WORK_MODE
int AM_API_GetResponseScoreByType(
AMResponses *responses,
int res_index,
char *_score_type,
float *out_score);
Definition SigSum_AlgoMarker.h:222
Definition SigSum_AlgoMarker.h:200
Definition AlgoMarker.h:88
Definition AlgoMarker.h:74
Definition AlgoMarker.h:233
Definition AlgoMarker.h:136
Definition AlgoMarker.h:184
Definition AlgoMarker.h:113
Definition AlgoMarker.h:272
Definition SigSum_AlgoMarker.h:439