|
|
|
|
using IOT.Show.Common;
|
|
|
|
|
using IOT.Show.Model;
|
|
|
|
|
using IOT.Show.SqlBase;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using IOT.Show;
|
|
|
|
|
using LedSDKDemo_CSharp;
|
|
|
|
|
|
|
|
|
|
namespace IOT.Show
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// led服务操作
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class LedServer
|
|
|
|
|
{
|
|
|
|
|
private static SqlSugarBase dbSql = new SqlSugarBase();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 初始化
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static void init()
|
|
|
|
|
{
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
List<T_Led_Info> ledInfo = dbSql.getLedInfo();
|
|
|
|
|
|
|
|
|
|
foreach (var item in ledInfo)
|
|
|
|
|
{
|
|
|
|
|
if (item.ip != null)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("**********" + item.title + "环境监控平台" + "**********");
|
|
|
|
|
Console.WriteLine("通讯IP:" + item.ip);
|
|
|
|
|
byte[] ip = Encoding.GetEncoding("GBK").GetBytes(item.ip);
|
|
|
|
|
|
|
|
|
|
bx_sdk_dual2.InitSdk();//初始化
|
|
|
|
|
bool result = dynamicArea_6(ip, item.title, item.font,item.ip);
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
LogHelper.Info(item.title + "Led刷新成功,地址为:" + item.ip);
|
|
|
|
|
}
|
|
|
|
|
bx_sdk_dual2.ReleaseSdk();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
System.Threading.Thread.Sleep(1000 * 30);
|
|
|
|
|
}
|
|
|
|
|
catch(Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogHelper.Error("失败:"+ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 动态区域更新
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="ip"></param>
|
|
|
|
|
/// <param name="title"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static bool dynamicArea_6(byte[] ip,string title,string fonts,string ipStr)
|
|
|
|
|
{
|
|
|
|
|
bool result = false;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
byte[] font = Encoding.Default.GetBytes(fonts);
|
|
|
|
|
DataTable dataTable = dbSql.getLedData(title);
|
|
|
|
|
StringBuilder text = new StringBuilder();
|
|
|
|
|
int intPadRight = 1;
|
|
|
|
|
if (title.Length < 5)
|
|
|
|
|
{
|
|
|
|
|
text.Append(" " + title + "环境监控平台\n");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
text.Append(" " + title + "环境监控平台\n");
|
|
|
|
|
}
|
|
|
|
|
var fontSize = 0;
|
|
|
|
|
for (int i = 0; i <= 5; i++)
|
|
|
|
|
{
|
|
|
|
|
if (dataTable.Rows.Count - 1 >= i)
|
|
|
|
|
{
|
|
|
|
|
#region
|
|
|
|
|
/*if (dataTable.Rows[i]["MonitorName"].ToString().Contains("硫化氢"))
|
|
|
|
|
{
|
|
|
|
|
text.Append((dataTable.Rows[i]["MonitorName"].ToString().PadRight(intPadRight, ' ') + " "));
|
|
|
|
|
text.Append(("浓度:" + "0.00").PadRight(intPadRight + 3, ' ') + "%");
|
|
|
|
|
text.Append("\n");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dataTable.Rows[i]["MonitorName"].ToString().Contains("照 度"))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
text.Append((dataTable.Rows[i]["MonitorName"].ToString().PadRight(intPadRight, ' ') + " "));
|
|
|
|
|
if (dataTable.Rows[i]["Illuminance"].ToString() == "0.0")
|
|
|
|
|
{
|
|
|
|
|
text.Append(("照度:" + "00.0").PadRight(intPadRight + 3, ' ') + "lux");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
text.Append(("照度:" + dataTable.Rows[i]["Illuminance"]).PadRight(intPadRight + 3, ' ') + "lux");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (dataTable.Rows[i]["Tempreture"].ToString() == "0.0")
|
|
|
|
|
{
|
|
|
|
|
text.Append((dataTable.Rows[i]["MonitorName"].ToString().PadRight(intPadRight, ' ') + " " + "温度:" + "00.0").PadRight(intPadRight + 3, ' ') + "℃ ");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
text.Append((dataTable.Rows[i]["MonitorName"].ToString().PadRight(intPadRight, ' ') + " " + "温度:" + dataTable.Rows[i]["Tempreture"]).PadRight(intPadRight + 3, ' ') + "℃ ");
|
|
|
|
|
}
|
|
|
|
|
if (dataTable.Rows[i]["Humidity"].ToString() == "0.0")
|
|
|
|
|
{
|
|
|
|
|
text.Append(("湿度:" + "00.0").PadRight(intPadRight + 3, ' ') + "%");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
text.Append(("湿度:" + dataTable.Rows[i]["Humidity"]).PadRight(intPadRight + 3, ' ') + "%");
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
#endregion
|
|
|
|
|
if (Convert.ToDecimal(dataTable.Rows[i]["tempreture"])<1)
|
|
|
|
|
{
|
|
|
|
|
text.Append((dataTable.Rows[i]["monitorName"].ToString().PadRight(dataTable.Rows[0]["monitorName"].ToString().Length, ' ') + " " + "温度:" + "00.00").PadRight(intPadRight + 3, ' ') + "℃ ");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
text.Append((dataTable.Rows[i]["monitorName"].ToString().PadRight(dataTable.Rows[0]["monitorName"].ToString().Length, ' ') + " " + "温度:" + dataTable.Rows[i]["tempreture"]).PadRight(intPadRight + 3, ' ') + "℃ ");
|
|
|
|
|
}
|
|
|
|
|
if (Convert.ToDecimal(dataTable.Rows[i]["humidity"].ToString())<1)
|
|
|
|
|
{
|
|
|
|
|
text.Append(("湿度:" + "00.00").PadRight(intPadRight + 3, ' ') + "%");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
text.Append(("湿度:" + dataTable.Rows[i]["humidity"]).PadRight(intPadRight + 3, ' ') + "%");
|
|
|
|
|
}
|
|
|
|
|
/*LogHelper.Info((dataTable.Rows[i]["monitorName"].ToString().PadRight(intPadRight, ' ') + " " + "温度:" + dataTable.Rows[i]["tempreture"]).PadRight(intPadRight + 3, ' ') + "℃ \t");
|
|
|
|
|
LogHelper.Info(("湿度:" + dataTable.Rows[i]["humidity"]).PadRight(intPadRight + 3, ' ') + "%");*/
|
|
|
|
|
fontSize = 10;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for (int num = 0;num<5-dataTable.Rows.Count; num++)
|
|
|
|
|
{
|
|
|
|
|
text.Append("\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
text.Append(DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "\n");
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (dataTable.Rows.Count - 1 >= i + 5)
|
|
|
|
|
{
|
|
|
|
|
text.Append("\n");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
text.Append("\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
string textT = text.ToString().Substring(0, text.ToString().Length - 1) + '\0';
|
|
|
|
|
|
|
|
|
|
bx_sdk_dual2.EQareaHeader_G6 aheader;
|
|
|
|
|
aheader.AreaType = 0x10;
|
|
|
|
|
aheader.AreaX = 0;
|
|
|
|
|
aheader.AreaY = 0;
|
|
|
|
|
aheader.AreaWidth = 256;
|
|
|
|
|
aheader.AreaHeight = 96;
|
|
|
|
|
aheader.BackGroundFlag = 0x00;
|
|
|
|
|
aheader.Transparency = 101;
|
|
|
|
|
aheader.AreaEqual = 0x00;
|
|
|
|
|
bx_sdk_dual2.EQSound_6G stSoundData = new bx_sdk_dual2.EQSound_6G();
|
|
|
|
|
byte[] strSoundTxt = Encoding.GetEncoding("GB2312").GetBytes("插入ab34测试语音");
|
|
|
|
|
stSoundData.SoundFlag = 0x00;
|
|
|
|
|
stSoundData.SoundPerson = 0x01;
|
|
|
|
|
stSoundData.SoundVolum = 6;
|
|
|
|
|
stSoundData.SoundSpeed = 0x2;
|
|
|
|
|
stSoundData.SoundDataMode = 0x00;
|
|
|
|
|
stSoundData.SoundReplayTimes = 0x01;
|
|
|
|
|
stSoundData.SoundReplayDelay = 200;
|
|
|
|
|
stSoundData.SoundReservedParaLen = 0x03;
|
|
|
|
|
stSoundData.Soundnumdeal = 0x00;
|
|
|
|
|
stSoundData.Soundlanguages = 0x00;
|
|
|
|
|
stSoundData.Soundwordstyle = 0x00;
|
|
|
|
|
stSoundData.SoundDataLen = strSoundTxt.Length;
|
|
|
|
|
stSoundData.SoundData = TypeCast.BytesToIntptr(strSoundTxt);
|
|
|
|
|
|
|
|
|
|
aheader.stSoundData = stSoundData;
|
|
|
|
|
bx_sdk_dual2.EQpageHeader_G6 pheader;
|
|
|
|
|
pheader.PageStyle = 0x00;
|
|
|
|
|
pheader.DisplayMode = 1;
|
|
|
|
|
pheader.ClearMode = 0x00;
|
|
|
|
|
pheader.Speed = 15;
|
|
|
|
|
pheader.StayTime = 500;
|
|
|
|
|
pheader.RepeatTime = 1;
|
|
|
|
|
pheader.ValidLen = 0;
|
|
|
|
|
pheader.CartoonFrameRate = 0x00;
|
|
|
|
|
pheader.BackNotValidFlag = 0x00;
|
|
|
|
|
pheader.arrMode = bx_sdk_dual2.E_arrMode.eMULTILINE;
|
|
|
|
|
pheader.fontSize = Convert.ToUInt16(fontSize);
|
|
|
|
|
pheader.color = (uint)0x01;
|
|
|
|
|
pheader.fontBold = 0;
|
|
|
|
|
pheader.fontItalic = 0;
|
|
|
|
|
pheader.tdirection = bx_sdk_dual2.E_txtDirection.pNORMAL;
|
|
|
|
|
pheader.txtSpace = 0;
|
|
|
|
|
pheader.Valign = 1;
|
|
|
|
|
pheader.Halign = 2;
|
|
|
|
|
IntPtr aa1 = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(bx_sdk_dual2.EQareaHeader_G6)));
|
|
|
|
|
Marshal.StructureToPtr(aheader, aa1, false);
|
|
|
|
|
IntPtr bb1 = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(bx_sdk_dual2.EQpageHeader_G6)));
|
|
|
|
|
Marshal.StructureToPtr(pheader, bb1, false);
|
|
|
|
|
|
|
|
|
|
//更新动态区,可设置属性 zc
|
|
|
|
|
int info = bx_sdk_dual2.dynamicArea_AddAreaTxtDetails_6G(ip, 5005, bx_sdk_dual2.E_ScreenColor_G56.eSCREEN_COLOR_SINGLE, 0,
|
|
|
|
|
ref aheader, ref pheader, font, Encoding.Default.GetBytes(textT));
|
|
|
|
|
if (info == 0)
|
|
|
|
|
{
|
|
|
|
|
LogHelper.Info(title+"数据更新成功:地址为" + ipStr+ "\n内容:"+ textT);
|
|
|
|
|
result = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
LogHelper.Error(title +"数据更新失败,请检查网络状态!!!地址为:"+ ipStr);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
catch(Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogHelper.Error("dynamicArea_6程序异常"+ex.Message);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|