CBrightnessContrastRegulateParam.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. using OTSDataType;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Drawing;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Xml;
  9. namespace OTSMeasureApp._0_OTSModel.OTSDataType
  10. {
  11. public enum AutoRegulateType
  12. {
  13. EveryPeriod = 0,
  14. EverySample = 1
  15. }
  16. internal class CBrightnessContrastRegulateParam:ISlo
  17. {
  18. public CBrightnessContrastRegulateParam()
  19. {
  20. brightphaseGrayvalue = 0;
  21. darkphaseGrayvalue = 0;
  22. }
  23. public Point stdMaterialOTSPos = new Point();
  24. public int brightphaseGrayvalue;
  25. public string brightphaseelement = "";
  26. public int darkphaseGrayvalue;
  27. public string darkphaseelement = "";
  28. public int mag = 100; //放大倍数
  29. public double initialBrightness;
  30. public double initialContrast;
  31. public int period = 60;//minutes to run the regulation
  32. public AutoRegulateType autoRegulateType = AutoRegulateType.EveryPeriod; //自动调节类型
  33. public bool toRun = false;
  34. public double workingDistance = 10.0;
  35. public override void Serialize(bool isStoring, XmlDocument classDoc, XmlNode rootNode)
  36. {
  37. xInt xbrphasevalue = new xInt();
  38. xInt xdarkphasevalue = new xInt();
  39. xInt xmag= new xInt();
  40. xString xbrphaseelement = new xString();
  41. xString xdarkphaseelement = new xString();
  42. xPoint xStart = new xPoint();
  43. xBool xtorun = new xBool();
  44. xDouble xinitialBrightness = new xDouble(this.initialBrightness);
  45. xDouble xinitialContrast = new xDouble(this.initialContrast);
  46. xInt xPeriod = new xInt(this.period);
  47. xString xAutoRegulateType = new xString(this.autoRegulateType.ToString());
  48. xDouble xworkingDistance = new xDouble(this.workingDistance);
  49. Slo slo = new Slo();
  50. slo.Register("ToRun", xtorun);
  51. slo.Register("BrightPhaseElement", xbrphaseelement);
  52. slo.Register("BrightPhaseValue", xbrphasevalue);
  53. slo.Register("DarkPhaseElement", xdarkphaseelement);
  54. slo.Register("DarkPhaseValue", xdarkphasevalue);
  55. slo.Register("mag", xmag);
  56. slo.Register("InitialBrightness", xinitialBrightness);
  57. slo.Register("InitialContrast", xinitialContrast);
  58. slo.Register("StdMaterialOTSPos", xStart);
  59. slo.Register("Period", xPeriod);
  60. slo.Register("AutoRegulateType", xAutoRegulateType);
  61. slo.Register("WorkingDistance", xworkingDistance);
  62. if (isStoring)
  63. {
  64. xStart.AssignValue(stdMaterialOTSPos);
  65. xbrphaseelement.AssignValue(brightphaseelement);
  66. xbrphasevalue.AssignValue(brightphaseGrayvalue);
  67. xdarkphaseelement.AssignValue(darkphaseelement);
  68. xdarkphasevalue.AssignValue(darkphaseGrayvalue);
  69. xmag.AssignValue(mag);
  70. xtorun.AssignValue(toRun);
  71. xinitialBrightness.AssignValue(initialBrightness);
  72. xinitialContrast.AssignValue(initialContrast);
  73. xPeriod.AssignValue(period);
  74. xAutoRegulateType.AssignValue(autoRegulateType.ToString());
  75. xworkingDistance.AssignValue(workingDistance);
  76. slo.Serialize(true, classDoc, rootNode);
  77. }
  78. else
  79. {
  80. slo.Serialize(false, classDoc, rootNode);
  81. stdMaterialOTSPos = xStart.value();
  82. brightphaseelement = xbrphaseelement.value();
  83. brightphaseGrayvalue = xbrphasevalue.value();
  84. darkphaseelement = xdarkphaseelement.value();
  85. darkphaseGrayvalue = xdarkphasevalue.value();
  86. mag = xmag.value();
  87. toRun = xtorun.value();
  88. initialBrightness = xinitialBrightness.value();
  89. initialContrast = xinitialContrast.value();
  90. period = xPeriod.value();
  91. autoRegulateType = (AutoRegulateType)Enum.Parse(typeof(AutoRegulateType), xAutoRegulateType.value(), true);
  92. workingDistance = xworkingDistance.value();
  93. }
  94. }
  95. }
  96. }