Explorar el Código

Merge remote-tracking branch 'gedian/dev' into dev

kingwang1995 hace 7 años
padre
commit
3b72278b27

+ 1 - 0
parkMonitor/DataBase/DBConnectionPool.cs

@@ -135,6 +135,7 @@ namespace parkMonitor.DataBase
             bool result = true;
             bool result = true;
             if (conn != null)
             if (conn != null)
             {
             {
+                string sql = "select garageFreeSpace from garage where garageID = '"+ ParkingSpaceManager.garageID+ "'";
                 string sql = "select garageFreeSpace from garage where garageID = '1'";
                 string sql = "select garageFreeSpace from garage where garageID = '1'";
                 MySqlCommand cmd = new MySqlCommand(sql, conn);
                 MySqlCommand cmd = new MySqlCommand(sql, conn);
                 try
                 try

+ 23 - 20
parkMonitor/DataBase/IDBOperation.cs

@@ -110,35 +110,38 @@ namespace parkMonitor.DataBase
                 Operation.malfunctionRemote = true;
                 Operation.malfunctionRemote = true;
                 Operation.malfunctionLocal = true;
                 Operation.malfunctionLocal = true;
             }
             }
-            while (conn != null && conn.State != ConnectionState.Open)
+            else
             {
             {
-                mt.EndTiming();
-                if (mt.IsLonger(45, 1, false, out count) && count >= 2)
+                while (conn != null && conn.State != ConnectionState.Open)
                 {
                 {
-                    if (conn.DataSource == DBConnection.remoteIP)
+                    mt.EndTiming();
+                    if (mt.IsLonger(45, 1, false, out count) && count >= 2)
                     {
                     {
-                        if (count == 2)
+                        if (conn.DataSource == DBConnection.remoteIP)
                         {
                         {
-                            UILogServer.ins.error("暂时无法连接远端数据库, 请检查网络连接后点击“控制面板-启动远端DB”恢复。");
-                            Log.WriteLog(LogType.NOT_DATABASE, LogFile.ERROR, "与远端DB失去连接");
+                            if (count == 2)
+                            {
+                                UILogServer.ins.error("暂时无法连接远端数据库, 请检查网络连接后点击“控制面板-启动远端DB”恢复。");
+                                Log.WriteLog(LogType.NOT_DATABASE, LogFile.ERROR, "与远端DB失去连接");
+                            }
+                            Operation.malfunctionRemote = true;
                         }
                         }
-                        Operation.malfunctionRemote = true;
-                    }
-                    else if (conn.DataSource == DBConnection.localIP)
-                    {
-                        if (count == 2)
+                        else if (conn.DataSource == DBConnection.localIP)
                         {
                         {
-                            UILogServer.ins.error("暂时无法连接本地数据库,请检查网络连接后点击“控制面板-启动本地DB”恢复。");
-                            Log.WriteLog(LogType.NOT_DATABASE, LogFile.ERROR, "与本地DB失去连接");
+                            if (count == 2)
+                            {
+                                UILogServer.ins.error("暂时无法连接本地数据库,请检查网络连接后点击“控制面板-启动本地DB”恢复。");
+                                Log.WriteLog(LogType.NOT_DATABASE, LogFile.ERROR, "与本地DB失去连接");
+                            }
+                            Operation.malfunctionLocal = true;
                         }
                         }
-                        Operation.malfunctionLocal = true;
                     }
                     }
-                };
-                try
-                {
-                    conn.Open();
+                    try
+                    {
+                        conn.Open();
+                    }
+                    catch { }
                 }
                 }
-                catch { }
             }
             }
         }
         }
 
 

+ 4 - 2
parkMonitor/controlPanel/ControlPanel.cs

@@ -105,7 +105,8 @@ namespace parkMonitor.controlPanel
             bool initState = false;
             bool initState = false;
             if (Operation.malfunctionRemote)
             if (Operation.malfunctionRemote)
             {
             {
-                using (MySqlConnection conn = new MySqlConnection(DBConnection.remoteConf))
+                using (MySqlConnection conn = DBConnectionPool.getPool(DBConnection.remoteConf).getConnection())
+                //using (MySqlConnection conn = new MySqlConnection(DBConnection.remoteConf))
                 {
                 {
                     Operation.TryOpen(conn);
                     Operation.TryOpen(conn);
                     initState = conn.Ping();
                     initState = conn.Ping();
@@ -124,7 +125,8 @@ namespace parkMonitor.controlPanel
             bool initState = false;
             bool initState = false;
             if (Operation.malfunctionLocal)
             if (Operation.malfunctionLocal)
             {
             {
-                using (MySqlConnection conn = new MySqlConnection(DBConnection.remoteConf))
+                using (MySqlConnection conn = DBConnectionPool.getPool(DBConnection.remoteConf).getConnection())
+                //using (MySqlConnection conn = new MySqlConnection(DBConnection.remoteConf))
                 {
                 {
                     Operation.TryOpen(conn);
                     Operation.TryOpen(conn);
                     initState = conn.Ping();
                     initState = conn.Ping();

+ 12 - 4
parkMonitor/entity/EntityForCore.cs

@@ -66,18 +66,22 @@ namespace parkMonitor.entity
             Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "数据库初始配置");
             Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "数据库初始配置");
             DBConnection.Init();
             DBConnection.Init();
             //远端连接测试
             //远端连接测试
-            using (MySqlConnection conn = new MySqlConnection(DBConnection.remoteConf))
+            using (MySqlConnection conn = DBConnectionPool.getPool(DBConnection.remoteConf).getConnection())
+            //using (MySqlConnection conn = new MySqlConnection(DBConnection.remoteConf))
             {
             {
                 Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "远端数据库连接测试");
                 Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "远端数据库连接测试");
                 Operation.TryOpen(conn);
                 Operation.TryOpen(conn);
                 initState = conn.Ping();
                 initState = conn.Ping();
+                Operation.DBClose(conn, null, null);
             }
             }
             //本地连接测试
             //本地连接测试
-            using (MySqlConnection conn = new MySqlConnection(DBConnection.localConf))
+            using (MySqlConnection conn = DBConnectionPool.getPool(DBConnection.remoteConf).getConnection())
+            //using (MySqlConnection conn = new MySqlConnection(DBConnection.localConf))
             {
             {
                 Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "本地数据库连接测试");
                 Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "本地数据库连接测试");
                 Operation.TryOpen(conn);
                 Operation.TryOpen(conn);
                 initState = initState && conn.Ping();
                 initState = initState && conn.Ping();
+                Operation.DBClose(conn, null, null);
             }
             }
             //车位管理初始化
             //车位管理初始化
             Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "初始化车位");
             Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "初始化车位");
