public void InstantiateOPCConnection() { /************************************************************************************************************** * -> Method : InstantiateOPCConnection * -> Event : This method is triggered by CountSubscription Method * -> Description: This method updates all properties in the Hardware class lists and instantiates OPCUtil. **************************************************************************************************************/ _OPCUtil = new OPCUtil(); bool isConnected = _OPCUtil.Connect(this); if (isConnected) { foreach (String hardware in Hardware.SegmentSummaryTagsList) { try { _OPCUtil.Subsribe(GetItemIdentifier(hardware.ToString())); } catch (Exception Ex) { MessageBox.Show(Application.Current.MainWindow, "Error: " + hardware.ToString() + " failed to be subscribe to\n(" + Ex.Message + ")"); } } foreach (String hardware in Hardware.SegmentParameterTagsList) { try { _OPCUtil.Subsribe(GetItemIdentifier(hardware.ToString())); } catch (Exception Ex) { MessageBox.Show(Application.Current.MainWindow, "Error: " + hardware.ToString() + " failed to be subscribe to\n(" + Ex.Message + ")"); } } //foreach (String hardware in Hardware.OffsetTagsList) //{ // try // { // _OPCUtil.Subsribe(GetItemIdentifier(hardware.ToString())); // } // catch (Exception Ex) // { // MessageBox.Show(Application.Current.MainWindow, "Error: " + hardware.ToString() + " failed to be subscribe to\n(" + Ex.Message + ")"); // } //}//useless foreach loop } else // If OPC server fails to connect { Writer.writeAll("Error : " + name + " is unable to connect to OPC server"); MessageBox.Show(Application.Current.MainWindow, "Error: Unable to Connect to Server\nApplication will now Shutdown"); Environment.Exit(0); } }
public void InstantiateOPCConnection() { _OPCUtil = new OPCUtil(); bool isConnected = _OPCUtil.Connect(this); if (isConnected) { foreach (String hardware in Hardware.SegmentSummaryTagsList) { try { _OPCUtil.Subsribe(getItemIdentifier(hardware.ToString())); } catch (Exception ex) { MessageBox.Show(Application.Current.MainWindow, "Error: " + hardware.ToString() + " failed to be subscribed to\n(" + ex.ToString() + ")"); string cheese = ex.ToString(); } } foreach (String hardware in Hardware.SegmentParameterTagsList) { try { _OPCUtil.Subsribe(getItemIdentifier(hardware.ToString())); } catch (Exception ex) { MessageBox.Show(Application.Current.MainWindow, "Error: " + hardware.ToString() + " failed to be subscribed to\n(" + ex.ToString() + ")"); } } foreach (String hardware in Hardware.OffsetTagsList) { try { _OPCUtil.Subsribe(getItemIdentifier(hardware.ToString())); } catch (Exception ex) { MessageBox.Show(Application.Current.MainWindow, "Error: " + hardware.ToString() + " failed to be subscribed to\n(" + ex.ToString() + ")"); } } newWindowThread.Abort(); } else // If OPC server fails to connect { Writer.writeAll("Error : " + name + " is unable to connect to OPC server"); MessageBox.Show(Application.Current.MainWindow, "Error: Unable to Connect to Server\nApplication will now Shutdown"); System.Windows.Application.Current.Shutdown(); } }
private void instantiateOPC() { try { if (OPCLocal != null) { OPCLocal.Subsribe(getItemIdentifier("Set_Pt")); } } catch (Exception ex) { //MessageBox.Show("Error: SetPt failed to be subscribed to\n(" + ex.ToString() + ")"); } }