CSpecialGrayRangeParam.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. using OTSDataType;
  2. using OTSModelSharp;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.IO;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Xml;
  10. namespace OTSMeasureApp._0_OTSModel.Measure.ParamData
  11. {
  12. public class CSpecialGrayRange:ISlo
  13. {
  14. public CIntRange range=new CIntRange();
  15. public CIntRange diameterRange = new CIntRange();
  16. public bool ifCollectXray;
  17. public override void Serialize(bool isStoring, XmlDocument classDoc, XmlNode rootNode)
  18. {
  19. xInt xStart = new xInt();
  20. xInt xEnd = new xInt();
  21. xInt xdiaStart = new xInt();
  22. xInt xdiaEnd = new xInt();
  23. xBool xIfXray = new xBool();
  24. Slo slo = new Slo();
  25. slo.Register("start", xStart);
  26. slo.Register("end", xEnd);
  27. slo.Register("diameterStart", xdiaStart);
  28. slo.Register("diameterEnd", xdiaEnd);
  29. slo.Register("collectXray", xIfXray);
  30. if (isStoring)
  31. {
  32. xStart.AssignValue(range.GetStart());
  33. xEnd.AssignValue(range.GetEnd());
  34. xdiaStart.AssignValue(diameterRange.GetStart());
  35. xdiaEnd.AssignValue(diameterRange.GetEnd());
  36. xIfXray.AssignValue(ifCollectXray);
  37. slo.Serialize(true, classDoc, rootNode);
  38. }
  39. else
  40. {
  41. slo.Serialize(false, classDoc, rootNode);
  42. range.SetStart(xStart.value());
  43. range.SetEnd(xEnd.value());
  44. diameterRange.SetStart(xdiaStart.value());
  45. diameterRange.SetEnd(xdiaEnd.value());
  46. ifCollectXray = xIfXray.value();
  47. }
  48. }
  49. }
  50. public class CSpecialGrayRangeParam: ISlo
  51. {
  52. const string STRSPECIALGRAYCONFIGFILE = "SpecialGrayConfig.xml";
  53. private List<CSpecialGrayRange> Ranges=new List<CSpecialGrayRange>();
  54. private bool isToRun;
  55. public static string GetParamFileFullName()
  56. {
  57. String path = ".\\" + DataPublic.STR_COFIGPATH + "\\" + DataPublic.STR_SYSTEM_DATA + "\\" + STRSPECIALGRAYCONFIGFILE;
  58. return path;
  59. }
  60. public bool IsToRun { get => isToRun; set => isToRun = value; }
  61. public List<CSpecialGrayRange> GetIntRanges()
  62. {
  63. return Ranges;
  64. }
  65. public void SetIntRanges(List<CSpecialGrayRange> value)
  66. {
  67. Ranges = value;
  68. }
  69. public override void Serialize(bool isStoring, XmlDocument classDoc, XmlNode rootNode)
  70. {
  71. Collection<CSpecialGrayRange> xRangelist = new Collection<CSpecialGrayRange>();
  72. xBool xtoRun = new xBool();
  73. Slo slo = new Slo();
  74. slo.Register("ToRun", xtoRun);
  75. slo.Register("GrayRangeList", xRangelist);
  76. if (isStoring)
  77. {
  78. xtoRun.AssignValue(isToRun);
  79. for (int i = 0; i < Ranges.Count; i++)
  80. {
  81. xRangelist.addItem(Ranges[i]);
  82. }
  83. slo.Serialize(true, classDoc, rootNode);
  84. }
  85. else
  86. {
  87. slo.Serialize(false, classDoc, rootNode);
  88. isToRun = xtoRun.value();
  89. Ranges.Clear();
  90. for (int i = 0; i < xRangelist.size(); i++)
  91. {
  92. Ranges.Add(xRangelist.getItem(i));
  93. }
  94. }
  95. }
  96. public bool LoadParam()
  97. {
  98. String path = ".\\" + DataPublic.STR_COFIGPATH + "\\" + DataPublic.STR_SYSTEM_DATA + "\\"+ STRSPECIALGRAYCONFIGFILE;
  99. // 5. check if the stage file exist
  100. if (File.Exists(path))
  101. {// the stage file exist
  102. XmlDocument doc = new XmlDocument();
  103. //载入xml文件
  104. doc.Load(path);
  105. XmlNode root = doc.SelectSingleNode("XMLData");
  106. Serialize(false, doc, root);
  107. return true;
  108. }
  109. return false;
  110. }
  111. }
  112. }