@@ -106,21 +110,25 @@ namespace parkMonitor.entity
             //远端连接测试
             //远端连接测试
             if (DBmode == 0 || DBmode == 1)
             if (DBmode == 0 || DBmode == 1)
             {
             {
-                using (MySqlConnection conn = new MySqlConnection(DBConnection.remoteConf))
+                using (MySqlConnection conn = DBConnectionPool.getPool(DBConnection.remoteConf).getConnection())
+                //using (MySqlConnection conn = new MySqlConnection(DBConnection.remoteConf))
                 {
                 {
                     Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "远端数据库连接测试");
                     Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "远端数据库连接测试");
                     Operation.TryOpen(conn);
                     Operation.TryOpen(conn);
                     initState = conn.Ping();
                     initState = conn.Ping();
+                    DBConnectionPool.getPool(DBConnection.remoteConf).ConnectionClose(conn);
                 }
                 }
             }
             }
             //本地连接测试
             //本地连接测试
             if (DBmode == 0 || DBmode == 1)
             if (DBmode == 0 || DBmode == 1)
             {
             {
-                using (MySqlConnection conn = new MySqlConnection(DBConnection.localConf))
+                using (MySqlConnection conn = DBConnectionPool.getPool(DBConnection.remoteConf).getConnection())
+                //using (MySqlConnection conn = new MySqlConnection(DBConnection.localConf))
                 {
                 {
                     Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "本地数据库连接测试");
                     Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "本地数据库连接测试");
                     Operation.TryOpen(conn);
                     Operation.TryOpen(conn);
                     initState = initState && conn.Ping();
                     initState = initState && conn.Ping();
+                    Operation.DBClose(conn, null, null);
                 }
                 }
             }
             }
             //车位管理初始化
             //车位管理初始化

+ 0 - 23
parkMonitor/entity/EquipmentSimpleFactory.cs

@@ -65,29 +65,6 @@ namespace parkMonitor.entity
 			} catch(Exception ex) {
 			} catch(Exception ex) {
 				Debug.WriteLine(ex.ToString());
 				Debug.WriteLine(ex.ToString());
 			}
 			}
-
-			//switch (equistr)
-   //         {
-   //             case "PLC":
-   //                 {
-   //                     //equipments = new PLCLinker();
-   //                 }
-   //                 break;
-   //             case "Num":
-   //                 {
-   //                    // equipments = new NumMachineLinker();
-   //                 }
-   //                 break;
-   //             case "Laser":
-   //                 {
-   //                    // equipments = new LaserLinker();
-   //                 }
-   //                 break;
-   //             default:
-   //                 {
-   //                     break;
-   //                 }
-   //         }
             return equipments;
             return equipments;
         }
         }
     }
     }

+ 0 - 27
parkMonitor/entity/IEquipmentsFactory.cs

@@ -1,27 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace parkMonitor.entity
-{
-    interface IEquipmentsFactory
-    {
-        IEquipments CreateEquipment();
-    }
-
-
-    //class EquipmentsLaserFactory :IEquipmentsFactory
-    //{
-    //    public Equipments createEquipment()
-    //    {
-    //        return new PLC();
-    //    }
-    //}
-
-    //class Laser : Equipments
-    //{
-
-    //}
-}

+ 0 - 1
parkMonitor/parkMonitor.csproj

@@ -117,7 +117,6 @@
     <Compile Include="entity\Equipments.cs" />
     <Compile Include="entity\Equipments.cs" />
     <Compile Include="entity\EquipmentSimpleFactory.cs" />
     <Compile Include="entity\EquipmentSimpleFactory.cs" />
     <Compile Include="entity\ICoreThreadDoWorking.cs" />
     <Compile Include="entity\ICoreThreadDoWorking.cs" />
-    <Compile Include="entity\IEquipmentsFactory.cs" />
     <Compile Include="entity\Jsonhelper.cs" />
     <Compile Include="entity\Jsonhelper.cs" />
     <Compile Include="LOG\Log.cs" />
     <Compile Include="LOG\Log.cs" />
     <Compile Include="LOG\LogManager.cs" />
     <Compile Include="LOG\LogManager.cs" />

BIN
parkMonitor/resource/inlineRes/plcAddr.csv


+ 49 - 53
parkMonitor/server/CoreThread/AbstractCmd.cs

