CBrightnessContrastRegulateParam.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 override void Serialize(bool isStoring, XmlDocument classDoc, XmlNode rootNode)
  35. {
  36. xInt xbrphasevalue = new xInt();
  37. xInt xdarkphasevalue = new xInt();
  38. xInt xmag= new xInt();
  39. xString xbrphaseelement = new xString();
  40. xString xdarkphaseelement = new xString();
  41. xPoint xStart = new xPoint();
  42. xBool xtorun = new xBool();
  43. xDouble xinitialBrightness = new xDouble(this.initialBrightness);
  44. xDouble xinitialContrast = new xDouble(this.initialContrast);
  45. xInt xPeriod = new xInt(this.period);
  46. xString xAutoRegulateType = new xString(this.autoRegulateType.ToString());
  47. Slo slo = new Slo();
  48. slo.Register("ToRun", xtorun);
  49. slo.Register("BrightPhaseElement", xbrphaseelement);
  50. slo.Register("BrightPhaseValue", xbrphasevalue);
  51. slo.Register("DarkPhaseElement", xdarkphaseelement);
  52. slo.Register("DarkPhaseValue", xdarkphasevalue);
  53. slo.Register("mag", xmag);
  54. slo.Register("InitialBrightness", xinitialBrightness);
  55. slo.Register("InitialContrast", xinitialContrast);
  56. slo.Register("StdMaterialOTSPos", xStart);
  57. slo.Register("Period", xPeriod);
  58. slo.Register("AutoRegulateType", xAutoRegulateType);
  59. if (isStoring)
  60. {
  61. xStart.AssignValue(stdMaterialOTSPos);
  62. xbrphaseelement.AssignValue(brightphaseelement);
  63. xbrphasevalue.AssignValue(brightphaseGrayvalue);
  64. xdarkphaseelement.AssignValue(darkphaseelement);
  65. xdarkphasevalue.AssignValue(darkphaseGrayvalue);
  66. xmag.AssignValue(mag);
  67. xtorun.AssignValue(toRun);
  68. xinitialBrightness.AssignValue(initialBrightness);
  69. xinitialContrast.AssignValue(initialContrast);
  70. xPeriod.AssignValue(period);
  71. xAutoRegulateType.AssignValue(autoRegulateType.ToString());
  72. slo.Serialize(true, classDoc, rootNode);
  73. }
  74. else
  75. {
  76. slo.Serialize(false, classDoc, rootNode);
  77. stdMaterialOTSPos = xStart.value();
  78. brightphaseelement = xbrphaseelement.value();
  79. brightphaseGrayvalue = xbrphasevalue.value();
  80. darkphaseelement = xdarkphaseelement.value();
  81. darkphaseGrayvalue = xdarkphasevalue.value();
  82. mag = xmag.value();
  83. toRun = xtorun.value();
  84. initialBrightness = xinitialBrightness.value();
  85. initialContrast = xinitialContrast.value();
  86. period = xPeriod.value();
  87. autoRegulateType = (AutoRegulateType)Enum.Parse(typeof(AutoRegulateType), xAutoRegulateType.value(), true);
  88. }
  89. }
  90. }
  91. }