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>
55#define LOCAL_SECTION LOG_APP
56#define LOCAL_LEVEL LOG_DEF_LEVEL
60#define AM_UNDEFINED_VALUE -9999.99
64 AM_TYPE_UNDEFINED = 0,
65 AM_TYPE_MEDIAL_INFRA = 1
73extern "C" class DLL_WORK_MODE
AMPoint {
76 long long timestamp = -1;
78 void set(
int _pid,
long long _timestamp) { pid = _pid; timestamp = _timestamp; }
80 void clear() { pid = -1; timestamp = -1; }
89 vector<string> args_strs;
92 int need_to_update_args = 0;
97 int get_n_msgs() {
return (
int)codes.size(); }
98 void get_messages(
int *n_msgs,
int **msgs_codes,
char ***msgs_args);
101 void insert_message(
int code,
const char *arg_ch);
113extern "C" class DLL_WORK_MODE
AMScore {
116 char *p_score_type = NULL;
117 float score = (float)AM_UNDEFINED_VALUE;
122 void get_score(
float *_score,
char **_score_type)
125 *_score_type = p_score_type;
138 void set_score_type(
char *_score_type) { p_score_type = _score_type; }
139 void set_score(
float _score) { score = _score; }
146 score = (float)AM_UNDEFINED_VALUE;
156 vector<AMScore> scores;
164 vector<string> verificationConfig;
165 map<string, int> scoresIndexs;
166 int need_to_update_scoreTypes = 0;
169 int get_patient_id() {
return point.pid; }
170 long long get_timestamp() {
return point.timestamp; }
171 int get_n_scores() {
return (
int)scores.size(); }
172 AMScore *get_am_score(
int idx) {
if (idx < 0 || idx >= scores.size())
return NULL;
return &scores[idx]; }
173 int get_score(
int idx,
float *_score,
char **_score_type) {
174 if (idx < 0 || idx >= scores.size())
return AM_FAIL_RC;
175 scores[idx].get_score(_score, _score_type);
178 AMMessages *get_score_msgs(
int idx) {
if (idx < 0 || idx >= scores.size())
return NULL;
return scores[idx].get_msgs(); }
182 void set_patient_id(
int _patient_id) { point.pid = _patient_id; }
183 void set_timestamp(
long long _timestamp) { point.timestamp = _timestamp; }
184 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); }
185 void init_scores(
int size) { scores.clear(); scores.resize(size); }
190 for (
auto element : scores)
208 long long* TimeStamps;
230 long long* TimeStamps;
249 string requestId =
"";
254 vector<AMResponse> responses;
258 vector<string> score_types_str;
259 vector<char *> score_types;
266 vector<string> verificationConfig;
269 int get_n_responses()
271 return (
int)responses.size();
273 AMResponse *get_response(
int index) {
if (index >= (
int)responses.size())
return NULL;
return &(responses[index]); }
274 int get_response_index_by_point(
int _pid,
long long _timestamp);
276 void get_score_types(
int *n_score_types,
char ***_score_types);
277 AMMessages *get_shared_messages() {
return &shared_msgs; }
278 char *get_request_id() {
return (
char *)requestId.c_str(); }
279 char *get_version() {
return (
char *)version.c_str(); }
280 int get_score(
int _pid,
long long _timestamp,
char *_score_type,
float *out_score);
281 int get_score_by_type(
int index,
char *_score_type,
float *out_score);
282 vector<char *> *get_score_type_vec_ptr() {
return &score_types; }
285 void set_request_id(
char *request_id) { requestId = string(request_id); }
286 void set_version(
char *_version) { version = string(_version); }
287 void insert_score_types(
char **_score_type,
int n_score_types);
288 AMResponse *create_point_response(
int _pid,
long long _timestamp);
294 for (
auto element : responses)
300 score_types_str.clear();
309extern "C" class DLL_WORK_MODE
AMRequest {
314 string requestId =
"";
318 vector<string> score_types_str;
321 vector<AMPoint> points;
325 vector<string> verificationConfig;
329 char *get_request_id() {
return (
char *)requestId.c_str(); }
330 int get_n_score_types() {
return (
int)score_types_str.size(); }
331 char *get_score_type(
int index) {
if (index >= get_n_score_types())
return NULL;
return (
char *)score_types_str[index].c_str(); }
332 int get_n_points() {
return (
int)points.size(); }
333 AMPoint *get_point(
int index) {
if (index >= get_n_points())
return NULL;
return &points[index]; }
334 int get_pid(
int index) {
if (index >= get_n_points())
return -1;
return points[index].pid; }
335 long long get_timestamp(
int index) {
if (index >= get_n_points())
return -1;
return points[index].timestamp; }
338 void set_request_id(
char *req_id) { requestId = string(req_id); }
339 void insert_point(
int _pid,
long long _timestamp) {
AMPoint p; p.set(_pid, _timestamp); points.push_back(p); }
340 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])); }
345 for (
auto element : points)
350 score_types_str.clear();
363 string config_fname =
"";
364 vector<string> supported_score_types;
372 virtual int Load(
const char *config_f) {
return 0; }
373 virtual int Unload() {
return 0; }
374 virtual int ClearData() {
return 0; }
375 virtual int AddData(
int patient_id,
const char *signalName,
int TimeStamps_len,
long long* TimeStamps,
int Values_len,
float* Values) {
return 0; }
376 virtual int AddDataStr(
int patient_id,
const char *signalName,
int TimeStamps_len,
long long* TimeStamps,
int Values_len,
char** Values) {
return 0; }
379 vector<AMData*> data;
380 vector<string> verificationConfig;
383 int IsScoreTypeSupported(
const char *_stype);
386 int get_type() {
return (
int)type; }
387 char *get_name() {
return (
char *)name.c_str(); }
388 char *get_config() {
return (
char *)config_fname.c_str(); }
391 void set_type(
int _type) { type = (AlgoMarkerType)_type; }
392 void set_name(
const char *_name) { name = string(_name); }
393 void set_config(
const char *_config_f) { config_fname = string(_config_f); }
394 void add_supported_stype(
const char *stype) { supported_score_types.push_back(
string(stype)); }
397 static AlgoMarker *make_algomarker(AlgoMarkerType am_type);
411 string type_in_config_file =
"";
412 string rep_fname =
"";
413 string model_fname =
"";
416 int read_config(
string conf_f);
424 set_type((
int)AM_TYPE_MEDIAL_INFRA);
425 add_supported_stype(
"Raw");
429 int Load(
const char *config_f);
432 int AddData(
int patient_id,
const char *signalName,
int TimeStamps_len,
long long* TimeStamps,
int Values_len,
float* Values);
433 int AddDataStr(
int patient_id,
const char *signalName,
int TimeStamps_len,
long long* TimeStamps,
int Values_len,
char** Values);
441 static ofstream *logFileStream;
443 static void closeLogFile();
444 static bool TurnOnLogs;
445 static vector<string> Arguments;
446 static const char* FunctionName;
447 static bool DoesEnterFunction;
448 static void WriteToLog(
string line);
449 static void FlushLogData();
450 static void StartFunction(
const char* function);
451 static int StartFunction(
int returnValue,
const char* function);
452 static void EndFunction(
const char* function);
453 static int EndFunction(
int returnValue,
const char* function);
454 static void AddArgument(
string argumentName,
string argument);
455 static void AddArgument(
string argumentName,
char* argument);
456 static void AddArgument(
string argumentName,
int* argument);
457 static void AddArgument(
string argumentName,
float* argument);
458 static void AddArgument(
string argumentName,
long long* argument);
459 static void AddArgument(
string argumentName,
unsigned long long argument);
460 static void AddArgument(
string argumentName,
int argument);
461 static void AddArgument(
string argumentName,
float argument);
462 static void AddArgument(
string argumentName,
long long argument);
463 static void AddArgument(
string argumentName,
char** argument);
464 static void AddArgument(
string argumentName,
int** argument,
int arraySize);
465 static void AddArgument(
string argumentName,
char*** argument,
int arraySize);
466 static void AddArgument(
string argumentName,
char** argument,
int arraySize);
467 static void AddArgument(
string argumentName,
long long* argument,
int arraySize);
468 static void AddArgument(
string argumentName,
int* argument,
int arraySize);
469 static void AddArgument(
string argumentName,
float* argument,
int arraySize);
470 static void AddArgument(
string argumentName,
AlgoMarker* argument);
471 static void AddArgument(
string argumentName,
AlgoMarker** argument);
472 static void AddArgument(
string argumentName,
AMRequest* argument);
473 static void AddArgument(
string argumentName,
AMRequest** argument);
474 static void AddArgument(
string argumentName,
AMResponses* argument);
475 static void AddArgument(
string argumentName,
AMResponses** argument);
476 static void AddArgument(
string argumentName,
AMResponse* argument);
477 static void AddArgument(
string argumentName,
AMResponse** argument);
488extern "C" DLL_WORK_MODE
int AM_API_Create(
int am_type,
AlgoMarker **new_am);
491extern "C" DLL_WORK_MODE
int AM_API_Load(
AlgoMarker* pAlgoMarker,
const char *config_fname);
494extern "C" DLL_WORK_MODE
int AM_API_ClearData(
AlgoMarker* pAlgoMarker);
498extern "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);
502extern "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);
506extern "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);
513extern "C" DLL_WORK_MODE
int AM_API_CreateResponses(
AMResponses **new_responses);
516extern "C" DLL_WORK_MODE
int AM_API_GetResponsesNum(
AMResponses *responses);
517extern "C" DLL_WORK_MODE
int AM_API_GetSharedMessages(
AMResponses *responses,
int *n_msgs,
int **msgs_codes,
char ***msgs_args);
518extern "C" DLL_WORK_MODE
int AM_API_GetResponseIndex(
AMResponses *responses,
int _pid,
long long _timestamp);
520extern "C" DLL_WORK_MODE
int AM_API_GetResponseAtIndex(
AMResponses *responses,
int index,
AMResponse **response);
521extern "C" DLL_WORK_MODE
int AM_API_GetResponseScoresNum(
AMResponse *response,
int *n_scores);
523extern "C" DLL_WORK_MODE
int AM_API_GetResponseScoreByIndex(
AMResponse *response,
int score_index,
float *score,
char **_score_type);
524extern "C" DLL_WORK_MODE
int AM_API_GetScoreMessages(
AMResponse *response,
int score_index,
int *n_msgs,
int **msgs_codes,
char ***msgs_args);
525extern "C" DLL_WORK_MODE
int AM_API_GetResponseMessages(
AMResponse *response,
int *n_msgs,
int **msgs_codes,
char ***msgs_args);
527extern "C" DLL_WORK_MODE
int AM_API_GetResponsePoint(
AMResponse *response,
int *pid,
long long *timestamp);
529extern "C" DLL_WORK_MODE
int AM_API_GetResponsesRequestId(
AMResponses *responses,
char **requestId);
533extern "C" DLL_WORK_MODE
int AM_API_GetName(
AlgoMarker *pAlgoMArker,
char **name);
536extern "C" DLL_WORK_MODE
void AM_API_DisposeAlgoMarker(
AlgoMarker *pAlgoMarker);
539extern "C" DLL_WORK_MODE
void AM_API_DisposeRequest(
AMRequest *pRequest);
542extern "C" DLL_WORK_MODE
void AM_API_DisposeResponses(
AMResponses *responses);
544extern "C" DLL_WORK_MODE
int AM_API_GetResponseScoreByType(
AMResponses *responses,
int res_index,
char *_score_type,
float *out_score);
Definition SigSum_AlgoMarker.h:223
Definition SigSum_AlgoMarker.h:201
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:440