找传奇、传世资源到传世资源站!

灵信LED开发

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

from clipboardusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace Demo{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } string s1; string s2; string s3; string s4; string s5; string s6; private void button5_Click(object sender, EventArgs e) { int nResult; LedDll.COMMUNICATIONINFO CommunicationInfo = new LedDll.COMMUNICATIONINFO();//定义一通讯参数结构体变量用于对设定的LED通讯,具体对此结构体元素赋值说明见COMMUNICATIONINFO结构体定义部份注示 //ZeroMemory(&CommunicationInfo,sizeof(COMMUNICATIONINFO)); //TCP通讯******************************************************************************** CommunicationInfo.SendType = 0;//设为固定IP通讯模式,即TCP通讯 CommunicationInfo.IpStr = "192.168.1.99";//给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(128, 128, 2);//根据传的参数创建节目句柄,64是屏宽点数,32是屏高点数,2是屏的颜色,注意此处屏宽高及颜色参数必需与设置屏参的屏宽高及颜色一致,否则发送时会提示错误 //此处可自行判断有未创建成功,hProgram返回NULL失败,非NULL成功,一般不会失败 nResult = LedDll.LV_AddProgram(hProgram, 1, 0, 1);//添加一个节目,参数说明见函数声明注示 if (nResult != 0) { string ErrStr; ErrStr = LedDll.LS_GetError(nResult); MessageBox.Show(ErrStr); return; } //添加一个文本1 LedDll.AREARECT AreaRect = new LedDll.AREARECT();//区域坐标属性结构体变量 AreaRect.left = 0; AreaRect.top = 32; 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_GREEN; FontProp.FontBold = 0; //int nsize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(LedDll.FONTPROP)); 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, textBox1.Text "g", ref FontProp, ref PlayProp, 1, 1);//通过字符串添加一个多行文本到图文区,参数说明见声明注示 //添加一个文本2 LedDll.AREARECT AreaRect1 = new LedDll.AREARECT();//区域坐标属性结构体变量 AreaRect1.left = 0; AreaRect1.top = 64; AreaRect1.width = 64; AreaRect1.height = 32; LedDll.LV_AddImageTextArea(hProgram, 1, 2, ref AreaRect1, 0); LedDll.FONTPROP FontProp1 = new LedDll.FONTPROP();//文字属性 FontProp1.FontName = "宋体"; FontProp1.FontSize = 12; FontProp1.FontColor = LedDll.COLOR_GREEN; FontProp1.FontBold = 0; //int nsize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(LedDll.FONTPROP)); LedDll.PLAYPROP PlayProp1 = new LedDll.PLAYPROP(); PlayProp1.InStyle = 0; PlayProp1.DelayTime = 3; PlayProp1.Speed = 4; nResult = LedDll.LV_AddMultiLineTextToImageTextArea(hProgram, 1, 2, LedDll.ADDTYPE_STRING,textBox2.Text "g", ref FontProp1, ref PlayProp1, 1, 1);//通过字符串添加一个多行文本到图文区,参数说明见声明注示 //添加一个文本3 LedDll.AREARECT AreaRect2 = new LedDll.AREARECT();//区域坐标属性结构体变量 AreaRect2.left = 0; AreaRect2.top = 96; AreaRect2.width = 64; AreaRect2.height = 32; LedDll.LV_AddImageTextArea(hProgram, 1, 3, ref AreaRect2, 0); LedDll.FONTPROP FontProp2 = new LedDll.FONTPROP();//文字属性 FontProp2.FontName = "宋体"; FontProp2.FontSize = 12; FontProp2.FontColor = LedDll.COLOR_GREEN; FontProp2.FontBold = 0; //int nsize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(LedDll.FONTPROP)); LedDll.PLAYPROP PlayProp2 = new LedDll.PLAYPROP(); PlayProp2.InStyle = 0; PlayProp2.DelayTime = 3; PlayProp2.Speed = 4; nResult = LedDll.LV_AddMultiLineTextToImageTextArea(hProgram, 1, 3, LedDll.ADDTYPE_STRING, textBox3.Text "g", ref FontProp2, ref PlayProp2, 1, 1);//通过字符串添加一个多行文本到图文区,参数说明见声明注示 //添加一个文本4 LedDll.AREARECT AreaRect3 = new LedDll.AREARECT();//区域坐标属性结构体变量 AreaRect3.left = 64; AreaRect3.top = 32; AreaRect3.width = 64; AreaRect3.height = 32; LedDll.LV_AddImageTextArea(hProgram, 1, 4, ref AreaRect3, 0); LedDll.FONTPROP FontProp3 = new LedDll.FONTPROP();//文字属性 FontProp3.FontName = "宋体"; FontProp3.FontSize = 12; FontProp3.FontColor = LedDll.COLOR_GREEN; FontProp3.FontBold = 0; //int nsize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(LedDll.FONTPROP)); LedDll.PLAYPROP PlayProp3 = new LedDll.PLAYPROP(); PlayProp3.InStyle = 0; PlayProp3.DelayTime = 3; PlayProp3.Speed = 4; nResult = LedDll.LV_AddMultiLineTextToImageTextArea(hProgram, 1, 4, LedDll.ADDTYPE_STRING, textBox4.Text "g", ref FontProp3, ref PlayProp3, 1, 1);//通过字符串添加一个多行文本到图文区,参数说明见声明注示 //添加一个文本5 LedDll.AREARECT AreaRect4 = new LedDll.AREARECT();//区域坐标属性结构体变量 AreaRect4.left = 64; AreaRect4.top = 64; AreaRect4.width = 64; AreaRect4.height = 32; LedDll.LV_AddImageTextArea(hProgram, 1, 5, ref AreaRect4, 0); LedDll.FONTPROP FontProp4 = new LedDll.FONTPROP();//文字属性 FontProp4.FontName = "宋体"; FontProp4.FontSize = 12; FontProp4.FontColor = LedDll.COLOR_GREEN; FontProp4.FontBold = 0; //int nsize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(LedDll.FONTPROP)); LedDll.PLAYPROP PlayProp4 = new LedDll.PLAYPROP(); PlayProp4.InStyle = 0; PlayProp4.DelayTime = 3; PlayProp4.Speed = 4; nResult = LedDll.LV_AddMultiLineTextToImageTextArea(hProgram, 1, 5, LedDll.ADDTYPE_STRING, textBox5.Text "g", ref FontProp4, ref PlayProp4, 1, 1);//通过字符串添加一个多行文本到图文区,参数说明见声明注示 //添加一个文本6 LedDll.AREARECT AreaRect5 = new LedDll.AREARECT();//区域坐标属性结构体变量 AreaRect5.left = 64; AreaRect5.top = 96; AreaRect5.width = 64; AreaRect5.height = 32; LedDll.LV_AddImageTextArea(hProgram, 1, 6, ref AreaRect5, 0); LedDll.FONTPROP FontProp5 = new LedDll.FONTPROP();//文字属性 FontProp5.FontName = "宋体"; FontProp5.FontSize = 12; FontProp5.FontColor = LedDll.COLOR_GREEN; FontProp5.FontBold = 0; //int nsize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(LedDll.FONTPROP)); LedDll.PLAYPROP PlayProp5 = new LedDll.PLAYPROP(); PlayProp5.InStyle = 0; PlayProp5.DelayTime = 3; PlayProp5.Speed = 4; nResult = LedDll.LV_AddMultiLineTextToImageTextArea(hProgram, 1, 6, LedDll.ADDTYPE_STRING, textBox6.Text "g", ref FontProp5, ref PlayProp5, 1, 1);//通过字符串添加一个多行文本到图文区,参数说明见声明注示 //添加一个文本7 LedDll.AREARECT AreaRect6 = new LedDll.AREARECT();//区域坐标属性结构体变量 AreaRect6.left = 0; AreaRect6.top = 0; AreaRect6.width = 128; AreaRect6.height = 32; LedDll.LV_AddImageTextArea(hProgram, 1, 7, ref AreaRect6, 0); LedDll.FONTPROP FontProp6 = new LedDll.FONTPROP();//文字属性 FontProp6.FontName = "宋体"; FontProp6.FontSize = 12; FontProp6.FontColor = LedDll.COLOR_GREEN; FontProp6.FontBold = 0; //int nsize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(LedDll.FONTPROP)); LedDll.PLAYPROP PlayProp6 = new LedDll.PLAYPROP(); PlayProp6.InStyle = 0; PlayProp6.DelayTime = 3; PlayProp6.Speed = 4; nResult = LedDll.LV_AddMultiLineTextToImageTextArea(hProgram, 1, 7, LedDll.ADDTYPE_STRING, "重量显示", ref FontProp6, ref PlayProp6, 2, 1);//通过字符串添加一个多行文本到图文区,参数说明见声明注示 nResult = LedDll.LV_Send(ref CommunicationInfo, hProgram);//发送,见函数声明注示 LedDll.LV_DeleteProgram(hProgram);//删除节目内存对象,详见函数声明注示 if (nResult != 0)//如果失败则可以调用LV_GetError获取中文错误信息 { string ErrStr; ErrStr = LedDll.LS_GetError(nResult); MessageBox.Show(ErrStr); } else { MessageBox.Show("发送成功"); } } private void timer1_Tick(object sender, EventArgs e) { timer1.Enabled = false; if (s1 != textBox1.Text || s2 != textBox2.Text || s3 != textBox3.Text || s4 != textBox4.Text || s5 != textBox5.Text || s6 != textBox6.Text) { s1 = textBox1.Text; s2 = textBox2.Text; s3 = textBox3.Text; s4 = textBox4.Text; s5 = textBox5.Text; s6 = textBox6.Text; int nResult; LedDll.COMMUNICATIONINFO CommunicationInfo = new LedDll.COMMUNICATIONINFO();//定义一通讯参数结构体变量用于对设定的LED通讯,具体对此结构体元素赋值说明见COMMUNICATIONINFO结构体定义部份注示 //ZeroMemory(&CommunicationInfo,sizeof(COMMUNICATIONINFO)); //TCP通讯******************************************************************************** CommunicationInfo.SendType = 0;//设为固定IP通讯模式,即TCP通讯 CommunicationInfo.IpStr = "192.168.1.99";//给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(128, 128, 2);//根据传的参数创建节目句柄,64是屏宽点数,32是屏高点数,2是屏的颜色,注意此处屏宽高及颜色参数必需与设置屏参的屏宽高及颜色一致,否则发送时会提示错误 //此处可自行判断有未创建成功,hProgram返回NULL失败,非NULL成功,一般不会失败 nResult = LedDll.LV_AddProgram(hProgram, 1, 0, 1);//添加一个节目,参数说明见函数声明注示 if (nResult != 0) { string ErrStr; ErrStr = LedDll.LS_GetError(nResult); MessageBox.Show(ErrStr); return; } //添加一个文本1 LedDll.AREARECT AreaRect = new LedDll.AREARECT();//区域坐标属性结构体变量 AreaRect.left = 0; AreaRect.top = 32; 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_GREEN; FontProp.FontBold = 0; //int nsize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(LedDll.FONTPROP)); 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, textBox1.Text "g", ref FontProp, ref PlayProp, 1, 1);//通过字符串添加一个多行文本到图文区,参数说明见声明注示 //添加一个文本2 LedDll.AREARECT AreaRect1 = new LedDll.AREARECT();//区域坐标属性结构体变量 AreaRect1.left = 0; AreaRect1.top = 64; AreaRect1.width = 64; AreaRect1.height = 32; LedDll.LV_AddImageTextArea(hProgram, 1, 2, ref AreaRect1, 0); LedDll.FONTPROP FontProp1 = new LedDll.FONTPROP();//文字属性 FontProp1.FontName = "宋体"; FontProp1.FontSize = 12; FontProp1.FontColor = LedDll.COLOR_GREEN; FontProp1.FontBold = 0; //int nsize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(LedDll.FONTPROP)); LedDll.PLAYPROP PlayProp1 = new LedDll.PLAYPROP(); PlayProp1.InStyle = 0; PlayProp1.DelayTime = 3; PlayProp1.Speed = 4; nResult = LedDll.LV_AddMultiLineTextToImageTextArea(hProgram, 1, 2, LedDll.ADDTYPE_STRING, textBox2.Text "g", ref FontProp1, ref PlayProp1, 1, 1);//通过字符串添加一个多行文本到图文区,参数说明见声明注示 //添加一个文本3 LedDll.AREARECT AreaRect2 = new LedDll.AREARECT();//区域坐标属性结构体变量 AreaRect2.left = 0; AreaRect2.top = 96; AreaRect2.width = 64; AreaRect2.height = 32; LedDll.LV_AddImageTextArea(hProgram, 1, 3, ref AreaRect2, 0); LedDll.FONTPROP FontProp2 = new LedDll.FONTPROP();//文字属性 FontProp2.FontName = "宋体"; FontProp2.FontSize = 12; FontProp2.FontColor = LedDll.COLOR_GREEN; FontProp2.FontBold = 0; //int nsize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(LedDll.FONTPROP)); LedDll.PLAYPROP PlayProp2 = new LedDll.PLAYPROP(); PlayProp2.InStyle = 0; PlayProp2.DelayTime = 3; PlayProp2.Speed = 4; nResult = LedDll.LV_AddMultiLineTextToImageTextArea(hProgram, 1, 3, LedDll.ADDTYPE_STRING, textBox3.Text "g", ref FontProp2, ref PlayProp2, 1, 1);//通过字符串添加一个多行文本到图文区,参数说明见声明注示 //添加一个文本4 LedDll.AREARECT AreaRect3 = new LedDll.AREARECT();//区域坐标属性结构体变量 AreaRect3.left = 64; AreaRect3.top = 32; AreaRect3.width = 64; AreaRect3.height = 32; LedDll.LV_AddImageTextArea(hProgram, 1, 4, ref AreaRect3, 0); LedDll.FONTPROP FontProp3 = new LedDll.FONTPROP();//文字属性 FontProp3.FontName = "宋体"; FontProp3.FontSize = 12; FontProp3.FontColor = LedDll.COLOR_GREEN; FontProp3.FontBold = 0; //int nsize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(LedDll.FONTPROP)); LedDll.PLAYPROP PlayProp3 = new LedDll.PLAYPROP(); PlayProp3.InStyle = 0; PlayProp3.DelayTime = 3; PlayProp3.Speed = 4; nResult = LedDll.LV_AddMultiLineTextToImageTextArea(hProgram, 1, 4, LedDll.ADDTYPE_STRING, textBox4.Text "g", ref FontProp3, ref PlayProp3, 1, 1);//通过字符串添加一个多行文本到图文区,参数说明见声明注示 //添加一个文本5 LedDll.AREARECT AreaRect4 = new LedDll.AREARECT();//区域坐标属性结构体变量 AreaRect4.left = 64; AreaRect4.top = 64; AreaRect4.width = 64; AreaRect4.height = 32; LedDll.LV_AddImageTextArea(hProgram, 1, 5, ref AreaRect4, 0); LedDll.FONTPROP FontProp4 = new LedDll.FONTPROP();//文字属性 FontProp4.FontName = "宋体"; FontProp4.FontSize = 12; FontProp4.FontColor = LedDll.COLOR_GREEN; FontProp4.FontBold = 0; //int nsize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(LedDll.FONTPROP)); LedDll.PLAYPROP PlayProp4 = new LedDll.PLAYPROP(); PlayProp4.InStyle = 0; PlayProp4.DelayTime = 3; PlayProp4.Speed = 4; nResult = LedDll.LV_AddMultiLineTextToImageTextArea(hProgram, 1, 5, LedDll.ADDTYPE_STRING, textBox5.Text "g", ref FontProp4, ref PlayProp4, 1, 1);//通过字符串添加一个多行文本到图文区,参数说明见声明注示 //添加一个文本6 LedDll.AREARECT AreaRect5 = new LedDll.AREARECT();//区域坐标属性结构体变量 AreaRect5.left = 64; AreaRect5.top = 96; AreaRect5.width = 64; AreaRect5.height = 32; LedDll.LV_AddImageTextArea(hProgram, 1, 6, ref AreaRect5, 0); LedDll.FONTPROP FontProp5 = new LedDll.FONTPROP();//文字属性 FontProp5.FontName = "宋体"; FontProp5.FontSize = 12; FontProp5.FontColor = LedDll.COLOR_GREEN; FontProp5.FontBold = 0; //int nsize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(LedDll.FONTPROP)); LedDll.PLAYPROP PlayProp5 = new LedDll.PLAYPROP(); PlayProp5.InStyle = 0; PlayProp5.DelayTime = 3; PlayProp5.Speed = 4; nResult = LedDll.LV_AddMultiLineTextToImageTextArea(hProgram, 1, 6, LedDll.ADDTYPE_STRING, textBox6.Text "g", ref FontProp5, ref PlayProp5, 1, 1);//通过字符串添加一个多行文本到图文区,参数说明见声明注示 //添加一个文本7 LedDll.AREARECT AreaRect6 = new LedDll.AREARECT();//区域坐标属性结构体变量 AreaRect6.left = 0; AreaRect6.top = 0; AreaRect6.width = 128; AreaRect6.height = 32; LedDll.LV_AddImageTextArea(hProgram, 1, 7, ref AreaRect6, 0); LedDll.FONTPROP FontProp6 = new LedDll.FONTPROP();//文字属性 FontProp6.FontName = "宋体"; FontProp6.FontSize = 12; FontProp6.FontColor = LedDll.COLOR_GREEN; FontProp6.FontBold = 0; //int nsize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(LedDll.FONTPROP)); LedDll.PLAYPROP PlayProp6 = new LedDll.PLAYPROP(); PlayProp6.InStyle = 0; PlayProp6.DelayTime = 3; PlayProp6.Speed = 4; nResult = LedDll.LV_AddMultiLineTextToImageTextArea(hProgram, 1, 7, LedDll.ADDTYPE_STRING, "重量显示", ref FontProp6, ref PlayProp6, 2, 1);//通过字符串添加一个多行文本到图文区,参数说明见声明注示nResult = LedDll.LV_Send(ref CommunicationInfo, hProgram);//发送,见函数声明注示 LedDll.LV_DeleteProgram(hProgram);//删除节目内存对象,详见函数声明注示 if (nResult != 0)//如果失败则可以调用LV_GetError获取中文错误信息 { string ErrStr; ErrStr = LedDll.LS_GetError(nResult); MessageBox.Show(ErrStr); } } timer1.Enabled = true; } }}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复