LED_Control.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. using Common;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace MeterPlugInLibrary
  8. {
  9. public class LED_Control
  10. {
  11. private Log lg = Log.GetInstance(); //写日志
  12. public LED_Control(string Ip)
  13. {
  14. int nResult;
  15. LedDll.COMMUNICATIONINFO CommunicationInfo = new LedDll.COMMUNICATIONINFO();//定义一通讯参数结构体变量用于对设定的LED通讯,具体对此结构体元素赋值说明见COMMUNICATIONINFO结构体定义部份注示
  16. CommunicationInfo.SendType = 0;//设为固定IP通讯模式,即TCP通讯
  17. CommunicationInfo.IpStr = Ip;//给IpStr赋值LED控制卡的IP
  18. CommunicationInfo.LedNumber = 1;//LED屏号为1,注意socket通讯和248通讯不识别屏号,默认赋1就行了,485必需根据屏的实际屏号进行赋值
  19. nResult = LedDll.LV_SetBasicInfo(ref CommunicationInfo, 2, 128, 48);//设置屏参,屏的颜色为2即为双基色,128为屏宽点数,48为屏高点数,具体函数参数说明见函数声明注示
  20. if (nResult != 0)//如果失败则可以调用LV_GetError获取中文错误信息
  21. {
  22. string ErrStr;
  23. ErrStr = LedDll.LS_GetError(nResult);
  24. //设置失败
  25. }
  26. else
  27. {
  28. //设置成功
  29. }
  30. }
  31. public void setOneLineMsg(string Ip,string ledInfo)
  32. {
  33. int nResult;
  34. LedDll.COMMUNICATIONINFO CommunicationInfo = new LedDll.COMMUNICATIONINFO();//定义一通讯参数结构体变量用于对设定的LED通讯,具体对此结构体元素赋值说明见COMMUNICATIONINFO结构体定义部份注示
  35. CommunicationInfo.SendType = 0;//设为固定IP通讯模式,即TCP通讯
  36. CommunicationInfo.IpStr = Ip;//给IpStr赋值LED控制卡的IP
  37. CommunicationInfo.LedNumber = 1;//LED屏号为1,注意socket通讯和248通讯不识别屏号,默认赋1就行了,485必需根据屏的实际屏号进行赋值
  38. int hProgram;//节目句柄
  39. hProgram = LedDll.LV_CreateProgram(128, 48, 2);//根据传的参数创建节目句柄,128是屏宽点数,48是屏高点数,2是屏的颜色,注意此处屏宽高及颜色参数必需与设置屏参的屏宽高及颜色一致,否则发送时会提示错误
  40. //此处可自行判断有未创建成功,hProgram返回NULL失败,非NULL成功,一般不会失败
  41. nResult = LedDll.LV_AddProgram(hProgram, 1, 0, 1);//添加一个节目,参数说明见函数声明注示
  42. if (nResult != 0)
  43. {
  44. string ErrStr;
  45. ErrStr = LedDll.LS_GetError(nResult);
  46. return;
  47. }
  48. LedDll.AREARECT AreaRect = new LedDll.AREARECT();//区域坐标属性结构体变量
  49. /*
  50. AreaRect.left = 0;
  51. AreaRect.top = 0;
  52. AreaRect.width = 128;
  53. AreaRect.height = 12;
  54. LedDll.DIGITALCLOCKAREAINFO DigitalClockAreaInfo = new LedDll.DIGITALCLOCKAREAINFO();
  55. DigitalClockAreaInfo.TimeColor = LedDll.COLOR_RED;
  56. DigitalClockAreaInfo.ShowStrFont.FontName = "宋体";
  57. DigitalClockAreaInfo.ShowStrFont.FontSize = 10;
  58. DigitalClockAreaInfo.IsShowHour = 1;
  59. DigitalClockAreaInfo.IsShowMinute = 1;
  60. nResult = LedDll.LV_AddDigitalClockArea(hProgram, 1, 1, ref AreaRect, ref DigitalClockAreaInfo);//注意区域号不能一样,详见函数声明注示
  61. //*/
  62. AreaRect.left = 0;
  63. AreaRect.top = 8;
  64. AreaRect.width = 128;
  65. AreaRect.height = 34;
  66. LedDll.FONTPROP FontProp = new LedDll.FONTPROP();//文字属性
  67. FontProp.FontName = "宋体";
  68. FontProp.FontSize = 24;
  69. FontProp.FontColor = LedDll.COLOR_RED;
  70. FontProp.FontBold = 0;
  71. //int nsize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(LedDll.FONTPROP));
  72. nResult = LedDll.LV_QuickAddSingleLineTextArea(hProgram, 1, 2, ref AreaRect, LedDll.ADDTYPE_STRING, ledInfo, ref FontProp, 4);//快速通过字符添加一个单行文本区域,函数见函数声明注示
  73. nResult = LedDll.LV_Send(ref CommunicationInfo, hProgram);//发送,见函数声明注示
  74. LedDll.LV_DeleteProgram(hProgram);//删除节目内存对象,详见函数声明注示
  75. if (nResult != 0)//如果失败则可以调用LV_GetError获取中文错误信息
  76. {
  77. string ErrStr;
  78. ErrStr = LedDll.LS_GetError(nResult);
  79. }
  80. else
  81. {
  82. //"发送成功";
  83. }
  84. }
  85. public void setTwoLineMsg(string Ip, string msg1, string msg2)
  86. {
  87. int nResult;
  88. LedDll.COMMUNICATIONINFO CommunicationInfo = new LedDll.COMMUNICATIONINFO();//定义一通讯参数结构体变量用于对设定的LED通讯,具体对此结构体元素赋值说明见COMMUNICATIONINFO结构体定义部份注示
  89. CommunicationInfo.SendType = 0;//设为固定IP通讯模式,即TCP通讯
  90. CommunicationInfo.IpStr = Ip;//给IpStr赋值LED控制卡的IP
  91. CommunicationInfo.LedNumber = 1;//LED屏号为1,注意socket通讯和248通讯不识别屏号,默认赋1就行了,485必需根据屏的实际屏号进行赋值
  92. int hProgram;//节目句柄
  93. hProgram = LedDll.LV_CreateProgram(128, 48, 2);//根据传的参数创建节目句柄,128是屏宽点数,48是屏高点数,2是屏的颜色,注意此处屏宽高及颜色参数必需与设置屏参的屏宽高及颜色一致,否则发送时会提示错误
  94. //此处可自行判断有未创建成功,hProgram返回NULL失败,非NULL成功,一般不会失败
  95. nResult = LedDll.LV_AddProgram(hProgram, 1, 0, 1);//添加一个节目,参数说明见函数声明注示
  96. if (nResult != 0)
  97. {
  98. string ErrStr;
  99. ErrStr = LedDll.LS_GetError(nResult);
  100. return;
  101. }
  102. LedDll.AREARECT AreaRect = new LedDll.AREARECT();//区域坐标属性结构体变量
  103. AreaRect.left = 0;
  104. AreaRect.top = 0;
  105. AreaRect.width = 128;
  106. AreaRect.height = 8;
  107. LedDll.DIGITALCLOCKAREAINFO DigitalClockAreaInfo = new LedDll.DIGITALCLOCKAREAINFO();
  108. DigitalClockAreaInfo.TimeColor = LedDll.COLOR_RED;
  109. DigitalClockAreaInfo.ShowStrFont.FontName = "宋体";
  110. DigitalClockAreaInfo.ShowStrFont.FontSize = 6;
  111. DigitalClockAreaInfo.IsShowHour = 1;
  112. DigitalClockAreaInfo.IsShowMinute = 1;
  113. nResult = LedDll.LV_AddDigitalClockArea(hProgram, 1, 1, ref AreaRect, ref DigitalClockAreaInfo);//注意区域号不能一样,详见函数声明注示
  114. AreaRect.left = 0;
  115. AreaRect.top = 8;
  116. AreaRect.width = 128;
  117. AreaRect.height = 20;
  118. LedDll.FONTPROP FontProp = new LedDll.FONTPROP();//文字属性
  119. FontProp.FontName = "宋体";
  120. FontProp.FontSize = 12;
  121. FontProp.FontColor = LedDll.COLOR_RED;
  122. FontProp.FontBold = 0;
  123. //int nsize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(LedDll.FONTPROP));
  124. nResult = LedDll.LV_QuickAddSingleLineTextArea(hProgram, 1, 2, ref AreaRect, LedDll.ADDTYPE_STRING, msg1, ref FontProp, 4);//快速通过字符添加一个单行文本区域,函数见函数声明注示
  125. AreaRect.left = 0;
  126. AreaRect.top = 28;
  127. AreaRect.width = 128;
  128. AreaRect.height = 20;
  129. nResult = LedDll.LV_QuickAddSingleLineTextArea(hProgram, 1, 3, ref AreaRect, LedDll.ADDTYPE_STRING, "智能计量系统", ref FontProp, 4);//快速通过字符添加一个单行文本区域,函数见函数声明注示
  130. nResult = LedDll.LV_Send(ref CommunicationInfo, hProgram);//发送,见函数声明注示
  131. LedDll.LV_DeleteProgram(hProgram);//删除节目内存对象,详见函数声明注示
  132. if (nResult != 0)//如果失败则可以调用LV_GetError获取中文错误信息
  133. {
  134. string ErrStr;
  135. ErrStr = LedDll.LS_GetError(nResult);
  136. }
  137. else
  138. {
  139. //"发送成功";
  140. }
  141. }
  142. #region 成品秤添加一个静止的图文区域显示重量
  143. public void setProductOneLineMsg(string Ip, string ledInfo)
  144. {
  145. int nResult;
  146. LedDll.COMMUNICATIONINFO CommunicationInfo = new LedDll.COMMUNICATIONINFO();//定义一通讯参数结构体变量用于对设定的LED通讯,具体对此结构体元素赋值说明见COMMUNICATIONINFO结构体定义部份注示
  147. CommunicationInfo.SendType = 0;//设为固定IP通讯模式,即TCP通讯
  148. CommunicationInfo.IpStr = Ip;//给IpStr赋值LED控制卡的IP
  149. CommunicationInfo.LedNumber = 1;//LED屏号为1,注意socket通讯和248通讯不识别屏号,默认赋1就行了,485必需根据屏的实际屏号进行赋值
  150. nResult = LedDll.LV_SetBasicInfo(ref CommunicationInfo, 2, 192, 64);//设置屏参,屏的颜色为2即为双基色,64为屏宽点数,32为屏高点数,具体函数参数说明见函数声明注示
  151. int hProgram;//节目句柄
  152. hProgram = LedDll.LV_CreateProgram(192, 64, 2);//根据传的参数创建节目句柄,128是屏宽点数,48是屏高点数,2是屏的颜色,注意此处屏宽高及颜色参数必需与设置屏参的屏宽高及颜色一致,否则发送时会提示错误
  153. //此处可自行判断有未创建成功,hProgram返回NULL失败,非NULL成功,一般不会失败
  154. nResult = LedDll.LV_AddProgram(hProgram, 1, 0, 1);//添加一个节目,参数说明见函数声明注示
  155. if (nResult != 0)
  156. {
  157. string ErrStr;
  158. ErrStr = LedDll.LS_GetError(nResult);
  159. return;
  160. }
  161. LedDll.AREARECT AreaRect = new LedDll.AREARECT();//区域坐标属性结构体变量
  162. AreaRect.left = 0;
  163. AreaRect.top = 8;
  164. AreaRect.width = 192;
  165. AreaRect.height = 34;
  166. LedDll.FONTPROP FontProp = new LedDll.FONTPROP();//文字属性
  167. FontProp.FontName = "宋体";
  168. FontProp.FontSize = 24;
  169. FontProp.FontColor = LedDll.COLOR_RED;
  170. FontProp.FontBold = 0;
  171. //int nsize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(LedDll.FONTPROP));
  172. nResult = LedDll.LV_QuickAddSingleLineTextArea(hProgram, 1, 2, ref AreaRect, LedDll.ADDTYPE_STRING, ledInfo, ref FontProp, 4);//快速通过字符添加一个单行文本区域,函数见函数声明注示
  173. nResult = LedDll.LV_Send(ref CommunicationInfo, hProgram);//发送,见函数声明注示
  174. LedDll.LV_DeleteProgram(hProgram);//删除节目内存对象,详见函数声明注示
  175. if (nResult != 0)//如果失败则可以调用LV_GetError获取中文错误信息
  176. {
  177. string ErrStr;
  178. ErrStr = LedDll.LS_GetError(nResult);
  179. }
  180. else
  181. {
  182. //"发送成功";
  183. }
  184. }
  185. public void setStaticLineMsg(string Ip, string ledInfo)
  186. {
  187. try
  188. {
  189. if (ledInfo == null) return;
  190. ledInfo = ledInfo.Replace(",", "\r\n");
  191. if (PbCache.OldLedInfo == ledInfo) return;
  192. lg.WriteLog(26, "led推送信息开始时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff"));
  193. PbCache.OldLedInfo = ledInfo;
  194. lg.WriteLog(26, PbCache.lockCarNo + "led推送信息:" + ledInfo);
  195. int nResult;
  196. LedDll.COMMUNICATIONINFO CommunicationInfo = new LedDll.COMMUNICATIONINFO();//定义一通讯参数结构体变量用于对设定的LED通讯,具体对此结构体元素赋值说明见COMMUNICATIONINFO结构体定义部份注示
  197. CommunicationInfo.SendType = 0;//设为固定IP通讯模式,即TCP通讯
  198. CommunicationInfo.IpStr = Ip;//给IpStr赋值LED控制卡的IP
  199. CommunicationInfo.LedNumber = 1;//LED屏号为1,注意socket通讯和248通讯不识别屏号,默认赋1就行了,485必需根据屏的实际屏号进行赋值
  200. nResult = LedDll.LV_SetBasicInfo(ref CommunicationInfo, 2, 96, 64);//设置屏参,屏的颜色为2即为双基色,64为屏宽点数,32为屏高点数,具体函数参数说明见函数声明注示
  201. int hProgram;//节目句柄
  202. hProgram = LedDll.LV_CreateProgram(96, 64, 2);//根据传的参数创建节目句柄,128是屏宽点数,48是屏高点数,2是屏的颜色,注意此处屏宽高及颜色参数必需与设置屏参的屏宽高及颜色一致,否则发送时会提示错误
  203. //此处可自行判断有未创建成功,hProgram返回NULL失败,非NULL成功,一般不会失败
  204. nResult = LedDll.LV_AddProgram(hProgram, 1, 0, 1);//添加一个节目,参数说明见函数声明注示
  205. if (nResult != 0)
  206. {
  207. string ErrStr;
  208. ErrStr = LedDll.LS_GetError(nResult);
  209. return;
  210. }
  211. LedDll.AREARECT AreaRect = new LedDll.AREARECT();//区域坐标属性结构体变量
  212. AreaRect.left = 0;
  213. AreaRect.top = 0;
  214. AreaRect.width = 96;
  215. AreaRect.height = 64;
  216. LedDll.FONTPROP FontProp = new LedDll.FONTPROP();//文字属性
  217. FontProp.FontName = "宋体";
  218. FontProp.FontSize = 10;
  219. FontProp.FontColor = LedDll.COLOR_RED;
  220. FontProp.FontBold = 0;
  221. //int nsize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(LedDll.FONTPROP));
  222. nResult = LedDll.LV_AddImageTextArea(hProgram, 1, 2, ref AreaRect, 0);
  223. //nResult = LedDll.LV_QuickAddSingleLineTextArea(hProgram, 1, 2, ref AreaRect, LedDll.ADDTYPE_STRING, ledInfo, ref FontProp, 4);//快速通过字符添加一个单行文本区域,函数见函数声明注示
  224. nResult = LedDll.LV_AddStaticTextToImageTextArea(hProgram, 1, 2, LedDll.ADDTYPE_STRING, ledInfo, ref FontProp, 1, 2, 1);//快速通过字符添加一个单行文本区域,函数见函数声明注示
  225. nResult = LedDll.LV_Send(ref CommunicationInfo, hProgram);//发送,见函数声明注示
  226. LedDll.LV_DeleteProgram(hProgram);//删除节目内存对象,详见函数声明注示
  227. if (nResult != 0)//如果失败则可以调用LV_GetError获取中文错误信息
  228. {
  229. string ErrStr;
  230. ErrStr = LedDll.LS_GetError(nResult);
  231. }
  232. else
  233. {
  234. //"发送成功";
  235. }
  236. lg.WriteLog(26, "led推送信息结束时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff"));
  237. }
  238. catch (Exception ex)
  239. {
  240. lg.WriteLog(25, PbCache.lockCarNo + "led_trycatch事件异常:" + ex.Message);
  241. }
  242. }
  243. public void setStaticLineMsgOut(string Ip, string ledInfo)
  244. {
  245. try
  246. {
  247. if (ledInfo == null) return;
  248. ledInfo = ledInfo.Replace(",", "\r\n");
  249. if (PbCache.OldLedInfo == ledInfo) return;
  250. lg.WriteLog(26, "led推送信息开始时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff"));
  251. PbCache.OldLedInfo = ledInfo;
  252. lg.WriteLog(26, PbCache.lockCarNo + "led推送信息:" + ledInfo);
  253. int nResult;
  254. LedDll.COMMUNICATIONINFO CommunicationInfo = new LedDll.COMMUNICATIONINFO();//定义一通讯参数结构体变量用于对设定的LED通讯,具体对此结构体元素赋值说明见COMMUNICATIONINFO结构体定义部份注示
  255. CommunicationInfo.SendType = 0;//设为固定IP通讯模式,即TCP通讯
  256. CommunicationInfo.IpStr = Ip;//给IpStr赋值LED控制卡的IP
  257. CommunicationInfo.LedNumber = 1;//LED屏号为1,注意socket通讯和248通讯不识别屏号,默认赋1就行了,485必需根据屏的实际屏号进行赋值
  258. nResult = LedDll.LV_SetBasicInfo(ref CommunicationInfo, 2, 96, 64);//设置屏参,屏的颜色为2即为双基色,64为屏宽点数,32为屏高点数,具体函数参数说明见函数声明注示
  259. int hProgram;//节目句柄
  260. hProgram = LedDll.LV_CreateProgram(96, 64, 2);//根据传的参数创建节目句柄,128是屏宽点数,48是屏高点数,2是屏的颜色,注意此处屏宽高及颜色参数必需与设置屏参的屏宽高及颜色一致,否则发送时会提示错误
  261. //此处可自行判断有未创建成功,hProgram返回NULL失败,非NULL成功,一般不会失败
  262. nResult = LedDll.LV_AddProgram(hProgram, 1, 0, 1);//添加一个节目,参数说明见函数声明注示
  263. if (nResult != 0)
  264. {
  265. string ErrStr;
  266. ErrStr = LedDll.LS_GetError(nResult);
  267. return;
  268. }
  269. LedDll.AREARECT AreaRect = new LedDll.AREARECT();//区域坐标属性结构体变量
  270. AreaRect.left = 0;
  271. AreaRect.top = 0;
  272. AreaRect.width = 96;
  273. AreaRect.height = 64;
  274. LedDll.FONTPROP FontProp = new LedDll.FONTPROP();//文字属性
  275. FontProp.FontName = "宋体";
  276. FontProp.FontSize = 13;
  277. FontProp.FontColor = LedDll.COLOR_RED;
  278. FontProp.FontBold = 0;
  279. //int nsize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(LedDll.FONTPROP));
  280. nResult = LedDll.LV_AddImageTextArea(hProgram, 1, 2, ref AreaRect, 0);
  281. //nResult = LedDll.LV_QuickAddSingleLineTextArea(hProgram, 1, 2, ref AreaRect, LedDll.ADDTYPE_STRING, ledInfo, ref FontProp, 4);//快速通过字符添加一个单行文本区域,函数见函数声明注示
  282. nResult = LedDll.LV_AddStaticTextToImageTextArea(hProgram, 1, 2, LedDll.ADDTYPE_STRING, ledInfo, ref FontProp, 1, 2, 1);//快速通过字符添加一个单行文本区域,函数见函数声明注示
  283. nResult = LedDll.LV_Send(ref CommunicationInfo, hProgram);//发送,见函数声明注示
  284. LedDll.LV_DeleteProgram(hProgram);//删除节目内存对象,详见函数声明注示
  285. if (nResult != 0)//如果失败则可以调用LV_GetError获取中文错误信息
  286. {
  287. string ErrStr;
  288. ErrStr = LedDll.LS_GetError(nResult);
  289. }
  290. else
  291. {
  292. //"发送成功";
  293. }
  294. lg.WriteLog(26, "led推送信息结束时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff"));
  295. }
  296. catch (Exception ex)
  297. {
  298. lg.WriteLog(25, PbCache.lockCarNo + "led_trycatch事件异常:" + ex.Message);
  299. }
  300. }
  301. public void setStatic4LineMsg(string Ip, string ledInfo)
  302. {
  303. string info1 = "";
  304. string info2 = "";
  305. string info3 = "";
  306. string info4 = "";
  307. //split ledInfo
  308. string[] list = ledInfo.Split(',');
  309. for (int i = 0; i < list.Length; i++)
  310. {
  311. if (i == 0) info1 = list[0];
  312. if (i == 1) info2 = list[1];
  313. if (i == 2) info3 = list[2];
  314. if (i == 3) info4 = list[3];
  315. }
  316. int nResult;
  317. LedDll.COMMUNICATIONINFO CommunicationInfo = new LedDll.COMMUNICATIONINFO();//定义一通讯参数结构体变量用于对设定的LED通讯,具体对此结构体元素赋值说明见COMMUNICATIONINFO结构体定义部份注示
  318. CommunicationInfo.SendType = 0;//设为固定IP通讯模式,即TCP通讯
  319. CommunicationInfo.IpStr = Ip;//给IpStr赋值LED控制卡的IP
  320. CommunicationInfo.LedNumber = 1;//LED屏号为1,注意socket通讯和248通讯不识别屏号,默认赋1就行了,485必需根据屏的实际屏号进行赋值
  321. nResult = LedDll.LV_SetBasicInfo(ref CommunicationInfo, 2, 192, 64);//设置屏参,屏的颜色为2即为双基色,64为屏宽点数,32为屏高点数,具体函数参数说明见函数声明注示
  322. int hProgram;//节目句柄
  323. hProgram = LedDll.LV_CreateProgram(192, 64, 2);//根据传的参数创建节目句柄,128是屏宽点数,48是屏高点数,2是屏的颜色,注意此处屏宽高及颜色参数必需与设置屏参的屏宽高及颜色一致,否则发送时会提示错误
  324. //此处可自行判断有未创建成功,hProgram返回NULL失败,非NULL成功,一般不会失败
  325. nResult = LedDll.LV_AddProgram(hProgram, 1, 0, 1);//添加一个节目,参数说明见函数声明注示
  326. if (nResult != 0)
  327. {
  328. string ErrStr;
  329. ErrStr = LedDll.LS_GetError(nResult);
  330. return;
  331. }
  332. LedDll.AREARECT AreaRect = new LedDll.AREARECT();//区域坐标属性结构体变量
  333. AreaRect.left = 0;
  334. AreaRect.top = 0;
  335. AreaRect.width = 192;
  336. AreaRect.height = 16;
  337. //nResult = LedDll.LV_QuickAddSingleLineTextArea(hProgram, 1, 2, ref AreaRect, LedDll.ADDTYPE_STRING, ledInfo, ref FontProp, 4);//快速通过字符添加一个单行文本区域,函数见函数声明注示
  338. LedDll.FONTPROP FontProp = new LedDll.FONTPROP();//文字属性
  339. FontProp.FontName = "宋体";
  340. FontProp.FontSize = 10;
  341. FontProp.FontColor = LedDll.COLOR_RED;
  342. FontProp.FontBold = 0;
  343. //int nsize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(LedDll.FONTPROP));
  344. nResult = LedDll.LV_AddImageTextArea(hProgram, 1, 2, ref AreaRect, 0);
  345. nResult = LedDll.LV_AddStaticTextToImageTextArea(hProgram, 1, 2, LedDll.ADDTYPE_STRING, ledInfo, ref FontProp, 1, 2, 1);//快速通过字符添加一个单行文本区域,函数见函数声明注示
  346. AreaRect.left = 0;
  347. AreaRect.top = 16;
  348. AreaRect.width = 192;
  349. AreaRect.height = 16;
  350. nResult = LedDll.LV_AddStaticTextToImageTextArea(hProgram, 1, 2, LedDll.ADDTYPE_STRING, info2, ref FontProp, 1, 2, 1);//快速通过字符添加一个单行文本区域,函数见函数声明注示
  351. AreaRect.left = 0;
  352. AreaRect.top = 32;
  353. AreaRect.width = 192;
  354. AreaRect.height = 16;
  355. nResult = LedDll.LV_AddStaticTextToImageTextArea(hProgram, 1, 2, LedDll.ADDTYPE_STRING, info3, ref FontProp, 1, 2, 1);//快速通过字符添加一个单行文本区域,函数见函数声明注示
  356. AreaRect.left = 0;
  357. AreaRect.top = 48;
  358. AreaRect.width = 192;
  359. AreaRect.height = 16;
  360. nResult = LedDll.LV_AddStaticTextToImageTextArea(hProgram, 1, 2, LedDll.ADDTYPE_STRING, info4, ref FontProp, 1, 2, 1);//快速通过字符添加一个单行文本区域,函数见函数声明注示
  361. nResult = LedDll.LV_Send(ref CommunicationInfo, hProgram);//发送,见函数声明注示
  362. LedDll.LV_DeleteProgram(hProgram);//删除节目内存对象,详见函数声明注示
  363. if (nResult != 0)//如果失败则可以调用LV_GetError获取中文错误信息
  364. {
  365. string ErrStr;
  366. ErrStr = LedDll.LS_GetError(nResult);
  367. }
  368. else
  369. {
  370. //"发送成功";
  371. }
  372. }
  373. #endregion
  374. }
  375. }