Method with three inputs but one output|OPC UA Implementation: Stacks, Tools, and Samples|Forum|OPC Foundation

Avatar
Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
Lost password?
sp_Feed sp_PrintTopic sp_TopicIcon
Method with three inputs but one output
Avatar
samet Yilmaz
New Member
Members
Forum Posts: 1
Member Since:
09/08/2020
sp_UserOfflineSmall Offline
1
10/12/2020 - 23:37
sp_Permalink sp_Print

Hey folks, 

i just want a method in which i can give 3 input values and which gives me back the 3 values.

 

————————————————————————————————————————————

static UA_StatusCode SetTimeMethodCallback1(UA_Server *server,
const UA_NodeId *sessionId, void *sessionHandle,
const UA_NodeId *methodId, void *methodContext,
const UA_NodeId *objectId, void *objectContext,
size_t inputSize, const UA_Variant *input,
size_t outputSize, UA_Variant *output)
{
UA_String *inputStr = (UA_String*)input->data;

charn str[64];

UA_Int32 year = (UA_Int32*)input[0].data;
UA_Int32 month = (UA_Int32*)input[1].data;
UA_Int32 day = (UA_Int32*)input[2].data;
sprintf(str, “%d”, year);
printf(“input of year %s”, str);

UA_Variant_setScalarCopy(output, &str, &UA_TYPES[UA_TYPES_STRING]);

UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_SERVER, “SetTime was called”);
return UA_STATUSCODE_GOOD;
}
static void SetTimeMethod(UA_Server *server)
{
//3 input arguments
UA_Argument inputArguments[3];
UA_Argument_init(&inputArguments[0]);
inputArguments[0].description = UA_LOCALIZEDTEXT(“en-US”, “set year”);
inputArguments[0].name = UA_STRING(“year”);
inputArguments[0].dataType = UA_TYPES[UA_TYPES_INT32].typeId;
inputArguments[0].valueRank = UA_VALUERANK_SCALAR;

UA_Argument_init(&inputArguments[1]);
inputArguments[1].description = UA_LOCALIZEDTEXT(“en-US”, “set month”);
inputArguments[1].name = UA_STRING(“month”);
inputArguments[1].dataType = UA_TYPES[UA_TYPES_INT32].typeId;
inputArguments[1].valueRank = UA_VALUERANK_SCALAR;

UA_Argument_init(&inputArguments[2]);
inputArguments[2].description = UA_LOCALIZEDTEXT(“en-US”, “set day”);
inputArguments[2].name = UA_STRING(“day”);
inputArguments[2].dataType = UA_TYPES[UA_TYPES_INT32].typeId;
inputArguments[2].valueRank = UA_VALUERANK_SCALAR;

// One output argument
UA_Argument outputArgument;
UA_Argument_init(&outputArgument);
outputArgument.description = UA_LOCALIZEDTEXT(“en-US”, “Date/Time was set”);
outputArgument.name = UA_STRING(“Date/Time”);
outputArgument.dataType = UA_TYPES[UA_TYPES_STRING].typeId;
outputArgument.valueRank = UA_VALUERANK_SCALAR;

UA_MethodAttributes DateAttr = UA_MethodAttributes_default;
DateAttr.description = UA_LOCALIZEDTEXT(“en-US”,”Set Time`”);
DateAttr.displayName = UA_LOCALIZEDTEXT(“en-US”,”Set Time”);
DateAttr.executable = true;
DateAttr.userExecutable = true;
UA_Server_addMethodNode(server, UA_NODEID_STRING(1,”SET Time”),
UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT),
UA_QUALIFIEDNAME(1, “SET TIME”),
DateAttr, &SetTimeMethodCallback1,
3, &inputArguments, 1, &outputArgument, NULL, NULL);
}

————————————————————————————————————————–

Avatar
Randy Armstrong
Admin
Forum Posts: 1580
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
2
10/13/2020 - 19:22
sp_Permalink sp_Print

Is this server code or client code?

What SDK are you using?

If Client code you do not set the output arguments.

They are returned.

Forum Timezone: America/Phoenix
Most Users Ever Online: 510
Currently Online:
Guest(s) 21
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Forum Stats:
Groups: 2
Forums: 10
Topics: 1446
Posts: 4891