TPatchDetail.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. using MeterVision.Config;
  2. using MeterVision.model;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace MeterVision.db
  9. {
  10. public class TPatchDetail
  11. {
  12. public string PatchDetailId { get; set; }
  13. public string PatchId { get; set; }
  14. public string CreateTime { get; set; }
  15. public string StandDetailId { get; set; }
  16. public string StandValue { get; set; }
  17. public string SrcImage { get; set; }
  18. public int RunFlag { get; set; }
  19. public string RunTime { get; set; }
  20. public string DstImage { get; set; }
  21. public int MeterType { get; set; }
  22. public int DigitCount { get; set; }
  23. public int PointerCount { get; set; }
  24. public string LastUnit { get; set; }
  25. public int ResultType { get; set; }
  26. public string RawValue { get; set; }
  27. public string FinalValue { get; set; }
  28. public int EqualFlag { get; set; }
  29. public string AiVer { get; set; }
  30. public string DebugInfo { get; set; }
  31. public string LogPath { get; set; }
  32. public string Memo { get; set; }
  33. // 构造函数,初始化默认值
  34. public TPatchDetail()
  35. {
  36. PatchDetailId = string.Empty;
  37. PatchId = string.Empty;
  38. CreateTime = string.Empty;
  39. StandDetailId = string.Empty;
  40. StandValue = string.Empty;
  41. SrcImage = string.Empty;
  42. RunFlag = 0;
  43. RunTime = string.Empty;
  44. DstImage = string.Empty;
  45. MeterType = 0;
  46. DigitCount = 0;
  47. PointerCount = 0;
  48. LastUnit = string.Empty;
  49. ResultType = 0;
  50. RawValue = string.Empty;
  51. FinalValue = string.Empty;
  52. EqualFlag = 0;
  53. AiVer = string.Empty;
  54. DebugInfo = string.Empty;
  55. LogPath = string.Empty;
  56. Memo = string.Empty;
  57. }
  58. public TPatchDetail(PatchDetailItem patchDetail, ResultModel resultModel)
  59. {
  60. PatchDetailId = patchDetail.PatchDetailId;
  61. PatchId = patchDetail.PatchId;
  62. CreateTime = patchDetail.CreateTime;
  63. StandDetailId = patchDetail.StandDetailId;
  64. StandValue = patchDetail.StandValue;
  65. SrcImage = patchDetail.SrcImage;
  66. RunFlag = 1;
  67. RunTime = ThisApp.GetNowTime_yyyyMMddHHmmss();
  68. DstImage = resultModel.DstImage;
  69. //MeterType = resultModel.MeterType;
  70. LastUnit = resultModel.SLastUnit;
  71. ResultType = resultModel.ResultType;
  72. RawValue = resultModel.SRawValue;
  73. FinalValue = resultModel.sFinalValue;
  74. AiVer = resultModel.AiVer;
  75. LogPath = resultModel.LogPath;
  76. // 使用 LINQ 进行转换和条件判断
  77. var formattedBytes = resultModel.DebugInfoBytes.Select(b => b == 88 ? "" : b.ToString());
  78. DebugInfo = string.Join(",", formattedBytes);
  79. //EqualFlag,这里需要判断,是否相等、约等、不等
  80. //先简单判断
  81. if (string.IsNullOrWhiteSpace(StandValue))
  82. {
  83. EqualFlag = 2;
  84. }
  85. else
  86. {
  87. //EqualFlag = (FinalValue.Equals(StandValue) ? 1 : 0);
  88. EqualFlag = PatchDetailItem.CheckEquailityWithStandValue(StandValue, FinalValue) ? 1 : 0;
  89. }
  90. }
  91. //设置结果
  92. public void SetResult(ResultModel resultModel)
  93. {
  94. RunFlag = 1;
  95. RunTime = ThisApp.GetNowTime_yyyyMMddHHmmss();
  96. DstImage = resultModel.DstImage;
  97. MeterType = resultModel.MeterType;
  98. //DigitCount = resultModel.DigitCount;
  99. //PointerCount = resultModel.PointerCount;
  100. LastUnit = resultModel.SLastUnit;
  101. ResultType = resultModel.ResultType;
  102. RawValue = resultModel.SRawValue;
  103. FinalValue = resultModel.sFinalValue;
  104. AiVer = resultModel.AiVer;
  105. LogPath = resultModel.LogPath;
  106. // 使用 LINQ 进行转换和条件判断
  107. var formattedBytes = resultModel.DebugInfoBytes.Select(b => b == 88 ? "" : b.ToString());
  108. DebugInfo = string.Join(",", formattedBytes);
  109. //EqualFlag,这里需要判断,是否相等、约等、不等
  110. //先简单判断
  111. if (string.IsNullOrWhiteSpace(StandValue))
  112. {
  113. EqualFlag = 2;
  114. }
  115. else
  116. {
  117. //EqualFlag = (FinalValue.Equals(StandValue) ? 1 : 0);
  118. EqualFlag = PatchDetailItem.CheckEquailityWithStandValue(StandValue, FinalValue) ? 1 : 0;
  119. }
  120. }
  121. //----------------------------------------------
  122. //判读标准值与结果指是否相等
  123. public bool CheckEquaility()
  124. {
  125. bool blEqual = false;
  126. //ConfigItem config = ConfigItem.GetConfigItem();
  127. if(MeterType == 1)
  128. {
  129. //数字+指针
  130. }
  131. else if(MeterType == 2)
  132. {
  133. //全指针
  134. }
  135. else if(MeterType == 3)
  136. {
  137. //全数字
  138. }
  139. else
  140. {
  141. //非水表
  142. blEqual = false;
  143. }
  144. return blEqual;
  145. }
  146. }
  147. ////////////////////////////////////////////////////////////
  148. }