Browse Source

修改管理员用户编号,补充演示版发送消息提示信息,为PLC调试窗口“终端1清零”增加按钮状态清除功能。

yct 6 years ago
parent
commit
061d6acc25

+ 1 - 1
PLCLinker/centralController/FormPLCConf.cs

@@ -350,7 +350,7 @@ namespace PLCConnector
             TerminalStru tsFromTerminal = new TerminalStru
             {
                 terminalID = 1,
-                btnStatus = -1,
+                btnStatus = (short)0,
                 cmd = (short)0,
                 receiptNum = (short)0,
             };

+ 5 - 3
PLCLinker/centralController/Terminal/Terminal.cs

@@ -712,11 +712,15 @@ namespace Terminal
                     {
                         parkingRecordsSql = "INSERT INTO parkingrecords (userID, numberPlate,parkingSpaceID,garageID,parkingRecordsState,realParkTime,receiptNum,parkingPrice)" +
                             "values ('" + term.licenseCodeA + "','" + license + "','" + parkingSpaceID + "','" + Monitor.Monitor.garageID + "',3,'" + DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss") + "','" + receipt + "',NULL);";
+                        Monitor.Monitor.SetNotification("用户"+ term.licenseCodeA + "停车记录已插入", parkMonitor.model.TextColor.Info);
+                        Log.WriteLog(LogType.process, LogFile.INFO, "用户" + term.licenseCodeA + "停车记录已插入," + license + "停在" + parkingSpaceID + ",凭证号:" + receipt);
                     }
                     else
                     {
                         parkingRecordsSql = "INSERT INTO parkingrecords (userID, numberPlate,parkingSpaceID,garageID,parkingRecordsState,realParkTime,receiptNum,parkingPrice)" +
-                            "values ('" + 1 + "','" + license + "','" + parkingSpaceID + "','" + Monitor.Monitor.garageID + "',3,'" + DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss") + "','" + receipt + "',NULL);";
+                            "values ('" + 30 + "','" + license + "','" + parkingSpaceID + "','" + Monitor.Monitor.garageID + "',3,'" + DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss") + "','" + receipt + "',NULL);";
+                        Monitor.Monitor.SetNotification("用户" + term.licenseCodeA + "停车记录已插入", parkMonitor.model.TextColor.Info);
+                        Log.WriteLog(LogType.process, LogFile.INFO, "用户" + term.licenseCodeA + "停车记录已插入," + license + "停在" + parkingSpaceID + ",凭证号:" + receipt);
                     }
                     List<string> list = new List<string>();
                     list.Add(parkingRecordsSql);
@@ -724,8 +728,6 @@ namespace Terminal
                     int remoteParkingRecordsID = 0;
                     Monitor.Monitor.localDBOper.Insert(list, out parkingRecordsID);
                     Monitor.Monitor.remoteDBOper.Insert(list, out remoteParkingRecordsID);
-                    Log.WriteLog(LogType.process, LogFile.INFO, "停车记录已插入," + license + "停在" + parkingSpaceID + ",凭证号:" + receipt);
-                    Monitor.Monitor.SetNotification("停车记录已插入", parkMonitor.model.TextColor.Info);
 
                     //查询记录ID号
                     //string findRecordSql = "select parkingRecordsID from parkingrecords where receiptNum = " + term.receiptNum + ";";

+ 35 - 12
PLCLinker/centralController/Terminal/TerminalSimul.cs

@@ -16,7 +16,8 @@ namespace Terminal
         /// <summary>
         /// 停车终端模拟操作
         /// </summary>
-        public static bool ParkTermOper(int id, string carInfo)
+        /// <returns>0成功 1寻找车辆停放位置失败 2生成凭证号失败 3凭证转换异常 4停车码解析异常 5地感异常 6终端状态异常 7指令占用异常 8其他异常</returns>
+        public static int ParkTermOper(int id, string carInfo)
         {
             int countdown = 10;
             int index = -1;
@@ -29,7 +30,7 @@ namespace Terminal
                 }
             }
             if (index == -1)
-                return false;
+                return 1;
             while (!stopSimul && countdown-- > 0)
             {
                 //判断终端块是否有地感、为停车终端、空闲中,之后发送停车指令
@@ -41,7 +42,7 @@ namespace Terminal
                     if (receiptNum == "")
                     {
                         Log.WriteLog(LogType.process, LogFile.ERROR, "未能获取凭证号");
-                        return false;
+                        return 2;
                     }
                     TerminalStru ts = new TerminalStru();
                     ts.terminalID = (short)id;
@@ -51,16 +52,28 @@ namespace Terminal
                     if (!int.TryParse(receiptNum, out ts.receiptNum))
                     {
                         Log.WriteLog(LogType.process, LogFile.ERROR, "凭证转换错误");
-                        return false;
+                        return 3;
                     }
                     if (!licenseCodeEncoding(carInfo, ref ts))
-                        return false;
+                        return 4;
                     Monitor.Monitor.PLC.WriteToPLC(ts, PLCDataType.terminal);
-                    return true;
+                    return 0;
                 }
                 Thread.Sleep(300);
             }
