Git Product home page Git Product logo

Comments (10)

ChristophRuckstetter avatar ChristophRuckstetter commented on June 9, 2024 1

I did an error on my side. With the UA_Server_addNode_begin() and UA_Server_addNode_finish() and the HasInterface reference it works just fine.

from sample-server.

ccvca avatar ccvca commented on June 9, 2024

At the moment, there are no specific attributes for interfaces, as in MachineTools, Interfaces are only used for TypeDefinitions, e.g. here, but it should work the same way.

struct MachineToolIdentification_t : public machinery::IMachineryItemVendorNameplateType_t, public machinery::IMachineTagNameplate_t {

As for all acessable OPC UA Variable a C++ variable must be available, the State must use another type than ns0::BaseObject_t (as this has no members).
E.g. (Unchecked, only as a demonstration)

struct IWWState_t {
  BinableMember<ns0::StateVariable_t> CurrentState;
}
REFL_TYPE(
  woodworking::IWWState_t ,
  UmatiServerLib::attribute::UaObjectType(UmatiServerLib::constexp::NodeId(constants::NsWoodworkingUri, UA_WOODWORKINGID_IWWSTATE)))
REFL_FIELD(CurrentState)

Then this IWWState_t should be fine for using in WwMachine_t for State, if State is a mandatory member.

For optional members which ony use Interfaces, this will not work as expected because the instanciation will use the methods from open62541 to instanciate an object, which will result in an Object of the inteface type (without HasInterface Reference). In this case additional implementations are required.

from sample-server.

ChristophRuckstetter avatar ChristophRuckstetter commented on June 9, 2024

In the Woodworking case the IWwStateType has two children of BaseObjectTypes, which a hasInterface Reference to another Type. And each of these BaseObjectTypes have again children of BaseObjectTypes with hasInterface references.

So I couldn't directly adapt your example.

I tried to implement the interface Types, and also dummy structs, that inherit from the interface types to use them. But i couldn't get it to work. Here is the complete code how i tried to implement the type definitions:
ChristophRuckstetter@b695d37

from sample-server.

ccvca avatar ccvca commented on June 9, 2024

After investigation, I detected two issues:

  1. Overview in IWwBaseState_t is an object, so it must be BindableMember instead of BindableMemberValue and some Fields are missing in the reflection (Fixed here: ChristophRuckstetter#1)
  2. UA_Server_addObjectNode from open62541 seems to ignore HasInterface references when creating the instance. (see also: open62541/open62541#4363 and open62541/open62541#3813) This must be fixed in open62541 for all mandatory childs, as the server expects that UA_Server_addObjectNode create a valid instance.

from sample-server.

GoetzGoerisch avatar GoetzGoerisch commented on June 9, 2024

open62541/open62541#4479

from sample-server.

ChristophRuckstetter avatar ChristophRuckstetter commented on June 9, 2024

I applied this patch (open62541/open62541#4479) to my open62541 build and tried to bring up the State/Machine/Flags Object by defining the Flags as optional in the TypeDefinitions and calling InstantiateOptional() on Instantiation (ChristophRuckstetter@ab81879) .

This compiles fine, but on runtime it throws the following exception: "terminate called after throwing an instance of 'std::runtime_error'
what(): Could not create optional node, Error: BadTypeDefinitionInvalid".

Is there something else that needs to be done to get the optional objects with hasinterface reference instantiated?

from sample-server.

GoetzGoerisch avatar GoetzGoerisch commented on June 9, 2024

With #330 also in develop

from sample-server.

ccvca avatar ccvca commented on June 9, 2024

On https://github.com/ccvca/Sample-Server/tree/ww_fix 9f9ac79 I fixed a bug, which causes the instanciation of abstract types. But I was not able to fully succeed in creating the optional Object, as I don't know a way to add the childs of that interface:
https://github.com/ccvca/Sample-Server/blob/9f9ac79f752b903421db5acc57a7fbfbc5a9be3a/UmatiServerLib/Instantiation.cpp#L158

open62541/open62541#4479 only supports HasInterfaces on TypeDefinition, but in this case an Object of type BaseObjectType in created and the interfaces are added afterwards.

from sample-server.

basyskom-jvoe avatar basyskom-jvoe commented on June 9, 2024

Optional children can also be added by implementing the optional child callback. Open62541 will then ask for every optional child if it should be added when an object is added to the server and adds it if the callback function returns true.

My pull request should also support HasInterface references on BaseObjectType objects, but in this case, the object creation must be done via the UA_Server_addNode_begin() and UA_Server_addNode_finish() functions.

from sample-server.

ChristophRuckstetter avatar ChristophRuckstetter commented on June 9, 2024

@basyskom-jvoe I tried to create the object with UA_Server_addNode_begin() and UA_Server_addNode_finish() and the object was created properly with the HasInterface reference, but the mandatory children as defined by the interface type weren't created.
I'm not sure if it should behave like that.

When I use UA_Server_addObjectNode (and the optional child callback returns true for the relevant object), the object is created properly with the HasInterface reference, and the mandatory children are also there.

from sample-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.