diff --git a/AIParkingApplication/AIParkingApplicationForm.Designer.cs b/AIParkingApplication/AIParkingApplicationForm.Designer.cs index 72cabd2..7738f8c 100644 --- a/AIParkingApplication/AIParkingApplicationForm.Designer.cs +++ b/AIParkingApplication/AIParkingApplicationForm.Designer.cs @@ -71,18 +71,21 @@ this.toolStripMenuItemSwitchLaneInOut.Name = "toolStripMenuItemSwitchLaneInOut"; this.toolStripMenuItemSwitchLaneInOut.Size = new System.Drawing.Size(180, 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.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.Text = "Ra - Vào"; + this.toolStripMenuItemSwitchLaneOutIn.Click += new System.EventHandler(this.toolStripMenuItemSwitchLaneOutIn_Click); // // AIParkingApplicationForm // diff --git a/AIParkingApplication/AIParkingApplicationForm.cs b/AIParkingApplication/AIParkingApplicationForm.cs index acfb9ab..04d440e 100644 --- a/AIParkingApplication/AIParkingApplicationForm.cs +++ b/AIParkingApplication/AIParkingApplicationForm.cs @@ -5,11 +5,12 @@ namespace AIParkingApplication { public partial class AIParkingApplicationForm : Form { - //@"C:\CongRa_1.mp4"; @"C:\HS_test.mp4"; @"rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov" private ApiController apiController; private IDoorControlAccess c3Device; - private LaneIn laneIn; - private LaneOut laneOut; + private LaneIn laneIn12; + private LaneIn laneIn56; + private LaneOut laneOut34; + private LaneOut laneOut78; private StatusBar statusBar; private Sidebar sidebar; private Config configOnWeb; @@ -36,32 +37,130 @@ namespace AIParkingApplication MessageBox.Show("Cấu hình API Plate Recognize lỗi!", "Cấu hình API Engine lỗi!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - laneIn = new LaneIn(1, this.configOnWeb.CameraData1.Id.ToString(), this.configOnWeb.CameraData1.StreamUrl, this.configOnWeb.CameraData2.StreamUrl, c3Device, this.apiController, engineApiController, true, false, true); - laneIn.BorderStyle = BorderStyle.FixedSingle; - laneIn.Location = new System.Drawing.Point(sidebar.Location.X + sidebar.Width + 20, menuStrip.Height); - Controls.Add(laneIn); - - laneOut = new LaneOut(2, this.configOnWeb.CameraData3.Id.ToString(), this.configOnWeb.CameraData3.StreamUrl, this.configOnWeb.CameraData4.StreamUrl, c3Device, this.apiController, engineApiController, true, false, true); - laneOut.BorderStyle = BorderStyle.FixedSingle; - laneOut.Location = new System.Drawing.Point(laneIn.Location.X + laneIn.Width + 20, menuStrip.Height); - Controls.Add(laneOut); statusBar = new StatusBar("192.168.1.122", "192.168.1.200", TimeSpan.FromSeconds(1)); statusBar.Location = new System.Drawing.Point(0, sidebar.Location.Y + sidebar.Height + 20); statusBar.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; Controls.Add(statusBar); - StartLanes(); + InitAllLanes(); } - private void StartLanes() + private void InitAllLanes() { - laneIn.Start(); - laneOut.Start(); + laneIn12 = new LaneIn(10, configOnWeb.CameraData1.Id.ToString(), configOnWeb.CameraData1.StreamUrl, configOnWeb.CameraData2.StreamUrl, c3Device, apiController, engineApiController, true, false, true); + laneIn12.BorderStyle = BorderStyle.FixedSingle; + laneIn12.Hide(); + Controls.Add(laneIn12); + + laneOut34 = new LaneOut(20, configOnWeb.CameraData3.Id.ToString(), configOnWeb.CameraData3.StreamUrl, configOnWeb.CameraData4.StreamUrl, c3Device, apiController, engineApiController, true, false, true); + laneOut34.BorderStyle = BorderStyle.FixedSingle; + laneOut34.Hide(); + Controls.Add(laneOut34); + + laneIn56 = new LaneIn(10, configOnWeb.CameraData5.Id.ToString(), configOnWeb.CameraData5.StreamUrl, configOnWeb.CameraData6.StreamUrl, c3Device, apiController, engineApiController, true, false, true); + laneIn56.BorderStyle = BorderStyle.FixedSingle; + laneIn56.Hide(); + Controls.Add(laneIn56); + + laneOut78 = new LaneOut(20, configOnWeb.CameraData7.Id.ToString(), configOnWeb.CameraData7.StreamUrl, configOnWeb.CameraData8.StreamUrl, c3Device, apiController, engineApiController, true, false, true); + laneOut78.BorderStyle = BorderStyle.FixedSingle; + laneOut78.Hide(); + Controls.Add(laneOut78); + } + + private void UpdateLaneInOut() + { + laneIn12.DoorId = 1; + laneIn12.Location = new System.Drawing.Point(sidebar.Location.X + sidebar.Width + 20, menuStrip.Height); + laneIn12.Show(); + laneIn12.Start(); + + laneOut34.DoorId = 2; + laneOut34.Location = new System.Drawing.Point(laneIn12.Location.X + laneIn12.Width + 20, menuStrip.Height); + laneOut34.Show(); + laneOut34.Start(); + } + + private void UpdateLaneInIn() + { + laneIn12.DoorId = 1; + laneIn12.Location = new System.Drawing.Point(sidebar.Location.X + sidebar.Width + 20, menuStrip.Height); + laneIn12.Show(); + laneIn12.Start(); + + laneIn56.DoorId = 2; + laneIn56.Location = new System.Drawing.Point(laneIn12.Location.X + laneIn12.Width + 20, menuStrip.Height); + laneIn56.Show(); + laneIn56.Start(); + } + + private void UpdateLaneOutIn() + { + laneOut78.DoorId = 1; + laneOut78.Location = new System.Drawing.Point(sidebar.Location.X + sidebar.Width + 20, menuStrip.Height); + laneOut78.Show(); + laneOut78.Start(); + + laneIn56.DoorId = 2; + laneIn56.Location = new System.Drawing.Point(laneOut78.Location.X + laneOut78.Width + 20, menuStrip.Height); + laneIn56.Show(); + laneIn56.Start(); + } + + private void UpdateLaneOutOut() + { + laneOut78.DoorId = 1; + laneOut78.Location = new System.Drawing.Point(sidebar.Location.X + sidebar.Width + 20, menuStrip.Height); + laneOut78.Show(); + laneOut78.Start(); + + laneOut34.DoorId = 2; + laneOut34.Location = new System.Drawing.Point(laneOut78.Location.X + laneOut78.Width + 20, menuStrip.Height); + laneOut34.Show(); + laneOut34.Start(); } private void toolStripMenuItemSwitchLaneInIn_Click(object sender, EventArgs e) { + StopAllLanes(); + UpdateLaneInIn(); + } + + private void toolStripMenuItemSwitchLaneInOut_Click(object sender, EventArgs e) + { + StopAllLanes(); + UpdateLaneInOut(); + } + + private void toolStripMenuItemSwitchLaneOutIn_Click(object sender, EventArgs e) + { + StopAllLanes(); + UpdateLaneOutIn(); + } + + private void toolStripMenuItemSwitchLaneOutOut_Click(object sender, EventArgs e) + { + StopAllLanes(); + UpdateLaneOutOut(); + } + + private void StopAllLanes() + { + laneIn12.DoorId = 10; + laneIn56.DoorId = 10; + laneOut34.DoorId = 10; + laneOut78.DoorId = 10; + + laneIn12?.Stop(); + laneIn56?.Stop(); + laneOut34?.Stop(); + laneOut78?.Stop(); + + laneIn12?.Hide(); + laneIn56?.Hide(); + laneOut34?.Hide(); + laneOut78?.Hide(); } private void AIParkingApplicationForm_FormClosing(object sender, FormClosingEventArgs e) diff --git a/AIParkingApplication/LaneIn.cs b/AIParkingApplication/LaneIn.cs index 3218328..4baf402 100644 --- a/AIParkingApplication/LaneIn.cs +++ b/AIParkingApplication/LaneIn.cs @@ -13,7 +13,7 @@ namespace AIParkingApplication private Camera overviewCamera; private Camera plateCamera; private PlateProcessor plateProcessor; - private int doorId; + public int DoorId { get; set; } private string cameraId; private bool isSupportSquarePlate; private bool isSupportLongPlate; @@ -35,7 +35,7 @@ namespace AIParkingApplication bool isRetryMode = false) { InitializeComponent(); - this.doorId = doorId; + DoorId = doorId; this.cameraId = cameraId; this.isSupportSquarePlate = isSupportSquarePlate; this.isSupportLongPlate = isSupportLongPlate; @@ -50,7 +50,7 @@ namespace AIParkingApplication private async void C3Device_OnNewCardReceived(int doorId, string cardNumber) { - if (this.doorId != doorId) + if (DoorId != doorId) { return; } @@ -87,7 +87,7 @@ namespace AIParkingApplication if (saveLogResult.Status) { - if (isAutoOpenDoor && this.doorId == doorId) + if (isAutoOpenDoor && DoorId == doorId) { OpenDoor(doorId); } diff --git a/AIParkingApplication/LaneOut.cs b/AIParkingApplication/LaneOut.cs index c2b2442..4bc3efb 100644 --- a/AIParkingApplication/LaneOut.cs +++ b/AIParkingApplication/LaneOut.cs @@ -13,7 +13,7 @@ namespace AIParkingApplication private Camera overviewCamera; private Camera plateCamera; private PlateProcessor plateProcessor; - private int doorId; + public int DoorId { get; set; } private string cameraId; private bool isSupportSquarePlate; private bool isSupportLongPlate; @@ -36,7 +36,7 @@ namespace AIParkingApplication bool isRetryMode = false) { InitializeComponent(); - this.doorId = doorId; + DoorId = doorId; this.cameraId = cameraId; this.isSupportSquarePlate = isSupportSquarePlate; this.isSupportLongPlate = isSupportLongPlate; @@ -52,7 +52,7 @@ namespace AIParkingApplication private async void C3Device_OnNewCardReceived(int doorId, string cardNumber) { - if (this.doorId != doorId) + if (DoorId != doorId) { return; }