From ab14853d29a7d1a7d6881a7c46570201aa329c26 Mon Sep 17 00:00:00 2001 From: DucDangAnh Date: Mon, 29 Jun 2020 13:56:04 +0700 Subject: [PATCH] LaneIn - Check CardInfomation. --- AIParkingApplication/LaneIn.cs | 78 +++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 34 deletions(-) diff --git a/AIParkingApplication/LaneIn.cs b/AIParkingApplication/LaneIn.cs index 7a46070..2916962 100644 --- a/AIParkingApplication/LaneIn.cs +++ b/AIParkingApplication/LaneIn.cs @@ -63,53 +63,63 @@ namespace AIParkingApplication var cardInfoResult = await apiController.GetCardInformation(cardNumber); if (cardInfoResult.IsValid) { - plateCamera.RequestCaptureOneFrame(); - overviewCamera.RequestCaptureOneFrame(); - await Task.Delay(200); - var plateVideoFrame = plateCamera.CurrentFrame; - var overviewVideoFrame = overviewCamera.CurrentFrame; - - pictureBoxOverviewImage.Invoke(new Action(() => + if (cardInfoResult.Direction == "in") { - pictureBoxOverviewImage.Image?.Dispose(); - pictureBoxOverviewImage.Image = overviewVideoFrame.ToBitmap(); - })); + plateCamera.RequestCaptureOneFrame(); + overviewCamera.RequestCaptureOneFrame(); + await Task.Delay(200); + var plateVideoFrame = plateCamera.CurrentFrame; + var overviewVideoFrame = overviewCamera.CurrentFrame; - FinalPlateResult result = await ProcessFrameImage(plateProcessor, plateVideoFrame, isRetryMode); - - pictureBoxPlateImage.Invoke(new Action(() => - { - pictureBoxPlateImage.Image?.Dispose(); - pictureBoxPlateImage.Image = result.PlateImage.ToBitmap(); - })); - - var cardInformation = await apiController.GetCardInformation(cardNumber); - - ShowCardInfoOnUI(cardNumber, result.PlateString, cardInformation.CardType, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT)); - - //TODO check saveLogResult - var saveLogResult = await apiController.SaveLog(LaneDirection.In, cardInformation.CardRealID.ToString(), "1", result.PlateType, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), result.PlateString, result.PlateImage, result.PlateImage, result.PlateImage, overviewVideoFrame); - if (saveLogResult.Status) - { - if (isAutoOpenDoor && this.doorId == doorId) + pictureBoxOverviewImage.Invoke(new Action(() => { - var openDoorResult = c3Device.OpenDoor(doorId); - if (openDoorResult.HasError) + pictureBoxOverviewImage.Image?.Dispose(); + pictureBoxOverviewImage.Image = overviewVideoFrame.ToBitmap(); + })); + + FinalPlateResult result = await ProcessFrameImage(plateProcessor, plateVideoFrame, isRetryMode); + + pictureBoxPlateImage.Invoke(new Action(() => + { + pictureBoxPlateImage.Image?.Dispose(); + pictureBoxPlateImage.Image = result.PlateImage.ToBitmap(); + })); + + var cardInformation = await apiController.GetCardInformation(cardNumber); + + ShowCardInfoOnUI(cardNumber, result.PlateString, cardInformation.CardType, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT)); + + var saveLogResult = await apiController.SaveLog(LaneDirection.In, cardInformation.CardRealID.ToString(), "1", result.PlateType, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), result.PlateString, result.PlateImage, result.PlateImage, result.PlateImage, overviewVideoFrame); + if (saveLogResult.Status) + { + if (isAutoOpenDoor && this.doorId == doorId) { - lblRecogizePlateStatus.Invoke(new Action(() => + var openDoorResult = c3Device.OpenDoor(doorId); + if (openDoorResult.HasError) { - lblRecogizePlateStatus.BackColor = Color.Red; - lblRecogizePlateStatus.Text = "KHÔNG THỂ MỞ CỬA"; - })); + lblRecogizePlateStatus.Invoke(new Action(() => + { + lblRecogizePlateStatus.BackColor = Color.Red; + lblRecogizePlateStatus.Text = "KHÔNG THỂ MỞ CỬA"; + })); + } } } + else + { + lblRecogizePlateStatus.Invoke(new Action(() => + { + lblRecogizePlateStatus.BackColor = Color.Red; + lblRecogizePlateStatus.Text = "KHÔNG THỂ KẾT NỐI ĐẾN MÁY CHỦ"; + })); + } } else { lblRecogizePlateStatus.Invoke(new Action(() => { lblRecogizePlateStatus.BackColor = Color.Red; - lblRecogizePlateStatus.Text = "KHÔNG THỂ KẾT NỐI ĐẾN MÁY CHỦ"; + lblRecogizePlateStatus.Text = "XE ĐÃ Ở TRONG BÃI"; })); } }