예제 #1
1
int main(int argc, char **argv)
{
    signal(SIGINT, stopHandler);
    signal(SIGTERM, stopHandler);

    UA_Server *server = UA_Server_new();
    UA_ServerConfig *config = UA_Server_getConfig(server);
    UA_ServerConfig_setDefault(config);

    config->customDataTypes = &customTypesArray;

    UA_StatusCode retval;
    /* create nodes from nodeset */
    if(namespace_testnodeset_generated(server) != UA_STATUSCODE_GOOD) {
        UA_LOG_ERROR(UA_Log_Stdout, UA_LOGCATEGORY_SERVER,
                     "Could not add the example nodeset. "
                     "Check previous output for any error.");
        retval = UA_STATUSCODE_BADUNEXPECTEDERROR;
    } else {
        UA_Variant out;
        UA_Variant_init(&out);
        UA_Server_readValue(server, UA_NODEID_NUMERIC(2, 10002), &out);
        UA_Point *p = (UA_Point *)out.data;
        printf("point 2d x: %f y: %f \n", p->x, p->y);
        retval = UA_Server_run(server, &running);
    }

    UA_Server_delete(server);
    return retval == UA_STATUSCODE_GOOD ? EXIT_SUCCESS : EXIT_FAILURE;
}
예제 #2
0
END_TEST

START_TEST(Nodes_checkInheritedValue)
    {
        UA_NodeId childState;
        findChildId(UA_NODEID_NUMERIC(1, 6020), UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT),
                    UA_QUALIFIEDNAME(1, "State"), &childState);
        ck_assert(!UA_NodeId_isNull(&childState));
        UA_NodeId childNumber;
        findChildId(childState, UA_NODEID_NUMERIC(0, UA_NS0ID_HASPROPERTY),
                    UA_QUALIFIEDNAME(1, "CustomStateNumber"), &childNumber);
        ck_assert(!UA_NodeId_isNull(&childNumber));

        UA_Variant inheritedValue;
        UA_Variant_init(&inheritedValue);
        UA_Server_readValue(server, childNumber, &inheritedValue);
        ck_assert(inheritedValue.type == &UA_TYPES[UA_TYPES_UINT32]);

        UA_UInt32 *value = (UA_UInt32 *) inheritedValue.data;

        ck_assert_int_eq(*value, valueToBeInherited);
        UA_Variant_deleteMembers(&inheritedValue);
    }