Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit 02b0bab

Browse files
adeas31OpenModelica-Hudson
authored andcommitted
Output the information when opc-ua server is initialized.
1 parent 0fc8e09 commit 02b0bab

File tree

5 files changed

+24
-9
lines changed

5 files changed

+24
-9
lines changed

SimulationRuntime/c/simulation/solver/embedded_server.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ void* no_embedded_server_init(DATA *data, double tout, double step, const char *
4747
return NULL;
4848
}
4949

50+
void no_wait_for_step(void *handle)
51+
{
52+
}
53+
5054
void no_embedded_server_deinit(void *handle)
5155
{
5256
}
@@ -57,14 +61,15 @@ int no_embedded_server_update(void *handle, double tout)
5761
}
5862

5963
void* (*embedded_server_init)(DATA *data, double tout, double step, const char *argv_0, void (*omc_real_time_sync_update)(DATA *data, double scaling), int port) = no_embedded_server_init;
64+
void (*wait_for_step)(void*) = no_wait_for_step;
6065
void (*embedded_server_deinit)(void*) = no_embedded_server_deinit;
6166
// Tells the embedded server that a simulation step has passed; the server
6267
// can read/write values from/to the simulator
6368
int (*embedded_server_update)(void*, double tout) = no_embedded_server_update;
6469

6570
void* embedded_server_load_functions(const char *server_name)
6671
{
67-
void *dll, *funcInit, *funcDeinit, *funcUpdate;
72+
void *dll, *funcInit, *funcWaitForStep, *funcDeinit, *funcUpdate;
6873
if (NULL==server_name || 0==strcmp("none", server_name)) {
6974
return NULL;
7075
}
@@ -88,20 +93,26 @@ void* embedded_server_load_functions(const char *server_name)
8893

8994
funcInit = dlsym(dll, "omc_embedded_server_init");
9095
if (!funcInit) {
91-
errorStreamPrint(LOG_DEBUG, 0, "Failed to load function opc_da_init: %s\n", dlerror());
96+
errorStreamPrint(LOG_DEBUG, 0, "Failed to load function omc_embedded_server_init: %s\n", dlerror());
97+
MMC_THROW();
98+
}
99+
funcWaitForStep = dlsym(dll, "omc_wait_for_step");
100+
if (!funcWaitForStep) {
101+
errorStreamPrint(LOG_DEBUG, 0, "Failed to load function omc_wait_for_step: %s\n", dlerror());
92102
MMC_THROW();
93103
}
94104
funcDeinit = dlsym(dll, "omc_embedded_server_deinit");
95105
if (!funcDeinit) {
96-
errorStreamPrint(LOG_DEBUG, 0, "Failed to load function opc_da_deinit: %s\n", dlerror());
106+
errorStreamPrint(LOG_DEBUG, 0, "Failed to load function omc_embedded_server_deinit: %s\n", dlerror());
97107
MMC_THROW();
98108
}
99109
funcUpdate = dlsym(dll, "omc_embedded_server_update");
100110
if (!funcUpdate) {
101-
errorStreamPrint(LOG_DEBUG, 0, "Failed to load function opc_da_new_iteration: %s\n", dlerror());
111+
errorStreamPrint(LOG_DEBUG, 0, "Failed to load function omc_embedded_server_update: %s\n", dlerror());
102112
MMC_THROW();
103113
}
104114
embedded_server_init = funcInit;
115+
wait_for_step = funcWaitForStep;
105116
embedded_server_deinit = funcDeinit;
106117
embedded_server_update = funcUpdate;
107118
infoStreamPrint(LOG_DEBUG, 0, "Loaded embedded server");

SimulationRuntime/c/simulation/solver/embedded_server.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ extern "C" {
3838
#endif
3939

4040
extern void* (*embedded_server_init)(DATA *data, double tout, double step, const char *argv_0, void (*omc_real_time_sync_update)(DATA *data, double scaling), int port);
41+
extern void (*wait_for_step)(void *handle);
4142
extern void (*embedded_server_deinit)(void *handle);
4243
/* Tells the embedded server that a simulation step has passed; the server
4344
* can read/write values from/to the simulator

SimulationRuntime/c/simulation/solver/solver_main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,8 @@ int solver_main(DATA* data, threadData_t *threadData, const char* init_initMetho
706706
}
707707
}
708708
data->embeddedServerState = embedded_server_init(data, data->localData[0]->timeValue, solverInfo.currentStepSize, argv_0, omc_real_time_sync_update, port);
709+
infoStreamPrint(LOG_STDOUT, 0, "The embedded server is initialized.");
710+
wait_for_step(data->embeddedServerState);
709711
#endif
710712
if(0 == retVal) {
711713
retVal = -1;

SimulationRuntime/opc/ua/omc_opc_ua.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ static void waitForStep(omc_opc_ua_state *state)
102102
}
103103
}
104104

105+
void omc_wait_for_step(void *state_vp)
106+
{
107+
waitForStep((omc_opc_ua_state*) state_vp);
108+
}
109+
105110
static UA_StatusCode
106111
readBoolean(void *handle, const UA_NodeId nodeid, UA_Boolean sourceTimeStamp, const UA_NumericRange *range, UA_DataValue *dataValue)
107112
{
@@ -585,11 +590,6 @@ void* omc_embedded_server_init(DATA *data, double t, double step, const char *ar
585590

586591
pthread_rwlock_unlock(&state->rwlock);
587592

588-
if (state) {
589-
fprintf(stderr, "omc_embedded_server_init done, state=%p, server=%p. Pause run=%d step=%d\n", state, state->server, state->run, state->step);
590-
waitForStep(state);
591-
}
592-
593593
return state;
594594
}
595595

SimulationRuntime/opc/ua/omc_opc_ua.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#endif
4949

5050
OPC_UA_EXPORT void* omc_embedded_server_init(DATA *data, double t, double step, const char *argv_0, void (*omc_real_time_sync_update)(DATA *data, double scaling), int port);
51+
OPC_UA_EXPORT void omc_wait_for_step(void*);
5152
OPC_UA_EXPORT void omc_embedded_server_deinit(void*);
5253
OPC_UA_EXPORT int omc_embedded_server_update(void*, double t);
5354

0 commit comments

Comments
 (0)