Compare commits

...

5 Commits

5 changed files with 66 additions and 30 deletions

View File

@ -87,6 +87,7 @@
<HintPath>..\packages\OpenCvSharp4.4.3.0.20200524\lib\net461\OpenCvSharp.Extensions.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Net.Http.Formatting, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.7\lib\net45\System.Net.Http.Formatting.dll</HintPath>

View File

@ -62,28 +62,28 @@
// toolStripMenuItemSwitchLaneInIn
//
this.toolStripMenuItemSwitchLaneInIn.Name = "toolStripMenuItemSwitchLaneInIn";
this.toolStripMenuItemSwitchLaneInIn.Size = new System.Drawing.Size(180, 22);
this.toolStripMenuItemSwitchLaneInIn.Size = new System.Drawing.Size(123, 22);
this.toolStripMenuItemSwitchLaneInIn.Text = "Vào - Vào";
this.toolStripMenuItemSwitchLaneInIn.Click += new System.EventHandler(this.toolStripMenuItemSwitchLaneInIn_Click);
//
// toolStripMenuItemSwitchLaneInOut
//
this.toolStripMenuItemSwitchLaneInOut.Name = "toolStripMenuItemSwitchLaneInOut";
this.toolStripMenuItemSwitchLaneInOut.Size = new System.Drawing.Size(180, 22);
this.toolStripMenuItemSwitchLaneInOut.Size = new System.Drawing.Size(123, 22);
this.toolStripMenuItemSwitchLaneInOut.Text = "Vào - Ra";
this.toolStripMenuItemSwitchLaneInOut.Click += new System.EventHandler(this.toolStripMenuItemSwitchLaneInOut_Click);
//
// toolStripMenuItemSwitchLaneOutOut
//
this.toolStripMenuItemSwitchLaneOutOut.Name = "toolStripMenuItemSwitchLaneOutOut";
this.toolStripMenuItemSwitchLaneOutOut.Size = new System.Drawing.Size(180, 22);
this.toolStripMenuItemSwitchLaneOutOut.Size = new System.Drawing.Size(123, 22);
this.toolStripMenuItemSwitchLaneOutOut.Text = "Ra - Ra";
this.toolStripMenuItemSwitchLaneOutOut.Click += new System.EventHandler(this.toolStripMenuItemSwitchLaneOutOut_Click);
//
// toolStripMenuItemSwitchLaneOutIn
//
this.toolStripMenuItemSwitchLaneOutIn.Name = "toolStripMenuItemSwitchLaneOutIn";
this.toolStripMenuItemSwitchLaneOutIn.Size = new System.Drawing.Size(180, 22);
this.toolStripMenuItemSwitchLaneOutIn.Size = new System.Drawing.Size(123, 22);
this.toolStripMenuItemSwitchLaneOutIn.Text = "Ra - Vào";
this.toolStripMenuItemSwitchLaneOutIn.Click += new System.EventHandler(this.toolStripMenuItemSwitchLaneOutIn_Click);
//
@ -100,6 +100,7 @@
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "AIParking - Phần mềm quản lý bãi đỗ xe";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.AIParkingApplicationForm_FormClosing);
this.Load += new System.EventHandler(this.AIParkingApplicationForm_Load);
this.menuStrip.ResumeLayout(false);
this.menuStrip.PerformLayout();
this.ResumeLayout(false);

View File

