SCLS/SSWCS_JXDL(2019)/ControlSystem/LedDll.cs

1097 lines
65 KiB
C#
Raw Normal View History

2025-05-19 09:45:29 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace RFIDReaderJilin.Common
{
public class LedDll
{
//颜色值 R 0x0000ff G 0x00ff00 B 0xff0000
public const int COLOR_RED = 0xff; //红色
public const int COLOR_GREEN = 0xff00; //绿色
public const int COLOR_YELLOW = 0xffff; //黄色
public const int ADDTYPE_STRING = 0; //添加类型为字符串
public const int ADDTYPE_FILE = 1; //添加类型为文件
public const int OK = 0;//函数返回成功
//******节目定时启用日期时间星期的标志宏***************************************************************************
public const int ENABLE_DATE = 0x01;
public const int ENABLE_TIME = 0x02;
public const int ENABLE_WEEK = 0x04;
//*****************************************************************************************************************
//******节目定时星期里某天启用宏***********************************************************
public const int WEEK_MON = 0x01;
public const int WEEK_TUES = 0x02;
public const int WEEK_WEN = 0x04;
public const int WEEK_THUR = 0x08;
public const int WEEK_FRI = 0x10;
public const int WEEK_SAT = 0x20;
public const int WEEK_SUN = 0x40;
//*****************************************************************************
//[StructLayout(LayoutKind.Sequential, Size = 8, CharSet = CharSet.Unicode, Pack = 1)]
//**通讯设置结构体*********************************************************
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct COMMUNICATIONINFO
{
public int LEDType; ////LED类型 0.6代T系A系XC系 1.6代E系 2.X1X2 3.7代C系
public int SendType; //通讯方式 0.为Tcp发送又称固定IP通讯, 1.广播发送(又称单机直连) 2.串口通讯 3.磁盘保存 4.广域网通讯
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)]
public string IpStr; //LED屏的IP地址只有通讯方式为0时才需赋值其它通讯方式无需赋值
public int Commport; //串口号只有通讯方式为2时才需赋值其它通讯方式无需赋值
public int Baud; //波特率只有通讯方式为2时才需赋值其它通讯方式无需赋值, 0.9600 1.57600 2.115200 直接赋值 9600192003840057600115200亦可
public int LedNumber; //LED的屏号只有通讯方式为2时且用485通讯时才需赋值其它通讯方式无需赋值
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
public string OutputDir; //磁盘保存的目录只有通讯方式为3时才需赋值其它通讯方式无需赋值
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 19)]
public string networkIdStr; //网络ID只有通讯方式为4时才需赋值其它通讯方式无需赋值
};
//***********************************************************************
//**区域坐标结构体*********************************************************
public struct AREARECT
{
public int left; //区域左上角横坐标
public int top; //区域左上角纵坐标
public int width; //区域的宽度
public int height; //区域的高度
};
//****************************************************************************
//***字体属性结构对**********************************************************
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct FONTPROP
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
public string FontName; //字体名
public int FontSize; //字号(单位磅)
public int FontColor; //字体颜色
public int FontBold; //是否加粗
public int FontItalic; //是否斜体
public int FontUnderLine; //时否下划线
};
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct QRAREAINFO
{
public int nLowVersion;//QR的最低版本,0~39
public int nHighVersion;//QR的最高版本,0~39,一般都是固定成39
public int nErrorCorrectionLevel;//纠错等级0:自适应 1:L 2:M 3:Q 4:H
public int nMaskVersion;//掩膜版本 0xff 自适应 0~7 手动选择
public int nBlankPointNum;//QR 码周边空白的点数,默认为 4一般这个值要大于等于 4当屏幕点数很紧张时且不够 4 的时候可选择 0表示区域内周边全做空白处理
public int nBaseCodeColor;//QR 码底颜色一般要求是白底白底识别率会高也可以设置为其他色0---红色1---绿色2---黄色3---蓝色4---紫色RB 组合5---青色GB 组合6---白色
public int isColorReverse;//QR 码颜色是否翻转0---不翻转1---翻转
public int nDefaultShow;//默认显示状态0---黑屏1---显示默认码
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 512)]
public string strDefaultCode;//默认码,字符长度不能超过512字节)
};
//****************************************************************************
//**页面显示的属性结构体****************************************************
public struct PLAYPROP
{
public int InStyle; //入场特技值(取值范围 0-38
public int OutStyle; //退场特技值现无效预留置0
public int Speed; //特技显示速度(取值范围1-255) 值越大,速度越慢
public int DelayTime; //页面留停时间(1-65535) 注:当入场特技为连续左移、连续右移、连续上移、连续下移时,此参数无效
};
/*
0=
1=
2=
3=
4=
5=
6=
7=
8=
9=
10=
11=()
12=()
13=()
14=()
15=
16=
17=
18=
19=
20=
21=
22=
23=()
24=()
25=()
26=()
27=
28=
29=
30=
31=
32=
33=
34=
35=
36=
37=
38=
*/
//*******************************************************************************
//**设置节目定时属性结构体****************************************************
public struct PROGRAMTIME
{
public int EnableFlag; //启用定时的标记ENABLE_DATE为启用日期,ENABLE_TIME为启用时间,ENABLE_WEEK为启用星期,可用或运算进行组合,如 ENABLE_DATE | ENABLE_TIME | ENABLE_WEEK
public int WeekValue; //启用星期后,选择要定时的星期里的某些天,用宏 WEEK_MON,WEEK_TUES,WEEK_WEN,WEEK_THUR,WEEK_FRI,WEEK_SAT,WEEK_SUN 通过或运算进行组合
public int StartYear; //起始年
public int StartMonth; //起始月
public int StartDay; //起始日
public int StartHour; //起姐时
public int StartMinute; //起始分
public int StartSecond; //起始秒
public int EndYear; //结束年
public int EndMonth; //结束月
public int EndDay; //结束日
public int EndHour; //结束时
public int EndMinute; //结束分
public int EndSecond; //结束秒
};
//**********************************************************************************
//数字时钟属性结构体*********************************************************************************
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DIGITALCLOCKAREAINFO
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
public string ShowStr; //自定义显示字符串
//[MarshalAs(UnmanagedType.Struct)]
public FONTPROP ShowStrFont; //自定义显示字符串以及日期星期时间的字体属性注意此字体属性里的FontColor只对自定义显示字体有效其它项的颜色有单独的颜色属性属性的赋值见FONTPROP结构体说明
public int TimeLagType; //时差类型 0为超前1为滞后
public int HourNum; //时差小时数
public int MiniteNum; //时差分钟数
public int DateFormat; //日期格式 0.YYYY年MM月DD日 1.YY年MM月DD日 2.MM/DD/YYYY 3.YYYY/MM/DD 4.YYYY-MM-DD 5.YYYY.MM.DD 6.MM.DD.YYYY 7.DD.MM.YYYY
public int DateColor; //日期字体颜色 格式是16进制 BBGGRR红色0xff 绿色0xff00 黄色0xffff
public int WeekFormat; //星期格式 0.星期X 1.Monday 2.Mon.
public int WeekColor; //星期字体颜色
public int TimeFormat; //时间格式 0.HH时mm分ss秒 1.HH時mm分ss秒 2.HH:mm:ss 3.上午 HH:mm:ss 4.AM HH:mm:ss 5.HH:mm:ss 上午 6.HH:mm:ss AM
public int TimeColor; //时间字体颜色
public int IsShowYear; //是否显示年 TRUE为显示 FALSE不显示 下同
public int IsShowWeek; //是否显示星期
public int IsShowMonth; //是否显示月
public int IsShowDay; //是否显示日
public int IsShowHour; //是否显示时
public int IsShowMinute; //是否显示分
public int IsShowSecond; //是否显示秒
public int IsMutleLineShow; //是否多行显示
};
//******************************************************************************
//**模拟时钟属性结构体*********************************************************
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CLOCKAREAINFO
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]
public string ShowStr; //自定义显示字符串
public FONTPROP ShowStrFont; //自定义显示字符串字体属性
public int TimeLagType; //时差类型 0为超前1为滞后
public int HourNum; //时差小时数
public int MiniteNum; //时差分钟数
public int ClockType; //表盘类型 0.圆形 1.正方形
public int HourMarkColor; //时标颜色 格式是16进制 BBGGRR红色0xff 绿色0xff00 黄色0xffff
public int HourMarkType; //时标类型 0.圆形 1.正方形
public int HourMarkWidth; //时标宽度 1~16
public int MiniteMarkColor; //分标颜色
public int MiniteMarkType; //分标类型 0.圆形 1.正方形
public int MiniteMarkWidth; //分标宽度 1~16
public int HourPointerColor; //时针颜色
public int MinutePointerColor; //分针颜色
public int SecondPointerColor; //秒针颜色
public int HourPointerWidth; //时针的宽度 1~5
public int MinutePointerWidth; //分针的宽度 1~5
public int SecondPointerWidth; //秒针的宽度 1~5
public int IsShowDate; //是否显示日期
public int DateFormat; //日期格式 0.YYYY年MM月DD日 1.YY年MM月DD日 2.MM/DD/YYYY 3.YYYY/MM/DD 4.YYYY-MM-DD 5.YYYY.MM.DD 6.MM.DD.YYYY 7.DD.MM.YYYY
public FONTPROP DateFont; //日期字体属性
public int IsShowWeek; //是否显示星期
public int WeekFormat; //星期格式 0.星期X 1.Monday 2.Mon.
public FONTPROP WeekFont; //星期字体属性
};
//**************************************************************************************
//**计时属性结构体**********************************************************************
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct TIMEAREAINFO
{
public int ShowFormat; //显示格式 0.xx天xx时xx分xx秒 1.xx天xx時xx分xx秒 2.xxDayxxHourxxMinxxSec 3.XXdXXhXXmXXs 4.xx:xx:xx:xx
public int nYear; //结束年
public int nMonth; //结束月
public int nDay; //结束日
public int nHour; //结束时
public int nMinute; //结束分
public int nSecond; //结束秒
public int IsShowDay; //是否显示天
public int IsShowHour; //是否显示时
public int IsShowMinute; //是否显示分
public int IsShowSecond; //是否显示秒
public int IsMutleLineShow; //是否多行显示,指的是自定义文字与计时文字是否分行显示
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
public string ShowStr; //自定义文字字符串
public int TimeStrColor; //计时文字的颜色
public FONTPROP ShowFont; //自定义文字及计时文字颜色其中FontColor只对文定义文字有效计时文字颜色为TimeStrColor
};
//****************************************************************************************
//**LED通讯参数修改结构体*****************************************************************
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct LEDCOMMUNICATIONPARAMETER
{
public int dwMask; //要修改项的标记 0.修改网络通讯参数 1.修改串口通讯参数 2.修改网口和串口通讯参数
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)]
public string IpStr; //新的IP地址只有dwMask为0或2时才需赋值其它值无需赋值格式例如 192.168.1.100
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)]
public string NetMaskStr; //新的子网掩码只有dwMask为0或2时才需赋值其它值无需赋值格式例如 255.255.255.0
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)]
public string GatewayStr; //新的网关只有dwMask为0或2时才需赋值其它值无需赋值,格式例如 192.168.1.1
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 18)]
public string MacStr; //新的MAC地址只有dwMask为0或2时才需赋值其它值无需赋值格式例如 12-34-56-78-9a-bc,如无需修改请设为 ff-ff-ff-ff-ff-ff
public int Baud; //波特率只有dwMask为1或2时才需赋值其它值无需赋值0.9600 1.57600 2.115200
public int LedNumber; //LED屏号 1~255,网络通讯和232通讯赋值 1 即可485必需和控制卡显示的屏号相同才可通讯
};
//*****************************************************************************************
//**流水边框属性结构体************************************************************************
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WATERBORDERINFO
{
public int Flag; //流水边框加载类型标志0.为动态库预置的边框 1.为从文件加载的边框
public int BorderType; //边框的类型Flag为0是有效0.单色边框 1.双基色边框 2.全彩边框
public int BorderValue; //边框的值Flag为0是有效单色边框取值范围是0~39,双基色边框取值范围是0~34,全彩边框取值范围是0~21
public int BorderColor; //边框线颜色,Flag为0并且BorderType为0是才有效
public int BorderStyle; //边框显示的样式 0.固定 1.顺时针 2.逆时针 3.闪烁
public int BorderSpeed;//边框流动的速度
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
public string WaterBorderBmpPath; //Flag 为1才有效, 边框图片文件的路径注意只能是bmp图片图片大小必需是宽度为32点取高度小于等于8
};
//*********************************************************************************************
//**定时开关屏设置属性************************************************************************
public struct ONOFFTIMEINFO
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public int[] TimeFlag; //支持3个定时1代表打开 0关闭
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public int[] StartHour; //开始时钟
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public int[] StartMinute; //开始分钟
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public int[] EndHour; //结束时钟
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public int[] EndMinute; //结束分钟
};
//********************************************************************************************
//**定时亮度设置属性**************************************************************************
public struct BRIGHTNESSTIMEINFO
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public int[] TimeFlag; //支持3个定时1代表打开 0关闭
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public int[] StartHour; //开始时钟
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public int[] StartMinute; //开始分钟
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public int[] EndHour; //结束时钟
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public int[] EndMinute; //结束分钟
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public int[] BrightnessValue; //亮度值0~15
};
//*******************************************************************************************
[UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
public delegate int SERVERINFOCALLBACK(int Msg, int wParam, IntPtr ptr);
public enum LV_MSG
{
LV_MSG_NONE,
LV_MSG_CARD_ONLINE,//上线通知通过CARD_INFO结构体指针获取详细上线信息
LV_MSG_CARD_OFFLINE,//下线通知通过CARD_INFO结构体指针获取详细下线信息
};
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CARD_INFO
{
public int port; //控制卡端口
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)]
public string ipStr; //控制卡IP
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 19)]
public string networkIdStr; //控制卡唯一网络ID每张卡都贴有唯一网络ID
};
/********************************************************************************************
* LV_InitLed (C卡)
* Led上显示的文字区域的颜色与下发的不一致, Led RGB顺序,
*
* nLedType
* 0.6T系A系XC系
* 1.6E系列
* 2.X1X2系列
* 3.7C系列(C2M,C4M)
* 4: E5,E6,C8
* nRgb RGB顺序,C卡有效,0. C卡时, 0: R->G->B 1: G->R->B 2:R->B->G 3:B->R->G 4:B->G->R 5:G->B->R
*
*
********************************************************************************************/
[DllImport("lv_led.dll", EntryPoint = "LV_InitLed", CharSet = CharSet.Unicode)]
public static extern void LV_InitLed(int nLedType, int nRgb);
/********************************************************************************************
* LV_CreateProgramEx HPROGRAM
*
*
* LedWidth
* LedHeight
* ColorType 1. 2. 3. C卡全彩参数为3 X系列卡参数固定为 4
* GrayLevel 1-5 ,4,8,16,32 C系列的卡才支持T,A,U,XC,W,E,X0
* SaveType 0flash节目3ram节目
* flash节目掉电不清除ram节目掉电清除ram节目, C卡程序才支持切换,
* flash程序,RAM程序请联系业务或者在官网下载,使Led Player对卡进行升级
*
* 0
* 0
********************************************************************************************/
[DllImport("lv_led.dll", EntryPoint = "LV_CreateProgramEx", CharSet = CharSet.Unicode)]
public static extern IntPtr LV_CreateProgramEx(int LedWidth, int LedHeight, int ColorType, int GrayLevel, int SaveType);
/*********************************************************************************************
* LV_AddProgram
*
*
* hProgram
* ProgramNo 0-255)0
* ProgramTime 0. 0.
* LoopCount 1-255
*
* 0
* 0 LV_GetError来获取错误信息
********************************************************************************************/
[DllImport("lv_led.dll", EntryPoint = "LV_AddProgram", CharSet = CharSet.Unicode)]
public static extern int LV_AddProgram(IntPtr hProgram, int ProgramNo, int ProgramTime, int LoopCount);
/*********************************************************************************************
* LV_SetProgramTime
*
*
* hProgram
* ProgramNo 0-255)0
* pProgramTime PROGRAMTIME结构体注示
*
* 0
* 0 LV_GetError来获取错误信息
********************************************************************************************/
[DllImport("lv_led.dll", EntryPoint = "LV_SetProgramTime", CharSet = CharSet.Unicode)]
public static extern int LV_SetProgramTime(IntPtr hProgram, int ProgramNo, ref PROGRAMTIME pProgramTime);
/*********************************************************************************************
* LV_AddImageTextArea
*
*
* hProgram
* ProgramNo 0-255)0
* AreaNo 1-255
* pAreaRect AREARECT结构体注示
* nLayout 1. 0. C系列1
*
* 0
* 0 LV_GetError来获取错误信息
********************************************************************************************/
[DllImport("lv_led.dll", EntryPoint = "LV_AddImageTextArea", CharSet = CharSet.Unicode)]
public static extern int LV_AddImageTextArea(IntPtr hProgram, int ProgramNo, int AreaNo, ref AREARECT pAreaRect, int nLayout);
/*********************************************************************************************
* LV_AddFileToImageTextArea
*
*
* hProgram
* ProgramNo 0-255)0
* AreaNo 1-255
* FilePath txt rtf bmp gif png jpg jpeg tiff
* pPlayProp PLAYPROP结构体注示
*
* 0
* 0 LV_GetError来获取错误信息
********************************************************************************************/
[DllImport("lv_led.dll", EntryPoint = "LV_AddFileToImageTextArea", CharSet = CharSet.Unicode)]
public static extern int LV_AddFileToImageTextArea(IntPtr hProgram, int ProgramNo, int AreaNo, string FilePath, ref PLAYPROP pPlayProp);
/*********************************************************************************************
* LV_AddSingleLineTextToImageTextArea
*
*
* hProgram
* ProgramNo 0-255)0
* AreaNo 1-255
* AddType 0. 1.txt和rtf文件
* AddStr AddType为0则为字符串数据,AddType为1则为文件路径
* pFontProp AddType为字符串类型或AddType为文件类型且文件为txt则可传入以赋值的该结构体NULL
* pPlayProp PLAYPROP结构体注示
*
* 0
* 0 LV_GetError来获取错误信息
********************************************************************************************/
[DllImport("lv_led.dll", EntryPoint = "LV_AddSingleLineTextToImageTextArea", CharSet = CharSet.Unicode)]
public static extern int LV_AddSingleLineTextToImageTextArea(IntPtr hProgram, int ProgramNo, int AreaNo, int AddType, string AddStr, ref FONTPROP pFontProp, ref PLAYPROP pPlayProp);
/*********************************************************************************************
* LV_AddMultiLineTextToImageTextArea
*
*
* hProgram
* ProgramNo 0-255)0
* AreaNo 1-255
* AddType 0. 1.txt和rtf文件
* AddStr AddType为0则为字符串数据,AddType为1则为文件路径 \n
* pFontProp AddType为字符串类型或AddType为文件类型且文件为txt则可传入以赋值的该结构体NULL
* pPlayProp PLAYPROP结构体注示
* nAlignment 0. 1. 2. txt文件有效
* IsVCenter 0. 1.
*
* 0
* 0 LV_GetError来获取错误信息
********************************************************************************************/
[DllImport("lv_led.dll", EntryPoint = "LV_AddMultiLineTextToImageTextArea", CharSet = CharSet.Unicode)]
public static extern int LV_AddMultiLineTextToImageTextArea(IntPtr hProgram, int ProgramNo, int AreaNo, int AddType, string AddStr, ref FONTPROP pFontProp, ref PLAYPROP pPlayProp, int nAlignment, int IsVCenter);
/*********************************************************************************************
* LV_AddStaticTextToImageTextArea
*
*
* hProgram
* ProgramNo 0-255)0
* AreaNo 1-255
* AddType 0. 1.txt和rtf文件
* AddStr AddType为0则为字符串数据,AddType为1则为文件路径
* pFontProp AddType为字符串类型或AddType为文件类型且文件为txt则可传入以赋值的该结构体NULL
* DelayTime 1~65535
* nAlignment 0. 1. 2. txt文件有效
* IsVCenter 0. 1.
*
* 0
* 0 LV_GetError来获取错误信息
********************************************************************************************/
[DllImport("lv_led.dll", EntryPoint = "LV_AddStaticTextToImageTextArea", CharSet = CharSet.Unicode)]
public static extern int LV_AddStaticTextToImageTextArea(IntPtr hProgram, int ProgramNo, int AreaNo, int AddType, string AddStr, ref FONTPROP pFontProp, int DelayTime, int nAlignment, int IsVCenter);
/*********************************************************************************************
* LV_QuickAddSingleLineTextArea
*
*
* hProgram
* ProgramNo 0-255)0
* AreaNo 1-255
* pAreaRect AREARECT结构体注示
* AddType 0. 1.txt和rtf文件
* AddStr AddType为0则为字符串数据,AddType为1则为文件路径
* pFontProp AddType为字符串类型或AddType为文件类型且文件为txt则可传入以赋值的该结构体NULL
* nSpeed 1~255
*
* 0
* 0 LV_GetError来获取错误信息
********************************************************************************************/
[DllImport("lv_led.dll", EntryPoint = "LV_QuickAddSingleLineTextArea", CharSet = CharSet.Unicode)]
public static extern int LV_QuickAddSingleLineTextArea(IntPtr hProgram, int ProgramNo, int AreaNo, ref AREARECT pAreaRect, int AddType, string AddStr, ref FONTPROP pFontProp, int nSpeed);
/*********************************************************************************************
* LV_AddDigitalClockArea
*
*
* hProgram
* ProgramNo 0-255)0
* AreaNo 1-255
* pAreaRect AREARECT结构体注示
* pDigitalClockAreaInfo DIGITALCLOCKAREAINFO结构体注示
*
* 0
* 0 LV_GetError来获取错误信息
********************************************************************************************/
[DllImport("lv_led.dll", EntryPoint = "LV_AddDigitalClockArea", CharSet = CharSet.Unicode)]
public static extern int LV_AddDigitalClockArea(IntPtr hProgram, int ProgramNo, int AreaNo, ref AREARECT pAreaRect, ref DIGITALCLOCKAREAINFO pDigitalClockAreaInfo);
/*********************************************************************************************
* LV_AddTimeArea
*
*
* hProgram
* ProgramNo 0-255)0
* AreaNo 1-255
* pAreaRect AREARECT结构体注示
* pTimeAreaInfo TIMEAREAINFO结构体注示
*
* 0
* 0 LV_GetError来获取错误信息
********************************************************************************************/
[DllImport("lv_led.dll", EntryPoint = "LV_AddTimeArea", CharSet = CharSet.Unicode)]
public static extern int LV_AddTimeArea(IntPtr hProgram, int ProgramNo, int AreaNo, ref AREARECT pAreaRect, ref TIMEAREAINFO pTimeAreaInfo);
/*********************************************************************************************
* LV_AddClockArea
*
*
* hProgram
* ProgramNo 0-255)0
* AreaNo 1-255
* pAreaRect AREARECT结构体注示
* pClockAreaInfo CLOCKAREAINFO结构体注示
*
* 0
* 0 LV_GetError来获取错误信息
********************************************************************************************/
[DllImport("lv_led.dll", EntryPoint = "LV_AddClockArea", CharSet = CharSet.Unicode)]
public static extern int LV_AddClockArea(IntPtr hProgram, int ProgramNo, int AreaNo, ref AREARECT pAreaRect, ref CLOCKAREAINFO pClockAreaInfo);
/*********************************************************************************************
* LV_AddNeiMaArea
*
* hProgram
* ProgramNo 0(0-255)
* AreaNo (1-255)
* pAreaRect AREARECT结构体注示
* C卡外的其他卡,X和Y坐标必须为8的整数倍,0,8,16,
* NeiMaStr GB2312
* FontSize 16 24 32
* FontColor BBGGRR 0xff 0xff00 绿 0xffff
* pPlayProp PLAYPROP结构体注示
*
* 0
* 0 LV_GetError来获取错误信息
********************************************************************************************/
[DllImport("lv_led.dll", EntryPoint = "LV_AddNeiMaArea", CharSet = CharSet.Unicode)]
public static extern int LV_AddNeiMaArea(IntPtr hProgram, int ProgramNo, int AreaNo, ref AREARECT pAreaRect, string NeiMaStr, int FontSize, int FontColor, ref PLAYPROP pPlayProp);
/// <summary>
/// 添加语音区域
/// </summary>
/// <param name="hProgram"></param>
/// <param name="ProgramNo"></param>
/// <param name="AreaNo"></param>
/// <param name="VoiceStr"></param>
/// <param name="DelayTime"></param>
/// <param name="PlayCount"></param>
/// <returns></returns>
[DllImport("lv_led.dll", EntryPoint = "LV_AddVoiceArea", CharSet = CharSet.Unicode)]
public static extern int LV_AddVoiceArea(IntPtr hProgram, int ProgramNo, int AreaNo, string VoiceStr, int DelayTime, int PlayCount);
/// <summary>
/// 添加二维码区域,仅C卡支持
/// </summary>
/// <param name="hProgram"></param>
/// <param name="ProgramNo"></param>
/// <param name="AreaNo"></param>
/// <param name="pAreaRect"></param>
/// <param name="pQRAreaInfo"></param>
/// <returns></returns>
[DllImport("lv_led.dll", EntryPoint = "LV_AddQRCodeArea", CharSet = CharSet.Unicode)]
public static extern int LV_AddQRCodeArea(IntPtr hProgram, int ProgramNo, int AreaNo, ref AREARECT pAreaRect, ref QRAREAINFO pQRAreaInfo);
/*********************************************************************************************
* LV_RefreshNeiMaArea
*
*
* pCommunicationInfo COMMUNICATIONINFO结构体注示
* NeiMaStr ,<<>>
*
* 0
* 0 LV_GetError来获取错误信息
********************************************************************************************/
[DllImport("lv_led.dll", EntryPoint = "LV_RefreshNeiMaArea", CharSet = CharSet.Unicode)]
public static extern int LV_RefreshNeiMaArea(ref COMMUNICATIONINFO pCommunicationInfo, string NeiMaStr);
/*********************************************************************************************
* LV_RefreshVoiceArea
*
*
* pCommunicationInfo COMMUNICATIONINFO结构体注示
* VoiceStr
*
* 0
* 0 LV_GetError来获取错误信息
********************************************************************************************/
[DllImport("lv_led.dll", EntryPoint = "LV_RefreshVoiceArea", CharSet = CharSet.Unicode)]
public static extern int LV_RefreshVoiceArea(ref COMMUNICATIONINFO pCommunicationInfo, string VoiceStr);
/// <summary>
/// 刷新二维码内容的显示
/// </summary>
/// <param name="pCommunicationInfo"></param>
/// <param name="CodeStr"></param>
/// <returns></returns>
[DllImport("lv_led.dll", EntryPoint = "LV_RefreshVoiceArea", CharSet = CharSet.Unicode)]
public static extern int LV_RefreshQRCodeArea(ref COMMUNICATIONINFO pCommunicationInfo, string CodeStr);
/*********************************************************************************************
* LV_AddWaterBorder
*
*
* hProgram
* ProgramNo 0-255)0
* AreaNo 1-255
* pAreaRect AREARECT结构体注示
* pWaterBorderInfo WATERBORDERINFO结构体注示
*
* 0
* 0 LV_GetError来获取错误信息
********************************************************************************************/
[DllImport("lv_led.dll", EntryPoint = "LV_AddWaterBorder", CharSet = CharSet.Unicode)]
public static extern int LV_AddWaterBorder(IntPtr hProgram, int ProgramNo, int AreaNo, ref AREARECT pAreaRect, ref WATERBORDERINFO pWaterBorderInfo);
//[DllImport("lv_led.dll", EntryPoint = "LV_AddVoiceArea", CharSet = CharSet.Unicode)]
//public static extern int LV_AddVoiceArea(IntPtr hProgram, int ProgramNo, int AreaNo,ref VOICEAREAINFO pVoiceAreaInfo);
/*********************************************************************************************
* LV_DeleteProgram (使)
*
*
* hProgram
********************************************************************************************/
[DllImport("lv_led.dll", EntryPoint = "LV_DeleteProgram", CharSet = CharSet.Unicode)]
public static extern void LV_DeleteProgram(IntPtr hProgram);
/*********************************************************************************************
* LV_Send
*
*
* pCommunicationInfo COMMUNICATIONINFO结构体注示
* hProgram
*
* 0
* 0 LV_GetError来获取错误信息
********************************************************************************************/
[DllImport("lv_led.dll", EntryPoint = "LV_Send", CharSet = CharSet.Unicode)]
public static extern int LV_Send(ref COMMUNICATIONINFO pCommunicationInfo, IntPtr hProgram);
/*********************************************************************************************
* LV_TestOnline LED屏是否可连接上
*
*
* pCommunicationInfo COMMUNICATIONINFO结构体注示
*
* 0
* 0 LV_GetError来获取错误信息
********************************************************************************************/
[DllImport("lv_led.dll", EntryPoint = "LV_TestOnline", CharSet = CharSet.Unicode)]
public static extern int LV_TestOnline(ref COMMUNICATIONINFO pCommunicationInfo);
/*********************************************************************************************
* LV_SetBasicInfoEx
* ,flash硬件弄坏
*
* pCommunicationInfo COMMUNICATIONINFO结构体注示
* ColorType 1. 2. 3. C卡全彩参数为3 X系列卡参数固定为 4
* GrayLevel 1-5 ,4,8,16,32 C系列的卡才支持T,A,U,XC,W,E,X0
* LedWidth
* LedHeight
*
* 0
* 0 LV_GetError来获取错误信息
********************************************************************************************/
[DllImport("lv_led.dll", EntryPoint = "LV_SetBasicInfoEx", CharSet = CharSet.Unicode)]
public static extern int LV_SetBasicInfoEx(ref COMMUNICATIONINFO pCommunicationInfo, int ColorType, int GrayLevel, int LedWidth, int LedHeight);
/*********************************************************************************************
* LV_SetOEDA OE DA
*
*
* pCommunicationInfo COMMUNICATIONINFO结构体注示
* Oe OE 0. 1.
* Da DA 0. 1.
*
* 0
* 0 LV_GetError来获取错误信息
********************************************************************************************/
[DllImport("lv_led.dll", EntryPoint = "LV_SetOEDA", CharSet = CharSet.Unicode)]
public static extern int LV_SetOEDA(ref COMMUNICATIONINFO pCommunicationInfo, int Oe, int Da);
/*********************************************************************************************
* LV_AdjustTime
*
*
* pCommunicationInfo COMMUNICATIONINFO结构体注示
*
* 0
* 0 LV_GetError来获取错误信息
********************************************************************************************/
[DllImport("lv_led.dll", EntryPoint = "LV_AdjustTime", CharSet = CharSet.Unicode)]
public static extern int LV_AdjustTime(ref COMMUNICATIONINFO pCommunicationInfo);
/*********************************************************************************************
* LV_PowerOnOff
*
*
* pCommunicationInfo COMMUNICATIONINFO结构体注示
* OnOff 0. 1. 2.(C卡)
*
* 0
* 0 LV_GetError来获取错误信息
********************************************************************************************/
[DllImport("lv_led.dll", EntryPoint = "LV_PowerOnOff", CharSet = CharSet.Unicode)]
public static extern int LV_PowerOnOff(ref COMMUNICATIONINFO pCommunicationInfo, int OnOff);
/*********************************************************************************************
* LV_TimePowerOnOff
*
*
* pCommunicationInfo COMMUNICATIONINFO结构体注示
* pTimeInfo ONOFFTIMEINFO结构体注示
*
* 0
* 0 LV_GetError来获取错误信息
********************************************************************************************/
[DllImport("lv_led.dll", EntryPoint = "LV_TimePowerOnOff", CharSet = CharSet.Unicode)]
public static extern int LV_TimePowerOnOff(ref COMMUNICATIONINFO pCommunicationInfo, ref ONOFFTIMEINFO pTimeInfo);
/*********************************************************************************************
* LV_SetBrightness
*
*
* pCommunicationInfo COMMUNICATIONINFO结构体注示
* BrightnessValue 0~15
*
* 0
* 0 LV_GetError来获取错误信息
********************************************************************************************/
[DllImport("lv_led.dll", EntryPoint = "LV_SetBrightness", CharSet = CharSet.Unicode)]
public static extern int LV_SetBrightness(ref COMMUNICATIONINFO pCommunicationInfo, int BrightnessValue);
/*********************************************************************************************
* LV_TimeBrightness
*
*
* pCommunicationInfo COMMUNICATIONINFO结构体注示
* pBrightnessTimeInfo BRIGHTNESSTIMEINFO结构体注示
*
* 0
* 0 LV_GetError来获取错误信息
********************************************************************************************/
[DllImport("lv_led.dll", EntryPoint = "LV_TimeBrightness", CharSet = CharSet.Unicode)]
public static extern int LV_TimeBrightness(ref COMMUNICATIONINFO pCommunicationInfo, ref BRIGHTNESSTIMEINFO pBrightnessTimeInfo);
/*********************************************************************************************
* LV_LedTest LED测试
*
*
* pCommunicationInfo COMMUNICATIONINFO结构体注示
* TestValue
*
* 0
* 0 LV_GetError来获取错误信息
********************************************************************************************/
[DllImport("lv_led.dll", EntryPoint = "LV_LedTest", CharSet = CharSet.Unicode)]
public static extern int LV_LedTest(ref COMMUNICATIONINFO pCommunicationInfo, int TestValue);
/*********************************************************************************************
* LV_TimeLocker LED定时锁屏
*
*
* pCommunicationInfo COMMUNICATIONINFO结构体注示
* LockerYear
* LockerMonth
* LockerDay
* LockerHour
* LockerMinute
*
* 0
* 0 LV_GetError来获取错误信息
********************************************************************************************/
[DllImport("lv_led.dll", EntryPoint = "LV_TimeLocker", CharSet = CharSet.Unicode)]
public static extern int LV_TimeLocker(ref COMMUNICATIONINFO pCommunicationInfo, int LockerYear, int LockerMonth, int LockerDay, int LockerHour, int LockerMinute);
/*********************************************************************************************
* LV_CancelLocker
*
*
* pCommunicationInfo COMMUNICATIONINFO结构体注示
*
* 0
* 0 LV_GetError来获取错误信息
********************************************************************************************/
[DllImport("lv_led.dll", EntryPoint = "LV_CancelLocker", CharSet = CharSet.Unicode)]
public static extern int LV_CancelLocker(ref COMMUNICATIONINFO pCommunicationInfo);
/*********************************************************************************************
* LV_SetLedCommunicationParameter LED通讯参数
*
*
* pCommunicationInfo COMMUNICATIONINFO结构体注示
* pLedCommunicationParameter LEDCOMMUNICATIONPARAMETER结构体注示
*
* 0
* 0 LV_GetError来获取错误信息
********************************************************************************************/
[DllImport("lv_led.dll", EntryPoint = "LV_SetLedCommunicationParameter", CharSet = CharSet.Unicode)]
public static extern int LV_SetLedCommunicationParameter(ref COMMUNICATIONINFO pCommunicationInfo, ref LEDCOMMUNICATIONPARAMETER pLedCommunicationParameter);
/*********************************************************************************************
* LV_LedInitServer C2MC4M才支持
*
*
* port
*
* 0
* 0 LV_GetError来获取错误信息
********************************************************************************************/
[DllImport("lv_led.dll", EntryPoint = "LV_LedInitServer", CharSet = CharSet.Unicode)]
public static extern int LV_LedInitServer(int port);
/*********************************************************************************************
* LV_LedShudownServer C2MC4M才支持
********************************************************************************************/
[DllImport("lv_led.dll", EntryPoint = "LV_LedShudownServer", CharSet = CharSet.Unicode)]
public static extern int LV_LedShudownServer();
/*********************************************************************************************
* LV_RegisterLedServerCallback C2MC4M才支持
*
*
* serverCallback
********************************************************************************************/
[DllImport("lv_led.dll", EntryPoint = "LV_RegisterLedServerCallback", CharSet = CharSet.Unicode)]
public static extern int LV_RegisterLedServerCallback(SERVERINFOCALLBACK serverCallback);
/*********************************************************************************************
* SetLedServerInfo LED屏的服务器信息
*
*
* IpStr LED屏的IP
* IsClient 1 0(广)
* ServerIp IP
* ServerPort
* HeartBeatTime LED心跳包时间(20)
*
* 0
* 0
********************************************************************************************/
[DllImport("lv_led.dll", EntryPoint = "LV_SetServerInfo", CharSet = CharSet.Unicode)]
public static extern int LV_SetServerInfo(ref COMMUNICATIONINFO pCommunicationInfo, int isClient, string ServerIp, int ServerPort, int HeartbeatTime);
/// <summary>
/// 设置继电器 C8 T8支持
/// </summary>
/// <param name="pCommunicationInfo">通讯参数赋值方式见COMMUNICATIONINFO结构体注示</param>
/// <param name="type">控制模式 0:手动模式 1:定时模式</param>
/// <param name="nManualSwitch">手动模式时的开关值 0:关 1:开</param>
/// <param name="flag1">定时模式的第一组时间标志 0:无效 1:有效</param>
/// <param name="startTime1">定时模式的第一组起始时间,格式如:"12:00:00"</param>
/// <param name="endTime1">定时模式的第一组结束时间,格式如:"13:59:59"</param>
/// <param name="flag2">定时模式的第二组时间标志 0:无效 1:有效</param>
/// <param name="startTime2">定时模式的第二组起始时间,格式如:"14:00:00"</param>
/// <param name="endTime2">定时模式的第二组结束时间,格式如:"15:59:59"</param>
/// <param name="flag3">定时模式的第三组时间标志 0:无效 1:有效</param>
/// <param name="startTime3">定时模式的第三组起始时间,格式如:"16:00:00"</param>
/// <param name="endTime3">定时模式的第三组结束时间,格式如:"17:59:59"</param>
/// <returns></returns>
[DllImport("lv_led.dll", EntryPoint = "LV_SetRelay", CharSet = CharSet.Unicode)]
public static extern int LV_SetRelay(ref COMMUNICATIONINFO pCommunicationInfo, int type, int nManualSwitch
, int flag1, string startTime1, string endTime1
, int flag2, string startTime2, string endTime2
, int flag3, string startTime3, string endTime3);
/*********************************************************************************************
* LV_GetError
*
*
* nErrCode
*
*
********************************************************************************************/
public static string LS_GetError(int nErrCode)
{
string ErrStr;
switch (nErrCode)
{
case -1:
ErrStr = "无效的节目句柄。(Invalid program handle.)"; break;
case -2:
ErrStr = "节目已经存在。(The program already exists.)"; break;
case -3:
ErrStr = "指定的节目不存在。The specified program does not exist."; break;
case -4:
ErrStr = "指定的区域不存在。The specified region does not exist."; break;
case -5:
ErrStr = "创建socket失败。Creating a socket has failed."; break;
case -6:
ErrStr = "错误的回复包。Error of the response package."; break;
case -7:
ErrStr = "不支持的文件类型。Unsupported file type."; break;
case -8:
ErrStr = "IP网关掩码或MAC字符串格式错误。The IP gateway mask or the MAC string is incorrectly formed."; break;
case -9:
ErrStr = "错误的波特率。The incorrect aud rate."; break;
case -10:
ErrStr = "文件路径不存在。File path does not exist."; break;
case -11:
ErrStr = "区域重叠。zone overlapping."; break;
case -12:
ErrStr = "打开文件失败。 Failed to open the file."; break;
case -14:
ErrStr = "区域已存在。The Area already exists."; break;
case -15:
ErrStr = "无效的发送类型。Invalid send type."; break;
case -16:
ErrStr = "绘图失败。Drawing failed."; break;
case -17:
ErrStr = "创建文件夹失败。 Failed to create a folder."; break;
case -30:
ErrStr = "打开串口失败。Failed to open the serial port."; break;
case -31:
ErrStr = "设置串口超时失败。Failed to set the serial port timeout."; break;
case -32:
ErrStr = "设置串口缓冲区失败。Failed to set the serial port buffer."; break;
case -33:
ErrStr = "串口发送数据失败。Serial port failed to send data."; break;
case -34:
ErrStr = "串口接收数据失败。The Serial port failed to receive the data."; break;
case -35:
ErrStr = "串口设置失败。Serial port settings have failed."; break;
case -36:
ErrStr = "串口接收数据超时。Serial port receives data timeout."; break;
case -37:
ErrStr = "USB不支持群发。USB does not support mass sending."; break;
case -38:
ErrStr = "发送取消。Send a cancellation."; break;
case -100:
ErrStr = "网络连接失败。The network connection has failed."; break;
case -101:
ErrStr = "网络发送失败。The network sending has failed."; break;
case -102:
ErrStr = "网络接收数据失败。The network has failed to receive the data."; break;
case -103:
ErrStr = "bind失败。The bind has failed."; break;
case -104:
ErrStr = "无可用网卡。No network card is available."; break;
case 0xc140:
ErrStr = "Logo与参屏大小不适应。Logo is not suitable to the screen size."; break;
case 0xdaa3:
ErrStr = "控制器繁忙。 The controller is busy."; break;
case 0xd5b0:
ErrStr = "固件程序型号不匹配。Firmware program model does not match."; break;
case 0xd5b4:
ErrStr = "不是有效的固件程序。Is not a valid firmware program."; break;
case 0xdab8:
ErrStr = "节目颜色或屏宽高与控制卡屏参设定值不一致。The program color or screen width and height is inconsistent with the set value of the control card screen parameter."; break;
case 0xc1ba:
ErrStr = "超出控制卡带载。 Out of the control cartridge load."; break;
case 0xdab5:
ErrStr = "节目数据大小超过允许的最大值。The program data size exceeds the maximum allowed value."; break;
default:
ErrStr = "未定义错误。 No error is defined.Error code is" + nErrCode.ToString(); break;
}
return ErrStr;
}
}
public static class IniFunc
{
/// <summary>
/// 获取值
/// </summary>
/// <param name="section">段落名</param>
/// <param name="key">键名</param>
/// <param name="defval">读取异常是的缺省值</param>
/// <param name="retval">键名所对应的的值,没有找到返回空值</param>
/// <param name="size">返回值允许的大小</param>
/// <param name="filepath">ini文件的完整路径</param>
/// <returns></returns>
[DllImport("kernel32.dll")]
private static extern int GetPrivateProfileString(
string section,
string key,
string defval,
StringBuilder retval,
int size,
string filepath);
/// <summary>
/// 写入
/// </summary>
/// <param name="section">需要写入的段落名</param>
/// <param name="key">需要写入的键名</param>
/// <param name="val">写入值</param>
/// <param name="filepath">ini文件的完整路径</param>
/// <returns></returns>
[DllImport("kernel32.dll")]
private static extern int WritePrivateProfileString(
string section,
string key,
string val,
string filepath);
/// <summary>
/// 获取数据
/// </summary>
/// <param name="section">段落名</param>
/// <param name="key">键名</param>
/// <param name="def">没有找到时返回的默认值</param>
/// <param name="filename">ini文件完整路径</param>
/// <returns></returns>
public static string GetString(string section, string key, string def, string filename)
{
StringBuilder sb = new StringBuilder(1024);
GetPrivateProfileString(section, key, def, sb, 1024, filename);
return sb.ToString();
}
/// <summary>
/// 写入数据
/// </summary>
/// <param name="section">段落名</param>
/// <param name="key">键名</param>
/// <param name="val">写入值</param>
/// <param name="filename">ini文件完整路径</param>
public static void WriteString(string section, string key, string val, string filename)
{
WritePrivateProfileString(section, key, val, filename);
}
}
public class CLedBasicInfo
{
/// <summary>
/// 屏类型
/// 0.6代T系A系XC系
/// 1.6代E系列
/// 2.X1X2系列
/// 3.7代C系列(C2M,C4M)
/// 4: E5,E6,C8
/// </summary>
public int m_ledType;
/// <summary>
/// 屏宽度
/// </summary>
public int m_ledWidth;
/// <summary>
/// 屏高度
/// </summary>
public int m_ledHeight;
/// <summary>
/// 屏颜色 1:单色 2:双色 3:七彩
/// 注C卡全彩参数为3 X系列卡参数固定为 4
/// </summary>
public int m_ledColor;
/// <summary>
/// 屏灰度等级
/// 目前C系列的卡才支持其它型号T,A,U,XC,W,E,X参数必须为0
/// 1-5对应的灰度等级分别为 无,4,8,16,32
/// </summary>
public int m_ledGrayLevel;
}
}