Compare commits

...

199 Commits

Author SHA1 Message Date
DucDangAnh
d97908a22b ConfigurationForm - Add Event For btnCheckDoorDeviceControlAccessIP_Click 2020-07-21 16:02:38 +07:00
DucDangAnh
9400402141 AppConstant - add App.config key 2020-07-21 15:52:47 +07:00
DucDangAnh
59208674e0 App.config - add Key AUTO_RUN_AT_STARTUP. ConfigurationForm - add features: auto startup with Windows. 2020-07-21 14:05:39 +07:00
DucDangAnh
aa73bf8129 ConfigurationForm - btnSaveSettings_Click: fix typo 2020-07-20 15:38:37 +07:00
DucDangAnh
aa1aae8c6c ConfigurationForm - add toolStripStatusLabelSavedSettingStatus to show saved settings status. 2020-07-20 15:36:31 +07:00
DucDangAnh
1671d3b456 ConfigurationForm - add chkAllowAutoLogin 2020-07-20 15:22:10 +07:00
DucDangAnh
a3543084b7 ConfigurationForm - add appLogger into constructor. Add LoadConfiguration() 2020-07-20 15:18:19 +07:00
DucDangAnh
89e766714a ConfigurationForm - allow user use Printer 2020-07-20 14:48:48 +07:00
DucDangAnh
fd96643412 Add ConfigurationForm. AIParkingApplicationForm - add ConfigurationForm 2020-07-20 14:39:16 +07:00
Le Chau
1418b1077e Merge branch 'master' of http://gitea.beetai.com/ducda/AIParkingApplication 2020-07-20 11:55:53 +07:00
Le Chau
53aa3e31ea Thêm tính năng lưu ROI lên Server và Vẽ lại ROI 2020-07-20 11:53:43 +07:00
Le Chau
076290e141 Thêm tính năng Cascade trong vùng ROI 2020-07-17 15:19:12 +07:00
DucDangAnh
6284909fd8 Util - Rename AddOrUpdateAppSettings to UpsertAppSettings 2020-07-17 15:01:16 +07:00
DucDangAnh
68d84387b8 App.config - add DEFAULT_WEB_SERVER key. LoginForm - update DEFAULT_WEB_SERVER 2020-07-17 15:00:13 +07:00
Le Chau
c0c8b325d0 Thêm tính năng vẽ ROI vào khung cam bắt biển 2020-07-17 14:03:14 +07:00
DucDangAnh
2c6e326008 LoginForm - Add UI check status auto login 2020-07-16 16:23:43 +07:00
DucDangAnh
01098b4597 LaneOut - Fix message type 2020-07-16 16:07:40 +07:00
DucDangAnh
61f6be6093 LaneOut - fix typo 2020-07-16 15:58:19 +07:00
DucDangAnh
d3a47432bb LaneOut - Add exMessage to logger of ReadUsePrinterConfig 2020-07-16 15:57:04 +07:00
DucDangAnh
2c60eebda1 App.config - add USE_PRINTER key. LaneOut - add ReadUsePrinterConfig 2020-07-16 15:55:10 +07:00
DucDangAnh
7c03df5229 LoginForm - Auto Login Feature. 2020-07-16 15:44:27 +07:00
DucDangAnh
c9b65ba883 Update logging message. 2020-07-16 15:30:46 +07:00
DucDangAnh
a835ed626b ApiController - simplified CardModel in GetCardInformation 2020-07-15 16:17:06 +07:00
DucDangAnh
79eca30267 ApiController - retry delay 800ms 2020-07-15 16:06:58 +07:00
DucDangAnh
87e3a7418a ApiController - update appLogger log 2020-07-15 16:04:54 +07:00
DucDangAnh
646449b4ba ApiController - rename applicationLogger -> appLogger 2020-07-15 15:59:21 +07:00
DucDangAnh
e8fae43c1d ApiController - Update Method: SaveLog. LaneIn, LaneOut - Add log 2020-07-15 15:54:46 +07:00
DucDangAnh
153eba219f Add appLogger. 2020-07-15 14:34:13 +07:00
DucDangAnh
b4baa218b4 ApiController - Add Log 2020-07-14 17:06:32 +07:00
DucDangAnh
b020ca2a73 AIParkingApplicationForm - Remove Redundant code. 2020-07-14 17:06:06 +07:00
DucDangAnh
ee590211f8 Move applicationLogger into LoginForm 2020-07-14 15:16:11 +07:00
DucDangAnh
52f71be90b ApiController - Update numberOfRetry 2020-07-14 14:48:53 +07:00
DucDangAnh
08c6ed210e NLog.config - Update Log Layout 2020-07-14 14:43:07 +07:00
DucDangAnh
2a8a1ff1a5 AIParkingApplicationForm - Update Loglevel when exit app. 2020-07-14 14:40:01 +07:00
DucDangAnh
8778a976db AIParkingApplicationForm - add applicationLogger 2020-07-14 14:30:58 +07:00
DucDangAnh
e1f1320671 NLog.config - Update logger configuration. 2020-07-14 14:27:43 +07:00
DucDangAnh
0af35e015a AIParkingApplicationForm - use serverIPAddress param instead of hardcoded string. 2020-07-14 11:38:11 +07:00
DucDangAnh
7d2f05a2f8 AIParkingApplication.csproj - Add NLog Lib. 2020-07-14 11:35:53 +07:00
DucDangAnh
d6d87b2ec8 AIParkingApplication.csproj - add class ExtensitionMethods. Util - Remove extensition methods. 2020-07-14 11:14:56 +07:00
DucDangAnh
740858693e AIParkingApplicationForm - hardcoded to const CURRENT_LANE_SETTING_KEY. Util - Add extensition method: DisableSelected 2020-07-14 11:07:53 +07:00
DucDangAnh
0375eac88d AIParkingApplicationForm - Remove Exit Dialog Confirmation. 2020-07-13 16:18:50 +07:00
DucDangAnh
daf755949a AIParkingApplicationForm - Add method: InitLaneFirstTime, save lanes configuration. 2020-07-13 16:02:50 +07:00
DucDangAnh
92d95236c8 LoginForm - Catch Execption: Set default text input for username, password 2020-07-13 15:41:04 +07:00
DucDangAnh
06dc6957ce Util - Update Method: AddOrUpdateAppSettings 2020-07-13 15:39:58 +07:00
DucDangAnh
5773b6d48e LoginForm - Save username, password to ConfigurationFile. 2020-07-13 15:35:01 +07:00
DucDangAnh
73e353b99e Util - Add Method AddOrUpdateAppSettings 2020-07-13 15:34:23 +07:00
DucDangAnh
9d25ac394b AIParkingApplicationForm - Closing Form Show Confirmation Dialog 2020-07-13 15:11:18 +07:00
DucDangAnh
74855b6467 LoginForm - Check IP Address Input. 2020-07-13 14:51:44 +07:00
DucDangAnh
728f65cd90 StatusBar - Remove updateInterval 2020-07-13 11:04:48 +07:00
DucDangAnh
50301189d8 Update App Title 2020-07-13 10:50:00 +07:00
DucDangAnh
6d7125511c Util - Add IsValidIPAddress 2020-07-13 10:48:20 +07:00
DucDangAnh
2c559d26b9 AIParkingApplicationForm - Fix bug: ReadAccessControlDeviceIPConfiguration 2020-07-13 10:34:27 +07:00
DucDangAnh
5c13a5c5e0 App.config - Add key DOOR_ACCESS_DEVICE_CONTROL. AIParkingApplicationForm - Add ReadAccessControlDeviceIPConfiguration 2020-07-13 10:18:31 +07:00
DucDangAnh
f0a64d9034 ApiController - Update httpClient timeout 2020-07-13 10:16:05 +07:00
DucDangAnh
4bf3ddea5d ApiController - Fix bugs 2020-07-13 10:02:34 +07:00
DucDangAnh
b50ea3c97c AIParkingApplicationForm - Refactor abit 2020-07-13 10:02:10 +07:00
DucDangAnh
8ae4adae0a LoginForm - check exception login status text 2020-07-10 15:11:41 +07:00
DucDangAnh
56e6ef249d ApiController - Refactor. 2020-07-10 14:57:19 +07:00
DucDangAnh
34d0054b01 Merge branch 'master' of http://gitea.beetai.com/ducda/AIParkingApplication 2020-07-10 14:47:00 +07:00
DucDangAnh
85ec2e8559 AIParkingApplicationForm - Refactor 2020-07-10 14:46:55 +07:00
Le Chau
e006ea75e4 Thêm tính năng thử gửi lại request tối đa 3 lần trước khi thông báo lỗi lấy thông tin thẻ hoặc ghi log 2020-07-10 14:45:27 +07:00
DucDangAnh
0cc0400b05 AIParkingApplicationForm - Add Func. UpdateMenuStripItemStatus 2020-07-09 15:09:52 +07:00
DucDangAnh
b46d79e101 AIParkingApplicationForm, StatusBar - Fix UI 2020-07-09 14:45:03 +07:00
DucDangAnh
960e8cf76d AIParkingApplicationForm - using namepsace for shorten usage. 2020-07-09 14:37:31 +07:00
DucDangAnh
f29ad3c5c4 StatusBar - Fix UI. 2020-07-09 14:37:02 +07:00
DucDangAnh
766873da13 AIParkingApplicationForm - Switch Lane Features. 2020-07-09 14:26:51 +07:00
DucDangAnh
d9c7da60b5 AIParkingApplicationForm - Fix build. 2020-07-08 16:37:07 +07:00
DucDangAnh
bd02973b52 ILane - Add Method Hide, Show 2020-07-08 15:39:01 +07:00
DucDangAnh
9cd22def78 LaneIn, LaneOut - Remove hardcoded cameraId 2020-07-08 15:38:39 +07:00
DucDangAnh
47a386a3f7 LoginForm - Remove redundant code. 2020-07-08 15:37:21 +07:00
DucDangAnh
7f61711e61 AIParkingApplicationForm - Add menustrip for laneswitch. 2020-07-08 13:54:01 +07:00
DucDangAnh
5b3d0f95c8 LaneIn - Fix bug that need to wait form load. 2020-07-07 17:21:43 +07:00
DucDangAnh
cc6df6ac2b LaneOut - Add FormLoad Event. 2020-07-07 17:21:09 +07:00
DucDangAnh
a00d77133f StatusBar - Form Load start Thread to Update Info. 2020-07-07 17:13:43 +07:00
DucDangAnh
fbee2526c5 Statistic - Fix bugs. 2020-07-07 17:09:47 +07:00
DucDangAnh
44ee429ae6 LaneOut - Add Printer. 2020-07-07 16:18:16 +07:00
DucDangAnh
315d2fd03a Add Printer Class, printerForm 2020-07-07 15:05:46 +07:00
DucDangAnh
5f7ac10f22 LoginForm - Catch exception to handle login status. (API needs to fixed same return data type: todo DongPD) 2020-07-07 14:01:19 +07:00
DucDangAnh
53f457b020 LoginForm - Try catch exception while init ApiController 2020-07-06 18:09:07 +07:00
DucDangAnh
bbe0f7ed64 Add EngineApiController 2020-07-06 17:51:30 +07:00
DucDangAnh
2c5c923fc9 AppConstant - Add Constant: DEFAULT_LOGO_IMAGE 2020-07-06 17:16:39 +07:00
DucDangAnh
92e57da18c LoginForm - Remove pictureBoxImageLogo border style 2020-07-06 17:13:33 +07:00
DucDangAnh
33eace9899 LoginForm - set txtUsername.Focus() 2020-07-06 17:10:44 +07:00
DucDangAnh
051ab35337 ApiController - Rename Stream_url -> StreamUrl 2020-07-06 16:28:53 +07:00
DucDangAnh
2e44442289 LoginForm, AIParkingApplicationForm: Get configuration on web 2020-07-06 16:27:26 +07:00
DucDangAnh
ee56086eff AIParkingApplicationForm - pass apiController thru Param. 2020-07-06 16:12:49 +07:00
DucDangAnh
8e537fba1b Util - Add regex serverUrl check. 2020-07-06 16:08:57 +07:00
DucDangAnh
ab9216cbc2 LoginForm - Add AcceptButton. 2020-07-06 15:22:14 +07:00
DucDangAnh
0ff210091a Add LoginForm. Make start LoginForm default. 2020-07-06 15:06:45 +07:00
DucDangAnh
d60b020ad2 Statistic - Check IsHandleCreated 2020-07-06 15:05:38 +07:00
DucDangAnh
0fc26f7f01 Util - UpdateImage and UpdateLabel check isDisposed 2020-07-06 15:05:24 +07:00
DucDangAnh
a038303db3 StatusBar - Fix UI 2020-07-06 11:42:21 +07:00
DucDangAnh
1da26f5106 AIParkingApplicationForm - Fix Width, Rename Title Text, Add icon 2020-07-06 11:14:00 +07:00
DucDangAnh
f56206d5c2 Add ApplicationLogo. Sidebar - Fixed Default Image Path. 2020-07-06 11:07:02 +07:00
DucDangAnh
9e9875123d StatusBar - Fix bug check engine file path. 2020-07-06 10:54:17 +07:00
DucDangAnh
bf9a89f8c5 Update UI. 2020-07-06 10:42:46 +07:00
DucDangAnh
3af336a184 Add Sidebar. Fix Statistic UI. 2020-07-06 10:32:30 +07:00
DucDangAnh
98538a3fba AIParkingApplicationForm - Remove Redundant Code. 2020-07-06 09:45:33 +07:00
DucDangAnh
3d08edea71 StatusBar - Check file engine.bat exist 2020-07-06 09:41:54 +07:00
DucDangAnh
b441c2d70a StatusBar - lblEngineStatus Rename Default Text 2020-07-06 09:34:17 +07:00
DucDangAnh
a717b356f0 Util - add ExecuteCommand. StatusBar - Check engine status. 2020-07-02 14:46:49 +07:00
DucDangAnh
798eee42e2 StatusBar - Update UI 2020-07-02 10:44:20 +07:00
DucDangAnh
2be71a249a LaneIn, LaneOut - Add PictureBox Border 2020-07-02 10:03:05 +07:00
DucDangAnh
a8bb5bf67a Statistic - Refactor 2020-07-02 09:43:45 +07:00
DucDangAnh
2a2c1439b3 AIParkingApplicationForm, Statistic - Fix UI 2020-07-01 17:38:35 +07:00
DucDangAnh
ede593da17 Statistic - use ApiController instead baseAddress 2020-07-01 17:24:38 +07:00
DucDangAnh
d1128f34c2 Statistic - Fix Design 2020-07-01 17:21:02 +07:00
DucDangAnh
42e04898cf LaneOut - Update lblStatusInfo Text 2020-07-01 17:07:02 +07:00
DucDangAnh
1871f67ec2 AIParkingApplicationForm - Add StatusBar into Form. 2020-07-01 16:50:31 +07:00
DucDangAnh
9573166217 LaneIn, LaneOut - Refactor abit 2020-07-01 16:30:47 +07:00
DucDangAnh
005095401f LaneIn - Update Some Texts 2020-07-01 11:23:49 +07:00
DucDangAnh
9916304ce2 LaneOut - Update sometext 2020-07-01 11:22:55 +07:00
DucDangAnh
0eefa56149 LaneOut - Update Timein, timeOut Text 2020-07-01 11:22:04 +07:00
DucDangAnh
9e34d572b7 LaneOut - add lblCardTimeOut 2020-07-01 11:16:17 +07:00
DucDangAnh
cd4fd83d4c Use DateTime.Now.GetTimeFormatted() instead DateTime.Now.ToString(AppConstant.DATETIME_FORMAT) 2020-07-01 10:53:34 +07:00
DucDangAnh
d541accb33 LaneOut - Change lblStatusInfo Text, Display lblMoneyAmount 2020-07-01 10:48:49 +07:00
DucDangAnh
be4b3b184a LaneIn - Change lblStatusInfo Text 2020-07-01 10:48:14 +07:00
DucDangAnh
c84d277f15 Util - Add method: ConvertFromBase64Image(string base64ImageString). LaneOut - Rename pictureBoxOverviewImageIn, pictureBoxPlateImageIn. ApiController - Rename CardIP -> CardId, Plate -> PlateString 2020-07-01 09:53:24 +07:00
DucDangAnh
3913dd41e7 AIParkingApplicationForm - Add StartLanes() 2020-07-01 09:26:27 +07:00
DucDangAnh
5c6775c6d4 LaneIn, LaneOut - Fix label lblStatusInfo 2020-07-01 09:26:08 +07:00
DucDangAnh
5f4fa31c35 LaneIn, LaneOut - Check doorId then do job 2020-06-30 17:40:47 +07:00
DucDangAnh
c93f57592f Update LaneOut 2020-06-30 17:38:14 +07:00
DucDangAnh
a761829216 LaneOut - Redeign layout. 2020-06-30 17:22:38 +07:00
DucDangAnh
b5d532f2a9 Add IDoorControlAccess. LaneIn - use IDoorControlAccess instead of C3DeviceController 2020-06-30 16:52:53 +07:00
DucDangAnh
e72f365013 C3DeviceController - prop. IPAddress to field. 2020-06-30 16:35:00 +07:00
DucDangAnh
4ee2507055 Util - Add OverLoad for UpdateLabel. StatusBar - Refactor. 2020-06-30 14:56:56 +07:00
DucDangAnh
9894ce831d Statistic - UpdateLabel 2020-06-30 14:37:16 +07:00
DucDangAnh
75efa50256 Statistic - Remove redundant code. 2020-06-30 14:17:11 +07:00
DucDangAnh
a7f5406550 ActionResult - Remove prop. public object Data 2020-06-30 14:16:50 +07:00
DucDangAnh
d00adfac4c Util - Add Overload UpdateLabel 2020-06-30 14:16:01 +07:00
DucDangAnh
19f9a4ed82 LaneIn - Refactor C3Device_OnNewCardReceived 2020-06-30 10:58:25 +07:00
DucDangAnh
562cccc7d5 LaneIn - use UpdateLabel. 2020-06-30 10:52:30 +07:00
DucDangAnh
9668f8f3ac Util - Add Extensition Methods: UpdateImage, UpdateLabel 2020-06-30 10:15:15 +07:00
DucDangAnh
d756d36082 LaneIn - Formload Event: Connect and check door access control connection . 2020-06-30 09:45:36 +07:00
DucDangAnh
1eee458212 LaneIn - rename lblRecogizePlateStatus to lblStatusInfo 2020-06-29 17:02:48 +07:00
DucDangAnh
e3d81bc413 ApiController - Refactor SaveLog 2020-06-29 16:58:16 +07:00
DucDangAnh
996a13013d Camera - Refactor abit 2020-06-29 16:51:31 +07:00
DucDangAnh
5b90cee75b LaneIn - Add Method: ClearPlateAndOverviewImage 2020-06-29 16:06:56 +07:00
DucDangAnh
0d5e76b2af AIParkingApplicationForm - Add 2 Test Button: btnStopLaneIn, btnStartLaneIn 2020-06-29 15:21:28 +07:00
DucDangAnh
20b3ce8360 LaneIn, PlateDetector - Remove 2 todos. 2020-06-29 15:20:55 +07:00
DucDangAnh
cc92f80a45 Util - use static HttpClient httpClientEngine as field. 2020-06-29 15:19:36 +07:00
DucDangAnh
148896423f Camera - Destructor check videoCapture null. 2020-06-29 15:06:00 +07:00
DucDangAnh
e30cc8470d LaneIn - Change lblRecogizePlateStatus Text 2020-06-29 15:05:26 +07:00
DucDangAnh
0f39bd31f3 PlateDetector - Add Destructor To Dispose plateCascadeClassifier 2020-06-29 15:05:07 +07:00
DucDangAnh
f63da8a968 Camera - use videoCapture as a field. 2020-06-29 15:02:31 +07:00
DucDangAnh
5259eba6b5 LaneIn - Refactor C3Device_OnNewCardReceived 2020-06-29 14:39:38 +07:00
DucDangAnh
ab14853d29 LaneIn - Check CardInfomation. 2020-06-29 13:56:04 +07:00
DucDangAnh
f280376752 LaneIn - Merge isAutoOpenDoor && this.doorId == doorId 2020-06-29 11:46:07 +07:00
DucDangAnh
34fc28a0d8 Util - Rename Prop Ocr -> PlateString 2020-06-29 11:41:24 +07:00
DucDangAnh
5bcea0ba3f PlateProcessor - FinalPlateResult add Prop: PlateType. ApiController - Rename CardValidation -> CardInformation 2020-06-29 11:39:36 +07:00
DucDangAnh
6c93c0dcb7 Util - OcrResult Rename Property: Plate -> PlateImageBase64 2020-06-29 11:37:18 +07:00
DucDangAnh
a7a060f89c ApiController - Rename TimeVehicleInOrOut -> Timestamp 2020-06-29 10:50:54 +07:00
DucDangAnh
8060a595c8 ApiController - Method SaveLog change params input 2020-06-29 10:41:03 +07:00
DucDangAnh
96cc32dbee ApiController - change Method CheckCard to GetCardInformation 2020-06-29 10:35:46 +07:00
DucDangAnh
57101b4d8f ApiController - Refactoring abit 2020-06-29 10:07:59 +07:00
DucDangAnh
7b05cbafa2 ApiController - remove method: GetApiPathFromServer 2020-06-29 09:56:12 +07:00
DucDangAnh
f4527e3eac Add Enums.cs. PlateDetector Remove enum PlateType. ApiController Remove enums: LaneDirection, ModePlate 2020-06-29 09:51:56 +07:00
DucDangAnh
454251898d Camera - Remove CameraEvent OnOneVideoFrameRequested; 2020-06-29 09:40:34 +07:00
DucDangAnh
963bba78a8 Merge branch 'master' of http://gitea.beetai.com/ducda/AIParkingApplication 2020-06-29 09:38:46 +07:00
DucDangAnh
12c2618932 LaneIn - Remove Event overviewCamera.OnOneVideoFrameRequested 2020-06-29 09:38:41 +07:00
Le Chau
7512bafc43 SmallRefactor 2020-06-29 09:37:00 +07:00
Le Chau
2cd9fa1ef3 SmallRefactor: {APIPath} -> {APIPathModel} 2020-06-29 09:37:00 +07:00
Le Chau
089c289019 SmallRefactor: {Data} -> {Config} 2020-06-29 09:37:00 +07:00
Le Chau
f8004c3212 SmallRefactor: {CardInfo} -> {CardModel} 2020-06-29 09:37:00 +07:00
Le Chau
02870d5aa7 SmallRefactor: {VehicleDirection} -> {LaneDirection} 2020-06-29 09:36:59 +07:00
Le Chau
5d7dcd63da Handle một lỗi Thread chạy trước khi Control được tạo dẫn đến lỗi 2020-06-29 09:36:59 +07:00
Le Chau
30f5f14ee7 SmallRefactor: {SaveLogParams} -> {SaveLogModel} 2020-06-29 09:36:59 +07:00
Le Chau
d5089f189b Chuyển API lấy Thống kê từ {Statistic} sang {ApiController} 2020-06-29 09:36:59 +07:00
Le Chau
e972222b91 SmallRefactor: Xoá component không cần thiết 2020-06-29 09:36:59 +07:00
Le Chau
2903ea8653 SmallRefactor: Truyền kiểu dữ liệu enum thay vì int 2020-06-29 09:36:59 +07:00
DucDangAnh
2de7ff5745 LaneIn - capture one video frame then show UI. C3Device_OnNewCardReceived 2020-06-29 09:35:05 +07:00
DucDangAnh
b7eae98821 LaneIn - Remove field: isRetryModeUntilOk 2020-06-29 09:28:20 +07:00
DucDangAnh
b0b062788e LaneIn - Remove Method CaptureAllCamera. 2020-06-29 09:25:59 +07:00
DucDangAnh
b94b6773d5 LaneIn - Remove Test Button. Remove Eventhandler for plateCamera.OnOneVideoFrameRequested 2020-06-29 09:25:12 +07:00
DucDangAnh
b8e88aaafe LaneIn - Check card info then do recognize plate. ApiController: CardValidation IsValid change type. 2020-06-26 17:46:45 +07:00
DucDangAnh
44eb7c3ee7 LaneIn - synchronous C3Device_OnNewCardReceived and PlateCamera_OnOneVideoFrameRequested 2020-06-26 17:38:50 +07:00
DucDangAnh
c01b0dac8a Merge branch 'master' of http://gitea.beetai.com/ducda/AIParkingApplication 2020-06-26 14:17:05 +07:00
Le Chau
b3517e90ea Thêm API Check valid thẻ 2020-06-26 14:16:53 +07:00
DucDangAnh
f38d8dd085 Merge branch 'master' of http://gitea.beetai.com/ducda/AIParkingApplication 2020-06-26 14:09:36 +07:00
Le Chau
eb9f0e86d3 Thêm API Lưu Log 2020-06-26 13:48:56 +07:00
Le Chau
968e852f18 Thêm API Login 2020-06-26 10:19:33 +07:00
DucDangAnh
48e900b353 LaneIn - Make ProcessFrameImage Return Result. 2020-06-25 16:39:00 +07:00
DucDangAnh
059e79924c Merge branch 'master' of http://gitea.beetai.com/ducda/AIParkingApplication 2020-06-25 13:39:42 +07:00
DucDangAnh
73a13a249d Add ApiController 2020-06-25 13:39:28 +07:00
Le Chau
04e74cea45 Tách show info thống kê ra khỏi phần {GetDataFromServer} 2020-06-25 11:46:37 +07:00
Le Chau
b6aef4b864 SmallRefactor: Xoá comment 2020-06-25 11:23:09 +07:00
Le Chau
7c0383fa9f Check null trong trường hợp không có jsonProperty trả về thì set giá trị về "0" với {TotalIn} và {TotalOut} 2020-06-25 11:16:24 +07:00
Le Chau
6344eaed34 Refactor: Đổi tên class {Vehicle} -> {parkInfo} 2020-06-25 11:11:20 +07:00
Le Chau
e939613153 SmallRefactor: {apiUrl} -> {baseAddress} 2020-06-25 11:09:02 +07:00
DucDangAnh
7529efa6d2 LaneIn - Remove using Task For Event: PlateCamera_OnOneVideoFrameRequested 2020-06-25 11:03:03 +07:00
Le Chau
fefc90331d SmallRefactor: Sửa naming Convention của {GetDataFromServer()} 2020-06-25 10:43:26 +07:00
Le Chau
b71846e3c9 Check vehice == null khi api trả về null 2020-06-25 10:42:26 +07:00
Le Chau
effa22abc9 sửa lỗi chính tả của biến {TotalOut} 2020-06-25 10:41:37 +07:00
Le Chau
bc86b4c00f SmallRefactor: Bỏ check object {Vehicle} null khi gán giá trị 2020-06-25 10:29:24 +07:00
Le Chau
cdc5ffb968 SmallRefactor: Thêm AccessModifier cho Label 2020-06-25 10:22:50 +07:00
Le Chau
8f8f5343e9 truyền chu kì lấy thống kê qua tham số của constructor thay vì constant như trước 2020-06-25 10:21:40 +07:00
Le Chau
a7fe049f15 SmallRefactor: Đưa thrStatistics.IsBackground vào Constructor 2020-06-25 10:07:53 +07:00
Le Chau
56e16cf267 Đưa chu kì lấy dữ liệu sang Constant. {TIME_TO_GET_STATISTIC_INFO}. Đơn vị tính theo giây 2020-06-25 09:58:47 +07:00
Le Chau
b2cdbf26f5 Sửa lỗi hiển thị exception {Engine} -> {ApiStatistic} 2020-06-25 09:52:17 +07:00
77 changed files with 306573 additions and 610 deletions

