Browse Source

屏显debug,声音模块不可小于16*16,清屏至少需要传一个空格。添加播放模式与延迟参数

yct 5 năm trước cách đây
mục cha
commit
a785be3fc2

+ 1 - 1
PLCLinker/centralController/App.config

@@ -36,7 +36,7 @@
     <!--显示屏信息-->
     <!--<add key="allInOneMachineIP" value="192.168.10.90"/>
     <add key="allInOneMachinePort" value="8888"/>-->
-    <add key="allInOneMachineIP" value="192.168.0.17"/>
+    <add key="allInOneMachineIP" value="192.168.0.19"/>
     <add key="allInOneMachinePort" value="5005"/>
     <!--中控webServer端口,deprecated-->
     <add key="webPort" value="9000"/>

+ 47 - 20
PLCLinker/centralController/Monitor/SystemInitializer.cs

@@ -89,14 +89,14 @@ namespace Monitor
             //初始化数据库对象
             Monitor.remoteDBOper = new DBOperation(remoteDBConnStr, DBtimeout);
             Monitor.localDBOper = new DBOperation(localDBConnStr, DBtimeout);
-            Monitor.SetNotification("初始化云端数据库...", parkMonitor.model.TextColor.Log);
-            initStatus = initStatus && Monitor.remoteDBOper.InitConnPooling(5);
-            if (!initStatus) { Monitor.SetNotification("云端数据库初始化异常", parkMonitor.model.TextColor.Error); return; }
-            Monitor.SetNotification("初始化本地数据库...", parkMonitor.model.TextColor.Log);
-            initStatus = initStatus && Monitor.localDBOper.InitConnPooling(5);
-            //数据库初始化结束,进入状态3
-            if (!initStatus) { Monitor.SetNotification("本地数据库初始化异常", parkMonitor.model.TextColor.Error); return; }
-            else { Monitor.initializeState = 3; }
+            //Monitor.SetNotification("初始化云端数据库...", parkMonitor.model.TextColor.Log);
+            //initStatus = initStatus && Monitor.remoteDBOper.InitConnPooling(5);
+            //if (!initStatus) { Monitor.SetNotification("云端数据库初始化异常", parkMonitor.model.TextColor.Error); return; }
+            //Monitor.SetNotification("初始化本地数据库...", parkMonitor.model.TextColor.Log);
+            //initStatus = initStatus && Monitor.localDBOper.InitConnPooling(5);
+            ////数据库初始化结束,进入状态3
+            //if (!initStatus) { Monitor.SetNotification("本地数据库初始化异常", parkMonitor.model.TextColor.Error); return; }
+            //else { Monitor.initializeState = 3; }
 
             //初始化凭证号
             initStatus = initStatus && Credence.ReadCredence();
@@ -153,21 +153,38 @@ namespace Monitor
             {
                 Monitor.allInOneMachine.AddScreen(Monitor.allInOneMachine.boardList.Count, Encoding.Default.GetBytes(Monitor.allInOneMachineIP[i]), (uint)Monitor.allInOneMachinePort[i], Led5kSDK.bx_5k_card_type.BX_6K3_YY, 1, 2);
             }
+            //Thread.Sleep(1000);
             #region 测试屏显
             //Console.WriteLine(Monitor.allInOneMachine.boardList.Count);
             //Console.WriteLine(Monitor.allInOneMachine.boardList[0].boardParams.ip + ", " + Monitor.allInOneMachine.boardList[0].boardParams.port);
