Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
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();
            }
        }
Ejemplo n.º 3
0
        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)
            //{

            //}
        }
 private void OPCInstanceReceive(OPCUtil _OPCUtl)
 {
     OPCLocal = _OPCUtl;
 }