View File

@@ -8,13 +8,19 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AAB88B46-4AAC-4BE6-8847-E7E4C37AEB6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AAB88B46-4AAC-4BE6-8847-E7E4C37AEB6D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AAB88B46-4AAC-4BE6-8847-E7E4C37AEB6D}.Debug|x64.ActiveCfg = Debug|x64
{AAB88B46-4AAC-4BE6-8847-E7E4C37AEB6D}.Debug|x64.Build.0 = Debug|x64
{AAB88B46-4AAC-4BE6-8847-E7E4C37AEB6D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AAB88B46-4AAC-4BE6-8847-E7E4C37AEB6D}.Release|Any CPU.Build.0 = Release|Any CPU
{AAB88B46-4AAC-4BE6-8847-E7E4C37AEB6D}.Release|x64.ActiveCfg = Release|x64
{AAB88B46-4AAC-4BE6-8847-E7E4C37AEB6D}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -16,6 +16,21 @@
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -36,10 +51,35 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.7.2\lib\net45\NLog.dll</HintPath>
</Reference>
<Reference Include="OpenCvSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6adad1e807fea099, processorArchitecture=MSIL">
<HintPath>..\packages\OpenCvSharp4.4.3.0.20200524\lib\net461\OpenCvSharp.dll</HintPath>
</Reference>
@@ -50,13 +90,21 @@
<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.IO.Compression" />
<Reference Include="System.Net.Http, Version=4.1.1.3, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Net.Http.4.3.4\lib\net46\System.Net.Http.dll</HintPath>
</Reference>
<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>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.6.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.7.1\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Transactions" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
@@ -64,7 +112,6 @@
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
@@ -76,9 +123,20 @@
<Compile Include="AIParkingApplicationForm.Designer.cs">
<DependentUpon>AIParkingApplicationForm.cs</DependentUpon>
</Compile>
<Compile Include="ApiController.cs" />
<Compile Include="AppConstant.cs" />
<Compile Include="C3DeviceController.cs" />
<Compile Include="Camera.cs" />
<Compile Include="ConfigurationForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="ConfigurationForm.Designer.cs">
<DependentUpon>ConfigurationForm.cs</DependentUpon>
</Compile>
<Compile Include="EngineApiController.cs" />
<Compile Include="Enums.cs" />
<Compile Include="ExtensitionMethods.cs" />
<Compile Include="IDoorControlAccess.cs" />
<Compile Include="ILane.cs" />
<Compile Include="LaneIn.cs">
<SubType>UserControl</SubType>
@@ -92,10 +150,23 @@
<Compile Include="LaneOut.Designer.cs">
<DependentUpon>LaneOut.cs</DependentUpon>
</Compile>
<Compile Include="LoginForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="LoginForm.Designer.cs">
<DependentUpon>LoginForm.cs</DependentUpon>
</Compile>
<Compile Include="PlateDetector.cs" />
<Compile Include="PlateProcessor.cs" />
<Compile Include="Printer.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Sidebar.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Sidebar.Designer.cs">
<DependentUpon>Sidebar.cs</DependentUpon>
</Compile>
<Compile Include="Statistic.cs">
<SubType>UserControl</SubType>
</Compile>
@@ -112,12 +183,18 @@
<EmbeddedResource Include="AIParkingApplicationForm.resx">
<DependentUpon>AIParkingApplicationForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="ConfigurationForm.resx">
<DependentUpon>ConfigurationForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="LaneIn.resx">
<DependentUpon>LaneIn.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="LaneOut.resx">
<DependentUpon>LaneOut.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="LoginForm.resx">
<DependentUpon>LoginForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
@@ -128,12 +205,24 @@
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<EmbeddedResource Include="Sidebar.resx">
<DependentUpon>Sidebar.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Statistic.resx">
<DependentUpon>Statistic.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="StatusBar.resx">
<DependentUpon>StatusBar.cs</DependentUpon>
</EmbeddedResource>
<None Include="engine.bat">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<Content Include="NLog.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Include="NLog.xsd">
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
@@ -149,6 +238,9 @@
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Content Include="Images\ApplicationLogo.ico">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Images\CantConnectCamera.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
@@ -158,8 +250,22 @@
<Content Include="plateLong.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="PrinterForm.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.6.1">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.6.1 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>

View File

@@ -28,21 +28,104 @@
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AIParkingApplicationForm));
this.menuStrip = new System.Windows.Forms.MenuStrip();
this.toolStripMenuItemSwitchLane = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemSwitchLaneInIn = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemSwitchLaneInOut = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemSwitchLaneOutOut = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItemSwitchLaneOutIn = new System.Windows.Forms.ToolStripMenuItem();
this.setupToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip.SuspendLayout();
this.SuspendLayout();
//
// menuStrip
//
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItemSwitchLane,
this.setupToolStripMenuItem});
this.menuStrip.Location = new System.Drawing.Point(0, 0);
this.menuStrip.Name = "menuStrip";
this.menuStrip.Size = new System.Drawing.Size(1366, 24);
this.menuStrip.TabIndex = 0;
this.menuStrip.Text = "menuStrip1";
//
// toolStripMenuItemSwitchLane
//
this.toolStripMenuItemSwitchLane.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItemSwitchLaneInIn,
this.toolStripMenuItemSwitchLaneInOut,
this.toolStripMenuItemSwitchLaneOutOut,
this.toolStripMenuItemSwitchLaneOutIn});
this.toolStripMenuItemSwitchLane.Name = "toolStripMenuItemSwitchLane";
this.toolStripMenuItemSwitchLane.Size = new System.Drawing.Size(59, 20);
this.toolStripMenuItemSwitchLane.Text = "Đảo làn";
//
// toolStripMenuItemSwitchLaneInIn
//
this.toolStripMenuItemSwitchLaneInIn.Name = "toolStripMenuItemSwitchLaneInIn";
this.toolStripMenuItemSwitchLaneInIn.Size = new System.Drawing.Size(180, 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.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);
//
// setupToolStripMenuItem
//
this.setupToolStripMenuItem.Name = "setupToolStripMenuItem";
this.setupToolStripMenuItem.Size = new System.Drawing.Size(56, 20);
this.setupToolStripMenuItem.Text = "Cài đặt";
this.setupToolStripMenuItem.Click += new System.EventHandler(this.setupToolStripMenuItem_Click);
//
// AIParkingApplicationForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1350, 729);
this.MinimumSize = new System.Drawing.Size(1366, 768);
this.ClientSize = new System.Drawing.Size(1366, 737);
this.Controls.Add(this.menuStrip);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MainMenuStrip = this.menuStrip;
this.MinimumSize = new System.Drawing.Size(1382, 776);
this.Name = "AIParkingApplicationForm";
this.Text = "AIParking Application";
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);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.MenuStrip menuStrip;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSwitchLane;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSwitchLaneInIn;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSwitchLaneInOut;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSwitchLaneOutOut;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSwitchLaneOutIn;
private System.Windows.Forms.ToolStripMenuItem setupToolStripMenuItem;
}
}

View File

