private void StopYarp() { if (senderYarp != null) { senderYarp.Abort(); } if (yarpPort != null) { yarpPort.Close(); } }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { #region Thred or timer if (decodingThread != null) { decodingThread.Abort(); } if (senderThread != null) { senderThread.Abort(); } if (checkYarpStatusTimer != null) { checkYarpStatusTimer.Elapsed -= new ElapsedEventHandler(CheckYarpConnections); checkYarpStatusTimer.Stop(); } if (videoStream != null) { videoStream.NewFrame -= new NewFrameEventHandler(videoSource_NewFrame); videoStream.Stop(); } #endregion #region Port if (yarpPortScene != null) { yarpPortScene.Close(); } if (yarpPortCommandDB != null) { yarpPortCommandDB.Close(); } if (yarpPortReplyDB != null) { yarpPortReplyDB.Close(); } if (yarpPortStatusDB != null) { yarpPortStatusDB.Close(); } #endregion }
private void Window_Closed(object sender, EventArgs e) { yarpPort.Close(); }
RecognizedQRCode getInformationDB(Dictionary <string, ZXing.ResultPoint[]> dict) { RecognizedQRCode rec = new RecognizedQRCode(); rec.ResolutionCam = new ResolutionCam(); rec.ResolutionCam.Width = w.ToString(); rec.ResolutionCam.Height = h.ToString(); foreach (var s in dict) { //preparo l'informazione del soggetto con la posizione centrale del QRCode InfoQRCode inf = new InfoQRCode(); inf.Positions = new List <Pos>(); foreach (var v in s.Value) { Pos p = new Pos(); p.X = v.X.ToString(); p.Y = v.Y.ToString(); inf.Positions.Add(p); } // verifico se già conosco il soggetto altrimenti interogo il database List <InfoQRCode> sub = SubjRecognition.InfoQRCode.FindAll(a => a.Message.Split('|')[1].Trim() == s.Key); if (sub.Count() == 0) { //leggo lo status del database se è occupato attendo string state = ""; do { yarpPortStatusDB.receivedData(out state); }while (state != "Activo"); //apro le connessioni con il db yarpPortCommandDB.openConnectionToDb(dataBaseCommand_OUT, dataBaseCommand_IN); yarpPortReplyDB.openReceiverReplyDb(dataBaseReply_OUT, dataBaseReply_IN); yarpPortCommandDB.sendData("SELECT * FROM subjects WHERE IdSubject=" + s.Key); System.Threading.Thread.Sleep(400); //attendo risposta string reply = ""; do { yarpPortReplyDB.receivedData(out reply); }while (reply == ""); //se non trovo nulla parte evento che gestire l'inserimento del nuovo soggetto if (reply.Replace("\"", "") == "|") { InputDialog.InputDialog dialog2 = new InputDialog.InputDialog("Assign ID and Name to ", "", ""); if (dialog2.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (dialog2.ResultText != "unknown") { yarpPortCommandDB.sendData("INSERT INTO subjects (IdSubject,Name,FirstTime) VALUE ('" + s.Key + "','" + dialog2.ResultText + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')"); System.Threading.Thread.Sleep(400); reply = ""; do { yarpPortReplyDB.receivedData(out reply); }while (reply == "" || reply == "\"|\""); inf.Message = "unknown"; } else { inf.Message = dialog2.ResultText; } } else { inf.Message = dialog2.ResultText; } } else { inf.Message = reply.Replace("\"", ""); } yarpPortCommandDB.Close(); yarpPortReplyDB.Close(); if (inf.Message != "unknown") { SubjRecognition.InfoQRCode.Add(inf); } } else { foreach (InfoQRCode info in sub) { if (info.Message[1] == s.Key[0]) { inf.Message = info.Message; } } } Sub.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate() { Sub.Content = inf.Message; })); rec.InfoQRCode.Add(inf); } return(rec); }