public void Send() { try { TakePictureControlMultiCamera takePicture = new TakePictureControlMultiCamera(); //如果是上一张是第一张照片 if (task.IsFirstPhoto) { task.IsFirstPhoto = false; task.CurrentCameraIndex = 0; } else { if (task.CurrentCameraIndex < task.CameraIds.Length-1) { task.CurrentCameraIndex++; } else { task.CurrentCameraIndex = 0; } } takePicture.CameraIds = task.CameraIds[task.CurrentCameraIndex].ToString(); takePicture.SerialNumber = Guid.NewGuid().ToString(); takePicture.GPSCode = task.GPSCode; takePicture.Data.ShootType = SimpleCmdType.TakePictureForDoorShot; takePicture.Data.CameraIdsLen = (byte)Encoding.Default.GetBytes(takePicture.CameraIds).Length; takePicture.Data.SerialNumberLen = (byte)Encoding.Default.GetBytes(takePicture.SerialNumber).Length; takePicture.Data.GPSCodeLen = (byte)Encoding.Default.GetBytes(takePicture.GPSCode).Length; Util.Common.LogFatal(string.Format("发送开门拍照指令,GPSCode:{0};CameraID:{1}",takePicture.GPSCode, takePicture.CameraIds)); byte[] dataBuffer = new byte[takePicture.GetLength()]; takePicture.WriteBuffer(0, dataBuffer); CmdData cmdData = new CmdData(); cmdData.Data.Cmd = ControlCmdType.SendTakePictureMultiCamera; cmdData.DataBuffer = dataBuffer; cmdData.Data.DataLen = (ushort)dataBuffer.Length; byte[] destBuffer = new byte[cmdData.GetLenth()]; cmdData.WriteBuffer(0, destBuffer); System.Net.IPEndPoint remoteGateway = Util.Common.GetGPSGatewayRouter(task.GPSCode); if (null == remoteGateway) { Logger.Info(string.Format("获取不到{0}的IP端口.", task.GPSCode)); return; } gwClient.Connect(remoteGateway); gwClient.Send(destBuffer, destBuffer.Length); Util.Common.LogFatal(string.Format("SendPhotographCmd gpscode:{0},vehicleCode:{1},CameraID:{2}", task.GPSCode, task.VehicleCode, task.CameraIds[task.CurrentCameraIndex])); } catch (System.Exception ex) { PES.Beehive.Logging.Logger.Fatal(ex); PES.Beehive.Logging.Logger.Error(ex); } }
/// <summary> /// 多摄像头拍照 /// </summary> /// <param name="eventIndex"></param> /// <returns></returns> private byte[] TakePicture(int eventIndex) { TakePictureControlMultiCamera takePicture = new TakePictureControlMultiCamera(); takePicture.CameraIds = this.txtParam2.Text.Trim(); takePicture.Data.GpsType = GPSType.BoShiJie; takePicture.SerialNumber = Guid.NewGuid().ToString(); takePicture.GPSCode = txtGpsCode.Text.Trim(); takePicture.Data.GPSCodeLen = (byte)Encoding.Default.GetBytes(takePicture.GPSCode).Length; takePicture.Data.CameraIdsLen = (byte)Encoding.Default.GetBytes(takePicture.CameraIds).Length; takePicture.Data.SerialNumberLen = (byte)Encoding.Default.GetBytes(takePicture.SerialNumber).Length; takePicture.Data.IsGpsAckMsg = true; switch (eventIndex) { //实时抓拍 case 5: takePicture.Data.ShootType = SimpleCmdType.RealTimeShoot; break; //正常连拍 case 6: takePicture.Data.ShootType = SimpleCmdType.NormalSeriateShoot; takePicture.Data.TurnsCount = Convert.ToUInt16(this.txtParam1.Text.Trim()); break; } byte[] dataBuffer = new byte[takePicture.GetLength()]; takePicture.WriteBuffer(0, dataBuffer); CmdData cmdData = new CmdData(); cmdData.Data.Cmd = ControlCmdType.SendTakePictureMultiCamera; cmdData.DataBuffer = dataBuffer; cmdData.Data.DataLen = (ushort)dataBuffer.Length; byte[] destBuffer = new byte[cmdData.GetLenth()]; cmdData.WriteBuffer(0, destBuffer); return destBuffer; }