Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding more docstrings, high level interface improvements #18

Merged
merged 26 commits into from
May 24, 2024
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
085c599
docstrings for server.jl add node functions (higher level interface m…
thomvet Apr 24, 2024
79949a0
More server and client docstrings + docs
thomvet Apr 24, 2024
5316618
distribute docstrings onto different api pages
thomvet Apr 24, 2024
f13fcf9
adjust purpose text in server_read.jl
thomvet Apr 25, 2024
055dd51
add readme and further docs
thomvet May 3, 2024
8490407
more docs; more tests; worked on high level interface.
thomvet May 9, 2024
ff4ae37
test more types in variable nodes (incl. string).
thomvet May 12, 2024
07d8ddf
fix array tests for complex numbers and strings
thomvet May 13, 2024
5a7c578
more high level interface
thomvet May 13, 2024
f5fc1b1
format
thomvet May 13, 2024
58b3bb7
remove callback tests for mac os x (LLVM limitation)
thomvet May 13, 2024
28f8647
remove method node test on mac os x
thomvet May 13, 2024
c9d9db6
mac os again
thomvet May 13, 2024
2caf7fd
shorter test strings
thomvet May 13, 2024
9f235c1
wait longer
thomvet May 13, 2024
f167c82
restructure files; interface improvements
thomvet May 14, 2024
01811f6
Move UA_Variant_new methods into JUA_Variant and adapt tests.
thomvet May 16, 2024
5e70700
started high level add node tests.
thomvet May 16, 2024
a0aa7bb
docstring; interface improvements
thomvet May 21, 2024
8f3ba6d
fix typo; add methodattributes to high level
thomvet May 21, 2024
2f06e35
complete high level types for now; need some more tests
thomvet May 21, 2024
d1fa9ce
test fallback methods
thomvet May 22, 2024
5b20e47
align client/server writevalue functions incl. jua_variant case
thomvet May 22, 2024
f9c6300
remove UA_Client_addMethodNode (unuseable also in open62541)
thomvet May 22, 2024
3bc82ae
clean up
thomvet May 22, 2024
a9b34b2
bugfix JUA_Server_writeValue
thomvet May 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove method node test on mac os x
thomvet committed May 13, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 28f8647ebdfb03aa13c77d94c40a307b2a543b8d
88 changes: 44 additions & 44 deletions test/server_add_nodes.jl
Original file line number Diff line number Diff line change
@@ -294,50 +294,50 @@ function helloWorldMethodCallback(server, sessionId, sessionHandle, methodId,
return UA_STATUSCODE_GOOD
end

inputArgument = UA_Argument_new()
inputArgument.description = UA_LOCALIZEDTEXT("en-US", "A String")
inputArgument.name = UA_STRING("MyInput");
inputArgument.dataType = UA_TYPES_PTRS[UA_TYPES_STRING].typeId;
inputArgument.valueRank = UA_VALUERANK_SCALAR
outputArgument = UA_Argument_new()
outputArgument.description = UA_LOCALIZEDTEXT("en-US", "A String");
outputArgument.name = UA_STRING("MyOutput");
outputArgument.dataType = UA_TYPES_PTRS[UA_TYPES_STRING].typeId
outputArgument.valueRank = UA_VALUERANK_SCALAR
helloAttr = UA_MethodAttributes_generate(description = "Say Hello World",
displayname = "Hello World",
executable = true,
userexecutable = true)

methodid = UA_NODEID_NUMERIC(1, 62541)
obj = UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER)
retval = UA_Server_addMethodNode(server, methodid,
obj,
UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT),
UA_QUALIFIEDNAME(1, "hello world"),
helloAttr, helloWorldMethodCallback,
1, inputArgument, 1, outputArgument, C_NULL, C_NULL)

@test retval == UA_STATUSCODE_GOOD

#UA_Server_run(server, Ref(true)) - checking server in uaexpert shows that the
#hello world method is there and that it produces the correct results when called
inputArguments = UA_Variant_new()
ua_s = UA_STRING("Peter")
UA_Variant_setScalar(inputArguments, ua_s, UA_TYPES_PTRS[UA_TYPES_STRING])
req = UA_CallMethodRequest_new()
req.objectId = obj
req.methodId = methodid
req.inputArgumentsSize = 1
req.inputArguments = inputArguments

answer = UA_CallMethodResult_new()
UA_Server_call(server, req, answer)
@test unsafe_load(answer.statusCode) == UA_STATUSCODE_GOOD
@test unsafe_string(unsafe_wrap(unsafe_load(answer.outputArguments))) == "Hello Peter"

UA_CallMethodRequest_delete(req)
UA_CallMethodResult_delete(answer)
if !Sys.isapple()
inputArgument = UA_Argument_new()
inputArgument.description = UA_LOCALIZEDTEXT("en-US", "A String")
inputArgument.name = UA_STRING("MyInput");
inputArgument.dataType = UA_TYPES_PTRS[UA_TYPES_STRING].typeId;
inputArgument.valueRank = UA_VALUERANK_SCALAR
outputArgument = UA_Argument_new()
outputArgument.description = UA_LOCALIZEDTEXT("en-US", "A String");
outputArgument.name = UA_STRING("MyOutput");
outputArgument.dataType = UA_TYPES_PTRS[UA_TYPES_STRING].typeId
outputArgument.valueRank = UA_VALUERANK_SCALAR
helloAttr = UA_MethodAttributes_generate(description = "Say Hello World",
displayname = "Hello World",
executable = true,
userexecutable = true)

