在好例子网,分享、交流、成长!
您当前所在位置:首页C# 开发实例C#网络编程 → 灵信视觉LED控制C#例程

灵信视觉LED控制C#例程

C#网络编程

下载此实例
  • 开发语言:C#
  • 实例大小:0.30M
  • 下载次数:95
  • 浏览次数:2585
  • 发布时间:2018-01-02
  • 实例类别:C#网络编程
  • 发 布 人:lovemj42
  • 文件格式:.rar
  • 所需积分:2
 相关标签: C# c

实例介绍

【实例简介】

【实例截图】

from clipboard

【核心代码】

using 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();
        }

        private void button1_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 = textBox3.Text;//给IpStr赋值LED控制卡的IP
            CommunicationInfo.LedNumber = 1;//LED屏号为1,注意socket通讯和232通讯不识别屏号,默认赋1就行了,485必需根据屏的实际屏号进行赋值
            //广播通讯********************************************************************************
            //CommunicationInfo.SendType=1;//设为单机直连,即广播通讯无需设LED控制器的IP地址
            //串口通讯********************************************************************************
            //CommunicationInfo.SendType = 2;//串口通讯
            //CommunicationInfo.Commport = 3;//串口的编号,如设备管理器里显示为 COM3 则此处赋值 3
            //CommunicationInfo.Baud = 57600;//波特率
            //CommunicationInfo.LedNumber = 1;


            nResult = LedDll.LV_SetBasicInfo(ref CommunicationInfo, 1, int.Parse(textBox1.Text), int.Parse(textBox2.Text));//设置屏参,屏的颜色为2即为双基色,64为屏宽点数,32为屏高点数,具体函数参数说明见函数声明注示
            if (nResult!=0)//如果失败则可以调用LV_GetError获取中文错误信息
            {
                string ErrStr;
                ErrStr=LedDll.LS_GetError(nResult);
                MessageBox.Show(ErrStr);
            }
            else
            {
                MessageBox.Show("设置成功");
            }
        }

        private void button2_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 = textBox3.Text;//给IpStr赋值LED控制卡的IP
            CommunicationInfo.LedNumber = 1;//LED屏号为1,注意socket通讯和232通讯不识别屏号,默认赋1就行了,485必需根据屏的实际屏号进行赋值
            //广播通讯********************************************************************************
            //CommunicationInfo.SendType=1;//设为单机直连,即广播通讯无需设LED控制器的IP地址
            //串口通讯********************************************************************************
            //CommunicationInfo.SendType = 2;//串口通讯
            //CommunicationInfo.Commport = 3;//串口的编号,如设备管理器里显示为 COM3 则此处赋值 3
            //CommunicationInfo.Baud = 57600;//波特率
            //CommunicationInfo.LedNumber = 1;

            int hProgram;//节目句柄
            hProgram = LedDll.LV_CreateProgram(int.Parse(textBox1.Text), int.Parse(textBox2.Text), 1);//根据传的参数创建节目句柄,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;
            }
            LedDll.AREARECT AreaRect=new LedDll.AREARECT();//区域坐标属性结构体变量
            AreaRect.left = 0;
            AreaRect.top = 0;
            AreaRect.width = int.Parse(textBox1.Text);
            AreaRect.height = int.Parse(textBox2.Text);

            LedDll.FONTPROP FontProp=new LedDll.FONTPROP();//文字属性
            FontProp.FontName="宋体";
            FontProp.FontSize = 32;
            FontProp.FontColor = LedDll.COLOR_RED;
            FontProp.FontBold = 0;
            //int nsize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(LedDll.FONTPROP));

            //LedDll.WATERBORDERINFO WaterProp = new LedDll.WATERBORDERINFO();//流水边框
            //WaterProp.BorderColor = LedDll.COLOR_RED;
            //WaterProp.BorderSpeed = 3;
            //WaterProp.BorderStyle = 3;
            //WaterProp.BorderType = 0;
            //WaterProp.BorderValue = 3;
            //WaterProp.Flag = 0;
            //LedDll.LV_AddWaterBorder(hProgram, 1, 0, ref AreaRect, ref WaterProp);

            //AreaRect.left = 3;
            //AreaRect.top = 3;
            //AreaRect.width = 90;
            //AreaRect.height = 42;

            LedDll.PLAYPROP PlayProp = new LedDll.PLAYPROP();
            PlayProp.InStyle = 6;
            PlayProp.DelayTime = 3;
            PlayProp.Speed = 6;
            LedDll.LV_AddImageTextArea(hProgram, 1, 1, ref AreaRect, 0);
            nResult= LedDll.LV_AddSingleLineTextToImageTextArea(hProgram, 1, 1, LedDll.ADDTYPE_STRING, textBox4.Text, ref FontProp, ref PlayProp);
            
            //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);
                MessageBox.Show(ErrStr);
            }
            else
            {
                MessageBox.Show("发送成功");
            }

        }

        private void button3_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.245";//给IpStr赋值LED控制卡的IP
            CommunicationInfo.LedNumber = 1;//LED屏号为1,注意socket通讯和232通讯不识别屏号,默认赋1就行了,485必需根据屏的实际屏号进行赋值
            //广播通讯********************************************************************************
            //CommunicationInfo.SendType=1;//设为单机直连,即广播通讯无需设LED控制器的IP地址
            //串口通讯********************************************************************************
            CommunicationInfo.SendType = 2;//串口通讯
            CommunicationInfo.Commport = 3;//串口的编号,如设备管理器里显示为 COM3 则此处赋值 3
            CommunicationInfo.Baud = 57600;//波特率
            CommunicationInfo.LedNumber = 1;

            int hProgram;//节目句柄
            hProgram = LedDll.LV_CreateProgram(96, 48, 1);//根据传的参数创建节目句柄,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;
            }
            LedDll.AREARECT AreaRect = new LedDll.AREARECT();//区域坐标属性结构体变量
            AreaRect.left = 0;
            AreaRect.top = 0;
            AreaRect.width = 96;
            AreaRect.height = 48;

            LedDll.LV_AddImageTextArea(hProgram,1,1,ref AreaRect,0);

            LedDll.FONTPROP FontProp = new LedDll.FONTPROP();//文字属性
            FontProp.FontName = "宋体";
            FontProp.FontSize = 16;
            FontProp.FontColor = LedDll.COLOR_RED;
            FontProp.FontBold = 0;

            LedDll.PLAYPROP PlayProp = new LedDll.PLAYPROP();
            PlayProp.InStyle = 6;
            PlayProp.DelayTime = 3;
            PlayProp.Speed = 10;
            //可以添加多个子项到图文区,如下添加可以选一个或多个添加
            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);
                MessageBox.Show(ErrStr);
            }
            else
            {
                MessageBox.Show("发送成功");
            }
        }

        private void button4_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.44";//给IpStr赋值LED控制卡的IP
            CommunicationInfo.LedNumber = 1;//LED屏号为1,注意socket通讯和232通讯不识别屏号,默认赋1就行了,485必需根据屏的实际屏号进行赋值
            //广播通讯********************************************************************************
            //CommunicationInfo.SendType=1;//设为单机直连,即广播通讯无需设LED控制器的IP地址
            //串口通讯********************************************************************************
            //CommunicationInfo.SendType = 2;//串口通讯
            //CommunicationInfo.Commport = 3;//串口的编号,如设备管理器里显示为 COM3 则此处赋值 3
            //CommunicationInfo.Baud = 57600;//波特率
            //CommunicationInfo.LedNumber = 1;

            int hProgram;//节目句柄
            hProgram = LedDll.LV_CreateProgram(96, 48, 1);//根据传的参数创建节目句柄,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;
            }
            LedDll.AREARECT AreaRect = new LedDll.AREARECT();//区域坐标属性结构体变量
            AreaRect.left = 0;
            AreaRect.top = 0;
            AreaRect.width = 96;
            AreaRect.height = 48;

            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);
                MessageBox.Show(ErrStr);
            }
            else
            {
                MessageBox.Show("发送成功");
            }
        }

        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.44";//给IpStr赋值LED控制卡的IP
            CommunicationInfo.LedNumber = 1;//LED屏号为1,注意socket通讯和232通讯不识别屏号,默认赋1就行了,485必需根据屏的实际屏号进行赋值
            //广播通讯********************************************************************************
            //CommunicationInfo.SendType=1;//设为单机直连,即广播通讯无需设LED控制器的IP地址
            //串口通讯********************************************************************************
            //CommunicationInfo.SendType = 2;//串口通讯
            //CommunicationInfo.Commport = 3;//串口的编号,如设备管理器里显示为 COM3 则此处赋值 3
            //CommunicationInfo.Baud = 57600;//波特率
            //CommunicationInfo.LedNumber = 1;

            int hProgram;//节目句柄
            hProgram = LedDll.LV_CreateProgram(96, 48, 1);//根据传的参数创建节目句柄,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;
            }
            LedDll.AREARECT AreaRect = new LedDll.AREARECT();//区域坐标属性结构体变量
            AreaRect.left = 0;
            AreaRect.top = 0;
            AreaRect.width = 96;
            AreaRect.height = 16;

            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;
            //int nsize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(LedDll.FONTPROP));
            LedDll.LV_AddImageTextArea(hProgram, 1, 1, ref AreaRect, 0);
            //nResult = LedDll.LV_QuickAddSingleLineTextArea(hProgram, 1, 1, ref AreaRect, LedDll.ADDTYPE_STRING, "通航高度", ref FontProp, 255);//快速通过字符添加一个单行文本区域,函数见函数声明注示
            LedDll.LV_AddSingleLineTextToImageTextArea(hProgram, 1, 1, LedDll.ADDTYPE_STRING, "通航高度", ref FontProp, ref PlayProp);
            
            AreaRect.left = 0;
            AreaRect.top = 16;
            AreaRect.width = 96;
            AreaRect.height = 32;
            //LedDll.DIGITALCLOCKAREAINFO DigitalClockAreaInfo = new LedDll.DIGITALCLOCKAREAINFO();
            //DigitalClockAreaInfo.TimeColor = LedDll.COLOR_RED;
         
            //DigitalClockAreaInfo.ShowStrFont.FontName = "宋体";
            //DigitalClockAreaInfo.ShowStrFont.FontSize = 12;
            //DigitalClockAreaInfo.IsShowHour = 1;
            //DigitalClockAreaInfo.IsShowMinute = 1;
            FontProp.FontName = "宋体";
            FontProp.FontSize = 32;
            FontProp.FontColor = LedDll.COLOR_RED;
            FontProp.FontBold = 0;

            //nResult = LedDll.LV_AddDigitalClockArea(hProgram, 1, 2, ref AreaRect, ref DigitalClockAreaInfo);//注意区域号不能一样,详见函数声明注示

            nResult = LedDll.LV_QuickAddSingleLineTextArea(hProgram, 1, 2, ref AreaRect, LedDll.ADDTYPE_STRING, "12.30米   ", ref FontProp, 5);

            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 button6_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.245";//给IpStr赋值LED控制卡的IP
            //CommunicationInfo.LedNumber = 1;//LED屏号为1,注意socket通讯和232通讯不识别屏号,默认赋1就行了,485必需根据屏的实际屏号进行赋值
            //广播通讯********************************************************************************
            //CommunicationInfo.SendType=1;//设为单机直连,即广播通讯无需设LED控制器的IP地址
            //串口通讯********************************************************************************
            CommunicationInfo.SendType = 2;//串口通讯
            CommunicationInfo.Commport = 3;//串口的编号,如设备管理器里显示为 COM3 则此处赋值 3
            CommunicationInfo.Baud = 57600;//波特率
            CommunicationInfo.LedNumber = 1;

            int hProgram;//节目句柄
            hProgram = LedDll.LV_CreateProgram(96, 48, 1);//根据传的参数创建节目句柄,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;
            }
            LedDll.AREARECT AreaRect = new LedDll.AREARECT();//区域坐标属性结构体变量
            AreaRect.left = 0;
            AreaRect.top = 0;
            AreaRect.width = 96;
            AreaRect.height = 24;

            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 = 24;
            AreaRect.width = 96;
            AreaRect.height = 24;
            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 = 96;
            AreaRect.height = 24;
            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 = 24;
            AreaRect.width = 96;
            AreaRect.height = 24;

            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);
                MessageBox.Show(ErrStr);
            }
            else
            {
                MessageBox.Show("发送成功");
            }
        }

        private void button7_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.245";//给IpStr赋值LED控制卡的IP
            //CommunicationInfo.LedNumber = 1;//LED屏号为1,注意socket通讯和232通讯不识别屏号,默认赋1就行了,485必需根据屏的实际屏号进行赋值

            CommunicationInfo.SendType = 2;//串口通讯
            CommunicationInfo.Commport = 3;//串口的编号,如设备管理器里显示为 COM3 则此处赋值 3
            CommunicationInfo.Baud = 57600;//波特率
            CommunicationInfo.LedNumber = 1;

            int Info = 1;

            //LedDll.ONOFFTIMEINFO Info=new LedDll.ONOFFTIMEINFO();
            //Info.TimeFlag = new int[3];
            //Info.StartHour = new int[3];
            //Info.StartMinute = new int[3];
            //Info.EndHour = new int[3];
            //Info.EndMinute = new int[3];

            //Info.TimeFlag[0] = 1;
            //Info.StartHour[0] = 16;
            //Info.StartMinute[0] = 11;
            //Info.EndHour[0] = 16;
            //Info.EndMinute[0] = 12;

            //nResult = LedDll.LV_TimePowerOnOff(ref CommunicationInfo, ref Info);
            LedDll.LV_PowerOnOff(ref CommunicationInfo, 1);
        }

        private void button8_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.44";//给IpStr赋值LED控制卡的IP
            CommunicationInfo.LedNumber = 1;//LED屏号为1,注意socket通讯和232通讯不识别屏号,默认赋1就行了,485必需根据屏的实际屏号进行赋值
            //广播通讯********************************************************************************
            //CommunicationInfo.SendType=1;//设为单机直连,即广播通讯无需设LED控制器的IP地址
            //串口通讯********************************************************************************
            //CommunicationInfo.SendType = 2;//串口通讯
            //CommunicationInfo.Commport = 3;//串口的编号,如设备管理器里显示为 COM3 则此处赋值 3
            //CommunicationInfo.Baud = 57600;//波特率
            //CommunicationInfo.LedNumber = 1;

            int hProgram;//节目句柄
            hProgram = LedDll.LV_CreateProgram(96, 48, 1);//根据传的参数创建节目句柄,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;
            }
            LedDll.AREARECT AreaRect = new LedDll.AREARECT();//区域坐标属性结构体变量
            AreaRect.left = 0;
            AreaRect.top = 0;
            AreaRect.width = 96;
            AreaRect.height = 48;
            LedDll.LV_AddImageTextArea(hProgram, 1, 1, ref AreaRect, 1);

            LedDll.PLAYPROP PlayProp = new LedDll.PLAYPROP();
            PlayProp.InStyle = 0;
            PlayProp.DelayTime = 1;
            PlayProp.Speed = 1;
            LedDll.LV_AddFileToImageTextArea(hProgram, 1, 1, "QQ图片20170913135850.png", ref PlayProp);

            LedDll.FONTPROP FontProp = new LedDll.FONTPROP();//文字属性
            FontProp.FontName = "宋体";
            FontProp.FontSize = 32;
            FontProp.FontColor = LedDll.COLOR_RED;
            FontProp.FontBold = 0;

            AreaRect.left = 3;
            AreaRect.top = 3;
            AreaRect.width = 90;
            AreaRect.height = 42;
            LedDll.LV_AddImageTextArea(hProgram, 1,2, ref AreaRect, 0);
            nResult = LedDll.LV_AddSingleLineTextToImageTextArea(hProgram, 1, 2, LedDll.ADDTYPE_STRING, "12.3", ref FontProp, 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);
                MessageBox.Show(ErrStr);
            }
            else
            {
                //MessageBox.Show("发送成功");
            }
        }

 
    }
}

标签: C# c

实例下载地址

灵信视觉LED控制C#例程

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警