Compare commits

..

6 Commits

6 changed files with 73 additions and 32 deletions

View File

@ -34,7 +34,7 @@
//
// btnStopLaneIn
//
this.btnStopLaneIn.Location = new System.Drawing.Point(1221, 88);
this.btnStopLaneIn.Location = new System.Drawing.Point(1205, 408);
this.btnStopLaneIn.Name = "btnStopLaneIn";
this.btnStopLaneIn.Size = new System.Drawing.Size(75, 23);
this.btnStopLaneIn.TabIndex = 0;
@ -44,7 +44,7 @@
//
// btnStartLaneIn
//
this.btnStartLaneIn.Location = new System.Drawing.Point(1221, 129);
this.btnStartLaneIn.Location = new System.Drawing.Point(1205, 449);
this.btnStartLaneIn.Name = "btnStartLaneIn";
this.btnStartLaneIn.Size = new System.Drawing.Size(75, 23);
this.btnStartLaneIn.TabIndex = 0;

View File

@ -1,4 +1,5 @@
using System.Windows.Forms;
using System;
using System.Windows.Forms;
namespace AIParkingApplication
{
@ -9,6 +10,9 @@ namespace AIParkingApplication
private IDoorControlAccess c3Device;
private LaneIn laneIn;
private LaneOut laneOut;
private StatusBar statusBar;
private Statistic statistic;
public AIParkingApplicationForm()
{
@ -23,10 +27,19 @@ namespace AIParkingApplication
laneOut.Location = new System.Drawing.Point(450, 0);
Controls.Add(laneOut);
statusBar = new StatusBar("192.168.1.122", "192.168.1.200", TimeSpan.FromSeconds(1));
statusBar.Location = new System.Drawing.Point(0, 692);
statusBar.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
Controls.Add(statusBar);
statistic = new Statistic(apiController, TimeSpan.FromMinutes(10));
statistic.Location = new System.Drawing.Point(laneIn.Width + laneOut.Width + 10, 0);
statistic.Anchor = AnchorStyles.Top | AnchorStyles.Left;
Controls.Add(statistic);
StartLanes();
}
private void btnStopLaneIn_Click(object sender, System.EventArgs e)
private void btnStopLaneIn_Click(object sender, EventArgs e)
{
laneIn.Stop();
laneOut.Stop();
@ -38,7 +51,7 @@ namespace AIParkingApplication
laneOut.Start();
}
private void btnStartLaneIn_Click(object sender, System.EventArgs e)
private void btnStartLaneIn_Click(object sender, EventArgs e)
{
StartLanes();
}

View File

@ -85,9 +85,11 @@ namespace AIParkingApplication
pictureBoxOverviewImage.UpdateImage(overviewVideoFrame.ToBitmap());
var cardInformation = await apiController.GetCardInformation(cardNumber);
ShowCardInfoOnUI(cardNumber, result.PlateString, cardInformation.CardType, DateTime.Now.GetTimeFormatted());
var saveLogResult = await apiController.SaveLog(LaneDirection.In, cardInformation.CardRealID.ToString(), "1", result.PlateType, DateTime.Now.GetTimeFormatted(), result.PlateString, result.PlateImage, result.PlateImage, result.PlateImage, overviewVideoFrame);
ShowCardInfoOnUI(cardNumber, result.PlateString, cardInformation.CardType, DateTime.Now.GetTimeFormatted());
if (saveLogResult.Status)
{
if (isAutoOpenDoor && this.doorId == doorId)

View File

@ -1,10 +1,10 @@
using OpenCvSharp;
using OpenCvSharp.Extensions;
using System;
using System;
using System.Drawing;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using OpenCvSharp;
using OpenCvSharp.Extensions;
namespace AIParkingApplication
{
@ -95,7 +95,7 @@ namespace AIParkingApplication
var saveLogResult = await apiController.SaveLog(LaneDirection.Out, cardInformation.CardRealID.ToString(), "1", result.PlateType, DateTime.Now.GetTimeFormatted(), result.PlateString, result.PlateImage, result.PlateImage, result.PlateImage, overviewVideoFrame, cardInformation.LogID.ToString());
ShowCardInfoOnUI(cardNumber, result.PlateString, cardInformation.CardType, cardInformation.TimeIn, DateTime.Now.GetTimeFormatted(), saveLogResult.Cost);
ShowCardInfoOnUI(cardNumber, result.PlateString, cardInformation.PlateString, cardInformation.CardType, cardInformation.TimeIn, DateTime.Now.GetTimeFormatted(), saveLogResult.Cost);
if (saveLogResult.Status)
{
@ -180,10 +180,10 @@ namespace AIParkingApplication
overviewCamera.Start();
}
private void ShowCardInfoOnUI(string cardNumber, string plateString, string cardType, string cardTimeIn, string cardTimeOut, string money)
private void ShowCardInfoOnUI(string cardNumber, string plateStringEngine, string plateInString, string cardType, string cardTimeIn, string cardTimeOut, string money)
{
lblCardNumber.UpdateLabel($"Số thẻ: {cardNumber}");
lblPlateString.UpdateLabel($"Biển số: {plateString}");
lblPlateString.UpdateLabel($"Biển số: {plateStringEngine}");
lblCardType.UpdateLabel($"Loại thẻ: {cardType}");
lblCardTime.UpdateLabel($"Vào: {cardTimeIn}");
lblCardTimeOut.UpdateLabel($"Ra: {cardTimeOut}");
@ -191,7 +191,21 @@ namespace AIParkingApplication
int.TryParse(money, out int moneyAmount);
lblMoneyAmount.UpdateLabel($"Số tiền: {string.Format("{0:n0}", moneyAmount)} vnđ");
lblStatusInfo.UpdateLabel(string.IsNullOrEmpty(plateString) ? "KHÔNG NHẬN DIỆN ĐƯỢC BIỂN SỐ" : $"MỜI XE {plateString} QUA", string.IsNullOrEmpty(plateString) ? Color.Red : Color.Green);
if (string.IsNullOrEmpty(plateStringEngine))
{
lblStatusInfo.UpdateLabel("KHÔNG NHẬN DIỆN ĐƯỢC BIỂN SỐ", Color.Red);
}
else
{
if (plateStringEngine != plateInString)
{
lblStatusInfo.UpdateLabel("SO KHỚP BIỂN SỐ KHÔNG CHÍNH XÁC", Color.Red);
}
else
{
lblStatusInfo.UpdateLabel($"MỜI XE {plateStringEngine} QUA", Color.Red);
}
}
}
private void OverviewCameraOnVideoFrameReceived(Mat videoFrame)

View File

@ -45,6 +45,8 @@
//
// grbVehicleStatistics
//
this.grbVehicleStatistics.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.grbVehicleStatistics.Controls.Add(this.label4);
this.grbVehicleStatistics.Controls.Add(this.label3);
this.grbVehicleStatistics.Controls.Add(this.lblVehicleTotalOut);
@ -53,7 +55,7 @@
this.grbVehicleStatistics.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.grbVehicleStatistics.Location = new System.Drawing.Point(1, 1);
this.grbVehicleStatistics.Name = "grbVehicleStatistics";
this.grbVehicleStatistics.Size = new System.Drawing.Size(290, 189);
this.grbVehicleStatistics.Size = new System.Drawing.Size(191, 178);
this.grbVehicleStatistics.TabIndex = 0;
this.grbVehicleStatistics.TabStop = false;
this.grbVehicleStatistics.Text = "Thống kê xe";
@ -61,7 +63,7 @@
// label4
//
this.label4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.label4.Location = new System.Drawing.Point(183, 133);
this.label4.Location = new System.Drawing.Point(112, 125);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(60, 20);
this.label4.TabIndex = 2;
@ -71,7 +73,7 @@
// label3
//
this.label3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.label3.Location = new System.Drawing.Point(42, 133);
this.label3.Location = new System.Drawing.Point(21, 125);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(60, 20);
this.label3.TabIndex = 2;
@ -82,7 +84,7 @@
//
this.lblVehicleTotalOut.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblVehicleTotalOut.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblVehicleTotalOut.Location = new System.Drawing.Point(183, 161);
this.lblVehicleTotalOut.Location = new System.Drawing.Point(112, 153);
this.lblVehicleTotalOut.Name = "lblVehicleTotalOut";
this.lblVehicleTotalOut.Size = new System.Drawing.Size(60, 20);
this.lblVehicleTotalOut.TabIndex = 1;
@ -93,7 +95,7 @@
//
this.lblVehicleTotalIn.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblVehicleTotalIn.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblVehicleTotalIn.Location = new System.Drawing.Point(42, 161);
this.lblVehicleTotalIn.Location = new System.Drawing.Point(21, 153);
this.lblVehicleTotalIn.Name = "lblVehicleTotalIn";
this.lblVehicleTotalIn.Size = new System.Drawing.Size(60, 20);
this.lblVehicleTotalIn.TabIndex = 1;
@ -102,6 +104,8 @@
//
// tlpStatisticTable
//
this.tlpStatisticTable.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tlpStatisticTable.ColumnCount = 2;
this.tlpStatisticTable.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
this.tlpStatisticTable.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
@ -111,11 +115,13 @@
this.tlpStatisticTable.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F));
this.tlpStatisticTable.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F));
this.tlpStatisticTable.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F));
this.tlpStatisticTable.Size = new System.Drawing.Size(278, 100);
this.tlpStatisticTable.Size = new System.Drawing.Size(180, 100);
this.tlpStatisticTable.TabIndex = 0;
//
// grbLoginInfo
//
this.grbLoginInfo.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.grbLoginInfo.Controls.Add(this.lblAuthorization);
this.grbLoginInfo.Controls.Add(this.lblUsername);
this.grbLoginInfo.Controls.Add(this.label2);
@ -123,10 +129,10 @@
this.grbLoginInfo.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.grbLoginInfo.Location = new System.Drawing.Point(1, 198);
this.grbLoginInfo.Name = "grbLoginInfo";
this.grbLoginInfo.Size = new System.Drawing.Size(290, 93);
this.grbLoginInfo.Size = new System.Drawing.Size(191, 93);
this.grbLoginInfo.TabIndex = 1;
this.grbLoginInfo.TabStop = false;
this.grbLoginInfo.Text = "Thông tin đăng nhập";
this.grbLoginInfo.Text = "Thông tin tài khoản";
//
// lblAuthorization
//
@ -134,9 +140,9 @@
this.lblAuthorization.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblAuthorization.Location = new System.Drawing.Point(109, 60);
this.lblAuthorization.Name = "lblAuthorization";
this.lblAuthorization.Size = new System.Drawing.Size(127, 18);
this.lblAuthorization.Size = new System.Drawing.Size(56, 18);
this.lblAuthorization.TabIndex = 0;
this.lblAuthorization.Text = "Nhân Viên Bảo Vệ";
this.lblAuthorization.Text = "Bảo Vệ";
//
// lblUsername
//
@ -154,9 +160,9 @@
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label2.Location = new System.Drawing.Point(16, 60);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(85, 18);
this.label2.Size = new System.Drawing.Size(89, 18);
this.label2.TabIndex = 0;
this.label2.Text = "Phân quyền";
this.label2.Text = "Phân quyền:";
//
// label1
//
@ -164,9 +170,9 @@
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.Location = new System.Drawing.Point(16, 27);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(73, 18);
this.label1.Size = new System.Drawing.Size(77, 18);
this.label1.TabIndex = 0;
this.label1.Text = "Tài khoản";
this.label1.Text = "Tài khoản:";
//
// Statistic
//
@ -175,7 +181,7 @@
this.Controls.Add(this.grbLoginInfo);
this.Controls.Add(this.grbVehicleStatistics);
this.Name = "Statistic";
this.Size = new System.Drawing.Size(292, 292);
this.Size = new System.Drawing.Size(193, 292);
this.Load += new System.EventHandler(this.Statistic_Load);
this.grbVehicleStatistics.ResumeLayout(false);
this.grbLoginInfo.ResumeLayout(false);

