Adding Custom Structure Using UaModeler
Moderator: uasdkhpc
-
- Hero Member
- Posts: 22
- Joined: 15 May 2023, 09:50
Adding Custom Structure Using UaModeler
Hi,
I am trying to add a custom structure known at compile time using the UaModeler. So far, I can add a variable and objects to the information model, and am able to view it using UaExpert. To add the custom structure, I followed the documentation and added a new structured data type, and also enabled the AddVariableType option. Then I gave some value to my variables in variable types and added an instance of the structure in the Objects folder, but when I try and view the structure the datatype is displayed as null and I cannot view the structure. However it still contains the variables and I can view them just fine.
https://ibb.co/zR93SPs
One possible problem I can think of is that in Additional Attributes, the value for my variable type is automatically set to Null, which I think is causing the error.
https://ibb.co/NW9Vzpw
Any insight will be greatly appreciated.
I am trying to add a custom structure known at compile time using the UaModeler. So far, I can add a variable and objects to the information model, and am able to view it using UaExpert. To add the custom structure, I followed the documentation and added a new structured data type, and also enabled the AddVariableType option. Then I gave some value to my variables in variable types and added an instance of the structure in the Objects folder, but when I try and view the structure the datatype is displayed as null and I cannot view the structure. However it still contains the variables and I can view them just fine.
https://ibb.co/zR93SPs
One possible problem I can think of is that in Additional Attributes, the value for my variable type is automatically set to Null, which I think is causing the error.
https://ibb.co/NW9Vzpw
Any insight will be greatly appreciated.
- Support Team
- Hero Member
- Posts: 3078
- Joined: 18 Mar 2011, 15:09
Re: Adding Custom Structure Using UaModeler
Hello,
the HP SDK does not support values for custom structures in XML (which is used as an intermediate format when the UaModeler generates code for the HP SDK), so these values must be set in code after generating.
the HP SDK does not support values for custom structures in XML (which is used as an intermediate format when the UaModeler generates code for the HP SDK), so these values must be set in code after generating.
Best regards
Unified Automation Support Team
Unified Automation Support Team
-
- Hero Member
- Posts: 22
- Joined: 15 May 2023, 09:50
Re: Adding Custom Structure Using UaModeler
Hi,
Thanks for the reply. I tried following thishttps://documentation.unified-automation.com/uasdkhp/1.7.1/html/usingextensionobjects.html , but was unable to implement the required structure. Could you link some examples, where a custom structure is implemented?
Thanks for the reply. I tried following thishttps://documentation.unified-automation.com/uasdkhp/1.7.1/html/usingextensionobjects.html , but was unable to implement the required structure. Could you link some examples, where a custom structure is implemented?
- Support Team
- Hero Member
- Posts: 3078
- Joined: 18 Mar 2011, 15:09
Re: Adding Custom Structure Using UaModeler
Hi,
the create_eurange() function from the link also works for other structures, instead of the struct ua_range, the struct of the custom datatype must be used, which is created by the UaModeler and instead of UA_ID_RANGE, the identifier (and namespace index) of the custom datatype must be used, which is also generated by the UaModeler.
the create_eurange() function from the link also works for other structures, instead of the struct ua_range, the struct of the custom datatype must be used, which is created by the UaModeler and instead of UA_ID_RANGE, the identifier (and namespace index) of the custom datatype must be used, which is also generated by the UaModeler.
Best regards
Unified Automation Support Team
Unified Automation Support Team
-
- Hero Member
- Posts: 22
- Joined: 15 May 2023, 09:50
Re: Adding Custom Structure Using UaModeler
Hi,
So, I defined the function is server_utilities.c and I am calling it in the same file, specifically inside the server_init_main function. I have added a print message in my functions, which is printed at the output. However, there is no change at the output of UaExpert. I have tried all the possible values for the identifier. Am I calling the function at the wrong place? I have managed to implement my structure using the CPP SDK, but HP SDK has me totally stumped.
So, I defined the function is server_utilities.c and I am calling it in the same file, specifically inside the server_init_main function. I have added a print message in my functions, which is printed at the output. However, there is no change at the output of UaExpert. I have tried all the possible values for the identifier. Am I calling the function at the wrong place? I have managed to implement my structure using the CPP SDK, but HP SDK has me totally stumped.
- Support Team
- Hero Member
- Posts: 3078
- Joined: 18 Mar 2011, 15:09
Re: Adding Custom Structure Using UaModeler
Hi,
the server_utilities.c is not intended to be modified, this code should be added to your provider which is generated as provider_*_impl.c, the concept of providers is explained here: https://documentation.unified-automation.com/uasdkhp/1.7.1/html/provider.html
The custom value will also need a value store which is also explained in the linked document and further demonstrated in Lesson 2, linked at the end of that document.
the server_utilities.c is not intended to be modified, this code should be added to your provider which is generated as provider_*_impl.c, the concept of providers is explained here: https://documentation.unified-automation.com/uasdkhp/1.7.1/html/provider.html
The custom value will also need a value store which is also explained in the linked document and further demonstrated in Lesson 2, linked at the end of that document.
Best regards
Unified Automation Support Team
Unified Automation Support Team
-
- Full Member
- Posts: 6
- Joined: 15 Aug 2023, 06:39
Re: Adding Custom Structure Using UaModeler
It seems UA ns0 structure type also cannot be identified by uaExpert. created 'tmpOutput3' variable whose type is ns0 'CurrencyUnitType' and assign the initial value to each field.
https://ibb.co/Chqkr8H
After uaModeler compile and execute 'build.sh', run the application program, 'tmpOutput3' value is 'NULL'. Although its Datatype is 'CurrencyUnitType' from 'Attributes' window, cannot view its Datatype or edit its value from 'Data Access View' window.
https://ibb.co/grWm038
For variable of UA namespace 0 structure type, also need to create the same datatype into provider which is generated as provider_*_impl.c ?
SDK version: v1.7.1
uaModeler version: 1.6.9 517
uaExpert version: 1.6.3
https://ibb.co/Chqkr8H
After uaModeler compile and execute 'build.sh', run the application program, 'tmpOutput3' value is 'NULL'. Although its Datatype is 'CurrencyUnitType' from 'Attributes' window, cannot view its Datatype or edit its value from 'Data Access View' window.
https://ibb.co/grWm038
For variable of UA namespace 0 structure type, also need to create the same datatype into provider which is generated as provider_*_impl.c ?
SDK version: v1.7.1
uaModeler version: 1.6.9 517
uaExpert version: 1.6.3
- Support Team
- Hero Member
- Posts: 3078
- Joined: 18 Mar 2011, 15:09
Re: Adding Custom Structure Using UaModeler
Hi,
the xml2c/xml2bin tools support the UA builtin datatypes as well as the following UA structures: Argument, EnumValueType, EUInformation and Range. Values of these datatypes can be loaded from xml files, other values need to be set in code which is explained following the link from my previous post:
https://documentation.unified-automation.com/uasdkhp/1.7.1/html/provider.html
Further information can be found in Lesson 2, linked at the end of that document.
the xml2c/xml2bin tools support the UA builtin datatypes as well as the following UA structures: Argument, EnumValueType, EUInformation and Range. Values of these datatypes can be loaded from xml files, other values need to be set in code which is explained following the link from my previous post:
https://documentation.unified-automation.com/uasdkhp/1.7.1/html/provider.html
Further information can be found in Lesson 2, linked at the end of that document.
Best regards
Unified Automation Support Team
Unified Automation Support Team
-
- Full Member
- Posts: 6
- Joined: 15 Aug 2023, 06:39
Re: Adding Custom Structure Using UaModeler
It looks a little bit strange. Since xml2c/xml2bin have already supported above four UA structures, why not support all UA structures since the encode/decode method should be applicable for all UA structures, do you have any plan to support all UA structures by xml2c/xml2bin?
It means customer need add the initial values in code for variables of custom type or even UA structure type, the values set in uaModeler is useless. Also need create separate valuestore and read/write functions in code to support read/write the values of these variables. It may add a big burden for the application.
It means customer need add the initial values in code for variables of custom type or even UA structure type, the values set in uaModeler is useless. Also need create separate valuestore and read/write functions in code to support read/write the values of these variables. It may add a big burden for the application.
-
- Full Member
- Posts: 6
- Joined: 15 Aug 2023, 06:39
Re: Adding Custom Structure Using UaModeler
About the variable of BuiltInType datatype, it can read the value set in xml value, but seems cannot change the value.
Below ‘tmpOutput2’ set initial value ‘234’ in xml file and compiled by uaModeler and build with ‘build.sh’, uaExpert can view its value of ‘234’, but change its value will get the fault ‘BadNotWriteable’ fault. And all fields of ‘tmpOutput3’ whose type is ‘CurrencyUnitType’ is either 0 or blank.
https://ibb.co/VVRw2HF
After added the valuestore and read/write function to ‘tmpOutput2’, ‘tmpOutput3’, the values of these two variables can be updated
https://ibb.co/fQfTS81
It means that if we want to change the values of the variable no matter it’s structure type or builtInType, we need add valuestore and read/write functions on it. It could be a big burden for application!
BTW, I need set ‘ENABLE_STRUCTURE_INTERNAL_CURRENCYUNITTYPE’ to ‘ON’ in ‘uatype_config.cmake’, otherwise ‘CurrencyUnitType’ cannot be found.
Please correct me if my above understanding is wrong, could you please provide your thoughts about it? thanks in advance.
Below ‘tmpOutput2’ set initial value ‘234’ in xml file and compiled by uaModeler and build with ‘build.sh’, uaExpert can view its value of ‘234’, but change its value will get the fault ‘BadNotWriteable’ fault. And all fields of ‘tmpOutput3’ whose type is ‘CurrencyUnitType’ is either 0 or blank.
https://ibb.co/VVRw2HF
After added the valuestore and read/write function to ‘tmpOutput2’, ‘tmpOutput3’, the values of these two variables can be updated
https://ibb.co/fQfTS81
It means that if we want to change the values of the variable no matter it’s structure type or builtInType, we need add valuestore and read/write functions on it. It could be a big burden for application!
BTW, I need set ‘ENABLE_STRUCTURE_INTERNAL_CURRENCYUNITTYPE’ to ‘ON’ in ‘uatype_config.cmake’, otherwise ‘CurrencyUnitType’ cannot be found.
Please correct me if my above understanding is wrong, could you please provide your thoughts about it? thanks in advance.
-
- Hero Member
- Posts: 22
- Joined: 15 May 2023, 09:50
Re: Adding Custom Structure Using UaModeler
Hi ReidLi,
I was wondering if you could share your code, or include some more detail on how you added the valuestore and read/write function to your structures. I just came back from vacation, and completely forgot all the leads I had about this. I would really appreciate it.
I was wondering if you could share your code, or include some more detail on how you added the valuestore and read/write function to your structures. I just came back from vacation, and completely forgot all the leads I had about this. I would really appreciate it.
-
- Full Member
- Posts: 6
- Joined: 15 Aug 2023, 06:39
Re: Adding Custom Structure Using UaModeler
Hi, Utkrist,
you may look at https://documentation.unified-automation.com/uasdkhp/1.7.1/html/server_gettingstarted2.html and related files are located in the folder \examples\server_gettingstarted\lesson02, I also use them for reference.
you may look at https://documentation.unified-automation.com/uasdkhp/1.7.1/html/server_gettingstarted2.html and related files are located in the folder \examples\server_gettingstarted\lesson02, I also use them for reference.