@ -1,4 +1,5 @@
using System;
using System.Configuration;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
@ -17,21 +18,33 @@ namespace AIParkingApplication
private Sidebar sidebar;
private Config configOnWeb;
private EngineApiController engineApiController;
private string doorAccessControlDeviceIP;
public AIParkingApplicationForm(ApiController apiController, Config configOnWeb)
{
InitializeComponent();
this.apiController = apiController;
this.configOnWeb = configOnWeb;
c3Device = new C3DeviceController("192.168.1.200");
sidebar = new Sidebar(apiController);
sidebar.Location = new Point(0, 0);
ReadAccessControlDeviceIPConfiguration();
if (string.IsNullOrEmpty(doorAccessControlDeviceIP))
{
MessageBox.Show("Kiểm tra lại cấu hình IP thiết bị mở cửa! (C3200)", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit();
}
c3Device = new C3DeviceController(doorAccessControlDeviceIP);
sidebar = new Sidebar(apiController)
{
Location = new Point(0, 0)
};
Controls.Add(sidebar);
statusBar = new StatusBar("192.168.1.122", "192.168.1.200", TimeSpan.FromSeconds(1));
statusBar.Location = new Point(0, sidebar.Location.Y + sidebar.Height + 26);
statusBar.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
statusBar = new StatusBar("192.168.1.122", doorAccessControlDeviceIP, TimeSpan.FromSeconds(1))
{
Location = new Point(0, sidebar.Location.Y + sidebar.Height + 26),
Anchor = AnchorStyles.Bottom | AnchorStyles.Left
};
Controls.Add(statusBar);
try
@ -44,7 +57,7 @@ namespace AIParkingApplication
return;
}
InitAllLanes();
}
private void InitAllLanes()
@ -185,9 +198,27 @@ namespace AIParkingApplication
laneOut78?.Hide();
}
private void ReadAccessControlDeviceIPConfiguration()
{
try
{
doorAccessControlDeviceIP = ConfigurationManager.AppSettings["DOOR_ACCESS_DEVICE_CONTROL_IP"].Trim();
}
catch (Exception ex)
{
Console.WriteLine($"{DateTime.Now.GetTimeFormatted()}\tReadAccessControlDeviceIPConfiguration\t{ex.Message}");
doorAccessControlDeviceIP = string.Empty;
}
}
private void AIParkingApplicationForm_FormClosing(object sender, FormClosingEventArgs e)
{
Application.Exit();
}
private void AIParkingApplicationForm_Load(object sender, EventArgs e)
{
InitAllLanes();
}
}
}

View File

@ -18,7 +18,7 @@ namespace AIParkingApplication
httpClient = new HttpClient
{
BaseAddress = new Uri(baseAddress),
Timeout = TimeSpan.FromSeconds(1)
Timeout = TimeSpan.FromSeconds(5)
};
isHttpClientDisposabled = false;
}
@ -70,7 +70,7 @@ namespace AIParkingApplication
catch (Exception ex)
{
Console.WriteLine($"GetStatisticInfo Exception:\t{DateTime.Now.GetTimeFormatted()} \t {ex.Message}");
return new Statistic.ParkInfo();
return null;
}
}
@ -87,12 +87,12 @@ namespace AIParkingApplication
do
{
response = await httpClient.PostAsJsonAsync("/api/check-card", request);
response.EnsureSuccessStatusCode();
requestCounter += 1;
await Task.Delay(100);
}
while (response.StatusCode != HttpStatusCode.OK && requestCounter < MAX_REQUEST);
response.EnsureSuccessStatusCode();
var cardValication = await response.Content.ReadAsAsync<CardInformation>();
return cardValication;
}
@ -108,8 +108,8 @@ namespace AIParkingApplication
{
string plateImageBase64 = Convert.ToBase64String(plateImage.ToBytes());
string plateImageResultBase64 = Convert.ToBase64String(plateImageResult.ToBytes());
string PlateFrameImageBase64 = Convert.ToBase64String(plateFrameImage.ToBytes());
string FrameImageBase64 = Convert.ToBase64String(frameImage.ToBytes());
string plateFrameImageBase64 = Convert.ToBase64String(plateFrameImage.ToBytes());
string frameImageBase64 = Convert.ToBase64String(frameImage.ToBytes());
try
{
var request = new SaveLogModel
@ -123,18 +123,18 @@ namespace AIParkingApplication
Timestamp = timestamp,
PlateImage = plateImageBase64,
PlateResultImage = plateImageResultBase64,
PlateFrameImage = PlateFrameImageBase64,
FrameImage = FrameImageBase64
PlateFrameImage = plateFrameImageBase64,
FrameImage = frameImageBase64
};
HttpResponseMessage response;
int requestCounter = 1;
do
{
response = await httpClient.PostAsJsonAsync("/api/save-logs", request);
response.EnsureSuccessStatusCode();
requestCounter += 1;
await Task.Delay(100);
} while (response.StatusCode != HttpStatusCode.OK && requestCounter < MAX_REQUEST);
response.EnsureSuccessStatusCode();
SaveLogRespone saveLogRespone = await response.Content.ReadAsAsync<SaveLogRespone>();
return saveLogRespone;
}

View File

@ -1,14 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<appSettings>
<add key="DOOR_ACCESS_DEVICE_CONTROL_IP" value="192.168.1.200" />
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>