Ejemplo n.º 1
0
 public Loader()
 {
     this.DoubleBuffered = true;
     InitializeComponent();
     m_instance = this;
     Client     = new Sharp7.S7Client();
     createDM("Visualizer", Client, new Visualizer(), Properties.Resources.data_access_bannerv2);
 }
Ejemplo n.º 2
0
 public Visualizer(Sharp7.S7Client client, VisualComponent component)
 {
     this.DoubleBuffered = true;
     Client = client;
     AddVcPanel(component);
     InitializeComponent();
     m_Instance = this;
 }
Ejemplo n.º 3
0
 public Fehler(Steuerung clientST, bool ueberwachung, int db, int dbByte, int dbBit, int art, int merkerByte, int merkerBit, String fehlertext, String fehlername, int fehlernummer)
 {
     this.clientST     = clientST;
     this.client       = clientST.getS7Client();
     this.ueberwachung = ueberwachung;
     this.db           = db;
     this.dbByte       = dbByte;
     this.dbBit        = dbBit;
     this.art          = art; // 0 = DB, 1 = M
     this.merkerByte   = merkerByte;
     this.merkerBit    = merkerBit;
     this.fehlerText   = fehlertext;
     this.fehlername   = fehlername;
     this.fehlernummer = fehlernummer;
 }
Ejemplo n.º 4
0
        private void CloseSockets()
        {
            //Console.WriteLine(DateTime.Now.ToLongTimeString() + " SiemensCom => CloseSockets : " + _destIP);

            lock (threading)
            {
                if (_s7client != null)
                {
                    _s7client.Disconnect();
                }
                _s7client = null;
            }

            Thread.Sleep(500);
        }
Ejemplo n.º 5
0
        private void watch_Tick(object sender, EventArgs e)
        {
            if (Client == null)
            {
                Client = Loader.Client;
                if (Client == null)
                {
                    MessageBox.Show("An error has occured with the PLC connection, please restart Visualizer and Connection Launcher programs");
                    watch.Enabled = false;
                    return;
                }
            }

            Buffer = Client.ReadIO(Properties.Settings.Default.BufferSize); // MAYBE TOO MUCH DATA HERE AND NO GARBAGE COLLECT
            updateViewNoFlicker();
            UpdateImgBoxControls();
        }
Ejemplo n.º 6
0
        //private void ComHandler()
        //{
        //    // Console.WriteLine(DateTime.Now.ToLongTimeString() + " SiemensCom => Thread started : " + _destIP);
        //    while (!stopThread)
        //    {
        //        try
        //        {
        //            { // forever
        //                try
        //                {
        //                    if (_s7client == null)
        //                        OpenSockets();

        //                    if (_s7client != null && !_s7client.Connected)
        //                        CloseSockets();
        //                }
        //                catch (Exception ex)
        //                {
        //                    Console.WriteLine("ComHandler()" + ex.Message);
        //                    // error ??
        //                }
        //                Thread.Sleep(50);
        //            }
        //        }
        //        catch
        //        {
        //            // Console.WriteLine(DateTime.Now.ToLongTimeString() + " SiemensCom => Thread abborted : " + _destIP);
        //        }

        //    }
        //}

        private void OpenSockets()
        {
            //Console.WriteLine(DateTime.Now.ToLongTimeString() + " SiemensCom => OpenSockets : " + _destIP);
            try
            {
                lock (threading)
                {
                    _s7client = new Sharp7.S7Client();
                    int result = _s7client.ConnectTo(_destIP, 0, 2);
                }
            }
            catch //(Exception ex)
            {
                //Console.WriteLine("SiemensCom : OpenSockets failed -> " + ex.Message);
                CloseSockets();
            }
        }
Ejemplo n.º 7
0
        public void createDM(string Name, Sharp7.S7Client client, SiemensForm Form, Image Image = null, object obj = null)
        {
            Controls.DmData dmd = new DmData();
            dmd.Name    = Name;
            dmd.Client  = client;
            dmd.Icon    = Image;
            dmd.Form    = Form;
            Form.Client = client;
            //dmd.Form.sendPacket = cloud.sendPacket;
            //dmd.Form.getConnection = cloud.getConnection;
            DiagnosticModule dm = new DiagnosticModule(dmd);

            if (obj is Module)
            {
                dm.AssemblyModule = (Module)obj;
            }
            FLOW.Controls.Add(dm);
        }
