private void PLC_Update_100_ms(PLCInterface sender, PLCInterfaceEventArgs e) { String msg = ""; // Start analize slike PRVOG RUBA S1 if (((bool)e.StatusData.Kamere.CAM4ZahtjevZaAnalizomS1.Value) && (!edgeDetection)) //Edge detection { HDevExp.InitHalcon(); Thread exportThread = new Thread(new ThreadStart(this.RunDia1)); exportThread.Start(); } edgeDetection = (bool)e.StatusData.Kamere.CAM4ZahtjevZaAnalizomS1.Value == true; //Edge detection help marker // Start analize slike PRVOG RUBA S2 if (((bool)e.StatusData.Kamere.CAM4ZahtjevZaAnalizomS2.Value) && (!edgeDetection)) { HDevExp.InitHalcon(); Thread exportThread = new Thread(new ThreadStart(this.RunDia2)); exportThread.Start(); } edgeDetection = (bool)e.StatusData.Kamere.CAM4ZahtjevZaAnalizomS2.Value == true; // Prioritet poruka (najviši prioritet je na dnu) //if ((bool)e.StatusData.RotacijskaOs.AutomaticActive.Value) msg = "MJERENJE SRHA U TIJEKU"; //if ((bool)e.StatusData.VertikalnaOs.AutomaticActive.Value) msg = "MJERENJE VALOVITOSTI U TIJEKU"; //if ((bool)e.StatusData.Ticalo.AutomaticActive.Value) msg = "MJERENJE DIMENZIJA U TIJEKU"; //if ((bool)e.StatusData.HorizontalnaOs.ReferencedX.Value == false) msg = "OS X NIJE REFERENCIRANA"; //if ((bool)e.StatusData.HorizontalnaOs.ReferencedY.Value == false) msg = "OS Y NIJE REFERENCIRANA"; //if ((bool)e.StatusData.HorizontalnaOs.FaultX.Value == true) msg = "GREŠKA OSI X"; //if ((bool)e.StatusData.HorizontalnaOs.FaultY.Value == true) msg = "GREŠKA OSI Y"; if (mwHandle != null) { mwHandle.tb_statusMessage.Dispatcher.BeginInvoke((Action)(() => { mwHandle.tb_statusMessage.Text = msg; })); } }
private void updatePage(object sender, PLCInterfaceEventArgs e) { List <AreaPoint> l1 = new List <AreaPoint>(); List <AreaPoint> l2 = new List <AreaPoint>(); //if ((bool)e.StatusData.Angle.AutomaticActive.Value) //{ // for (int i = 0; i < 10; i++ ) // { // l1.Add(e.StatusData.Angle.LINE1[i]); // l2.Add(e.StatusData.Angle.LINE2[i]); // } // bestFitLine(l1, out avg1, out k1); // bestFitLine(l2, out avg2, out k2); // y1 = avg1.Y - k1 * avg1.X; // y2 = avg2.Y - k2 * avg2.X; // Math.Atan((k2 - k1) / (1 + k1 * k2)); // Dispatcher.BeginInvoke(new Action(() => // { // lb_alfa.Content = Math.Abs(((180/Math.PI)*Math.Atan((k2 - k1) / (1 + k1 * k2)))).ToString(); // lb_beta.Content = (180.0f - (180/Math.PI)*Math.Atan((k2 - k1) / (1 + k1 * k2))).ToString(); // })); //} Dispatcher.BeginInvoke(new Action(() => { })); }
private void updatePage_100ms(object sender, PLCInterfaceEventArgs e) { Dispatcher.BeginInvoke(new Action(() => { //minimapa.ActualPosition = new Point(Math.Abs((float)e.StatusData.HorizontalnaOs.ActualPosition.X.Value) * scalex, (float)e.StatusData.HorizontalnaOs.ActualPosition.Y.Value * scaley); //minimapa.FirstPoint = new Point(Math.Abs((float)e.StatusData.VertikalnaOs.FirstPoint.X.Value) * scalex, (float)e.StatusData.VertikalnaOs.FirstPoint.Y.Value * scaley); //minimapa.SecondPoint = new Point(Math.Abs((float)e.StatusData.VertikalnaOs.LastPoint.X.Value) * scalex, (float)e.StatusData.VertikalnaOs.LastPoint.Y.Value * scaley); //if (((bool)e.StatusData.VertikalnaOs.AutomaticActive.Value == true) && ((bool)e.StatusData.VertikalnaOs.SheetAbsent.Value == false)) //{ // b_pokreniMjerenje.Foreground = Brushes.Red; // b_pokreniMjerenje.Content = "STOP"; //} //else //{ // b_pokreniMjerenje.Content = "POKRENI MJERENJE"; // b_pokreniMjerenje.Foreground = Brushes.Black; //} //if (((bool)e.StatusData.VertikalnaOs.AutomaticActive.Value == true) && ((bool)e.StatusData.VertikalnaOs.SheetAbsent.Value == true)) //{ // b_pokreniKompenzaciju.Foreground = Brushes.Red; // b_pokreniKompenzaciju.Content = "STOP"; //} //else //{ // b_pokreniKompenzaciju.Content = "POKRENI KOMPENZACIJU"; // b_pokreniKompenzaciju.Foreground = Brushes.Black; //} })); }
private void updatePage(object sender, PLCInterfaceEventArgs e) { Dispatcher.BeginInvoke(new Action(() => { //lb_tempGlass1.Content = (((int)e.StatusData.Temperature.Glass1.Value) / 10.0f).ToString(); //lb_tempGlass2.Content = ((((int)e.StatusData.Temperature.Glass1.Value)-1) / 10.0f).ToString(); //lb_tempLG1.Content = (((int)e.StatusData.Temperature.LG1.Value) / 10.0f).ToString(); //lb_tempLG2.Content = (((int)e.StatusData.Temperature.LG2.Value) / 10.0f).ToString(); })); }
private void onClock100msTick(Object source, System.Timers.ElapsedEventArgs e) { int result; lock (TimerLock) { result = ReadStatus(); } PLCInterfaceEventArgs p1 = new PLCInterfaceEventArgs(); p1.StatusData = STATUS; p1.CyclicStatusBuffer = CyclicStatusBuffer; if (Update_100_ms != null) { Update_100_ms(this, p1); } if (updateCounter == 10) { result = 0; lock (TimerLock) { result = ReadControl(); //result = ReadStatus(); //result += ReadManual(); } PLCInterfaceEventArgs p2 = new PLCInterfaceEventArgs(); p2.ControlData = CONTROL; //p2.StatusData = STATUS; p2.CyclicControlBuffer = CyclicControlBuffer; //p2.CyclicStatusBuffer = CyclicStatusBuffer; //p2.StatusData = STATUS; //p3 //PLCInterfaceEventArgs p3 = new PLCInterfaceEventArgs(); //p3.StatusData = STATUS; //p3.CyclicStatusBuffer = CyclicStatusBuffer; if ((Update_1_s != null) && (result == 0)) { //if ((Update_1_s != null)) Update_1_s(this, p2); } //Update_1_s(this, p3); updateCounter = 0; } updateCounter++; Clock_100_ms.Start(); }
private void updatePage1234(object sender, PLCInterfaceEventArgs e) { Dispatcher.BeginInvoke((Action)(() => { try { ControlTag.GetValueFromGroupBuffer(e.CyclicControlBuffer); SetpointX888 = (float)ControlTag.Value; } catch { } } )); }
private void updatePage(object sender, PLCInterfaceEventArgs e) { //if ((bool)e.StatusData.VertikalnaOs.AutomaticActive.Value) //{ // points.Clear(); // byte[] tempByte = App.PLC.ReadCustom(30, 36, 2000); // DB30 LASER_SENSOR_DB, DATA_LOG_BUFFER offset 42.0, Array[0..999] of Int (16 bit!), db30.dbd36 = Resolution // float resolution = Snap7.S7.GetRealAt(tempByte, 0); // for (int i = 6; i < 1006; i++) // { // Int16 ripple = (Int16)((tempByte[i * 2] << 8) | tempByte[i * 2 + 1]); // if (ripple == -32768) // { // break; // } // points.Add(new DataPoint(i*resolution, ripple/1000.0f)); // // } // rippleDetection.RippleData = points; // Dispatcher.BeginInvoke(new Action(() => // { // try // { // rippleDetection.Smooth(); // graf.InvalidatePlot(true); // rippleDetection.EdgeThicknes = (int)(Convert.ToDouble(tb_debljina.Text.Replace(".", ",")) * 1000); // rippleDetection.Detect(); // } // catch // { // } // lb_brojValova.Content = rippleDetection.NoOfWaves.ToString(); // lb_dužinaVala.Content = rippleDetection.EdgeLength.ToString(); // lb_faktorValovitosti.Content = rippleDetection.Ratio.ToString(); // lb_visinaVala.Content = (rippleDetection.EdgeHeight/1000.0f).ToString(); // App.MainReportInterface.Valovitost_brojValova = rippleDetection.NoOfWaves; // App.MainReportInterface.Valovitost_duzinaVala = rippleDetection.EdgeLength; // App.MainReportInterface.Valovitost_faktor = rippleDetection.Ratio; // App.MainReportInterface.Valovitost_visinaVala = rippleDetection.EdgeHeight / 1000.0f; // App.MainReportInterface.Valovitost_pozicija = OdabirLimovaKontrola.LineNumber; // })); //} }
private void updatePage(object sender, PLCInterfaceEventArgs e) { //cameraPointList.Clear(); //for (int i = 0; i <= e.StatusData.Ticalo.POINTS.Length - 1; i++) //{ // if ((e.StatusData.Ticalo.POINTS[i].TYPE == (short)objectType.CIRCLE) || (e.StatusData.Ticalo.POINTS[i].TYPE == (short)objectType.ANGLE)) // { // cameraPointList.Add(new Point(e.StatusData.Ticalo.POINTS[i].POINT1.X, e.StatusData.Ticalo.POINTS[i].POINT1.Y)); // } //} //Dispatcher.BeginInvoke(new Action(() => //{ // odabirLimova.AddPointList(cameraPointList); //})); }
private void updatePage_100(object sender, PLCInterfaceEventArgs e) { Dispatcher.BeginInvoke(new Action(() => { //if (((bool)e.StatusData.Ticalo.AutomaticActive.Value == true) && (b_ponoviMjerenje.Content != "STOP")) //{ // b_ponoviMjerenje.Foreground = Brushes.Red; // b_ponoviMjerenje.Content = "STOP"; //} //else if (((bool)e.StatusData.Ticalo.AutomaticActive.Value == false) && (b_ponoviMjerenje.Foreground != Brushes.Black)) //{ // b_ponoviMjerenje.Content = "PONOVI MJERENJE\n AUTOMATSKI"; // b_ponoviMjerenje.Foreground = Brushes.Black; //} })); }
private void updatePage_1_s(object sender, PLCInterfaceEventArgs e) { Dispatcher.BeginInvoke(new Action(() => { //if (e.ControlData != null) // if ((bool)e.ControlData.Temperature.CompesationOn.Value) // { // b_ukljuci.Content = "ISKLJUČI"; // b_ukljuci.Foreground = System.Windows.Media.Brushes.Green; // } // else // { // b_ukljuci.Content = "UKLJUČI"; // b_ukljuci.Foreground = System.Windows.Media.Brushes.Black; // } })); }
//public int WriteCameraOutput(PrepoznavanjeOblika.CameraOutputType cameraOutput) //{ // //byte[] _tempBuffer = new byte[22]; // //int result = -99; // //lock (PLCInterface.TimerLock) // //{ // // if (Client.Connected()) // // { // // S7.SetRealAt(_tempBuffer, 0, cameraOutput.POINT1.X + (float)STATUS.HorizontalnaOs.ActualPosition.X.Value); // // S7.SetRealAt(_tempBuffer, 4, cameraOutput.POINT1.Y + (float)STATUS.HorizontalnaOs.ActualPosition.Y.Value); // // S7.SetRealAt(_tempBuffer, 8, cameraOutput.POINT2.X + (float)STATUS.HorizontalnaOs.ActualPosition.X.Value); // // S7.SetRealAt(_tempBuffer, 12, cameraOutput.POINT2.Y + (float)STATUS.HorizontalnaOs.ActualPosition.Y.Value); // // S7.SetRealAt(_tempBuffer, 16, cameraOutput.PARAMETER); // // S7.SetIntAt(_tempBuffer, 20, (short)cameraOutput.TYPE); // // result = Client.DBWrite(28, 12, 22, _tempBuffer); // // } // //} // //return result; //} #endregion private void onClock100msTick(Object source, System.Timers.ElapsedEventArgs e) { //Thread.CurrentThread.Name = "PLCinterface_100msTick_Thread_" + second_counter.ToString(); //second_counter++; int result; lock (TimerLock) { result = ReadStatus(); } PLCInterfaceEventArgs p1 = new PLCInterfaceEventArgs(); p1.StatusData = STATUS; p1.CyclicStatusBuffer = CyclicStatusBuffer; if (Update_100_ms != null) { Update_100_ms(this, p1); } if (updateCounter == 10) { result = 0; lock (TimerLock) { result = ReadControl(); //result += ReadManual(); } PLCInterfaceEventArgs p2 = new PLCInterfaceEventArgs(); p2.ControlData = CONTROL; p2.CyclicControlBuffer = CyclicControlBuffer; //p2.StatusData = STATUS; if ((Update_1_s != null) && (result == 0)) { Update_1_s(this, p2); } updateCounter = 0; } updateCounter++; Clock_100_ms.Start(); }
private void updatePage(object sender, PLCInterfaceEventArgs e) { //if ((bool)e.StatusData.Saber.AutomaticActive.Value) //{ // points.Clear(); // double saber; // double max = Double.MinValue, min = Double.MaxValue; // Point p1, p2; // p1 = new Point((float)e.StatusData.Saber.FirstPoint.X.Value, (float)e.StatusData.Saber.FirstPoint.Y.Value); // p2 = new Point((float)e.StatusData.Saber.SecondPoint.X.Value, (float)e.StatusData.Saber.SecondPoint.Y.Value); // float resolution = (float)Math.Sqrt(Math.Pow(p1.X - p2.X, 2) + Math.Pow(p1.Y - p2.Y, 2)) / ((int)e.ControlData.Ticalo.NumberOfMeas.Value - 1); // for (int i = 0; i < (int)e.ControlData.Ticalo.NumberOfMeas.Value; i++) // { // saber = -distancePointToLine(p1, p2, e.StatusData.Saber.POINTS[i]); // if (saber < min) min = saber; // else if (saber > max) max = saber; // if ((-10f > saber) || (saber > 10f)) // { // break; // } // points.Add(new DataPoint(i , saber)); // } // Dispatcher.BeginInvoke(new Action(() => // { // graf.InvalidatePlot(true); // App.MainReportInterface.Sablja_duljina = (float)Math.Sqrt(Math.Pow(p1.X - p2.X, 2) + Math.Pow(p1.Y - p2.Y, 2)); // App.MainReportInterface.Sablja_visina = (float)(max - min); // App.MainReportInterface.Sablja_posto = App.MainReportInterface.Sablja_visina / App.MainReportInterface.Sablja_duljina * 100.0f; // })); //} Dispatcher.BeginInvoke(new Action(() => { App.MainReportInterface.Sablja_pozicija = OdabirLimovaKontrola.LineNumber; })); }
private void updatePage123(object sender, PLCInterfaceEventArgs e) { Dispatcher.BeginInvoke((Action)(() => { try { ControlTag.GetValueFromGroupBuffer(e.CyclicStatusBuffer); if ((bool)ControlTag.Value) { label123.Background = OnColor; } else { label123.Background = OffColor; } } catch { } } )); }
private void updateStatus(object sender, PLCInterfaceEventArgs e) { Dispatcher.BeginInvoke((Action)(() => { try { StatusTag.GetValueFromGroupBuffer(e.CyclicStatusBuffer); if ((bool)StatusTag.Value) { Grid.Background = OnColor; Button.Margin = new Thickness(3); } else { Grid.Background = OffColor; Button.Margin = new Thickness(1); } } catch { } } )); }
private void PLC_Update_100_ms(PLCInterface sender, PLCInterfaceEventArgs e) { String msg = "SISTEM SPREMAN"; // Start analize slike D1 PRVOG RUBA S1 ******************************************************************** if (((bool)e.StatusData.Kamere.CAM4ZahtjevZaAnalizomS1.Value) && ((float)e.StatusData.MjerenjeDiametara.BrojPonavljanjaSekvence.Value == 1.0f) && _oneCallFlagD1S1) { _oneCallFlagD1S1 = false; Thread d1meassureS1 = new Thread(() => HDevExp.RunHalcon1(windowID)); // d1meassureS1.name = "Thread D1S1 d1meassureS1.Name = "Thread D1S1"; d1meassureS1.Start(); } else if (!(bool)e.StatusData.Kamere.CAM4ZahtjevZaAnalizomS1.Value) { _oneCallFlagD1S1 = true; } // Start analize slike D1 DRUGOG RUBA S2 ******************************************************************* if (((bool)e.StatusData.Kamere.CAM4ZahtjevZaAnalizomS2.Value) && ((float)e.StatusData.MjerenjeDiametara.BrojPonavljanjaSekvence.Value == 1.0f) && _oneCallFlagD1S2) { _oneCallFlagD1S2 = false; //Thread d1meassureS2 = new Thread(new ThreadStart(HDevExp.RunHalcon2)); Thread d1meassureS2 = new Thread(() => HDevExp.RunHalcon2(windowID)); d1meassureS2.Name = "Thread D1S2"; d1meassureS2.Start(); } else if (!(bool)e.StatusData.Kamere.CAM4ZahtjevZaAnalizomS2.Value) { _oneCallFlagD1S2 = true; } // Start analize slike D2 DRUGOG RUBA S1 ******************************************************************* if (((bool)e.StatusData.Kamere.CAM4ZahtjevZaAnalizomS1.Value) && ((float)e.StatusData.MjerenjeDiametara.BrojPonavljanjaSekvence.Value == 2.0f) && _oneCallFlagD2S1) { _oneCallFlagD2S1 = false; //Thread d2meassureS1 = new Thread(new ThreadStart(HDevExp.RunHalcon3)); Thread d1meassureS2 = new Thread(() => HDevExp.RunHalcon3(windowID)); d1meassureS2.Name = "Thread D2S1"; d1meassureS2.Start(); } else if (!(bool)e.StatusData.Kamere.CAM4ZahtjevZaAnalizomS1.Value) { _oneCallFlagD2S1 = true; } // Start analize slike D2 DRUGOG RUBA S2 ******************************************************************* if (((bool)e.StatusData.Kamere.CAM4ZahtjevZaAnalizomS2.Value) && ((float)e.StatusData.MjerenjeDiametara.BrojPonavljanjaSekvence.Value == 2.0f) && _oneCallFlagD2S2) { _oneCallFlagD2S2 = false; //Thread d2meassureS2 = new Thread(new ThreadStart(HDevExp.RunHalcon4)); Thread d2meassureS2 = new Thread(() => HDevExp.RunHalcon4(windowID)); d2meassureS2.Name = "Thread D2S2"; d2meassureS2.Start(); } else if (!(bool)e.StatusData.Kamere.CAM4ZahtjevZaAnalizomS2.Value) { _oneCallFlagD2S2 = true; } // Start analize slike D3 DRUGOG RUBA S1 ******************************************************************* if (((bool)e.StatusData.Kamere.CAM4ZahtjevZaAnalizomS1.Value) && ((float)e.StatusData.MjerenjeDiametara.BrojPonavljanjaSekvence.Value == 3.0f) && _oneCallFlagD3S1) { _oneCallFlagD3S1 = false; //Thread d3meassureS1 = new Thread(new ThreadStart(HDevExp.RunHalcon5)); Thread d3meassureS1 = new Thread(() => HDevExp.RunHalcon5(windowID)); d3meassureS1.Name = "Thread D3S1"; d3meassureS1.Start(); } else if (!(bool)e.StatusData.Kamere.CAM4ZahtjevZaAnalizomS1.Value) { _oneCallFlagD3S1 = true; } // Start analize slike D3 DRUGOG RUBA S2 ******************************************************************* if (((bool)e.StatusData.Kamere.CAM4ZahtjevZaAnalizomS2.Value) && ((float)e.StatusData.MjerenjeDiametara.BrojPonavljanjaSekvence.Value == 3.0f) && _oneCallFlagD3S2) { _oneCallFlagD3S2 = false; //Thread d3meassureS2 = new Thread(new ThreadStart(HDevExp.RunHalcon6)); Thread d3meassureS2 = new Thread(() => HDevExp.RunHalcon6(windowID)); d3meassureS2.Name = "Thread D3S2"; d3meassureS2.Start(); } else if (!(bool)e.StatusData.Kamere.CAM4ZahtjevZaAnalizomS2.Value) { _oneCallFlagD3S2 = true; } // Start analize slike D4 DRUGOG RUBA S1 ******************************************************************* if (((bool)e.StatusData.Kamere.CAM4ZahtjevZaAnalizomS1.Value) && ((float)e.StatusData.MjerenjeDiametara.BrojPonavljanjaSekvence.Value == 4.0f) && _oneCallFlagD4S1) { _oneCallFlagD4S1 = false; //Thread d4meassureS1 = new Thread(new ThreadStart(HDevExp.RunHalcon7)); Thread d4meassureS1 = new Thread(() => HDevExp.RunHalcon7(windowID)); d4meassureS1.Name = "Thread D4S1"; d4meassureS1.Start(); } else if (!(bool)e.StatusData.Kamere.CAM4ZahtjevZaAnalizomS1.Value) { _oneCallFlagD4S1 = true; } // Start analize slike D4 DRUGOG RUBA S2 ******************************************************************* if (((bool)e.StatusData.Kamere.CAM4ZahtjevZaAnalizomS2.Value) && ((float)e.StatusData.MjerenjeDiametara.BrojPonavljanjaSekvence.Value == 4.0f) && _oneCallFlagD4S2) { _oneCallFlagD4S2 = false; //Thread d4meassureS2 = new Thread(new ThreadStart(HDevExp.RunHalcon8)); Thread d4meassureS2 = new Thread(() => HDevExp.RunHalcon8(windowID)); d4meassureS2.Name = "Thread D4S2"; d4meassureS2.Start(); } else if (!(bool)e.StatusData.Kamere.CAM4ZahtjevZaAnalizomS2.Value) { _oneCallFlagD4S2 = true; } // Start analize slike D5 DRUGOG RUBA S1 ******************************************************************* if (((bool)e.StatusData.Kamere.CAM4ZahtjevZaAnalizomS1.Value) && ((float)e.StatusData.MjerenjeDiametara.BrojPonavljanjaSekvence.Value == 5.0f) && _oneCallFlagD5S1) { _oneCallFlagD5S1 = false; //Thread d4meassureS1 = new Thread(new ThreadStart(HDevExp.RunHalcon7)); Thread d5meassureS1 = new Thread(() => HDevExp.RunDia5side1(windowID)); d5meassureS1.Name = "Thread D5S1"; d5meassureS1.Start(); } else if (!(bool)e.StatusData.Kamere.CAM4ZahtjevZaAnalizomS1.Value) { _oneCallFlagD5S1 = true; } // Start analize slike D5 DRUGOG RUBA S2 ******************************************************************* if (((bool)e.StatusData.Kamere.CAM4ZahtjevZaAnalizomS2.Value) && ((float)e.StatusData.MjerenjeDiametara.BrojPonavljanjaSekvence.Value == 5.0f) && _oneCallFlagD5S2) { _oneCallFlagD5S2 = false; //Thread d4meassureS2 = new Thread(new ThreadStart(HDevExp.RunHalcon8)); Thread d5meassureS2 = new Thread(() => HDevExp.RunDia5side2(windowID)); d5meassureS2.Name = "Thread D5S2"; d5meassureS2.Start(); } else if (!(bool)e.StatusData.Kamere.CAM4ZahtjevZaAnalizomS2.Value) { _oneCallFlagD5S2 = true; } // Start analize slike za detekciju POROZNOSTI VERTIKALNO *************************************************** if (((bool)e.StatusData.Kamere.CAM2ZahtjevZaAnalizom.Value) && _onceCallFlagPorVer) { _onceCallFlagPorVer = false; Thread porosityverth = new Thread(new ThreadStart(pPoroznost.PorosityVerWindow)); porosityverth.Name = "Thread PorosityVer"; porosityverth.Start(); // Start sa display-om, thread error //pPoroznost.PorosityVerWindow(); } else if (!(bool)e.StatusData.Kamere.CAM2ZahtjevZaAnalizom.Value) { _onceCallFlagPorVer = true; } // Start analize slike za detekciju POROZNOSTI HORIZONTALNO ************************************************ if (((bool)e.StatusData.Kamere.CAM3ZahtjevZaAnalizom.Value) && _oneCallFlagPorHor) { _oneCallFlagPorHor = false; Thread porosityhorth = new Thread(new ThreadStart(pPoroznost.PorosityHorWindow)); porosityhorth.Name = "Thread PorosityHor"; porosityhorth.Start(); // Start sa display-om, thread error //pPoroznost.PorosityHorWindow(); } else if (!(bool)e.StatusData.Kamere.CAM3ZahtjevZaAnalizom.Value) { _oneCallFlagPorHor = true; } // Start analize slike za robot PICK - LEFT PALLET *********************************************************** if (((bool)e.StatusData.Kamere.CAM1ZahtjevZaAnalizomT1.Value) && _oneCallFlagPick) { _oneCallFlagPick = false; leftpallet = true; lastlayerleft = (bool)e.StatusData.TrenutniSlojevi.ZadnjiSlojLijeva.Value; // We call public method in class pRobot Thread pickTriggerT1 = new Thread(() => pRobot.RobotPickStartT1(leftpallet, lastlayerleft)); pickTriggerT1.Name = "Thread pickTriggerT1"; pickTriggerT1.Start(); } else if (!(bool)e.StatusData.Kamere.CAM1ZahtjevZaAnalizomT1.Value) { _oneCallFlagPick = true; } // Start analize slike za robot PICK - RIGHT PALLET ********************************************************** if (((bool)e.StatusData.Kamere.CAM1ZahtjevZaAnalizomT2.Value) && _oneCallFlagPickRight) { _oneCallFlagPickRight = false; leftpallet = false; lastlayerright = (bool)e.StatusData.TrenutniSlojevi.ZadnjiSlojDesna.Value; Thread pickTriggerT2 = new Thread(() => pRobot.RobotPickStartT1(leftpallet, lastlayerright)); pickTriggerT2.Name = "Thread pickTriggerT2"; pickTriggerT2.Start(); } else if (!(bool)e.StatusData.Kamere.CAM1ZahtjevZaAnalizomT2.Value) { _oneCallFlagPickRight = true; } // R-Os je prosla 360 i nije nasla porozni dio CAM2 if (((bool)e.StatusData.MjerenjePoroznosti.GotovoCAM2.Value) && _oneCallFlagPorVerNotFound) { _oneCallFlagPorVerNotFound = false; HDevExp.Porositydetectedver = true; //HDevExp.Porositydetectedhor = true; } else if (!(bool)e.StatusData.MjerenjePoroznosti.GotovoCAM2.Value) { _oneCallFlagPorVerNotFound = true; } // R-Os je prosla 360 i nije nasla porozni dio CAM3 if (((bool)e.StatusData.MjerenjePoroznosti.GotovoCAM3.Value) && _oneCallFlagPorHorNotFound) { _oneCallFlagPorHorNotFound = false; //HDevExp.Porositydetectedver = true; HDevExp.Porositydetectedhor = true; } else if (!(bool)e.StatusData.MjerenjePoroznosti.GotovoCAM3.Value) { _oneCallFlagPorHorNotFound = true; } // Save Data from PLC if (((bool)e.StatusData.Automatika.SnimiMjerenja.Value) && _oneCallFlagSaveData) { _oneCallFlagSaveData = false; savedata.Add(new ReportInterface.DimensionLine { String = "No.1", Poroznost = true, // D1 NazivnoD1 = (float)e.StatusData.Upisanevrijednosti.Dijametar1.Value, MjerenoD1 = (float)e.StatusData.MjerenjeDiametara.Diametar1.Value, DeltaPlusD1 = (float)e.StatusData.Upisanevrijednosti.Dijametar1DeltaPlus.Value, DeltaMinusD1 = (float)e.StatusData.Upisanevrijednosti.Dijametar1DeltaMinus.Value, // D2 NazivnoD2 = (float)e.StatusData.Upisanevrijednosti.Dijametar2.Value, MjerenoD2 = (float)e.StatusData.MjerenjeDiametara.Diametar2.Value, DeltaPlusD2 = (float)e.StatusData.Upisanevrijednosti.Dijametar2DeltaPlus.Value, DeltaMinusD2 = (float)e.StatusData.Upisanevrijednosti.Dijametar2DeltaMinus.Value, // D3 NazivnoD3 = (float)e.StatusData.Upisanevrijednosti.Dijametar3.Value, MjerenoD3 = (float)e.StatusData.MjerenjeDiametara.Diametar3.Value, DeltaPlusD3 = (float)e.StatusData.Upisanevrijednosti.Dijametar3DeltaPlus.Value, DeltaMinusD3 = (float)e.StatusData.Upisanevrijednosti.Dijametar3DeltaMinus.Value, // D4 NazivnoD4 = (float)e.StatusData.Upisanevrijednosti.Dijametar4.Value, MjerenoD4 = (float)e.StatusData.MjerenjeDiametara.Diametar4.Value, DeltaPlusD4 = (float)e.StatusData.Upisanevrijednosti.Dijametar4DeltaPlus.Value, DeltaMinusD4 = (float)e.StatusData.Upisanevrijednosti.Dijametar4DeltaMinus.Value, // D5 NazivnoD5 = (float)e.StatusData.Upisanevrijednosti.Dijametar5.Value, MjerenoD5 = (float)e.StatusData.MjerenjeDiametara.Diametar5.Value, DeltaPlusD5 = (float)e.StatusData.Upisanevrijednosti.Dijametar5DeltaPlus.Value, DeltaMinusD5 = (float)e.StatusData.Upisanevrijednosti.Dijametar5DeltaMinus.Value, // V1 NazivnoV1 = (float)e.StatusData.Upisanevrijednosti.Visina1.Value, MjerenoV1 = (float)e.StatusData.MjerenjeTicalom.Visina1.Value, DeltaPlusV1 = (float)e.StatusData.Upisanevrijednosti.Visina1DeltaPlus.Value, DeltaMinusV1 = (float)e.StatusData.Upisanevrijednosti.Visina1DeltaMinus.Value, // V2 NazivnoV2 = (float)e.StatusData.Upisanevrijednosti.Visina2.Value, MjerenoV2 = (float)e.StatusData.MjerenjeTicalom.Visina2.Value, DeltaPlusV2 = (float)e.StatusData.Upisanevrijednosti.Visina2DeltaPlus.Value, DeltaMinusV2 = (float)e.StatusData.Upisanevrijednosti.Visina2DeltaMinus.Value, // V3 NazivnoV3 = (float)e.StatusData.Upisanevrijednosti.Visina3.Value, // Ne Radi, probati //NazivnoV3 = ((float)e.StatusData.Upisanevrijednosti.Visina2.Value - (float)e.StatusData.Upisanevrijednosti.Visina3.Value), MjerenoV3 = (float)e.StatusData.MjerenjeTicalom.Visina3.Value, DeltaPlusV3 = (float)e.StatusData.Upisanevrijednosti.Visina3DeltaPlus.Value, DeltaMinusV3 = (float)e.StatusData.Upisanevrijednosti.Visina3DeltaMinus.Value, // VB // Dodati naknadno - nije potrebno ispisivati u izvjestaju // NazivnoVB = (float)e.StatusData.Upisanevrijednosti. MjerenoVB = (float)e.StatusData.MjerenjeTicalom.VisinaBaze.Value, // V2 Devijacija MjerenoV2Devijacija = (float)e.StatusData.MjerenjeTicalom.DevijacijaVisine.Value }); string json = JsonConvert.SerializeObject(savedata.ToArray(), Formatting.Indented); string DataBaseFileName = "savedata.JSON"; string DataBasePath = Path.Combine(Environment.CurrentDirectory, @"database", DataBaseFileName); File.WriteAllText(DataBasePath, json); } else if (!(bool)e.StatusData.Automatika.SnimiMjerenja.Value) { _oneCallFlagSaveData = true; } // Save TEST DATA S1 if (((bool)e.StatusData.Automatika.SnimiMjerenjaS1.Value) && _oneCallFlagTestDataS1) { _oneCallFlagTestDataS1 = false; // Code // Update list values //var updateHor = testdata.FirstOrDefault(v => v.ValueHorS1 == 0.0); //if (updateHor != null) //{ // updateHor.ValueHorS1 = (float)e.StatusData.HorizontalnaOs.AktualnaPozicija.Value; //} //var updateVer = testdata.FirstOrDefault(v => v.ValueVerS1 == 0.0); //if (updateVer != null) //{ // updateVer.ValueVerS1 = (float) e.StatusData.VertikalnaOs.AktualnaPozicija.Value; //} //var updatePx = testdata.FirstOrDefault(v => v.ValuePxS1 == 0.0); //if (updateVer != null) //{ // updateVer.ValuePxS1 = (float)e.StatusData.Kamere.CAM4Rezultat.Value; //} //testdata.Insert(0, new ReportInterface.TestData //{ // ValueHorS1 = (float)e.StatusData.HorizontalnaOs.AktualnaPozicija.Value, // ValueVerS1 = (float)e.StatusData.VertikalnaOs.AktualnaPozicija.Value, // ValuePxS1 = (float)e.StatusData.Kamere.CAM4Rezultat.Value, //}); testdata.Add(new ReportInterface.TestData { ValueHorS1 = (float)e.StatusData.HorizontalnaOs.AktualnaPozicija.Value, ValueVerS1 = (float)e.StatusData.VertikalnaOs.AktualnaPozicija.Value, ValuePxS1 = (float)e.StatusData.Kamere.CAM4Rezultat.Value, TemperatureCam4S1 = (float)e.StatusData.Kamere.CAM3Rezultat.Value, }); // Save to memory string json = JsonConvert.SerializeObject(testdata.ToArray(), Formatting.Indented); string DataBaseFileName = "testdata.JSON"; string DataBasePath = Path.Combine(Environment.CurrentDirectory, @"database", DataBaseFileName); File.WriteAllText(DataBasePath, json); } else if (!(bool)e.StatusData.Automatika.SnimiMjerenjaS1.Value) { _oneCallFlagTestDataS1 = true; } // Save TEST DATA S2 if (((bool)e.StatusData.Automatika.SnimiMjerenjaS2.Value) && _oneCallFlagTestDataS2) { _oneCallFlagTestDataS2 = false; // Code testdata.Add(new ReportInterface.TestData { ValueHorS2 = (float)e.StatusData.HorizontalnaOs.AktualnaPozicija.Value, ValueVerS2 = (float)e.StatusData.VertikalnaOs.AktualnaPozicija.Value, ValuePxS2 = (float)e.StatusData.Kamere.CAM4Rezultat.Value, TemperatureCam4S2 = (float)e.StatusData.Kamere.CAM3Rezultat.Value, }); // Added to record one edge data // Save to memory string json = JsonConvert.SerializeObject(testdata.ToArray(), Formatting.Indented); string DataBaseFileName = "testdata.JSON"; string DataBasePath = Path.Combine(Environment.CurrentDirectory, @"database", DataBaseFileName); File.WriteAllText(DataBasePath, json); } else if (!(bool)e.StatusData.Automatika.SnimiMjerenjaS2.Value) { _oneCallFlagTestDataS2 = true; } if (mwHandle != null) { mwHandle.tb_statusMessage.Dispatcher.BeginInvoke((Action)(() => { mwHandle.tb_statusMessage.Text = msg; })); } }
private void updatePage_100ms(object sender, PLCInterfaceEventArgs e) { Dispatcher.BeginInvoke(new Action(() => { //minimapa.ActualPosition = new Point(Math.Abs((float)e.StatusData.HorizontalnaOs.ActualPosition.X.Value) * scalex, (float)e.StatusData.HorizontalnaOs.ActualPosition.Y.Value * scaley); //minimapa.FirstPoint = new Point(Math.Abs((float)e.StatusData.RotacijskaOs.FirstPoint.X.Value) * scalex, (float)e.StatusData.RotacijskaOs.FirstPoint.Y.Value * scaley); //minimapa.SecondPoint = new Point(Math.Abs((float)e.StatusData.RotacijskaOs.LastPoint.X.Value) * scalex, (float)e.StatusData.RotacijskaOs.LastPoint.Y.Value * scaley); //if (((bool)e.StatusData.RotacijskaOs.AutomaticActive.Value == true) && (p_pokreniMjerenje.Content != "STOP")) //{ // p_pokreniMjerenje.Foreground = Brushes.Red; // p_pokreniMjerenje.Content = "STOP"; //} //else if (((bool)e.StatusData.RotacijskaOs.AutomaticActive.Value == false) && (p_pokreniMjerenje.Foreground != Brushes.Black)) //{ // p_pokreniMjerenje.Content = "POKRENI MJERENJE"; // p_pokreniMjerenje.Foreground = Brushes.Black; // if (points.Count > 1) // { // points.Clear(); // rawPlotData = App.PLC.ReadCustom(60, 100, 4000); // DB60 LENGTH_GAUGE_DB // for (int i = 0; i < 2000; i++) // { // Int16 srh = (Int16)((rawPlotData[i * 2] << 8) | rawPlotData[i * 2 + 1]); // if (srh == -32768) // { // if (((i) < ((i / 100) + 1) * 100) && ((i - ((i / 100) * 100) > 10))) // { // double tempp = points[i - 1].Y; // points.Add(new DataPoint(i * 0.1, tempp)); // continue; // } // else // { // break; // } // } // points.Add(new DataPoint(i * 0.1, (float)srh / 2.0f)); // } // points.Add(new DataPoint(points[points.Count - 1].X + 0.1, points[points.Count - 1].Y)); // points.Add(new DataPoint(points[points.Count - 1].X + 0.1, points[points.Count - 1].Y)); // // points.Add(new DataPoint(points[points.Count - 1].X,points[points.Count - 1].Y)); // Dispatcher.BeginInvoke(new Action(() => // { // burrDetection.Position = OdabirLimovaKontrola.LineNumber; // position number // })); // burrDetection.BurrData = points; // setting this parameter will calculate burr data // Dispatcher.BeginInvoke(new Action(() => // { // graf.InvalidatePlot(true); // l_maxSrh.Content = burrDetection.MaxBurr.ToString(); // l_postotak.Content = burrDetection.BurrPercent.ToString(); // // Za izvještaj // App.MainReportInterface.BurrList.Clear(); // if (burrDetection.BurrList != null) // { // App.MainReportInterface.BurrList.AddRange(burrDetection.BurrList); // } // dataGrid1.Items.Refresh(); // App.pIzvjestaji.dataGridSrh.Items.Refresh(); // App.MainReportInterface.Srh_max = burrDetection.MaxBurr; // App.MainReportInterface.Srh_postotak = burrDetection.BurrPercent; // App.MainReportInterface.Srh_pozicija = OdabirLimovaKontrola.LineNumber; // App.MainReportInterface.Srh_brojUzoraka = NumberOfMeas; // })); // } //} //if ((bool)e.StatusData.RotacijskaOs.AutomaticSimpleActive.Value == true) //{ // float posX = (float)e.StatusData.HorizontalnaOs.ActualPosition.X.Value; // float posY = (float)e.StatusData.HorizontalnaOs.ActualPosition.Y.Value; // float lengthGaugeValue = ((float)e.StatusData.RotacijskaOs.LengthGaugeActualValue.Value) / 2000; // if (!firstPoint) // { // // Distance to previous point // float dist = (float)Math.Sqrt(Math.Pow(posX - posXold, 2) + Math.Pow(posY - posYold, 2)); // if (dist > 0.1f) // Da točke na grafu ne budu preblizu // { // // Dodaj točku na graf // plotXvalue += dist; // if (points.Count > 100) points.RemoveAt(0); // points.Add(new OxyPlot.DataPoint(plotXvalue, lengthGaugeValue)); // //x_os.Maximum = points[points.Count - 1].X; // //x_os.Minimum = points[0].X; // graf.InvalidatePlot(); // posXold = posX; // posYold = posY; // } // } // else // { // // Nema starih točaka pa samo dodaj točku na graf (plotXvalue = 0.0f) // points.Add(new OxyPlot.DataPoint(plotXvalue, lengthGaugeValue)); // firstPoint = false; // graf.InvalidatePlot(); // posXold = posX; // posYold = posY; // } // //posXold = posX; // //posYold = posY; //} })); }
private void updatePage(object sender, PLCInterfaceEventArgs e) { //if ((bool)e.StatusData.RotacijskaOs.AutomaticActive.Value) //{ // points.Clear(); // rawPlotData = App.PLC.ReadCustom(60, 100, 4000); // DB60 LENGTH_GAUGE_DB // for (int i = 0; i < 2000; i++) // { // Int16 srh = (Int16)((rawPlotData[i * 2] << 8) | rawPlotData[i * 2 + 1]); // if (srh == -32768) // { // if (((i) < ((i / 100) + 1) * 100) && ((i - ((i / 100) * 100) > 10))) // { // double tempp = points[i - 1].Y; // points.Add(new DataPoint(i * 0.1, tempp)); // continue; // } // else // { // break; // } // } // points.Add(new DataPoint(i*0.1, (float)srh/2.0f)); // } //// points.Add(new DataPoint(points[points.Count - 1].X,points[points.Count - 1].Y)); // Dispatcher.BeginInvoke(new Action(() => // { // burrDetection.Position = OdabirLimovaKontrola.LineNumber; // position number // })); // burrDetection.BurrData = points; // setting this parameter will calculate burr data // Dispatcher.BeginInvoke(new Action(() => // { // graf.InvalidatePlot(true); // l_maxSrh.Content = burrDetection.MaxBurr.ToString(); // l_postotak.Content = burrDetection.BurrPercent.ToString(); // // Za izvještaj // App.MainReportInterface.BurrList.Clear(); // if (burrDetection.BurrList != null) // { // App.MainReportInterface.BurrList.AddRange(burrDetection.BurrList); // } // dataGrid1.Items.Refresh(); // App.pIzvjestaji.dataGridSrh.Items.Refresh(); // App.MainReportInterface.Srh_max = burrDetection.MaxBurr; // App.MainReportInterface.Srh_postotak = burrDetection.BurrPercent; // App.MainReportInterface.Srh_pozicija = OdabirLimovaKontrola.LineNumber; // App.MainReportInterface.Srh_brojUzoraka = NumberOfMeas; // })); //} Dispatcher.BeginInvoke(new Action(() => { //if (((bool)e.ControlData.VertikalnaOs.SimpleBurrMeas.Value == true) && (p_novoMjerenje.Content != "STOP")) //{ // p_novoMjerenje.Foreground = Brushes.Red; // p_novoMjerenje.Content = "STOP"; //} //else if (((bool)e.ControlData.VertikalnaOs.SimpleBurrMeas.Value == false) && (p_novoMjerenje.Foreground != Brushes.Black)) //{ // if (p_novoMjerenje.Content == "STOP") // { // if (burrDetection.BurrList == null) // burrDetection.BurrList = new List<BurrLine>(); // burrDetection.BurrList.Add(new BurrLine(0, OdabirLimovaKontrola.LineNumber, burrDetection.DetectOne(points))); // burrDetection.BurrList = burrDetection.BurrList; // App.MainReportInterface.BurrList.Clear(); // if (burrDetection.BurrList != null) // { // App.MainReportInterface.BurrList.AddRange(burrDetection.BurrList); // } // dataGrid1.Items.Refresh(); // App.pIzvjestaji.dataGridSrh.Items.Refresh(); // App.MainReportInterface.Srh_max = burrDetection.MaxBurr; // App.MainReportInterface.Srh_postotak = burrDetection.BurrPercent; // App.MainReportInterface.Srh_pozicija = OdabirLimovaKontrola.LineNumber; // App.MainReportInterface.Srh_brojUzoraka = NumberOfMeas; // } // p_novoMjerenje.Content = "POKRENI JEDNOKRATNO\n MJERENJE"; // p_novoMjerenje.Foreground = Brushes.Black; //} })); }
private void updatePagePRucno_1s(object sender, PLCInterfaceEventArgs e) { }
private void updatePage1234(object sender, PLCInterfaceEventArgs e) { }