private void YesCloseWindowCommand(Window obj) { UIOffsetOld = SetPt; if (Int32.Parse(OffsetEnteredAdj) >= -20 && Int32.Parse(OffsetEnteredAdj) <= 20) { try { newResult = Int32.Parse(OffsetEnteredAdj) + Int32.Parse(SetPt); } catch (Exception) { MessageBox.Show("Error: SetPoint is null"); } if (OPCLocal != null) { if (OPCLocal.Connect()) { SetPt = newResult.ToString(); UIOffsetNew = SetPt; _eventAggregator.GetEvent <UpdatedSourceEvent>().Publish(new OPCObject("Set_Pt", SetPt)); } //obj.Close(); } } else { UIOffsetOld = SetPt; MessageBox.Show("Please enter value between -20 and 20."); } }
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(); } }
public void ReadRecipe(string RecipName) { //1-instantiate separate OPC connection on separate thread _OPCRecipeThread = new OPCUtil(); bool isConnected = _OPCRecipeThread.Connect(this); //2-Get recipe details that will be written onto the PLC(Need to access DB) //SegmentSummaryPageViewModel.RecipeName //if (isConnected) //{ //} }