ProgramBase.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading;
  6. using HNWD.Pregrant.Common;
  7. using HNWD.Pregrant.DataAccess;
  8. using HNWD.Pregrant.Model;
  9. namespace HNWD.LatticeScreen.Server
  10. {
  11. internal abstract class ProgramBase
  12. {
  13. protected WD_ProgramInfoDataAccess wd_ProgramInfoDataAccess = WD_ProgramInfoDataAccess.GetInstance();
  14. protected LedLatticeScreen ledLatticeScreen;
  15. protected WD_ProgramInfo wd_ProgramInfo;
  16. protected uint AlignMode = 0;
  17. protected uint FormatMode = 0;
  18. public string CallId = string.Empty;
  19. public long addTime = DateTime.Now.Ticks;
  20. protected int responseByLedCommand = 0;
  21. public bool bSuccess = true;
  22. public string Msg = "操作成功";
  23. public ProgramBase()
  24. {
  25. }
  26. protected bool ProgramIsNull
  27. {
  28. get { return this.wd_ProgramInfo == null ? true : false; }
  29. }
  30. public virtual void SetEntity(WD_ProgramInfo wd_ProgramInfo)
  31. {
  32. this.wd_ProgramInfo = wd_ProgramInfo;
  33. }
  34. public virtual WD_ProgramInfo GetEntity()
  35. {
  36. return this.wd_ProgramInfo;
  37. }
  38. /// <summary>
  39. /// 带刷屏显示
  40. /// </summary>
  41. /// <param name="state"></param>
  42. public abstract void PlayWithErase();
  43. /// <summary>
  44. /// 不带刷屏显示
  45. /// </summary>
  46. /// <param name="state"></param>
  47. public abstract void PlayWithoutErase();
  48. protected void GetTextAlignMode(string index)
  49. {
  50. List<string> listAlign = new List<string>();
  51. listAlign.Add("水平左垂直上对齐");
  52. listAlign.Add("水平左垂直中对齐");
  53. listAlign.Add("水平左垂直下对齐");
  54. listAlign.Add("水平中垂直上对齐");
  55. listAlign.Add("水平中垂直中对齐");
  56. listAlign.Add("水平中垂直下对齐");
  57. listAlign.Add("水平右垂直上对齐");
  58. listAlign.Add("水平右垂直中对齐");
  59. listAlign.Add("水平右垂直下对齐");
  60. string cn = listAlign[Convert.ToInt32(index)];
  61. TextProgramAlign tpa = TextProgramAlignList.GetList().Find(f => f.AlignName_CN == cn);
  62. this.AlignMode = TextProgramAlignList.GetValue(tpa.AlignName_EN);
  63. }
  64. protected void GetBitmapAlignMode(string index)
  65. {
  66. List<string> listAlign = new List<string>();
  67. listAlign.Add("水平左垂直上对齐");
  68. listAlign.Add("水平左垂直中对齐");
  69. listAlign.Add("水平左垂直下对齐");
  70. listAlign.Add("水平中垂直上对齐");
  71. listAlign.Add("水平中垂直中对齐");
  72. listAlign.Add("水平中垂直下对齐");
  73. listAlign.Add("水平右垂直上对齐");
  74. listAlign.Add("水平右垂直中对齐");
  75. listAlign.Add("水平右垂直下对齐");
  76. string cn = listAlign[Convert.ToInt32(index)];
  77. TextProgramAlign tpa = TextProgramAlignList.GetList().Find(f => f.AlignName_CN == cn);
  78. this.AlignMode = BitmapProgramAlignList.GetValue(tpa.AlignName_EN);
  79. }
  80. protected void GetClockFormatMode(string index)
  81. {
  82. List<string> listAlign = new List<string>();
  83. listAlign.Add("yyyy年MM月dd日HH时mm分ss秒");
  84. listAlign.Add("yyyy年MM月dd日");
  85. listAlign.Add("HH时mm分ss秒");
  86. string cn = listAlign[Convert.ToInt32(index)];
  87. TextProgramAlign tpa = ClockProgramFormatList.GetList().Find(f => f.AlignName_CN == cn);
  88. this.FormatMode = ClockProgramFormatList.GetValue(tpa.AlignName_EN);
  89. }
  90. protected virtual void ResponseMessage()
  91. {
  92. if (responseByLedCommand == LedControl.JR_OK)
  93. {
  94. this.Msg = "发送DrawText指令成功";
  95. this.bSuccess = true;
  96. }
  97. else
  98. {
  99. this.Msg = "发送DrawText指令失败, 错误代码:" + responseByLedCommand;
  100. this.bSuccess = false;
  101. }
  102. }
  103. protected virtual void ResponseMessage(bool bbitmap)
  104. {
  105. if (responseByLedCommand == LedControl.JR_OK)
  106. {
  107. this.Msg = "发送JHDrawMultPixel指令成功";
  108. this.bSuccess = true;
  109. }
  110. else
  111. {
  112. this.Msg = "发送JHDrawMultPixel指令失败, 错误代码:" + responseByLedCommand;
  113. this.bSuccess = false;
  114. }
  115. }
  116. }
  117. }