@@ -1,25 +1,312 @@
using System.Windows.Forms;
using NLog;
using System;
using System.Configuration;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
namespace AIParkingApplication
{
public partial class AIParkingApplicationForm : Form
{
//@"C:\CongRa_1.mp4"; @"C:\HS_test.mp4"; @"rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov"
public AIParkingApplicationForm()
private ApiController apiController;
private IDoorControlAccess c3Device;
private LaneIn laneIn12;
private LaneIn laneIn56;
private LaneOut laneOut34;
private LaneOut laneOut78;
private StatusBar statusBar;
private Sidebar sidebar;
private Config configOnWeb;
private EngineApiController engineApiController;
private string doorAccessControlDeviceIP;
private Logger appLogger;
public AIParkingApplicationForm(ApiController apiController, string serverIPAddress, Config configOnWeb, Logger appLogger)
{
InitializeComponent();
C3DeviceController c3Device = new C3DeviceController("192.168.1.200");
LaneIn laneIn = new LaneIn(1, @"C:\HS_test.mp4", @"C:\HS_test.mp4", c3Device, true, false, true);
//LaneIn laneOut = new LaneIn();
Controls.Add(laneIn);
laneIn.Start();
//laneOut.Location = new System.Drawing.Point(550, 0);
//Controls.Add(laneOut);
this.apiController = apiController;
this.configOnWeb = configOnWeb;
this.appLogger = appLogger;
//LaneIn laneIn1 = new LaneIn(@"C:\HS_test.mp4", @"C:\HS_test.mp4", c3Device, true, false, false);
//laneIn1.Location = new System.Drawing.Point(550, 0);
//Controls.Add(laneIn1);
//laneIn1.Start();
ReadAccessControlDeviceIPConfigurationFile();
if (string.IsNullOrEmpty(doorAccessControlDeviceIP) || !Util.IsValidIPAddress(doorAccessControlDeviceIP))
{
appLogger.Log(LogLevel.Error, "Kiểm tra lại cấu hình IP thiết bị mở cửa!");
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(appLogger, doorAccessControlDeviceIP);
sidebar = new Sidebar(apiController)
{
Location = new Point(0, 0)
};
Controls.Add(sidebar);
statusBar = new StatusBar(serverIPAddress, doorAccessControlDeviceIP)
{
Location = new Point(0, sidebar.Location.Y + sidebar.Height + 26),
Anchor = AnchorStyles.Bottom | AnchorStyles.Left
};
Controls.Add(statusBar);
try
{
engineApiController = new EngineApiController($"http://{this.configOnWeb.APIPath.ApiPlateRecognize.IP}:{this.configOnWeb.APIPath.ApiPlateRecognize.Port}");
}
catch (Exception ex)
{
appLogger.Log(LogLevel.Error, $"Cấu hình URL của Engine nhận diện biển số lỗi. exMessage: {ex.Message}");
MessageBox.Show("Cấu hình API Plate Recognize lỗi!", "Cấu hình API Engine lỗi!", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
Application.ThreadException += Application_ThreadException;
}
private void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
{
appLogger.Log(LogLevel.Error, $"Application.ThreadException. ex:{e.Exception.Message}");
}
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
appLogger.Log(LogLevel.Error, $"AppDomain.CurrentDomain.UnhandledException. ex:{(e.ExceptionObject as Exception).Message}");
}
private void InitAllLanes()
{
laneIn12 = new LaneIn(10, configOnWeb.CameraData1.Id.ToString(), configOnWeb.CameraData1.StreamUrl, configOnWeb.CameraData2.StreamUrl, c3Device, apiController, engineApiController, appLogger, configOnWeb.CameraData1.Roi_config, 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, appLogger, configOnWeb.CameraData3.Roi_config, 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, appLogger, configOnWeb.CameraData5.Roi_config, 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, appLogger, configOnWeb.CameraData7.Roi_config, true, false, true);
laneOut78.BorderStyle = BorderStyle.FixedSingle;
laneOut78.Hide();
Controls.Add(laneOut78);
}
private void UpdateLaneInOut()
{
laneIn12.DoorId = 1;
laneIn12.Location = new Point(sidebar.Location.X + sidebar.Width + 20, menuStrip.Height);
laneIn12.Show();
laneIn12.Start();
laneOut34.DoorId = 2;
laneOut34.Location = new Point(laneIn12.Location.X + laneIn12.Width + 20, menuStrip.Height);
laneOut34.Show();
laneOut34.Start();
}
private void UpdateLaneInIn()
{
laneIn12.DoorId = 1;
laneIn12.Location = new Point(sidebar.Location.X + sidebar.Width + 20, menuStrip.Height);
laneIn12.Show();
laneIn12.Start();
laneIn56.DoorId = 2;
laneIn56.Location = new Point(laneIn12.Location.X + laneIn12.Width + 20, menuStrip.Height);
laneIn56.Show();
laneIn56.Start();
}
private void UpdateLaneOutIn()
{
laneOut78.DoorId = 1;
laneOut78.Location = new Point(sidebar.Location.X + sidebar.Width + 20, menuStrip.Height);
laneOut78.Show();
laneOut78.Start();
laneIn56.DoorId = 2;
laneIn56.Location = new Point(laneOut78.Location.X + laneOut78.Width + 20, menuStrip.Height);
laneIn56.Show();
laneIn56.Start();
}
private void UpdateLaneOutOut()
{
laneOut78.DoorId = 1;
laneOut78.Location = new Point(sidebar.Location.X + sidebar.Width + 20, menuStrip.Height);
laneOut78.Show();
laneOut78.Start();
laneOut34.DoorId = 2;
laneOut34.Location = new Point(laneOut78.Location.X + laneOut78.Width + 20, menuStrip.Height);
laneOut34.Show();
laneOut34.Start();
}
private void toolStripMenuItemSwitchLaneInIn_Click(object sender, EventArgs e)
{
Util.UpsertAppSettings(AppConstant.CURRENT_LANE_SETTING, "IN-IN");
UpdateMenuStripItemStatus(sender as ToolStripMenuItem);
StopAllLanes();
UpdateLaneInIn();
appLogger.Log(LogLevel.Info, "Chuyển làn: IN-IN");
}
private void toolStripMenuItemSwitchLaneInOut_Click(object sender, EventArgs e)
{
Util.UpsertAppSettings(AppConstant.CURRENT_LANE_SETTING, "IN-OUT");
UpdateMenuStripItemStatus(sender as ToolStripMenuItem);
StopAllLanes();
UpdateLaneInOut();
appLogger.Log(LogLevel.Info, "Chuyển làn: IN-OUT");
}
private void toolStripMenuItemSwitchLaneOutIn_Click(object sender, EventArgs e)
{
Util.UpsertAppSettings(AppConstant.CURRENT_LANE_SETTING, "OUT-IN");
UpdateMenuStripItemStatus(sender as ToolStripMenuItem);
StopAllLanes();
UpdateLaneOutIn();
appLogger.Log(LogLevel.Info, "Chuyển làn: OUT-IN");
}
private void toolStripMenuItemSwitchLaneOutOut_Click(object sender, EventArgs e)
{
Util.UpsertAppSettings(AppConstant.CURRENT_LANE_SETTING, "OUT-OUT");
UpdateMenuStripItemStatus(sender as ToolStripMenuItem);
StopAllLanes();
UpdateLaneOutOut();
appLogger.Log(LogLevel.Info, "Chuyển làn: OUT-OUT");
}
private void UpdateMenuStripItemStatus(ToolStripMenuItem selectedToolStripMenuItem)
{
if (selectedToolStripMenuItem != null)
{
((ToolStripMenuItem)selectedToolStripMenuItem.OwnerItem).DropDownItems
.OfType<ToolStripMenuItem>().ToList()
.ForEach(item =>
{
item.Checked = false;
item.Enabled = true;
});
selectedToolStripMenuItem.Checked = true;
selectedToolStripMenuItem.Enabled = false;
}
}
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 InitLaneFirstTime()
{
try
{
string lanesConfig = ConfigurationManager.AppSettings[AppConstant.CURRENT_LANE_SETTING];
if (!string.IsNullOrEmpty(lanesConfig))
{
string[] lanes = lanesConfig.Split('-');
if (lanes.Length == 2)
{
string lane0 = lanes[0].ToLower();
string lane1 = lanes[1].ToLower();
if (lane0 == "in" && lane1 == "in")
{
UpdateLaneInIn();
toolStripMenuItemSwitchLaneInIn.DisableSelected();
appLogger.Log(LogLevel.Info, $"Khởi động App sử dụng lane: IN-IN");
}
if (lane0 == "in" && lane1 == "out")
{
UpdateLaneInOut();
toolStripMenuItemSwitchLaneInOut.DisableSelected();
appLogger.Log(LogLevel.Info, $"Khởi động App sử dụng lane: IN-OUT");
}
if (lane0 == "out" && lane1 == "in")
{
UpdateLaneOutIn();
toolStripMenuItemSwitchLaneOutIn.DisableSelected();
appLogger.Log(LogLevel.Info, $"Khởi động App sử dụng lane: OUT-IN");
}
if (lane0 == "out" && lane1 == "out")
{
UpdateLaneOutOut();
toolStripMenuItemSwitchLaneOutOut.DisableSelected();
appLogger.Log(LogLevel.Info, $"Khởi động App sử dụng lane: OUT-OUT");
}
}
else
{
Util.UpsertAppSettings(AppConstant.CURRENT_LANE_SETTING, "IN-OUT");
UpdateLaneInOut();
toolStripMenuItemSwitchLaneInOut.DisableSelected();
appLogger.Log(LogLevel.Info, $"Khởi động App đọc config không đủ 2 param: IN-OUT");
}
}
}
catch (Exception ex)
{
Util.UpsertAppSettings(AppConstant.CURRENT_LANE_SETTING, "IN-OUT");
UpdateLaneInOut();
toolStripMenuItemSwitchLaneInOut.DisableSelected();
Console.WriteLine($"{DateTime.Now.GetTimeFormatted()}\tReadLaneSettingFromConfigurationFile\t{ex.Message}");
appLogger.Log(LogLevel.Error, $"Đọc config làn lỗi khi khởi động app!\texMessage: {ex.Message}");
}
}
private void ReadAccessControlDeviceIPConfigurationFile()
{
try
{
doorAccessControlDeviceIP = ConfigurationManager.AppSettings[AppConstant.DOOR_ACCESS_DEVICE_CONTROL_IP].Trim();
}
catch (Exception ex)
{
doorAccessControlDeviceIP = string.Empty;
Console.WriteLine($"{DateTime.Now.GetTimeFormatted()}\tReadAccessControlDeviceIPConfiguration\t{ex.Message}");
appLogger.Log(LogLevel.Error, $"Cấu hình IP thiết bị mở cửa lỗi({AppConstant.DOOR_ACCESS_DEVICE_CONTROL_IP})!\texMessage: {ex.Message}");
}
}
private void AIParkingApplicationForm_Load(object sender, EventArgs e)
{
InitAllLanes();
InitLaneFirstTime();
}
private void AIParkingApplicationForm_FormClosing(object sender, FormClosingEventArgs e)
{
appLogger.Log(LogLevel.Info, $"Đóng ứng dụng");
Application.Exit();
}
private void setupToolStripMenuItem_Click(object sender, EventArgs e)
{
var configurationForm = new ConfigurationForm(appLogger);
configurationForm.ShowDialog(this);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -4,6 +4,5 @@
{
public bool HasError { get; set; }
public string Message { get; set; }
public object Data { get; set; }
}
}

View File

@@ -0,0 +1,553 @@
using System;
using System.Net.Http;
using System.Threading.Tasks;
using OpenCvSharp;
using Newtonsoft.Json;
using System.Net;
using NLog;
using System.Drawing;
namespace AIParkingApplication
{
public class ApiController : IDisposable
{
private HttpClient httpClient;
private bool isHttpClientDisposabled;
private int numberOfRetry;
private Logger appLogger;
public ApiController(string serverIPAddress, Logger appLogger, int numberOfRetry = 3)
{
this.appLogger = appLogger;
httpClient = new HttpClient
{
BaseAddress = new Uri($"http://{serverIPAddress}"),
Timeout = TimeSpan.FromSeconds(5)
};
isHttpClientDisposabled = false;
this.numberOfRetry = numberOfRetry;
}
~ApiController()
{
Dispose();
}
public async Task<LoginDataModel> Login(LoginModel loginData)
{
try
{
HttpResponseMessage response = await httpClient.PostAsJsonAsync("/api/login", loginData);
response.EnsureSuccessStatusCode();
var loginResult = await response.Content.ReadAsAsync<LoginDataModel>();
return loginResult;
}
catch (Exception ex)
{
Console.WriteLine($"Login Exception:\t{DateTime.Now.GetTimeFormatted()} \t {ex.Message}");
appLogger.Log(LogLevel.Error, $"Login lỗi. exMessage: {ex.Message}");
return new LoginDataModel
{
IsLoginSuccess = false,
Exception = ex
};
}
}
public async Task<Statistic.ParkInfo> GetStatisticInfo()
{
try
{
HttpResponseMessage response = await httpClient.GetAsync("/api/statistics");
response.EnsureSuccessStatusCode();
Statistic.ParkInfo parkingInfo = await response.Content.ReadAsAsync<Statistic.ParkInfo>();
if (string.IsNullOrEmpty(parkingInfo.TotalIn))
{
parkingInfo.TotalIn = "0";
}
if (string.IsNullOrEmpty(parkingInfo.TotalOut))
{
parkingInfo.TotalOut = "0";
}
return parkingInfo;
}
catch (Exception ex)
{
Console.WriteLine($"GetStatisticInfo Exception:\t{DateTime.Now.GetTimeFormatted()} \t {ex.Message}");
appLogger.Log(LogLevel.Error, $"Query dữ liệu thống kê bãi xe lỗi. exMessage: {ex.Message}");
return null;
}
}
public async Task<CardInformation> GetCardInformation(string cardNumber)
{
int requestCounter = 1;
try
{
HttpResponseMessage response;
do
{
response = await httpClient.PostAsJsonAsync("/api/check-card", new CardModel { CardNumber = cardNumber });
response.EnsureSuccessStatusCode();
requestCounter += 1;
await Task.Delay(800);
}
while (response.StatusCode != HttpStatusCode.OK && requestCounter < numberOfRetry);
var cardValication = await response.Content.ReadAsAsync<CardInformation>();
return cardValication;
}
catch (Exception ex)
{
Console.WriteLine($"CheckCard Exception:\t{DateTime.Now.GetTimeFormatted()} \t {ex.Message}");
appLogger.Log(LogLevel.Error, $"Query thông tin thẻ lỗi. Thẻ số: {cardNumber} | số lần thử lại: {requestCounter} | exMessage: {ex.Message}");
return null;
}
}
public async Task<SaveLogRespone> SaveLog(LaneDirection direction, string cardID, string cameraID, PlateType plateType, string timestamp, string plateString, Mat plateImage, Mat plateImageResult, Mat plateFrameImage, Mat frameImage, string logID = "")
{
string plateImageBase64 = Convert.ToBase64String(plateImage.ToBytes());
string plateImageResultBase64 = Convert.ToBase64String(plateImageResult.ToBytes());
string plateFrameImageBase64 = Convert.ToBase64String(plateFrameImage.ToBytes());
string frameImageBase64 = Convert.ToBase64String(frameImage.ToBytes());
int requestCounter = 1;
try
{
var request = new SaveLogModel
{
Direction = direction == LaneDirection.In ? "in" : "out",
LogID = logID,
CardID = cardID,
TextPlate = plateString,
CameraID = cameraID,
ModePlate = plateType == PlateType.Square ? "1" : "0",
Timestamp = timestamp,
PlateImage = plateImageBase64,
PlateResultImage = plateImageResultBase64,
PlateFrameImage = plateFrameImageBase64,
FrameImage = frameImageBase64
};
HttpResponseMessage response;
do
{
response = await httpClient.PostAsJsonAsync("/api/save-logs", request);
response.EnsureSuccessStatusCode();
requestCounter += 1;
await Task.Delay(800);
} while (response.StatusCode != HttpStatusCode.OK && requestCounter < numberOfRetry);
SaveLogRespone saveLogRespone = await response.Content.ReadAsAsync<SaveLogRespone>();
return saveLogRespone;
}
catch (Exception ex)
{
Console.WriteLine($"SaveLog Exception:\t{DateTime.Now.GetTimeFormatted()} \t {ex.Message}");
appLogger.Log(LogLevel.Error, string.Format("Không thể lưu log gửi xe. Làn: {0} | Mã thẻ: {1} | cameraID: {2} | Thời gian: {3} | Biển số: {4} | LogID: {5} | exMessage: ", direction == LaneDirection.In ? "IN" : "OUT", cardID, cameraID, timestamp, plateString, logID, ex.Message));
return null;
}
}
public async void SaveRoiToServer(Rectangle roiRegion, string cameraId)
{
int requestCounter = 1;
try
{
var request = new RoiConfig
{
CameraID = cameraId,
X = roiRegion.X,
Y = roiRegion.Y,
Width = roiRegion.Width,
Height = roiRegion.Height
};
HttpResponseMessage response;
do
{
response = await httpClient.PostAsJsonAsync("/api/update-roi", request);
response.EnsureSuccessStatusCode();
requestCounter += 1;
} while (response.StatusCode != HttpStatusCode.OK && requestCounter < numberOfRetry);
SaveLogRespone saveLogRespone = await response.Content.ReadAsAsync<SaveLogRespone>();
}
catch (Exception ex)
{
Console.WriteLine($"SaveRoiConfig Exception:\t{DateTime.Now.GetTimeFormatted()} \t {ex.Message}");
appLogger.Log(LogLevel.Error, string.Format("Không thể lưu ROI Config | exMessage: " + ex.Message));
}
}
public void Dispose()
{
if (httpClient != null && !isHttpClientDisposabled)
{
isHttpClientDisposabled = true;
httpClient.Dispose();
}
}
}
#region Check card validation API Data Model
public class CardModel
{
[JsonProperty("card")]
public string CardNumber { get; set; }
}
public class CardInformation
{
[JsonProperty("status")]
public bool IsValid { get; set; }
[JsonProperty("type")]
public string Direction { get; set; }
[JsonProperty("cardID")]
public string CardId { get; set; }
[JsonProperty("cardRealID")]
public int CardRealID { get; set; }
[JsonProperty("log_id")]
public int LogID { get; set; }
[JsonProperty("cardType")]
public string CardType { get; set; }
[JsonProperty("vehicleType")]
public string VehicleType { get; set; }
[JsonProperty("autoOpen")]
public bool AutoOpenDoor { get; set; }
[JsonProperty("plate")]
public string PlateString { get; set; }
[JsonProperty("time")]
public string TimeIn { get; set; }
[JsonProperty("plateImage")]
public string PlateImageBase64 { get; set; }
[JsonProperty("frameImage")]
public string FrameImageBase64 { get; set; }
[JsonProperty("faceImage")]
public string FaceImageBase64 { get; set; }
[JsonProperty("name")]
public string CustomerName { get; set; }
}
#endregion
#region Save Log API Data Model
public class SaveLogRespone
{
[JsonProperty("status")]
public bool Status { get; set; }
[JsonProperty("logID")]
public int LogID { get; set; }
[JsonProperty("cost")]
public string Cost { get; set; }
}
public class SaveLogModel
{
[JsonProperty("card")]
public string CardID { get; set; }
[JsonProperty("plate")]
public string TextPlate { get; set; }
[JsonProperty("type")]
public string Direction { get; set; }
[JsonProperty("mod")]
public string ModePlate { get; set; }
[JsonProperty("log_id")]
public string LogID { get; set; }
[JsonProperty("camera")]
public string CameraID { get; set; }
[JsonProperty("time")]
public string Timestamp { get; set; }
[JsonProperty("plateImage")]
public string PlateImage { get; set; }
[JsonProperty("plateResultImage")]
public string PlateResultImage { get; set; }
[JsonProperty("plateFrameImage")]
public string PlateFrameImage { get; set; }
[JsonProperty("frameImage")]
public string FrameImage { get; set; }
}
#endregion
#region Get Config API Data Model
public class LoginModel
{
[JsonProperty("username")]
public string Username { get; set; }
[JsonProperty("password")]
public string Password { get; set; }
}
public class LoginDataModel
{
[JsonProperty("status")]
public bool IsLoginSuccess { get; set; }
[JsonProperty("data")]
public Config LoginData { get; set; }
public Exception Exception { get; set; }
}
public class Config
{
[JsonProperty("userID")]
public int UserID { get; set; }
[JsonProperty("name")]
public string UserName { get; set; }
[JsonProperty("configROI")]
public bool IsConfigROI { get; set; }
[JsonProperty("configSystemLogs")]
public bool IsSaveSystemLogs { get; set; }
[JsonProperty("api")]
public APIPathModel APIPath { get; set; }
[JsonProperty("camera1")]
public CameraData CameraData1 { get; set; }
[JsonProperty("camera2")]
public CameraData CameraData2 { get; set; }
[JsonProperty("camera3")]
public CameraData CameraData3 { get; set; }
[JsonProperty("camera4")]
public CameraData CameraData4 { get; set; }
[JsonProperty("camera5")]
public CameraData CameraData5 { get; set; }
[JsonProperty("camera6")]
public CameraData CameraData6 { get; set; }
[JsonProperty("camera7")]
public CameraData CameraData7 { get; set; }
[JsonProperty("camera8")]
public CameraData CameraData8 { get; set; }
[JsonProperty("statistic")]
public Statistics StatisticsData { get; set; }
[JsonProperty("cascadeConfig")]
public CascadeConfig CascadeConfigData { get; set; }
[JsonProperty("laneConfig")]
public LaneConfig LaneConfigData { get; set; }
}
#region API Path
public class APIPathModel
{
[JsonProperty("apiStatistics")]
public APIProperties ApiStatistics { get; set; }
[JsonProperty("apiPlateRecognize")]
public APIProperties ApiPlateRecognize { get; set; }
[JsonProperty("apiCheckCard")]
public APIProperties ApiCheckCard { get; set; }
[JsonProperty("apiSaveLogs")]
public APIProperties ApiSaveLogs { get; set; }
[JsonProperty("apiUpdateLogs")]
public APIProperties ApiUpdateLogs { get; set; }
}
public class APIProperties
{
[JsonProperty("ip")]
public string IP { get; set; }
[JsonProperty("port")]
public string Port { get; set; }
[JsonProperty("path")]
public string Path { get; set; }
}
#endregion
public class CameraData
{
[JsonProperty("id")]
public int Id { get; set; }
[JsonProperty("gate")]
public int Gate { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("type")]
public string Type { get; set; }
[JsonProperty("stream_url")]
public string StreamUrl { get; set; }
[JsonProperty("minWidth")]
public double MinWidth { get; set; }
[JsonProperty("maxWidth")]
public double MaxWidth { get; set; }
[JsonProperty("minHeight")]
public double MinHeight { get; set; }
[JsonProperty("maxHeight")]
public double MaxHeight { get; set; }
[JsonProperty("scaleFactor")]
public double ScaleFactor { get; set; }
[JsonProperty("minNeighbors")]
public double MinNeighbors { get; set; }
[JsonProperty("status")]
public double Status { get; set; }
[JsonProperty("isRecognizeCamera")]
public bool IsRecognizeCamera { get; set; }
[JsonProperty("isLongPlate")]
public bool IsLongPlate { get; set; }
[JsonProperty("stt")]
public int Stt { get; set; }
[JsonProperty("roi_config")]
public string Roi_config { get; set; }
[JsonProperty("created_at")]
public int Created_at { get; set; }
[JsonProperty("modified_at")]
public int Modified_at { get; set; }
}
public class Statistics
{
[JsonProperty("moto")]
public string Moto { get; set; }
[JsonProperty("oto")]
public string Oto { get; set; }
[JsonProperty("vip")]
public string Vip { get; set; }
[JsonProperty("total_in")]
public string Total_in { get; set; }
[JsonProperty("total_out")]
public string Total_out { get; set; }
}
public class CascadeConfig
{
[JsonProperty("minWidthPlate")]
public int MinWidthPlate { get; set; }
[JsonProperty("maxWidthPlate")]
public int MaxWidthPlate { get; set; }
[JsonProperty("minHeightPlate")]
public int MinHeightPlate { get; set; }
[JsonProperty("maxHeightPlate")]
public int MaxHeightPlate { get; set; }
[JsonProperty("minWidthLongPlate")]
public int MinWidthLongPlate { get; set; }
[JsonProperty("maxWidthLongPlate")]
public int MaxWidthLongPlate { get; set; }
[JsonProperty("minHeightLongPlate")]
public int MinHeightLongPlate { get; set; }
[JsonProperty("maxHeightLongPlate")]
public int MaxHeightLongPlate { get; set; }
[JsonProperty("scaleFactor")]
public double ScaleFactor { get; set; }
[JsonProperty("scaleFactorLong")]
public double ScaleFactorLong { get; set; }
[JsonProperty("minNeighbors")]
public double MinNeighbors { get; set; }
[JsonProperty("minNeighborsLong")]
public double MinNeighborsLong { get; set; }
[JsonProperty("timeOut")]
public int TimeOut { get; set; }
[JsonProperty("logs")]
public int Logs { get; set; }
}
#region LaneConfig
public class LaneConfig
{
[JsonProperty("laneConfig")]
public LaneConfigPosision Posision { get; set; }
}
public class LaneConfigPosision
{
[JsonProperty("left")]
public LaneConfigParam LeftLane { get; set; }
[JsonProperty("right")]
public LaneConfigParam RightLane { get; set; }
}
public class LaneConfigParam
{
[JsonProperty("name")]
public string LaneName { get; set; }
[JsonProperty("default")]
public string DefaultLane { get; set; }
[JsonProperty("longPlate")]
public bool IsLongPlate { get; set; }
}
#endregion
#endregion
}

View File

@@ -1,14 +1,31 @@
<?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" />
<add key="DEFAULT_USERNAME" value="cong1vao" />
<add key="DEFAULT_PASSWORD" value="123456a@" />
<add key="DEFAULT_WEB_SERVER" value="192.168.1.122:80" />
<add key="CURRENT_LANE_SETTING" value="IN-OUT" />
<add key="AUTO_LOGIN" value="false" />
<add key="USE_PRINTER" value="false" />
<add key="AUTO_OPEN_DOOR_1" value="true" />
<add key="AUTO_OPEN_DOOR_2" value="true" />
<add key="ALLOW_CHANGE_ROI_RECT" value="true" />
<add key="AUTO_RUN_AT_STARTUP" value="false" />
</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>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.1.3" newVersion="4.1.1.3" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@@ -2,12 +2,29 @@
{
public static class AppConstant
{
#region Application Messages
public const string APPLICATION_IS_RUNNNING = "AIParkingApplication: Ứng dụng đã chạy!";
public const string ERROR_TITLE = "Lỗi";
public const string DATETIME_FORMAT = "HH:mm:ss dd/MM/yyyy";
#endregion
public const string CAMERA_FAILED_IMAGE_PATH = @"Images\CantConnectCamera.jpg";
public const string CAMERA_FAILED_IMAGE_PATH = @".\Images\CantConnectCamera.jpg";
public const string DEFAULT_LOGO_IMAGE = @".\Images\ApplicationLogo.ico";
public const string APPLICATION_LOGGER_NAME = "ApplicationLogger";
public const string PING_SERVER_LOGGER_NAME = "PingServerLogger";
public const string PING_DOOR_DEVICE_CONTROL_ACCESS_LOGGER_NAME = "PingDoorDeviceControlAccessLogger";
#region App Config Key
public const string DOOR_ACCESS_DEVICE_CONTROL_IP = "DOOR_ACCESS_DEVICE_CONTROL_IP";
public const string DEFAULT_USERNAME = "DEFAULT_USERNAME";
public const string DEFAULT_PASSWORD = "DEFAULT_PASSWORD";
public const string DEFAULT_WEB_SERVER = "DEFAULT_WEB_SERVER";
public const string CURRENT_LANE_SETTING = "CURRENT_LANE_SETTING";
public const string AUTO_LOGIN = "AUTO_LOGIN";
public const string USE_PRINTER = "USE_PRINTER";
public const string AUTO_OPEN_DOOR_1 = "AUTO_OPEN_DOOR_1";
public const string AUTO_OPEN_DOOR_2 = "AUTO_OPEN_DOOR_2";
public const string ALLOW_CHANGE_ROI_RECT = "ALLOW_CHANGE_ROI_RECT";
public const string AUTO_RUN_AT_STARTUP = "AUTO_RUN_AT_STARTUP";
#endregion
}
}

View File

@@ -1,4 +1,5 @@
using System;
using NLog;
using System;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
@@ -7,25 +8,27 @@ namespace AIParkingApplication
{
public delegate void C3DeviceEvent(int doorId, string cardNumber);
public class C3DeviceController
public class C3DeviceController : IDoorControlAccess
{
public string IPAddress { get; }
private string ipAddress;
private int port;
private IntPtr oneTimeConnectedParamHandler;
private string connectionString;
private bool isReconnected;
private int reconnectCounter;
private Logger appLogger;
public event C3DeviceEvent OnNewCardReceived;
public C3DeviceController(string ipAddress, int port = C3Constant.DEFAULT_C3_PORT)
public C3DeviceController(Logger appLogger, string ipAddress, int port = C3Constant.DEFAULT_C3_PORT)
{
IPAddress = ipAddress;
this.ipAddress = ipAddress;
this.port = port;
connectionString = $"protocol=TCP,ipaddress={this.IPAddress},port={this.port},timeout=2000,passwd=";
connectionString = $"protocol=TCP,ipaddress={this.ipAddress},port={this.port},timeout=2000,passwd=";
oneTimeConnectedParamHandler = IntPtr.Zero;
isReconnected = true;
reconnectCounter = 0;
this.appLogger = appLogger;
}
~C3DeviceController()
@@ -50,7 +53,7 @@ namespace AIParkingApplication
public ActionResult Connect()
{
if (Util.IsPingable(IPAddress, out long replyTime))
if (Util.IsPingable(ipAddress, out long replyTime))
{
oneTimeConnectedParamHandler = Connect(connectionString);
if (oneTimeConnectedParamHandler != IntPtr.Zero)
@@ -58,7 +61,7 @@ namespace AIParkingApplication
var result = new ActionResult
{
HasError = false,
Message = string.Format(C3Constant.CONNECTED_SUCCESSFULLY, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), IPAddress)
Message = string.Format(C3Constant.CONNECTED_SUCCESSFULLY, DateTime.Now.GetTimeFormatted(), ipAddress)
};
return result;
}
@@ -67,7 +70,7 @@ namespace AIParkingApplication
var result = new ActionResult
{
HasError = true,
Message = string.Format(C3Constant.FAILED_TO_CONNECT, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), IPAddress, PullLastError())
Message = string.Format(C3Constant.FAILED_TO_CONNECT, DateTime.Now.GetTimeFormatted(), ipAddress, PullLastError())
};
return result;
}
@@ -77,7 +80,7 @@ namespace AIParkingApplication
var result = new ActionResult
{
HasError = true,
Message = string.Format(C3Constant.FAILED_TO_PING, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), IPAddress)
Message = string.Format(C3Constant.FAILED_TO_PING, DateTime.Now.GetTimeFormatted(), ipAddress)
};
return result;
}
@@ -93,7 +96,7 @@ namespace AIParkingApplication
var result = new ActionResult
{
HasError = false,
Message = string.Format(C3Constant.OPENNED_DOOR_SUCCESSFULLY, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), IPAddress)
Message = string.Format(C3Constant.OPENNED_DOOR_SUCCESSFULLY, DateTime.Now.GetTimeFormatted(), ipAddress)
};
return result;
}
@@ -102,7 +105,7 @@ namespace AIParkingApplication
var result = new ActionResult
{
HasError = true,
Message = string.Format(C3Constant.FAILED_TO_OPEN_DOOR, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), IPAddress)
Message = string.Format(C3Constant.FAILED_TO_OPEN_DOOR, DateTime.Now.GetTimeFormatted(), ipAddress)
};
return result;
}
@@ -112,7 +115,7 @@ namespace AIParkingApplication
var result = new ActionResult
{
HasError = true,
Message = string.Format(C3Constant.NOT_CONNECTTED, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), IPAddress)
Message = string.Format(C3Constant.NOT_CONNECTTED, DateTime.Now.GetTimeFormatted(), ipAddress)
};
return result;
}
@@ -131,18 +134,18 @@ namespace AIParkingApplication
}
}
public ActionResult GetRTLog(out int doorId, out string cardNumber)
private ActionResult GetRTLog(out int doorId, out string cardNumber)
{
doorId = C3Constant.DEFAULT_DOOR_ID;
cardNumber = C3Constant.DEFAULT_CARD_NUMBER;
if (!Util.IsPingable(IPAddress, out long replyTime))
if (!Util.IsPingable(ipAddress, out long replyTime))
{
isReconnected = false;
var result = new ActionResult
{
HasError = true,
Message = string.Format(C3Constant.FAILED_TO_PING, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), IPAddress)
Message = string.Format(C3Constant.FAILED_TO_PING, DateTime.Now.GetTimeFormatted(), ipAddress)
};
return result;
}
@@ -177,7 +180,7 @@ namespace AIParkingApplication
{
isReconnected = true;
reconnectCounter = 0;
reconnectResult.Message = string.Format(C3Constant.RECONNECTED_SUCCESSFULLY, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), IPAddress);
reconnectResult.Message = string.Format(C3Constant.RECONNECTED_SUCCESSFULLY, DateTime.Now.GetTimeFormatted(), ipAddress);
}
return reconnectResult;
}
@@ -185,7 +188,7 @@ namespace AIParkingApplication
var result = new ActionResult
{
HasError = true,
Message = string.Format(C3Constant.FAILED_TO_READ_LOG, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), IPAddress)
Message = string.Format(C3Constant.FAILED_TO_READ_LOG, DateTime.Now.GetTimeFormatted(), ipAddress)
};
return result;
}
@@ -197,7 +200,7 @@ namespace AIParkingApplication
var result = new ActionResult
{
HasError = true,
Message = string.Format(C3Constant.WRONG_FORMAT_DATA, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), IPAddress, ex.Message)
Message = string.Format(C3Constant.WRONG_FORMAT_DATA, DateTime.Now.GetTimeFormatted(), ipAddress, ex.Message)
};
return result;
}
@@ -210,7 +213,7 @@ namespace AIParkingApplication
var result = new ActionResult
{
HasError = false,
Message = string.Format(C3Constant.DISCONNECTED_SUCCESSFULLY, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), IPAddress)
Message = string.Format(C3Constant.DISCONNECTED_SUCCESSFULLY, DateTime.Now.GetTimeFormatted(), ipAddress)
};
return result;
}

View File

@@ -1,5 +1,6 @@
using OpenCvSharp;
using System.Threading;
using System.Windows.Forms;
namespace AIParkingApplication
{
@@ -10,15 +11,17 @@ namespace AIParkingApplication
private string streamUrl;
private volatile bool isFrameRequested;
private Thread readStreamThread;
private VideoCapture videoCapture;
public volatile Mat CurrentFrame;
public event CameraEvent OnVideoFrameReceived;
public event CameraEvent OnOneVideoFrameRequested;
public event CameraEvent OnOpenVideoStreamFailed;
public Camera(string streamUrl)
{
this.streamUrl = streamUrl;
isFrameRequested = false;
videoCapture = new VideoCapture();
readStreamThread = new Thread(new ThreadStart(ReadVideoStream));
readStreamThread.IsBackground = true;
}
@@ -26,6 +29,7 @@ namespace AIParkingApplication
~Camera()
{
Stop();
videoCapture?.Dispose();
}
public void Start()
@@ -45,16 +49,16 @@ namespace AIParkingApplication
public void ReadVideoStream()
{
VideoCapture videoCapture = new VideoCapture(); //TODO: Need to dispose this videoCapture?
Mat videoFrame = new Mat();
if (!videoCapture.Open(streamUrl))
{
OnOpenVideoStreamFailed?.Invoke(Cv2.ImRead(AppConstant.CAMERA_FAILED_IMAGE_PATH));
OnOpenVideoStreamFailed?.Invoke(Cv2.ImRead(Application.StartupPath + AppConstant.CAMERA_FAILED_IMAGE_PATH));
return;
}
Mat videoFrame = new Mat();
while (true)
{
//Thread.Sleep(5);
Thread.Sleep(50); //Stream Thread Sleep
//Thread.Sleep(40); //Video Thread Sleep
@@ -63,10 +67,14 @@ namespace AIParkingApplication
OnVideoFrameReceived?.Invoke(videoFrame);
if (isFrameRequested)
{
OnOneVideoFrameRequested?.Invoke(videoFrame);
CurrentFrame = videoFrame;
isFrameRequested = false;
}
}
else
{
OnOpenVideoStreamFailed?.Invoke(Cv2.ImRead(Application.StartupPath + AppConstant.CAMERA_FAILED_IMAGE_PATH));
}
}
}

View File