Ejemplo n.º 8
0
        //public bool Connected = false;

        public Visualizer(Sharp7.S7Client client = null)
        {
            this.DoubleBuffered = true;
            m_Instance          = this;
            if (client == null)
            {
                Client = Loader.Client;
            }

            InitializeComponent();
            if (File.Exists("default.clf"))
            {
                try
                {
                    CLibrary = Library.Read("default.clf");
                    CLibrary = assignEventstoVcps(CLibrary);
                    updateVcpFlow(CLibrary);
                    updateLibrary();
                    updateWatchList();
                }
                catch { }
            }
        }
        public DiagnosticModule(DmData data)
        {
            m_dmdata  = data;
            Client    = m_dmdata.Client;
            ChildForm = data.Form;

            m_tempff = data.Form;
            Text     = data.Name;
            //m_button.Text = data.Name;
            m_icon         = data.Icon;
            m_imgbox.Image = data.Icon;

            this.Size           = new System.Drawing.Size(280, 150);
            this.BorderStyle    = BorderStyle.FixedSingle;
            this.Name           = data.Name;
            m_tooltip.IsBalloon = true;
            m_tooltip.UseFading = true;
            m_tooltip.SetToolTip(this, data.Description);
            m_tooltip.SetToolTip(m_button, data.Description);
            m_tooltip.SetToolTip(m_imgbox, data.Description);
            m_imgbox.Size         = new Size(274, 118);
            m_imgbox.Location     = new Point(3, 3);
            m_imgbox.BorderStyle  = BorderStyle.Fixed3D;
            m_imgbox.SizeMode     = PictureBoxSizeMode.StretchImage;
            m_imgbox.DoubleClick += Button_Click;
            m_button.Anchor       = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right | AnchorStyles.Bottom)));
            m_imgbox.Anchor       = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right | AnchorStyles.Bottom | AnchorStyles.Top)));
            m_button.Size         = new Size(274, 26);
            m_button.Location     = new Point(3, 121);
            m_button.Click       += Button_Click;
            m_button.Font         = new System.Drawing.Font("BankGothic Md BT", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.Controls.Add(m_imgbox);
            this.Controls.Add(m_button);


            Invalidate();
        }
