LED显示屏的Dll申明(C#)



using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace LEDScreen
{
    static class ClsLED
    {
        public const int FONT_SET_16 = 0 ;           //16点阵字符
        public const int FONT_SET_24 = 1 ;          //24点阵字符

        public const int PKC_QUERY = 4;
        public const int PKC_ADJUST_TIME = 6;
        public const int PKC_GET_POWER = 9;
        public const int PKC_SET_POWER = 10;
        public const int PKC_GET_BRIGHT = 11;
        public const int PKC_SET_BRIGHT = 12;

        //public const LEDAPI _stdcall;

        public const int DEV_COM = 0;              //串口通讯
        public const int DEV_UDP = 1;             //UDP通讯
        public const int DEV_MODEM = 2;             //Modem通讯

        public const int SBR_9600 = 0;            //串口速率9600
        public const int SBR_14400 = 1;             //14400
        public const int SBR_19200 = 2;             //串口速率19200
        public const int SBR_38400 = 3;             //串口速率38400
        public const int SBR_57600 = 4;             //串口速率57600
        public const int SBR_115200 = 5;             //串口速率115200

        public const int ROOT_PLAY = 0x11;       //下发节目为播放数据
        public const int ROOT_DOWNLOAD = 0x12;        //下发节目为保存并播放

        public const int SCREEN_UNICOLOR = 1;       //单色显示屏
        public const int SCREEN_COLOR = 2;       //双色显示屏
        public const int SCREEN_FULLCOLOR = 3;       //全彩色显示屏
        public const int SCREEN_GRAY = 4;       //256级灰度屏

        public const int LM_RX_COMPLETE = 1;
        public const int LM_TX_COMPLETE = 2;
        public const int LM_RESPOND = 3;
        public const int LM_TIMEOUT = 4;
        public const int LM_NOTIFY = 5;
        public const int LM_PARAM = 6;
        public const int LM_TX_PROGRESS = 7;
        public const int LM_RX_PROGRESS = 8;

        //时间格式定义,用于AddDateTime函数中format参数
        public const int DF_YMD = 1;       //年月日 "2004年12月31日"
        public const int DF_HN = 2;       //时分    "19:20"
        public const int DF_HNS = 3;       //时分秒 "19:20:30"
        public const int DF_Y = 4;       //年      "2004"
        public const int DF_M = 5;       //月      "12" "01" 注意:始终显示两位数字
        public const int DF_D = 6;       //日
        public const int DF_H = 7;       //时
        public const int DF_N = 8;       //分
        public const int DF_S = 9;      //秒
        public const int DF_W = 10;       //星期    "星期三"

        //正计时、倒计时format参数
        public const int CF_DAY = 0;               //天数
        public const int CF_HOUR = 1;               //小时数
        public const int CF_HMS = 2;               //时分秒
        public const int CF_HM = 3;               //时分
        public const int CF_MS = 4;               //分秒
        public const int CF_S = 5;               //秒

        public const int LEM_BUFFER_FULL = 1;        //错误代码:发送缓冲满
        public const int LED_POWER_ON = 1;        //显示屏电源打开
        public const int LED_POWER_OFF = 0;        //显示屏电源已关闭

        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
        public struct DEVICEPARAM
        {
            [MarshalAs(UnmanagedType.I4)]
            public Int32 devType;                   //通讯设备类型
            [MarshalAs(UnmanagedType.I4)]
            public Int32 speed;                     //通讯速度(仅对串行通讯有用)
            [MarshalAs(UnmanagedType.I4)]
            public Int32 ComPort;                   //本地端口(对串行通讯为:串口号;对UDP通讯为:本地端口号,一般要大于1024)
            [MarshalAs(UnmanagedType.I4)]
            public Int32 FlowCon;                   //远程端口号(对UDP通讯有用,必须为6666)\
            [MarshalAs(UnmanagedType.I4)]
            public Int32 locPort;                   //未用
            [MarshalAs(UnmanagedType.I4)]
            public Int32 rmtPort;
            [MarshalAs(UnmanagedType.I4)]
            public Int32 memory;
            [MarshalAs(UnmanagedType.I4,SizeConst = 6)]
            public Int32 Reserved;
        };

        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
        public struct TNotifyMessage
        {
            [MarshalAs(UnmanagedType.I4)]
            public Int32 Message;
            [MarshalAs(UnmanagedType.I4)]
            public Int32 Command;
            [MarshalAs(UnmanagedType.I4)]
            public Int32 Result;
            [MarshalAs(UnmanagedType.I4)]
            public Int32 Status;
            [MarshalAs(UnmanagedType.I4)]
            public Int32 Address;
            [MarshalAs(UnmanagedType.I4)]
            public Int32 Size;
            [MarshalAs(UnmanagedType.I4)]
            public Int32 Buffer;
            public DEVICEPARAM param;
            [MarshalAs(UnmanagedType.U1, SizeConst = 16)]
            public char Host;
            [MarshalAs(UnmanagedType.I4)]
            public Int32 Port;
        }
        public struct rect
        {
            public Int32 left;
            public Int32 top;
            public Int32 right;
            public Int32 bottom;
        };

        public struct TIMESTAMP
        {
          Int32 date;
          long time;
        };
            
        /// <summary>
        /// 初始化LEDSender动态链接库
        /// </summary>
        [DllImport("LEDSender.dll",EntryPoint="LED_Startup",CharSet=CharSet.Ansi)]
        public static extern void LED_Startup();
        /// <summary>
        /// 终止LEDSender动态链接库
        /// </summary>
        [DllImport("LEDSender.dll", EntryPoint = "LED_Cleanup", CharSet = CharSet.Ansi)]
        public static extern void LED_Cleanup();
        /// <summary>
        /// 打开通讯信道
        /// </summary>
        /// <param name="param"></param>
        /// <param name="Notify"></param>
        /// <param name="Window"></param>
        /// <param name="Message"></param>
        /// <returns></returns>
        [DllImport("LEDSender.dll", EntryPoint = "LED_Open", CharSet = CharSet.Ansi)]
        public static extern Int32 LED_Open(ref DEVICEPARAM param, Int32 Notify, Int32 Window, Int32 Message);
        /// <summary>
        /// 关闭通讯信道
        /// </summary>
        /// <param name="dev"></param>
        /// <returns></returns>
        [DllImport("LEDSender.dll", EntryPoint = "LED_Close", CharSet = CharSet.Ansi)]
        public static extern Int32 LED_Close(Int32 dev);
        /// <summary>
        /// 查询显示屏状态
        /// </summary>
        /// <param name="dev"></param>
        /// <param name="Group"></param>
        /// <param name="ScrNo"></param>
        /// <param name="Host"></param>
        /// <param name="port"></param>
        /// <returns></returns>
        [DllImport("LEDSender.dll", EntryPoint = "LED_Query", CharSet = CharSet.Ansi)]
        public static extern Int32 LED_Query(Int32 dev, byte Group, ref char[] Host, Int32 port);
        /// <summary>
        /// 校正显示屏时间
        /// </summary>
        /// <param name="dev"></param>
        /// <param name="Group"></param>
        /// <param name="ScrNo"></param>
        /// <param name="Host"></param>
        /// <param name="port"></param>
        /// <returns></returns>
        [DllImport("LEDSender.dll", EntryPoint = "LED_AdjustTime", CharSet = CharSet.Ansi)]
        public static extern Int32 LED_AdjustTime(Int32 dev, byte Group, byte ScrNo, ref char[] Host, Int32 port);

        /// <summary>
        /// 发送数据到显示屏
        /// </summary>
        /// <param name="dev"></param>
        /// <param name="Group"></param>
        /// <param name="ScrNo"></param>
        /// <param name="Host"></param>
        /// <param name="port"></param>
        /// <returns></returns>
        [DllImport("LEDSender.dll", EntryPoint = "LED_SendToScreen", CharSet = CharSet.Ansi)]
        public static extern Int32 LED_SendToScreen(Int32 dev, Byte Address, string Host, Int32 Port);
        /// <summary>
        /// 设置显示屏电源
        /// </summary>
        /// <param name="dev"></param>
        /// <param name="Group"></param>
        /// <param name="ScrNo"></param>
        /// <param name="Host"></param>
        /// <param name="port"></param>
        /// <param name="Power"></param>
        /// <returns></returns>
        [DllImport("LEDSender.dll", EntryPoint = "LED_SetPower", CharSet = CharSet.Ansi)]
        public static extern Int32 LED_SetPower(Int32 dev, byte Group, byte ScrNo, string Host, Int32 port, Int32 Power);
        /// <summary>
        /// 读取显示屏电源状态
        /// </summary>
        /// <param name="dev"></param>
        /// <param name="Group"></param>
        /// <param name="ScrNo"></param>
        /// <param name="Host"></param>
        /// <param name="port"></param>
        /// <returns></returns>
        [DllImport("LEDSender.dll", EntryPoint = "LED_GetPower", CharSet = CharSet.Ansi)]
        public static extern Int32 LED_GetPower(Int32 dev, byte Group, byte ScrNo, string Host, Int32 port);
        /// <summary>
        /// 调整显示屏亮度
        /// </summary>
        /// <param name="dev"></param>
        /// <param name="Group"></param>
        /// <param name="ScrNo"></param>
        /// <param name="Host"></param>
        /// <param name="port"></param>
        /// <param name="Brightness"></param>
        /// <returns></returns>
        [DllImport("LEDSender.dll", EntryPoint = "LED_SetBrightness", CharSet = CharSet.Ansi)]
        public static extern Int32 LED_SetBrightness(Int32 dev, byte Group, byte ScrNo, ref char[] Host, Int32 port, byte Brightness);
        /// <summary>
        /// 调整显示屏IP地址
        /// </summary>
        /// <param name="dev"></param>
        /// <param name="Group"></param>
        /// <param name="ScrNo"></param>
        /// <param name="Host"></param>
        /// <param name="port"></param>
        /// <param name="NewIP"></param>
        /// <returns></returns>
        [DllImport("LEDSender.dll", EntryPoint = "LED_SetIPAddress", CharSet = CharSet.Ansi)]
        public static extern Int32 LED_SetIPAddress(Int32 dev, byte Group, byte ScrNo, ref char[] Host, Int32 port, ref char[] NewIP);
        /// <summary>
        ///
        /// </summary>
        /// <param name="dev"></param>
        /// <param name="Group"></param>
        /// <param name="ScrNo"></param>
        /// <param name="Host"></param>
        /// <param name="port"></param>
        /// <param name="filename"></param>
        /// <returns></returns>
        [DllImport("LEDSender.dll", EntryPoint = "LED_DownLoadFontSet", CharSet = CharSet.Ansi)]
        public static extern Int32 LED_DownLoadFontSet(Int32 dev, byte Group, byte ScrNo, ref char[] Host, Int32 port, ref char[] filename);
        /// <summary>
        /// 开始形成发送数据
        /// </summary>
        /// <param name="RootType"></param>
        /// <param name="ScreenType"></param>
        /// <returns></returns>
        [DllImport("LEDSender.dll", EntryPoint = "MakeRoot", CharSet = CharSet.Ansi)]
        public static extern Int32 MakeRoot(Int32 RootType, Int32 ScreenType);
        /// <summary>
        /// 追加显示页面
        /// </summary>
        /// <param name="DisplayTime"></param>
        /// <returns></returns>
        [DllImport("LEDSender.dll", EntryPoint = "AddLeaf", CharSet = CharSet.Ansi)]
        public static extern Int32 AddLeaf(Int32 DisplayTime);

        /// <summary>
        ///
        /// </summary>
        /// <param name="rect1"></param>
        /// <param name="left"></param>
        /// <param name="top"></param>
        /// <param name="right"></param>
        /// <param name="bottom"></param>
        [DllImport("user32.dll", EntryPoint = "SetRect", CharSet = CharSet.Ansi)]
        public static extern void SetRect(ref rect rect1, Int32 left, Int32 top, Int32 right, Int32 bottom);

        /// <summary>
        ///
        /// </summary>
        /// <param name="dc"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="rect"></param>
        /// <param name="method"></param>
        /// <param name="speed"></param>
        /// <param name="transparent"></param>
        /// <returns></returns>
        [DllImport("LEDSender.dll", EntryPoint = "LED_GetNotifyMessage", CharSet = CharSet.Ansi)]
        public static extern Int32 LED_GetNotifyMessage(ref TNotifyMessage Notify);

        /// <summary>
        /// 追加时间显示
        /// </summary>
        /// <param name="rect"></param>
        /// <param name="transparent"></param>
        /// <param name="fontname"></param>
        /// <param name="fontsize"></param>
        /// <param name="fontcolor"></param>
        /// <param name="format"></param>
        /// <returns></returns>
        //[DllImport("LEDSender.dll", EntryPoint = "AddDateTime", CharSet = CharSet.Ansi)]
        //public extern Int32 AddDateTime(LPRECT rect, Int32 transparent, ref char[] fontname, Int32 fontsize, Int32 fontcolor, Int32 format);
        /// <summary>
        /// 显示内码汉字
        /// </summary>
        /// <param name="str"></param>
        /// <param name="rect"></param>
        /// <param name="method"></param>
        /// <param name="speed"></param>
        /// <param name="transparent"></param>
        /// <param name="fontset"></param>
        /// <param name="fontcolor"></param>
        /// <returns></returns>
        [DllImport("LEDSender.dll", EntryPoint = "AddString", CharSet = CharSet.Ansi)]
        public static extern Int32 AddString(string str, ref rect rect1, Int32 method, Int32 speed, Int32 transparent, Int32 fontset, Int32 fontcolor);

        //[DllImport("LEDSender.dll", EntryPoint = "AddText", CharSet = CharSet.Ansi)]
        //public extern Int32 AddText(ref char[] str, LPRECT rect, Int32 method, Int32 speed, Int32 transparent, ref char[] fontname, Int32 fontsize, Int32 fontcolor);
        /// <summary>
        /// 加动画显示区域(只有256级灰度和全彩色才可显示动画)
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="rect"></param>
        /// <param name="stretch"></param>
        /// <returns></returns>
        //[DllImport("LEDSender.dll", EntryPoint = "AddMovie", CharSet = CharSet.Ansi)]
        //public extern Int32 AddMovie(ref char[] filename, LPRECT rect, Int32 stretch);
        /// <summary>
        /// 追加正计时显示区域
        /// </summary>
        /// <param name="rect"></param>
        /// <param name="transparent"></param>
        /// <param name="fontname"></param>
        /// <param name="fontsize"></param>
        /// <param name="fontcolor"></param>
        /// <param name="format"></param>
        /// <param name="starttime"></param>
        /// <returns></returns>
        //[DllImport("LEDSender.dll", EntryPoint = "AddCountUp", CharSet = CharSet.Ansi)]
        //public extern Int32 AddCountUp(LPRECT rect, Int32 transparent, ref char[] fontname, Int32 fontsize, Int32 fontcolor, Int32 format, LPSYSTEMTIME starttime);
        /// <summary>
        /// 追加倒计时显示区域
        /// </summary>
        /// <param name="rect"></param>
        /// <param name="transparent"></param>
        /// <param name="fontname"></param>
        /// <param name="fontsize"></param>
        /// <param name="fontcolor"></param>
        /// <param name="format"></param>
        /// <param name="endtime"></param>
        /// <returns></returns>
        //[DllImport("LEDSender.dll", EntryPoint = "AddCountDown", CharSet = CharSet.Ansi)]
        //public extern Int32 AddCountDown(LPRECT rect, Int32 transparent, ref char[] fontname, Int32 fontsize, Int32 fontcolor, long format, LPSYSTEMTIME endtime);

    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值