Comments (5)
Here a writing to a tag screenshot:
- prior to writing the Tag ALT_S33_GPCState has the value "5" as a Float ValueType() (is a scalar variable/no array)
- I want to write 7 to it
After submitting the value I see some items in the Info-Box where especially the value: Variant(Scalar<10>, value 7) (see screenshot) strikes me as <10> should refer to the ValueType().
The writing ends without an error but the monitored Tag reads Variant(Scalar<Null>, value: <null>)
opcua-commander and also other OPCUA Client cannot read this Tag correctly any more.
from opcua-commander.
Hi again in case if anybody interested I found a solution/fix that seems to work at least for me.
diff --git a/lib/model/model.ts b/lib/model/model.ts
index 4544277..c499789 100644
--- a/lib/model/model.ts
+++ b/lib/model/model.ts
@@ -301,10 +301,11 @@ export class Model extends EventEmitter {
const dataType = this.getAttributeValue(attributes, AttributeIds.DataType);
const arrayDimension = this.getAttributeValue(attributes, AttributeIds.ArrayDimensions);
if (dataType) {
- const value = new Variant();
- value.dataType = dataType.text.split(" ")[0];
- value.value = data;
- value.arrayType = arrayDimension.text > 0 ? VariantArrayType.Array : VariantArrayType.Scalar;
+ const value = new Variant({
+ dataType: dataType.text.split(" ")[0],
+ value: data,
+ arrayType: arrayDimension.text > 0 ? VariantArrayType.Array : VariantArrayType.Scalar,
+ });
const writeValue = new WriteValue({
nodeId: node.nodeId,
attributeId: AttributeIds.Value,
I cannot be sure about that fix in any situation but it does get me to use the tool for all the types I use in my work.
If someone more knowledgeable could validate this and may be correct the original code/repository this would be grate.
best
Georges
from opcua-commander.
Just an additional feedback, Float, Int and its variants like Int32,UInt32 do work fine with this modification.
But I have en error with Boolean Type variables. It seems that this type is not handled in the coerceVariantType() (variant.ts of node-opcua-variant module).
I tried it with writing true/false and 0/1 and non of this is working.
The data given to the constructor is a string "true"/"false" "1"/"0" is not converted to a type conform value.
Finally isValidVariant() reruns with an error.
Error: Invalid variant arrayType: Scalar dataType: Boolean value:1 (javascript type = string )
at constructHook (/opt/opcuacommander/node_modules/node-opcua-variant/source/variant.ts:472:19)
at new Variant (/opt/opcuacommander/node_modules/node-opcua-variant/source/variant.ts:112:26)
at Model.writeNode (/opt/opcuacommander/lib/model/model.ts:304:21)
at processTicksAndRejections (node:internal/process/task_queues:94:5)
at Form.<anonymous> (/opt/opcuacommander/lib/view/view.ts:249:33)
I can live with that by not using OPCUA Boolean types as long as I have the OPC-Server configuration in hand but it would be nice to have this issue also fixed.
from opcua-commander.
fix in version 0.18.0
from opcua-commander.
Hi all and thank you for the fix.
I have pulled the 0.18.0 code base and rebuild the docker container.
I have tested the same write action and this does produce the following exception
Error: dimension can only provided if variant is a matrix
at assert (/opt/opcuacommander/node_modules/node-opcua-assert/source/index.ts:12:21)
at constructHook (/opt/opcuacommander/node_modules/node-opcua-variant/source/variant.ts:486:15)
at new Variant (/opt/opcuacommander/node_modules/node-opcua-variant/source/variant.ts:112:26)
at Model.writeNode (/opt/opcuacommander/lib/model/model.ts:311:21)
at processTicksAndRejections (node:internal/process/task_queues:94:5)
at Form.<anonymous> (/opt/opcuacommander/lib/view/view.ts:238:23)
Base on that and my previous research, I have just removed the dimension property at Variant creation.
diff --git a/lib/model/model.ts b/lib/model/model.ts
@@ -311,7 +311,7 @@ export class Model extends EventEmitter {
const value = new Variant({
dataType,
arrayType: valueRank === -1 ? VariantArrayType.Scalar : valueRank === 1 ? VariantArrayType.Array : VariantArrayType.Matrix,
- dimensions: arrayDimension,
+// dimensions: arrayDimension,
value: data,
});
const writeValue = new WriteValue({
With that I am back to be able to just write scalar opc-variables.
The error in writing Boolean types is still present.
Error: Invalid variant arrayType: Scalar dataType: Boolean value:1 (javascript type = string )
at constructHook (/opt/opcuacommander/node_modules/node-opcua-variant/source/variant.ts:472:19)
at new Variant (/opt/opcuacommander/node_modules/node-opcua-variant/source/variant.ts:112:26)
at Model.writeNode (/opt/opcuacommander/lib/model/model.ts:311:21)
at processTicksAndRejections (node:internal/process/task_queues:94:5)
at Form.<anonymous> (/opt/opcuacommander/lib/view/view.ts:238:23)
from opcua-commander.
Related Issues (20)
- Add certs as parameters HOT 1
- Connection with SecurityPolicy != None
- opcua-commander closes immediately after connecting HOT 7
- Can not run on Ubuntu with Nodejs 6.14 HOT 1
- Seeing a Back off error HOT 2
- Monitoring not work HOT 1
- Running OPC-UA commander on RaspberryPi HOT 1
- Cannot read property 'join' of undefined HOT 3
- Exception when connecting to end-point HOT 1
- Error: Cannot find module 'xml-writer' HOT 3
- Docker image build seems broken
- Naming conflict with OpenShift CLI (oc) HOT 2
- Issue in writing a OPC-Tag/Variable - dimension can only provided if variant is a matrix HOT 3
- Issue in writing a OPC-Tag/Variable - Invalid variant Boolean value:1 HOT 4
- Doesn't Start HOT 3
- Cannot find ANONYMOUS user token policy in end point description HOT 3
- Wrong version displayed in 0.31.0 HOT 1
- Docker image is broken HOT 1
- Can not connect to opc ua plc using opcua-commander HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opcua-commander.