Ejemplo n.º 10
0
        void bg_DoWork(object sender, DoWorkEventArgs e)
        {
            // does a job like writing to serial communication, webservices etc
            var worker = sender as BackgroundWorker;

            stopwatch = new Stopwatch();
            try
            {
                stopwatch.Start();
                //    if (ListMachines != null)
                {
                    machineOperations = new List <MachineOperation>();
                    //MachineItem machine = new MachineItem();
                    //machine.IP = "172.16.1.145";
                    //machine.Line = "L03";
                    LoadAdress();//load list PLC machine
                    foreach (var machine in ListMachines)
                    {
                        try
                        {
                            //     machine.IP =
                            MQCVariable mQCOld = new MQCVariable();
                            if (DicMQCVariableIP.ContainsKey(machine.IP))
                            {
                                mQCOld = DicMQCVariableIP[machine.IP];
                            }


                            MQCVariable mQCPLC     = GetMQCVariableRealtime(machine.IP, mQCOld);
                            MQCVariable mQCChanged = new MQCVariable();
                            if (mQCPLC.Connection == 0)
                            {
                                bool          isChanged   = false;
                                List <string> listChanged = new List <string>();
                                //   if (mQCPLC.DicSPLCtatus[VariablePLC.FlagKT] == true)
                                {
                                    mQCChanged = GetMQCVariableDisCrepancy(mQCPLC, mQCOld, ref isChanged, ref listChanged);
                                    if (DicMQCVariableIP.ContainsKey(machine.IP))
                                    {
                                        DicMQCVariableIP[machine.IP] = mQCPLC;
                                    }
                                    else
                                    {
                                        DicMQCVariableIP.Add(machine.IP, mQCPLC);
                                    }
                                    if (listChanged.Contains("Reset"))
                                    {
                                        //MachineOperation operation = new MachineOperation();
                                        //operation.IP = machine.IP;
                                        //operation.Line = machine.Line;
                                        //operation.Lot = qRMQC_MES.PO;
                                        //operation.Inspector = qRIDMES.FullName;
                                        //operation.product = qRMQC_MES.Product;

                                        //operation.Output = mQCPLC.ListMQCQty[0];
                                        //operation.NG = mQCPLC.ListMQCQty[1];
                                        //operation.Rework = mQCPLC.ListMQCQty[2];
                                        //operation.Status = "Reset";
                                        SQLUpload.SQLQRUpdate sQLQRUpdate = new SQLQRUpdate();
                                        sQLQRUpdate.UpdateOrInsertQRRecordTable(mQCOld, machine.Line);

                                        SystemRecord.Output(SystemRecord.MSG_TYPE.Nor, "QR MES Reset", mQCOld.QRMES);
                                        SystemRecord.Output(SystemRecord.MSG_TYPE.Nor, "QR Inspector", mQCOld.QRID);
                                        SystemRecord.Output(SystemRecord.MSG_TYPE.Nor, "Ouput Quantity", mQCOld.ListMQCQty[0].ToString());
                                        SystemRecord.Output(SystemRecord.MSG_TYPE.Nor, "NG Quantity", mQCOld.ListMQCQty[1].ToString());
                                        SystemRecord.Output(SystemRecord.MSG_TYPE.Nor, "RW Quantity", mQCOld.ListMQCQty[2].ToString());
                                        return;
                                    }
                                    UploadPLCtoDatabase(mQCChanged, listChanged, machine.Line);

                                    QRMQC_MES qRMQC_MES = QRSpilittoClass.QRstring2MQCFormat(mQCPLC.QRMES);
                                    QRIDMES   qRIDMES   = QRSpilittoClass.QRstring2IDFormat(mQCPLC.QRID);

                                    MachineOperation operation = new MachineOperation();
                                    operation.IP        = machine.IP;
                                    operation.Line      = machine.Line;
                                    operation.Lot       = qRMQC_MES.PO;
                                    operation.Inspector = qRIDMES.FullName;
                                    operation.product   = qRMQC_MES.Product;
                                    if (mQCPLC.ListMQCQty.Count == 3)
                                    {
                                        operation.Output = mQCPLC.ListMQCQty[0];
                                        operation.NG     = mQCPLC.ListMQCQty[1];
                                        operation.Rework = mQCPLC.ListMQCQty[2];
                                        operation.Status = "Updating";
                                    }
                                    else if (mQCPLC.ListMQCQty.Count == 0)
                                    {
                                        operation.Output = 0;
                                        operation.NG     = 0;
                                        operation.Rework = 0;
                                        operation.Status = "Waiting";
                                    }
                                    //if (listChanged.Contains("Reset"))
                                    //{
                                    //    operation.Status = "Reset";
                                    //    //SQLUpload.SQLQRUpdate sQLQRUpdate = new SQLQRUpdate();
                                    //    //sQLQRUpdate.UpdateOrInsertQRRecordTable(mQCPLC, machine.Line);
                                    //    SystemRecord.Output(SystemRecord.MSG_TYPE.Nor, "QR MES Reset", mQCPLC.QRMES);
                                    //    SystemRecord.Output(SystemRecord.MSG_TYPE.Nor, "QR Inspector", mQCPLC.QRID);
                                    //    SystemRecord.Output(SystemRecord.MSG_TYPE.Nor, "Ouput Quantity", mQCPLC.ListMQCQty[0].ToString());
                                    //    SystemRecord.Output(SystemRecord.MSG_TYPE.Nor, "NG Quantity", mQCPLC.ListMQCQty[1].ToString());
                                    //    SystemRecord.Output(SystemRecord.MSG_TYPE.Nor, "RW Quantity", mQCPLC.ListMQCQty[2].ToString());

                                    //}
                                    //else
                                    //{
                                    //    operation.Status = "Updating";
                                    //}

                                    machineOperations.Add(operation);
                                }
                            }
                            else
                            {
                                MachineOperation operation = new MachineOperation();
                                operation.IP   = machine.IP;
                                operation.Line = machine.Line;
                                Sharp7.S7Client client = new Sharp7.S7Client();
                                operation.Status = client.ErrorText(mQCPLC.Connection);
                                machineOperations.Add(operation);
                            }
                        }
                        catch (Exception ex)
                        {
                            SystemLog.Output(SystemLog.MSG_TYPE.Err, "PLC IP : " + machine.IP, ex.Message);
                        }
                    }
                }


                stopwatch.Stop();
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "Read PLC fail", ex.Message);
            }

            System.Threading.Thread.Sleep(100);
        }
Ejemplo n.º 11
0
 public SiemensForm(Sharp7.S7Client client)
 {
 }