/// <summary> /// Executes a read request for the current set if items. /// </summary> public void DoRead() { try { // read from server. TsCDaItem[] items = ItemsCTRL.GetItems(); TsCDaItemValueResult[] results = null; if (m_subscription != null) { if (m_synchronous) { results = m_subscription.Read(items); } else { results = new AsyncRequestDlg().ShowDialog(m_subscription, items); if (results == null) { return; } } } else { // add dummy client handles to test that they get returned properly. foreach (TsCDaItem item in items) { item.ClientHandle = item.ItemName; } results = m_server.Read(items); } // save results. m_values = results; BackBTN.Enabled = true; NextBTN.Enabled = false; CancelBTN.Visible = false; DoneBTN.Visible = true; OptionsBTN.Visible = false; ItemsCTRL.Visible = false; ResultsCTRL.Visible = true; // display results. ResultsCTRL.Initialize(m_server, (m_subscription != null)?m_subscription.Locale:m_server.Locale, results); } catch (Exception e) { MessageBox.Show(e.Message); } }
/// <summary> /// Executes a write request for the current set if items. /// </summary> public void DoWrite() { try { // get the selected items TsCDaItemValue[] items = ItemsCTRL.GetItems(); // write to server. OpcItemResult[] results = null; if (m_subscription != null) { if (m_synchronous) { results = m_subscription.Write(items); } else { results = new AsyncRequestDlg().ShowDialog(m_subscription, items); if (results == null) { return; } } } else { // add dummy client handles to test that they get returned properly. foreach (TsCDaItemValue item in items) { item.ClientHandle = item.ItemName; } results = m_server.Write(items); } // create a list of item value results. ArrayList values = new ArrayList(); for (int ii = 0; ii < items.Length; ii++) { TsCDaItemValueResult value = new TsCDaItemValueResult(items[ii]); value.ItemName = results[ii].ItemName; value.ItemPath = results[ii].ItemPath; value.ClientHandle = results[ii].ClientHandle; value.ServerHandle = results[ii].ServerHandle; value.Result = results[ii].Result; value.DiagnosticInfo = results[ii].DiagnosticInfo; values.Add(value); } // save results. m_values = (TsCDaItemValueResult[])values.ToArray(typeof(TsCDaItemValueResult)); BackBTN.Enabled = true; NextBTN.Enabled = false; CancelBTN.Visible = false; DoneBTN.Visible = true; OptionsBTN.Visible = false; ItemsCTRL.Visible = false; ResultsCTRL.Visible = true; // display results. ResultsCTRL.Initialize(m_server, (m_subscription != null)?m_subscription.Locale:m_server.Locale, m_values); } catch (Exception e) { MessageBox.Show(e.Message); } }