Browse Source

use FileManager in measure thread

HaoShuang 5 years ago
parent
commit
934d88c585

+ 9 - 10
FileManager/Serialize.cs

@@ -294,7 +294,7 @@ namespace FileManager
 
 
     //typedef std::map<std::string, CollectionBase*>::iterator __declspec(dllexport) CollectionIterator;  ???
-    public abstract class CollectionBase<T>
+    public abstract class CollectionBase<ISlo>
     {
         private string m_sCollectionName;
         private string m_sCollectionClassType;
@@ -304,7 +304,7 @@ namespace FileManager
         public SortedDictionary<ISlo, bool> m_mOwner = new SortedDictionary<ISlo, bool>();   //map<ISlo*, bool> ??
         public void setCollectionName(string value) { m_sCollectionName = value; }
         public void setCollectionClassType(string value) { m_sCollectionClassType = value; }
-        public abstract T newElement();
+        public abstract ISlo newElement();
         public string getCollectionName() { return m_sCollectionName; }
         public int size() { return m_vCollection.Count(); }
         public ISlo getItem(int itemID) { return m_vCollection[itemID]; }
@@ -317,13 +317,13 @@ namespace FileManager
         }
     }
 
-    public class Collection<T> : CollectionBase<T>
+    public class Collection<T> : CollectionBase<ISlo>
     {
         /**
         create new element of type T
         @return empty object of type T
         */
-        public override T newElement()
+        public override ISlo newElement()
         {
             T newItem = System.Activator.CreateInstance<T>();
             //T newItem = default(T);
@@ -335,8 +335,8 @@ namespace FileManager
             //I change this value to be false forever(gsp).No matter what case there's no need to set the object's owner to the collection
             //after we created the object we'll put them to in a smartpointer.then the smartpointer will manage it.
             //m_mOwner[sIo] = false;//m_mOwner[newItem]=true 
-            Type type = newItem.GetType();
-            return newItem;
+            //Type type = newItem.GetType();
+            return sIo;
         }
 
         public void addItem(T item)
@@ -363,7 +363,7 @@ namespace FileManager
 
     //typedef std::vector<Slo*>::iterator  __declspec(dllexport) SerializableIterator;  //iterator?
 
-    public class Slo<T> : ISlo
+    public class Slo : ISlo
     {
         //private (Slo const &s) { }
         //private Slo operator=(Slo const &s) { return *this; };
@@ -383,7 +383,7 @@ namespace FileManager
         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<T>> m_MemberCollections = new SortedDictionary<string, CollectionBase<T>>();
+        public SortedDictionary<string, CollectionBase<ISlo>> m_MemberCollections = new SortedDictionary<string, CollectionBase<ISlo>>();
 
         public void setClassName(string ClassName) { m_sClassName = ClassName; }
         public Slo()
@@ -424,13 +424,12 @@ namespace FileManager
          @SubclassCollection Collection to register
          @return void
         */
-        public void Register(string CollectionName, CollectionBase<T> SubclassCollection)
+        public void Register(string CollectionName, CollectionBase<ISlo> SubclassCollection)
         {
             SubclassCollection.setCollectionName(CollectionName);
             m_MemberCollections[CollectionName] = SubclassCollection;
         }
 
-
         public override void Serialize(bool isStoring, XmlDocument xml, XmlNode rootNode)
         {
             if (isStoring)

+ 2 - 2
MeasureData/CutHole.cs

@@ -128,7 +128,7 @@ namespace MeasureData
         public override void Serialize(bool isStoring, XmlDocument xml, XmlNode rootNode)
         {
 
-            Slo<CutHole> slo_cuthole = new Slo<CutHole>();
+            Slo slo_cuthole = new Slo();
 
             xString regName = new xString();
             regName.AssignValue("CutHole");
@@ -139,7 +139,7 @@ namespace MeasureData
             SampleName.AssignValue(this.HoleName);
             slo_cuthole.Register("SampleName", SampleName);
 
-            Slo<SemPosition> slo_sp = new Slo<SemPosition>();
+            Slo slo_sp = new Slo();
             xDouble ptx = new xDouble();
             ptx.AssignValue(this.Position.X);
             slo_sp.Register("X", ptx);

+ 16 - 20
MeasureData/MeasureFile.cs

@@ -80,42 +80,38 @@ namespace MeasureData
         //样品孔存储xml文档
         public override void Serialize(bool isStoring, XmlDocument xml, XmlNode rootNode)
         {
-            Slo<MeasureFile> slo_msf = new Slo<MeasureFile>();
+            Slo sFile = new Slo();
+            Slo sParam = new Slo();
+            Collection<CutHole> sCutHoles = new Collection<CutHole>();
 
-            Slo<CutHole> slo_cuthole = new Slo<CutHole>();
-            Collection<CutHole> cot_cuthole = new Collection<CutHole>();
-
-            for (int i = 0; i < this.ListCutHole.Count; i++)
+            foreach (CutHole hole in ListCutHole)
             {
-                cot_cuthole.addItem(ListCutHole[i]);
-            }
-
+                sCutHoles.addItem(hole);
+            }            
+            
             xString FileName = new xString();
             xString FilePath = new xString();
             FileName.AssignValue(this.FileName);
             FilePath.AssignValue(this.FilePath);
-            slo_cuthole.Register("FileName", FileName);
-            slo_cuthole.Register("FilePath", FilePath);
-
-            slo_cuthole.Register("ListCutHole", cot_cuthole);
-
-            slo_msf.Register("MeasureFile", slo_cuthole);
+            sFile.Register("FileName", FileName);
+            sFile.Register("FilePath", FilePath);
+            sFile.Register("Param", this.MParam);
+            sFile.Register("ListCutHole", sCutHoles);            
 
             if (isStoring)
             {
-                slo_msf.Serialize(true, xml, rootNode);
+                sFile.Serialize(true, xml, rootNode);                
             }
             else
             {
-                slo_msf.Serialize(false, xml, rootNode);
+                sFile.Serialize(false, xml, rootNode);
 
                 this.FileName = FileName.value();
                 this.FilePath = FilePath.value();
-                for (int i = 0; i < cot_cuthole.m_vCollection.Count; i++)
+                for (int i = 0; i < sCutHoles.size(); i++)
                 {
-                    this.ListCutHole.Add(cot_cuthole.getItem(i));
+                    ListCutHole.Add(sCutHoles.getItem(i));
                 }
-
             }
         }
        
@@ -172,7 +168,7 @@ namespace MeasureData
             }
 
             XmlDocument doc = new XmlDocument();
-            if (Directory.Exists(FileName))
+            if (File.Exists(FileName))
             {
                 doc.Load(this.FileName);//载入xml文件               
             }

+ 1 - 1
MeasureData/MeasureParam.cs

@@ -77,7 +77,7 @@ namespace MeasureData
         //XML文件保存测量参数
         public override void Serialize(bool isStoring, XmlDocument xml, XmlNode rootNode)
         {
-            Slo<MeasureParam> slo_msparam = new Slo<MeasureParam>();
+            Slo slo_msparam = new Slo();
 
             xString sampleName = new xString();
             xBool pt = new xBool();

+ 1 - 1
MeasureData/SemPosition.cs

@@ -149,7 +149,7 @@ namespace MeasureData
 
         public override void Serialize(bool isStoring, XmlDocument xml, XmlNode rootNode)
         {
-            Slo<SemPosition> slo_sp = new Slo<SemPosition>();
+            Slo slo_sp = new Slo();
 
             xDouble ptx = new xDouble();
             ptx.AssignValue(this.X);

+ 24 - 0
MeasureThread/Measure.cs

@@ -20,8 +20,32 @@ namespace MeasureThread
         SEM
     }
 
+    //层间通讯数据包
+    public struct ST_MSTMsg
+    {
+        //线程状态
+        public struct STMThreadStatus
+        {
+            public int iMThreadStatus;     
+            public string cMsrStartTime;  
+            public string cMsrEndTime;    
+        };
+        //切孔状态
+        public struct STMSampleStatus
+        {
+            public int iMeasureSampleStatus;    
+            public string cSampleName;
+        };
+        public STMThreadStatus STMThreadStu;
+        public STMSampleStatus STMSampleStu;
+    };
+
+
     public class Measure
     {
+        public delegate void ProgressEventHandler(ST_MSTMsg msg);
+        public event ProgressEventHandler ProgressEvent;
+
         //全局只有一个fatorySEM
         static FactoryHardware factorySEM = FactoryHardware.Instance;
         ISEMControl iSEM = factorySEM.ISEM;