private void LEDErrorControl(int nResult) { string ErrStr; ErrStr = LedDll.LS_GetError(nResult); Console.WriteLine(ErrStr); }
/// <summary> /// 设置屏参(只需根据屏的宽高点数的颜色设置一次,发送节目时无需设置) /// </summary> public void Button1_Click() { CommunicationInfo.LEDType = 3; //TCP通讯******************************************************************************** CommunicationInfo.SendType = 0; //设为固定IP通讯模式,即TCP通讯 CommunicationInfo.IpStr = ip_Str; //给IpStr赋值LED控制卡的IP CommunicationInfo.LedNumber = 1; //LED屏号为1,注意socket通讯和232通讯不识别屏号,默认赋1就行了,485必需根据屏的实际屏号进行赋值 //广播通讯******************************************************************************** //CommunicationInfo.SendType=1;//设为单机直连,即广播通讯无需设LED控制器的IP地址 //串口通讯******************************************************************************** //CommunicationInfo.SendType=2;//串口通讯 //CommunicationInfo.Commport=1;//串口的编号,如设备管理器里显示为 COM3 则此处赋值 3 //CommunicationInfo.Baud=9600;//波特率 //CommunicationInfo.LedNumber=1; nResult = LedDll.LV_SetBasicInfo(ref CommunicationInfo, 3, ledWidth, ledHeight, 5); //设置屏参,屏的颜色为2即为双基色,64为屏宽点数,32为屏高点数,具体函数参数说明见函数声明注示 print(nResult); if (nResult != 0)//如果失败则可以调用LV_GetError获取中文错误信息 { string ErrStr; ErrStr = LedDll.LS_GetError(nResult); Debug.Log(ErrStr); text.text = ErrStr; // MessageBox.Show(ErrStr); } else { text.text = "设置成功"; // MessageBox.Show("设置成功"); Debug.Log("设置成功"); } }
/// <summary> /// 一个节目下设置一个多行文本区域 /// </summary> public void Button3_Click() { int hProgram; //节目句柄 hProgram = LedDll.LV_CreateProgram(64, 32, 3, 5, 0); //根据传的参数创建节目句柄,64是屏宽点数,32是屏高点数,2是屏的颜色,注意此处屏宽高及颜色参数必需与设置屏参的屏宽高及颜色一致,否则发送时会提示错误 //此处可自行判断有未创建成功,hProgram返回NULL失败,非NULL成功,一般不会失败 nResult = LedDll.LV_AddProgram(hProgram, 1, 0, 1); //添加一个节目,参数说明见函数声明注示 if (nResult != 0) { string ErrStr; ErrStr = LedDll.LS_GetError(nResult); Debug.Log(ErrStr); // MessageBox.Show(ErrStr); return; } LedDll.AREARECT AreaRect = new LedDll.AREARECT();//区域坐标属性结构体变量 AreaRect.left = 0; AreaRect.top = 0; AreaRect.width = 64; AreaRect.height = 32; LedDll.LV_AddImageTextArea(hProgram, 1, 1, ref AreaRect, 0); LedDll.FONTPROP FontProp = new LedDll.FONTPROP();//文字属性 FontProp.FontName = "宋体"; FontProp.FontSize = 12; FontProp.FontColor = LedDll.COLOR_RED; FontProp.FontBold = 0; LedDll.PLAYPROP PlayProp = new LedDll.PLAYPROP(); PlayProp.InStyle = 0; PlayProp.DelayTime = 3; PlayProp.Speed = 4; //可以添加多个子项到图文区,如下添加可以选一个或多个添加 nResult = LedDll.LV_AddMultiLineTextToImageTextArea(hProgram, 1, 1, LedDll.ADDTYPE_STRING, "上海灵信~~~~~", ref FontProp, ref PlayProp, 0, 0); //通过字符串添加一个多行文本到图文区,参数说明见声明注示 nResult = LedDll.LV_AddMultiLineTextToImageTextArea(hProgram, 1, 1, LedDll.ADDTYPE_FILE, "test.rtf", ref FontProp, ref PlayProp, 0, 0); //通过rtf文件添加一个多行文本到图文区,参数说明见声明注示 nResult = LedDll.LV_AddMultiLineTextToImageTextArea(hProgram, 1, 1, LedDll.ADDTYPE_FILE, "test.txt", ref FontProp, ref PlayProp, 0, 0); //通过txt文件添加一个多行文本到图文区,参数说明见声明注示 nResult = LedDll.LV_Send(ref CommunicationInfo, hProgram); //发送,见函数声明注示 LedDll.LV_DeleteProgram(hProgram); //删除节目内存对象,详见函数声明注示 if (nResult != 0) //如果失败则可以调用LV_GetError获取中文错误信息 { string ErrStr; ErrStr = LedDll.LS_GetError(nResult); Debug.Log(ErrStr); // MessageBox.Show(ErrStr); } else { Debug.Log("发送成功"); // MessageBox.Show("发送成功"); } }
public void SendInfo(IList <LEDStyle> ledStyles) { string errorInfo; int hProgram = LedDll.LV_CreateProgram(this.ledWidth, this.ledHeight, 2); var result = LedDll.LV_AddProgram(hProgram, 1, 0, 1); if (result != 0) { errorInfo = LedDll.LS_GetError(result); //Logger.Error(errorInfo);; } areaRect = new LedDll.AREARECT(); fontProp = new LedDll.FONTPROP(); int areaNo = 1; foreach (var ledStyle in ledStyles) { areaRect.left = ledStyle.ledLeft; areaRect.top = ledStyle.ledTop; areaRect.width = ledStyle.ledWidth; areaRect.height = ledStyle.ledHeight; fontProp.FontName = "宋体"; fontProp.FontSize = 12; fontProp.FontColor = ledStyle.fontColor; fontProp.FontBold = 0; result = LedDll.LV_AddImageTextArea(hProgram, 1, areaNo, ref areaRect, 0); if (result != 0) { errorInfo = LedDll.LS_GetError(result); //Logger.Error(errorInfo);; } result = LedDll.LV_AddMultiLineTextToImageTextArea(hProgram, 1, areaNo++, LedDll.ADDTYPE_STRING, ledStyle.info, ref fontProp, ref playProp, 0, ledStyle.isVCenter); if (result != 0) { errorInfo = LedDll.LS_GetError(result); //Logger.Error(errorInfo);; } } result = LedDll.LV_Send(ref communicationInfo, hProgram); if (result != 0) { errorInfo = LedDll.LS_GetError(result); //Logger.Error(errorInfo);; } LedDll.LV_DeleteProgram(hProgram); }
/// <summary> /// 一个节目下设置一个连续左移的单行文本区域 /// </summary> public void Button2_Click() { int hProgram; //节目句柄 hProgram = LedDll.LV_CreateProgram(64, 32, 3, 5, 0); //根据传的参数创建节目句柄,64是屏宽点数,32是屏高点数,2是屏的颜色,注意此处屏宽高及颜色参数必需与设置屏参的屏宽高及颜色一致,否则发送时会提示错误 //此处可自行判断有未创建成功,hProgram返回NULL失败,非NULL成功,一般不会失败 nResult = LedDll.LV_AddProgram(hProgram, 1, 0, 1); //添加一个节目,参数说明见函数声明注示 if (nResult != 0) { string ErrStr; ErrStr = LedDll.LS_GetError(nResult); Debug.Log(ErrStr); text.text = ErrStr; // MessageBox.Show(ErrStr); return; } LedDll.AREARECT AreaRect = new LedDll.AREARECT();//区域坐标属性结构体变量 AreaRect.left = 0; AreaRect.top = 0; AreaRect.width = 64; AreaRect.height = 32; LedDll.FONTPROP FontProp = new LedDll.FONTPROP();//文字属性 FontProp.FontName = "宋体"; FontProp.FontSize = typeSize; FontProp.FontColor = LedDll.COLOR_GREEN; FontProp.FontBold = 0; //int nsize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(LedDll.FONTPROP)); nResult = LedDll.LV_QuickAddSingleLineTextArea(hProgram, 1, 1, ref AreaRect, LedDll.ADDTYPE_STRING, content_Str, ref FontProp, 4);//快速通过字符添加一个单行文本区域,函数见函数声明注示 // nResult = LedDll.LV_QuickAddSingleLineTextArea(hProgram, 1, 1, ref AreaRect, LedDll.ADDTYPE_FILE, "test.rtf", ref FontProp, 4);//快速通过rtf文件添加一个单行文本区域,函数见函数声明注示 //nResult = LedDll.LV_QuickAddSingleLineTextArea(hProgram, 1, 1, ref AreaRect, LedDll.ADDTYPE_FILE, "test.txt", ref FontProp, 4);//快速通过txt文件添加一个单行文本区域,函数见函数声明注示 nResult = LedDll.LV_Send(ref CommunicationInfo, hProgram); //发送,见函数声明注示 LedDll.LV_DeleteProgram(hProgram); //删除节目内存对象,详见函数声明注示 if (nResult != 0) //如果失败则可以调用LV_GetError获取中文错误信息 { string ErrStr; ErrStr = LedDll.LS_GetError(nResult); Debug.Log(ErrStr); text.text = ErrStr; // MessageBox.Show(ErrStr); } else { Debug.Log("发送成功"); text.text = "发送成功"; // MessageBox.Show("发送成功"); } }
/// <summary> /// 一个节目下设置一个图片区(表格的显示通过自绘图片并通过此方式添加发送) /// </summary> public void Button4_Click() { int hProgram; //节目句柄 hProgram = LedDll.LV_CreateProgram(64, 32, 3, 5, 0); //根据传的参数创建节目句柄,64是屏宽点数,32是屏高点数,2是屏的颜色,注意此处屏宽高及颜色参数必需与设置屏参的屏宽高及颜色一致,否则发送时会提示错误 //此处可自行判断有未创建成功,hProgram返回NULL失败,非NULL成功,一般不会失败 nResult = LedDll.LV_AddProgram(hProgram, 1, 0, 1); //添加一个节目,参数说明见函数声明注示 if (nResult != 0) { string ErrStr; ErrStr = LedDll.LS_GetError(nResult); Debug.Log(ErrStr); // MessageBox.Show(ErrStr); return; } LedDll.AREARECT AreaRect = new LedDll.AREARECT();//区域坐标属性结构体变量 AreaRect.left = 0; AreaRect.top = 0; AreaRect.width = 64; AreaRect.height = 32; LedDll.LV_AddImageTextArea(hProgram, 1, 1, ref AreaRect, 0); LedDll.PLAYPROP PlayProp = new LedDll.PLAYPROP(); PlayProp.InStyle = 0; PlayProp.DelayTime = 3; PlayProp.Speed = 4; //可以添加多个子项到图文区,如下添加可以选一个或多个添加 //可以添加多个子项到图文区,如下添加可以选一个或多个添加 nResult = LedDll.LV_AddFileToImageTextArea(hProgram, 1, 1, "test.bmp", ref PlayProp); nResult = LedDll.LV_AddFileToImageTextArea(hProgram, 1, 1, "test.jpg", ref PlayProp); nResult = LedDll.LV_AddFileToImageTextArea(hProgram, 1, 1, "test.png", ref PlayProp); PlayProp.Speed = 3; nResult = LedDll.LV_AddFileToImageTextArea(hProgram, 1, 1, "test.gif", ref PlayProp); nResult = LedDll.LV_Send(ref CommunicationInfo, hProgram); //发送,见函数声明注示 LedDll.LV_DeleteProgram(hProgram); //删除节目内存对象,详见函数声明注示 if (nResult != 0) //如果失败则可以调用LV_GetError获取中文错误信息 { string ErrStr; ErrStr = LedDll.LS_GetError(nResult); Debug.Log(ErrStr); //MessageBox.Show(ErrStr); } else { Debug.Log("发送成功"); //MessageBox.Show("发送成功"); } }
private void Init() { communicationInfo = new LedDll.COMMUNICATIONINFO(); communicationInfo.SendType = 0; communicationInfo.IpStr = this.ip; communicationInfo.LedNumber = 1; string errorInfo; var result = LedDll.LV_SetBasicInfo(ref communicationInfo, 2, ledWidth, ledHeight); if (result != 0) { errorInfo = LedDll.LS_GetError(result); } playProp = new LedDll.PLAYPROP(); playProp.InStyle = 0; playProp.DelayTime = 3; playProp.Speed = 4; }
public void SendInfo(string info) { string errorInfo; int hProgram = LedDll.LV_CreateProgram(this.ledWidth, this.ledHeight, 1); var result = LedDll.LV_AddProgram(hProgram, 1, 0, 1); if (result != 0) { errorInfo = LedDll.LS_GetError(result); Logger.Error(errorInfo); } result = LedDll.LV_AddImageTextArea(hProgram, 1, 1, ref areaRect, 0); if (result != 0) { errorInfo = LedDll.LS_GetError(result); Logger.Error(errorInfo); } result = LedDll.LV_AddMultiLineTextToImageTextArea(hProgram, 1, 1, LedDll.ADDTYPE_STRING, info, ref fontProp, ref playProp, 0, 0); if (result != 0) { errorInfo = LedDll.LS_GetError(result); Logger.Error(errorInfo); } result = LedDll.LV_Send(ref communicationInfo, hProgram); if (result != 0) { errorInfo = LedDll.LS_GetError(result); Logger.Error(errorInfo); } LedDll.LV_DeleteProgram(hProgram); }
private void Init() { communicationInfo = new LedDll.COMMUNICATIONINFO(); communicationInfo.SendType = 0; communicationInfo.IpStr = this.ip; communicationInfo.LedNumber = 1; string errorInfo; var result = LedDll.LV_SetBasicInfo(ref communicationInfo, 1, ledWidth, ledHeight); if (result != 0) { errorInfo = LedDll.LS_GetError(result); Logger.Error(errorInfo); } fontProp = new LedDll.FONTPROP(); fontProp.FontName = "宋体"; fontProp.FontSize = 12; fontProp.FontColor = LedDll.COLOR_RED; fontProp.FontBold = 0; playProp = new LedDll.PLAYPROP(); playProp.InStyle = 0; playProp.DelayTime = 3; playProp.Speed = 4; areaRect = new LedDll.AREARECT(); areaRect.left = 0; areaRect.top = 0; areaRect.width = this.ledWidth; areaRect.height = this.ledHeight; }
private void ledkanban(string TempIP, string Tempst, string message, string Jd, string strcolor) { int nResult; LedDll.COMMUNICATIONINFO CommunicationInfo = new LedDll.COMMUNICATIONINFO(); CommunicationInfo.SendType = 0; CommunicationInfo.IpStr = TempIP; CommunicationInfo.LedNumber = 1; int hProgram; hProgram = LedDll.LV_CreateProgram(64, 32, 2); nResult = LedDll.LV_AddProgram(hProgram, 1, 0, 10); if (nResult != 0) { string ErrStr; ErrStr = LedDll.LS_GetError(nResult); MessageBox.Show(ErrStr); return; } LedDll.AREARECT AreaRect = new LedDll.AREARECT(); AreaRect.left = 0; AreaRect.top = 0; AreaRect.width = 64; AreaRect.height = 16; LedDll.FONTPROP FontProp = new LedDll.FONTPROP(); FontProp.FontName = "Arial"; FontProp.FontSize = 10; if (strcolor == "r") { FontProp.FontColor = LedDll.COLOR_RED; } else if (strcolor == "g") { FontProp.FontColor = LedDll.COLOR_GREEN; } FontProp.FontBold = 0; nResult = LedDll.LV_QuickAddSingleLineTextArea(hProgram, 1, 1, ref AreaRect, LedDll.ADDTYPE_STRING, message, ref FontProp, 4); AreaRect.left = 0; AreaRect.top = 16; AreaRect.width = 64; AreaRect.height = 16; FontProp.FontSize = 10; LedDll.LV_AddSingleLineTextToImageTextArea(hProgram, 1, 2, ref AreaRect, 0); nResult = LedDll.LV_AddStaticTextToImageTextArea(hProgram, 1, 2, LedDll.ADDTYPE_STRING, Tempst, ref FontProp, 1, 2, 1); nResult = LedDll.LV_AddProgram(hProgram, 2, 0, 5); AreaRect.left = 0; AreaRect.top = 16; AreaRect.width = 64; AreaRect.height = 16; FontProp.FontName = "Arial"; FontProp.FontSize = 10; FontProp.FontColor = LedDll.COLOR_GREEN; FontProp.FontBold = 0; LedDll.LV_AddSingleLineTextToImageTextArea(hProgram, 2, 2, ref AreaRect, 0); nResult = LedDll.LV_AddStaticTextToImageTextArea(hProgram, 2, 2, LedDll.ADDTYPE_STRING, Jd, ref FontProp, 1, 2, 1); // nResult = LedDll.LV_QuickAddSingleLineTextArea(hProgram, 2, 2, ref AreaRect, LedDll.ADDTYPE_STRING, Jd , ref FontProp, 4); AreaRect.left = 0; AreaRect.top = 0; AreaRect.width = 64; AreaRect.height = 16; FontProp.FontSize = 10; LedDll.LV_AddSingleLineTextToImageTextArea(hProgram, 2, 1, ref AreaRect, 0); nResult = LedDll.LV_AddStaticTextToImageTextArea(hProgram, 2, 1, LedDll.ADDTYPE_STRING, "Completed", ref FontProp, 1, 2, 1); nResult = LedDll.LV_Send(ref CommunicationInfo, hProgram); LedDll.LV_DeleteProgram(hProgram); if (nResult != 0) { string ErrStr; ErrStr = LedDll.LS_GetError(nResult); listBox1.Items.Add(ErrStr); } else { listBox1.Items.Add(TempIP + " LED发发送成功"); } }
public void LedOnlinecontrol(LedInfo info, string identityId, int checktype) { try { if (info.LedIp == null) { Console.WriteLine("LED参数未设置"); return; } int nResult; LedDll.COMMUNICATIONINFO CommunicationInfo = new LedDll.COMMUNICATIONINFO(); //定义一通讯参数结构体变量用于对设定的LED通讯,具体对此结构体元素赋值说明见COMMUNICATIONINFO结构体定义部份注示 CommunicationInfo.SendType = 0; //设为固定IP通讯模式,即TCP通讯 CommunicationInfo.IpStr = info.LedIp; //给IpStr赋值LED控制卡的IP CommunicationInfo.LedNumber = 1; nResult = LedDll.LV_SetBasicInfo(ref CommunicationInfo, 2, info.Width, info.Height); if (nResult != 0) { LEDErrorControl(nResult); return; } int hProgram;//节目句柄 nResult = LedDll.LV_TestOnline(ref CommunicationInfo); if (nResult != 0) { for (int i = 0; i < 3; i++) { nResult = LedDll.LV_TestOnline(ref CommunicationInfo); if (nResult == 0) { Console.WriteLine("NET连接成功"); break; } } Console.WriteLine("NET3次连接失败"); return; } hProgram = LedDll.LV_CreateProgram(info.Width, info.Height, 2);//根据传的参数创建节目句柄,64是屏宽点数,32是屏高点数,2是屏的颜色,注意此处屏宽高及颜色参数必需与设置屏参的屏宽高及颜色一致,否则发送时会提示错误 if (hProgram == 0) { Console.WriteLine("创建节目对象失败"); return; } nResult = LedDll.LV_AddProgram(hProgram, 1, 0, 0);//添加一个节目,参数说明见函数声明注示 if (nResult != 0) { LEDErrorControl(nResult); return; } List <ModuleInfo> lla = GetLEDArea(info.Id); foreach (ModuleInfo la in lla) { LedDll.AREARECT AreaRect = new LedDll.AREARECT();//区域坐标属性结构体变量 AreaRect.left = la.Left_begin; AreaRect.top = la.Top_begin; AreaRect.width = la.Width; AreaRect.height = la.Height; LedDll.LV_AddImageTextArea(hProgram, 1, la.Id, ref AreaRect, 1); LedDll.FONTPROP FontProp = new LedDll.FONTPROP();//文字属性 FontProp.FontName = "宋体"; FontProp.FontSize = la.Font_size; FontProp.FontColor = LedDll.COLOR_RED; FontProp.FontBold = la.Font_bold; LedDll.PLAYPROP PlayProp = new LedDll.PLAYPROP(); PlayProp.InStyle = la.In_style; PlayProp.DelayTime = la.Delay_time; PlayProp.Speed = la.Speed; //可以添加多个子项到图文区,如下添加可以选一个或多个添加(注意点:调用添加子项到图文区域这些方法前都必须要先调用LV_AddImageTextArea) if (la.Area_type == 1 || la.Area_type == 5 || la.Area_type == 6) { nResult = LedDll.LV_AddMultiLineTextToImageTextArea(hProgram, 1, la.Id, LedDll.ADDTYPE_STRING, GetOutputString(la.Module_type, identityId, checktype), ref FontProp, ref PlayProp, la.Multi_nAlignment, la.Multi_IsVCenter); if (nResult != 0)//如果失败则可以调用LV_GetError获取中文错误信息 { LEDErrorControl(nResult); return; } } if (la.Area_type == 2) { nResult = LedDll.LV_AddSingleLineTextToImageTextArea(hProgram, 1, la.Id, LedDll.ADDTYPE_STRING, GetOutputString(la.Module_type, identityId, checktype), ref FontProp, ref PlayProp); if (nResult != 0)//如果失败则可以调用LV_GetError获取中文错误信息 { LEDErrorControl(nResult); return; } } #region 数字时钟 #warning 区域号问题 if (la.Area_type == 3) { LedDll.DIGITALCLOCKAREAINFO DigitalClockAreaInfo = new LedDll.DIGITALCLOCKAREAINFO(); int dateformat1 = Convert.ToInt32(ConfigurationManager.AppSettings["DateFormat1"].ToString()); int timeformat1 = Convert.ToInt32(ConfigurationManager.AppSettings["TimeFormat1"].ToString()); DigitalClockAreaInfo.ShowStrFont = FontProp; if (dateformat1 >= 0 && dateformat1 < 8) { DigitalClockAreaInfo.DateFormat = dateformat1; DigitalClockAreaInfo.IsMutleLineShow = 1; DigitalClockAreaInfo.IsShowYear = 1; DigitalClockAreaInfo.IsShowMonth = 1; DigitalClockAreaInfo.IsShowDay = 1; } if (timeformat1 >= 0 && timeformat1 < 7) { DigitalClockAreaInfo.TimeFormat = timeformat1; DigitalClockAreaInfo.IsShowHour = 1; DigitalClockAreaInfo.IsShowMinute = 1; DigitalClockAreaInfo.IsShowSecond = 1; DigitalClockAreaInfo.IsMutleLineShow = 1; } LedDll.LV_AdjustTime(ref CommunicationInfo); nResult = LedDll.LV_AddDigitalClockArea(hProgram, 1, 6, ref AreaRect, ref DigitalClockAreaInfo); //注意区域号不能一样,详见函数声明注示 if (nResult != 0) //如果失败则可以调用LV_GetError获取中文错误信息 { LEDErrorControl(nResult); return; } } if (la.Area_type == 4) { LedDll.DIGITALCLOCKAREAINFO DigitalClockAreaInfo = new LedDll.DIGITALCLOCKAREAINFO(); int dateformat2 = Convert.ToInt32(ConfigurationManager.AppSettings["DateFormat2"].ToString()); int timeformat2 = Convert.ToInt32(ConfigurationManager.AppSettings["TimeFormat2"].ToString()); DigitalClockAreaInfo.ShowStrFont = FontProp; if (dateformat2 >= 0 && dateformat2 < 8) { DigitalClockAreaInfo.DateFormat = dateformat2; DigitalClockAreaInfo.IsMutleLineShow = 1; DigitalClockAreaInfo.IsShowYear = 1; DigitalClockAreaInfo.IsShowMonth = 1; DigitalClockAreaInfo.IsShowDay = 1; } if (timeformat2 >= 0 && timeformat2 < 7) { DigitalClockAreaInfo.TimeFormat = timeformat2; DigitalClockAreaInfo.IsShowHour = 1; DigitalClockAreaInfo.IsShowMinute = 1; DigitalClockAreaInfo.IsShowSecond = 1; DigitalClockAreaInfo.IsMutleLineShow = 1; } LedDll.LV_AdjustTime(ref CommunicationInfo); nResult = LedDll.LV_AddDigitalClockArea(hProgram, 1, 7, ref AreaRect, ref DigitalClockAreaInfo);//注意区域号不能一样,详见函数声明注示 } if (la.Area_type == 5) { int aid = la.Id; LedDll.CLOCKAREAINFO DigitalClockAreaInfo = new LedDll.CLOCKAREAINFO(); DigitalClockAreaInfo.ClockType = 0; DigitalClockAreaInfo.DateFormat = 1; DigitalClockAreaInfo.HourMarkColor = 1; DigitalClockAreaInfo.HourMarkType = 0; DigitalClockAreaInfo.HourMarkWidth = 2; DigitalClockAreaInfo.MiniteMarkColor = LedDll.COLOR_RED; DigitalClockAreaInfo.MiniteMarkType = 0; DigitalClockAreaInfo.MiniteMarkWidth = 1; DigitalClockAreaInfo.HourMarkColor = LedDll.COLOR_RED; DigitalClockAreaInfo.MinutePointerColor = LedDll.COLOR_RED; DigitalClockAreaInfo.SecondPointerColor = LedDll.COLOR_RED; DigitalClockAreaInfo.MinutePointerWidth = 2; DigitalClockAreaInfo.HourPointerWidth = 3; DigitalClockAreaInfo.SecondPointerWidth = 1; LedDll.LV_AdjustTime(ref CommunicationInfo); nResult = LedDll.LV_AddClockArea(hProgram, 1, 8, ref AreaRect, ref DigitalClockAreaInfo); //注意区域号不能一样,详见函数声明注示 if (nResult != 0) //如果失败则可以调用LV_GetError获取中文错误信息 { LEDErrorControl(nResult); return; } } #endregion } #warning 这种文本区域的方法与图像区域的方法是互斥的,即如果调用了LV_AddImageTextArea,则再调用此方法,屏幕没有内容显示 #warning nResult = LedDll.LV_QuickAddSingleLineTextArea(hProgram, 1, 2, ref AreaRect, LedDll.ADDTYPE_STRING, "上海灵信视觉技术股份有限公司", ref FontProp, 4); //快速通过字符添加一个单行文本区域,函数见函数声明注示 nResult = LedDll.LV_Send(ref CommunicationInfo, hProgram); //发送,见函数声明注示 LedDll.LV_DeleteProgram(hProgram); //删除节目内存对象,详见函数声明注示 if (nResult != 0) //如果失败则可以调用LV_GetError获取中文错误信息 { string ErrStr; ErrStr = LedDll.LS_GetError(nResult); Console.WriteLine(ErrStr); } else { Console.WriteLine("LED发送成功"); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
/// <summary> /// 班组考勤统计LED控制,轨交 /// </summary> /// <param name="info"></param> /// <param name="identityId"></param> /// <param name="checktype"></param> public async void LedWorkGroupControl(LedInfo info, string identityId, int checktype) { try { //getClassCount();//通用版 GetClassCountLocal();//轨交版 if (info.LedIp == null) { Console.WriteLine("LED参数未设置"); return; } int nResult; LedDll.COMMUNICATIONINFO CommunicationInfo = new LedDll.COMMUNICATIONINFO(); //定义一通讯参数结构体变量用于对设定的LED通讯,具体对此结构体元素赋值说明见COMMUNICATIONINFO结构体定义部份注示 CommunicationInfo.SendType = 0; //设为固定IP通讯模式,即TCP通讯 CommunicationInfo.IpStr = info.LedIp; //给IpStr赋值LED控制卡的IP CommunicationInfo.LedNumber = 1; nResult = LedDll.LV_SetBasicInfo(ref CommunicationInfo, 2, info.Width, info.Height); if (nResult != 0) { LEDErrorControl(nResult); return; } int hProgram; //节目句柄 hProgram = LedDll.LV_CreateProgram(info.Width, info.Height, 2); //根据传的参数创建节目句柄,64是屏宽点数,32是屏高点数,2是屏的颜色,注意此处屏宽高及颜色参数必需与设置屏参的屏宽高及颜色一致,否则发送时会提示错误 if (hProgram == 0) { Console.WriteLine("创建节目对象失败"); return; } nResult = LedDll.LV_AddProgram(hProgram, 1, 0, 0);//添加一个节目,参数说明见函数声明注示 if (nResult != 0) { LEDErrorControl(nResult); return; } List <ModuleInfo> lla = GetLEDArea(info.Id); foreach (ModuleInfo la in lla) { LedDll.AREARECT AreaRect = new LedDll.AREARECT();//区域坐标属性结构体变量 AreaRect.left = la.Left_begin; AreaRect.top = la.Top_begin; AreaRect.width = la.Width; AreaRect.height = la.Height; LedDll.LV_AddImageTextArea(hProgram, 1, la.Id, ref AreaRect, 1); LedDll.FONTPROP FontProp = new LedDll.FONTPROP();//文字属性 FontProp.FontName = "宋体"; FontProp.FontSize = la.Font_size; FontProp.FontColor = LedDll.COLOR_RED; FontProp.FontBold = la.Font_bold; LedDll.PLAYPROP PlayProp = new LedDll.PLAYPROP(); PlayProp.InStyle = la.In_style; PlayProp.DelayTime = la.Delay_time; PlayProp.Speed = la.Speed; if (la.Area_type == 1 || la.Area_type == 5 || la.Area_type == 6) { string outs = string.Empty; foreach (ClassCount cc in CCC) { outs += cc.classNo + " 在场" + cc.count + "人\n"; } LedDll.LV_AddMultiLineTextToImageTextArea(hProgram, 1, la.Id, LedDll.ADDTYPE_STRING, outs, ref FontProp, ref PlayProp, la.Multi_nAlignment, la.Multi_IsVCenter); } if (la.Area_type == 2) { nResult = LedDll.LV_AddSingleLineTextToImageTextArea(hProgram, 1, la.Id, LedDll.ADDTYPE_STRING, ConfigurationManager.AppSettings["slogen"].ToString(), ref FontProp, ref PlayProp); if (nResult != 0)//如果失败则可以调用LV_GetError获取中文错误信息 { LEDErrorControl(nResult); return; } } } nResult = LedDll.LV_Send(ref CommunicationInfo, hProgram); //发送,见函数声明注示 LedDll.LV_DeleteProgram(hProgram); //删除节目内存对象,详见函数声明注示 if (nResult != 0) //如果失败则可以调用LV_GetError获取中文错误信息 { string ErrStr; ErrStr = LedDll.LS_GetError(nResult); Console.WriteLine(ErrStr); } else { Console.WriteLine("LED发送成功"); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
/// <summary> /// 两个节目下个设置一个单行文本去和一个数字时钟区(多节目通过此方法添加) /// </summary> public void Button6_Click() { int hProgram; //节目句柄 hProgram = LedDll.LV_CreateProgram(64, 32, 3, 5, 0); //根据传的参数创建节目句柄,64是屏宽点数,32是屏高点数,2是屏的颜色,注意此处屏宽高及颜色参数必需与设置屏参的屏宽高及颜色一致,否则发送时会提示错误 //此处可自行判断有未创建成功,hProgram返回NULL失败,非NULL成功,一般不会失败 nResult = LedDll.LV_AddProgram(hProgram, 1, 0, 1); //添加一个节目,参数说明见函数声明注示 if (nResult != 0) { string ErrStr; ErrStr = LedDll.LS_GetError(nResult); Debug.Log(ErrStr); // MessageBox.Show(ErrStr); return; } LedDll.AREARECT AreaRect = new LedDll.AREARECT();//区域坐标属性结构体变量 AreaRect.left = 0; AreaRect.top = 0; AreaRect.width = 64; AreaRect.height = 16; LedDll.FONTPROP FontProp = new LedDll.FONTPROP();//文字属性 FontProp.FontName = "宋体"; FontProp.FontSize = 12; FontProp.FontColor = LedDll.COLOR_RED; FontProp.FontBold = 0; //int nsize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(LedDll.FONTPROP)); nResult = LedDll.LV_QuickAddSingleLineTextArea(hProgram, 1, 1, ref AreaRect, LedDll.ADDTYPE_STRING, "上海灵信视觉技术股份有限公司", ref FontProp, 4);//快速通过字符添加一个单行文本区域,函数见函数声明注示 AreaRect.left = 0; AreaRect.top = 16; AreaRect.width = 64; AreaRect.height = 16; LedDll.DIGITALCLOCKAREAINFO DigitalClockAreaInfo = new LedDll.DIGITALCLOCKAREAINFO(); DigitalClockAreaInfo.TimeColor = LedDll.COLOR_RED; DigitalClockAreaInfo.ShowStrFont.FontName = "宋体"; DigitalClockAreaInfo.ShowStrFont.FontSize = 12; DigitalClockAreaInfo.IsShowHour = 1; DigitalClockAreaInfo.IsShowMinute = 1; nResult = LedDll.LV_AddDigitalClockArea(hProgram, 1, 2, ref AreaRect, ref DigitalClockAreaInfo);//注意区域号不能一样,详见函数声明注示 /////////////////////////////////////////////////// nResult = LedDll.LV_AddProgram(hProgram, 2, 0, 1); AreaRect.left = 0; AreaRect.top = 0; AreaRect.width = 64; AreaRect.height = 16; FontProp.FontName = "黑体"; FontProp.FontSize = 12; FontProp.FontColor = LedDll.COLOR_RED; FontProp.FontBold = 0; //int nsize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(LedDll.FONTPROP)); nResult = LedDll.LV_QuickAddSingleLineTextArea(hProgram, 2, 1, ref AreaRect, LedDll.ADDTYPE_STRING, "胡半仙到此一游", ref FontProp, 4);//快速通过字符添加一个单行文本区域,函数见函数声明注示 AreaRect.left = 0; AreaRect.top = 16; AreaRect.width = 64; AreaRect.height = 16; DigitalClockAreaInfo.ShowStrFont.FontName = "黑体"; DigitalClockAreaInfo.ShowStrFont.FontSize = 12; DigitalClockAreaInfo.IsShowHour = 1; DigitalClockAreaInfo.IsShowMinute = 1; DigitalClockAreaInfo.TimeFormat = 2; nResult = LedDll.LV_AddDigitalClockArea(hProgram, 2, 2, ref AreaRect, ref DigitalClockAreaInfo); //注意区域号不能一样,详见函数声明注示 nResult = LedDll.LV_Send(ref CommunicationInfo, hProgram); //发送,见函数声明注示 LedDll.LV_DeleteProgram(hProgram); //删除节目内存对象,详见函数声明注示 if (nResult != 0) //如果失败则可以调用LV_GetError获取中文错误信息 { string ErrStr; ErrStr = LedDll.LS_GetError(nResult); Debug.Log(ErrStr); //MessageBox.Show(ErrStr); } else { Debug.Log("发送成功"); //MessageBox.Show("发送成功"); } }
public void Button2_Click() { int nResult; LedDll.COMMUNICATIONINFO CommunicationInfo = new LedDll.COMMUNICATIONINFO();//定义一通讯参数结构体变量用于对设定的LED通讯,具体对此结构体元素赋值说明见COMMUNICATIONINFO结构体定义部份注示 CommunicationInfo.LEDType = 3; //TCP通讯******************************************************************************** CommunicationInfo.SendType = 0; //设为固定IP通讯模式,即TCP通讯 CommunicationInfo.IpStr = "192.168.1.245"; //给IpStr赋值LED控制卡的IP CommunicationInfo.LedNumber = 1; //LED屏号为1,注意socket通讯和232通讯不识别屏号,默认赋1就行了,485必需根据屏的实际屏号进行赋值 //广播通讯******************************************************************************** //CommunicationInfo.SendType=1;//设为单机直连,即广播通讯无需设LED控制器的IP地址 //串口通讯******************************************************************************** //CommunicationInfo.SendType=2;//串口通讯 //CommunicationInfo.Commport=1;//串口的编号,如设备管理器里显示为 COM3 则此处赋值 3 //CommunicationInfo.Baud=9600;//波特率 //CommunicationInfo.LedNumber=1; int hProgram; //节目句柄 hProgram = LedDll.LV_CreateProgram(64, 32, 3, 5, 0); //根据传的参数创建节目句柄,64是屏宽点数,32是屏高点数,2是屏的颜色,注意此处屏宽高及颜色参数必需与设置屏参的屏宽高及颜色一致,否则发送时会提示错误 //此处可自行判断有未创建成功,hProgram返回NULL失败,非NULL成功,一般不会失败 nResult = LedDll.LV_AddProgram(hProgram, 1, 0, 1); //添加一个节目,参数说明见函数声明注示 if (nResult != 0) { string ErrStr; ErrStr = LedDll.LS_GetError(nResult); Debug.Log(ErrStr); text.text = ErrStr; // MessageBox.Show(ErrStr); return; } LedDll.AREARECT AreaRect = new LedDll.AREARECT();//区域坐标属性结构体变量 AreaRect.left = 0; AreaRect.top = 0; AreaRect.width = 64; AreaRect.height = 32; LedDll.FONTPROP FontProp = new LedDll.FONTPROP();//文字属性 FontProp.FontName = "宋体"; FontProp.FontSize = 12; FontProp.FontColor = LedDll.COLOR_GREEN; FontProp.FontBold = 0; //int nsize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(LedDll.FONTPROP)); nResult = LedDll.LV_QuickAddSingleLineTextArea(hProgram, 1, 1, ref AreaRect, LedDll.ADDTYPE_STRING, "上海灵信视觉技术股份有限公司", ref FontProp, 4);//快速通过字符添加一个单行文本区域,函数见函数声明注示 // nResult = LedDll.LV_QuickAddSingleLineTextArea(hProgram, 1, 1, ref AreaRect, LedDll.ADDTYPE_FILE, "test.rtf", ref FontProp, 4);//快速通过rtf文件添加一个单行文本区域,函数见函数声明注示 //nResult = LedDll.LV_QuickAddSingleLineTextArea(hProgram, 1, 1, ref AreaRect, LedDll.ADDTYPE_FILE, "test.txt", ref FontProp, 4);//快速通过txt文件添加一个单行文本区域,函数见函数声明注示 nResult = LedDll.LV_Send(ref CommunicationInfo, hProgram); //发送,见函数声明注示 LedDll.LV_DeleteProgram(hProgram); //删除节目内存对象,详见函数声明注示 if (nResult != 0) //如果失败则可以调用LV_GetError获取中文错误信息 { string ErrStr; ErrStr = LedDll.LS_GetError(nResult); Debug.Log(ErrStr); text.text = ErrStr; // MessageBox.Show(ErrStr); } else { Debug.Log("发送成功"); text.text = "发送成功"; // MessageBox.Show("发送成功"); } }
public void Button4_Click() { int nResult; LedDll.COMMUNICATIONINFO CommunicationInfo = new LedDll.COMMUNICATIONINFO();//定义一通讯参数结构体变量用于对设定的LED通讯,具体对此结构体元素赋值说明见COMMUNICATIONINFO结构体定义部份注示 CommunicationInfo.LEDType = 3; //TCP通讯******************************************************************************** CommunicationInfo.SendType = 0; //设为固定IP通讯模式,即TCP通讯 CommunicationInfo.IpStr = "192.168.1.245"; //给IpStr赋值LED控制卡的IP CommunicationInfo.LedNumber = 1; //LED屏号为1,注意socket通讯和232通讯不识别屏号,默认赋1就行了,485必需根据屏的实际屏号进行赋值 //广播通讯******************************************************************************** //CommunicationInfo.SendType=1;//设为单机直连,即广播通讯无需设LED控制器的IP地址 //串口通讯******************************************************************************** //CommunicationInfo.SendType=2;//串口通讯 //CommunicationInfo.Commport=1;//串口的编号,如设备管理器里显示为 COM3 则此处赋值 3 //CommunicationInfo.Baud=9600;//波特率 //CommunicationInfo.LedNumber=1; int hProgram; //节目句柄 hProgram = LedDll.LV_CreateProgram(64, 32, 3, 5, 0); //根据传的参数创建节目句柄,64是屏宽点数,32是屏高点数,2是屏的颜色,注意此处屏宽高及颜色参数必需与设置屏参的屏宽高及颜色一致,否则发送时会提示错误 //此处可自行判断有未创建成功,hProgram返回NULL失败,非NULL成功,一般不会失败 nResult = LedDll.LV_AddProgram(hProgram, 1, 0, 1); //添加一个节目,参数说明见函数声明注示 if (nResult != 0) { string ErrStr; ErrStr = LedDll.LS_GetError(nResult); Debug.Log(ErrStr); // MessageBox.Show(ErrStr); return; } LedDll.AREARECT AreaRect = new LedDll.AREARECT();//区域坐标属性结构体变量 AreaRect.left = 0; AreaRect.top = 0; AreaRect.width = 64; AreaRect.height = 32; LedDll.LV_AddImageTextArea(hProgram, 1, 1, ref AreaRect, 0); LedDll.PLAYPROP PlayProp = new LedDll.PLAYPROP(); PlayProp.InStyle = 0; PlayProp.DelayTime = 3; PlayProp.Speed = 4; //可以添加多个子项到图文区,如下添加可以选一个或多个添加 //可以添加多个子项到图文区,如下添加可以选一个或多个添加 nResult = LedDll.LV_AddFileToImageTextArea(hProgram, 1, 1, "test.bmp", ref PlayProp); nResult = LedDll.LV_AddFileToImageTextArea(hProgram, 1, 1, "test.jpg", ref PlayProp); nResult = LedDll.LV_AddFileToImageTextArea(hProgram, 1, 1, "test.png", ref PlayProp); PlayProp.Speed = 3; nResult = LedDll.LV_AddFileToImageTextArea(hProgram, 1, 1, "test.gif", ref PlayProp); nResult = LedDll.LV_Send(ref CommunicationInfo, hProgram); //发送,见函数声明注示 LedDll.LV_DeleteProgram(hProgram); //删除节目内存对象,详见函数声明注示 if (nResult != 0) //如果失败则可以调用LV_GetError获取中文错误信息 { string ErrStr; ErrStr = LedDll.LS_GetError(nResult); Debug.Log(ErrStr); //MessageBox.Show(ErrStr); } else { Debug.Log("发送成功"); //MessageBox.Show("发送成功"); } }