methodid = UA_NODEID_NUMERIC(1, 62541)
obj = UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER)
retval = UA_Server_addMethodNode(server, methodid,
obj,
UA_NODEID_NUMERIC(0, UA_NS0ID_HASCOMPONENT),
UA_QUALIFIEDNAME(1, "hello world"),
helloAttr, helloWorldMethodCallback,
1, inputArgument, 1, outputArgument, C_NULL, C_NULL)

@test retval == UA_STATUSCODE_GOOD

inputArguments = UA_Variant_new()
ua_s = UA_STRING("Peter")
UA_Variant_setScalar(inputArguments, ua_s, UA_TYPES_PTRS[UA_TYPES_STRING])
req = UA_CallMethodRequest_new()
req.objectId = obj
req.methodId = methodid
req.inputArgumentsSize = 1
req.inputArguments = inputArguments

answer = UA_CallMethodResult_new()
UA_Server_call(server, req, answer)
@test unsafe_load(answer.statusCode) == UA_STATUSCODE_GOOD
@test unsafe_string(unsafe_wrap(unsafe_load(answer.outputArguments))) == "Hello Peter"

UA_CallMethodRequest_delete(req)
UA_CallMethodResult_delete(answer)
end

#TODO: this will need a test to see whether any memory is leaking.


Unchanged files with check annotations Beta

Base.unsafe_wrap(p::Ptr{UA_Variant}) = unsafe_wrap(unsafe_load(p))
UA_Variant_isEmpty(v::UA_Variant) = v.type == C_NULL
UA_Variant_isEmpty(p::Ptr{UA_Variant}) = UA_Variant_isEmpty(unsafe_load(p))

Check warning on line 866 in src/types.jl

Codecov / codecov/patch

src/types.jl#L866

Added line #L866 was not covered by tests
UA_Variant_isScalar(v::UA_Variant) = v.arrayLength == 0 #TODO: this fails when strings are present in the variant, why? && v.data > UA_EMPTY_ARRAY_SENTINEL
UA_Variant_isScalar(p::Ptr{UA_Variant}) = UA_Variant_isScalar(unsafe_load(p))

Check warning on line 868 in src/types.jl

Codecov / codecov/patch

src/types.jl#L868

Added line #L868 was not covered by tests
function UA_Variant_hasScalarType(v::UA_Variant, type::Ref{UA_DataType})
return UA_Variant_isScalar(v) && type == v.type
const JUA_AccessControl_default = UA_AccessControl_default
const JUA_AccessControl_defaultWithLoginCallback = UA_AccessControl_defaultWithLoginCallback
function JUA_Server_runUntilInterrupt(server::JUA_Server)
running = Ref(true)
try
Base.exit_on_sigint(false)
UA_Server_run(server, running)

Check warning on line 89 in src/wrappers.jl

Codecov / codecov/patch

src/wrappers.jl#L85-L89

Added lines #L85 - L89 were not covered by tests
catch err
UA_Server_run_shutdown(server)
println("Shutting down server.")
Base.exit_on_sigint(true)

Check warning on line 93 in src/wrappers.jl

Codecov / codecov/patch

src/wrappers.jl#L91-L93

Added lines #L91 - L93 were not covered by tests
end
return nothing

Check warning on line 95 in src/wrappers.jl

Codecov / codecov/patch

src/wrappers.jl#L95

Added line #L95 was not covered by tests
end
## Client and client config
mutable struct JUA_Variant <: AbstractOpen62541Wrapper
ptr::Ptr{UA_Variant}
function JUA_Variant()
obj = new(UA_Variant_new())
finalizer(release_handle, obj)
return obj

Check warning on line 274 in src/wrappers.jl

Codecov / codecov/patch

src/wrappers.jl#L271-L274

Added lines #L271 - L274 were not covered by tests
end
end
function release_handle(obj::JUA_Variant)
UA_Variant_delete(Jpointer(obj))

Check warning on line 279 in src/wrappers.jl

Codecov / codecov/patch

src/wrappers.jl#L278-L279

Added lines #L278 - L279 were not covered by tests
end
function JUA_Client_readValueAttribute(client, nodeId)
return statuscode
end
function JUA_Server_readValue(client, nodeId)

Check warning on line 300 in src/wrappers.jl

Codecov / codecov/patch

src/wrappers.jl#L300

Added line #L300 was not covered by tests
#TODO: Is there a way of making this typestable?
#(it's not really known what kind of data is stored inside a nodeid unless
#one checks the datatype beforehand)
v = UA_Variant_new()
UA_Server_readValue(client, nodeId, v)
r = __get_juliavalues_from_variant(v)
UA_Variant_delete(v)
return r

Check warning on line 308 in src/wrappers.jl

Codecov / codecov/patch

src/wrappers.jl#L304-L308

Added lines #L304 - L308 were not covered by tests
end
function __extract_ExtensionObject(eo::UA_ExtensionObject)
if eo.encoding != UA_EXTENSIONOBJECT_DECODED
error("can't make sense of this extension object yet.")

Check warning on line 313 in src/wrappers.jl

Codecov / codecov/patch

src/wrappers.jl#L313

Added line #L313 was not covered by tests
else
v = eo.content.decoded
type = juliadatatype(v.type)
function __get_juliavalues_from_variant(v)
wrapped = unsafe_wrap(v)
if typeof(wrapped) == UA_ExtensionObject
wrapped = __extract_ExtensionObject.(wrapped)

Check warning on line 325 in src/wrappers.jl

Codecov / codecov/patch

src/wrappers.jl#L325

Added line #L325 was not covered by tests
elseif typeof(wrapped) <: Array && eltype(wrapped) == UA_ExtensionObject
wrapped = __extract_ExtensionObject.(wrapped)
end