-            //Monitor.allInOneMachine.boardList[0].UpdateText("上上上", 3);
-            //Monitor.allInOneMachine.boardList[0].UpdateArrow(2);
-            //Thread.Sleep(2000);
-            //Monitor.allInOneMachine.boardList[0].UpdateText("下下下", 3);
-            //Monitor.allInOneMachine.boardList[0].UpdateArrow(3);
-            //Thread.Sleep(2000);
-            //Monitor.allInOneMachine.boardList[0].UpdateText("左左左", 3);
-            //Monitor.allInOneMachine.boardList[0].UpdateArrow(1);
-            //Thread.Sleep(2000);
-            //Monitor.allInOneMachine.boardList[0].UpdateText("右右右", 3);
-            //Monitor.allInOneMachine.boardList[0].UpdateArrow(0);
-            //Thread.Sleep(2000);
+            Monitor.allInOneMachine.boardList[0].UpdateText("请带好随身携带的物品,关闭车窗与车门,收起后视镜,确认所有人员离开车辆后,操作终端停车", 60, 2);
+            Monitor.allInOneMachine.boardList[0].UpdateArrow(2);
+            Thread.Sleep(4000);
+            ////Monitor.allInOneMachine.boardList[0].UpdateText("下下下", 3);
+            Monitor.allInOneMachine.boardList[0].UpdateArrow(-1);
+            Thread.Sleep(4000);
+            ////Monitor.allInOneMachine.boardList[0].UpdateText("左左左", 3);
+            //Monitor.allInOneMachine.boardList[0].UpdateText("请带好随身携带的物品,关闭车窗与车门,收起后视镜,确认所有人员离开车辆后,操作终端停车", 3);
+            Monitor.allInOneMachine.boardList[0].UpdateArrow(1);
+            Thread.Sleep(4000);
+            ////Monitor.allInOneMachine.boardList[0].UpdateText("", 20);
+            Monitor.allInOneMachine.boardList[0].UpdateArrow(-1);
+            Thread.Sleep(5000);
+            Monitor.allInOneMachine.boardList[0].UpdateArrow(0);
+            Thread.Sleep(5000);
+            Monitor.allInOneMachine.boardList[0].UpdateArrow(-1);
+            Thread.Sleep(4000);
+            ////Monitor.allInOneMachine.boardList[0].UpdateText("左左左", 3);
+            //Monitor.allInOneMachine.boardList[0].UpdateText("请带好随身携带的物品,关闭车窗与车门,收起后视镜,确认所有人员离开车辆后,操作终端停车", 3);
+            Monitor.allInOneMachine.boardList[0].UpdateArrow(3);
+            Thread.Sleep(4000);
+            ////Monitor.allInOneMachine.boardList[0].UpdateText("", 20);
+            Monitor.allInOneMachine.boardList[0].UpdateArrow(-1);
+            Thread.Sleep(5000);
+            Monitor.allInOneMachine.boardList[0].UpdateArrow(1);
+            Thread.Sleep(8000);
+            Monitor.allInOneMachine.boardList[0].UpdateArrow(-1);
+            Thread.Sleep(5000);
             #endregion 
             //BroadcastLinker.Start();
             //Monitor.allInOneMachine = BroadcastLinker.ins;//new BroadcastBoard(Monitor.allInOneMachineIP, Monitor.allInOneMachinePort);
@@ -316,6 +333,16 @@ namespace Monitor
             //关闭数据库
             if (Monitor.remoteDBOper != null) { Monitor.remoteDBOper.DBClose(); }
             if (Monitor.localDBOper != null) { Monitor.localDBOper.DBClose(); }
+            // 关闭屏显
+            if (Monitor.allInOneMachine != null)
+            {
+                for (int i = 0; i < Monitor.allInOneMachine.boardList.Count; i++)
+                {
+                    Monitor.allInOneMachine.boardList[i].UpdateText(" ",2,0);
+                    Monitor.allInOneMachine.boardList[i].UpdateArrow(-1);
+                }
+                Monitor.allInOneMachine.DestroyAll();
+            }
             Terminal.Terminal.Stop();
         }
 

+ 87 - 47
PLCLinker/centralController/allInOneMachine/broadcastModule.cs

@@ -53,11 +53,11 @@ namespace BroadcastModule
             {
                 while (!Monitor.Monitor.isClosing)
                 {
+                    Thread.Sleep(5000);
                     foreach (BroadcastBoard bb in boardList)
                     {
                         bb.CheckConnection();
                     }
-                    Thread.Sleep(5000);
                 }
             });
         }
