Просмотр исходного кода

add Serialize in COTSGeneralParameters

CXS 5 лет назад
Родитель
Сommit
c61bac1c1a

+ 41 - 11
OTS/OTSIncAMeasureApp/SourceGridStringProvider/XMLSerialization.cs

@@ -16,7 +16,6 @@ namespace OTSIncAMeasureApp.SourceGridStringProvider
     {
         void Serialize(bool isStoring, XmlDocument xml, XmlNode rootNode);
     }
-
     public class MemberBase
     {
         const string RootClassName = "XMLData";
@@ -60,6 +59,10 @@ namespace OTSIncAMeasureApp.SourceGridStringProvider
             return value;
         }
         //xInt operator=(const int value) { AssignValue(value); return *this; };  //c#不可以重载=
+        public static implicit operator xInt(int value)
+        {
+            return new xInt(value);
+        }
     }
 
     public class xDouble : MemberBase
@@ -74,8 +77,15 @@ namespace OTSIncAMeasureApp.SourceGridStringProvider
             return value;
         }
         //xDouble operator=(const double value) { AssignValue(value); return *this; }; //c#不可以重载=
+        public static implicit operator xDouble(double value)
+        {
+            return new xDouble(value);
+        }
     }
 
+
+
+
     public class xLong : MemberBase
     {
         public void AssignValue(long value) { m_sValue = value.ToString(); }   //因为c#无=重载,所以修改为public            public xLong() { AssignValue(0); }
@@ -88,6 +98,10 @@ namespace OTSIncAMeasureApp.SourceGridStringProvider
             return value;
         }
         //xLong operator=(const long value) { AssignValue(value); return *this; };  //c#不可以重载=
+        public static implicit operator xLong(long value)
+        {
+            return new xLong(value);
+        }
     }
 
     public class xDWORD : MemberBase
@@ -102,6 +116,10 @@ namespace OTSIncAMeasureApp.SourceGridStringProvider
             return value;
         }
         //xDWORD operator=(const DWORD value) { AssignValue(value); return *this; };
+        public static implicit operator xDWORD(uint value)
+        {
+            return new xDWORD(value);
+        }
     }
 
     public class xBool : MemberBase
@@ -127,7 +145,7 @@ namespace OTSIncAMeasureApp.SourceGridStringProvider
         }
     }
 
-    public class xTime_t : MemberBase                
+    public class xTime_t : MemberBase
     {
         public void AssignValue(DateTime value)     //因为c#无=重载,所以修改为public
         {
@@ -147,6 +165,10 @@ namespace OTSIncAMeasureApp.SourceGridStringProvider
             return Convert.ToDateTime(m_sValue);
         }
         //xTime_t operator=(const time_t value) { AssignValue(value); return *this; };
+        public static implicit operator xTime_t(DateTime value)
+        {
+            return new xTime_t(value);
+        }
     }
 
     //   class __declspec(dllexport) xOleDateTime : public MemberBase  //COleDateTime对应c#类型?统一改为time_t
@@ -161,7 +183,7 @@ namespace OTSIncAMeasureApp.SourceGridStringProvider
     //         xOleDateTime operator=(const COleDateTime value) { AssignValue(value); return *this; };
     //   };
 
-    public class xOleDateTimeSpan : MemberBase   
+    public class xOleDateTimeSpan : MemberBase
     {
         public void AssignValue(TimeSpan value)        //因为c#无=重载,所以修改为public
         {
@@ -180,6 +202,10 @@ namespace OTSIncAMeasureApp.SourceGridStringProvider
         }
 
         //xOleDateTimeSpan operator=(const COleDateTimeSpan value) { AssignValue(value); return *this; };
+        public static implicit operator xOleDateTimeSpan(TimeSpan value)
+        {
+            return new xOleDateTimeSpan(value);
+        }
     };
 
     public class xRect : MemberBase
@@ -307,6 +333,10 @@ namespace OTSIncAMeasureApp.SourceGridStringProvider
             return p;
         }
         //xPoint operator=(const CPoint value) { AssignValue(value); return *this; };
+        public static implicit operator xPoint(System.Drawing.Point value)
+        {
+            return new xPoint(value);
+        }
     };
 
 
