Page 1 of 1

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

Posted: 03 Dec 2019, 08:59
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);
        }
    }

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

Posted: 19 May 2020, 22:13
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.