-            return false;
+            if (Terminal.terminalInfo[1].groundStatus != 1)
+            {
+                return 5;
+            }
+            else if (Terminal.terminalInfo[1].terminalStatus != 1)
+            {
+                return 6;
+            }
+            else if (Terminal.terminalInfo[1].cmd != 0)
+            {
+                return 7;
+            }
+            return 8;
         }
         /// <summary>
         /// 用户与车辆信息编码写入PLC
@@ -106,8 +119,8 @@ namespace Terminal
         /// 取车终端模拟操作
         /// </summary>
         /// <param name="receiptNum"></param>
-        /// <returns></returns>
-        public static bool FetchTermOper(string receiptNum)
+        /// <returns>0成功 1地感异常 2终端状态异常 3指令占用异常 4凭证解析异常 5其他异常</returns>
+        public static int FetchTermOper(string receiptNum)
         {
             ////定位2号终端
             //int index = 0;
@@ -133,7 +146,7 @@ namespace Terminal
                     {
                         ts.receiptNum = int.Parse(receiptNum);
                     }
-                    catch { return false; }
+                    catch { return 4; }
                     ts.paymentStatus = 2;//强制支付完成
                     ts.btnStatus = (short)-1;
                     ts.cmd = 2;
@@ -142,11 +155,21 @@ namespace Terminal
                     ts.licenseCodeC = -1;
                     ts.licenseCodeD = -1;
                     Monitor.Monitor.PLC.WriteToPLC(ts, PLCDataType.terminal);
-                    return true;
+                    return 0;
                 }
                 Thread.Sleep(300);
             }
-            return false;
+            if (Terminal.terminalInfo[1].groundStatus != 0)
+            {
+                return 1;
+            }else if(Terminal.terminalInfo[1].terminalStatus != 2)
+            {
+                return 2;
+            }else if(Terminal.terminalInfo[1].cmd != 0)
+            {
+                return 3;
+            }
+            return 5;
         }
     }
 }

+ 55 - 21
PLCLinker/centralController/WebServer/WebServer.cs

@@ -303,7 +303,7 @@ namespace centralController.WebServer
                             returnMsg = new MessageUTF8();
                             int id = 0;
                             int countdown = 2;
