CSpecialGrayRangeParam.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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 bool ifCollectXray;
  16. public override void Serialize(bool isStoring, XmlDocument classDoc, XmlNode rootNode)
  17. {
  18. xInt xStart = new xInt();
  19. xInt xEnd = new xInt();
  20. xBool xIfXray = new xBool();
  21. Slo slo = new Slo();
  22. slo.Register("start", xStart);
  23. slo.Register("end", xEnd);
  24. slo.Register("collectXray", xIfXray);
  25. if (isStoring)
  26. {
  27. xStart.AssignValue(range.GetStart());
  28. xEnd.AssignValue(range.GetEnd());
  29. xIfXray.AssignValue(ifCollectXray);
  30. slo.Serialize(true, classDoc, rootNode);
  31. }
  32. else
  33. {
  34. slo.Serialize(false, classDoc, rootNode);
  35. range.SetStart(xStart.value());
  36. range.SetEnd(xEnd.value());
  37. ifCollectXray = xIfXray.value();
  38. }
  39. }
  40. }
  41. public class CSpecialGrayRangeParam: ISlo
  42. {
  43. const string STRSPECIALGRAYCONFIGFILE = "SpecialGrayConfig.xml";
  44. private List<CSpecialGrayRange> Ranges=new List<CSpecialGrayRange>();
  45. private bool isToRun;
  46. public static string GetParamFileFullName()
  47. {
  48. String path = ".\\" + DataPublic.STR_COFIGPATH + "\\" + DataPublic.STR_SYSTEM_DATA + "\\" + STRSPECIALGRAYCONFIGFILE;
  49. return path;
  50. }
  51. public bool IsToRun { get => isToRun; set => isToRun = value; }
  52. public List<CSpecialGrayRange> GetIntRanges()
  53. {
  54. return Ranges;
  55. }
  56. public void SetIntRanges(List<CSpecialGrayRange> value)
  57. {
  58. Ranges = value;
  59. }
  60. public override void Serialize(bool isStoring, XmlDocument classDoc, XmlNode rootNode)
  61. {
  62. Collection<CSpecialGrayRange> xRangelist = new Collection<CSpecialGrayRange>();
  63. xBool xtoRun = new xBool();
  64. Slo slo = new Slo();
  65. slo.Register("ToRun", xtoRun);
  66. slo.Register("GrayRangeList", xRangelist);
  67. if (isStoring)
  68. {
  69. xtoRun.AssignValue(isToRun);
  70. for (int i = 0; i < Ranges.Count; i++)
  71. {
  72. xRangelist.addItem(Ranges[i]);
  73. }
  74. slo.Serialize(true, classDoc, rootNode);
  75. }
  76. else
  77. {
  78. slo.Serialize(false, classDoc, rootNode);
  79. isToRun = xtoRun.value();
  80. Ranges.Clear();
  81. for (int i = 0; i < xRangelist.size(); i++)
  82. {
  83. Ranges.Add(xRangelist.getItem(i));
  84. }
  85. }
  86. }
  87. public bool LoadParam()
  88. {
  89. String path = ".\\" + DataPublic.STR_COFIGPATH + "\\" + DataPublic.STR_SYSTEM_DATA + "\\"+ STRSPECIALGRAYCONFIGFILE;
  90. // 5. check if the stage file exist
  91. if (File.Exists(path))
  92. {// the stage file exist
  93. XmlDocument doc = new XmlDocument();
  94. //载入xml文件
  95. doc.Load(path);
  96. XmlNode root = doc.SelectSingleNode("XMLData");
  97. Serialize(false, doc, root);
  98. return true;
  99. }
  100. return false;
  101. }
  102. }
  103. }