Skip to content

Commit 36c233f

Browse files
authored
set valueRank = -1 in OPC UA to avoid the default -2 (#11313)
1 parent 5d55005 commit 36c233f

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

OMCompiler/SimulationRuntime/opc/ua/omc_opc_ua.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,8 @@ static inline omc_opc_ua_state* addVars(omc_opc_ua_state *state, var_kind_t varK
324324
UA_DataSource dataSource = {0};
325325
UA_VariableAttributes attr;
326326
UA_VariableAttributes_init(&attr);
327+
/* set it to scalar as some clients do not like -2 variant */
328+
attr.valueRank = -1; /* scalar */
327329
int inputIndex;
328330
int isState=0;
329331

@@ -420,6 +422,8 @@ static inline omc_opc_ua_state* addAliasVars(omc_opc_ua_state *state, var_kind_t
420422
UA_DataSource dataSource = {0};
421423
UA_VariableAttributes attr;
422424
UA_VariableAttributes_init(&attr);
425+
/* set it to scalar as some clients do not like -2 variant */
426+
attr.valueRank = -1; /* scalar */
423427
int inputIndex;
424428
int isState = 0;
425429

@@ -537,6 +541,8 @@ void* omc_embedded_server_init(DATA *data, double t, double step, const char *ar
537541
.handle = state, .read = readBoolean, .write = writeBoolean};
538542
UA_VariableAttributes attr;
539543
UA_VariableAttributes_init(&attr);
544+
/* set it to scalar as some clients do not like -2 variant */
545+
attr.valueRank = -1; /* scalar */
540546
attr.description = UA_LOCALIZEDTEXT("en_US","When set to true, the simulator takes a single step");
541547
attr.displayName = UA_LOCALIZEDTEXT("en_US","step");
542548
attr.writeMask = 1;
@@ -549,8 +555,8 @@ void* omc_embedded_server_init(DATA *data, double t, double step, const char *ar
549555
/* add variable for simulation run */
550556
UA_NodeId runNodeId = UA_NODEID_NUMERIC(0, OMC_OPC_NODEID_RUN);
551557
UA_QualifiedName runName = UA_QUALIFIEDNAME(1, "OpenModelica.run");
552-
UA_VariableAttributes runAttr;
553-
UA_VariableAttributes_init(&runAttr);
558+
/* set it to scalar as some clients do not like -2 variant */
559+
attr.valueRank = -1; /* scalar */
554560
attr.description = UA_LOCALIZEDTEXT("en_US","When set to true, the simulator keeps running until run is set to false");
555561
attr.displayName = UA_LOCALIZEDTEXT("en_US","run");
556562
attr.writeMask = 1;
@@ -567,6 +573,8 @@ void* omc_embedded_server_init(DATA *data, double t, double step, const char *ar
567573
.handle = state, .read = readReal, .write = writeReal};
568574
UA_VariableAttributes attr;
569575
UA_VariableAttributes_init(&attr);
576+
/* set it to scalar as some clients do not like -2 variant */
577+
attr.valueRank = -1; /* scalar */
570578
attr.description = UA_LOCALIZEDTEXT("en_US","Real-time scaling factor. 1.0=real-time, 0.0=disabled");
571579
attr.displayName = UA_LOCALIZEDTEXT("en_US","realTimeScalingFactor");
572580
attr.writeMask = 1;
@@ -584,6 +592,8 @@ void* omc_embedded_server_init(DATA *data, double t, double step, const char *ar
584592
.handle = state, .read = readBoolean, .write = writeBoolean};
585593
UA_VariableAttributes attr;
586594
UA_VariableAttributes_init(&attr);
595+
/* set it to scalar as some clients do not like -2 variant */
596+
attr.valueRank = -1; /* scalar */
587597
attr.description = UA_LOCALIZEDTEXT("en_US","Enabled when using the stopTime to stop the simulation");
588598
attr.displayName = UA_LOCALIZEDTEXT("en_US","enableStopTime");
589599
attr.writeMask = 1;
@@ -601,6 +611,8 @@ void* omc_embedded_server_init(DATA *data, double t, double step, const char *ar
601611
.handle = state, .read = readReal, .write = NULL};
602612
UA_VariableAttributes timeAttr;
603613
UA_VariableAttributes_init(&timeAttr);
614+
/* set it to scalar as some clients do not like -2 variant */
615+
timeAttr.valueRank = -1; /* scalar */
604616
timeAttr.description = UA_LOCALIZEDTEXT("en_US","current simulation time");
605617
timeAttr.displayName = UA_LOCALIZEDTEXT("en_US","time");
606618
UA_Server_addDataSourceVariableNode(state->server, timeNodeId,
@@ -616,6 +628,8 @@ void* omc_embedded_server_init(DATA *data, double t, double step, const char *ar
616628
.handle = state, .read = readBoolean, .write = writeBoolean};
617629
UA_VariableAttributes attr;
618630
UA_VariableAttributes_init(&attr);
631+
/* set it to scalar as some clients do not like -2 variant */
632+
attr.valueRank = -1; /* scalar */
619633
attr.description = UA_LOCALIZEDTEXT("en_US", "When set to true, the simulation is terminated gracefully");
620634
attr.displayName = UA_LOCALIZEDTEXT("en_US", "terminate");
621635
attr.writeMask = 1;

0 commit comments

Comments
 (0)