liudl
2025-02-16 7ab32aab1cfd8b71940ade95fa69aec0b95e95c3
Admin.NET/WCS.Application/Util/LedDll.cs
@@ -988,6 +988,96 @@
    }
    /// <summary>
    /// LED显示
    /// </summary>
    /// <param name="m_Ip">LED屏幕IP地址</param>
    /// <param name="m_text">显示内容</param>
    public void ConsoleLeds(string m_Ip, string m_text)
    {
        m_ledWidth = 256;
        m_ledHeight = 160;
        m_ledColor = 1;
        m_ledGrayLevel = 0;
        try
        {
            Logger logger = LogManager.GetCurrentClassLogger();
            int nResult;
            LedDll.COMMUNICATIONINFO CommunicationInfo = new LedDll.COMMUNICATIONINFO();
            CommunicationInfo.LEDType = 0;
            //TCP通讯********************************************************************************
            CommunicationInfo.SendType = 0;                                                     // 设为固定IP通讯模式,即TCP通讯
            CommunicationInfo.IpStr = m_Ip;                                                     // 给IpStr赋值LED控制卡的IP
            CommunicationInfo.LedNumber = 1;                                                    // LED屏号为1,注意socket通讯和232通讯不识别屏号,默认赋1就行了,485必需根据屏的实际屏号进行赋值
            #region 创建一个节目
            IntPtr hProgram;                                                                    // 节目句柄
                                                                                                //注意此处屏宽高及颜色参数必需与设置屏参的屏宽高及颜色一致,否则发送时会提示错误
            hProgram = LedDll.LV_CreateProgramEx(m_ledWidth, m_ledHeight, m_ledColor, m_ledGrayLevel, 0);
            nResult = LedDll.LV_AddProgram(hProgram, 0, 0, 1);                                  // 添加一个节目,参数说明见函数声明注示
            if (nResult != 0)
            {
                string ErrStr = LedDll.LS_GetError(nResult);                                           // liudl  此处需记录Log
                throw new Exception(ErrStr);
            }
            #endregion
            #region 创建区域
            // 区域范围变量 参数设定
            LedDll.AREARECT AreaRect = new LedDll.AREARECT();//区域坐标属性结构体变量
            AreaRect.left = 0;
            AreaRect.top = 0;
            AreaRect.width = m_ledWidth;
            AreaRect.height = m_ledHeight;
            LedDll.LV_AddImageTextArea(hProgram, 0, 2, ref AreaRect, 1);
            // 区域字体变量 参数设定
            LedDll.FONTPROP FontProp = new LedDll.FONTPROP();//文字属性
            FontProp.FontName = "宋体";
            FontProp.FontSize = 16;
            FontProp.FontColor = LedDll.COLOR_RED;
            FontProp.FontBold = 1;
            // 区域字体运行速度 带入方式
            LedDll.PLAYPROP PlayProp = new LedDll.PLAYPROP();
            PlayProp.InStyle = 0;
            PlayProp.DelayTime = 3;
            PlayProp.Speed = 2;
            // 多文本区域 用于显示托盘信息
            nResult = LedDll.LV_AddMultiLineTextToImageTextArea(hProgram, 0, 2, LedDll.ADDTYPE_STRING, m_text, ref FontProp, ref PlayProp, 0, 1);
            // 发送到LED屏幕
            nResult = LedDll.LV_Send(ref CommunicationInfo, hProgram);
            LedDll.LV_DeleteProgram(hProgram);
            #endregion
            if (nResult != 0)
            {
                string ErrStr;
                ErrStr = LedDll.LS_GetError(nResult);               // liudl 此处需要添加log
                logger.Error("返回错误信息A04:", ErrStr);
            }
        }
        catch (Exception ex)
        {
            // 不抛出异常,防止阻碍主程序运行; Liudl:此处需添加log
            //throw ex;
            Logger logger = LogManager.GetCurrentClassLogger();
            logger.Error("测试trycatch捕捉的信息:", ex.Message);
        }
    }
    /// <summary>
    /// 发送给LED 单独更新字幕区域
    /// </summary>
    /// <param name="m_ip">LED屏幕IP地址</param>