Reset (Write) the value of OPC variable...

Unified Architecture topics related to OPC UA Specification, compliant behavior and any technical issues of OPC UA, like Security, Information Model, Companion Specs DI, PLCopen, ADI, ...

Moderator: Support Team

Post Reply
AnsMumtaz
Jr. Member
Jr. Member
Posts: 1
Joined: 03 Dec 2019, 08:27

Reset (Write) the value of OPC variable...

Post by AnsMumtaz »

This my function which i am using to write new values for OPC DA server variable. Actually, variable is MeterCount which shows the length in meters and i am making a button to reset its value(means 0). I want to write the new value from WPF application(VS 2015) but its not working (not showing any error or exception)... please help me with this. Reading the values is not the problem it's working perfectly but writing is not working, the variable data type is string with output (0.20 m)... and i want to reset the value (0.00 m) at any time when the reset button is pressed.
Note: You can ask me any question to understand the problem.

Code: Select all

using TitaniumAS.Opc.Client.Da;
using TitaniumAS.Opc.Client.Common;
using TitaniumAS.Opc.Client.Da.Browsing;

   private void MeterReset_Click(object sender, RoutedEventArgs e)
    {
        try
        {
           foreach (OpcItemHelper item in videoSettings.selectedDevice1.opcItemList)
                {
                    if(item.itemId.ToString().Contains("MeterCount"))
                    {
                        opcIds += item.itemId;                  // + ",";
                    }
                }

                object[] opcvalues = { "0.00 m" };
                OpcDaItem itemMeterCount = readGroup.Items.FirstOrDefault(i => i.ItemId == opcIds);
                OpcDaItem[] itemsVal = { itemMeterCount };
                HRESULT[] rs = readGroup.Write(itemsVal, opcvalues);

                readGroup.ValuesChanged += OnGroupValuesChanged;
                readGroup.UpdateRate = TimeSpan.FromMilliseconds(100);
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }

User avatar
Support Team
Hero Member
Hero Member
Posts: 3064
Joined: 18 Mar 2011, 15:09

Re: Reset (Write) the value of OPC variable...

Post by Support Team »

Hello,

the code you are showing has no relation no no of our Unified Automation products. This forum is to support Unified Automation libraries and tools.

Best approach to solve your issue is asking the supplier, which is not us.
Best regards
Unified Automation Support Team

Post Reply