@@ -228,7 +228,8 @@ namespace parkMonitor.server.CoreThread
                     }
                     }
                     try
                     try
                     {
                     {
-                        using (MySqlConnection conn = new MySqlConnection(DBConnection.remoteConf))
+                        using (MySqlConnection conn = DBConnectionPool.getPool(DBConnection.remoteConf).getConnection())
+                        //using (MySqlConnection conn = new MySqlConnection(DBConnection.remoteConf))
                         {
                         {
                             Operation.TryOpen(conn);
                             Operation.TryOpen(conn);
                             bool DBStoreStatus = false;                       //判断数据库事务操作是否正常
                             bool DBStoreStatus = false;                       //判断数据库事务操作是否正常
@@ -266,7 +267,8 @@ namespace parkMonitor.server.CoreThread
                     }
                     }
                     try
                     try
                     {
                     {
-                        using (MySqlConnection conn = new MySqlConnection(DBConnection.remoteConf))
+                        using (MySqlConnection conn = DBConnectionPool.getPool(DBConnection.remoteConf).getConnection())
+                        //using (MySqlConnection conn = new MySqlConnection(DBConnection.remoteConf))
                         {
                         {
                             Operation.TryOpen(conn);
                             Operation.TryOpen(conn);
                             bool DBStoreStatus = false;                       //判断数据库事务操作是否正常
                             bool DBStoreStatus = false;                       //判断数据库事务操作是否正常
@@ -667,29 +669,7 @@ namespace parkMonitor.server.CoreThread
             {
             {
                 bool displayed = false;
                 bool displayed = false;
                 //等待获取缓冲位资源
                 //等待获取缓冲位资源
-                while (pb == null && !MyTimer.restart)
-                {
-                    pb = ParkingBufferManager.ins.MallocParkingBuffer(queueCmd.id);
-                    if (pb != null)
-                    {
-                        Log.WriteLog(LogType.NOT_DATABASE, LogFile.INFO, queueCmd.LicenseNum + "分配缓冲位:" + pb.bufferID);
-                        break;
-                    }
-                    else if (!displayed)
-                    {
-                        UILogServer.ins.error(queueCmd.LicenseNum + "缓冲位已满");
-                        Log.WriteLog(LogType.NOT_DATABASE, LogFile.WARNING, queueCmd.LicenseNum + "缓冲位分配失败");
-                        displayed = true;
-                    }
-                    Thread.Sleep(2000);
-                }
-                if (pb == null)
-                {
-                    UILogServer.ins.error("缓冲位分配失败,流程已回滚");
-                    Log.WriteLog(LogType.NOT_DATABASE, LogFile.ERROR, "缓冲位分配失败,流程已回滚");
-                    Rollback(queueCmd, 0, false, true, lmToBeReleased);
-                    return;
-                }
+                
 
 
                 //获取车位资源
                 //获取车位资源
                 ppp = WaitForParkingSpaceResource(queueCmd, out freeSpaceCount);
                 ppp = WaitForParkingSpaceResource(queueCmd, out freeSpaceCount);
@@ -737,9 +717,35 @@ namespace parkMonitor.server.CoreThread
                     return;
                     return;
                 }
                 }
 
 
+                while (pb == null && !MyTimer.restart)
+                {
+                    //pb = ParkingBufferManager.ins.MallocParkingBuffer(queueCmd.id);
+                    pb = new ParkingBuffer(ppp.parkingSpaceX, true);
+                    ParkingBufferManager.ins.SetParkingBuffer(ppp.parkingSpaceX, true);
+                    if (pb != null)
+                    {
+                        Log.WriteLog(LogType.NOT_DATABASE, LogFile.INFO, queueCmd.LicenseNum + "分配缓冲位:" + pb.bufferID);
+                        break;
+                    }
+                    else if (!displayed)
+                    {
+                        UILogServer.ins.error(queueCmd.LicenseNum + "缓冲位已满");
+                        Log.WriteLog(LogType.NOT_DATABASE, LogFile.WARNING, queueCmd.LicenseNum + "缓冲位分配失败");
+                        displayed = true;
+                    }
+                    Thread.Sleep(2000);
+                }
+                if (pb == null)
+                {
+                    UILogServer.ins.error("缓冲位分配失败,流程已回滚");
+                    Log.WriteLog(LogType.NOT_DATABASE, LogFile.ERROR, "缓冲位分配失败,流程已回滚");
+                    Rollback(queueCmd, 0, false, true, lmToBeReleased);
+                    return;
+                }
+
                 //车位赋值与写数据库
                 //车位赋值与写数据库
                 if (!queueCmd.manual)
                 if (!queueCmd.manual)
-                {                  
+                {
                 }
                 }
                 else
                 else
                 {
                 {
@@ -796,8 +802,8 @@ namespace parkMonitor.server.CoreThread
             //分配的车位数据
             //分配的车位数据
             cm.parkingSpaceID = Convert.ToString(ppp.parkingSpaceID);
             cm.parkingSpaceID = Convert.ToString(ppp.parkingSpaceID);
             //!!!之前把停车位X坐标当做缓冲位ID,现修改为被管理的缓冲位ID,之后PLC地址需调整!!!
             //!!!之前把停车位X坐标当做缓冲位ID,现修改为被管理的缓冲位ID,之后PLC地址需调整!!!
-            //cm.parkingSpaceX = Convert.ToString(ppp.parkingSpaceX);
-            cm.parkingSpaceX = Convert.ToString(pb.bufferID);
+            cm.parkingSpaceX = Convert.ToString(ppp.parkingSpaceX);
+            //cm.parkingSpaceX = Convert.ToString(pb.bufferID);
             cm.parkingSpaceY = Convert.ToString(ppp.parkingSpaceY);
             cm.parkingSpaceY = Convert.ToString(ppp.parkingSpaceY);
             cm.parkingSpaceZ = Convert.ToString(ppp.parkingSpaceZ);
             cm.parkingSpaceZ = Convert.ToString(ppp.parkingSpaceZ);
             PLC.SetMessage(cm);
             PLC.SetMessage(cm);
@@ -839,7 +845,7 @@ namespace parkMonitor.server.CoreThread
             Robot.robot1.waitCount -= 1;
             Robot.robot1.waitCount -= 1;
             //自动化测试用
             //自动化测试用
             //ManualParkingSimul.ins.Update(Int32.Parse(queueCmd.LicenseNum.Substring(2, 1)));
             //ManualParkingSimul.ins.Update(Int32.Parse(queueCmd.LicenseNum.Substring(2, 1)));
-            ParkingSimul.ins.Update(Int32.Parse(queueCmd.LicenseNum.Substring(2, 1)));
+            //ParkingSimul.ins.Update(Int32.Parse(queueCmd.LicenseNum.Substring(2, 1)));
             //根据号牌查找车型
             //根据号牌查找车型
             //int vehicleTypeID = oper.getVehicleTypeID(numberPlate);
             //int vehicleTypeID = oper.getVehicleTypeID(numberPlate);
             //判断测量数据是否准确
             //判断测量数据是否准确
@@ -865,10 +871,11 @@ namespace parkMonitor.server.CoreThread
                         int parkingRecordsID = 0;
                         int parkingRecordsID = 0;
                         try
                         try
                         {
                         {
-                            //using (MySqlConnection conn = DBConnectionPool.getPool(DBConnection.remoteConf).getConnection())
-                            using (MySqlConnection conn = new MySqlConnection(DBConnection.remoteConf))
+                            using (MySqlConnection conn = DBConnectionPool.getPool(DBConnection.remoteConf).getConnection())
+                            //using (MySqlConnection conn = new MySqlConnection(DBConnection.remoteConf))
                             {
                             {
                                 Operation.TryOpen(conn);
                                 Operation.TryOpen(conn);
+                                //string insertRecordSql = "insert into parkingrecords(userID,numberPlate,parkingSpaceID,garageID,parkingRecordsState,realParkTime) values('" + userID + "','" + queueCmd.LicenseNum + "','" + ppp.parkingSpaceID + "','" + garageID + "',3,'" + realParkTime + "')";
                                 string insertRecordSql = "insert into parkingrecords(userID,numberPlate,parkingSpaceID,garageID,parkingRecordsState,realParkTime) values('" + userID + "','" + queueCmd.LicenseNum + "','" + ppp.parkingSpaceID + "','" + garageID + "',3,'" + realParkTime + "')";
                                 string insertRecordSql = "insert into parkingrecords(userID,numberPlate,parkingSpaceID,garageID,parkingRecordsState,realParkTime) values('" + userID + "','" + queueCmd.LicenseNum + "','" + ppp.parkingSpaceID + "','" + garageID + "',3,'" + realParkTime + "')";
                                 if (!Operation.MyTransaction(conn, insertRecordSql, out parkingRecordsID))
                                 if (!Operation.MyTransaction(conn, insertRecordSql, out parkingRecordsID))
                                 {
                                 {
@@ -876,8 +883,8 @@ namespace parkMonitor.server.CoreThread
                                     Log.WriteLog(LogType.DATABASE, "1", insertRecordSql);
                                     Log.WriteLog(LogType.DATABASE, "1", insertRecordSql);
                                 }
                                 }
                             }
                             }
-                            //using (MySqlConnection conn = DBConnectionPool.getPool(DBConnection.remoteConf).getConnection())
-                            using (MySqlConnection conn = new MySqlConnection(DBConnection.remoteConf))
+                            using (MySqlConnection conn = DBConnectionPool.getPool(DBConnection.remoteConf).getConnection())
+                            //using (MySqlConnection conn = new MySqlConnection(DBConnection.remoteConf))
                             {
                             {
                                 Operation.TryOpen(conn);
                                 Operation.TryOpen(conn);
                                 string updateVehicleSql = "update vehicle set vehiclepParkState = 1,scanEntryTime = '" + queueCmd.TimeRecord + "',parkingRecordsID = '" + parkingRecordsID + "',parkingSpaceID = '" + ppp.parkingSpaceID + "',vehicleTypeConfirm = 1,frontwheelbase = '" + frontWheelbase + "',rearwheelbase = '" + rearWheelbase + "' where numberPlate = '" + queueCmd.LicenseNum + "'";
                                 string updateVehicleSql = "update vehicle set vehiclepParkState = 1,scanEntryTime = '" + queueCmd.TimeRecord + "',parkingRecordsID = '" + parkingRecordsID + "',parkingSpaceID = '" + ppp.parkingSpaceID + "',vehicleTypeConfirm = 1,frontwheelbase = '" + frontWheelbase + "',rearwheelbase = '" + rearWheelbase + "' where numberPlate = '" + queueCmd.LicenseNum + "'";
@@ -1119,7 +1126,7 @@ namespace parkMonitor.server.CoreThread
 
 
             //自动化测试用
             //自动化测试用
             //ManualParkingSimul.ins.Update(Int32.Parse(queueCmd.LicenseNum.Substring(2, 1)));
             //ManualParkingSimul.ins.Update(Int32.Parse(queueCmd.LicenseNum.Substring(2, 1)));
-            ParkingSimul.ins.Update(Int32.Parse(queueCmd.LicenseNum.Substring(2, 1)));
+            //ParkingSimul.ins.Update(Int32.Parse(queueCmd.LicenseNum.Substring(2, 1)));
 
 
             int freeSpaceCount = ParkingSpaceManager.ins.GetFreeSpaceCount();
             int freeSpaceCount = ParkingSpaceManager.ins.GetFreeSpaceCount();
             //数据库更新
             //数据库更新
@@ -1129,41 +1136,30 @@ namespace parkMonitor.server.CoreThread
                 {
                 {
                     if (!queueCmd.manual)
                     if (!queueCmd.manual)
                     {
                     {
-                        //云端数据库更新
-                        //更新车库表车位数
-                        //int freeSpaceCount = oper.getGarageFreeSpace(DBConnection.remoteStr, garageID);
-                        //freeSpaceCount = freeSpaceCount + 1;
-                        //oper.UpdateGarageFreeSpace(connectionStr, freeSpaceCount, garageID);
-                        //更新车位表车位状态
-                        //oper.UpdateParkingSpaceState(connectionStr, ps.parkingSpaceID, 0);
-                        //更新车辆表车辆停车状态
-                        //oper.UpdateVehicleParkState(connectionStr, queueCmd.LicenseNum, 0);
-                        //更新停车记录表
-                        //oper.UpdateParkingRecords(connectionStr, 6, queueCmd.TimeRecord, queueCmd.parkingRecordsID);
                         //取车事务
                         //取车事务
                         try
                         try
                         {
                         {
-                            //using (MySqlConnection conn = DBConnectionPool.getPool(DBConnection.remoteConf).getConnection())
-                            using (MySqlConnection conn = new MySqlConnection(DBConnection.remoteConf))
+                            using (MySqlConnection conn = DBConnectionPool.getPool(DBConnection.remoteConf).getConnection())
+                            //using (MySqlConnection conn = new MySqlConnection(DBConnection.remoteConf))
                             {
                             {
                                 Operation.TryOpen(conn);
                                 Operation.TryOpen(conn);
                                 bool DBStoreStatus = false;       //判断数据库事务操作是否正常 
                                 bool DBStoreStatus = false;       //判断数据库事务操作是否正常 
                                 int temp;
                                 int temp;
                                 List<string> strs = new List<string>();
                                 List<string> strs = new List<string>();
-                                string updateParkingSpaceStateSql = "update parkingspace set parkingSpaceState = 0 where parkingSpaceID = '" + ps.parkingSpaceID + "'";
-                                string updateFreeSpaceSql = "update garage set garageFreeSpace = '" + freeSpaceCount + "' where garageID = '" + garageID + "'";
+                                //string updateParkingSpaceStateSql = "update parkingspace set parkingSpaceState = 0 where parkingSpaceID = '" + ps.parkingSpaceID + "'";
+                                //string updateFreeSpaceSql = "update garage set garageFreeSpace = '" + freeSpaceCount + "' where garageID = '" + garageID + "'";
                                 string updateVehicleStateSql = "update vehicle set vehiclepParkState = 0 where numberPlate = '" + queueCmd.LicenseNum + "'";
                                 string updateVehicleStateSql = "update vehicle set vehiclepParkState = 0 where numberPlate = '" + queueCmd.LicenseNum + "'";
                                 string updateParkingRecordsSql = "update parkingrecords set parkingRecordsState = 6,realGetTime = '" + queueCmd.TimeRecord + "'where parkingRecordsID = '" + queueCmd.parkingRecordsID + "'";
                                 string updateParkingRecordsSql = "update parkingrecords set parkingRecordsState = 6,realGetTime = '" + queueCmd.TimeRecord + "'where parkingRecordsID = '" + queueCmd.parkingRecordsID + "'";
-                                strs.Add(updateParkingSpaceStateSql);
-                                strs.Add(updateFreeSpaceSql);
+                                //strs.Add(updateParkingSpaceStateSql);
+                                //strs.Add(updateFreeSpaceSql);
                                 strs.Add(updateVehicleStateSql);
                                 strs.Add(updateVehicleStateSql);
                                 strs.Add(updateParkingRecordsSql);
                                 strs.Add(updateParkingRecordsSql);
                                 if (!Operation.MyTransaction(conn, strs, out temp))
                                 if (!Operation.MyTransaction(conn, strs, out temp))
                                 {
                                 {
                                     Log.WriteLog(LogType.NOT_DATABASE, "数据库操作出错,记录sql语句等待流程回滚");
                                     Log.WriteLog(LogType.NOT_DATABASE, "数据库操作出错,记录sql语句等待流程回滚");
                                     //写日志记录sql,以待之后处理
                                     //写日志记录sql,以待之后处理
-                                    Log.WriteLog(LogType.DATABASE, "0", updateParkingSpaceStateSql);
-                                    Log.WriteLog(LogType.DATABASE, "0", updateFreeSpaceSql);
+                                    //Log.WriteLog(LogType.DATABASE, "0", updateParkingSpaceStateSql);
+                                    //Log.WriteLog(LogType.DATABASE, "0", updateFreeSpaceSql);
                                     Log.WriteLog(LogType.DATABASE, "0", updateVehicleStateSql);
                                     Log.WriteLog(LogType.DATABASE, "0", updateVehicleStateSql);
                                     Log.WriteLog(LogType.DATABASE, "0", updateParkingRecordsSql);
                                     Log.WriteLog(LogType.DATABASE, "0", updateParkingRecordsSql);
                                 }
                                 }

+ 7 - 52
parkMonitor/server/CoreThread/CoreThreadTest2.cs

@@ -189,36 +189,6 @@ namespace parkMonitor.server.CoreThread
                 }
                 }
                 Thread.Sleep(100);
                 Thread.Sleep(100);
             }
             }
-
-            //同步数据库
-            //Task.Factory.StartNew(() =>
-            //{
-            //    while (true)
-            //    {
-            //        try
-            //        {
-            //            //更新车库表车位数
-            //            int freeSpaceCount = oper.getGarageFreeSpace("SqlConnectionLocation",localGarageId);
-            //            oper.UpdateGarageFreeSpace("SqlConnectionStr",freeSpaceCount, localGarageId);
-            //            //更新车位状态                       
-            //            //int[] parkingSpace = oper.GetAllParkingSpaceID(localGarageId);
-            //            Dictionary<int, Parking_Space> lps = oper.GetAllParkingSpace("SqlConnectionLocation", localGarageId);
-            //            if (lps != null)
-            //            {
-            //                //Dictionary<>
-            //                for (int i = 1; i <= lps.Count; i++)
-            //                {
-            //                    oper.UpdateParkingSpaceState("SqlConnectionStr", lps[i].parkingSpaceID,lps[i].parkingSpaceState);
-            //                }
-            //            }
-            //        }
-            //        catch (Exception)
-            //        {
-            //            Console.WriteLine("无同步数据");
-            //        }
-            //        Thread.Sleep(8000);
-            //    }
-            //});
         }
         }
 
 
         /// <summary>挂起</summary>
         /// <summary>挂起</summary>
@@ -250,22 +220,7 @@ namespace parkMonitor.server.CoreThread
                 Thread.Sleep(200);
                 Thread.Sleep(200);
             }
             }
         }
         }
-        /// <summary>
-        /// 获取可执行号牌
-        /// </summary>
-        //private AbstractMessage GetExecuteNumberPlate()
-        //{
-        //    AbstractMessage msg = null;
-        //    while (!isClosing)
-        //    {
-        //        msg = queuingThread.GetMessage();
-        //        if (msg != null)
-        //        {
-        //            break;
-        //        }
-        //    }
-        //    return msg;
-        //}
+
         /// <summary>
         /// <summary>
         /// 定时执行车库、车位更新
         /// 定时执行车库、车位更新
         /// </summary>
         /// </summary>
@@ -276,8 +231,8 @@ namespace parkMonitor.server.CoreThread
                 int freeSpaceCount = ParkingSpaceManager.ins.GetFreeSpaceCount();
                 int freeSpaceCount = ParkingSpaceManager.ins.GetFreeSpaceCount();
                 try
                 try
                 {
                 {
-                    //using (MySqlConnection conn = DBConnectionPool.getPool(DBConnection.remoteConf).getConnection())
-                    using (MySqlConnection conn = new MySqlConnection(DBConnection.remoteConf))
+                    using (MySqlConnection conn = DBConnectionPool.getPool(DBConnection.remoteConf).getConnection())
+                    //using (MySqlConnection conn = new MySqlConnection(DBConnection.remoteConf))
                     {
                     {
 
 
                         Operation.TryOpen(conn);
                         Operation.TryOpen(conn);
@@ -340,8 +295,8 @@ namespace parkMonitor.server.CoreThread
                         int parkingRecordsID = 0;
                         int parkingRecordsID = 0;
                         try
                         try
                         {
                         {
-                            //using (MySqlConnection conn = DBConnectionPool.getPool(DBConnection.remoteConf).getConnection())
-                            using (MySqlConnection conn = new MySqlConnection(DBConnection.remoteConf))
+                            using (MySqlConnection conn = DBConnectionPool.getPool(DBConnection.remoteConf).getConnection())
+                            //using (MySqlConnection conn = new MySqlConnection(DBConnection.remoteConf))
                             {
                             {
                                 Operation.TryOpen(conn);
                                 Operation.TryOpen(conn);
                                 Operation.MyTransaction(conn, sqlMsg, out parkingRecordsID);
                                 Operation.MyTransaction(conn, sqlMsg, out parkingRecordsID);
@@ -358,8 +313,8 @@ namespace parkMonitor.server.CoreThread
                         int temp;
                         int temp;
                         try
                         try
                         {
                         {
-                            //using (MySqlConnection conn = DBConnectionPool.getPool(DBConnection.remoteConf).getConnection())
-                            using (MySqlConnection conn = new MySqlConnection(DBConnection.remoteConf))
+                            using (MySqlConnection conn = DBConnectionPool.getPool(DBConnection.remoteConf).getConnection())
+                            //using (MySqlConnection conn = new MySqlConnection(DBConnection.remoteConf))
                             {
                             {
                                 Operation.TryOpen(conn);
                                 Operation.TryOpen(conn);
                                 Operation.MyTransaction(conn, sqlMsg, out temp);
                                 Operation.MyTransaction(conn, sqlMsg, out temp);

+ 17 - 0
parkMonitor/server/CoreThread/SpaceManager.cs

@@ -311,6 +311,23 @@ namespace parkMonitor.server.CoreThread
                 return false;
                 return false;
             }
             }
         }
         }
+
+        public bool SetParkingBuffer(int parkingBufferID, bool status)
+        {
+            if (CheckIfBufferExist(parkingBufferID))
+            {
+                if (bufferList[parkingBufferID-1].occupied != status)
+                {
+                    bufferList[parkingBufferID-1].occupied = status;
+                    return true;
+                }
+                else { return false; }
+            }
+            else
+            {
+                return false;
+            }
+        }
     }
     }
     /// <summary>
     /// <summary>
     /// 缓冲位单元
     /// 缓冲位单元

+ 55 - 18
parkMonitor/server/NumMachine/NumMachine.cs

@@ -22,6 +22,45 @@ using parkMonitor.LOG;
 
 
 namespace parkMonitor.server
 namespace parkMonitor.server
 {
 {
+    public class NumMachineManager : IEquipments
+    {
+        public static NumMachineLinker ins;
+        public AbstractMessage GetMessage()
+        {
+            return ins.GetMessage();
+        }
+
+        public void SetMessage(AbstractMessage message)
+        {
+            ins.SetMessage(message);
+        }
+
+        public void Start()
+        {
+            Task.Factory.StartNew(() =>
+            {
+                ins = new NumMachineLinker();
+                Task.Factory.StartNew(()=>{
+                    ins.Start();
+                    ins.Bounds = new Rectangle(0, 0, 0, 0);
+                    ins.ShowDialog();
+                });
+                
+                //ins.WindowState = FormWindowState.Minimized;
+                ins.Hide();
+            });
+        }
+
+        public void Stop()
+        {
+            Task.Factory.StartNew(() =>
+            {
+                ins.Close();
+                ins.Stop();
+            });
+        }
+    }
+
     /// <summary>
     /// <summary>
     /// 号牌机通信类
     /// 号牌机通信类
     /// </summary>
     /// </summary>
@@ -31,39 +70,38 @@ namespace parkMonitor.server
         /// 刷新时间间隔与个数
         /// 刷新时间间隔与个数
         /// </summary>
         /// </summary>
         public const int REFRESHINGTIME = 500, FILTERINGNUMBER = 8;
         public const int REFRESHINGTIME = 500, FILTERINGNUMBER = 8;
-
         ///<summary>通过设备句柄访问pic;链接时add,系统关闭时remove</summary>
         ///<summary>通过设备句柄访问pic;链接时add,系统关闭时remove</summary>
-        private Dictionary<int, PictureBox> devPicMap = new Dictionary<int, PictureBox>();
+        private static Dictionary<int, PictureBox> devPicMap = new Dictionary<int, PictureBox>();
         ///<summary>通过名字获取pic对象;创建pic时add,系统关闭remove</summary>
         ///<summary>通过名字获取pic对象;创建pic时add,系统关闭remove</summary>
-        private Dictionary<string, PictureBox> namePicMap = new Dictionary<string, PictureBox>();
+        private static Dictionary<string, PictureBox> namePicMap = new Dictionary<string, PictureBox>();
         ///<summary>通过ip获取设备id;产生ip时创建</summary>
         ///<summary>通过ip获取设备id;产生ip时创建</summary>
-        private Dictionary<string, int> ipIdMap = new Dictionary<string, int>();
+        private static Dictionary<string, int> ipIdMap = new Dictionary<string, int>();
         ///<summary>通过ip获取设备句柄;产生句柄时创建</summary>
         ///<summary>通过ip获取设备句柄;产生句柄时创建</summary>
-        private Dictionary<string, int> ipHandleMap = new Dictionary<string, int>();
+        private static Dictionary<string, int> ipHandleMap = new Dictionary<string, int>();
         /// <summary>句柄到号牌回调映射</summary>
         /// <summary>句柄到号牌回调映射</summary>
-        private Dictionary<int, VzClientSDK.VZLPRC_PLATE_INFO_CALLBACK> handleCallbackMap = new Dictionary<int, VzClientSDK.VZLPRC_PLATE_INFO_CALLBACK>();
+        private static Dictionary<int, VzClientSDK.VZLPRC_PLATE_INFO_CALLBACK> handleCallbackMap = new Dictionary<int, VzClientSDK.VZLPRC_PLATE_INFO_CALLBACK>();
         ///<summary>号牌队列</summary>
         ///<summary>号牌队列</summary>
-        private Queue<NumberMachineNode> LicBuffer = new Queue<NumberMachineNode>();
+        private static Queue<NumberMachineNode> LicBuffer = new Queue<NumberMachineNode>();
         ///<summary>计数Map</summary>
         ///<summary>计数Map</summary>
-        private Dictionary<string, Dictionary<NumberMachineNode, int>> filterMap = new Dictionary<string, Dictionary<NumberMachineNode, int>>();
+        private static Dictionary<string, Dictionary<NumberMachineNode, int>> filterMap = new Dictionary<string, Dictionary<NumberMachineNode, int>>();
         /// <summary>筛选计数</summary>
         /// <summary>筛选计数</summary>
-        private int filterCount = 0;
+        private static int filterCount = 0;
         /// <summary>系统关闭</summary>
         /// <summary>系统关闭</summary>
-        private bool isClosing = false;
+        private static bool isClosing = false;
         /// <summary>开启拍照的设备</summary>
         /// <summary>开启拍照的设备</summary>
-        private int snapshotDevHandle = -1;
+        private static int snapshotDevHandle = -1;
         /// <summary>允许无号牌时拍照</summary>
         /// <summary>允许无号牌时拍照</summary>
-        private bool enableEmptySnapshot = true;
+        private static bool enableEmptySnapshot = true;
 
 
-        private NumberMachineMessage nmMsg = new NumberMachineMessage();
-        VzClientSDK.VZLPRC_FIND_DEVICE_CALLBACK_EX find_DeviceCB = null;
-        VzClientSDK.VZLPRC_PLATE_INFO_CALLBACK m_PlateResultCB = null;
+        private static NumberMachineMessage nmMsg = new NumberMachineMessage();
+        private static VzClientSDK.VZLPRC_FIND_DEVICE_CALLBACK_EX find_DeviceCB = null;
+        private static VzClientSDK.VZLPRC_PLATE_INFO_CALLBACK m_PlateResultCB = null;
         private const int MSG_PLATE_INFO = 0x901;
         private const int MSG_PLATE_INFO = 0x901;
         private const int MSG_DEVICE_INFO = 0x902;
         private const int MSG_DEVICE_INFO = 0x902;
         /// <summary>
         /// <summary>
         /// 用于消息传递机制
         /// 用于消息传递机制
         /// </summary>
         /// </summary>
-        public IntPtr hwndMain;
+        public static IntPtr hwndMain;
 
 
         /// <summary>
         /// <summary>
         /// 号牌机类构造函数
         /// 号牌机类构造函数
@@ -637,7 +675,7 @@ namespace parkMonitor.server
         /// </summary>
         /// </summary>
         public void Start()
         public void Start()
         {
         {
-            Task.Run(() =>
+            Task.Factory.StartNew(() =>
             {
             {
                 isClosing = false;
                 isClosing = false;
 
 
@@ -652,7 +690,6 @@ namespace parkMonitor.server
                 {
                 {
                     Debug.WriteLine(ex.ToString());
                     Debug.WriteLine(ex.ToString());
                 }
                 }
-                //this.Show();
             });
             });
 
 
             Task.Factory.StartNew(() =>
             Task.Factory.StartNew(() =>

+ 14 - 14
parkMonitor/server/PLCLinker/PLCLinker.cs

@@ -158,7 +158,7 @@ namespace parkMonitor.server
                     decompressIndex.Add((48 + i).ToString());
                     decompressIndex.Add((48 + i).ToString());
                 }
                 }
                 //70-76
                 //70-76
-                for (int i = 0; i < 7; i++)
+                for (int i = 0; i < 13; i++)
                 {
                 {
                     decompressIndex.Add((70 + i).ToString());
                     decompressIndex.Add((70 + i).ToString());
                 }
                 }
@@ -739,19 +739,19 @@ namespace parkMonitor.server
                 }
                 }
             });
             });
 
 
-            //模拟plc与激光自动操作
-            Task.Factory.StartNew(() =>
-            {
-                laserAnim();
-            });
-            Task.Factory.StartNew(() =>
-            {
-                wheelbaseAnim();
-            });
-            Task.Factory.StartNew(() =>
-            {
-                autoCycling();
-            });
+            ////模拟plc与激光自动操作
+            //Task.Factory.StartNew(() =>
+            //{
+            //    laserAnim();
+            //});
+            //Task.Factory.StartNew(() =>
+            //{
+            //    wheelbaseAnim();
+            //});
+            //Task.Factory.StartNew(() =>
+            //{
+            //    autoCycling();
+            //});
         }
         }
 
 
         /// <summary>
         /// <summary>

+ 0 - 1
parkMonitor/view/menuBox/MenuBox.xaml

@@ -41,7 +41,6 @@
 						<!--<util:DevMenuListBox Margin="0,0,0,0" MiniSource="/parkMonitor;component/resource/image/menu/start.png" Content="{lng:LngBind sensor}" ItemsSource="{Binding DevMenuItems.Sensor}" Source="/parkMonitor;component/resource/image/map/Sensor.png" x:Name="lstSensor" SelectionChanged="lstSensor_SelectionChanged"/>-->
 						<!--<util:DevMenuListBox Margin="0,0,0,0" MiniSource="/parkMonitor;component/resource/image/menu/start.png" Content="{lng:LngBind sensor}" ItemsSource="{Binding DevMenuItems.Sensor}" Source="/parkMonitor;component/resource/image/map/Sensor.png" x:Name="lstSensor" SelectionChanged="lstSensor_SelectionChanged"/>-->
 						<util:ImageMenuItem Margin="0,0,5,0" MouseOverColor="#808080" MiniSource="/parkMonitor;component/resource/image/menu/start.png" Content="号牌机" Source="/parkMonitor;component/resource/image/map/numMachine.png" x:Name="muRunNumMachine" MouseLeftButtonUp="muRunNumMachine_MouseLeftButtonUp"/>
 						<util:ImageMenuItem Margin="0,0,5,0" MouseOverColor="#808080" MiniSource="/parkMonitor;component/resource/image/menu/start.png" Content="号牌机" Source="/parkMonitor;component/resource/image/map/numMachine.png" x:Name="muRunNumMachine" MouseLeftButtonUp="muRunNumMachine_MouseLeftButtonUp"/>
                         <util:ImageMenuItem Margin="0,0,5,0" MouseOverColor="#808080" MiniSource="/parkMonitor;component/resource/image/menu/start.png" Content="回滚已关闭" Source="/parkMonitor;component/resource/image/map/circulate2.png" x:Name="muRunRestartProcess" MouseLeftButtonUp="muRunRestartProcess_MouseLeftButtonUp"/>
                         <util:ImageMenuItem Margin="0,0,5,0" MouseOverColor="#808080" MiniSource="/parkMonitor;component/resource/image/menu/start.png" Content="回滚已关闭" Source="/parkMonitor;component/resource/image/map/circulate2.png" x:Name="muRunRestartProcess" MouseLeftButtonUp="muRunRestartProcess_MouseLeftButtonUp"/>
-                        <util:ImageMenuItem Margin="0,0,5,0" MouseOverColor="#808080" MiniSource="/parkMonitor;component/resource/image/menu/start.png" Content="启用远端DB" Source="/parkMonitor;component/resource/image/map/monitor.png" x:Name="muHandleCommandFromWeb" MouseLeftButtonUp="muHandleCommandFromWeb_MouseLeftButtonUp"/>
                         <util:ImageMenuItem Margin="0,0,5,0" MouseOverColor="#808080" MiniSource="/parkMonitor;component/resource/image/menu/start.png" Content="控制面板" Source="/parkMonitor;component/resource/image/map/monitor.png" x:Name="muControlPanel" MouseLeftButtonUp="muControlPanel_MouseLeftButtonUp"/>
                         <util:ImageMenuItem Margin="0,0,5,0" MouseOverColor="#808080" MiniSource="/parkMonitor;component/resource/image/menu/start.png" Content="控制面板" Source="/parkMonitor;component/resource/image/map/monitor.png" x:Name="muControlPanel" MouseLeftButtonUp="muControlPanel_MouseLeftButtonUp"/>
                         <!--<util:ImageMenuItem Margin="0,0,5,0" MouseOverColor="#808080" MiniSource="/parkMonitor;component/resource/image/menu/start.png" Content="激光雷达" Source="/parkMonitor;component/resource/image/map/laser.png" x:Name="muRunLaser" MouseLeftButtonUp="muRunLaser_MouseLeftButtonUp"/>-->
                         <!--<util:ImageMenuItem Margin="0,0,5,0" MouseOverColor="#808080" MiniSource="/parkMonitor;component/resource/image/menu/start.png" Content="激光雷达" Source="/parkMonitor;component/resource/image/map/laser.png" x:Name="muRunLaser" MouseLeftButtonUp="muRunLaser_MouseLeftButtonUp"/>-->
 						<!--<util:ImageMenuItem Margin="0,0,5,0" MouseOverColor="#808080" MiniSource="/parkMonitor;component/resource/image/menu/start.png" Content="转运系统" Source="/parkMonitor;component/resource/image/map/tray.png" x:Name="muRunTray" MouseLeftButtonUp="muRunTray_MouseLeftButtonUp"/>-->
 						<!--<util:ImageMenuItem Margin="0,0,5,0" MouseOverColor="#808080" MiniSource="/parkMonitor;component/resource/image/menu/start.png" Content="转运系统" Source="/parkMonitor;component/resource/image/map/tray.png" x:Name="muRunTray" MouseLeftButtonUp="muRunTray_MouseLeftButtonUp"/>-->

+ 0 - 14
parkMonitor/view/menuBox/MenuBox.xaml.cs

@@ -130,20 +130,6 @@ namespace parkMonitor.view.util
             //MessageBox.Show("sender:" + sender);
             //MessageBox.Show("sender:" + sender);
         }
         }
 
 
-        /// <summary>
-        /// 处理联网命令
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        private void muHandleCommandFromWeb_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
-        {
-            if (Operation.malfunctionRemote)
-            {
-                Operation.malfunctionRemote = false;
-                UILogServer.ins.info("已重新启用远端DB");
-                Log.WriteLog(LogType.NOT_DATABASE, LogFile.INFO, "已重新启用远端DB");
-            }
-        }
         /// <summary>
         /// <summary>
         /// 控制面板,管理车位与缓冲位
         /// 控制面板,管理车位与缓冲位
         /// </summary>
         /// </summary>