@@ -340,7 +370,7 @@ namespace OTSIncAMeasureApp.SourceGridStringProvider
         create new element of type T
         @return empty object of type T
         */
-        public override ISlo newElement() 
+        public override ISlo newElement()
         {
             T newItem = System.Activator.CreateInstance<T>();
             //T newItem = default(T);
@@ -380,7 +410,7 @@ namespace OTSIncAMeasureApp.SourceGridStringProvider
 
     //typedef std::vector<Slo*>::iterator  __declspec(dllexport) SerializableIterator;  //iterator?
 
-    public class Slo: ISlo
+    public class Slo : ISlo
     {
         //private (Slo const &s) { }
         //private Slo operator=(Slo const &s) { return *this; };
@@ -399,8 +429,8 @@ namespace OTSIncAMeasureApp.SourceGridStringProvider
         public string m_sClassName;
         public string m_sVersion;
         public SortedDictionary<string, MemberBase> m_AttributeMappings = new SortedDictionary<string, MemberBase>();
-        public SortedDictionary<string, ISlo> m_MemberMappings=new SortedDictionary<string, ISlo>();
-        public SortedDictionary<string, CollectionBase<ISlo>> m_MemberCollections=new SortedDictionary<string, CollectionBase<ISlo>>();
+        public SortedDictionary<string, ISlo> m_MemberMappings = new SortedDictionary<string, ISlo>();
+        public SortedDictionary<string, CollectionBase<ISlo>> m_MemberCollections = new SortedDictionary<string, CollectionBase<ISlo>>();
 
         public void setClassName(string ClassName) { m_sClassName = ClassName; }
         public Slo()
@@ -448,18 +478,18 @@ namespace OTSIncAMeasureApp.SourceGridStringProvider
         }
 
 
-        public override void Serialize(bool isStoring, XmlDocument classDoc, XmlNode rootNode)
+        public override void Serialize(bool isStoring, XmlDocument xml, XmlNode rootNode)
         {
             if (isStoring)
             {
-                if (classDoc.DocumentElement != null)
+                if (xml.DocumentElement != null)
                 {
-                    toXML(classDoc, rootNode);
+                    toXML(xml, rootNode);
                 }
             }
             else
             {
-                fromXML(classDoc, rootNode);
+                fromXML(xml, rootNode);
             }
         }
         public void toXML(XmlDocument xml, XmlNode rootNode)

+ 88 - 1
OTS/OTSModelSharp/Measure/GetParam/OTSGeneralParameters.cs

@@ -4,10 +4,12 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using System.Xml;
+using static OTSDataType.otsdataconst;
 
 namespace OTSModelSharp
 {
-   public class COTSGeneralParameters
+   public class COTSGeneralParameters : ISlo
     {
         //--------------------definition-------------
         int m_StdLibTypeIndex;
@@ -241,5 +243,90 @@ namespace OTSModelSharp
         }
 
         public bool SetGenParam(COTSGeneralParameters GenParam) { return false; }
+
+        public override void Serialize(bool isStoring, XmlDocument classDoc, XmlNode rootNode)
+        {
+            xString xstrDefaultSampleName =new xString();
+            xBool xbMeasSwitch=new xBool();
+            xString xstrMeasParamFileFolderName=new xString();
+            xString xstrPartSTDLibFolderName=new xString();
+            xString xstrPartSTDLibFileName=new xString();
+            xInt xnStdLibTypeIndex=new xInt();
+            xInt xnMembraneType= new xInt();
+            xInt xnShape=new xInt();
+            xDouble xdArea=new xDouble();
+
+            xInt xnModel=new xInt();
+            xString xstrLaboratoty=new xString();
+            xString xstrAnalysisReferenceNumber=new xString();
+            xString xstrCustomerName=new xString();
+            xString xstrSampleName=new xString();
+            xString xstrSampleDescription=new xString();
+            xString xstrOperatorName=new xString();
+            xString xstrComment=new xString();
+
+            Slo slo = new Slo();
+            slo.Register("DefaultSampleName", xstrDefaultSampleName);
+            slo.Register("MeasSwitch", xbMeasSwitch);
+            slo.Register("MeasParamFileFolderName", xstrMeasParamFileFolderName);
+            slo.Register("PartSTDLibFolderName",xstrPartSTDLibFolderName);
+            slo.Register("STDLibTypeIndex",xnStdLibTypeIndex);
+            slo.Register("MembraneType",xnMembraneType);
+            slo.Register("DefaultShape",xnShape);
+            slo.Register("DefaultArea",xdArea);
+            slo.Register("MsrParam", m_DefaultMsrParam);
+
+            slo.Register("Model", xnModel);
+            slo.Register("Laboratoty",xstrLaboratoty);
+            slo.Register("AnalysisReferenceNumber",xstrAnalysisReferenceNumber);
+            slo.Register("CustomerName",xstrCustomerName);
+            slo.Register("SampleDescription",xstrSampleDescription);
+            slo.Register("OperatorName",xstrOperatorName);
+            slo.Register("Comment",xstrComment);
+
+            if (isStoring)
+            {
+                xstrDefaultSampleName.AssignValue(m_strDefaultSampleName);
+                xbMeasSwitch.AssignValue(m_bMeasSwitch);
+                xstrMeasParamFileFolderName.AssignValue(m_strMeasParamFileFolderName);
+                xstrPartSTDLibFolderName.AssignValue(m_strPartSTDLibFolderName);
+                xnStdLibTypeIndex.AssignValue(m_StdLibTypeIndex);
+                xnMembraneType.AssignValue((int)m_DefaultmembraneType);
+                xnShape.AssignValue((int)m_nDefaultShape);
+                xdArea.AssignValue(m_dDefaultArea);
+                xnModel.AssignValue(m_Model);
+                xstrLaboratoty.AssignValue(m_strLaboratoty);
+                xstrAnalysisReferenceNumber.AssignValue(m_strAnalysisReferenceNumber);
+                xstrCustomerName.AssignValue(m_strCustomerName);
+                xstrSampleDescription.AssignValue(m_strSampleDescription);
+                xstrOperatorName.AssignValue(m_strOperatorName);
+                xstrComment.AssignValue(m_strComment);
+
+                slo.Serialize(true, classDoc, rootNode);
+            }
+            else
+            {
+                slo.Serialize(false, classDoc, rootNode);
+
+                m_strDefaultSampleName = xstrDefaultSampleName.value();
+                m_bMeasSwitch = xbMeasSwitch.value();
+                m_strMeasParamFileFolderName = xstrMeasParamFileFolderName.value();
+                m_strPartSTDLibFolderName = xstrPartSTDLibFolderName.value();
+                m_StdLibTypeIndex = xnStdLibTypeIndex.value();
+                m_DefaultmembraneType = (MEMBRANE_TYPE)xnMembraneType.value();
+                m_nDefaultShape = (DOMAIN_SHAPE)xnShape.value();
+                m_dDefaultArea = xdArea.value();
+
+                m_Model = xnModel.value();
+                m_strLaboratoty = xstrLaboratoty.value();
+                m_strAnalysisReferenceNumber = xstrAnalysisReferenceNumber.value();
+                m_strCustomerName = xstrCustomerName.value();
+                m_strSampleDescription = xstrSampleDescription.value();
+                m_strOperatorName = xstrOperatorName.value();
+                m_strComment = xstrComment.value();
+            }
+        }
+
+
     }
 }

+ 4 - 5
OTS/OTSModelSharp/Measure/GetParam/OTSProgMgrParamFile.cs

@@ -674,11 +674,10 @@ namespace OTSModelSharp
 
             slo.Register("ProgMgrFileMark", xProgMgrFileMark);
             slo.Register("ProgMgrFileVersion", xProgMgrFileVersion);
-            slo.Register("StageData", m_pStageData);
-            slo.Register("GenParam", m_pGenParam);               
-            slo.Register("ImageScanParam", m_pImageScanParam);
-            slo.Register("ImageProcParam", m_pImageProcParam);
-            slo.Register("XrayParam", m_pXRayParam);
+
+            slo.Register("GenParam", m_pParam);               
+
+
             if (isStoring)
             {
                 xProgMgrFileMark.AssignValue(PROG_MGR_FILE_MARK);