@@ -0,0 +1,290 @@
namespace AIParkingApplication
{
partial class ConfigurationForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.lblDoorDeviceControlAccessIPStatus = new System.Windows.Forms.Label();
this.btnCheckDoorDeviceControlAccessIP = new System.Windows.Forms.Button();
this.btnClose = new System.Windows.Forms.Button();
this.btnSaveSettings = new System.Windows.Forms.Button();
this.chkAllowChangeROIRect = new System.Windows.Forms.CheckBox();
this.chkAllowAutoDoor2 = new System.Windows.Forms.CheckBox();
this.chkAllowAutoDoor1 = new System.Windows.Forms.CheckBox();
this.lblAllowChangeROIRect = new System.Windows.Forms.Label();
this.lblAllowAutoOpenDoorIn = new System.Windows.Forms.Label();
this.txtDoorDeviceControlAccessIP = new System.Windows.Forms.TextBox();
this.lblDoorDeviceControlAccessIP = new System.Windows.Forms.Label();
this.lblAllowUsePrinter = new System.Windows.Forms.Label();
this.chkAllowUsePrinter = new System.Windows.Forms.CheckBox();
this.lblAllowAutoLogin = new System.Windows.Forms.Label();
this.chkAllowAutoLogin = new System.Windows.Forms.CheckBox();
this.statusStrip = new System.Windows.Forms.StatusStrip();
this.toolStripStatusLabelSavedSettingStatus = new System.Windows.Forms.ToolStripStatusLabel();
this.lblAllowAutoRun = new System.Windows.Forms.Label();
this.chkAllowAutoRunAtStartUp = new System.Windows.Forms.CheckBox();
this.statusStrip.SuspendLayout();
this.SuspendLayout();
//
// lblDoorDeviceControlAccessIPStatus
//
this.lblDoorDeviceControlAccessIPStatus.AutoSize = true;
this.lblDoorDeviceControlAccessIPStatus.Location = new System.Drawing.Point(412, 9);
this.lblDoorDeviceControlAccessIPStatus.Name = "lblDoorDeviceControlAccessIPStatus";
this.lblDoorDeviceControlAccessIPStatus.Size = new System.Drawing.Size(58, 13);
this.lblDoorDeviceControlAccessIPStatus.TabIndex = 17;
this.lblDoorDeviceControlAccessIPStatus.Text = "Trạng thái:";
//
// btnCheckDoorDeviceControlAccessIP
//
this.btnCheckDoorDeviceControlAccessIP.Location = new System.Drawing.Point(330, 3);
this.btnCheckDoorDeviceControlAccessIP.Name = "btnCheckDoorDeviceControlAccessIP";
this.btnCheckDoorDeviceControlAccessIP.Size = new System.Drawing.Size(75, 24);
this.btnCheckDoorDeviceControlAccessIP.TabIndex = 2;
this.btnCheckDoorDeviceControlAccessIP.Text = "Kiểm tra";
this.btnCheckDoorDeviceControlAccessIP.UseVisualStyleBackColor = true;
this.btnCheckDoorDeviceControlAccessIP.Click += new System.EventHandler(this.btnCheckDoorDeviceControlAccessIP_Click);
//
// btnClose
//
this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnClose.Location = new System.Drawing.Point(528, 207);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(106, 41);
this.btnClose.TabIndex = 7;
this.btnClose.Text = "Đóng";
this.btnClose.UseVisualStyleBackColor = true;
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// btnSaveSettings
//
this.btnSaveSettings.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnSaveSettings.Location = new System.Drawing.Point(416, 207);
this.btnSaveSettings.Name = "btnSaveSettings";
this.btnSaveSettings.Size = new System.Drawing.Size(106, 41);
this.btnSaveSettings.TabIndex = 0;
this.btnSaveSettings.Text = "Lưu";
this.btnSaveSettings.UseVisualStyleBackColor = true;
this.btnSaveSettings.Click += new System.EventHandler(this.btnSaveSettings_Click);
//
// chkAllowChangeROIRect
//
this.chkAllowChangeROIRect.AutoSize = true;
this.chkAllowChangeROIRect.Location = new System.Drawing.Point(252, 95);
this.chkAllowChangeROIRect.Name = "chkAllowChangeROIRect";
this.chkAllowChangeROIRect.Size = new System.Drawing.Size(72, 17);
this.chkAllowChangeROIRect.TabIndex = 5;
this.chkAllowChangeROIRect.Text = "Cho phép";
this.chkAllowChangeROIRect.UseVisualStyleBackColor = true;
//
// chkAllowAutoDoor2
//
this.chkAllowAutoDoor2.AutoSize = true;
this.chkAllowAutoDoor2.Location = new System.Drawing.Point(252, 37);
this.chkAllowAutoDoor2.Name = "chkAllowAutoDoor2";
this.chkAllowAutoDoor2.Size = new System.Drawing.Size(68, 17);
this.chkAllowAutoDoor2.TabIndex = 4;
this.chkAllowAutoDoor2.Text = "Cửa số 2";
this.chkAllowAutoDoor2.UseVisualStyleBackColor = true;
//
// chkAllowAutoDoor1
//
this.chkAllowAutoDoor1.AutoSize = true;
this.chkAllowAutoDoor1.Location = new System.Drawing.Point(141, 37);
this.chkAllowAutoDoor1.Name = "chkAllowAutoDoor1";
this.chkAllowAutoDoor1.Size = new System.Drawing.Size(68, 17);
this.chkAllowAutoDoor1.TabIndex = 3;
this.chkAllowAutoDoor1.Text = "Cửa số 1";
this.chkAllowAutoDoor1.UseVisualStyleBackColor = true;
//
// lblAllowChangeROIRect
//
this.lblAllowChangeROIRect.AutoSize = true;
this.lblAllowChangeROIRect.Location = new System.Drawing.Point(11, 96);
this.lblAllowChangeROIRect.Name = "lblAllowChangeROIRect";
this.lblAllowChangeROIRect.Size = new System.Drawing.Size(211, 13);
this.lblAllowChangeROIRect.TabIndex = 9;
this.lblAllowChangeROIRect.Text = "Cho phép thay đổi vùng nhận diện biển số:";
//
// lblAllowAutoOpenDoorIn
//
this.lblAllowAutoOpenDoorIn.AutoSize = true;
this.lblAllowAutoOpenDoorIn.Location = new System.Drawing.Point(11, 39);
this.lblAllowAutoOpenDoorIn.Name = "lblAllowAutoOpenDoorIn";
this.lblAllowAutoOpenDoorIn.Size = new System.Drawing.Size(89, 13);
this.lblAllowAutoOpenDoorIn.TabIndex = 10;
this.lblAllowAutoOpenDoorIn.Text = "Tự động mở cửa:";
//
// txtDoorDeviceControlAccessIP
//
this.txtDoorDeviceControlAccessIP.Location = new System.Drawing.Point(141, 5);
this.txtDoorDeviceControlAccessIP.Name = "txtDoorDeviceControlAccessIP";
this.txtDoorDeviceControlAccessIP.Size = new System.Drawing.Size(183, 20);
this.txtDoorDeviceControlAccessIP.TabIndex = 1;
//
// lblDoorDeviceControlAccessIP
//
this.lblDoorDeviceControlAccessIP.AutoSize = true;
this.lblDoorDeviceControlAccessIP.Location = new System.Drawing.Point(12, 9);
this.lblDoorDeviceControlAccessIP.Name = "lblDoorDeviceControlAccessIP";
this.lblDoorDeviceControlAccessIP.Size = new System.Drawing.Size(96, 13);
this.lblDoorDeviceControlAccessIP.TabIndex = 7;
this.lblDoorDeviceControlAccessIP.Text = "IP Thiết bị mở cửa:";
//
// lblAllowUsePrinter
//
this.lblAllowUsePrinter.AutoSize = true;
this.lblAllowUsePrinter.Location = new System.Drawing.Point(11, 67);
this.lblAllowUsePrinter.Name = "lblAllowUsePrinter";
this.lblAllowUsePrinter.Size = new System.Drawing.Size(83, 13);
this.lblAllowUsePrinter.TabIndex = 9;
this.lblAllowUsePrinter.Text = "Sử dụng máy in:";
//
// chkAllowUsePrinter
//
this.chkAllowUsePrinter.AutoSize = true;
this.chkAllowUsePrinter.Location = new System.Drawing.Point(141, 66);
this.chkAllowUsePrinter.Name = "chkAllowUsePrinter";
this.chkAllowUsePrinter.Size = new System.Drawing.Size(66, 17);
this.chkAllowUsePrinter.TabIndex = 5;
this.chkAllowUsePrinter.Text = "Sử dụng";
this.chkAllowUsePrinter.UseVisualStyleBackColor = true;
//
// lblAllowAutoLogin
//
this.lblAllowAutoLogin.AutoSize = true;
this.lblAllowAutoLogin.Location = new System.Drawing.Point(11, 129);
this.lblAllowAutoLogin.Name = "lblAllowAutoLogin";
this.lblAllowAutoLogin.Size = new System.Drawing.Size(106, 13);
this.lblAllowAutoLogin.TabIndex = 9;
this.lblAllowAutoLogin.Text = "Tự động đăng nhập:";
//
// chkAllowAutoLogin
//
this.chkAllowAutoLogin.AutoSize = true;
this.chkAllowAutoLogin.Location = new System.Drawing.Point(141, 128);
this.chkAllowAutoLogin.Name = "chkAllowAutoLogin";
this.chkAllowAutoLogin.Size = new System.Drawing.Size(66, 17);
this.chkAllowAutoLogin.TabIndex = 5;
this.chkAllowAutoLogin.Text = "Sử dụng";
this.chkAllowAutoLogin.UseVisualStyleBackColor = true;
//
// statusStrip
//
this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripStatusLabelSavedSettingStatus});
this.statusStrip.Location = new System.Drawing.Point(0, 259);
this.statusStrip.Name = "statusStrip";
this.statusStrip.Size = new System.Drawing.Size(646, 22);
this.statusStrip.TabIndex = 18;
this.statusStrip.Text = "statusStrip";
//
// toolStripStatusLabelSavedSettingStatus
//
this.toolStripStatusLabelSavedSettingStatus.Name = "toolStripStatusLabelSavedSettingStatus";
this.toolStripStatusLabelSavedSettingStatus.Size = new System.Drawing.Size(110, 17);
this.toolStripStatusLabelSavedSettingStatus.Text = "Cấu hình ứng dụng";
//
// lblAllowAutoRun
//
this.lblAllowAutoRun.AutoSize = true;
this.lblAllowAutoRun.Location = new System.Drawing.Point(11, 161);
this.lblAllowAutoRun.Name = "lblAllowAutoRun";
this.lblAllowAutoRun.Size = new System.Drawing.Size(122, 13);
this.lblAllowAutoRun.TabIndex = 9;
this.lblAllowAutoRun.Text = "Tự khởi động ứng dụng:";
//
// chkAllowAutoRunAtStartUp
//
this.chkAllowAutoRunAtStartUp.AutoSize = true;
this.chkAllowAutoRunAtStartUp.Location = new System.Drawing.Point(141, 160);
this.chkAllowAutoRunAtStartUp.Name = "chkAllowAutoRunAtStartUp";
this.chkAllowAutoRunAtStartUp.Size = new System.Drawing.Size(66, 17);
this.chkAllowAutoRunAtStartUp.TabIndex = 5;
this.chkAllowAutoRunAtStartUp.Text = "Sử dụng";
this.chkAllowAutoRunAtStartUp.UseVisualStyleBackColor = true;
//
// ConfigurationForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(646, 281);
this.Controls.Add(this.statusStrip);
this.Controls.Add(this.lblDoorDeviceControlAccessIPStatus);
this.Controls.Add(this.btnCheckDoorDeviceControlAccessIP);
this.Controls.Add(this.btnClose);
this.Controls.Add(this.btnSaveSettings);
this.Controls.Add(this.chkAllowAutoRunAtStartUp);
this.Controls.Add(this.chkAllowAutoLogin);
this.Controls.Add(this.chkAllowUsePrinter);
this.Controls.Add(this.chkAllowChangeROIRect);
this.Controls.Add(this.lblAllowAutoRun);
this.Controls.Add(this.chkAllowAutoDoor2);
this.Controls.Add(this.lblAllowAutoLogin);
this.Controls.Add(this.chkAllowAutoDoor1);
this.Controls.Add(this.lblAllowUsePrinter);
this.Controls.Add(this.lblAllowChangeROIRect);
this.Controls.Add(this.lblAllowAutoOpenDoorIn);
this.Controls.Add(this.txtDoorDeviceControlAccessIP);
this.Controls.Add(this.lblDoorDeviceControlAccessIP);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.MaximumSize = new System.Drawing.Size(662, 320);
this.MinimumSize = new System.Drawing.Size(662, 320);
this.Name = "ConfigurationForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Cấu hình ứng dụng";
this.Load += new System.EventHandler(this.ConfigurationForm_Load);
this.statusStrip.ResumeLayout(false);
this.statusStrip.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label lblDoorDeviceControlAccessIPStatus;
private System.Windows.Forms.Button btnCheckDoorDeviceControlAccessIP;
private System.Windows.Forms.Button btnClose;
private System.Windows.Forms.Button btnSaveSettings;
private System.Windows.Forms.CheckBox chkAllowChangeROIRect;
private System.Windows.Forms.CheckBox chkAllowAutoDoor2;
private System.Windows.Forms.CheckBox chkAllowAutoDoor1;
private System.Windows.Forms.Label lblAllowChangeROIRect;
private System.Windows.Forms.Label lblAllowAutoOpenDoorIn;
private System.Windows.Forms.TextBox txtDoorDeviceControlAccessIP;
private System.Windows.Forms.Label lblDoorDeviceControlAccessIP;
private System.Windows.Forms.Label lblAllowUsePrinter;
private System.Windows.Forms.CheckBox chkAllowUsePrinter;
private System.Windows.Forms.Label lblAllowAutoLogin;
private System.Windows.Forms.CheckBox chkAllowAutoLogin;
private System.Windows.Forms.StatusStrip statusStrip;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabelSavedSettingStatus;
private System.Windows.Forms.Label lblAllowAutoRun;
private System.Windows.Forms.CheckBox chkAllowAutoRunAtStartUp;
}
}

View File

@@ -0,0 +1,108 @@
using NLog;
using System;
using System.Configuration;
using System.Windows.Forms;
namespace AIParkingApplication
{
public partial class ConfigurationForm : Form
{
private Logger appLogger;
private string doorAccessControlDeviceIP;
private bool allowAutoOpenDoor1;
private bool allowAutoOpenDoor2;
private bool allowUsePrinter;
private bool allowChangeROIRect;
private bool allowAutoLogin;
private bool allowAutoRunAtStartUp;
public ConfigurationForm(Logger appLogger)
{
InitializeComponent();
this.appLogger = appLogger;
}
private void btnClose_Click(object sender, EventArgs e)
{
Close();
}
private void btnSaveSettings_Click(object sender, EventArgs e)
{
bool isValidIPAddress = Util.IsValidIPAddress(txtDoorDeviceControlAccessIP.Text);
if (!isValidIPAddress)
{
MessageBox.Show("Nhập đúng IP thiết bị mở cửa!");
return;
}
Util.UpsertAppSettings(AppConstant.DOOR_ACCESS_DEVICE_CONTROL_IP, txtDoorDeviceControlAccessIP.Text);
Util.UpsertAppSettings(AppConstant.AUTO_OPEN_DOOR_1, chkAllowAutoDoor1.Checked.ToString().ToLower());
Util.UpsertAppSettings(AppConstant.AUTO_OPEN_DOOR_2, chkAllowAutoDoor2.Checked.ToString().ToLower());
Util.UpsertAppSettings(AppConstant.USE_PRINTER, chkAllowUsePrinter.Checked.ToString().ToLower());
Util.UpsertAppSettings(AppConstant.ALLOW_CHANGE_ROI_RECT, chkAllowChangeROIRect.Checked.ToString().ToLower());
Util.UpsertAppSettings(AppConstant.AUTO_LOGIN, chkAllowAutoLogin.Checked.ToString().ToLower());
Util.UpsertAppSettings(AppConstant.AUTO_RUN_AT_STARTUP, chkAllowAutoRunAtStartUp.Checked.ToString().ToLower());
if (chkAllowAutoRunAtStartUp.Checked)
{
Util.AddApplicationToStartup();
}
else
{
Util.RemoveApplicationFromStartup();
}
toolStripStatusLabelSavedSettingStatus.Text = $"{DateTime.Now.GetTimeFormatted()} Đã lưu cài đặt";
}
private void ConfigurationForm_Load(object sender, EventArgs e)
{
LoadConfiguration();
txtDoorDeviceControlAccessIP.Text = doorAccessControlDeviceIP;
chkAllowAutoDoor1.Checked = allowAutoOpenDoor1;
chkAllowAutoDoor2.Checked = allowAutoOpenDoor2;
chkAllowUsePrinter.Checked = allowUsePrinter;
chkAllowChangeROIRect.Checked = allowChangeROIRect;
chkAllowAutoLogin.Checked = allowAutoLogin;
chkAllowAutoRunAtStartUp.Checked = allowAutoRunAtStartUp;
}
private void LoadConfiguration()
{
doorAccessControlDeviceIP = ReadConfigurationFromAppSettings(AppConstant.DOOR_ACCESS_DEVICE_CONTROL_IP, string.Empty);
bool.TryParse(ReadConfigurationFromAppSettings(AppConstant.AUTO_OPEN_DOOR_1, "false"), out allowAutoOpenDoor1);
bool.TryParse(ReadConfigurationFromAppSettings(AppConstant.AUTO_OPEN_DOOR_2, "false"), out allowAutoOpenDoor2);
bool.TryParse(ReadConfigurationFromAppSettings(AppConstant.USE_PRINTER, "false"), out allowUsePrinter);
bool.TryParse(ReadConfigurationFromAppSettings(AppConstant.ALLOW_CHANGE_ROI_RECT, "false"), out allowChangeROIRect);
bool.TryParse(ReadConfigurationFromAppSettings(AppConstant.AUTO_LOGIN, "false"), out allowAutoLogin);
bool.TryParse(ReadConfigurationFromAppSettings(AppConstant.AUTO_RUN_AT_STARTUP, "false"), out allowAutoRunAtStartUp);
}
private string ReadConfigurationFromAppSettings(string configurationKey, string defaultValueIfReadFailed)
{
try
{
return ConfigurationManager.AppSettings[configurationKey].Trim();
}
catch (Exception ex)
{
Util.UpsertAppSettings(configurationKey, defaultValueIfReadFailed);
Console.WriteLine($"ReadDoorDeviceControlAccessConfiguration. ex: {ex.Message}");
appLogger.Log(LogLevel.Info, $"ConfigurationForm - ReadConfigurationFromAppSettings. Key: {configurationKey} - DefaultValue: {defaultValueIfReadFailed}. ex: {ex.Message}");
return defaultValueIfReadFailed;
}
}
private void btnCheckDoorDeviceControlAccessIP_Click(object sender, EventArgs e)
{
lblDoorDeviceControlAccessIPStatus.Text = string.Empty;
bool isValidIPAddress = Util.IsValidIPAddress(txtDoorDeviceControlAccessIP.Text);
if (!isValidIPAddress)
{
lblDoorDeviceControlAccessIPStatus.Text = "Không đúng định dạng IP";
}
else
{
lblDoorDeviceControlAccessIPStatus.Text = "OK";
}
}
}
}

View File

@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="statusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@@ -0,0 +1,40 @@
using System;
using System.Net.Http;
using System.Threading.Tasks;
using OpenCvSharp;
namespace AIParkingApplication
{
public class EngineApiController
{
private HttpClient httpClientEngine;
public EngineApiController(string engineBaseAddress)
{
httpClientEngine = new HttpClient { BaseAddress = new Uri(engineBaseAddress), Timeout = TimeSpan.FromMilliseconds(5000) };
}
public async Task<OcrResult> SendEngineRequestAsync(Mat plateImage, PlateType plateType)
{
string plateImageBase64 = Convert.ToBase64String(plateImage.ToBytes());
try
{
var request = new PlateRequestEngineModel
{
Img64 = plateImageBase64,
Mode = plateType == PlateType.Square ? "square" : "long",
Display = "full"
};
HttpResponseMessage response = await httpClientEngine.PostAsJsonAsync("/get-from-frame", request);
response.EnsureSuccessStatusCode();
var ocrResult = await response.Content.ReadAsAsync<OcrResult>();
return ocrResult;
}
catch (Exception ex)
{
Console.WriteLine($"SendEngineRequest : {ex.Message}");
return new OcrResult();
}
}
}
}

View File

@@ -0,0 +1,14 @@
namespace AIParkingApplication
{
public enum PlateType
{
Square,
Long
}
public enum LaneDirection
{
In,
Out
}
}

View File

@@ -0,0 +1,76 @@
using System;
using System.Drawing;
using System.Windows.Forms;
namespace AIParkingApplication
{
public static class ExtensitionMethods
{
public static void DisableSelected(this ToolStripMenuItem toolStripMenuItem)
{
toolStripMenuItem.Checked = true;
toolStripMenuItem.Enabled = false;
}
public static string GetTimeFormatted(this DateTime dateTime)
{
return dateTime.ToString(AppConstant.DATETIME_FORMAT);
}
public static void UpdateImage(this PictureBox pictureBox, Bitmap image)
{
if (pictureBox.IsDisposed)
{
return;
}
pictureBox.Invoke(new Action(() =>
{
pictureBox.Image?.Dispose();
pictureBox.Image = image;
}));
}
public static void UpdateLabel(this Label label, string text, Color backColor, Color foreColor)
{
if (label.IsDisposed)
{
return;
}
label.Invoke(new Action(() =>
{
label.Text = text;
label.BackColor = backColor;
label.ForeColor = foreColor;
}));
}
public static void UpdateLabel(this Label label, string text, Color backColor)
{
if (label.IsDisposed)
{
return;
}
label.Invoke(new Action(() =>
{
label.Text = text;
label.BackColor = backColor;
}));
}
public static void UpdateLabel(this Label label, string text)
{
if (label.IsDisposed)
{
return;
}
label.Invoke(new Action(() =>
{
label.Text = text;
}));
}
}
}

View File

@@ -0,0 +1,14 @@
using System.Threading.Tasks;
namespace AIParkingApplication
{
public interface IDoorControlAccess
{
event C3DeviceEvent OnNewCardReceived;
ActionResult Connect();
ActionResult Disconnect();
Task GetLogToReceiveNewCard();
ActionResult OpenDoor(int doorId);
}
}

View File

@@ -4,5 +4,7 @@
{
void Start();
void Stop();
void Hide();
void Show();
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB

View File

@@ -38,10 +38,9 @@
this.lblCardType = new System.Windows.Forms.Label();
this.lblCardNumber = new System.Windows.Forms.Label();
this.grbCardInformation = new System.Windows.Forms.GroupBox();
this.button1 = new System.Windows.Forms.Button();
this.lblCardTime = new System.Windows.Forms.Label();
this.lblPlateString = new System.Windows.Forms.Label();
this.lblRecogizePlateStatus = new System.Windows.Forms.Label();
this.lblStatusInfo = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxPlateImage)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxPlateVideo)).BeginInit();
this.grbPlateCamera.SuspendLayout();
@@ -53,6 +52,7 @@
//
// pictureBoxPlateImage
//
this.pictureBoxPlateImage.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBoxPlateImage.Location = new System.Drawing.Point(226, 23);
this.pictureBoxPlateImage.Name = "pictureBoxPlateImage";
this.pictureBoxPlateImage.Size = new System.Drawing.Size(200, 200);
@@ -62,12 +62,17 @@
//
// pictureBoxPlateVideo
//
this.pictureBoxPlateVideo.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBoxPlateVideo.Location = new System.Drawing.Point(15, 23);
this.pictureBoxPlateVideo.Name = "pictureBoxPlateVideo";
this.pictureBoxPlateVideo.Size = new System.Drawing.Size(200, 200);
this.pictureBoxPlateVideo.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBoxPlateVideo.TabIndex = 0;
this.pictureBoxPlateVideo.TabStop = false;
this.pictureBoxPlateVideo.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBoxPlateVideo_Paint);
this.pictureBoxPlateVideo.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pictureBoxPlateVideo_MouseDown);
this.pictureBoxPlateVideo.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pictureBoxPlateVideo_MouseMove);
this.pictureBoxPlateVideo.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pictureBoxPlateVideo_MouseUp);
//
// grbPlateCamera
//
@@ -84,6 +89,7 @@
//
// pictureBoxOverviewImage
//
this.pictureBoxOverviewImage.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBoxOverviewImage.Location = new System.Drawing.Point(226, 24);
this.pictureBoxOverviewImage.Name = "pictureBoxOverviewImage";
this.pictureBoxOverviewImage.Size = new System.Drawing.Size(200, 200);
@@ -93,6 +99,7 @@
//
// pictureBoxOverviewVideo
//
this.pictureBoxOverviewVideo.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBoxOverviewVideo.Location = new System.Drawing.Point(15, 24);
this.pictureBoxOverviewVideo.Name = "pictureBoxOverviewVideo";
this.pictureBoxOverviewVideo.Size = new System.Drawing.Size(200, 200);
@@ -131,22 +138,21 @@
this.lblCardType.AutoSize = true;
this.lblCardType.Location = new System.Drawing.Point(12, 64);
this.lblCardType.Name = "lblCardType";
this.lblCardType.Size = new System.Drawing.Size(60, 18);
this.lblCardType.Size = new System.Drawing.Size(64, 18);
this.lblCardType.TabIndex = 0;
this.lblCardType.Text = "Loại thẻ";
this.lblCardType.Text = "Loại thẻ:";
//
// lblCardNumber
//
this.lblCardNumber.AutoSize = true;
this.lblCardNumber.Location = new System.Drawing.Point(12, 31);
this.lblCardNumber.Name = "lblCardNumber";
this.lblCardNumber.Size = new System.Drawing.Size(51, 18);
this.lblCardNumber.Size = new System.Drawing.Size(55, 18);
this.lblCardNumber.TabIndex = 0;
this.lblCardNumber.Text = "Số thẻ";
this.lblCardNumber.Text = "Số thẻ:";
//
// grbCardInformation
//
this.grbCardInformation.Controls.Add(this.button1);
this.grbCardInformation.Controls.Add(this.lblCardType);
this.grbCardInformation.Controls.Add(this.lblCardTime);
this.grbCardInformation.Controls.Add(this.lblPlateString);
@@ -160,52 +166,42 @@
this.grbCardInformation.TabStop = false;
this.grbCardInformation.Text = "Thông tin thẻ";
//
// button1
//
this.button1.Location = new System.Drawing.Point(360, 20);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// lblCardTime
//
this.lblCardTime.AutoSize = true;
this.lblCardTime.Location = new System.Drawing.Point(223, 64);
this.lblCardTime.Name = "lblCardTime";
this.lblCardTime.Size = new System.Drawing.Size(68, 18);
this.lblCardTime.Size = new System.Drawing.Size(72, 18);
this.lblCardTime.TabIndex = 0;
this.lblCardTime.Text = "Thời gian";
this.lblCardTime.Text = "Thời gian:";
//
// lblPlateString
//
this.lblPlateString.AutoSize = true;
this.lblPlateString.Location = new System.Drawing.Point(223, 31);
this.lblPlateString.Name = "lblPlateString";
this.lblPlateString.Size = new System.Drawing.Size(58, 18);
this.lblPlateString.Size = new System.Drawing.Size(62, 18);
this.lblPlateString.TabIndex = 0;
this.lblPlateString.Text = "Biển số";
this.lblPlateString.Text = "Biển số:";
//
// lblRecogizePlateStatus
// lblStatusInfo
//
this.lblRecogizePlateStatus.BackColor = System.Drawing.Color.CornflowerBlue;
this.lblRecogizePlateStatus.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblRecogizePlateStatus.ForeColor = System.Drawing.SystemColors.Control;
this.lblRecogizePlateStatus.Location = new System.Drawing.Point(1, 159);
this.lblRecogizePlateStatus.Margin = new System.Windows.Forms.Padding(0);
this.lblRecogizePlateStatus.Name = "lblRecogizePlateStatus";
this.lblRecogizePlateStatus.Size = new System.Drawing.Size(440, 40);
this.lblRecogizePlateStatus.TabIndex = 15;
this.lblRecogizePlateStatus.Text = "XIN CHÀO";
this.lblRecogizePlateStatus.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.lblStatusInfo.BackColor = System.Drawing.Color.CornflowerBlue;
this.lblStatusInfo.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblStatusInfo.ForeColor = System.Drawing.SystemColors.Control;
this.lblStatusInfo.Location = new System.Drawing.Point(1, 159);
this.lblStatusInfo.Margin = new System.Windows.Forms.Padding(0);
this.lblStatusInfo.Name = "lblStatusInfo";
this.lblStatusInfo.Size = new System.Drawing.Size(440, 40);
this.lblStatusInfo.TabIndex = 15;
this.lblStatusInfo.Text = "XIN CHÀO";
this.lblStatusInfo.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// LaneIn
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.lblRecogizePlateStatus);
this.Controls.Add(this.lblStatusInfo);
this.Controls.Add(this.grbPlateCamera);
this.Controls.Add(this.grbOverviewCamera);
this.Controls.Add(this.lblLaneLabel);
@@ -213,6 +209,7 @@
this.Margin = new System.Windows.Forms.Padding(0);
this.Name = "LaneIn";
this.Size = new System.Drawing.Size(442, 692);
this.Load += new System.EventHandler(this.LaneIn_Load);
((System.ComponentModel.ISupportInitialize)(this.pictureBoxPlateImage)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxPlateVideo)).EndInit();
this.grbPlateCamera.ResumeLayout(false);
@@ -238,7 +235,6 @@
private System.Windows.Forms.GroupBox grbCardInformation;
private System.Windows.Forms.Label lblPlateString;
private System.Windows.Forms.Label lblCardTime;
private System.Windows.Forms.Label lblRecogizePlateStatus;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label lblStatusInfo;
}
}

View File