@@ -96,7 +96,7 @@ namespace BroadcastModule
         {
             foreach (BroadcastBoard bb in boardList)
             {
-                bb.RemoveDynamicAreas(bb.boardParams.handle);
+                //bb.RemoveDynamicAreas(bb.boardParams.handle);
                 Led5kSDK.Destroy(bb.boardParams.handle);
             }
         }
@@ -144,7 +144,7 @@ namespace BroadcastModule
         public Led5kSDK.bx_5k_area_header header_model;
         private object area1Lock;
         private object area2Lock;
-        private string[] arrows = { "\\T001arrU64|", "\\T001arrD64|", "\\T001arrL64|", "\\T001arrR64|" };
+        private string[] arrows = { "\\T001arrU64|\\n", "\\T001arrD64|\\n", "\\T001arrL64|\\n", "\\T001arrR64|\\n" };
         //************************************************ 方法块 **************************************************
         // *************** 公有方法 ***************
         public BroadcastBoard(int id, byte[] ip, uint port, Led5kSDK.bx_5k_card_type card_type, uint handle)
@@ -200,17 +200,17 @@ namespace BroadcastModule
 
             //第一行128*16显示文字,上下8像素留空
             AreaInfo area1 = new AreaInfo(handle, 0, Encoding.Default.GetBytes(""));
-            area1.header.AreaWidth = 2;// 2=16/8
-            area1.header.AreaHeight = 96;
-            area1.header.AreaX = 8 / 8;
-            area1.header.AreaY = 0;
-            area1.header.SingleLine = 0x02;
+            area1.header.AreaWidth = 16;// 2=16/8
+            area1.header.AreaHeight = 16;//96
+            area1.header.AreaX = 0 / 8; // 8/8
+            area1.header.AreaY = 8; // 0
+            area1.header.SingleLine = 0x01;
             area1.header.NewLine = 0x02;
-            area1.header.DisplayMode = 0x02;
-            area1.header.StayTime = 4;
+            area1.header.DisplayMode = 0x03;
+            area1.header.StayTime = 1;
             area1.header.RunMode = 2;
             area1.header.Speed = 2;
-            area1.header.Timeout = 5;
+            area1.header.Timeout = 20;
             //bb.header_model.AreaY = 16;
             area1.index = AddDynamicArea(handle, area1.header);
             if (area1.index != -1)
@@ -227,13 +227,15 @@ namespace BroadcastModule
             AreaInfo area2 = new AreaInfo(handle, 1, Encoding.Default.GetBytes(""));
             area2.header.AreaWidth = 8;// 8=64/8
             area2.header.AreaHeight = 64;
+            area2.header.AreaX = 32 / 8; // 8/8
+            area2.header.AreaY = 32; // 8/8
             area2.header.SingleLine = 0x01;
             area2.header.NewLine = 0x01;
             area2.header.DisplayMode = 0x02;
-            area2.header.StayTime = 5;
+            area2.header.StayTime = 20;
             area2.header.RunMode = 2;
-            area2.header.AreaX = (32 + 16) / 8;
-            area2.header.AreaY = 16;
+            //area2.header.AreaX = (32 + 16) / 8;
+            //area2.header.AreaY = 16;
             area2.index = AddDynamicArea(handle, area2.header);
             if (area2.index != -1)
             {
@@ -246,7 +248,7 @@ namespace BroadcastModule
                 return false;
             }
 
-            //顶角右偏32像素的16*16块专用于播放声音
+            //顶角右偏32像素的8*8块专用于播放声音
             AreaInfo areaSound = new AreaInfo(handle, 2, Encoding.Default.GetBytes(""));
             areaSound.header.AreaWidth = 2;// 2=16/8
             areaSound.header.AreaHeight = 16;
@@ -255,8 +257,8 @@ namespace BroadcastModule
             areaSound.header.DisplayMode = 0x02;
             areaSound.header.StayTime = 1;
             areaSound.header.RunMode = 2;
-            areaSound.header.AreaX = 32 / 8;
-            areaSound.header.AreaY = 0;
+            areaSound.header.AreaX = 0;// 32 / 8;
+            areaSound.header.AreaY = 64; //0
             areaSound.header.Speed = 4;
             areaSound.index = AddDynamicArea(handle, areaSound.header);
             if (areaSound.index != -1)
@@ -277,44 +279,62 @@ namespace BroadcastModule
         /// </summary>
         /// <param name="sentence"></param>
         /// <param name="slice"></param>
-        public bool UpdateText(string sentence, int waitSec, int slice = 6)
+        public bool UpdateText(string sentence, int waitSec, int runMode=-1, bool horizontal = true, int slice = 6)
         {
             List<string> sentenceContent = new List<string>();
             int i = 0;
             if (boardParams.handle == 0 || boardParams.areas.Count < 2)
                 return false;
-            while (i < sentence.Length)
+            // 竖屏
+            if (!horizontal)
             {
-                if ((i + slice) % slice == 0)
+                while (i < sentence.Length)
                 {
-                    if (i < sentence.Length - slice + 1)
+                    if ((i + slice) % slice == 0) 
                     {
-                        char[] temp = (sentence.Substring(i, slice)).ToCharArray();
-                        temp = temp.Reverse().ToArray();
-                        sentenceContent.Add(new String(temp));
-                        i = i + slice - 1;
+                        if (i < sentence.Length - slice + 1)
+                        {
+                            char[] temp = (sentence.Substring(i, slice)).ToCharArray();
+                            temp = temp.Reverse().ToArray();
+                            sentenceContent.Add(new String(temp));
+                            i = i + slice - 1;
+                        }
+                        else
+                        {
+                            sentenceContent.Add(new String(sentence.Substring(i).ToCharArray().Reverse().ToArray()));
+                            break;
+                        }
                     }
-                    else
+                    i++;
+                }
+                lock (area1Lock)
+                {
+                    Task.Factory.StartNew(() =>
                     {
-                        sentenceContent.Add(new String(sentence.Substring(i).ToCharArray().Reverse().ToArray()));
-                        break;
-                    }
+                        int count = 0;
+                        UpdateArea(boardParams.handle, boardParams.areas[2].index, Encoding.Default.GetBytes(""), true, Encoding.Default.GetBytes(sentence), 10);
+                        while (count < sentenceContent.Count)
+                        {
+                            UpdateArea(boardParams.handle, boardParams.areas[0].index, Encoding.Default.GetBytes(sentenceContent[count]));
+                            Thread.Sleep(waitSec * 1000);
+                            count++;
+                        }
+                    });
                 }
-                i++;
             }
-            lock (area1Lock)
+            // 横屏
+            else
             {
-                Task.Factory.StartNew(() =>
+                lock (area1Lock)
                 {
-                    int count = 0;
-                    UpdateArea(boardParams.handle, boardParams.areas[2].index, Encoding.Default.GetBytes(""), true, Encoding.Default.GetBytes(sentence));
-                    while (count < sentenceContent.Count)
+                    Task.Factory.StartNew(() =>
                     {
-                        UpdateArea(boardParams.handle, boardParams.areas[0].index, Encoding.Default.GetBytes(sentenceContent[count]));
-                        Thread.Sleep(waitSec * 1000);
-                        count++;
-                    }
-                });
+                        UpdateArea(boardParams.handle, boardParams.areas[2].index, Encoding.Default.GetBytes(""), true, Encoding.Default.GetBytes(sentence), 10, runMode, waitSec);
+                        UpdateArea(boardParams.handle, boardParams.areas[0].index, Encoding.Default.GetBytes(sentence), runMode, waitSec);
+                        Console.WriteLine("index: " + boardParams.areas[0].index);
+                        Console.WriteLine("sentence: " + sentence);
+                    });
+                }
             }
             return true;
         }
@@ -323,7 +343,7 @@ namespace BroadcastModule
         /// </summary>
         /// <param name="index"></param>
         /// <returns></returns>
