示例#1
0
        public void OpenDevice1()
        {
            int nResult;

            LedDll.COMMUNICATIONINFO CommunicationInfo = new LedDll.COMMUNICATIONINFO(); //定义一通讯参数结构体变量用于对设定的LED通讯,具体对此结构体元素赋值说明见COMMUNICATIONINFO结构体定义部份注示
                                                                                         //ZeroMemory(&CommunicationInfo,sizeof(COMMUNICATIONINFO));
                                                                                         //TCP通讯********************************************************************************
            CommunicationInfo.SendType  = 0;                                             //设为固定IP通讯模式,即TCP通讯
            CommunicationInfo.IpStr     = ip1;                                           //给IpStr赋值LED控制卡的IP
            CommunicationInfo.LedNumber = LedNumber1;                                    //LED屏号为1,注意socket通讯和232通讯不识别屏号,默认赋1就行了,485必需根据屏的实际屏号进行赋值



            nResult = LedDll.LV_SetBasicInfoEx(ref CommunicationInfo, ColorType1, GrayLevel1, LedWidth1, LedHeight1); //设置屏参,屏的颜色为2即为双基色,64为屏宽点数,32为屏高点数,具体函数参数说明见函数声明注示
            if (nResult != 0)                                                                                         //如果失败则可以调用LV_GetError获取中文错误信息
            {
                string ErrStr;
                ErrStr = LedDll.LS_GetError(nResult);
                Log.myLog.Info("入厂LED,设置失败!");
                MessageBox.Show(ErrStr);
            }
            else
            {
                Log.myLog.Info("入厂LED,设置成功");
                // MessageBox.Show("设置成功");
            }



            Console.WriteLine(LedWidth1 + "*" + LedHeight1);
        }
示例#2
0
        public void AdjustTime()
        {
            int nResult;

            LedDll.COMMUNICATIONINFO CommunicationInfo = new LedDll.COMMUNICATIONINFO(); //定义一通讯参数结构体变量用于对设定的LED通讯,具体对此结构体元素赋值说明见COMMUNICATIONINFO结构体定义部份注示
                                                                                         //ZeroMemory(&CommunicationInfo,sizeof(COMMUNICATIONINFO));
                                                                                         //TCP通讯********************************************************************************
            CommunicationInfo.SendType  = 0;                                             //设为固定IP通讯模式,即TCP通讯
            CommunicationInfo.IpStr     = ip1;                                           //给IpStr赋值LED控制卡的IP
            CommunicationInfo.LedNumber = LedNumber1;                                    //LED屏号为1,注意socket通讯和232通讯不识别屏号,默认赋1就行了,485必需根据屏的实际屏号进行赋值

            nResult = LedDll.LV_AdjustTime(ref CommunicationInfo);
            if (nResult != 0)//如果失败则可以调用LV_GetError获取中文错误信息
            {
                string ErrStr;
                ErrStr = LedDll.LS_GetError(nResult);
                Log.myLog.Info("LED1 校时失败!");
                MessageBox.Show("LED1 校时失败! err = " + ErrStr);
            }
            else
            {
                Log.myLog.Info("LED1 校时成功");
            }


            CommunicationInfo.SendType  = 0;          //设为固定IP通讯模式,即TCP通讯
            CommunicationInfo.IpStr     = ip2;        //给IpStr赋值LED控制卡的IP
            CommunicationInfo.LedNumber = LedNumber2; //LED屏号为1,注意socket通讯和232通讯不识别屏号,默认赋1就行了,485必需根据屏的实际屏号进行赋值

            nResult = LedDll.LV_AdjustTime(ref CommunicationInfo);
            if (nResult != 0)//如果失败则可以调用LV_GetError获取中文错误信息
            {
                string ErrStr;
                ErrStr = LedDll.LS_GetError(nResult);
                Log.myLog.Info("LED2 校时失败!");
                MessageBox.Show("LED2 校时失败! err = " + ErrStr);
            }
            else
            {
                Log.myLog.Info("LED2 校时成功");
            }
        }
