Open AnsMumtaz-IMS opened 4 years ago
private void opceditor_Click(object sender, RoutedEventArgs e) { string opcIds = ""; string opcHierarchy = "";
foreach (OpcItemHelper item in videoSettings.selectedDevice1.opcItemList)
{
Dispatcher.BeginInvoke((Action)delegate ()
{
// lbOpcTest.Content = "ItemId: " + value.Item.ItemId + " Value: " + value.Value + " Quality: " + value.Quality + " Timestamp: " + value.Timestamp;
try
{
if (item.itemId.ToString().Contains("MeterCount"))
{
opcIds = item.itemId; // + ",";
//MessageBox.Show(opcIds);
object[] opcvalues = { 0 };
OpcDaItem itemMeterCount = readGroup.Items.FirstOrDefault(i => i.ItemId == opcIds);
OpcDaItem[] itemsVal = { itemMeterCount };
HRESULT[] rs = readGroup.Write(itemsVal, opcvalues);
}
}
catch (Exception ex)
{
MessageBox.Show("Error(Reset): " + ex.Message);
}
});
}
readGroup.ValuesChanged += OnGroupValuesChanged;
readGroup.UpdateRate = TimeSpan.FromMilliseconds(100);
}
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... can anyone please help me with this. Reading the values is not problem its working perfectly but writing is not working.