09/08/2020
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);
}
————————————————————————————————————————–
1 Guest(s)