@@ -1,7 +1,12 @@
using System;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Printing;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Newtonsoft.Json;
using NLog;
using OpenCvSharp;
using OpenCvSharp.Extensions;
@@ -12,145 +17,188 @@ 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;
private bool isAutoOpenDoor;
private bool isRetryMode;
private bool isRetryModeUntilOk; //TODO: Test mode
private C3DeviceController c3Device;
private IDoorControlAccess doorControlAccess;
private ApiController apiController;
private Logger appLogger;
private System.Drawing.Point StartPoint { get; set; }
private System.Drawing.Point CurrentCursorPosition { get; set; }
private Rectangle pictureBoxRoi;
private bool IsDrawBox { get; set; }
private Rect roiBoxRect;
public LaneIn(int doorId,
string cameraId,
string plateStream,
string overviewStream,
C3DeviceController c3Device,
IDoorControlAccess doorControlAccess,
ApiController apiController,
EngineApiController engineApiController,
Logger appLogger,
string roiConfig,
bool isSupportSquarePlate = true,
bool isSupportLongPlate = false,
bool isAutoOpenDoor = true,
bool isRetryMode = false,
bool isRetryModeUntilOk = false)
bool isRetryMode = false)
{
InitializeComponent();
this.doorId = doorId;
this.appLogger = appLogger;
DoorId = doorId;
this.cameraId = cameraId;
this.isSupportSquarePlate = isSupportSquarePlate;
this.isSupportLongPlate = isSupportLongPlate;
this.isAutoOpenDoor = isAutoOpenDoor;
this.isRetryMode = isRetryMode;
this.isRetryModeUntilOk = isRetryModeUntilOk;
overviewCamera = new Camera(overviewStream);
plateCamera = new Camera(plateStream);
this.c3Device = c3Device;
this.c3Device.OnNewCardReceived += C3Device_OnNewCardReceived;
plateCamera.OnVideoFrameReceived += PlateCameraOnVideoFrameReceived;
plateCamera.OnOneVideoFrameRequested += PlateCamera_OnOneVideoFrameRequested;
plateCamera.OnOpenVideoStreamFailed += PlateCamera_OnOpenVideoStreamFailed;
overviewCamera.OnVideoFrameReceived += OverviewCameraOnVideoFrameReceived;
overviewCamera.OnOneVideoFrameRequested += OverviewCamera_OnOneVideoFrameRequested;
overviewCamera.OnOpenVideoStreamFailed += OverviewCamera_OnOpenVideoStreamFailed;
plateProcessor = new PlateProcessor(this.isSupportSquarePlate, this.isSupportLongPlate);
if (!this.c3Device.Connect().HasError)
{
_ = this.c3Device.GetLogToReceiveNewCard();
}
this.apiController = apiController;
this.doorControlAccess = doorControlAccess;
plateProcessor = new PlateProcessor(engineApiController, this.isSupportSquarePlate, this.isSupportLongPlate);
this.pictureBoxRoi = Util.ConvertStringToRectangle(roiConfig);
}
private void C3Device_OnNewCardReceived(int doorId, string cardNumber)
private async void C3Device_OnNewCardReceived(int doorId, string cardNumber)
{
//Request To Capture And Process Frame.
CaptureAllCamera();
//Request Card Info
if (isAutoOpenDoor)
if (DoorId != doorId)
{
if (this.doorId == doorId)
return;
}
ClearPlateAndOverviewImage();
var cardInfoResult = await apiController.GetCardInformation(cardNumber);
if (cardInfoResult == null)
{
lblStatusInfo.UpdateLabel("KHÔNG THỂ KẾT NỐI SERVER", Color.Purple);
appLogger.Log(LogLevel.Error, $"Request thẻ cổng {doorId} vào | số thẻ : {cardNumber} | lỗi: KHÔNG THỂ KẾT NỐI TỚI SERVER");
return;
}
if (!cardInfoResult.IsValid)
{
lblStatusInfo.UpdateLabel("THẺ KHÔNG HỢP LỆ", Color.Purple);
appLogger.Log(LogLevel.Info, $"Request thẻ cổng {doorId} vào | số thẻ : {cardNumber} | lỗi: THẺ KHÔNG HỢP LỆ");
return;
}
if (cardInfoResult.Direction != "in")
{
lblStatusInfo.UpdateLabel("XE ĐÃ Ở TRONG BÃI", Color.Red);
appLogger.Log(LogLevel.Info, $"Request thẻ cổng {doorId} vào | số thẻ : {cardNumber} | lỗi: XE ĐÃ Ở TRONG BÃI");
return;
}
plateCamera.RequestCaptureOneFrame();
overviewCamera.RequestCaptureOneFrame();
await Task.Delay(200);
appLogger.Log(LogLevel.Info, $"Request thẻ cổng {doorId} vào | số thẻ : {cardNumber} | Chụp ảnh camera");
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);
var saveLogResult = await apiController.SaveLog(LaneDirection.In, cardInformation.CardRealID.ToString(), cameraId, result.PlateType, DateTime.Now.GetTimeFormatted(), result.PlateString, result.PlateImage, result.PlateImage, result.PlateImage, overviewVideoFrame);
if (saveLogResult == null)
{
lblStatusInfo.UpdateLabel("KHÔNG CÓ KẾT NỐI ĐẾN MÁY CHỦ", Color.Red);
appLogger.Log(LogLevel.Error, $"Request thẻ cổng {doorId} vào | số thẻ : {cardNumber} | lỗi: KHÔNG CÓ KẾT NỐI ĐẾN MÁY CHỦ - KHÔNG LƯU ĐƯỢC LOG");
return;
}
ShowCardInfoOnUI(cardNumber, result.PlateString, cardInformation.CardType, DateTime.Now.GetTimeFormatted());
if (saveLogResult.Status)
{
if (isAutoOpenDoor && DoorId == doorId)
{
c3Device.OpenDoor(doorId);
OpenDoor(doorId);
appLogger.Log(LogLevel.Info, $"Request thẻ cổng {doorId} vào | số thẻ : {cardNumber} | biển số: {result.PlateString} | Đã mở cửa");
}
}
else
{
appLogger.Log(LogLevel.Error, $"Request thẻ cổng {doorId} vào | số thẻ : {cardNumber} | lỗi: LƯU BẢN GHI LỖI");
lblStatusInfo.UpdateLabel("LƯU BẢN GHI LỖI", Color.Red);
}
}
private void PlateCamera_OnOpenVideoStreamFailed(Mat videoFrame)
{
pictureBoxPlateVideo.Invoke(new Action(() =>
{
pictureBoxPlateVideo.Image?.Dispose();
pictureBoxPlateVideo.Image = videoFrame.ToBitmap();
}));
pictureBoxPlateVideo.UpdateImage(videoFrame.ToBitmap());
}
private void OverviewCamera_OnOpenVideoStreamFailed(Mat videoFrame)
{
pictureBoxOverviewVideo.Invoke(new Action(() =>
{
pictureBoxOverviewImage.Image?.Dispose();
pictureBoxOverviewVideo.Image = videoFrame.ToBitmap();
}));
pictureBoxOverviewVideo.UpdateImage(videoFrame.ToBitmap());
}
private void OverviewCamera_OnOneVideoFrameRequested(Mat videoFrame)
private void ClearPlateAndOverviewImage()
{
pictureBoxPlateImage.UpdateImage(null);
pictureBoxOverviewImage.UpdateImage(null);
}
private void OpenDoor(int doorId)
{
if (doorControlAccess.OpenDoor(doorId).HasError)
{
lblStatusInfo.UpdateLabel("KHÔNG THỂ MỞ CỬA", Color.Red);
}
}
private async Task<FinalPlateResult> ProcessFrameImage(PlateProcessor plateProcessor, Mat frame, bool isRetryMode)
{
var starTime = DateTime.Now;
Cv2.Resize(frame, frame, new OpenCvSharp.Size(1280, 720));
roiBoxRect = Util.ConvertRectangleToRect(pictureBoxRoi, pictureBoxPlateVideo);
Mat frameRoi = frame[roiBoxRect];
try
{
pictureBoxOverviewImage.Invoke(new Action(() =>
FinalPlateResult finalPlateResult = await plateProcessor.ProcessPlate(frameRoi);
if (isRetryMode && !plateProcessor.IsPlateStringValid(finalPlateResult.PlateString))
{
pictureBoxOverviewImage.Image?.Dispose();
pictureBoxOverviewImage.Image = videoFrame.ToBitmap();
}));
Thread.Sleep(1000);
overviewCamera.RequestCaptureOneFrame();
finalPlateResult = await plateProcessor.ProcessPlate(frameRoi);
Console.WriteLine("ProcessFrameImage Retry Mode");
}
appLogger.Log(LogLevel.Info, $"ProcessFrameImage: {(DateTime.Now - starTime).TotalMilliseconds} ms");
return finalPlateResult;
}
catch (Exception ex)
{
Console.WriteLine($"{Util.GetCurrentMethodName()}\texMessage: {ex.Message}");
Console.WriteLine($"ProcessFrameImage\texMessage: {ex.Message}");
appLogger.Log(LogLevel.Info, $"ProcessFrameImage: ex: {ex.Message}");
return new FinalPlateResult
{
PlateImage = frameRoi,
PlateString = string.Empty,
PlateType = PlateType.Square
};
}
}
private void PlateCamera_OnOneVideoFrameRequested(Mat videoFrame)
{
Task.Factory.StartNew(new Action(async () =>
{
try
{
//TODO: check size before resizing
Cv2.Resize(videoFrame, videoFrame, new Size(1280, 720));
FinalPlateResult finalPlateResult = await plateProcessor.ProcessPlate(videoFrame);
if (isRetryMode && !plateProcessor.IsPlateStringValid(finalPlateResult.PlateString))
{
if (isRetryModeUntilOk) //TODO: TestMode
{
Thread.Sleep(500);
CaptureAllCamera();
}
else
{
Console.WriteLine("PlateCamera_OnOneVideoFrameRequested Retry Mode");
Thread.Sleep(1000);
overviewCamera.RequestCaptureOneFrame();
finalPlateResult = await plateProcessor.ProcessPlate(videoFrame);
}
}
pictureBoxPlateImage.Invoke(new Action(() =>
{
pictureBoxPlateImage.Image?.Dispose();
pictureBoxPlateImage.Image = finalPlateResult.PlateImage;
}));
ShowCardInfoOnUI("224", finalPlateResult.PlateString, "Thẻ tháng", DateTime.Now.ToString(AppConstant.DATETIME_FORMAT));
}
catch (Exception ex)
{
Console.WriteLine($"PlateCamera_OnOneVideoFrameRequested\texMessage: {ex.Message}");
}
}));
}
public void Stop()
{
plateCamera.Stop();
overviewCamera.Stop();
pictureBoxPlateImage.UpdateImage(null);
pictureBoxPlateVideo.UpdateImage(null);
pictureBoxOverviewImage.UpdateImage(null);
pictureBoxOverviewVideo.UpdateImage(null);
}
public void Start()
@@ -161,74 +209,83 @@ namespace AIParkingApplication
private void ShowCardInfoOnUI(string cardNumber, string plateString, string cardType, string cardTime)
{
lblCardNumber.Invoke(new Action(() =>
{
lblCardNumber.Text = $"Số thẻ: {cardNumber}";
}));
lblPlateString.Invoke(new Action(() =>
{
lblPlateString.Text = $"Biển số: {plateString}";
}));
lblCardType.Invoke(new Action(() =>
{
lblCardType.Text = $"Loại thẻ: {cardType}";
}));
lblCardTime.Invoke(new Action(() =>
{
lblCardTime.Text = $"Thời gian: {cardTime}";
}));
lblRecogizePlateStatus.Invoke(new Action(() =>
{
lblRecogizePlateStatus.Text = string.IsNullOrEmpty(plateString) ? "KHÔNG NHẬN DIỆN ĐƯỢC BIỂN SỐ" : $"MỜI XE {plateString} VÀO";
lblRecogizePlateStatus.BackColor = string.IsNullOrEmpty(plateString) ? System.Drawing.Color.Red : System.Drawing.Color.Green;
}));
lblCardNumber.UpdateLabel($"Số thẻ: {cardNumber}");
lblPlateString.UpdateLabel($"Biển số: {plateString}");
lblCardType.UpdateLabel($"Loại thẻ: {cardType}");
lblCardTime.UpdateLabel($"Thời gian: {cardTime}");
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);
}
private void OverviewCameraOnVideoFrameReceived(Mat videoFrame)
{
try
{
pictureBoxOverviewVideo.Invoke(new Action(() =>
{
pictureBoxOverviewVideo.Image?.Dispose();
pictureBoxOverviewVideo.Image = videoFrame.ToBitmap();
}));
}
catch (Exception ex)
{
Console.WriteLine($"{Util.GetCurrentMethodName()}\texMessage: {ex.Message}");
}
pictureBoxOverviewVideo.UpdateImage(videoFrame.ToBitmap());
}
private void PlateCameraOnVideoFrameReceived(Mat videoFrame)
{
try
pictureBoxPlateVideo.UpdateImage(videoFrame.ToBitmap());
}
private void ConnectToDoorAccessControl()
{
if (!doorControlAccess.Connect().HasError)
{
pictureBoxPlateVideo.Invoke(new Action(() =>
{
pictureBoxPlateVideo.Image?.Dispose();
pictureBoxPlateVideo.Image = videoFrame.ToBitmap();
}));
_ = doorControlAccess.GetLogToReceiveNewCard();
}
catch (Exception ex)
else
{
Console.WriteLine($"{Util.GetCurrentMethodName()}\texMessage: {ex.Message}");
lblStatusInfo.UpdateLabel("KHÔNG THỂ KẾT NỐI TỚI C3200", Color.Purple);
}
}
private void CaptureAllCamera()
private void LaneIn_Load(object sender, EventArgs e)
{
plateCamera.RequestCaptureOneFrame();
overviewCamera.RequestCaptureOneFrame();
doorControlAccess.OnNewCardReceived += C3Device_OnNewCardReceived;
plateCamera.OnVideoFrameReceived += PlateCameraOnVideoFrameReceived;
plateCamera.OnOpenVideoStreamFailed += PlateCamera_OnOpenVideoStreamFailed;
overviewCamera.OnVideoFrameReceived += OverviewCameraOnVideoFrameReceived;
overviewCamera.OnOpenVideoStreamFailed += OverviewCamera_OnOpenVideoStreamFailed;
ConnectToDoorAccessControl();
}
private void button1_Click(object sender, EventArgs e)
private void pictureBoxPlateVideo_MouseDown(object sender, MouseEventArgs e)
{
CaptureAllCamera();
if (e.Button == MouseButtons.Left)
{
StartPoint = e.Location;
pictureBoxRoi = new Rectangle(StartPoint, new System.Drawing.Size(0, 0));
IsDrawBox = true;
}
}
private void pictureBoxPlateVideo_MouseMove(object sender, MouseEventArgs e)
{
if (IsDrawBox)
{
CurrentCursorPosition = e.Location;
pictureBoxRoi.Width = CurrentCursorPosition.X - StartPoint.X;
pictureBoxRoi.Height = CurrentCursorPosition.Y - StartPoint.Y;
}
Refresh();
}
private void pictureBoxPlateVideo_MouseUp(object sender, MouseEventArgs e)
{
IsDrawBox = false;
if (StartPoint.X + pictureBoxRoi.Width > pictureBoxPlateVideo.Width || StartPoint.Y + pictureBoxRoi.Height > pictureBoxPlateVideo.Height)
{
pictureBoxRoi.X = pictureBoxRoi.Y = 0;
pictureBoxRoi.Width = pictureBoxPlateVideo.Width;
pictureBoxRoi.Height = pictureBoxPlateVideo.Height;
}
apiController.SaveRoiToServer(pictureBoxRoi, cameraId);
}
private void pictureBoxPlateVideo_Paint(object sender, PaintEventArgs e)
{
Pen redPen = new Pen(Color.FromArgb(255, 255, 0, 0), 3);
e.Graphics.DrawRectangle(redPen, pictureBoxRoi);
}
}
}
}

View File

@@ -147,7 +147,10 @@
<metadata name="grbCardInformation.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="button1.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="lblCardTime.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="lblPlateString.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="lblCardTime.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
@@ -156,16 +159,7 @@
<metadata name="lblPlateString.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="button1.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="lblCardTime.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="lblPlateString.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="lblRecogizePlateStatus.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="lblStatusInfo.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">

View File

@@ -29,212 +29,282 @@
private void InitializeComponent()
{
this.grbPlateRefernce = new System.Windows.Forms.GroupBox();
this.pictureBox6 = new System.Windows.Forms.PictureBox();
this.pictureBox5 = new System.Windows.Forms.PictureBox();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.grbPlateCamera = new System.Windows.Forms.GroupBox();
this.backgroundWorker2 = new System.ComponentModel.BackgroundWorker();
this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
this.lblMoneyAmount = new System.Windows.Forms.Label();
this.lblCardType = new System.Windows.Forms.Label();
this.pictureBoxOverviewImageIn = new System.Windows.Forms.PictureBox();
this.pictureBoxPlateImageIn = new System.Windows.Forms.PictureBox();
this.grbCardInformation = new System.Windows.Forms.GroupBox();
this.lblLaneLabel = new System.Windows.Forms.Label();
this.pictureBox4 = new System.Windows.Forms.PictureBox();
this.pictureBox3 = new System.Windows.Forms.PictureBox();
this.grbOverviewCamera = new System.Windows.Forms.GroupBox();
this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.lblCardType = new System.Windows.Forms.Label();
this.lblCardTimeOut = new System.Windows.Forms.Label();
this.lblCardTime = new System.Windows.Forms.Label();
this.lblMoneyAmount = new System.Windows.Forms.Label();
this.lblPlateString = new System.Windows.Forms.Label();
this.lblCardNumber = new System.Windows.Forms.Label();
this.pictureBoxPlateImage = new System.Windows.Forms.PictureBox();
this.pictureBoxPlateVideo = new System.Windows.Forms.PictureBox();
this.grbPlateCamera = new System.Windows.Forms.GroupBox();
this.pictureBoxOverviewImage = new System.Windows.Forms.PictureBox();
this.pictureBoxOverviewVideo = new System.Windows.Forms.PictureBox();
this.grbOverviewCamera = new System.Windows.Forms.GroupBox();
this.lblLaneLabel = new System.Windows.Forms.Label();
this.lblStatusInfo = new System.Windows.Forms.Label();
this.grbPlateRefernce.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox6)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox5)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.grbPlateCamera.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxOverviewImageIn)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxPlateImageIn)).BeginInit();
this.grbCardInformation.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox4)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxPlateImage)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxPlateVideo)).BeginInit();
this.grbPlateCamera.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxOverviewImage)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxOverviewVideo)).BeginInit();
this.grbOverviewCamera.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
this.SuspendLayout();
//
// grbPlateRefernce
//
this.grbPlateRefernce.Controls.Add(this.pictureBox6);
this.grbPlateRefernce.Controls.Add(this.pictureBox5);
this.grbPlateRefernce.Controls.Add(this.pictureBoxOverviewImageIn);
this.grbPlateRefernce.Controls.Add(this.pictureBoxPlateImageIn);
this.grbPlateRefernce.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.grbPlateRefernce.Location = new System.Drawing.Point(445, 171);
this.grbPlateRefernce.Location = new System.Drawing.Point(453, 208);
this.grbPlateRefernce.Name = "grbPlateRefernce";
this.grbPlateRefernce.Size = new System.Drawing.Size(212, 510);
this.grbPlateRefernce.Size = new System.Drawing.Size(226, 484);
this.grbPlateRefernce.TabIndex = 9;
this.grbPlateRefernce.TabStop = false;
this.grbPlateRefernce.Text = "THAM CHIẾU BIỂN SỐ VÀO";
this.grbPlateRefernce.Text = "Tham chiếu vào";
//
// pictureBox6
// pictureBoxOverviewImageIn
//
this.pictureBox6.Location = new System.Drawing.Point(6, 296);
this.pictureBox6.Name = "pictureBox6";
this.pictureBox6.Size = new System.Drawing.Size(200, 200);
this.pictureBox6.TabIndex = 0;
this.pictureBox6.TabStop = false;
this.pictureBoxOverviewImageIn.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.pictureBoxOverviewImageIn.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBoxOverviewImageIn.Location = new System.Drawing.Point(13, 270);
this.pictureBoxOverviewImageIn.Name = "pictureBoxOverviewImageIn";
this.pictureBoxOverviewImageIn.Size = new System.Drawing.Size(200, 200);
this.pictureBoxOverviewImageIn.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBoxOverviewImageIn.TabIndex = 0;
this.pictureBoxOverviewImageIn.TabStop = false;
//
// pictureBox5
// pictureBoxPlateImageIn
//
this.pictureBox5.Location = new System.Drawing.Point(6, 23);
this.pictureBox5.Name = "pictureBox5";
this.pictureBox5.Size = new System.Drawing.Size(200, 200);
this.pictureBox5.TabIndex = 0;
this.pictureBox5.TabStop = false;
//
// pictureBox1
//
this.pictureBox1.Location = new System.Drawing.Point(212, 23);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(200, 200);
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// grbPlateCamera
//
this.grbPlateCamera.Controls.Add(this.pictureBox1);
this.grbPlateCamera.Controls.Add(this.pictureBox2);
this.grbPlateCamera.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.grbPlateCamera.Location = new System.Drawing.Point(15, 171);
this.grbPlateCamera.Name = "grbPlateCamera";
this.grbPlateCamera.Size = new System.Drawing.Size(424, 238);
this.grbPlateCamera.TabIndex = 7;
this.grbPlateCamera.TabStop = false;
this.grbPlateCamera.Text = "CAMERA BIỂN SỐ";
//
// lblMoneyAmount
//
this.lblMoneyAmount.AutoSize = true;
this.lblMoneyAmount.Location = new System.Drawing.Point(209, 31);
this.lblMoneyAmount.Name = "lblMoneyAmount";
this.lblMoneyAmount.Size = new System.Drawing.Size(54, 18);
this.lblMoneyAmount.TabIndex = 0;
this.lblMoneyAmount.Text = "Số tiền";
//
// lblCardType
//
this.lblCardType.AutoSize = true;
this.lblCardType.Location = new System.Drawing.Point(12, 59);
this.lblCardType.Name = "lblCardType";
this.lblCardType.Size = new System.Drawing.Size(60, 18);
this.lblCardType.TabIndex = 0;
this.lblCardType.Text = "Loại thẻ";
this.pictureBoxPlateImageIn.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.pictureBoxPlateImageIn.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBoxPlateImageIn.Location = new System.Drawing.Point(13, 23);
this.pictureBoxPlateImageIn.Name = "pictureBoxPlateImageIn";
this.pictureBoxPlateImageIn.Size = new System.Drawing.Size(200, 200);
this.pictureBoxPlateImageIn.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBoxPlateImageIn.TabIndex = 0;
this.pictureBoxPlateImageIn.TabStop = false;
//
// grbCardInformation
//
this.grbCardInformation.Controls.Add(this.lblCardType);
this.grbCardInformation.Controls.Add(this.lblCardTimeOut);
this.grbCardInformation.Controls.Add(this.lblCardTime);
this.grbCardInformation.Controls.Add(this.lblMoneyAmount);
this.grbCardInformation.Controls.Add(this.lblPlateString);
this.grbCardInformation.Controls.Add(this.lblCardNumber);
this.grbCardInformation.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.grbCardInformation.Location = new System.Drawing.Point(15, 69);
this.grbCardInformation.Location = new System.Drawing.Point(1, 55);
this.grbCardInformation.Margin = new System.Windows.Forms.Padding(0);
this.grbCardInformation.Name = "grbCardInformation";
this.grbCardInformation.Size = new System.Drawing.Size(642, 91);
this.grbCardInformation.TabIndex = 8;
this.grbCardInformation.Size = new System.Drawing.Size(678, 104);
this.grbCardInformation.TabIndex = 19;
this.grbCardInformation.TabStop = false;
this.grbCardInformation.Text = "THÔNG TIN THẺ";
this.grbCardInformation.Text = "Thông tin thẻ";
//
// lblLaneLabel
// lblCardType
//
this.lblLaneLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.lblLaneLabel.AutoSize = true;
this.lblLaneLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 26.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblLaneLabel.Location = new System.Drawing.Point(262, 22);
this.lblLaneLabel.Name = "lblLaneLabel";
this.lblLaneLabel.Size = new System.Drawing.Size(141, 39);
this.lblLaneLabel.TabIndex = 5;
this.lblLaneLabel.Text = "LÀN RA";
this.lblCardType.AutoSize = true;
this.lblCardType.Location = new System.Drawing.Point(12, 64);
this.lblCardType.Name = "lblCardType";
this.lblCardType.Size = new System.Drawing.Size(64, 18);
this.lblCardType.TabIndex = 0;
this.lblCardType.Text = "Loại thẻ:";
//
// pictureBox4
// lblCardTimeOut
//
this.pictureBox4.Location = new System.Drawing.Point(6, 24);
this.pictureBox4.Name = "pictureBox4";
this.pictureBox4.Size = new System.Drawing.Size(200, 200);
this.pictureBox4.TabIndex = 0;
this.pictureBox4.TabStop = false;
this.lblCardTimeOut.AutoSize = true;
this.lblCardTimeOut.Location = new System.Drawing.Point(462, 64);
this.lblCardTimeOut.Name = "lblCardTimeOut";
this.lblCardTimeOut.Size = new System.Drawing.Size(31, 18);
this.lblCardTimeOut.TabIndex = 0;
this.lblCardTimeOut.Text = "Ra:";
//
// pictureBox3
// lblCardTime
//
this.pictureBox3.Location = new System.Drawing.Point(212, 24);
this.pictureBox3.Name = "pictureBox3";
this.pictureBox3.Size = new System.Drawing.Size(200, 200);
this.pictureBox3.TabIndex = 0;
this.pictureBox3.TabStop = false;
this.lblCardTime.AutoSize = true;
this.lblCardTime.Location = new System.Drawing.Point(223, 64);
this.lblCardTime.Name = "lblCardTime";
this.lblCardTime.Size = new System.Drawing.Size(38, 18);
this.lblCardTime.TabIndex = 0;
this.lblCardTime.Text = "Vào:";
//
// grbOverviewCamera
// lblMoneyAmount
//
this.grbOverviewCamera.Controls.Add(this.pictureBox3);
this.grbOverviewCamera.Controls.Add(this.pictureBox4);
this.grbOverviewCamera.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.grbOverviewCamera.Location = new System.Drawing.Point(15, 443);
this.grbOverviewCamera.Name = "grbOverviewCamera";
this.grbOverviewCamera.Size = new System.Drawing.Size(424, 238);
this.grbOverviewCamera.TabIndex = 6;
this.grbOverviewCamera.TabStop = false;
this.grbOverviewCamera.Text = "CAMERA TOÀN CẢNH";
this.lblMoneyAmount.AutoSize = true;
this.lblMoneyAmount.Location = new System.Drawing.Point(462, 31);
this.lblMoneyAmount.Name = "lblMoneyAmount";
this.lblMoneyAmount.Size = new System.Drawing.Size(58, 18);
this.lblMoneyAmount.TabIndex = 0;
this.lblMoneyAmount.Text = "Số tiền:";
//
// pictureBox2
// lblPlateString
//
this.pictureBox2.Location = new System.Drawing.Point(6, 23);
this.pictureBox2.Name = "pictureBox2";
this.pictureBox2.Size = new System.Drawing.Size(200, 200);
this.pictureBox2.TabIndex = 0;
this.pictureBox2.TabStop = false;
this.lblPlateString.AutoSize = true;
this.lblPlateString.Location = new System.Drawing.Point(223, 31);
this.lblPlateString.Name = "lblPlateString";
this.lblPlateString.Size = new System.Drawing.Size(62, 18);
this.lblPlateString.TabIndex = 0;
this.lblPlateString.Text = "Biển số:";
//
// lblCardNumber
//
this.lblCardNumber.AutoSize = true;
this.lblCardNumber.Location = new System.Drawing.Point(12, 31);
this.lblCardNumber.Name = "lblCardNumber";
this.lblCardNumber.Size = new System.Drawing.Size(51, 18);
this.lblCardNumber.Size = new System.Drawing.Size(55, 18);
this.lblCardNumber.TabIndex = 0;
this.lblCardNumber.Text = "Số thẻ";
this.lblCardNumber.Text = "Số thẻ:";
//
// pictureBoxPlateImage
//
this.pictureBoxPlateImage.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBoxPlateImage.Location = new System.Drawing.Point(226, 23);
this.pictureBoxPlateImage.Name = "pictureBoxPlateImage";
this.pictureBoxPlateImage.Size = new System.Drawing.Size(200, 200);
this.pictureBoxPlateImage.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBoxPlateImage.TabIndex = 0;
this.pictureBoxPlateImage.TabStop = false;
//
// pictureBoxPlateVideo
//
this.pictureBoxPlateVideo.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBoxPlateVideo.Location = new System.Drawing.Point(15, 23);
this.pictureBoxPlateVideo.Name = "pictureBoxPlateVideo";
this.pictureBoxPlateVideo.Size = new System.Drawing.Size(200, 200);
this.pictureBoxPlateVideo.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBoxPlateVideo.TabIndex = 0;
this.pictureBoxPlateVideo.TabStop = false;
this.pictureBoxPlateVideo.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBoxPlateVideo_Paint);
this.pictureBoxPlateVideo.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pictureBoxPlateVideo_MouseDown);
this.pictureBoxPlateVideo.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pictureBoxPlateVideo_MouseMove);
this.pictureBoxPlateVideo.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pictureBoxPlateVideo_MouseUp);
//
// grbPlateCamera
//
this.grbPlateCamera.Controls.Add(this.pictureBoxPlateImage);
this.grbPlateCamera.Controls.Add(this.pictureBoxPlateVideo);
this.grbPlateCamera.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.grbPlateCamera.Location = new System.Drawing.Point(1, 208);
this.grbPlateCamera.Margin = new System.Windows.Forms.Padding(0);
this.grbPlateCamera.Name = "grbPlateCamera";
this.grbPlateCamera.Size = new System.Drawing.Size(439, 238);
this.grbPlateCamera.TabIndex = 18;
this.grbPlateCamera.TabStop = false;
this.grbPlateCamera.Text = "Camera biển số";
//
// pictureBoxOverviewImage
//
this.pictureBoxOverviewImage.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBoxOverviewImage.Location = new System.Drawing.Point(226, 24);
this.pictureBoxOverviewImage.Name = "pictureBoxOverviewImage";
this.pictureBoxOverviewImage.Size = new System.Drawing.Size(200, 200);
this.pictureBoxOverviewImage.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBoxOverviewImage.TabIndex = 0;
this.pictureBoxOverviewImage.TabStop = false;
//
// pictureBoxOverviewVideo
//
this.pictureBoxOverviewVideo.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBoxOverviewVideo.Location = new System.Drawing.Point(15, 24);
this.pictureBoxOverviewVideo.Name = "pictureBoxOverviewVideo";
this.pictureBoxOverviewVideo.Size = new System.Drawing.Size(200, 200);
this.pictureBoxOverviewVideo.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBoxOverviewVideo.TabIndex = 0;
this.pictureBoxOverviewVideo.TabStop = false;
//
// grbOverviewCamera
//
this.grbOverviewCamera.Controls.Add(this.pictureBoxOverviewImage);
this.grbOverviewCamera.Controls.Add(this.pictureBoxOverviewVideo);
this.grbOverviewCamera.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.grbOverviewCamera.Location = new System.Drawing.Point(1, 454);
this.grbOverviewCamera.Margin = new System.Windows.Forms.Padding(0);
this.grbOverviewCamera.Name = "grbOverviewCamera";
this.grbOverviewCamera.Size = new System.Drawing.Size(439, 238);
this.grbOverviewCamera.TabIndex = 17;
this.grbOverviewCamera.TabStop = false;
this.grbOverviewCamera.Text = "Camera toàn cảnh";
//
// lblLaneLabel
//
this.lblLaneLabel.BackColor = System.Drawing.Color.Red;
this.lblLaneLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 26.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblLaneLabel.ForeColor = System.Drawing.SystemColors.Control;
this.lblLaneLabel.Location = new System.Drawing.Point(1, 1);
this.lblLaneLabel.Margin = new System.Windows.Forms.Padding(0);
this.lblLaneLabel.Name = "lblLaneLabel";
this.lblLaneLabel.Size = new System.Drawing.Size(678, 50);
this.lblLaneLabel.TabIndex = 16;
this.lblLaneLabel.Text = "LÀN RA";
this.lblLaneLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// lblStatusInfo
//
this.lblStatusInfo.BackColor = System.Drawing.Color.CornflowerBlue;
this.lblStatusInfo.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblStatusInfo.ForeColor = System.Drawing.SystemColors.Control;
this.lblStatusInfo.Location = new System.Drawing.Point(1, 159);
this.lblStatusInfo.Margin = new System.Windows.Forms.Padding(0);
this.lblStatusInfo.Name = "lblStatusInfo";
this.lblStatusInfo.Size = new System.Drawing.Size(678, 40);
this.lblStatusInfo.TabIndex = 20;
this.lblStatusInfo.Text = "XIN CHÀO";
this.lblStatusInfo.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// LaneOut
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.grbPlateRefernce);
this.Controls.Add(this.grbCardInformation);
this.Controls.Add(this.lblLaneLabel);
this.Controls.Add(this.grbOverviewCamera);
this.Controls.Add(this.grbPlateCamera);
this.Controls.Add(this.grbOverviewCamera);
this.Controls.Add(this.lblLaneLabel);
this.Controls.Add(this.lblStatusInfo);
this.Controls.Add(this.grbPlateRefernce);
this.Name = "LaneOut";
this.Size = new System.Drawing.Size(671, 694);
this.Size = new System.Drawing.Size(680, 692);
this.Load += new System.EventHandler(this.LaneOut_Load);
this.grbPlateRefernce.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox6)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox5)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.grbPlateCamera.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBoxOverviewImageIn)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxPlateImageIn)).EndInit();
this.grbCardInformation.ResumeLayout(false);
this.grbCardInformation.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox4)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxPlateImage)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxPlateVideo)).EndInit();
this.grbPlateCamera.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBoxOverviewImage)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxOverviewVideo)).EndInit();
this.grbOverviewCamera.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.GroupBox grbPlateRefernce;
private System.Windows.Forms.PictureBox pictureBox6;
private System.Windows.Forms.PictureBox pictureBox5;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.GroupBox grbPlateCamera;
private System.Windows.Forms.PictureBox pictureBox2;
private System.ComponentModel.BackgroundWorker backgroundWorker2;
private System.ComponentModel.BackgroundWorker backgroundWorker1;
private System.Windows.Forms.Label lblMoneyAmount;
private System.Windows.Forms.Label lblCardType;
private System.Windows.Forms.PictureBox pictureBoxOverviewImageIn;
private System.Windows.Forms.PictureBox pictureBoxPlateImageIn;
private System.Windows.Forms.GroupBox grbCardInformation;
private System.Windows.Forms.Label lblCardType;
private System.Windows.Forms.Label lblCardTime;
private System.Windows.Forms.Label lblPlateString;
private System.Windows.Forms.Label lblCardNumber;
private System.Windows.Forms.Label lblLaneLabel;
private System.Windows.Forms.PictureBox pictureBox4;
private System.Windows.Forms.PictureBox pictureBox3;
private System.Windows.Forms.PictureBox pictureBoxPlateImage;
private System.Windows.Forms.PictureBox pictureBoxPlateVideo;
private System.Windows.Forms.GroupBox grbPlateCamera;
private System.Windows.Forms.PictureBox pictureBoxOverviewImage;
private System.Windows.Forms.PictureBox pictureBoxOverviewVideo;
private System.Windows.Forms.GroupBox grbOverviewCamera;
private System.Windows.Forms.Label lblLaneLabel;
private System.Windows.Forms.Label lblStatusInfo;
private System.Windows.Forms.Label lblMoneyAmount;
private System.Windows.Forms.Label lblCardTimeOut;
}
}