-                            bool success = true;
+                            int resultCode = 8;
                             //根据号牌寻找对应号牌机编号,找不到则返回失败信息
                             if (msg.context != "" && msg.userID != "")
                             {
@@ -322,21 +322,43 @@ namespace centralController.WebServer
                             {
                                 try
                                 {
-                                    success = TerminalSimul.ParkTermOper(id, msg.context);
+                                    resultCode = TerminalSimul.ParkTermOper(id, msg.context);
                                 }
-                                catch { success = false; }
+                                catch { resultCode = 8; }
                             }
-                            else { success = false; }
+                            else { resultCode = 1; }
                             Thread.Sleep(1500);
-                            if (success)
+                            switch (resultCode)
                             {
-                                returnMsg.cmd = "PARKOK";
-                                Monitor.Monitor.SetNotification("车辆" + msg.context.Split('.')[2] + "正在进行停车", parkMonitor.model.TextColor.Info);
-                            }
-                            else
-                            {
-                                returnMsg.cmd = "PARKFAILED";
-                                Monitor.Monitor.SetNotification("未识别到车辆" + msg.context.Split('.')[2] + "停放位置,请确认车辆已入场", parkMonitor.model.TextColor.Warning);
+                                case 0:
+                                    returnMsg.cmd = "PARKOK";
+                                    Monitor.Monitor.SetNotification("车辆" + msg.context.Split('.')[2] + ",终端" + id + "正在进行停车", parkMonitor.model.TextColor.Info); break;
+                                case 1:
+                                    returnMsg.cmd = "PARKFAILED";
+                                    Monitor.Monitor.SetNotification("未识别到车辆" + msg.context.Split('.')[2] + ",终端" + id + "停放位置,请确认车辆已入场", parkMonitor.model.TextColor.Warning); break;
+                                case 2:
+                                    returnMsg.cmd = "PARKFAILED";
+                                    Monitor.Monitor.SetNotification("车辆" + msg.context.Split('.')[2] + ",终端" + id + "生成凭证号失败", parkMonitor.model.TextColor.Warning); break;
+                                case 3:
+                                    returnMsg.cmd = "PARKFAILED";
+                                    Monitor.Monitor.SetNotification("车辆" + msg.context.Split('.')[2] + ",终端" + id + "凭证转换异常", parkMonitor.model.TextColor.Warning); break;
+                                case 4:
+                                    returnMsg.cmd = "PARKFAILED";
+                                    Monitor.Monitor.SetNotification("车辆" + msg.context.Split('.')[2] + ",终端" + id + "停车码解析异常", parkMonitor.model.TextColor.Warning); break;
+                                case 5:
+                                    returnMsg.cmd = "PARKFAILED";
+                                    Monitor.Monitor.SetNotification("车辆" + msg.context.Split('.')[2] + ",终端" + id + "地感异常,当前位置无地感", parkMonitor.model.TextColor.Warning); break;
+                                case 6:
+                                    returnMsg.cmd = "PARKFAILED";
+                                    Monitor.Monitor.SetNotification("车辆" + msg.context.Split('.')[2] + ",终端" + id + "状态异常,非停车终端", parkMonitor.model.TextColor.Warning); break;
+                                case 7:
+                                    returnMsg.cmd = "PARKFAILED";
+                                    Monitor.Monitor.SetNotification("车辆" + msg.context.Split('.')[2] + ",终端" + id + "状态异常,已有停车指令在处理中", parkMonitor.model.TextColor.Warning); break;
+                                case 8:
+                                    returnMsg.cmd = "PARKFAILED";
+                                    Monitor.Monitor.SetNotification("车辆" + msg.context.Split('.')[2] + ",终端" + id + "其他异常", parkMonitor.model.TextColor.Warning);
+                                    Log.WriteLog(LogType.process, LogFile.ERROR, "凭证号" + msg.context + "出现未知异常,无法停车"); break;
+
                             }
                             returnMsg.userID = msg.userID;
                             returnMsg.garageID = Monitor.Monitor.garageID;
@@ -349,17 +371,29 @@ namespace centralController.WebServer
                         lock (fetchLock)
                         {
                             returnMsg = new MessageUTF8();
-                            bool success = TerminalSimul.FetchTermOper(msg.context);
+                            int resultCode = TerminalSimul.FetchTermOper(msg.context);
                             Thread.Sleep(1500);
-                            if (success)
-                            {
-                                returnMsg.cmd = "FETCHOK";
-                                Monitor.Monitor.SetNotification("凭证号" + msg.context + "正在取车", parkMonitor.model.TextColor.Info);
-                            }
-                            else
+                            switch (resultCode)
                             {
-                                returnMsg.cmd = "FETCHFAILED";
-                                Monitor.Monitor.SetNotification("凭证号" + msg.context + "异常,无法解析", parkMonitor.model.TextColor.Warning);
+                                case 0:
+                                    returnMsg.cmd = "FETCHOK";
+                                    Monitor.Monitor.SetNotification("凭证号" + msg.context + "正在取车", parkMonitor.model.TextColor.Info); break;
+                                case 1:
+                                    returnMsg.cmd = "FETCHFAILED";
+                                    Monitor.Monitor.SetNotification("凭证号" + msg.context + "地感异常,有地感时无法取车", parkMonitor.model.TextColor.Warning); break;
+                                case 2:
+                                    returnMsg.cmd = "FETCHFAILED";
+                                    Monitor.Monitor.SetNotification("凭证号" + msg.context + "终端状态异常,当前非取车终端", parkMonitor.model.TextColor.Warning); break;
+                                case 3:
+                                    returnMsg.cmd = "FETCHFAILED";
+                                    Monitor.Monitor.SetNotification("凭证号" + msg.context + "指令占用异常,已有取车指令在处理中", parkMonitor.model.TextColor.Warning); break;
+                                case 4:
+                                    returnMsg.cmd = "FETCHFAILED";
+                                    Monitor.Monitor.SetNotification("凭证号" + msg.context + "凭证解析异常,无法解析该凭证号", parkMonitor.model.TextColor.Warning); break;
+                                case 5:
+                                    returnMsg.cmd = "FETCHFAILED";
+                                    Monitor.Monitor.SetNotification("凭证号" + msg.context + "其他异常", parkMonitor.model.TextColor.Warning);
+                                    Log.WriteLog(LogType.process, LogFile.ERROR, "凭证号" + msg.context + "出现未知异常,无法取车"); break;
                             }
                             returnMsg.userID = msg.userID;
                             returnMsg.garageID = Monitor.Monitor.garageID;