LED_Control.cs 24 KB

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