示例#3
0
        public void TestLEDTextUpdate2(string chepai, string weight)
        {
            double w;

            if (double.TryParse(weight, out w))
            {
                w = w / 1000;
            }
            else
            {
                w = 0;
            }

            weight = "称重:" + w + "吨";

            int nResult;

            LedDll.COMMUNICATIONINFO CommunicationInfo = new LedDll.COMMUNICATIONINFO(); //定义一通讯参数结构体变量用于对设定的LED通讯,具体对此结构体元素赋值说明见COMMUNICATIONINFO结构体定义部份注示
                                                                                         //ZeroMemory(&CommunicationInfo,sizeof(COMMUNICATIONINFO));
                                                                                         //TCP通讯********************************************************************************

            CommunicationInfo.SendType  = 0;                                             //设为固定IP通讯模式,即TCP通讯
            CommunicationInfo.IpStr     = ip2;                                           //给IpStr赋值LED控制卡的IP
            CommunicationInfo.LedNumber = LedNumber2;                                    //LED屏号为1,注意socket通讯和232通讯不识别屏号,默认赋1就行了,485必需根据屏的实际屏号进行赋值


            int hProgram = 0;                                                                       //节目句柄

            hProgram = LedDll.LV_CreateProgramEx(LedWidth2, LedHeight2, ColorType2, GrayLevel2, 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);
                Console.WriteLine(ErrStr);
                return;
            }

            #region chepai
            LedDll.AREARECT AreaRect = new LedDll.AREARECT();//区域坐标属性结构体变量
            AreaRect.left   = 0;
            AreaRect.top    = 25;
            AreaRect.width  = 120;
            AreaRect.height = 25;

            LedDll.FONTPROP FontProp = new LedDll.FONTPROP();//文字属性
            FontProp.FontName  = "宋体";
            FontProp.FontSize  = 12;
            FontProp.FontColor = LedDll.COLOR_YELLOW;
            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_AddImageTextArea(hProgram, 1, 1, ref AreaRect, 0);
            if (nResult != 0)
            {
                string ErrStr;
                ErrStr = LedDll.LS_GetError(nResult);
                Console.WriteLine(ErrStr);
                return;
            }
            //nResult = LedDll.LV_QuickAddSingleLineTextArea(hProgram, 1, 1, ref AreaRect, LedDll.ADDTYPE_FILE, "test.txt", ref FontProp, 4);//快速通过txt文件添加一个单行文本区域,函数见函数声明注示
            nResult = LedDll.LV_AddStaticTextToImageTextArea(hProgram, 1, 1, LedDll.ADDTYPE_STRING, chepai, ref FontProp, 1, 2, 1);
            if (nResult != 0)
            {
                string ErrStr;
                ErrStr = LedDll.LS_GetError(nResult);
                Console.WriteLine(ErrStr);
                return;
            }
            //
            #endregion
            #region weight
            AreaRect.left   = 0;
            AreaRect.top    = 50;
            AreaRect.width  = 120;
            AreaRect.height = 30;


            FontProp.FontName  = "宋体";
            FontProp.FontSize  = 10;
            FontProp.FontColor = LedDll.COLOR_YELLOW;
            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_AddImageTextArea(hProgram, 1, 2, ref AreaRect, 0);
            if (nResult != 0)
            {
                string ErrStr;
                ErrStr = LedDll.LS_GetError(nResult);
                Console.WriteLine(ErrStr);
                return;
            }
            //nResult = LedDll.LV_QuickAddSingleLineTextArea(hProgram, 1, 1, ref AreaRect, LedDll.ADDTYPE_FILE, "test.txt", ref FontProp, 4);//快速通过txt文件添加一个单行文本区域,函数见函数声明注示
            nResult = LedDll.LV_AddStaticTextToImageTextArea(hProgram, 1, 2, LedDll.ADDTYPE_STRING, weight, ref FontProp, 1, 2, 1);
            if (nResult != 0)
            {
                string ErrStr;
                ErrStr = LedDll.LS_GetError(nResult);
                Console.WriteLine(ErrStr);
                return;
            }

            #endregion
            //
            #region 日期
            AreaRect.left   = 0;
            AreaRect.top    = 0;
            AreaRect.width  = 120;
            AreaRect.height = 25;
            LedDll.DIGITALCLOCKAREAINFO DigitalClockAreaInfo = new LedDll.DIGITALCLOCKAREAINFO();
            DigitalClockAreaInfo.TimeColor            = LedDll.COLOR_RED;
            DigitalClockAreaInfo.DateColor            = LedDll.COLOR_RED;
            DigitalClockAreaInfo.ShowStrFont.FontName = "宋体";
            DigitalClockAreaInfo.ShowStrFont.FontSize = 8;
            // DigitalClockAreaInfo.ShowStr = DateTime.Now.ToString("yy-MM-dd HH:mm:ss");

            DigitalClockAreaInfo.IsShowYear   = 1;
            DigitalClockAreaInfo.IsShowMonth  = 1;
            DigitalClockAreaInfo.IsShowDay    = 1;
            DigitalClockAreaInfo.IsShowHour   = 1;
            DigitalClockAreaInfo.IsShowMinute = 1;
            // DigitalClockAreaInfo.IsShowSecond = 1;
            DigitalClockAreaInfo.DateFormat = 4;
            DigitalClockAreaInfo.TimeFormat = 2;

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


            //AreaRect.left = 0;
            //AreaRect.top = 0;
            //AreaRect.width = 120;
            //AreaRect.height = 25;


            //FontProp.FontName = "宋体";
            //FontProp.FontSize = 10;
            //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);//快速通过字符添加一个单行文本区域,函数见函数声明注示
            //// nResult = LedDll.LV_QuickAddSingleLineTextArea(hProgram, 1, 1, ref AreaRect, LedDll.ADDTYPE_FILE, "test.rtf", ref FontProp, 4);//快速通过rtf文件添加一个单行文本区域,函数见函数声明注示
            //nResult = LedDll.LV_AddImageTextArea(hProgram, 1, 3, ref AreaRect, 0);
            //if (nResult != 0)
            //{
            //    string ErrStr;
            //    ErrStr = LedDll.LS_GetError(nResult);
            //    Console.WriteLine(ErrStr);
            //    return;
            //}
            //string t = DateTime.Now.ToString("D");
            ////nResult = LedDll.LV_QuickAddSingleLineTextArea(hProgram, 1, 1, ref AreaRect, LedDll.ADDTYPE_FILE, "test.txt", ref FontProp, 4);//快速通过txt文件添加一个单行文本区域,函数见函数声明注示
            //nResult = LedDll.LV_AddStaticTextToImageTextArea(hProgram, 1, 3, LedDll.ADDTYPE_STRING, t, ref FontProp, 1, 2, 1);
            //if (nResult != 0)
            //{
            //    string ErrStr;
            //    ErrStr = LedDll.LS_GetError(nResult);
            //    Console.WriteLine(ErrStr);
            //    return;
            //}


            #endregion

            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("发送成功");
            }
        }