123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- using OTSDataType;
- using OTSModelSharp;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Xml;
- namespace OTSMeasureApp._0_OTSModel.OTSDataType
- {
- public class CSpecialGrayRange:ISlo
- {
- public CIntRange range=new CIntRange();
- public CIntRange diameterRange = new CIntRange();
- public bool ifCollectXray;
-
- public override void Serialize(bool isStoring, XmlDocument classDoc, XmlNode rootNode)
- {
- xInt xStart = new xInt();
- xInt xEnd = new xInt();
- xInt xdiaStart = new xInt();
- xInt xdiaEnd = new xInt();
- xBool xIfXray = new xBool();
- Slo slo = new Slo();
- slo.Register("start", xStart);
- slo.Register("end", xEnd);
- slo.Register("diameterStart", xdiaStart);
- slo.Register("diameterEnd", xdiaEnd);
- slo.Register("collectXray", xIfXray);
- if (isStoring)
- {
- xStart.AssignValue(range.GetStart());
- xEnd.AssignValue(range.GetEnd());
- xdiaStart.AssignValue(diameterRange.GetStart());
- xdiaEnd.AssignValue(diameterRange.GetEnd());
- xIfXray.AssignValue(ifCollectXray);
- slo.Serialize(true, classDoc, rootNode);
- }
- else
- {
- slo.Serialize(false, classDoc, rootNode);
- range.SetStart(xStart.value());
- range.SetEnd(xEnd.value());
- diameterRange.SetStart(xdiaStart.value());
- diameterRange.SetEnd(xdiaEnd.value());
- ifCollectXray = xIfXray.value();
- }
- }
- }
- public class CSpecialGrayRangeParam: ISlo
- {
- const string STRSPECIALGRAYCONFIGFILE = "SpecialGrayConfig.xml";
- private List<CSpecialGrayRange> Ranges=new List<CSpecialGrayRange>();
- private bool isToRun=false;
- private bool isInited=false;
- public CSpecialGrayRangeParam()
- {
- }
- public static string GetParamFileFullName()
- {
- String path = ".\\" + DataPublic.STR_COFIGPATH + "\\" + DataPublic.STR_SYSTEM_DATA + "\\" + STRSPECIALGRAYCONFIGFILE;
- return path;
- }
-
- public bool GetIsToRun()
- {
- if (isInited == false)
- {
- LoadParam();
- isInited = true;
- }
- return isToRun;
- }
- public void SetIsToRun(bool value)
- {
- isToRun = value;
- }
- public bool IsInited { get => isInited; set => isInited = value; }
- public List<CSpecialGrayRange> GetSpecialGreyRanges()
- {
- if (isInited == false)
- {
- LoadParam();
- isInited = true;
- }
- return Ranges;
- }
- public void SetSpecailGrayRanges(List<CSpecialGrayRange> value)
- {
- Ranges = value;
- }
- public override void Serialize(bool isStoring, XmlDocument classDoc, XmlNode rootNode)
- {
-
- Collection<CSpecialGrayRange> xRangelist = new Collection<CSpecialGrayRange>();
- xBool xtoRun = new xBool();
-
- Slo slo = new Slo();
- slo.Register("ToRun", xtoRun);
- slo.Register("GrayRangeList", xRangelist);
- if (isStoring)
- {
- xtoRun.AssignValue(isToRun);
- for (int i = 0; i < Ranges.Count; i++)
- {
- xRangelist.addItem(Ranges[i]);
- }
-
- slo.Serialize(true, classDoc, rootNode);
- }
- else
- {
- slo.Serialize(false, classDoc, rootNode);
- isToRun = xtoRun.value();
- Ranges.Clear();
- for (int i = 0; i < xRangelist.size(); i++)
- {
- Ranges.Add(xRangelist.getItem(i));
- }
- }
- }
- public bool LoadParam()
- {
-
- String path = ".\\" + DataPublic.STR_COFIGPATH + "\\" + DataPublic.STR_SYSTEM_DATA + "\\"+ STRSPECIALGRAYCONFIGFILE;
- // 5. check if the stage file exist
- if (File.Exists(path))
- {// the stage file exist
-
- XmlDocument doc = new XmlDocument();
- //载入xml文件
- doc.Load(path);
- XmlNode root = doc.SelectSingleNode("XMLData");
- Serialize(false, doc, root);
- isInited = true;
- return true;
- }
- return false;
- }
- }
- }
|