View File

@@ -1,20 +1,369 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using NLog;
using OpenCvSharp;
using OpenCvSharp.Extensions;
namespace AIParkingApplication
{
public partial class LaneOut : UserControl
public partial class LaneOut : UserControl, ILane
{
public LaneOut()
private Camera overviewCamera;
private Camera plateCamera;
private PlateProcessor plateProcessor;
public int DoorId { get; set; }
private string cameraId;
private bool isSupportSquarePlate;
private bool isSupportLongPlate;
private bool isAutoOpenDoor;
private bool isRetryMode;
private IDoorControlAccess doorControlAccess;
private ApiController apiController;
private Printer printer;
private Logger appLogger;
private bool isUsePrinter;
private System.Drawing.Point StartPoint { get; set; }
private System.Drawing.Point CurrentCursorPosition { get; set; }
private Rectangle pictureBoxRoi;
private bool IsDrawBox { get; set; }
private Rect roiBoxRect;
public LaneOut(int doorId,
string cameraId,
string plateStream,
string overviewStream,
IDoorControlAccess doorControlAccess,
ApiController apiController,
EngineApiController engineApiController,
Logger appLogger,
string roiConfig,
bool isSupportSquarePlate = true,
bool isSupportLongPlate = false,
bool isAutoOpenDoor = true,
bool isRetryMode = false)
{
InitializeComponent();
this.appLogger = appLogger;
DoorId = doorId;
this.cameraId = cameraId;
this.isSupportSquarePlate = isSupportSquarePlate;
this.isSupportLongPlate = isSupportLongPlate;
this.isAutoOpenDoor = isAutoOpenDoor;
this.isRetryMode = isRetryMode;
overviewCamera = new Camera(overviewStream);
plateCamera = new Camera(plateStream);
this.apiController = apiController;
this.doorControlAccess = doorControlAccess;
printer = new Printer(appLogger);
plateProcessor = new PlateProcessor(engineApiController, this.isSupportSquarePlate, this.isSupportLongPlate);
ReadUsePrinterConfig();
this.pictureBoxRoi = Util.ConvertStringToRectangle(roiConfig);
}
private async void C3Device_OnNewCardReceived(int doorId, string cardNumber)
{
if (DoorId != doorId)
{
return;
}
ClearPlateAndOverviewImage();
ClearPlateAndOverviewImageIn();
var cardInfoResult = await apiController.GetCardInformation(cardNumber);
if (cardInfoResult == null)
{
lblStatusInfo.UpdateLabel("KHÔNG THỂ KẾT NỐI SERVER", Color.Purple);
appLogger.Log(LogLevel.Error, $"Request thẻ cổng {doorId} ra | số thẻ : {cardNumber} | lỗi: KHÔNG THỂ KẾT NỐI TỚI SERVER");
return;
}
if (!cardInfoResult.IsValid)
{
lblStatusInfo.UpdateLabel("THẺ KHÔNG HỢP LỆ", Color.Purple);
appLogger.Log(LogLevel.Info, $"Request thẻ cổng {doorId} ra | số thẻ : {cardNumber} | lỗi: THẺ KHÔNG HỢP LỆ");
return;
}
if (cardInfoResult.Direction != "out")
{
lblStatusInfo.UpdateLabel("CHƯA NHẬN THẺ VÀO", Color.Red);
appLogger.Log(LogLevel.Info, $"Request thẻ cổng {doorId} ra | số thẻ : {cardNumber} | lỗi: CHƯA NHẬN THẺ VÀO");
return;
}
Bitmap plateImageIn = Util.ConvertFromBase64Image(cardInfoResult.PlateImageBase64);
Bitmap overviewImageIn = Util.ConvertFromBase64Image(cardInfoResult.FrameImageBase64);
pictureBoxPlateImageIn.UpdateImage(plateImageIn);
pictureBoxOverviewImageIn.UpdateImage(overviewImageIn);
plateCamera.RequestCaptureOneFrame();
overviewCamera.RequestCaptureOneFrame();
await Task.Delay(200);
appLogger.Log(LogLevel.Info, $"Request thẻ cổng {doorId} ra | số thẻ : {cardNumber} | Chụp ảnh camera");
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);
var saveLogResult = await apiController.SaveLog(LaneDirection.Out, cardInformation.CardRealID.ToString(), cameraId, result.PlateType, DateTime.Now.GetTimeFormatted(), result.PlateString, result.PlateImage, result.PlateImage, result.PlateImage, overviewVideoFrame, cardInformation.LogID.ToString());
if (saveLogResult == null)
{
lblStatusInfo.UpdateLabel("KHÔNG CÓ KẾT NỐI ĐẾN MÁY CHỦ", Color.Red);
appLogger.Log(LogLevel.Error, $"Request thẻ cổng {doorId} ra | số thẻ : {cardNumber} | lỗi: KHÔNG CÓ KẾT NỐI ĐẾN MÁY CHỦ - KHÔNG LƯU ĐƯỢC LOG");
return;
}
ShowCardInfoOnUI(cardNumber, result.PlateString, cardInformation.PlateString, cardInformation.CardType, cardInformation.TimeIn, DateTime.Now.GetTimeFormatted(), saveLogResult.Cost);
if (saveLogResult.Status)
{
if (isAutoOpenDoor)
{
OpenDoor(doorId);
appLogger.Log(LogLevel.Info, $"Request thẻ cổng {doorId} ra | số thẻ : {cardNumber} | biển số: {result.PlateString} | Đã mở cửa");
}
if (isUsePrinter)
{
PrinterData printerData = new PrinterData
{
PlateString = result.PlateString,
MoneyAmount = saveLogResult.Cost,
TimeParkingIn = cardInformation.TimeIn,
TimeParkingOut = DateTime.Now.GetTimeFormatted()
};
printer.DoPrint(printerData);
}
}
else
{
appLogger.Log(LogLevel.Error, $"Request thẻ cổng {doorId} ra | số thẻ : {cardNumber} | lỗi: LƯU BẢN GHI LỖI");
lblStatusInfo.UpdateLabel("LƯU BẢN GHI LỖI", Color.Red);
}
}
private void ReadUsePrinterConfig()
{
try
{
bool.TryParse(ConfigurationManager.AppSettings[AppConstant.USE_PRINTER], out isUsePrinter);
}
catch (Exception ex)
{
Util.UpsertAppSettings(AppConstant.USE_PRINTER, "false");
appLogger.Log(LogLevel.Error, $"Không thể đọc cấu hình: {AppConstant.USE_PRINTER}. ex: {ex.Message }");
}
}
private void PlateCamera_OnOpenVideoStreamFailed(Mat videoFrame)
{
pictureBoxPlateVideo.UpdateImage(videoFrame.ToBitmap());
}
private void OverviewCamera_OnOpenVideoStreamFailed(Mat videoFrame)
{
pictureBoxOverviewVideo.UpdateImage(videoFrame.ToBitmap());
}
private void ClearPlateAndOverviewImage()
{
pictureBoxPlateImage.UpdateImage(null);
pictureBoxOverviewImage.UpdateImage(null);
}
private void ClearPlateAndOverviewImageIn()
{
pictureBoxPlateImageIn.UpdateImage(null);
pictureBoxOverviewImageIn.UpdateImage(null);
}
private void OpenDoor(int doorId)
{
var openDoorResult = doorControlAccess.OpenDoor(doorId);
if (openDoorResult.HasError)
{
lblStatusInfo.UpdateLabel("KHÔNG THỂ MỞ CỬA", Color.Red);
appLogger.Log(LogLevel.Error, $"Không thể mở cửa {doorId}. Lỗi: {openDoorResult.Message}");
}
}
private async Task<FinalPlateResult> ProcessFrameImage(PlateProcessor plateProcessor, Mat frame, bool isRetryMode)
{
var starTime = DateTime.Now;
Cv2.Resize(frame, frame, new OpenCvSharp.Size(1280, 720));
Rect roiBoxRect = Util.ConvertRectangleToRect(pictureBoxRoi, pictureBoxPlateVideo);
Mat frameRoi = frame[roiBoxRect];
try
{
FinalPlateResult finalPlateResult = await plateProcessor.ProcessPlate(frame);
if (isRetryMode && !plateProcessor.IsPlateStringValid(finalPlateResult.PlateString))
{
Console.WriteLine("ProcessFrameImage Retry Mode");
Thread.Sleep(1000);
overviewCamera.RequestCaptureOneFrame();
finalPlateResult = await plateProcessor.ProcessPlate(frame);
}
appLogger.Log(LogLevel.Info, $"ProcessFrameImage: {(DateTime.Now - starTime).TotalMilliseconds} ms");
return finalPlateResult;
}
catch (Exception ex)
{
Console.WriteLine($"ProcessFrameImage\texMessage: {ex.Message}");
return new FinalPlateResult
{
PlateImage = frame,
PlateString = string.Empty,
PlateType = PlateType.Square
};
}
}
public void Stop()
{
plateCamera.Stop();
overviewCamera.Stop();
pictureBoxPlateImage.UpdateImage(null);
pictureBoxPlateVideo.UpdateImage(null);
pictureBoxOverviewImage.UpdateImage(null);
pictureBoxOverviewVideo.UpdateImage(null);
}
public void Start()
{
plateCamera.Start();
overviewCamera.Start();
}
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ố: {plateStringEngine}");
lblCardType.UpdateLabel($"Loại thẻ: {cardType}");
lblCardTime.UpdateLabel($"Vào: {cardTimeIn}");
lblCardTimeOut.UpdateLabel($"Ra: {cardTimeOut}");
int.TryParse(money, out int moneyAmount);
lblMoneyAmount.UpdateLabel($"Số tiền: {string.Format("{0:n0}", moneyAmount)} vnđ");
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.Green);
}
}
}
private void OverviewCameraOnVideoFrameReceived(Mat videoFrame)
{
try
{
pictureBoxOverviewVideo.UpdateImage(videoFrame.ToBitmap());
}
catch (Exception ex)
{
Console.WriteLine($"{Util.GetCurrentMethodName()}\texMessage: {ex.Message}");
}
}
private void PlateCameraOnVideoFrameReceived(Mat videoFrame)
{
try
{
pictureBoxPlateVideo.UpdateImage(videoFrame.ToBitmap());
}
catch (Exception ex)
{
Console.WriteLine($"{Util.GetCurrentMethodName()}\texMessage: {ex.Message}");
}
}
private void ConnectToDoorAccessControl()
{
if (!doorControlAccess.Connect().HasError)
{
_ = doorControlAccess.GetLogToReceiveNewCard();
}
else
{
lblStatusInfo.UpdateLabel("KHÔNG THỂ KẾT NỐI TỚI C3200", Color.Purple);
}
}
private void LaneIn_Load(object sender, EventArgs e)
{
ConnectToDoorAccessControl();
}
private void LaneOut_Load(object sender, EventArgs e)
{
doorControlAccess.OnNewCardReceived += C3Device_OnNewCardReceived;
plateCamera.OnVideoFrameReceived += PlateCameraOnVideoFrameReceived;
plateCamera.OnOpenVideoStreamFailed += PlateCamera_OnOpenVideoStreamFailed;
overviewCamera.OnVideoFrameReceived += OverviewCameraOnVideoFrameReceived;
overviewCamera.OnOpenVideoStreamFailed += OverviewCamera_OnOpenVideoStreamFailed;
}
private void pictureBoxPlateVideo_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
StartPoint = e.Location;
pictureBoxRoi = new Rectangle(StartPoint, new System.Drawing.Size(0, 0));
IsDrawBox = true;
}
}
private void pictureBoxPlateVideo_MouseMove(object sender, MouseEventArgs e)
{
if (IsDrawBox)
{
CurrentCursorPosition = e.Location;
pictureBoxRoi.Width = CurrentCursorPosition.X - StartPoint.X;
pictureBoxRoi.Height = CurrentCursorPosition.Y - StartPoint.Y;
}
Refresh();
}
private void pictureBoxPlateVideo_MouseUp(object sender, MouseEventArgs e)
{
IsDrawBox = false;
if (StartPoint.X + pictureBoxRoi.Width > pictureBoxPlateVideo.Width || StartPoint.Y + pictureBoxRoi.Height > pictureBoxPlateVideo.Height)
{
pictureBoxRoi.X = pictureBoxRoi.Y = 0;
pictureBoxRoi.Width = pictureBoxPlateVideo.Width;
pictureBoxRoi.Height = pictureBoxPlateVideo.Height;
}
apiController.SaveRoiToServer(pictureBoxRoi, cameraId);
}
private void pictureBoxPlateVideo_Paint(object sender, PaintEventArgs e)
{
Pen redPen = new Pen(Color.FromArgb(255, 255, 0, 0), 3);
e.Graphics.DrawRectangle(redPen, pictureBoxRoi);
}
}
}

View File

@@ -117,10 +117,85 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="backgroundWorker2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>176, 17</value>
<metadata name="grbPlateRefernce.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="backgroundWorker1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>12, 17</value>
<metadata name="pictureBoxOverviewImageIn.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="pictureBoxPlateImageIn.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="pictureBoxOverviewImageIn.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="pictureBoxPlateImageIn.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="grbCardInformation.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="lblCardType.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="lblCardTimeOut.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="lblCardTime.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="lblMoneyAmount.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="lblPlateString.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="lblCardNumber.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="lblCardType.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="lblCardTimeOut.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="lblCardTime.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="lblMoneyAmount.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="lblPlateString.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="lblCardNumber.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="pictureBoxPlateImage.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="pictureBoxPlateVideo.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="grbPlateCamera.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="pictureBoxOverviewImage.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="pictureBoxOverviewVideo.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="grbOverviewCamera.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="lblLaneLabel.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="lblStatusInfo.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

181
AIParkingApplication/LoginForm.Designer.cs generated Normal file
View File

@@ -0,0 +1,181 @@
namespace AIParkingApplication
{
partial class LoginForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LoginForm));
this.pictureBoxImageLogo = new System.Windows.Forms.PictureBox();
this.txtUsername = new System.Windows.Forms.TextBox();
this.lblUsername = new System.Windows.Forms.Label();
this.txtPassword = new System.Windows.Forms.TextBox();
this.lblPassword = new System.Windows.Forms.Label();
this.txtServerAddress = new System.Windows.Forms.TextBox();
this.lblServerAddress = new System.Windows.Forms.Label();
this.btnLogin = new System.Windows.Forms.Button();
this.lblLoginStatus = new System.Windows.Forms.Label();
this.chkAutoLogin = new System.Windows.Forms.CheckBox();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxImageLogo)).BeginInit();
this.SuspendLayout();
//
// pictureBoxImageLogo
//
this.pictureBoxImageLogo.Location = new System.Drawing.Point(12, 14);
this.pictureBoxImageLogo.Name = "pictureBoxImageLogo";
this.pictureBoxImageLogo.Size = new System.Drawing.Size(185, 185);
this.pictureBoxImageLogo.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBoxImageLogo.TabIndex = 0;
this.pictureBoxImageLogo.TabStop = false;
//
// txtUsername
//
this.txtUsername.Location = new System.Drawing.Point(294, 14);
this.txtUsername.Name = "txtUsername";
this.txtUsername.Size = new System.Drawing.Size(227, 20);
this.txtUsername.TabIndex = 1;
this.txtUsername.Text = "cong1vao";
//
// lblUsername
//
this.lblUsername.AutoSize = true;
this.lblUsername.Location = new System.Drawing.Point(214, 17);
this.lblUsername.Name = "lblUsername";
this.lblUsername.Size = new System.Drawing.Size(55, 13);
this.lblUsername.TabIndex = 2;
this.lblUsername.Text = "Tài khoản";
//
// txtPassword
//
this.txtPassword.Location = new System.Drawing.Point(294, 45);
this.txtPassword.Name = "txtPassword";
this.txtPassword.PasswordChar = '*';
this.txtPassword.Size = new System.Drawing.Size(227, 20);
this.txtPassword.TabIndex = 1;
this.txtPassword.Text = "123456a@";
//
// lblPassword
//
this.lblPassword.AutoSize = true;
this.lblPassword.Location = new System.Drawing.Point(214, 48);
this.lblPassword.Name = "lblPassword";
this.lblPassword.Size = new System.Drawing.Size(52, 13);
this.lblPassword.TabIndex = 2;
this.lblPassword.Text = "Mật khẩu";
//
// txtServerAddress
//
this.txtServerAddress.Location = new System.Drawing.Point(294, 77);
this.txtServerAddress.Name = "txtServerAddress";
this.txtServerAddress.Size = new System.Drawing.Size(227, 20);
this.txtServerAddress.TabIndex = 1;
this.txtServerAddress.Text = "192.168.1.122:80";
//
// lblServerAddress
//
this.lblServerAddress.AutoSize = true;
this.lblServerAddress.Location = new System.Drawing.Point(214, 80);
this.lblServerAddress.Name = "lblServerAddress";
this.lblServerAddress.Size = new System.Drawing.Size(48, 13);
this.lblServerAddress.TabIndex = 2;
this.lblServerAddress.Text = "Máy chủ";
//
// btnLogin
//
this.btnLogin.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnLogin.Location = new System.Drawing.Point(294, 162);
this.btnLogin.Name = "btnLogin";
this.btnLogin.Size = new System.Drawing.Size(227, 37);
this.btnLogin.TabIndex = 3;
this.btnLogin.Text = "Đăng nhập";
this.btnLogin.UseVisualStyleBackColor = true;
this.btnLogin.Click += new System.EventHandler(this.btnLogin_Click);
//
// lblLoginStatus
//
this.lblLoginStatus.AutoSize = true;
this.lblLoginStatus.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblLoginStatus.ForeColor = System.Drawing.SystemColors.ControlLight;
this.lblLoginStatus.Location = new System.Drawing.Point(291, 100);
this.lblLoginStatus.Name = "lblLoginStatus";
this.lblLoginStatus.Size = new System.Drawing.Size(90, 18);
this.lblLoginStatus.TabIndex = 4;
this.lblLoginStatus.Text = "Login Status";
//
// chkAutoLogin
//
this.chkAutoLogin.AutoSize = true;
this.chkAutoLogin.Location = new System.Drawing.Point(295, 142);
this.chkAutoLogin.Name = "chkAutoLogin";
this.chkAutoLogin.Size = new System.Drawing.Size(122, 17);
this.chkAutoLogin.TabIndex = 5;
this.chkAutoLogin.Text = "Tự động đăng nhập";
this.chkAutoLogin.UseVisualStyleBackColor = true;
this.chkAutoLogin.CheckedChanged += new System.EventHandler(this.chkAutoLogin_CheckedChanged);
//
// LoginForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(534, 211);
this.Controls.Add(this.chkAutoLogin);
this.Controls.Add(this.lblLoginStatus);
this.Controls.Add(this.btnLogin);
this.Controls.Add(this.lblServerAddress);
this.Controls.Add(this.lblPassword);
this.Controls.Add(this.lblUsername);
this.Controls.Add(this.txtServerAddress);
this.Controls.Add(this.txtPassword);
this.Controls.Add(this.txtUsername);
this.Controls.Add(this.pictureBoxImageLogo);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximumSize = new System.Drawing.Size(550, 250);
this.Name = "LoginForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "AIParking - Hệ thống quản lý bãi đỗ xe - Đăng nhập";
this.TopMost = true;
this.Load += new System.EventHandler(this.LoginForm_Load);
((System.ComponentModel.ISupportInitialize)(this.pictureBoxImageLogo)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.PictureBox pictureBoxImageLogo;
private System.Windows.Forms.TextBox txtUsername;
private System.Windows.Forms.Label lblUsername;
private System.Windows.Forms.TextBox txtPassword;
private System.Windows.Forms.Label lblPassword;
private System.Windows.Forms.TextBox txtServerAddress;
private System.Windows.Forms.Label lblServerAddress;
private System.Windows.Forms.Button btnLogin;
private System.Windows.Forms.Label lblLoginStatus;
private System.Windows.Forms.CheckBox chkAutoLogin;
}
}

