//private void button8_Click(object sender, EventArgs e) //{ // Console.WriteLine("开始转换\n"); // ExcuteProcess("ffmpeg.exe", "-y -i 1.264 output.mp4", (s, ee) => Console.WriteLine(ee.Data)); // MessageBox.Show("ok"); //} /* * ExcuteProcess h264转MP4格式 * exe: 一个外部可执行程序mmjpeg * agr: 视频属性等一些输入数据 * output: 输出视频 */ private void timephotoing(object o) { Console.WriteLine("timephotoing"); try { while (isTimePictrue) { DateTime dt = DateTime.Now; String path = System.Windows.Forms.Application.StartupPath; //获取当前执行文件的文件目录 Console.WriteLine(path); string fileName = path + "\\time_capture\\"; fileName += dt.Year.ToString() + "-"; fileName += dt.Month.ToString() + "-"; fileName += dt.Day.ToString() + " "; // fileName += "-"; fileName += dt.Hour.ToString() + "-"; fileName += dt.Minute.ToString() + "-"; fileName += dt.Second.ToString() + ".jpg"; //照片属性已经获取了。 //下面数组的每一个元素的顺序不能乱,要和客户端的一致。 int[] pictureAttribute = { -10, caphour, capmin, Resolution, Whitebalance, Bright, Contrast, Saturation, Quanlity }; bool flag = false; flag = communicateToClient.gettimePicture(fileName, pictureAttribute); //可能接收图片失败 if (flag) { if (pb.Image != null) //先清除上一次的图片 { pb.Image.Dispose(); } pb.Image = Image.FromFile(fileName); Console.WriteLine("photoing finish\n"); Console.WriteLine(fileName); if (fileName != null) { Show(fileName); srcBitmap = (Bitmap)Bitmap.FromFile(fileName, true); } } } communicateToClient.stopTimePicture(); bt_stop_timecap.Visible = false; //不可见 } catch (SocketException ex) { DealwithSocketException dealEx = new DealwithSocketException(ex); MessageBox.Show(dealEx.errorMessage); if (ex.SocketErrorCode == SocketError.ConnectionAborted) { m_clientPoint.loseConnect = true; //和客户端失去了联系 } return; } finally { isBusy = false; } }
private void temping(object o) { String val = null; try { val = communicateToClient.getTemp(6); //设置一个60秒的最长等待时间 } catch (SocketException ex) { DealwithSocketException dealEx = new DealwithSocketException(ex); MessageBox.Show(dealEx.errorMessage); if (ex.SocketErrorCode == SocketError.ConnectionAborted) { m_clientPoint.loseConnect = true; //和客户端失去了联系 } return; } finally { // m_clientPoint.loseConnect = true; //和客户端失去了联系 isBusy = false; } // lb_temp.Text = "温度值为: " + val; }
private void watering(object o) { String val = null; try { val = communicateToClient.getWater(); } catch (SocketException ex) { DealwithSocketException dealEx = new DealwithSocketException(ex); MessageBox.Show(dealEx.errorMessage); if (ex.SocketErrorCode == SocketError.ConnectionAborted) { m_clientPoint.loseConnect = true; //和客户端失去了联系 } return; } finally { isBusy = false; } // lb_water.Text = "水分值为: " + val; }
private void videoing(object o) { Console.WriteLine("start videoing\n"); string fileName; bool flag = false; int value = -1; int[] config = null; string errno = String.Empty; bool state = true; communicateArmClient.Operate(OPERATE.MODIFY_STATE, DEVICE.VEDIO, ref state, ref value, ref config, ref errno); //if (m_h264FileBuff == null) // m_h264FileBuff = new VideoNameBuff(); //m_isTransformH264 = true; //ThreadPool.QueueUserWorkItem(new WaitCallback(transFromH264ToMp4), null); try { while (isVideoing) { DateTime dt = DateTime.Now; String path = System.Windows.Forms.Application.StartupPath; //获取当前执行文件的文件目录 Console.WriteLine(path); fileName = "video\\"; fileName += "video_"; //fileName += dt.Year.ToString() + "-"; //fileName += dt.Month.ToString() + "-"; //fileName += dt.Day.ToString() + "_"; //fileName += dt.Hour.ToString() + "-"; //fileName += dt.Minute.ToString() + "-"; //fileName += dt.Second.ToString() + "--"; //fileName += dt.Millisecond.ToString() + ".264"; fileName += ".264"; //m_comToClient 会自动加上10 int[] videoAttr = { -10, Resolution, Whitebalance, Bright, Contrast, Saturation }; flag = communicateArmClient.getVideo(fileName, videoAttr); //flag = communicateToClient.getVideo(fileName, videoAttr); //flag 为 false时表明接收图片失败。 //if (flag) //{ // m_h264FileBuff.pushFileName(fileName); //} } communicateToClient.stopVideo(); bt_stop_video.Visible = false; //不可见 } catch (SocketException ex) { DealwithSocketException dealEx = new DealwithSocketException(ex); MessageBox.Show(dealEx.errorMessage); if (ex.SocketErrorCode == SocketError.ConnectionAborted) { m_clientPoint.loseConnect = true; //和客户端失去了联系 } return; } finally { m_isTransformH264 = false; m_h264FileBuff.clear(); //清除残余文件 isBusy = false; } }
private void Photoing(object o) { DateTime dt = DateTime.Now; int[] pictureAttribute = new int[6]; pictureAttribute[0] = Resolution; pictureAttribute[1] = Whitebalance; pictureAttribute[2] = Bright; pictureAttribute[3] = Saturation; pictureAttribute[4] = Contrast; pictureAttribute[5] = Quanlity; string savePath = imageSavePath + "\\capture\\"; string fileName = dt.Year.ToString() + "-"; fileName += dt.Month.ToString() + "-"; fileName += dt.Day.ToString() + " _"; fileName += dt.Hour.ToString() + "-"; fileName += dt.Minute.ToString() + "-"; fileName += dt.Second.ToString() + ".jpg"; string fileFullPath = savePath + fileName; ThreadPool.QueueUserWorkItem(new WaitCallback(OperateImageCapture), pictureAttribute); bool flag = false; try { flag = communicateArmClient.GetPicture(fileFullPath, pictureAttribute); } catch (SocketException ex) { DealwithSocketException dealEx = new DealwithSocketException(ex); MessageBox.Show(dealEx.errorMessage); if (ex.SocketErrorCode == SocketError.ConnectionAborted) { armClient.IsLoseConnect = true; } return; } finally { isBusy = false; } if (flag) { if (pb.Image != null) //先清除上一次的图片 { pb.Image.Dispose(); } pb.Image = Image.FromFile(fileFullPath); if (fileFullPath != null) { //Show(fileFullPath); //srcBitmap = (Bitmap)Bitmap.FromFile(fileFullPath, true); ImageBLL imageBll = new ImageBLL(); ImageData imageData = new ImageData(); imageData.nodeid = nodeData.id; imageData.datetime = DateTime.Now; imageData.path = savePath; imageData.fullpath = fileFullPath; imageData.fileName = fileName; imageData.status = 1; if (imageBll.Insert(imageData)) { ShowControlWarnInMessageBox(true, "插入图像记录成功"); } else { ShowControlWarnInMessageBox(false, "插入图像记录失败"); } } } }