convertersystems / opc-ua-client

Visualize and control your enterprise using OPC Unified Architecture (OPC UA) and Visual Studio.
MIT License
405 stars 119 forks source link

How To Subscribe to Arrays #261

Closed kratostav closed 11 months ago

kratostav commented 1 year ago

Hi, first thank you for this great library. I only have one Problem subscribing to an array in MVVM fashion. How to I subscribe and how to I get the Values to change in both directions? Or do I have to flatten the arrays in multiple nodes?

awcullen commented 1 year ago

You can subscribe to whole arrays like below. To change value at the PLC, you will have to set the property (write the whole array). Changing a single element won't work :(



    /// <summary>
    /// Gets or sets the value of DemoStaticArraysUInt16.
    /// </summary>
    [MonitoredItem(nodeId: "ns=2;s=Demo.Static.Arrays.UInt16")]
    public UInt16[] DemoStaticArraysUInt16
    {
        get { return this._DemoStaticArraysVector; }
        set { this.SetProperty(ref this._DemoStaticArraysVector, value); }
    }

    private UInt16[] _DemoStaticArraysVector;