View File

@@ -0,0 +1,153 @@
using NLog;
using System;
using System.Configuration;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
namespace AIParkingApplication
{
public partial class LoginForm : Form
{
private ApiController apiController;
private Logger applicationLogger;
private bool isAutoLogin;
public LoginForm()
{
InitializeComponent();
applicationLogger = LogManager.GetLogger(AppConstant.APPLICATION_LOGGER_NAME);
applicationLogger.Log(LogLevel.Info, new string('-', 20));
isAutoLogin = false;
string defaultLogoImagePath = Application.StartupPath + AppConstant.DEFAULT_LOGO_IMAGE;
if (File.Exists(defaultLogoImagePath))
{
pictureBoxImageLogo.Image = new Bitmap(defaultLogoImagePath);
}
txtUsername.Focus();
lblLoginStatus.Text = string.Empty;
AcceptButton = btnLogin;
}
private async void Login()
{
btnLogin.Enabled = false;
string serverUrl = txtServerAddress.Text;
if (string.IsNullOrEmpty(serverUrl))
{
lblLoginStatus.Text = "Địa chỉ server không được để trống! \r\n ví dụ: 192.168.1.2:80";
btnLogin.Enabled = true;
applicationLogger.Log(LogLevel.Info, "Địa chỉ server không được để trống");
return;
}
Util.ParseHostString(serverUrl, out string ipAddress, out int port);
if (!Util.IsValidIPAddress(ipAddress))
{
lblLoginStatus.Text = "Địa chỉ server không đúng định dạng: \r\n ví dụ: 192.168.1.122:80";
btnLogin.Enabled = true;
applicationLogger.Log(LogLevel.Info, "Địa chỉ server không đúng định dạng");
return;
}
try
{
apiController = new ApiController(serverUrl, applicationLogger);
}
catch (Exception ex)
{
applicationLogger.Log(LogLevel.Error, $"Cấu máy chủ lỗi - Kiểm tra lại tên máy chủ, kết nối máy chủ! Không thể khởi tạo API Webserver. ex: {ex.Message}");
MessageBox.Show($"Cấu máy chủ lỗi - Kiểm tra lại tên máy chủ, kết nối máy chủ! \r\n {ex.Message}", "Lỗi khởi tạo API!", MessageBoxButtons.OK, MessageBoxIcon.Error);
btnLogin.Enabled = true;
return;
}
lblLoginStatus.Text = string.Empty;
string username = txtUsername.Text;
string password = txtPassword.Text;
if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
{
lblLoginStatus.Text = "Tên tài khoản hoặc mật khẩu không được để trống";
btnLogin.Enabled = true;
applicationLogger.Log(LogLevel.Info, "Tên tài khoản hoặc mật khẩu không được để trống");
return;
}
var loginResult = await apiController.Login(new LoginModel { Username = username, Password = password });
if (loginResult.Exception != null)
{
btnLogin.Enabled = true;
var execeptioMessage = loginResult.Exception.Message;
if (execeptioMessage.Contains("Error converting value"))
{
lblLoginStatus.UpdateLabel("Sai tên tài khoản hoặc mật khẩu!", Color.Red);
applicationLogger.Log(LogLevel.Info, "Sai tên tài khoản hoặc mật khẩu");
return;
}
if (execeptioMessage.Contains("An error occurred while sending the request"))
{
lblLoginStatus.UpdateLabel("Không có kết nối tới server!\r\nKiểm tra lại kết nối tới server!", Color.Red, Color.White);
applicationLogger.Log(LogLevel.Error, "Không có kết nối tới server!");
return;
}
lblLoginStatus.UpdateLabel("Không có kết nối tới server!\r\nKiểm tra lại kết nối tới server!", Color.Red, Color.White);
applicationLogger.Log(LogLevel.Error, "Không có kết nối tới server!");
}
if (loginResult.IsLoginSuccess)
{
Util.UpsertAppSettings(AppConstant.DEFAULT_USERNAME, txtUsername.Text);
Util.UpsertAppSettings(AppConstant.DEFAULT_PASSWORD, txtPassword.Text);
Util.UpsertAppSettings(AppConstant.DEFAULT_WEB_SERVER, txtServerAddress.Text);
new AIParkingApplicationForm(apiController, ipAddress, loginResult.LoginData, applicationLogger).Show();
Hide();
applicationLogger.Log(LogLevel.Info, $"Đăng nhập thành công với tài khoản: {txtUsername.Text}");
}
}
private void btnLogin_Click(object sender, EventArgs e)
{
Login();
}
private void ReadAppConfigurationFromFile()
{
try
{
txtUsername.Text = ConfigurationManager.AppSettings[AppConstant.DEFAULT_USERNAME];
txtPassword.Text = ConfigurationManager.AppSettings[AppConstant.DEFAULT_PASSWORD];
txtServerAddress.Text = ConfigurationManager.AppSettings[AppConstant.DEFAULT_WEB_SERVER];
bool.TryParse(ConfigurationManager.AppSettings[AppConstant.AUTO_LOGIN], out isAutoLogin);
if (isAutoLogin)
{
chkAutoLogin.Checked = true;
Login();
}
}
catch (Exception ex)
{
txtUsername.Text = string.Empty;
txtPassword.Text = string.Empty;
Util.UpsertAppSettings(AppConstant.DEFAULT_USERNAME, string.Empty);
Util.UpsertAppSettings(AppConstant.DEFAULT_PASSWORD, string.Empty);
Util.UpsertAppSettings(AppConstant.AUTO_LOGIN, "false");
Util.UpsertAppSettings(AppConstant.DEFAULT_WEB_SERVER, "127.0.0.1:80");
chkAutoLogin.Checked = false;
Console.WriteLine($"{DateTime.Now.GetTimeFormatted()}\tReadAccessControlDeviceIPConfiguration\t{ex.Message}");
applicationLogger.Log(LogLevel.Error, $"Không thể đọc cấu hình tài khoản mặc định: {AppConstant.DEFAULT_USERNAME}, {AppConstant.DEFAULT_PASSWORD}");
}
}
private void LoginForm_Load(object sender, EventArgs e)
{
ReadAppConfigurationFromFile();
}
private void chkAutoLogin_CheckedChanged(object sender, EventArgs e)
{
Util.UpsertAppSettings(AppConstant.AUTO_LOGIN, (sender as CheckBox).Checked.ToString().ToLower());
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off" internalLogFile="D:\nlog-internal.log">
<variable name="logDirectory" value="${basedir}/logs"/>
<variable name="logLayout" value="${date:format=HH\:mm\:ss dd-MM-yyyy} ${uppercase:${level}} ${message} ${exception}"/>
<targets>
<target xsi:type="File" name="applicationLogger" fileName="${logDirectory}/${shortdate}_App.log"
layout="${logLayout}" maxArchiveFiles="30" encoding="Unicode" writeBom="true"/>
<target xsi:type="File" name="pingServerLoggingFile" fileName="${logDirectory}/${shortdate}_PingServer.log"
layout="${logLayout}" maxArchiveFiles="30" encoding="Unicode" writeBom="true"/>
<target xsi:type="File" name="pingDoorDeviceControlAccessLoggingFile" fileName="${logDirectory}/${shortdate}_PingDoorDeviceControlAccess.log"
layout="${logLayout}" maxArchiveFiles="30" encoding="Unicode" writeBom="true"/>
</targets>
<rules>
<logger name="ApplicationLogger" minlevel="Trace" writeTo="applicationLogger" />
<logger name="PingServerLogger" minlevel="Trace" writeTo="pingServerLoggingFile" />
<logger name="PingDoorDeviceControlAccessLogger" minlevel="Trace" writeTo="pingDoorDeviceControlAccessLoggingFile" />
</rules>
</nlog>

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,7 @@
using OpenCvSharp;
using System;
using System.Linq;
using System.Windows.Forms;
namespace AIParkingApplication
{
@@ -20,7 +21,13 @@ namespace AIParkingApplication
this.maxSizePlate = maxSizePlate;
this.scaleFactor = scaleFactor;
this.minNeighbors = minNeighbors;
plateCascadeClassifier = new CascadeClassifier(this.plateType == PlateType.Square ? PlateDetectorConstant.SQUARE_PLATE_WEIGHT_FILENAME : PlateDetectorConstant.LONG_PLATE_WEIGHT_FILENAME);
string plateWeightPath = Application.StartupPath + (this.plateType == PlateType.Square ? PlateDetectorConstant.SQUARE_PLATE_WEIGHT_FILENAME : PlateDetectorConstant.LONG_PLATE_WEIGHT_FILENAME);
plateCascadeClassifier = new CascadeClassifier(plateWeightPath);
}
~PlateDetector()
{
plateCascadeClassifier?.Dispose();
}
public Mat DetectPlate(Mat frame)
@@ -66,7 +73,6 @@ namespace AIParkingApplication
}
Console.WriteLine($"GetBiggestPlate - Width: {biggestPlateRect.Width}\tHeight: {biggestPlateRect.Height}");
Rect extendedRect = ExtendPlateRect(biggestPlateRect);
//TODO: check oversize frame
Mat plateImage;
try
{
@@ -81,16 +87,10 @@ namespace AIParkingApplication
}
}
public enum PlateType
{
Square,
Long
}
public static class PlateDetectorConstant
{
public const string SQUARE_PLATE_WEIGHT_FILENAME = "plate.xml";
public const string LONG_PLATE_WEIGHT_FILENAME = "plateLong.xml";
public const string SQUARE_PLATE_WEIGHT_FILENAME = @".\plate.xml";
public const string LONG_PLATE_WEIGHT_FILENAME = @".\plateLong.xml";
public const double SCALE_FACTOR_DEFAULT_SQUARE_PLATE = 1.03;
public static int MIN_NEIGHBORS_DEFAULT_SQUARE_PLATE = 2;

View File

@@ -2,7 +2,6 @@
using OpenCvSharp.Extensions;
using System;
using System.Drawing;
using System.IO;
using System.Threading.Tasks;
namespace AIParkingApplication
@@ -13,11 +12,13 @@ namespace AIParkingApplication
private bool isSupportLongPlate;
private PlateDetector squarePlateDetector;
private PlateDetector longPlateDetector;
private EngineApiController engineApiController;
public PlateProcessor(bool isSupportSquarePlate = true, bool isSupportLongPlate = false)
public PlateProcessor(EngineApiController engineApiController, bool isSupportSquarePlate = true, bool isSupportLongPlate = false)
{
this.isSupportSquarePlate = isSupportSquarePlate;
this.isSupportLongPlate = isSupportLongPlate;
this.engineApiController = engineApiController;
if (this.isSupportSquarePlate)
{
@@ -35,25 +36,23 @@ namespace AIParkingApplication
Mat plateDetected = plateType == PlateType.Square ? squarePlateDetector.DetectPlate(frame) : longPlateDetector.DetectPlate(frame);
//TODO: Check if plateDetected empty
OcrResult plateOcrResultFromEngine = await Util.SendEngineRequestAsync(plateDetected, plateType);
Bitmap finalPlateImage;
if (!string.IsNullOrEmpty(plateOcrResultFromEngine.Ocr) && !string.IsNullOrEmpty(plateOcrResultFromEngine.Plate))
OcrResult plateOcrResultFromEngine = await engineApiController.SendEngineRequestAsync(plateDetected, plateType);
Mat finalPlateImage;
if (!string.IsNullOrEmpty(plateOcrResultFromEngine.PlateString) && !string.IsNullOrEmpty(plateOcrResultFromEngine.PlateImageBase64))
{
byte[] imageData = Convert.FromBase64String(plateOcrResultFromEngine.Plate);
using (var ms = new MemoryStream(imageData))
{
finalPlateImage = new Bitmap(ms);
}
Bitmap plateBitmapImage = Util.ConvertFromBase64Image(plateOcrResultFromEngine.PlateImageBase64);
finalPlateImage = BitmapConverter.ToMat(plateBitmapImage);
}
else
{
finalPlateImage = plateDetected.ToBitmap();
finalPlateImage = plateDetected;
}
return new FinalPlateResult
{
PlateString = plateOcrResultFromEngine.Ocr,
PlateImage = finalPlateImage
PlateString = plateOcrResultFromEngine.PlateString,
PlateImage = finalPlateImage,
PlateType = plateType
};
}
@@ -84,7 +83,8 @@ namespace AIParkingApplication
return new FinalPlateResult
{
PlateString = string.Empty,
PlateImage = frame.ToBitmap()
PlateImage = frame,
PlateType = PlateType.Square
};
}
}
@@ -105,6 +105,7 @@ namespace AIParkingApplication
public class FinalPlateResult
{
public string PlateString { get; set; }
public Bitmap PlateImage { get; set; }
public Mat PlateImage { get; set; }
public PlateType PlateType { get; set; }
}
}

View File

@@ -0,0 +1,76 @@
using Microsoft.Win32;
using NLog;
using System;
using System.IO;
using System.Windows.Forms;
namespace AIParkingApplication
{
public class Printer
{
private Logger appLogger;
public Printer(Logger appLogger)
{
this.appLogger = appLogger;
SetupPrinterPageSetting();
}
public void DoPrint(PrinterData printData)
{
WebBrowser webBrowser = new WebBrowser();
webBrowser.Left = 0;
string documentText = ProcessingString("PrinterForm.html", printData);
if (!string.IsNullOrEmpty(documentText))
{
webBrowser.DocumentText = documentText;
webBrowser.DocumentCompleted += WebBrowser_DocumentCompleted;
}
}
private void WebBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
((WebBrowser)sender).Print();
}
private string ProcessingString(string path, PrinterData printerField)
{
try
{
string htmlStr = File.ReadAllText(path);
htmlStr = htmlStr.Replace("{PLATE_STRING}", printerField.PlateString)
.Replace("{TIME_PARKING_IN}", printerField.TimeParkingIn)
.Replace("{TIME_PARKING_OUT}", printerField.TimeParkingOut)
.Replace("{MONEY_AMOUNT}", printerField.MoneyAmount);
return htmlStr;
}
catch (Exception ex)
{
Console.WriteLine($"ProcessingString\texMessage:{ex.Message}");
appLogger.Log(LogLevel.Error, $"Lỗi khi In hóa đơn: {ex.Message}");
return string.Empty;
}
}
private void SetupPrinterPageSetting()
{
RegistryKey key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer\PageSetup", RegistryKeyPermissionCheck.ReadWriteSubTree);
key.SetValue("footer", string.Empty, RegistryValueKind.String);
key.SetValue("header", string.Empty, RegistryValueKind.String);
key.SetValue("margin_top", 0);
key.SetValue("margin_right", 0.2);
key.SetValue("margin_bottom", 0.5);
key.SetValue("margin_left", 0.2);
key.Close();
}
}
public class PrinterData
{
public string PlateString { get; set; }
public string TimeParkingIn { get; set; }
public string TimeParkingOut { get; set; }
public string MoneyAmount { get; set; }
}
}

View File

@@ -16,7 +16,7 @@ namespace AIParkingApplication
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new AIParkingApplicationForm());
Application.Run(new LoginForm());
}
else
{

View File

@@ -1,16 +1,15 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("AIParkingApplication")]
[assembly: AssemblyTitle("AIParking - Phần mềm quản lý bãi đỗ xe")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AIParkingApplication")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyCopyright("Copyright © DucDA 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

46
AIParkingApplication/Sidebar.Designer.cs generated Normal file
View File

@@ -0,0 +1,46 @@
namespace AIParkingApplication
{
partial class Sidebar
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
//
// Sidebar
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Name = "Sidebar";
this.Size = new System.Drawing.Size(192, 692);
this.Load += new System.EventHandler(this.Sidebar_Load);
this.ResumeLayout(false);
}
#endregion
}
}

View File

@@ -0,0 +1,41 @@
using System;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
namespace AIParkingApplication
{
public partial class Sidebar : UserControl
{
private Statistic statistic;
private string logoImagePath;
private ApiController apiController;
public Sidebar(ApiController apiController, string logoImagePath = AppConstant.DEFAULT_LOGO_IMAGE)
{
InitializeComponent();
this.apiController = apiController;
this.logoImagePath = logoImagePath;
}
private void Sidebar_Load(object sender, EventArgs e)
{
string defaultLogoImagePath = Application.StartupPath + logoImagePath;
if (File.Exists(defaultLogoImagePath))
{
PictureBox pictureBoxImageLogo;
pictureBoxImageLogo = new PictureBox();
pictureBoxImageLogo.Location = new Point(1, 1);
pictureBoxImageLogo.Size = new Size(185, 185);
pictureBoxImageLogo.SizeMode = PictureBoxSizeMode.StretchImage;
pictureBoxImageLogo.Image = new Bitmap(logoImagePath);
Controls.Add(pictureBoxImageLogo);
}
statistic = new Statistic(apiController, TimeSpan.FromMinutes(10));
statistic.Location = new Point(0, 400);
statistic.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
Controls.Add(statistic);
}
}
}

View File

@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View File

@@ -34,17 +34,26 @@
this.lblVehicleTotalOut = new System.Windows.Forms.Label();
this.lblVehicleTotalIn = new System.Windows.Forms.Label();
this.tlpStatisticTable = new System.Windows.Forms.TableLayoutPanel();
this.lblLoaiXe = new System.Windows.Forms.Label();
this.lblSoLuong = new System.Windows.Forms.Label();
this.lblXeMay = new System.Windows.Forms.Label();
this.lblSoLuongXeMay = new System.Windows.Forms.Label();
this.lblOto = new System.Windows.Forms.Label();
this.lblSoLuongOto = new System.Windows.Forms.Label();
this.grbLoginInfo = new System.Windows.Forms.GroupBox();
this.lblAuthorization = new System.Windows.Forms.Label();
this.lblUsername = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.grbVehicleStatistics.SuspendLayout();
this.tlpStatisticTable.SuspendLayout();
this.grbLoginInfo.SuspendLayout();
this.SuspendLayout();
//
// 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 +62,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(189, 178);
this.grbVehicleStatistics.TabIndex = 0;
this.grbVehicleStatistics.TabStop = false;
this.grbVehicleStatistics.Text = "Thống kê xe";
@@ -61,7 +70,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 +80,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 +91,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 +102,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,20 +111,91 @@
//
// 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.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.Single;
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));
this.tlpStatisticTable.Controls.Add(this.lblLoaiXe, 0, 0);
this.tlpStatisticTable.Controls.Add(this.lblSoLuong, 1, 0);
this.tlpStatisticTable.Controls.Add(this.lblXeMay, 0, 1);
this.tlpStatisticTable.Controls.Add(this.lblSoLuongXeMay, 1, 1);
this.tlpStatisticTable.Controls.Add(this.lblOto, 0, 2);
this.tlpStatisticTable.Controls.Add(this.lblSoLuongOto, 1, 2);
this.tlpStatisticTable.Location = new System.Drawing.Point(6, 22);
this.tlpStatisticTable.Name = "tlpStatisticTable";
this.tlpStatisticTable.RowCount = 3;
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(178, 100);
this.tlpStatisticTable.TabIndex = 0;
//
// lblLoaiXe
//
this.lblLoaiXe.Anchor = System.Windows.Forms.AnchorStyles.None;
this.lblLoaiXe.AutoSize = true;
this.lblLoaiXe.Location = new System.Drawing.Point(17, 8);
this.lblLoaiXe.Name = "lblLoaiXe";
this.lblLoaiXe.Size = new System.Drawing.Size(55, 18);
this.lblLoaiXe.TabIndex = 0;
this.lblLoaiXe.Text = "Loại xe";
//
// lblSoLuong
//
this.lblSoLuong.Anchor = System.Windows.Forms.AnchorStyles.None;
this.lblSoLuong.AutoSize = true;
this.lblSoLuong.Location = new System.Drawing.Point(99, 8);
this.lblSoLuong.Name = "lblSoLuong";
this.lblSoLuong.Size = new System.Drawing.Size(67, 18);
this.lblSoLuong.TabIndex = 0;
this.lblSoLuong.Text = "Số lượng";
//
// lblXeMay
//
this.lblXeMay.Anchor = System.Windows.Forms.AnchorStyles.None;
this.lblXeMay.AutoSize = true;
this.lblXeMay.Location = new System.Drawing.Point(15, 41);
this.lblXeMay.Name = "lblXeMay";
this.lblXeMay.Size = new System.Drawing.Size(58, 18);
this.lblXeMay.TabIndex = 0;
this.lblXeMay.Text = "Xe máy";
//
// lblSoLuongXeMay
//
this.lblSoLuongXeMay.Anchor = System.Windows.Forms.AnchorStyles.None;
this.lblSoLuongXeMay.AutoSize = true;
this.lblSoLuongXeMay.Location = new System.Drawing.Point(125, 41);
this.lblSoLuongXeMay.Name = "lblSoLuongXeMay";
this.lblSoLuongXeMay.Size = new System.Drawing.Size(16, 18);
this.lblSoLuongXeMay.TabIndex = 0;
this.lblSoLuongXeMay.Text = "0";
//
// lblOto
//
this.lblOto.Anchor = System.Windows.Forms.AnchorStyles.None;
this.lblOto.AutoSize = true;
this.lblOto.Location = new System.Drawing.Point(28, 74);
this.lblOto.Name = "lblOto";
this.lblOto.Size = new System.Drawing.Size(33, 18);
this.lblOto.TabIndex = 0;
this.lblOto.Text = "Ôtô";
//
// lblSoLuongOto
//
this.lblSoLuongOto.Anchor = System.Windows.Forms.AnchorStyles.None;
this.lblSoLuongOto.AutoSize = true;
this.lblSoLuongOto.Location = new System.Drawing.Point(125, 74);
this.lblSoLuongOto.Name = "lblSoLuongOto";
this.lblSoLuongOto.Size = new System.Drawing.Size(16, 18);
this.lblSoLuongOto.TabIndex = 0;
this.lblSoLuongOto.Text = "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 +203,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(190, 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 +214,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 +234,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 +244,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,9 +255,11 @@
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(192, 292);
this.Load += new System.EventHandler(this.Statistic_Load);
this.grbVehicleStatistics.ResumeLayout(false);
this.tlpStatisticTable.ResumeLayout(false);
this.tlpStatisticTable.PerformLayout();
this.grbLoginInfo.ResumeLayout(false);
this.grbLoginInfo.PerformLayout();
this.ResumeLayout(false);
@@ -197,5 +279,11 @@
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label lblVehicleTotalOut;
private System.Windows.Forms.Label lblVehicleTotalIn;
private System.Windows.Forms.Label lblLoaiXe;
private System.Windows.Forms.Label lblSoLuong;
private System.Windows.Forms.Label lblXeMay;
private System.Windows.Forms.Label lblSoLuongXeMay;
private System.Windows.Forms.Label lblOto;
private System.Windows.Forms.Label lblSoLuongOto;
}
}

View File

