Reset (Write) the value of OPC variable...
Posted: 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.
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);
}
}