Selaa lähdekoodia

总车位实时显示debug,解决显示不更新问题,提高总车位plc刷新频率为15s一次。

yct 6 vuotta sitten
vanhempi
commit
1c6790e4e6

+ 2 - 2
PLCLinker/centralController/App.config

@@ -7,9 +7,9 @@
     <add key="retryCount" value="3"/>
     <add key="defaultLic" value="鄂ZZZZZZ"/>
     <!--停车位显示相关配置-->
-    <add key="floors" value="13"/>
+    <add key="floors" value="17"/>
     <add key="rows" value="2"/>
-    <add key="spacesInRow" value="8"/>
+    <add key="spacesInRow" value="6"/>
     <!--数据库信息-->
     <!--<add key="remoteDBConnStr" value="Data Source=59.175.148.85;port=3306;uid=root;pooling=true;max pool size=1024;pwd=x5;database=zxpark_cloud_2;CharSet=utf8;Allow Zero Datetime=true;"/>-->
     <add key="remoteDBConnStr" value="Data Source=192.168.0.152;port=3306;uid=root;pooling=true;max pool size=1024;pwd=x5;database=zxpark_cloud_2;CharSet=utf8;Allow Zero Datetime=true;"/>

+ 31 - 11
PLCLinker/centralController/FormCentralController.cs

@@ -295,6 +295,17 @@ namespace centralController
                         idPssMap.Add(psList[i].parkingSpace, psList[i]);
                     }
                 }
+                else
+                {
+                    for (int i = 0; i < psList.Count; i++)
+                    {
+                        try
+                        {
+                            idPssMap[psList[i].parkingSpace] = psList[i];
+                        }
+                        catch { }
+                    }
+                }
 
                 TableLayoutPanel tlp = new TableLayoutPanel();
                 tlp.Name = "tlp_ParkingSpace";
@@ -361,20 +372,29 @@ namespace centralController
                         foreach (Control segment in psCC)
                         {
                             Control.ControlCollection segmentCC = segment.Controls;
-                            foreach (Control space in segmentCC)
+                            //Console.WriteLine("seg::"+segmentCC.Count);
+                            foreach (Control spaces in segmentCC)
                             {
-                                if (space.GetType() == typeof(Label))
+                                Control.ControlCollection spaceCC = spaces.Controls;
+                                //Console.WriteLine("spaces::"+spaceCC.Count);
+                                foreach (Control space in spaceCC)
                                 {
-                                    int index = -1;
-                                    int.TryParse(space.Text.Substring(2), out index);
-                                    if (idPssMap.ContainsKey(index))
-                                    {
-                                        space.BackColor = GetPSColor(idPssMap[index].spaceStatus);
-                                    }
-                                    else
+                                    if (space.GetType() == typeof(Label))
                                     {
-                                        needUpdate = true;
-                                        break;
+                                        int index = -1;
+                                        bool result = int.TryParse(space.Text.Substring(2), out index);
+                                        //Console.WriteLine("text is :" + space.Text+", index:"+index);
+                                        if (idPssMap.ContainsKey(index))
+                                        {
+                                            Console.WriteLine("index:" + index+", status:"+ idPssMap[index].spaceStatus);
+                                            space.BackColor = GetPSColor(idPssMap[index].spaceStatus);
+                                        }
+                                        else if(result)
+                                        {
+                                            needUpdate = true;
+                                            //Console.WriteLine("need update:"+index);
+                                            break;
+                                        }
                                     }
                                 }
                             }

+ 2 - 2
PLCLinker/centralController/Monitor/Monitor.cs

@@ -132,7 +132,7 @@ namespace Monitor
                     count = 0;
                     updateCount = false;
                 }
-                if (count > 300)
+                if (count > 50)
                     count = 3;
                 count++;
                 if (PLC != null)
@@ -185,7 +185,7 @@ namespace Monitor
                             }
                             catch (Exception ex) { Console.WriteLine("PLC监控中控数据," + ex.Message); }
                             //最后获得所有车位信息
-                            if (count < 10 && count % 3 == 0)
+                            if (count < 10 && count % 5 == 0)
                             {
                                 try
                                 {