@@ -2,94 +2,45 @@
using System.Windows.Forms;
using System.Threading;
using Newtonsoft.Json;
using System.Net.Http;
namespace AIParkingApplication
{
public partial class Statistic : UserControl
{
private readonly HttpClient client;
private readonly Thread thrStatistics;
private readonly Thread statisticsThread;
private readonly TimeSpan updateInterval;
private ApiController apiController;
Label lblLoaiXe;
Label lblXeMay;
Label lblOto;
Label lblSoLuong;
Label lblSoLuongXeMay;
Label lblSoLuongOto;
public Statistic(string apiUrl)
public Statistic(ApiController apiController, TimeSpan updateInterval)
{
InitializeComponent();
client = new HttpClient { BaseAddress = new Uri(apiUrl), Timeout = TimeSpan.FromMilliseconds(5000) };
thrStatistics = new Thread(new ThreadStart(GetStatistic));
thrStatistics.IsBackground = true;
thrStatistics.Start();
this.apiController = apiController;
this.updateInterval = updateInterval;
statisticsThread = new Thread(new ThreadStart(GetStatistic)) { IsBackground = true };
}
private void GetStatistic()
{
while (true)
{
GETDataFromServer();
Thread.Sleep(1000);
GetDataUpdate();
Thread.Sleep(updateInterval);
}
}
private async void GETDataFromServer()
private async void GetDataUpdate()
{
try
ParkInfo parkInfo = await apiController.GetStatisticInfo();
if (parkInfo != null && IsHandleCreated)
{
HttpResponseMessage response = await client.GetAsync("/api/statistics");
response.EnsureSuccessStatusCode();
var vehicle = await response.Content.ReadAsAsync<Vehicle>();
lblSoLuongXeMay?.Invoke(new Action(() =>
{
lblSoLuongXeMay.Text = vehicle.NumberOfMoto.ToString();
}));
lblSoLuongOto?.Invoke(new Action(() =>
{
lblSoLuongOto.Text = vehicle.NumberOfCar.ToString();
}));
lblVehicleTotalIn?.Invoke(new Action(() =>
{
lblVehicleTotalIn.Text = vehicle.TotalIn;
}));
lblVehicleTotalOut?.Invoke(new Action(() =>
{
lblVehicleTotalOut.Text = vehicle.TotelOut;
}));
}
catch (Exception ex)
{
Console.WriteLine($"SendEngineRequest : {ex.Message}");
lblSoLuongXeMay.UpdateLabel(parkInfo.NumberOfMoto.ToString());
lblSoLuongOto.UpdateLabel(parkInfo.NumberOfCar.ToString());
lblVehicleTotalIn.UpdateLabel(parkInfo.TotalIn);
lblVehicleTotalOut.UpdateLabel(parkInfo.TotalOut);
}
}
private void Statistic_Load(object sender, EventArgs e)
{
tlpStatisticTable.BorderStyle = BorderStyle.FixedSingle;
tlpStatisticTable.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single;
System.Drawing.Font labelFont = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
lblLoaiXe = new Label() { Text = "Loại xe", Font = labelFont };
lblXeMay = new Label() { Text = "Xe máy", Font = labelFont };
lblOto = new Label() { Text = "Ô tô", Font = labelFont };
lblSoLuong = new Label() { Text = "Số Lượng", Font = labelFont };
lblSoLuongXeMay = new Label() { Text = "0", Font = labelFont };
lblSoLuongOto = new Label() { Text = "0", Font = labelFont };
//Fill to StaticTable
tlpStatisticTable.Controls.Add(lblLoaiXe, 0, 0);
tlpStatisticTable.Controls.Add(lblXeMay, 0, 1);
tlpStatisticTable.Controls.Add(lblOto, 0, 2);
tlpStatisticTable.Controls.Add(lblSoLuong, 1, 0);
tlpStatisticTable.Controls.Add(lblSoLuongXeMay, 1, 1);
tlpStatisticTable.Controls.Add(lblSoLuongOto, 1, 2);
}
public class Vehicle
public class ParkInfo
{
[JsonProperty("oto")]
public int NumberOfCar { get; set; }
@@ -101,7 +52,12 @@ namespace AIParkingApplication
public string TotalIn { get; set; }
[JsonProperty("total_out")]
public string TotelOut { get; set; }
public string TotalOut { get; set; }
}
private void Statistic_Load(object sender, EventArgs e)
{
statisticsThread.Start();
}
}
}

View File

@@ -29,97 +29,127 @@
private void InitializeComponent()
{
this.lblPingTimeServer = new System.Windows.Forms.Label();
this.lblPingServer = new System.Windows.Forms.Label();
this.lblDateTime = new System.Windows.Forms.Label();
this.lblPingC3200 = new System.Windows.Forms.Label();
this.lblPingTimeC3 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.lblPingDoorAccessControlDevice = new System.Windows.Forms.Label();
this.lblPingTimeToDoorAccessControl = new System.Windows.Forms.Label();
this.lblConnectionStatus = new System.Windows.Forms.Label();
this.lblServer = new System.Windows.Forms.Label();
this.lblEngine = new System.Windows.Forms.Label();
this.lblEngineStatus = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// lblPingTimeServer
//
this.lblPingTimeServer.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblPingTimeServer.Location = new System.Drawing.Point(181, 2);
this.lblPingTimeServer.Location = new System.Drawing.Point(212, 0);
this.lblPingTimeServer.Name = "lblPingTimeServer";
this.lblPingTimeServer.Size = new System.Drawing.Size(75, 23);
this.lblPingTimeServer.Size = new System.Drawing.Size(65, 18);
this.lblPingTimeServer.TabIndex = 0;
this.lblPingTimeServer.Text = "1ms";
this.lblPingTimeServer.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// lblPingServer
//
this.lblPingServer.AutoSize = true;
this.lblPingServer.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblPingServer.Location = new System.Drawing.Point(128, 4);
this.lblPingServer.Name = "lblPingServer";
this.lblPingServer.Size = new System.Drawing.Size(51, 18);
this.lblPingServer.TabIndex = 1;
this.lblPingServer.Text = "Server";
//
// lblDateTime
//
this.lblDateTime.AutoSize = true;
this.lblDateTime.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.lblDateTime.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblDateTime.Location = new System.Drawing.Point(597, 4);
this.lblDateTime.Location = new System.Drawing.Point(1226, 0);
this.lblDateTime.Name = "lblDateTime";
this.lblDateTime.Size = new System.Drawing.Size(140, 18);
this.lblDateTime.TabIndex = 2;
this.lblDateTime.Text = "17/06/2020 16:54:43";
this.lblDateTime.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// lblPingC3200
// lblPingDoorAccessControlDevice
//
this.lblPingC3200.AutoSize = true;
this.lblPingC3200.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblPingC3200.Location = new System.Drawing.Point(308, 4);
this.lblPingC3200.Name = "lblPingC3200";
this.lblPingC3200.Size = new System.Drawing.Size(109, 18);
this.lblPingC3200.TabIndex = 3;
this.lblPingC3200.Text = "Thiết bị mở cửa";
this.lblPingDoorAccessControlDevice.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblPingDoorAccessControlDevice.Location = new System.Drawing.Point(316, 0);
this.lblPingDoorAccessControlDevice.Name = "lblPingDoorAccessControlDevice";
this.lblPingDoorAccessControlDevice.Size = new System.Drawing.Size(114, 18);
this.lblPingDoorAccessControlDevice.TabIndex = 3;
this.lblPingDoorAccessControlDevice.Text = "Thiết bị mở cửa:";
this.lblPingDoorAccessControlDevice.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// lblPingTimeC3
// lblPingTimeToDoorAccessControl
//
this.lblPingTimeC3.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblPingTimeC3.Location = new System.Drawing.Point(436, 2);
this.lblPingTimeC3.Name = "lblPingTimeC3";
this.lblPingTimeC3.Size = new System.Drawing.Size(75, 23);
this.lblPingTimeC3.TabIndex = 3;
this.lblPingTimeC3.Text = "500ms";
this.lblPingTimeC3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.lblPingTimeToDoorAccessControl.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblPingTimeToDoorAccessControl.Location = new System.Drawing.Point(440, 0);
this.lblPingTimeToDoorAccessControl.Name = "lblPingTimeToDoorAccessControl";
this.lblPingTimeToDoorAccessControl.Size = new System.Drawing.Size(71, 18);
this.lblPingTimeToDoorAccessControl.TabIndex = 3;
this.lblPingTimeToDoorAccessControl.Text = "500ms";
this.lblPingTimeToDoorAccessControl.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label1
// lblConnectionStatus
//
this.label1.AutoSize = true;
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(3, 4);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(125, 18);
this.label1.TabIndex = 1;
this.label1.Text = "Trạng thái kết nối:";
this.lblConnectionStatus.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblConnectionStatus.Location = new System.Drawing.Point(0, 0);
this.lblConnectionStatus.Name = "lblConnectionStatus";
this.lblConnectionStatus.Size = new System.Drawing.Size(125, 18);
this.lblConnectionStatus.TabIndex = 1;
this.lblConnectionStatus.Text = "Trạng thái kết nối";
this.lblConnectionStatus.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// lblServer
//
this.lblServer.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblServer.Location = new System.Drawing.Point(142, 0);
this.lblServer.Name = "lblServer";
this.lblServer.Size = new System.Drawing.Size(63, 18);
this.lblServer.TabIndex = 1;
this.lblServer.Text = "Server:";
this.lblServer.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// lblEngine
//
this.lblEngine.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblEngine.Location = new System.Drawing.Point(583, 0);
this.lblEngine.Name = "lblEngine";
this.lblEngine.Size = new System.Drawing.Size(65, 18);
this.lblEngine.TabIndex = 3;
this.lblEngine.Text = "Engine:";
this.lblEngine.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// lblEngineStatus
//
this.lblEngineStatus.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblEngineStatus.Location = new System.Drawing.Point(654, 0);
this.lblEngineStatus.Name = "lblEngineStatus";
this.lblEngineStatus.Size = new System.Drawing.Size(169, 18);
this.lblEngineStatus.TabIndex = 3;
this.lblEngineStatus.Text = "---";
this.lblEngineStatus.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// StatusBar
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.lblPingTimeC3);
this.Controls.Add(this.lblPingC3200);
this.Controls.Add(this.lblEngineStatus);
this.Controls.Add(this.lblPingTimeToDoorAccessControl);
this.Controls.Add(this.lblEngine);
this.Controls.Add(this.lblPingDoorAccessControlDevice);
this.Controls.Add(this.lblDateTime);
this.Controls.Add(this.label1);
this.Controls.Add(this.lblPingServer);
this.Controls.Add(this.lblServer);
this.Controls.Add(this.lblConnectionStatus);
this.Controls.Add(this.lblPingTimeServer);
this.Margin = new System.Windows.Forms.Padding(0);
this.MaximumSize = new System.Drawing.Size(1366, 18);
this.MinimumSize = new System.Drawing.Size(1366, 18);
this.Name = "StatusBar";
this.Size = new System.Drawing.Size(740, 25);
this.Size = new System.Drawing.Size(1366, 18);
this.Load += new System.EventHandler(this.StatusBar_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label lblPingTimeServer;
private System.Windows.Forms.Label lblPingServer;
private System.Windows.Forms.Label lblDateTime;
private System.Windows.Forms.Label lblPingC3200;
private System.Windows.Forms.Label lblPingTimeC3;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label lblPingDoorAccessControlDevice;
private System.Windows.Forms.Label lblPingTimeToDoorAccessControl;
private System.Windows.Forms.Label lblConnectionStatus;
private System.Windows.Forms.Label lblServer;
private System.Windows.Forms.Label lblEngine;
private System.Windows.Forms.Label lblEngineStatus;
}
}

View File

@@ -1,58 +1,70 @@
using System;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
using System.Threading;
using System.Windows.Forms;
namespace AIParkingApplication
{
public partial class StatusBar : UserControl
{
private string webServerIP;
private string c3IP;
public StatusBar(string webServerIP, string c3IP)
private string doorAccessControlDeviceIP;
private const string engineFilePath = @"\engine.bat";
private Thread updateInfoThread;
public StatusBar(string webServerIP, string doorAccessControlDeviceIP)
{
InitializeComponent();
this.webServerIP = webServerIP;
this.c3IP = c3IP;
Thread thrStatus = new Thread(new ThreadStart(UpdateStatus));
thrStatus.IsBackground = true;
thrStatus.Start();
this.doorAccessControlDeviceIP = doorAccessControlDeviceIP;
updateInfoThread = new Thread(UpdateStatus) { IsBackground = true };
}
private void UpdateStatus()
{
while (true)
{
lblDateTime.Invoke(new Action(() =>
if (IsHandleCreated)
{
lblDateTime.Text = DateTime.Now.ToString(AppConstant.DATETIME_FORMAT);
}));
lblDateTime.UpdateLabel(DateTime.Now.GetTimeFormatted());
lblPingTimeC3.Invoke(new Action(() =>
{
PingResult pingResult = GetPingStatus(c3IP);
lblPingTimeC3.Text = $"{pingResult.ReplyTime} ms";
lblPingTimeC3.BackColor = pingResult.BackColor;
lblPingTimeC3.ForeColor = pingResult.ForceColor;
}));
PingResult pingDoorAccessControlResult = GetPingStatus(doorAccessControlDeviceIP);
lblPingTimeToDoorAccessControl.UpdateLabel($"{pingDoorAccessControlResult.ReplyTime} ms", pingDoorAccessControlResult.BackColor, pingDoorAccessControlResult.ForeColor);
lblPingTimeServer.Invoke(new Action(() =>
{
PingResult pingResult = GetPingStatus(webServerIP);
lblPingTimeServer.Text = $"{pingResult.ReplyTime} ms";
lblPingTimeServer.BackColor = pingResult.BackColor;
lblPingTimeServer.ForeColor = pingResult.ForceColor;
}));
Thread.Sleep(1000);
PingResult pingWebServerResult = GetPingStatus(webServerIP);
lblPingTimeServer.UpdateLabel($"{pingWebServerResult.ReplyTime} ms", pingWebServerResult.BackColor, pingWebServerResult.ForeColor);
if (Process.GetProcessesByName("tmux").Length == 0)
{
string engineBatFilePath = Application.StartupPath + engineFilePath;
if (File.Exists(engineBatFilePath))
{
Util.ExecuteCommand(engineBatFilePath);
lblEngineStatus.UpdateLabel("DỪNG HOẠT ĐỘNG", Color.Red);
}
else
{
lblEngineStatus.UpdateLabel("KHÔNG TÌM THẤY FILE", Color.Red);
}
}
else
{
lblEngineStatus.UpdateLabel("ĐANG HOẠT ĐỘNG", Color.Green);
}
}
Thread.Sleep(TimeSpan.FromSeconds(1));
}
}
private PingResult GetPingStatus(string ip)
private PingResult GetPingStatus(string ipAddress)
{
PingResult pingResult = new PingResult();
bool isPingable;
isPingable = Util.IsPingable(ip, out long replyTime);
isPingable = Util.IsPingable(ipAddress, out long replyTime);
if (isPingable)
{
switch (replyTime)
{
case long n when (n >= 0 && n < 1):
@@ -68,6 +80,7 @@ namespace AIParkingApplication
pingResult.BackColor = Color.Red;
break;
}
}
else
{
pingResult.ReplyTime = 0;
@@ -80,7 +93,12 @@ namespace AIParkingApplication
{
public long ReplyTime { get; set; }
public Color BackColor { get; set; }
public Color ForceColor { get; set; }
public Color ForeColor { get; set; }
}
private void StatusBar_Load(object sender, EventArgs e)
{
updateInfoThread.Start();
}
}
}

View File

@@ -1,10 +1,15 @@
using Newtonsoft.Json;
using Microsoft.Win32;
using Newtonsoft.Json;
using OpenCvSharp;
using System;
using System.Configuration;
using System.Diagnostics;
using System.Net.Http;
using System.Drawing;
using System.IO;
using System.Net;
using System.Net.NetworkInformation;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AIParkingApplication
{
@@ -50,29 +55,127 @@ namespace AIParkingApplication
return sf.GetMethod().Name;
}
public static async Task<OcrResult> SendEngineRequestAsync(Mat plateImage, PlateType plateType)
public static Bitmap ConvertFromBase64Image(string base64ImageString)
{
byte[] imageData = Convert.FromBase64String(base64ImageString);
using (var memoryStream = new MemoryStream(imageData))
{
Bitmap image = new Bitmap(memoryStream);
return image;
}
}
public static void ExecuteCommand(string command)
{
var processInfo = new ProcessStartInfo("cmd.exe", "/c " + command);
processInfo.CreateNoWindow = true;
processInfo.UseShellExecute = false;
processInfo.RedirectStandardError = true;
processInfo.RedirectStandardOutput = true;
using (var process = Process.Start(processInfo))
{
process.OutputDataReceived += (object sender, DataReceivedEventArgs e) => Console.WriteLine("Engine Output >>" + e.Data);
process.BeginOutputReadLine();
process.ErrorDataReceived += (object sender, DataReceivedEventArgs e) => Console.WriteLine("Engine Error >>" + e.Data);
process.BeginErrorReadLine();
//process.WaitForExit();
//Console.WriteLine("ExitCode: {0}", process.ExitCode);
//process.Close();
}
}
public static bool IsValidIPAddress(string ipAddress)
{
if (string.IsNullOrEmpty(ipAddress))
{
return false;
}
bool isValidIPAddress = IPAddress.TryParse(ipAddress, out IPAddress ip);
return isValidIPAddress;
}
public static void ParseHostString(string hostString, out string hostName, out int port)
{
if (!hostString.Contains(":"))
{
hostName = hostString;
port = 80;
return;
}
string[] hostParts = hostString.Split(':');
if (hostParts.Length != 2)
{
hostName = string.Empty;
port = 0;
return;
}
hostName = hostParts[0];
int.TryParse(hostParts[1], out port);
}
public static void UpsertAppSettings(string key, string value)
{
string plateImageBase64 = Convert.ToBase64String(plateImage.ToBytes());
try
{
using (var client = new HttpClient { BaseAddress = new Uri("http://localhost:8080/"), Timeout = TimeSpan.FromMilliseconds(5000) })
var configFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
var settings = configFile.AppSettings.Settings;
if (settings[key] == null)
{
var request = new PlateRequestEngineModel
{
Img64 = plateImageBase64,
Mode = plateType == PlateType.Square ? "square" : "long",
Display = "full"
};
HttpResponseMessage response = await client.PostAsJsonAsync("/get-from-frame", request);
response.EnsureSuccessStatusCode();
var ocrResult = await response.Content.ReadAsAsync<OcrResult>();
return ocrResult;
settings.Add(key, value);
}
else
{
settings[key].Value = value;
}
configFile.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection(configFile.AppSettings.SectionInformation.Name);
}
catch (Exception ex)
catch (ConfigurationErrorsException ex)
{
Console.WriteLine($"SendEngineRequest : {ex.Message}");
return new OcrResult();
Console.WriteLine($"{DateTime.Now.GetTimeFormatted()}\tAddOrUpdateAppSettings\t{ex.Message}");
}
}
public static Rect ConvertRectangleToRect(Rectangle pictureBoxRoi, PictureBox pictureBoxPlateVideo)
{
Rect temp = new Rect
{
X = pictureBoxRoi.X * 1280 / pictureBoxPlateVideo.Width,
Y = pictureBoxRoi.Y * 720 / pictureBoxPlateVideo.Height,
Width = pictureBoxRoi.Width * 1280 / pictureBoxPlateVideo.Width,
Height = pictureBoxRoi.Height * 720 / pictureBoxPlateVideo.Height
};
return temp;
}
public static Rectangle ConvertStringToRectangle(string input)
{
var roi = JsonConvert.DeserializeObject<RoiConfig>(input);
return new Rectangle
{
X = roi.X,
Y = roi.Y,
Height = roi.Height,
Width = roi.Width
};
}
public static void AddApplicationToStartup()
{
using (RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true))
{
key.SetValue("AIParkingApplication", "\"" + Application.ExecutablePath + "\"");
}
}
public static void RemoveApplicationFromStartup()
{
using (RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true))
{
key.DeleteValue("AIParkingApplication", false);
}
}
}
@@ -92,10 +195,10 @@ namespace AIParkingApplication
public class OcrResult
{
[JsonProperty("ocr")]
public string Ocr { get; set; }
public string PlateString { get; set; }
[JsonProperty("plate")]
public string Plate { get; set; }
public string PlateImageBase64 { get; set; }
}
public static class UtilConstant
@@ -105,4 +208,22 @@ namespace AIParkingApplication
public const string HTTP_POST_METHOD = "POST";
public const string HTTP_POST_CONTENTTYPE = "application/json";
}
public class RoiConfig
{
[JsonProperty("x")]
public int X { get; set; }
[JsonProperty("y")]
public int Y { get; set; }
[JsonProperty("width")]
public int Width { get; set; }
[JsonProperty("height")]
public int Height { get; set; }
[JsonProperty("camera_id")]
public string CameraID { get; set; }
}
}

View File

@@ -0,0 +1,3 @@
@echo off
wsl bash -c "cd ~/AIParking_Engine_deploy && tmux new-session -d -s "engine" gunicorn app:app -b 0.0.0.0:8080 --workers=2"
exit

View File

@@ -2,8 +2,12 @@
<packages>
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.7" targetFramework="net461" />
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net461" />
<package id="NLog" version="4.7.2" targetFramework="net461" />
<package id="NLog.Config" version="4.7.2" targetFramework="net461" />
<package id="NLog.Schema" version="4.7.2" targetFramework="net461" />
<package id="OpenCvSharp4" version="4.3.0.20200524" targetFramework="net461" />
<package id="OpenCvSharp4.runtime.win" version="4.3.0.20200524" targetFramework="net461" />
<package id="OpenCvSharp4.Windows" version="4.3.0.20200524" targetFramework="net461" />
<package id="System.Net.Http" version="4.3.4" targetFramework="net461" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.7.1" targetFramework="net461" />
</packages>

View File

@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
@media only print {
@page {
margin: 0;
}
body {
margin: 0 20px;
height: 100px;
}
}
</style>
</head>
<body style="">
<h3 style="text-align: center;"><em>BỆNH VIỆN BẠCH MAI</em></h3>
<h2 style="text-align: center;"><strong>Biên lai thu tiền</strong></h2>
<p>Biển số xe: <em><strong>{PLATE_STRING}</strong></em></p>
<p>Thời gian vào: <em><strong>{TIME_PARKING_IN}</strong></em></p>
<p>Thời gian ra: <strong><em>{TIME_PARKING_OUT}</em></strong></p>
<p>Số tiền: <strong><em>{MONEY_AMOUNT}</em></strong></p>
</body>
</html>

BIN
packages/NLog.4.7.2/.signature.p7s vendored Normal file

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

BIN
packages/NLog.4.7.2/lib/net35/NLog.dll vendored Normal file

Binary file not shown.

29160
packages/NLog.4.7.2/lib/net35/NLog.xml vendored Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

BIN
packages/NLog.4.7.2/lib/net45/NLog.dll vendored Normal file

Binary file not shown.

29589
packages/NLog.4.7.2/lib/net45/NLog.xml vendored Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

BIN
packages/NLog.4.7.2/lib/sl4/NLog.dll vendored Normal file

Binary file not shown.

21873
packages/NLog.4.7.2/lib/sl4/NLog.xml vendored Normal file

File diff suppressed because it is too large Load Diff

BIN
packages/NLog.4.7.2/lib/sl5/NLog.dll vendored Normal file

Binary file not shown.

22039
packages/NLog.4.7.2/lib/sl5/NLog.xml vendored Normal file

File diff suppressed because it is too large Load Diff

BIN
packages/NLog.4.7.2/lib/wp8/NLog.dll vendored Normal file

Binary file not shown.

21215
packages/NLog.4.7.2/lib/wp8/NLog.xml vendored Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log">
<!-- optional, add some variables
https://github.com/nlog/NLog/wiki/Configuration-file#variables
-->
<variable name="myvar" value="myvalue"/>
<!--
See https://github.com/nlog/nlog/wiki/Configuration-file
for information on customizing logging rules and outputs.
-->
<targets>
<!--
add your targets here
See https://github.com/nlog/NLog/wiki/Targets for possible targets.
See https://github.com/nlog/NLog/wiki/Layout-Renderers for the possible layout renderers.
-->
<!--
Write events to a file with the date in the filename.
<target xsi:type="File" name="f" fileName="${basedir}/logs/${shortdate}.log"
layout="${longdate} ${uppercase:${level}} ${message}" />
-->
</targets>
<rules>
<!-- add your logging rules here -->
<!--
Write all events with minimal level of Debug (So Debug, Info, Warn, Error and Fatal, but not Trace) to "f"
<logger name="*" minlevel="Debug" writeTo="f" />
-->
</rules>
</nlog>

View File

@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log">
<!-- optional, add some variables
https://github.com/nlog/NLog/wiki/Configuration-file#variables
-->
<variable name="myvar" value="myvalue"/>
<!--
See https://github.com/nlog/nlog/wiki/Configuration-file
for information on customizing logging rules and outputs.
-->
<targets>
<!--
add your targets here
See https://github.com/nlog/NLog/wiki/Targets for possible targets.
See https://github.com/nlog/NLog/wiki/Layout-Renderers for the possible layout renderers.
-->
<!--
Write events to a file with the date in the filename.
<target xsi:type="File" name="f" fileName="${basedir}/logs/${shortdate}.log"
layout="${longdate} ${uppercase:${level}} ${message}" />
-->
</targets>
<rules>
<!-- add your logging rules here -->
<!--
Write all events with minimal level of Debug (So Debug, Info, Warn, Error and Fatal, but not Trace) to "f"
<logger name="*" minlevel="Debug" writeTo="f" />
-->
</rules>
</nlog>

View File

@@ -0,0 +1,12 @@
param($installPath, $toolsPath, $package, $project)
$configItem = $project.ProjectItems.Item("NLog.config")
# set 'Copy To Output Directory' to 'Copy if newer'
$copyToOutput = $configItem.Properties.Item("CopyToOutputDirectory")
$copyToOutput.Value = 2
# set 'Build Action' to 'Content'
$buildAction = $configItem.Properties.Item("BuildAction")
$buildAction.Value = 2

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff