|
@@ -56,7 +56,11 @@ namespace BroadcastModule
|
|
|
Thread.Sleep(5000);
|
|
|
foreach (BroadcastBoard bb in boardList)
|
|
|
{
|
|
|
- bb.CheckConnection();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ bb.CheckConnection(5);
|
|
|
+ }
|
|
|
+ catch(Exception e) { Console.WriteLine("LED"+bb.boardParams.id+"连接:\n"+e.StackTrace); }
|
|
|
}
|
|
|
}
|
|
|
});
|
|
@@ -142,6 +146,9 @@ namespace BroadcastModule
|
|
|
private Dictionary<uint, List<Led5kSDK.bx_5k_area_header>> handleDynamicAreasMap;
|
|
|
private int volume = 10;
|
|
|
public Led5kSDK.bx_5k_area_header header_model;
|
|
|
+ public int ledScanState;// 0空闲 1正常 2前超界 3后超界 4左超界 5右超界 6测量失败
|
|
|
+ private int[] dispStatus;
|
|
|
+ private bool isDisplaying;
|
|
|
private object area1Lock;
|
|
|
private object area2Lock;
|
|
|
private string[] arrows = { "\\T001arrU64|\\n", "\\T001arrD64|\\n", "\\T001arrL64|\\n", "\\T001arrR64|\\n" };
|
|
@@ -149,6 +156,9 @@ namespace BroadcastModule
|
|
|
// *************** 公有方法 ***************
|
|
|
public BroadcastBoard(int id, byte[] ip, uint port, Led5kSDK.bx_5k_card_type card_type, uint handle)
|
|
|
{
|
|
|
+ ledScanState = -1;
|
|
|
+ isDisplaying = false;
|
|
|
+ dispStatus = new int[2];
|
|
|
handleDynamicAreasMap = new Dictionary<uint, List<Led5kSDK.bx_5k_area_header>>();
|
|
|
header_model = new Led5kSDK.bx_5k_area_header();
|
|
|
area1Lock = new object();
|
|
@@ -160,7 +170,7 @@ namespace BroadcastModule
|
|
|
/// 检查连接状态
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
- public bool CheckConnection()
|
|
|
+ public bool CheckConnection(int sleptSec)
|
|
|
{
|
|
|
int count = 3;
|
|
|
int result = -1;
|
|
@@ -168,6 +178,34 @@ namespace BroadcastModule
|
|
|
{
|
|
|
if (boardParams.handle != 0)
|
|
|
{
|
|
|
+ // 检查是否有内容在显示
|
|
|
+ int displaying = 0;
|
|
|
+ lock (area1Lock)
|
|
|
+ {
|
|
|
+ displaying = dispStatus[0];
|
|
|
+ }
|
|
|
+ lock (area2Lock)
|
|
|
+ {
|
|
|
+ displaying += dispStatus[1];
|
|
|
+ }
|
|
|
+ if (displaying <= 0 && isDisplaying)
|
|
|
+ {
|
|
|
+ UpdateText("欢迎光临智象停车", 2, 0);
|
|
|
+ UpdateArrow(-1, 2, 0);
|
|
|
+ Console.WriteLine("LED清屏");
|
|
|
+ isDisplaying = false;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ lock (area1Lock)
|
|
|
+ {
|
|
|
+ dispStatus[0] = dispStatus[0] >= 0 ? (dispStatus[0] - sleptSec) : 0;
|
|
|
+ }
|
|
|
+ lock (area2Lock)
|
|
|
+ {
|
|
|
+ dispStatus[1] = dispStatus[1] >= 0 ? (dispStatus[1] - sleptSec) : 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
result = Led5kSDK.CON_PING(boardParams.handle);
|
|
|
Console.WriteLine("屏幕ping结果: " + result);
|
|
|
if (result == 0)
|
|
@@ -207,7 +245,7 @@ namespace BroadcastModule
|
|
|
area1.header.SingleLine = 0x01;
|
|
|
area1.header.NewLine = 0x02;
|
|
|
area1.header.DisplayMode = 0x03;
|
|
|
- area1.header.StayTime = 1;
|
|
|
+ area1.header.StayTime = 10;
|
|
|
area1.header.RunMode = 2;
|
|
|
area1.header.Speed = 2;
|
|
|
area1.header.Timeout = 20;
|
|
@@ -279,7 +317,7 @@ namespace BroadcastModule
|
|
|
/// </summary>
|
|
|
/// <param name="sentence"></param>
|
|
|
/// <param name="slice"></param>
|
|
|
- public bool UpdateText(string sentence, int waitSec, int runMode=-1, bool horizontal = true, int slice = 6)
|
|
|
+ public bool UpdateText(string sentence, int waitSec, int runMode = -1,int dispMode = -1, bool horizontal = true, int slice = 6)
|
|
|
{
|
|
|
List<string> sentenceContent = new List<string>();
|
|
|
int i = 0;
|
|
@@ -290,7 +328,7 @@ namespace BroadcastModule
|
|
|
{
|
|
|
while (i < sentence.Length)
|
|
|
{
|
|
|
- if ((i + slice) % slice == 0)
|
|
|
+ if ((i + slice) % slice == 0)
|
|
|
{
|
|
|
if (i < sentence.Length - slice + 1)
|
|
|
{
|
|
@@ -325,16 +363,27 @@ namespace BroadcastModule
|
|
|
// 横屏
|
|
|
else
|
|
|
{
|
|
|
- lock (area1Lock)
|
|
|
+
|
|
|
+ Task.Factory.StartNew(() =>
|
|
|
{
|
|
|
- Task.Factory.StartNew(() =>
|
|
|
+ lock (area1Lock)
|
|
|
{
|
|
|
+ dispStatus[0] = waitSec;
|
|
|
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);
|
|
|
- });
|
|
|
- }
|
|
|
+ UpdateArea(boardParams.handle, boardParams.areas[0].index, Encoding.Default.GetBytes(sentence + "\\n"), runMode, waitSec, dispMode);
|
|
|
+ }
|
|
|
+ if (sentence != "欢迎光临智象停车")
|
|
|
+ {
|
|
|
+ isDisplaying = true;
|
|
|
+ }
|
|
|
+ Console.WriteLine("index: " + boardParams.areas[0].index);
|
|
|
+ Console.WriteLine("sentence: " + sentence);
|
|
|
+ //if (runMode != 0)
|
|
|
+ //{
|
|
|
+ // Thread.Sleep(waitSec*1000);
|
|
|
+ // dispStatus[0] = false;
|
|
|
+ //}
|
|
|
+ });
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
@@ -343,23 +392,33 @@ namespace BroadcastModule
|
|
|
/// </summary>
|
|
|
/// <param name="index"></param>
|
|
|
/// <returns></returns>
|
|
|
- public bool UpdateArrow(int index, int waitSec=5, int runMode = -1)
|
|
|
+ public bool UpdateArrow(int index, int waitSec = 5, int runMode = -1)
|
|
|
{
|
|
|
if (index > 3)
|
|
|
return false;
|
|
|
if (boardParams.handle == 0 || boardParams.areas.Count < 2)
|
|
|
return false;
|
|
|
- lock (area2Lock)
|
|
|
+ Task.Factory.StartNew(() =>
|
|
|
{
|
|
|
- if (index < 0)
|
|
|
- {
|
|
|
- UpdateArea(boardParams.handle, boardParams.areas[1].index, Encoding.Default.GetBytes(" "), runMode, waitSec);
|
|
|
- }
|
|
|
- else
|
|
|
+ lock (area2Lock)
|
|
|
{
|
|
|
- UpdateArea(boardParams.handle, boardParams.areas[1].index, Encoding.Default.GetBytes(arrows[index]), runMode, waitSec);
|
|
|
+ dispStatus[1] = waitSec;
|
|
|
+ if (index < 0)
|
|
|
+ {
|
|
|
+ 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]), runMode, waitSec);
|
|
|
+ isDisplaying = true;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
+ //if (runMode != 0)
|
|
|
+ //{
|
|
|
+ // Thread.Sleep(waitSec*1000);
|
|
|
+ // dispStatus[1] = false;
|
|
|
+ //}
|
|
|
+ });
|
|
|
return true;
|
|
|
}
|
|
|
/// <summary>
|
|
@@ -454,7 +513,7 @@ namespace BroadcastModule
|
|
|
/// 动态区域更新函数
|
|
|
/// </summary>
|
|
|
/// <param name="i"></param>
|
|
|
- private bool UpdateArea(uint handle, int index, byte[] areaText, int runMode=-1, int waitSec=-1)
|
|
|
+ private bool UpdateArea(uint handle, int index, byte[] areaText, int runMode = -1, int waitSec = -1, int dispMode = -1)
|
|
|
{
|
|
|
int err = -1;
|
|
|
List<Led5kSDK.bx_5k_area_header> list;
|
|
@@ -472,10 +531,14 @@ namespace BroadcastModule
|
|
|
if (index == list[i].DynamicAreaLoc)
|
|
|
{
|
|
|
Led5kSDK.bx_5k_area_header temp = list[i];
|
|
|
- if(runMode>=0 && runMode < 3)
|
|
|
+ if (runMode >= 0 && runMode < 3)
|
|
|
{
|
|
|
temp.RunMode = (byte)runMode;
|
|
|
}
|
|
|
+ if(dispMode >= 0 && dispMode < 7)
|
|
|
+ {
|
|
|
+ temp.DisplayMode = (byte)dispMode;
|
|
|
+ }
|
|
|
if (waitSec >= 0)
|
|
|
{
|
|
|
temp.Timeout = (short)waitSec;
|
|
@@ -499,7 +562,7 @@ namespace BroadcastModule
|
|
|
/// 动态区域更新函数
|
|
|
/// </summary>
|
|
|
/// <param name="i"></param>
|
|
|
- private bool UpdateArea(uint handle, int index, byte[] areaText, bool soundOnly, byte[] soundText, int sound, int runMode = -1, int waitSec = -1)
|
|
|
+ private bool UpdateArea(uint handle, int index, byte[] areaText, bool soundOnly, byte[] soundText, int sound, int runMode = -1, int waitSec = -1, int dispMode = -1)
|
|
|
{
|
|
|
int err = -1;
|
|
|
sound = sound > 10 ? 10 : sound;
|
|
@@ -523,6 +586,10 @@ namespace BroadcastModule
|
|
|
{
|
|
|
temp.RunMode = (byte)runMode;
|
|
|
}
|
|
|
+ if (dispMode >= 0 && dispMode < 7)
|
|
|
+ {
|
|
|
+ temp.DisplayMode = (byte)dispMode;
|
|
|
+ }
|
|
|
if (waitSec >= 0)
|
|
|
{
|
|
|
temp.Timeout = (short)waitSec;
|