|
@@ -48,6 +48,18 @@ namespace BroadcastModule
|
|
|
|
|
|
Led5kSDK.InitSdk(2, 2);
|
|
Led5kSDK.InitSdk(2, 2);
|
|
boardList = new List<BroadcastBoard>();
|
|
boardList = new List<BroadcastBoard>();
|
|
|
|
+ //初始化时启动连接检查线程
|
|
|
|
+ Task.Factory.StartNew(() =>
|
|
|
|
+ {
|
|
|
|
+ while (!Monitor.Monitor.isClosing)
|
|
|
|
+ {
|
|
|
|
+ foreach (BroadcastBoard bb in boardList)
|
|
|
|
+ {
|
|
|
|
+ bb.CheckConnection();
|
|
|
|
+ }
|
|
|
|
+ Thread.Sleep(5000);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -63,11 +75,15 @@ namespace BroadcastModule
|
|
public bool AddScreen(int id, byte[] led_ip, uint led_port, Led5kSDK.bx_5k_card_type card_type, int tmout_sec, int mode)
|
|
public bool AddScreen(int id, byte[] led_ip, uint led_port, Led5kSDK.bx_5k_card_type card_type, int tmout_sec, int mode)
|
|
{
|
|
{
|
|
uint hand = Led5kSDK.CreateClient(led_ip, led_port, card_type, tmout_sec, mode, null);
|
|
uint hand = Led5kSDK.CreateClient(led_ip, led_port, card_type, tmout_sec, mode, null);
|
|
|
|
+ BroadcastBoard bb = new BroadcastBoard(id, led_ip, led_port, card_type, hand);
|
|
if (hand == 0)
|
|
if (hand == 0)
|
|
|
|
+ {
|
|
|
|
+ boardList.Add(bb);
|
|
return false;
|
|
return false;
|
|
|
|
+ }
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- BroadcastBoard bb = new BroadcastBoard(id, led_ip, led_port, card_type, hand);
|
|
|
|
|
|
+ bb.connected = true;
|
|
bb.InitBoard(hand);
|
|
bb.InitBoard(hand);
|
|
boardList.Add(bb);
|
|
boardList.Add(bb);
|
|
return true;
|
|
return true;
|
|
@@ -122,6 +138,7 @@ namespace BroadcastModule
|
|
public class BroadcastBoard
|
|
public class BroadcastBoard
|
|
{
|
|
{
|
|
public BoardParams boardParams;
|
|
public BoardParams boardParams;
|
|
|
|
+ public bool connected;
|
|
private Dictionary<uint, List<Led5kSDK.bx_5k_area_header>> handleDynamicAreasMap;
|
|
private Dictionary<uint, List<Led5kSDK.bx_5k_area_header>> handleDynamicAreasMap;
|
|
private int volume = 10;
|
|
private int volume = 10;
|
|
public Led5kSDK.bx_5k_area_header header_model;
|
|
public Led5kSDK.bx_5k_area_header header_model;
|
|
@@ -139,6 +156,37 @@ namespace BroadcastModule
|
|
boardParams = new BoardParams(id, ip, port, card_type, handle);
|
|
boardParams = new BoardParams(id, ip, port, card_type, handle);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 检查连接状态
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ public bool CheckConnection()
|
|
|
|
+ {
|
|
|
|
+ int count = 3;
|
|
|
|
+ int result = -1;
|
|
|
|
+ while (count > 0)
|
|
|
|
+ {
|
|
|
|
+ if (boardParams.handle != 0)
|
|
|
|
+ {
|
|
|
|
+ result = Led5kSDK.CON_PING(boardParams.handle);
|
|
|
|
+ Console.WriteLine("屏幕ping结果: " + result);
|
|
|
|
+ if (result == 0)
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ boardParams.handle = Led5kSDK.CreateClient(boardParams.ip, boardParams.port, boardParams.card_type, 1, 2, null);
|
|
|
|
+ }
|
|
|
|
+ count--;
|
|
|
|
+ if (count == 0 && result != 0 && boardParams.handle != 0)
|
|
|
|
+ {
|
|
|
|
+ Led5kSDK.Destroy(boardParams.handle);
|
|
|
|
+ boardParams.handle = 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ connected = (result == 0 ? true : false);
|
|
|
|
+ return connected;
|
|
|
|
+ }
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 初始化控制板
|
|
/// 初始化控制板
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -233,7 +281,7 @@ namespace BroadcastModule
|
|
{
|
|
{
|
|
List<string> sentenceContent = new List<string>();
|
|
List<string> sentenceContent = new List<string>();
|
|
int i = 0;
|
|
int i = 0;
|
|
- if (boardParams.handle == 0 || boardParams.areas.Count<2)
|
|
|
|
|
|
+ if (boardParams.handle == 0 || boardParams.areas.Count < 2)
|
|
return false;
|
|
return false;
|
|
while (i < sentence.Length)
|
|
while (i < sentence.Length)
|
|
{
|
|
{
|
|
@@ -259,7 +307,7 @@ namespace BroadcastModule
|
|
Task.Factory.StartNew(() =>
|
|
Task.Factory.StartNew(() =>
|
|
{
|
|
{
|
|
int count = 0;
|
|
int count = 0;
|
|
- UpdateArea(boardParams.handle, boardParams.areas[2].index, Encoding.Default.GetBytes(""),true, Encoding.Default.GetBytes(sentence));
|
|
|
|
|
|
+ UpdateArea(boardParams.handle, boardParams.areas[2].index, Encoding.Default.GetBytes(""), true, Encoding.Default.GetBytes(sentence));
|
|
while (count < sentenceContent.Count)
|
|
while (count < sentenceContent.Count)
|
|
{
|
|
{
|
|
UpdateArea(boardParams.handle, boardParams.areas[0].index, Encoding.Default.GetBytes(sentenceContent[count]));
|
|
UpdateArea(boardParams.handle, boardParams.areas[0].index, Encoding.Default.GetBytes(sentenceContent[count]));
|
|
@@ -341,7 +389,7 @@ namespace BroadcastModule
|
|
{
|
|
{
|
|
for (int i = 0; i < list.Count; i++)
|
|
for (int i = 0; i < list.Count; i++)
|
|
{
|
|
{
|
|
- if(list[i].DynamicAreaLoc == index)
|
|
|
|
|
|
+ if (list[i].DynamicAreaLoc == index)
|
|
{
|
|
{
|
|
err = Led5kSDK.SCREEN_DelDynamicArea(handle, list[i].DynamicAreaLoc);
|
|
err = Led5kSDK.SCREEN_DelDynamicArea(handle, list[i].DynamicAreaLoc);
|
|
return true;
|
|
return true;
|
|
@@ -441,7 +489,7 @@ namespace BroadcastModule
|
|
{
|
|
{
|
|
Led5kSDK.bx_5k_area_header temp = list[i];
|
|
Led5kSDK.bx_5k_area_header temp = list[i];
|
|
temp.DataLen = areaText.Length;
|
|
temp.DataLen = areaText.Length;
|
|
- if(!soundOnly)
|
|
|
|
|
|
+ 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, 1, 5, soundText.Length, soundText);
|
|
else
|
|
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, 1, 5, soundText.Length, soundText);
|