Login  •  Register


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, ...

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

Postby AnsMumtaz » 03 Dec 2019, 08:59

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);
        }
    }
AnsMumtaz
Jr. Member
Jr. Member
 
Posts: 1
Joined: 03 Dec 2019, 08:27

Return to Technical

Who is online

Users browsing this forum: No registered users and 0 guests