-        public bool UpdateArrow(int index)
+        public bool UpdateArrow(int index, int waitSec=5, int runMode = -1)
         {
             if (index > 3)
                 return false;
@@ -333,11 +353,11 @@ namespace BroadcastModule
             {
                 if (index < 0)
                 {
-                    UpdateArea(boardParams.handle, boardParams.areas[1].index, Encoding.Default.GetBytes(""));
+                    UpdateArea(boardParams.handle, boardParams.areas[1].index, Encoding.Default.GetBytes(" "), runMode, waitSec);
                 }
                 else
                 {
-                    UpdateArea(boardParams.handle, boardParams.areas[1].index, Encoding.Default.GetBytes(arrows[index]));
+                    UpdateArea(boardParams.handle, boardParams.areas[1].index, Encoding.Default.GetBytes(arrows[index]), runMode, waitSec);
                 }
             }
             return true;
@@ -434,7 +454,7 @@ namespace BroadcastModule
         /// 动态区域更新函数
         /// </summary>
         /// <param name="i"></param>
-        private bool UpdateArea(uint handle, int index, byte[] areaText)
+        private bool UpdateArea(uint handle, int index, byte[] areaText, int runMode=-1, int waitSec=-1)
         {
             int err = -1;
             List<Led5kSDK.bx_5k_area_header> list;
@@ -452,7 +472,16 @@ namespace BroadcastModule
                         if (index == list[i].DynamicAreaLoc)
                         {
                             Led5kSDK.bx_5k_area_header temp = list[i];
+                            if(runMode>=0 && runMode < 3)
+                            {
+                                temp.RunMode = (byte)runMode;
+                            }
+                            if (waitSec >= 0)
+                            {
+                                temp.Timeout = (short)waitSec;
+                            }
                             temp.DataLen = areaText.Length;
+                            handleDynamicAreasMap[handle][i] = temp;
                             err = Led5kSDK.SCREEN_SendDynamicArea(handle, temp, (ushort)temp.DataLen, areaText);
                             break;
                         }
@@ -470,9 +499,11 @@ namespace BroadcastModule
         /// 动态区域更新函数
         /// </summary>
         /// <param name="i"></param>
-        private bool UpdateArea(uint handle, int index, byte[] areaText, bool soundOnly, byte[] soundText)
+        private bool UpdateArea(uint handle, int index, byte[] areaText, bool soundOnly, byte[] soundText, int sound, int runMode = -1, int waitSec = -1)
         {
             int err = -1;
+            sound = sound > 10 ? 10 : sound;
+            sound = sound < 1 ? 1 : sound;
             List<Led5kSDK.bx_5k_area_header> list;
             if (!handleDynamicAreasMap.ContainsKey(handle))
             {
@@ -488,11 +519,20 @@ namespace BroadcastModule
                         if (index == list[i].DynamicAreaLoc)
                         {
                             Led5kSDK.bx_5k_area_header temp = list[i];
+                            if (runMode >= 0 && runMode < 3)
+                            {
+                                temp.RunMode = (byte)runMode;
+                            }
+                            if (waitSec >= 0)
+                            {
+                                temp.Timeout = (short)waitSec;
+                            }
                             temp.DataLen = areaText.Length;
+                            handleDynamicAreasMap[handle][i] = temp;
                             if (!soundOnly)
-                                err = Led5kSDK.SCREEN_SendSoundDynamicArea(handle, temp, (ushort)temp.DataLen, areaText, 2, 0, 1, 5, soundText.Length, soundText);
+                                err = Led5kSDK.SCREEN_SendSoundDynamicArea(handle, temp, (ushort)temp.DataLen, areaText, 2, 0, (byte)sound, 5, soundText.Length, soundText);
                             else
-                                err = Led5kSDK.SCREEN_SendSoundDynamicArea(handle, temp, 0, Encoding.Default.GetBytes(""), 2, 0, 1, 5, soundText.Length, soundText);
+                                err = Led5kSDK.SCREEN_SendSoundDynamicArea(handle, temp, 0, Encoding.Default.GetBytes(""), 2, 0, (byte)sound, 5, soundText.Length, soundText);
                             break;
                         }
                     }