View File

@ -10,7 +10,7 @@ namespace AIParkingApplication
private readonly Thread thrStatistics;
private readonly TimeSpan updateInterval;
private ParkInfo parkInfo;
private string baseAddress;
private ApiController apiController;
private Label lblLoaiXe;
private Label lblXeMay;
@ -19,10 +19,10 @@ namespace AIParkingApplication
private Label lblSoLuongXeMay;
private Label lblSoLuongOto;
public Statistic(string baseAddress, TimeSpan updateInterval)
public Statistic(ApiController apiController, TimeSpan updateInterval)
{
InitializeComponent();
this.baseAddress = baseAddress;
this.apiController = apiController;
this.updateInterval = updateInterval;
thrStatistics = new Thread(new ThreadStart(GetStatistic)) { IsBackground = true };
thrStatistics.Start();
@ -40,7 +40,6 @@ namespace AIParkingApplication
async void GetDataFromServer()
{
ApiController apiController = new ApiController(this.baseAddress);
parkInfo = await apiController.GetStatisticInfo();
}
@ -69,6 +68,13 @@ namespace AIParkingApplication
lblSoLuongXeMay = new Label() { Text = "0", Font = labelFont };
lblSoLuongOto = new Label() { Text = "0", Font = labelFont };
lblLoaiXe.Anchor = AnchorStyles.None;
lblXeMay.Anchor = AnchorStyles.None;
lblOto.Anchor = AnchorStyles.None;
lblSoLuong.Anchor = AnchorStyles.None;
lblSoLuongXeMay.Anchor = AnchorStyles.None;
lblSoLuongOto.Anchor = AnchorStyles.None;
tlpStatisticTable.Controls.Add(lblLoaiXe, 0, 0);
tlpStatisticTable.Controls.Add(lblXeMay, 0, 1);
tlpStatisticTable.Controls.Add(lblOto, 0, 2);