From 19f9a4ed827ded827e269060ec611c6e04e63da1 Mon Sep 17 00:00:00 2001 From: DucDangAnh Date: Tue, 30 Jun 2020 10:58:25 +0700 Subject: [PATCH] LaneIn - Refactor C3Device_OnNewCardReceived --- AIParkingApplication/LaneIn.cs | 64 ++++++++++++++++------------------ 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/AIParkingApplication/LaneIn.cs b/AIParkingApplication/LaneIn.cs index d58c7b1..f7c9c91 100644 --- a/AIParkingApplication/LaneIn.cs +++ b/AIParkingApplication/LaneIn.cs @@ -57,45 +57,43 @@ namespace AIParkingApplication { ClearPlateAndOverviewImage(); var cardInfoResult = await apiController.GetCardInformation(cardNumber); - if (cardInfoResult.IsValid) + if (!cardInfoResult.IsValid) { - if (cardInfoResult.Direction == "in") + lblStatusInfo.UpdateLabel("THẺ KHÔNG HỢP LỆ", Color.Purple); + return; + } + + if (cardInfoResult.Direction != "in") + { + lblStatusInfo.UpdateLabel("THẺ ĐÃ ĐƯỢC SỬ DỤNG", Color.Red); + return; + } + + plateCamera.RequestCaptureOneFrame(); + overviewCamera.RequestCaptureOneFrame(); + await Task.Delay(200); + + var plateVideoFrame = plateCamera.CurrentFrame; + FinalPlateResult result = await ProcessFrameImage(plateProcessor, plateVideoFrame, isRetryMode); + pictureBoxPlateImage.UpdateImage(result.PlateImage.ToBitmap()); + + var overviewVideoFrame = overviewCamera.CurrentFrame; + pictureBoxOverviewImage.UpdateImage(overviewVideoFrame.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) { - plateCamera.RequestCaptureOneFrame(); - overviewCamera.RequestCaptureOneFrame(); - await Task.Delay(200); - - var plateVideoFrame = plateCamera.CurrentFrame; - FinalPlateResult result = await ProcessFrameImage(plateProcessor, plateVideoFrame, isRetryMode); - pictureBoxPlateImage.UpdateImage(result.PlateImage.ToBitmap()); - - var overviewVideoFrame = overviewCamera.CurrentFrame; - pictureBoxOverviewImage.UpdateImage(overviewVideoFrame.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) - { - OpenDoor(doorId); - } - } - else - { - lblStatusInfo.UpdateLabel("KHÔNG THỂ KẾT NỐI ĐẾN MÁY CHỦ", Color.Red); - } - } - else - { - lblStatusInfo.UpdateLabel("THẺ ĐÃ ĐƯỢC SỬ DỤNG", Color.Red); + OpenDoor(doorId); } } else { - lblStatusInfo.UpdateLabel("THẺ KHÔNG HỢP LỆ", Color.Purple); + lblStatusInfo.UpdateLabel("KHÔNG CÓ KẾT NỐI ĐẾN MÁY CHỦ", Color.Red); } }