Преглед на файлове

Merge branch 'master' of http://192.168.1.123:10080/SDD1/HOZ

wb_han преди 5 години
родител
ревизия
9fed5585fd

+ 0 - 12
FileManager/Class1.cs

@@ -1,12 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace FileManager
-{
-    public class Class1
-    {
-    }
-}

+ 4 - 1
FileManager/FileManager.csproj

@@ -34,15 +34,18 @@
   <ItemGroup>
     <Reference Include="System" />
     <Reference Include="System.Core" />
+    <Reference Include="System.Drawing" />
     <Reference Include="System.Xml.Linq" />
     <Reference Include="System.Data.DataSetExtensions" />
     <Reference Include="Microsoft.CSharp" />
     <Reference Include="System.Data" />
     <Reference Include="System.Net.Http" />
     <Reference Include="System.Xml" />
+    <Reference Include="WindowsBase" />
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="Class1.cs" />
+    <Compile Include="Serialize.cs" />
+    <Compile Include="XmlManager.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

+ 669 - 0
FileManager/Serialize.cs

@@ -0,0 +1,669 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Xml;
+
+namespace FileManager
+{
+    //#define RootClassName  "XMLData"
+    //#define XMLClassEndTag  std::string("</")+RootClassName+">"
+    //#define Empty_String  std::string("")
+
+    public interface Convertinterface
+    {
+        void Serialize(bool isStoring, XmlDocument xml, XmlNode rootNode);
+    }
+
+    public class MemberBase
+    {
+        const string RootClassName = "XMLData";
+        const string XMLClassEndTag = "</" + RootClassName + ">";
+        const string Empty_String = "";
+
+        protected string m_sValue;
+        //public virtual ~MemberBase() { };
+        public virtual void Dispose() { }
+        public string toString() { return m_sValue; }
+        //public const char* c_str() { return m_sValue.c_str(); }
+        public string getStringPtr(string str) { return m_sValue = str; }     //c++原代码为:std::string *getStringPtr() { return &m_sValue; }; 
+    }
+    /**
+		serializable string
+	*/
+    public class xString : MemberBase
+    {
+        public void AssignValue(string value) { m_sValue = value; }           //因为c#无=重载,所以修改为public
+        public xString() { }
+        public xString(string value) { AssignValue(value); }
+        public string value() { return m_sValue; }
+        //public xString operator=(const string value) { AssignValue(value); return *this; }  //c#不可以重载=
+        //public xString operator=(const char* value) { AssignValue(value); return *this; }  //c#不可以重载=
+    }
+
+    public class xInt : MemberBase
+    {
+        public void AssignValue(int value) { m_sValue = value.ToString(); }        //因为c#无=重载,所以修改为public
+        public xInt() { AssignValue(0); }
+        public xInt(int value) { AssignValue(value); }
+        public int value()
+        {
+            int value;
+            value = int.Parse(m_sValue);
+            return value;
+        }
+        //xInt operator=(const int value) { AssignValue(value); return *this; };  //c#不可以重载=
+    }
+
+    public class xDouble : MemberBase
+    {
+        public void AssignValue(double value) { m_sValue = value.ToString(); }       //因为c#无=重载,所以修改为public
+        public xDouble() { AssignValue(0); }
+        public xDouble(double value) { AssignValue(value); }
+        public double value()
+        {
+            double value;
+            value = double.Parse(m_sValue);
+            return value;
+        }
+        //xDouble operator=(const double value) { AssignValue(value); return *this; }; //c#不可以重载=
+    }
+
+    public class xLong : MemberBase
+    {
+        public void AssignValue(long value) { m_sValue = value.ToString(); }   //因为c#无=重载,所以修改为public            public xLong() { AssignValue(0); }
+        public xLong(long value) { AssignValue(value); }
+        public long value()
+        {
+            long value;
+            value = long.Parse(m_sValue);
+            return value;
+        }
+        //xLong operator=(const long value) { AssignValue(value); return *this; };  //c#不可以重载=
+    }
+
+    public class xDWORD : MemberBase
+    {
+        public void AssignValue(uint value) { m_sValue = value.ToString(); }    //因为c#无=重载,所以修改为public
+        public xDWORD() { AssignValue(0); }
+        public xDWORD(uint value) { AssignValue(value); }
+        public uint value()
+        {
+            uint value;
+            value = uint.Parse(m_sValue);
+            return value;
+        }
+        //xDWORD operator=(const DWORD value) { AssignValue(value); return *this; };
+    }
+
+    public class xBool : MemberBase
+    {
+        public void AssignValue(bool value) { m_sValue = value ? "true" : "false"; }       //因为c#无=重载,所以修改为public
+        public xBool() { AssignValue(false); }
+        public xBool(bool value) { AssignValue(value); }
+
+        public bool value()
+        {
+            bool value = false;
+            string sHelp = m_sValue;
+            //transform(sHelp.GetEnumerator(), sHelp.end(), sHelp.GetEnumerator(), toupper);
+            sHelp.ToUpper();
+            if (sHelp == "TRUE")
+                return true;
+            return value;
+        }
+        //xBool operator=(const bool value) { AssignValue(value); return *this; };
+    }
+
+    public class xTime_t : MemberBase   //time_t对应c#类型?long?
+    {
+        public void AssignValue(DateTime value)     //因为c#无=重载,所以修改为public
+        {
+            m_sValue = value.ToString();
+        }
+
+        public xTime_t()
+        {
+            DateTime t = Convert.ToDateTime(0);
+            AssignValue(t);
+        }
+
+        public xTime_t(DateTime value) { AssignValue(value); }
+
+        public DateTime value()
+        {
+            return Convert.ToDateTime(m_sValue);
+        }
+        //xTime_t operator=(const time_t value) { AssignValue(value); return *this; };
+    }
+
+    //   class __declspec(dllexport) xOleDateTime : public MemberBase  //COleDateTime对应c#类型?统一改为time_t
+    //  {
+    //   {
+    //      private:
+    //	       void AssignValue(const COleDateTime value);
+    //      public:
+    //	       xOleDateTime() { };
+    //         xOleDateTime(COleDateTime value) { AssignValue(value); };
+    //         COleDateTime value();
+    //         xOleDateTime operator=(const COleDateTime value) { AssignValue(value); return *this; };
+    //   };
+
+    public class xOleDateTimeSpan : MemberBase   //COleDateTimeSpan对应c#类型?TimeSpan?
+    {
+        public void AssignValue(TimeSpan value)        //因为c#无=重载,所以修改为public
+        {
+            m_sValue = value.ToString();
+        }
+        public xOleDateTimeSpan()
+        {
+            TimeSpan timeSpan = DateTime.Now - DateTime.Now;
+            AssignValue(timeSpan);
+        }
+        public xOleDateTimeSpan(TimeSpan value) { AssignValue(value); }
+
+        public TimeSpan value()
+        {
+            return TimeSpan.Parse(m_sValue);
+        }
+
+        //xOleDateTimeSpan operator=(const COleDateTimeSpan value) { AssignValue(value); return *this; };
+    };
+
+    public class xRect : MemberBase
+    {
+        public void AssignValue(Rect value, int shape = 1)        //因为c#无=重载,所以修改为public
+        {
+            //Rect x = new Rect();
+
+            // domain text body
+            string strDomainTextBody = "";
+            // value 1 -- shape
+            string strValue = "";
+
+            // value 2 -- center x
+            // domain center
+            int centerX = (int)(value.Left + value.Right) / 2;
+            strValue = centerX.ToString();
+
+            strDomainTextBody += strValue + ",";
+            // value 3 -- center y
+            int centerY = (int)(value.Top + value.Bottom) / 2;
+            strValue = centerY.ToString();
+            strDomainTextBody += strValue + ",";
+
+            if (shape == 0)
+            {
+                // value 4 -- diameter
+                int diameter = (int)value.Width;
+                strValue = diameter.ToString();
+                strDomainTextBody += strValue + ",";
+                // value 5 -- 0
+                strDomainTextBody += "0";
+            }
+            else
+            {
+                // value 4 -- width
+                int width = (int)value.Width;
+                strValue = width.ToString();
+                strDomainTextBody += strValue + ",";
+                // value 5 -- height
+                int height = (int)value.Width;
+                strValue = height.ToString();
+                strDomainTextBody += strValue;
+            }
+
+            // return domain text body
+            m_sValue = strDomainTextBody;
+        }
+
+        public xRect()  //xRect() { AssignValue(0); };???
+        {
+            Rect value = new Rect();
+            value.X = 0;
+            value.Y = 0;
+            value.Width = 1;
+            value.Height = 1;
+            AssignValue(value, 1);
+        }
+
+        xRect(Rect value, int shape) { AssignValue(value, shape); }
+
+        void SplitString(string s, ref List<string> v, string c)
+        {
+            string[] sArray = System.Text.RegularExpressions.Regex.Split(s, c, System.Text.RegularExpressions.RegexOptions.None);
+            foreach (string i in sArray)
+                v.Add(i);
+        }
+        public Rect value()
+        {
+            Rect rectangle = new Rect();
+            List<string> point = new List<string>();
+
+            SplitString(m_sValue, ref point, ",");
+
+            rectangle.X = int.Parse(point[0]);
+            rectangle.Y = int.Parse(point[1]);
+            rectangle.Width = Math.Abs(int.Parse(point[0]) + int.Parse(point[2]));
+            rectangle.Height = Math.Abs(int.Parse(point[1]) + int.Parse(point[3]));
+            return rectangle;
+        }
+    }
+
+    public class xPoint : MemberBase
+    {
+        public void AssignValue(System.Drawing.Point value)             //因为c#无=重载,所以修改为public
+        {
+            int X = value.Y;
+            int Y = value.Y;
+            string OutString;
+            string sX = X.ToString();
+            string sY = Y.ToString();
+            OutString = sX + "," + sY;
+            m_sValue = OutString;
+        }
+        xPoint()
+        {
+            System.Drawing.Point value = new System.Drawing.Point();
+            value.X = 0;
+            value.Y = 0;
+            AssignValue(value);
+        }
+        xPoint(System.Drawing.Point value) { AssignValue(value); }
+        void SplitString(string s, ref List<string> v, string c)
+        {
+            string[] sArray = System.Text.RegularExpressions.Regex.Split(s, c, System.Text.RegularExpressions.RegexOptions.None);
+            foreach (string i in sArray)
+                v.Add(i);
+        }
+        System.Drawing.Point value()
+        {
+            System.Drawing.Point p = new System.Drawing.Point();
+            List<string> point = new List<string>();
+            SplitString(m_sValue, ref point, ",");
+
+            p.X = int.Parse(point[0]);
+            p.Y = int.Parse(point[1]);
+
+            return p;
+        }
+
+    };
+
+
+    //typedef std::map<std::string, CollectionBase*>::iterator __declspec(dllexport) CollectionIterator;  ???
+    public abstract class CollectionBase<T> 
+    {
+        private string m_sCollectionName;
+        private string m_sCollectionClassType;
+        public CollectionBase() { m_sCollectionName = ""; m_sCollectionClassType = ""; }
+        public List<ISlo> m_vCollection = new List<ISlo>(); //vector<ISlo*> m_vCollection;  ISlo*转??
+
+        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 string getCollectionName() { return m_sCollectionName; }
+        public int size() { return m_vCollection.Count(); }
+        public ISlo getItem(int itemID) { return m_vCollection[itemID]; }
+        public void Clear()
+        {
+            if (m_vCollection.Count() > 0)
+            {
+                m_vCollection.Clear();
+            }
+        }
+    }
+
+    public class Collection<T> : CollectionBase<T>
+    {
+        /**
+        create new element of type T
+        @return empty object of type T
+        */
+        public override T newElement() 
+        {
+            T newItem = System.Activator.CreateInstance<T>();
+            //T newItem = default(T);
+            object temp = newItem;
+            ISlo sIo = (ISlo)temp;
+
+            //Slo sIo = new Slo();
+            m_vCollection.Add(sIo);
+            //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;
+        }
+
+        public void addItem(T item)
+        {
+            object temp = item;
+            ISlo sIo = (ISlo)temp;
+            m_vCollection.Add(sIo);/* m_mOwner[item] = false;*/
+        }
+
+        public T getItem(int itemID) 
+        {
+            object temp = m_vCollection[itemID];
+            T item = (T)temp;
+            return item;
+        }
+    };
+
+    public abstract class ISlo : Convertinterface
+    {
+        public abstract void Serialize(bool isStoring, XmlDocument xml, XmlNode rootNode);
+
+        //virtual ~ISlo() = default;
+    }
+
+    //typedef std::vector<Slo*>::iterator  __declspec(dllexport) SerializableIterator;  //iterator?
+
+    public class Slo<T>: ISlo
+    {
+        //private (Slo const &s) { }
+        //private Slo operator=(Slo const &s) { return *this; };
+
+        public string strReplaceAll(string source, string searchFor, string replaceWith)
+        {
+            if ((searchFor == null) || (searchFor == ""))
+            {
+                return source;
+            }
+            source.Replace(searchFor, replaceWith);
+            return source;
+        }
+
+        public string m_sXML;
+        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<T>> m_MemberCollections=new SortedDictionary<string, CollectionBase<T>>();
+
+        public void setClassName(string ClassName) { m_sClassName = ClassName; }
+        public Slo()
+        {
+            m_sClassName = null;
+            m_sVersion = null;
+            m_sXML = null;
+            m_AttributeMappings.Clear();
+            m_MemberMappings.Clear();
+            m_MemberCollections.Clear();
+        }
+
+        /**
+         Register a member
+         @MemberName XML-Description/Name for the member
+         @Member Member to register
+         @return void
+        */
+        public void Register(string MemberName, MemberBase Member)  // public void Register(string MemberName, MemberBase Member, string DefaultValue)  DefaultValue无引用,c#无自动补充功能,故方法调整为双参数
+        {
+            m_AttributeMappings[MemberName] = Member;
+        }
+
+        /**
+        Register a member-subclass
+        @MemberName XML-Description/Name for the member-class
+        @Member Member-class to register
+        @return void
+        */
+        public void Register(string MemberName, ISlo Member)
+        {
+            m_MemberMappings[MemberName] = Member;
+        }
+
+        /**
+         Register a class-collection
+         @CollectionName XML-Description/Name for the collection
+         @SubclassCollection Collection to register
+         @return void
+        */
+        public void Register(string CollectionName, CollectionBase<T> SubclassCollection)
+        {
+            SubclassCollection.setCollectionName(CollectionName);
+            m_MemberCollections[CollectionName] = SubclassCollection;
+        }
+
+
+        public override void Serialize(bool isStoring, XmlDocument xml, XmlNode rootNode)
+        {
+            if (isStoring)
+            {
+                if (xml.DocumentElement != null)
+                {
+                    toXML(xml, rootNode);
+                }
+            }
+            else
+            {
+                fromXML(xml, rootNode);
+            }
+        }
+        public void toXML(XmlDocument xml, XmlNode rootNode)
+        {
+            //XmlNode rootNode = xml.SelectSingleNode("XMLData");
+
+            //for (auto it_member = m_AttributeMappings.begin(); it_member != m_AttributeMappings.end(); ++it_member)
+            //{
+            //    rootNode->SetAttribute(it_member->first.c_str(), it_member->second->c_str());
+            //}
+            for (int it_member = 0; it_member < m_AttributeMappings.Count; it_member++)
+            {
+                var element = m_AttributeMappings.ElementAt(it_member);
+                
+                if (rootNode.Attributes[element.Key] == null)
+                {
+                    XmlElement XmlEle = (XmlElement)rootNode;
+                    XmlEle.SetAttribute(element.Key, element.Value.toString());
+                }
+                else
+                {
+                    rootNode.Attributes[element.Key].InnerText = element.Value.toString();
+                }
+            }
+            //XmlElement element = (XmlElement)xmlDoc.SelectSingleNode("BookStore/NewBook");
+
+            //for (auto it_subclass = m_MemberMappings.begin(); it_subclass != m_MemberMappings.end(); ++it_subclass)
+            //{
+            //    ISlo* subMember = it_subclass->second;
+            //    tinyxml2::XMLElement* subClassNode = classDoc->NewElement("Member");
+            //    subClassNode->SetAttribute("RegName", it_subclass->first.c_str());
+            //    rootNode->InsertEndChild(subClassNode);
+            //    subMember->Serialize(true, classDoc, subClassNode);
+            //}
+
+            for (int it_subclass = 0; it_subclass < m_MemberMappings.Count; it_subclass++)
+            {
+                var element = m_MemberMappings.ElementAt(it_subclass);
+                ISlo subMember = element.Value;
+                XmlNode subClassNode = xml.CreateElement("Member");
+                rootNode.AppendChild(subClassNode);
+
+                //if (rootNode.Attributes["RegName"] == null)
+                //{
+                //    XmlElement XmlEle_subclass = (XmlElement)rootNode;
+                //    XmlEle_subclass.SetAttribute("RegName", element.Key);
+                //}
+                //else
+                //{
+                //    subClassNode.Attributes["RegName"].InnerText = element.Key;
+                //}
+
+                XmlElement XmlEle = (XmlElement)subClassNode;
+                XmlEle.SetAttribute("RegName", element.Key);
+                subMember.Serialize(true, xml, subClassNode);
+            }
+
+
+            //for (CollectionIterator it_collection = m_MemberCollections.begin(); it_collection != m_MemberCollections.end(); ++it_collection)
+            //{
+            //    tinyxml2::XMLElement* listNode = classDoc->NewElement("Collection");
+            //    listNode->SetAttribute("RegName", (*it_collection).second->getCollectionName().c_str());
+            //    for (size_t c = 0; c < (*it_collection).second->size(); c++)
+            //    {
+            //        ISlo* item = (*it_collection).second->getItem(c);
+            //        tinyxml2::XMLElement* elementNode = classDoc->NewElement("Member");
+            //        item->Serialize(true, classDoc, elementNode);
+            //        listNode->InsertEndChild(elementNode);
+            //    }
+            //    rootNode->InsertEndChild(listNode);
+            //}
+
+            for (int it_collection = 0; it_collection < m_MemberCollections.Count; it_collection++)
+            {
+                var element = m_MemberCollections.ElementAt(it_collection);
+                XmlNode listNode = xml.CreateElement("Collection");
+                XmlElement XmlEle = (XmlElement)listNode;
+                XmlEle.SetAttribute("RegName", element.Value.getCollectionName());
+                for (int c = 0; c < element.Value.size(); c++)
+                {
+                    ISlo item = element.Value.getItem(c);
+                    XmlNode elementNode = xml.CreateElement("Member");
+                    item.Serialize(true, xml, elementNode);
+                    listNode.AppendChild(elementNode);
+                }
+
+                rootNode.AppendChild(listNode);
+            }
+        }
+
+        public void fromXML(XmlDocument xml, XmlNode rootNode)
+        {
+
+            //for (var it = this.m_AttributeMappings.First(); it != this.m_AttributeMappings.Last(); ++it)
+            //{
+            //    if (rootNode->Attribute(it->first.c_str()))
+            //    {
+            //        *(it->second->getStringPtr()) = rootNode->Attribute(it->first.c_str());// *(*it)->getField() = memberNode->GetText();
+            //    }
+            //}
+            for (int count = 0; count < m_AttributeMappings.Count; count++)
+            {
+                var element = m_AttributeMappings.ElementAt(count);
+                if (rootNode.Attributes[element.Key] != null)
+                {
+                    string aa = rootNode.Attributes[element.Key].Value;
+                    element.Value.getStringPtr(rootNode.Attributes[element.Key].Value);
+                }
+            }
+
+            //tinyxml2::XMLElement* classNode = rootNode->FirstChildElement("Member");
+            //while (classNode != NULL)
+            //{
+            //    std::string className = classNode->Attribute("RegName");
+            //    for (auto it_subclass = this->m_MemberMappings.begin(); it_subclass != this->m_MemberMappings.end(); ++it_subclass)
+            //    {
+            //        if (it_subclass->first == className)
+            //        {
+            //            it_subclass->second->Serialize(false, classDoc, classNode);
+            //            break;
+            //        }
+            //    }
+            //    classNode = classNode->NextSiblingElement("Member");
+            //}
+
+            XmlNodeList classNodeList = rootNode.SelectNodes("Member");
+            if (classNodeList.Count != 0)
+            {
+                for (int i = 0; i < classNodeList.Count; i++)
+                {
+                    string className = classNodeList[i].Attributes["RegName"].Value;
+                    for (int count = 0; count < m_MemberMappings.Count; count++)
+                    {
+                        var element = m_MemberMappings.ElementAt(count);
+                        if (element.Key == className)
+                        {
+                            element.Value.Serialize(false, xml, classNodeList[i]);
+                            break;
+                        }
+                    }
+                }
+            }
+
+            //tinyxml2::XMLElement* collectionNode = rootNode->FirstChildElement("Collection");
+            //while (collectionNode != NULL)
+            //{
+            //    std::string collectionName = collectionNode->Attribute("RegName");
+            //    for (CollectionIterator it_collection = this->m_MemberCollections.begin(); it_collection != this->m_MemberCollections.end(); ++it_collection)
+            //    {
+            //        if ((*it_collection).second->getCollectionName() == collectionName)
+            //        {
+            //            (*it_collection).second->Clear();
+            //            tinyxml2::XMLElement* classNode = collectionNode->FirstChildElement("Member");
+            //            while (classNode != NULL)
+            //            {
+            //                ISlo* newItem = (*it_collection).second->newElement();
+            //                newItem->Serialize(false, classDoc, classNode);
+            //                classNode = classNode->NextSiblingElement("Member");
+            //            }
+            //        }
+            //    }
+            //    collectionNode = collectionNode->NextSiblingElement("Collection");
+            //}
+            //}
+
+            XmlNodeList collectionNodeList = rootNode.SelectNodes("Collection");
+            if (collectionNodeList.Count != 0)
+            {
+                for (int i = 0; i < collectionNodeList.Count; i++)
+                {
+                    string collectionName = collectionNodeList[i].Attributes["RegName"].Value;
+
+                    for (int count = 0; count < m_MemberCollections.Count; count++)
+                    {
+                        var element = m_MemberCollections.ElementAt(count);
+                        if (element.Value.getCollectionName() == collectionName)
+                        {
+                            element.Value.Clear();
+                            XmlNodeList classNode2List = collectionNodeList[i].SelectNodes("Member");
+                            if (classNode2List.Count != 0)
+                            {
+                                for (int j = 0; j < classNode2List.Count; j++)
+                                {
+                                    Convertinterface newItem = (Convertinterface)element.Value.newElement();
+                                    //ISlo newItem = element.Value.newElement();
+                                    //Object objectItem = element.Value.newElement();
+                                    //ISlo newItem = (ISlo)objectItem;
+
+                                    //newItem.m_AttributeMappings = m_AttributeMappings;
+                                    //newItem.m_MemberMappings = m_MemberMappings;
+                                    //newItem.m_MemberCollections = m_MemberCollections;
+
+                                    newItem.Serialize(false, xml, classNode2List[j]);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        string IdentifyClass(XmlNode rootNode, string XMLSource)  
+        {
+            return rootNode.Attributes["RegName"].Value;
+        }
+
+        string IdentifyClassVersions(XmlNode rootNode, string XMLSource)  //同 IdentifyClass ???
+        {
+            return rootNode.Attributes["RegName"].Value;
+        }
+
+
+        public string getClassName() { return m_sClassName; }
+        public void setVersion(string value) { m_sVersion = value; }
+        public string getVersion() { return m_sVersion; }
+
+        public void Clear()
+        {
+            m_AttributeMappings.Clear();
+            m_MemberMappings.Clear();
+            m_MemberCollections.Clear();
+        }
+    }
+}

+ 46 - 0
FileManager/XmlManager.cs

@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using System.Xml;
+using System.IO;
+using System.Reflection;
+
+namespace FileManager
+{
+    public class XmlManager
+    {
+        #region 创建Xml文件,并创建根节点和属性
+        /// <summary>
+        /// 创建Xml文件,并创建根节点和属性
+        /// </summary>
+        /// <param name="xmlfullname">Xml文件的全路径</param>
+        /// <param name="rootnode">根节点名</param>
+        /// <param name="list_attributes">根节点的属性键值对</param>
+        /// <returns></returns>
+        public Boolean CreateXmlFile(String xmlfullname,String rootnode)
+        {
+            XmlDocument xmlDoc = new XmlDocument();
+            //创建类型声明节点  
+            XmlNode node = xmlDoc.CreateXmlDeclaration("1.0", "utf-8", "");
+            xmlDoc.AppendChild(node);
+            //创建根节点  
+            XmlNode root = xmlDoc.CreateElement(rootnode);
+            xmlDoc.AppendChild(root);
+            try
+            {
+                xmlDoc.Save(xmlfullname);
+                return true;
+            }
+            catch (Exception e)
+            {
+                //显示错误信息  
+                Console.WriteLine(e.Message);
+                return false;
+            }
+        }
+        #endregion
+    }
+}

Файловите разлики са ограничени, защото са твърде много
+ 1047 - 537
HOZProject/FormUnitControl.Designer.cs


+ 558 - 174
HOZProject/FormUnitControl.cs

@@ -16,176 +16,57 @@ using System.Windows.Forms;
 
 using System.IO;
 using SmartSEMControl;
+using FileManager;
+using System.Xml;
+using MeasureData;
+using System.Threading;
 
 namespace HOZProject
 {
     public partial class FormUnitControl : Form
     {
+        #region 系统参数
         //全局只有一个fatorySEM
         static FactoryHardware factorySEM = FactoryHardware.Instance;
         ISEMControl iSEM = factorySEM.ISEM;
 
-        #region 系统参数
+        public XmlManager xmg = new XmlManager();
+
+        
         private String path = Directory.GetCurrentDirectory();
+        private int st_flag = 0;
         #endregion
 
         #region 构造函数
         public FormUnitControl()
         {
-            InitializeComponent();     
-            
+            InitializeComponent();
+
+            Control.CheckForIllegalCrossThreadCalls = false;
 
+            if(iSEM.ConnectStatus())
+            {
+                float ret = iSEM.GetFIBIMAGING();
+                if(ret==0)
+                {
+                    btnSEM.BackColor = Color.Lime;
+                }
+                else if(ret==1)
+                {
+                    btnFIB.BackColor = Color.Lime;
+                    panelFIB.Visible = true;
+                }
+                else if(ret==2)
+                {
+                    btnMILL.BackColor = Color.Lime;
+                }
+            }
             //Calling Notification for updated status
             //CZEMApi.Notify += new _EMApiEvents_NotifyEventHandler(CZEMApi_Notify);
             //CZEMApi.NotifyWithCurrentValue += new _EMApiEvents_NotifyWithCurrentValueEventHandler(CZEMApi_NotifyWithCurrentValue);
             //加载参数
 
         }
-        #endregion
-		
-		#region 设备初始化按键
-        private void btnInit_Click(object sender, EventArgs e)
-        {
-            //if (sem.Init())
-            //{
-            //    btnInit.BackColor = Color.Lime;
-            //}
-            //else
-            //{
-            //    btnInit.BackColor = Color.Red;
-            //}
-        }
-        #endregion
-		
-        #region 设备关闭按键
-        private void btnCloseCtrl_Click(object sender, EventArgs e)
-        {
-            //if (sem.UnInit())
-            //{
-            //    btnInit.BackColor = Control.DefaultBackColor;
-            //}
-        }
-        #endregion
-
-        #region 设置参数更新通知
-        private void btnSetNotify_Click(object sender, EventArgs e)
-        {
-            //if (m_bInitialised)
-            //{
-            //    // Magnification
-            //    if (CZEMApi.SetNotify("AP_MAG", 1) != 0)
-            //    {
-            //        DisplayError("SetNotify", "AP_MAG");
-            //        return;
-            //    }
-            //    // Working distance
-            //    if (CZEMApi.SetNotify("AP_WD", 1) != 0)
-            //    {
-            //        DisplayError("SetNotify", "AP_WD");
-            //        return;
-            //    }
-            //    // BRIGHTNESS 亮度
-            //    if (CZEMApi.SetNotify("AP_BRIGHTNESS", 1) != 0)
-            //    {
-            //        DisplayError("SetNotify", "AP_BRIGHTNESS");
-            //        return;
-            //    }
-            //    // AP_CONTRAST,对比度
-            //    if (CZEMApi.SetNotify("AP_CONTRAST", 1) != 0)
-            //    {
-            //        DisplayError("SetNotify", "AP_CONTRAST");
-            //        return;
-            //    }
-            //    // Vacuum
-            //    if (CZEMApi.SetNotify("DP_VACSTATUS", 1) != 0)
-            //    {
-            //        DisplayError("SetNotify", "DP_VACSTATUS");
-            //        return;
-            //    }
-            //    // Gun / EHT state
-            //    if (CZEMApi.SetNotify("DP_RUNUPSTATE", 1) != 0)
-            //    {
-            //        DisplayError("SetNotify", "DP_RUNUPSTATE");
-            //        return;
-            //    }
-            //    // actual KV / EHT
-            //    if (CZEMApi.SetNotify("AP_ACTUALKV", 1) != 0)
-            //    {
-            //        DisplayError("SetNotify", "AP_ACTUALKV");
-            //        return;
-            //    }
-            //    // actual current
-            //    if (CZEMApi.SetNotify("AP_ACTUALCURRENT", 1) != 0)
-            //    {
-            //        DisplayError("SetNotify", "AP_ACTUALCURRENT");
-            //        return;
-            //    }
-            //    // column type
-            //    if (CZEMApi.SetNotify("DP_COLUMN_TYPE", 1) != 0)
-            //    {
-            //        DisplayError("SetNotify", "DP_COLUMN_TYPE");
-            //        return;
-            //    }
-            //    // mode
-            //    if (CZEMApi.SetNotify("DP_OPERATING_MODE", 1) != 0)
-            //    {
-            //        DisplayError("SetNotify", "DP_OPERATING_MODE");
-            //        return;
-            //    }
-            //    // scan rate
-            //    if (CZEMApi.SetNotify("DP_SCANRATE", 1) != 0)
-            //    {
-            //        DisplayError("SetNotify", "DP_SCANRATE");
-            //        return;
-            //    }
-            //    // auto function active
-            //    if (CZEMApi.SetNotify("DP_AUTO_FUNCTION", 1) != 0)
-            //    {
-            //        DisplayError("SetNotify", "DP_AUTO_FUNCTION");
-            //        return;
-            //    }
-
-
-            //    // probe current
-            //    if (CZEMApi.SetNotify("AP_IPROBE", 1) != 0)
-            //    {
-            //        DisplayError("SetNotify", "AP_IPROBE");
-            //        return;
-            //    }
-            //    // detector
-            //    if (CZEMApi.SetNotify("DP_DETECTOR_TYPE", 1) != 0)
-            //    {
-            //        DisplayError("SetNotify", "DP_DETECTOR_TYPE");
-            //        return;
-            //    }
-            //    // stage initialised
-            //    if (CZEMApi.SetNotify("DP_STAGE_INIT", 1) != 0)
-            //    {
-            //        DisplayError("SetNotify", "DP_STAGE_INIT");
-            //        return;
-            //    }
-            //    // stage busy?
-            //    if (CZEMApi.SetNotify("DP_STAGE_IS", 1) != 0)
-            //    {
-            //        DisplayError("SetNotify", "DP_STAGE_IS");
-            //        return;
-            //    }
-            //    // fib mode
-            //    if (CZEMApi.SetNotify("DP_FIB_MODE", 1) != 0)
-            //    {
-            //        DisplayError("SetNotify", "DP_FIB_MODE");
-            //        return;
-            //    }
-            //    // fib gun state
-            //    if (CZEMApi.SetNotify("DP_FIB_GUN_STATE", 1) != 0)
-            //    {
-            //        DisplayError("SetNotify", "DP_FIB_GUN_STATE");
-            //        return;
-            //    }
-
-            //listmsg.Items.Add("Notification enabled");
-            // }
-        }
         #endregion
         
         #region 缩放Get
@@ -195,13 +76,12 @@ namespace HOZProject
             float ret = iSEM.GetMagnification();
             if (float.IsNaN(ret))
             {
-                lblenlargeGet.Text = "NaN";
+                txtenlargeSet.Text = "NaN";
                 txtenlargeSet.Enabled = false;
                 btnenlargeSet.Enabled = false;
             }
             else
             {
-                lblenlargeGet.Text = ret.ToString();
                 txtenlargeSet.Text = ret.ToString();
                 btnenlargeSet.Enabled = true;
             }
@@ -226,13 +106,12 @@ namespace HOZProject
             float ret = iSEM.GetWorkingDistance();
             if (float.IsNaN(ret))
             {
-                lblWDGet.Text = "NaN";
+                txtWDSet.Text = "NaN";
                 txtWDSet.Enabled = false;
                 btnWDSet.Enabled = false;
             }
             else
             {
-                lblWDGet.Text = ret.ToString();
                 txtWDSet.Text = ret.ToString();
                 btnWDSet.Enabled = true;
             }
@@ -256,13 +135,12 @@ namespace HOZProject
             float ret = iSEM.GetBrightness();
             if (float.IsNaN(ret))
             {
-                lblBrightnessGet.Text = "NaN";
+                txtBrightnessSet.Text = "NaN";
                 txtBrightnessSet.Enabled = false;
                 btnBrightnessSet.Enabled = false;
             }
             else
-            {
-                lblBrightnessGet.Text = ret.ToString();
+            { 
                 txtBrightnessSet.Text = ret.ToString();
                 btnBrightnessSet.Enabled = true;
             }
@@ -286,13 +164,12 @@ namespace HOZProject
             float ret = iSEM.GetContrast();
             if (float.IsNaN(ret))
             {
-                lblContrastGet.Text = "NaN";
+                txtContrastSet.Text = "NaN";
                 txtContrastSet.Enabled = false;
                 btnContrastSet.Enabled = false;
             }
             else
             {
-                lblContrastGet.Text = ret.ToString();
                 txtContrastSet.Text = ret.ToString();
                 btnContrastSet.Enabled = true;
             }
@@ -316,13 +193,12 @@ namespace HOZProject
             float ret = iSEM.GetAstigmatismX();
             if (float.IsNaN(ret))
             {
-                lblAstigmatismXGet.Text = "NaN";
+                txtAstigmatismXSet.Text = "NaN";
                 txtAstigmatismXSet.Enabled = false;
                 btnAstigmatismXSet.Enabled = false;
             }
             else
             {
-                lblAstigmatismXGet.Text = ret.ToString();
                 txtAstigmatismXSet.Text = ret.ToString();
                 btnAstigmatismXSet.Enabled = true;
             }
@@ -346,13 +222,12 @@ namespace HOZProject
             float ret = iSEM.GetAstigmatismY();
             if (float.IsNaN(ret))
             {
-                lblAstigmatismYGet.Text = "NaN";
+                txtAstigmatismYSet.Text = "NaN";
                 txtAstigmatismYSet.Enabled = false;
                 btnAstigmatismYSet.Enabled = false;
             }
             else
             {
-                lblAstigmatismYGet.Text = ret.ToString();
                 txtAstigmatismYSet.Text = ret.ToString();
                 btnAstigmatismYSet.Enabled = true;
             }
@@ -377,13 +252,12 @@ namespace HOZProject
             float ret = iSEM.GetTiltAngle();
             if (float.IsNaN(ret))
             {
-                lblTiltAngleGet.Text = "NaN";
+                txtTiltAngleSet.Text = "NaN";
                 txtTiltAngleSet.Enabled = false;
                 btnTiltAngleSet.Enabled = false;
             }
             else
             {
-                lblTiltAngleGet.Text = ret.ToString();
                 txtTiltAngleSet.Text = ret.ToString();
                 btnTiltAngleSet.Enabled = true;
             }
@@ -422,13 +296,12 @@ namespace HOZProject
             float ret = iSEM.GetScanRotation();
             if (float.IsNaN(ret))
             {
-                lblScanRotationGet.Text = "NaN";
+                txtScanRotationSet.Text = "NaN";
                 txtScanRotationSet.Enabled = false;
                 btnScanRotationSet.Enabled = false;
             }
             else
             {
-                lblScanRotationGet.Text = ret.ToString();
                 txtScanRotationSet.Text = ret.ToString();
                 btnScanRotationSet.Enabled = true;
             }
@@ -462,6 +335,58 @@ namespace HOZProject
         }
         #endregion
 
+        #region 电子束
+        private void btnTiltCorrXGet_Click(object sender, EventArgs e)
+        {
+            float ret = iSEM.GetBeamShiftX();
+            if (float.IsNaN(ret))
+            {
+                txtTiltCorrX.Text = "NaN";
+                txtTiltCorrX.Enabled = false;
+                btnTiltCorrXSet.Enabled = false;
+            }
+            else
+            {
+                txtTiltCorrX.Text = ret.ToString();
+                btnTiltCorrXSet.Enabled = true;
+            }
+        }
+
+        private void btnTiltCorrXSet_Click(object sender, EventArgs e)
+        {
+            float set = 0;
+            if (float.TryParse(txtTiltCorrX.Text, out set))
+            {
+                iSEM.SetBeamShiftX(set);
+            }
+        }
+
+        private void btnTiltCorrYGet_Click(object sender, EventArgs e)
+        {
+            float ret = iSEM.GetBeamShiftY();
+            if (float.IsNaN(ret))
+            {
+                txtTiltCorrY.Text = "NaN";
+                txtTiltCorrY.Enabled = false;
+                btnTiltCorrYSet.Enabled = false;
+            }
+            else
+            {
+                txtTiltCorrY.Text = ret.ToString();
+                btnTiltCorrYSet.Enabled = true;
+            }
+        }
+
+        private void btnTiltCorrYSet_Click(object sender, EventArgs e)
+        {
+            float set = 0;
+            if (float.TryParse(txtTiltCorrY.Text, out set))
+            {
+                iSEM.SetBeamShiftY(set);
+            }
+        }
+        #endregion
+
         #region 开启电压
         private void btnOpenVoltage_Click(object sender, EventArgs e)
         {
@@ -476,6 +401,32 @@ namespace HOZProject
         }
         #endregion
 
+        #region 电子束校正
+        private void btnTiltCorr_Click(object sender, EventArgs e)
+        {
+            float ret = iSEM.GetTiltCorrection();
+            if (float.IsNaN(ret))
+            {
+                btnTiltCorr.BackColor = Color.Red;
+            }
+            else
+            {
+                if(ret==0)
+                {
+                    btnTiltCorr.BackColor = Color.Blue;
+                    iSEM.SetTiltCorrectionOn();
+                    btnTiltCorr.Text = "电子束状态:On";
+                }
+                else
+                {
+                    btnTiltCorr.BackColor = Color.Lime;
+                    iSEM.SetTiltCorrectionOff();
+                    btnTiltCorr.Text = "电子束状态:Off";
+                }
+            }
+        }
+        #endregion  
+
         #region 样品台位置获取
         private void btnStageGetX_Click(object sender, EventArgs e)
         {
@@ -643,27 +594,460 @@ namespace HOZProject
         }
         #endregion
 
-        private void btnDoSemDriftCorrn_Click(object sender, EventArgs e)
+        #region 窗体关闭
+        private void FormUnitControl_FormClosing(object sender, FormClosingEventArgs e)
         {
-            iSEM.SetTiltCorrectionOff();
+            if(iSEM!=null)
+            {
+                iSEM.Dispose();
+            }
         }
+        #endregion
 
-        private void button1_Click(object sender, EventArgs e)
+        #region 宏文件
+        private void btnCMDMCF_Click(object sender, EventArgs e)
         {
-            iSEM.SetTiltCorrectionOn();
+            iSEM.CMDMCFFilename("OPTON");
         }
+        #endregion
 
-        private void FormUnitControl_FormClosing(object sender, FormClosingEventArgs e)
+        private void btnCreatXml_Click(object sender, EventArgs e)
         {
-            if(iSEM!=null)
+            SaveFileDialog sfd = new SaveFileDialog();
+            sfd.Title = "生成Xml文件位置:";
+            sfd.FileName = "test.xml";
+            sfd.Filter = "XML文件|*.xml";
+            if (sfd.ShowDialog() == DialogResult.OK)
             {
-                iSEM.Dispose();
+                string fn = sfd.FileName;
+                List<KeyValuePair<String, String>> lkvp = new List<KeyValuePair<string, string>>();
+                lkvp.Add(new KeyValuePair<string, string>("key1","value1"));
+                lkvp.Add(new KeyValuePair<string, string>("key2", "value2"));
+                xmg.CreateXmlFile(fn,"XMLData");
+
+                lkvp.Clear();
+                lkvp.Add(new KeyValuePair<string, string>("key3", "value3"));
+                lkvp.Add(new KeyValuePair<string, string>("key4", "value4"));
+                //xmg.CreateNode(fn, "XMLData", "子节点", "", lkvp);
+                //xmg.CreateNode(fn, "子节点", "子bb节点", "", lkvp);
             }
         }
 
-        private void btnCMDMCF_Click(object sender, EventArgs e)
+        private void button1_Click_1(object sender, EventArgs e)
         {
-            iSEM.CMDMCFFilename("OPTON");
+            XmlDocument doc = new XmlDocument();
+            doc.Load("test.xml");//载入xml文件
+
+            XmlNode root = doc.SelectSingleNode("XMLData");
+
+            MeasureFile mf = new MeasureFile();
+
+            mf.FileName = "abcdefg";
+            mf.Serialize(true, doc, root);
+
+            doc.Save("test.xml");
+        }
+
+        #region SEM模式
+        private void btnSEM_Click(object sender, EventArgs e)
+        {
+            if(iSEM.CmdFIBModeSEM())
+            {
+                btnFIB.BackColor = SystemColors.Control;
+                btnSEM.BackColor = Color.Lime;
+                btnMILL.BackColor = SystemColors.Control;
+                panelFIB.Visible = false;
+            } 
+        }
+        #endregion
+
+        #region FIB模式
+        private void btnFIB_Click(object sender, EventArgs e)
+        {
+            if(iSEM.CmdFIBModeFIB())
+            {
+                btnFIB.BackColor = Color.Lime;
+                btnSEM.BackColor = SystemColors.Control;
+                btnMILL.BackColor = SystemColors.Control;
+                panelFIB.Visible = true;
+            }
+        }
+        #endregion
+
+        #region MILL模式
+        private void btnMILL_Click(object sender, EventArgs e)
+        {
+            if(iSEM.CmdFIBModeMILL())
+            {
+                btnFIB.BackColor = SystemColors.Control;
+                btnSEM.BackColor = SystemColors.Control;
+                btnMILL.BackColor = Color.Lime;
+            }
+        }
+        #endregion
+
+        #region 自动对焦1
+        private void btnAutoFocus1_Click(object sender, EventArgs e)
+        {
+            iSEM.CmdAutoFocusCoarse();
+            btnAutoFocus1.BackColor = Color.Red;
+            st_flag = 1;
+            Thread.Sleep(1000);
+            Thread thread = new Thread(AutoFunction);
+            thread.Start();
         }
+        #endregion
+
+        #region 自动函数监测线程
+        private void AutoFunction()
+        {
+            float ret = 111;
+            while(true)
+            {
+                ret = iSEM.GetAutoFunction();
+                if(ret==0)
+                {
+                    if (st_flag == 1)
+                    {
+                        btnAutoFocus1.BackColor = Color.Lime;
+                    }
+                    else if(st_flag==2)
+                    {
+                        btnAutoFocus2.BackColor = Color.Lime;
+                    }
+                    else if (st_flag == 3)
+                    {
+                        btnAutoBrightness.BackColor = Color.Lime;
+                    }
+                    else if (st_flag == 4)
+                    {
+                        btnAutoContrast.BackColor = Color.Lime;
+                    }
+                    else if (st_flag == 5)
+                    {
+                        btnAutoBrightness.BackColor = Color.Lime;
+                        btnAutoContrast.BackColor = Color.Lime;
+                        btnAutoBC.BackColor = Color.Lime;
+                    }
+                    else if (st_flag == 6)
+                    {
+                        btnAutoBCCancle.BackColor = Color.Lime;
+                    }
+                    else if (st_flag == 7)
+                    {
+                        btnAutoStig.BackColor = Color.Lime;
+                    }
+                    break;
+                }
+            }
+        }
+        #endregion
+
+        #region 自动对焦2
+        private void btnAutoFocus2_Click(object sender, EventArgs e)
+        {
+            iSEM.CmdAutoFocusFine();
+            btnAutoFocus2.BackColor = Color.Red;
+            st_flag = 2;
+            Thread.Sleep(1000);
+            Thread thread = new Thread(AutoFunction);
+            thread.Start();
+        }
+        #endregion
+
+        #region 自动亮度、对比度
+        private void btnAutoBrightness_Click(object sender, EventArgs e)
+        {
+            iSEM.SetAutoVideoBrightness();
+            btnAutoBrightness.BackColor = Color.Red;
+            st_flag = 3;
+            Thread.Sleep(1000);
+            Thread thread = new Thread(AutoFunction);
+            thread.Start();
+        }
+
+        private void btnAutoContrast_Click(object sender, EventArgs e)
+        {
+            iSEM.SetAutoVideoBrightness();
+            btnAutoContrast.BackColor = Color.Red;
+            st_flag = 4;
+            Thread.Sleep(1000);
+            Thread thread = new Thread(AutoFunction);
+            thread.Start();
+        }
+
+        private void btnAutoBC_Click(object sender, EventArgs e)
+        {
+            iSEM.SetAutoVideoBrightness();
+            btnAutoBrightness.BackColor = Color.Red;
+            btnAutoContrast.BackColor = Color.Red;
+            btnAutoBC.BackColor = Color.Red;
+            st_flag = 5;
+            Thread.Sleep(1000);
+            Thread thread = new Thread(AutoFunction);
+            thread.Start();
+        }
+
+        private void btnAutoBCCancle_Click(object sender, EventArgs e)
+        {
+            iSEM.SetAutoVideoOff();
+            btnAutoBCCancle.BackColor = Color.Red;
+            st_flag = 6;
+            Thread.Sleep(1000);
+            Thread thread = new Thread(AutoFunction);
+            thread.Start();
+        }
+        #endregion
+
+        #region 自动消像散
+        private void btnAutoStig_Click(object sender, EventArgs e)
+        {
+            iSEM.CmdAutoStig();
+            btnAutoStig.BackColor = Color.Red;
+            st_flag = 7;
+            Thread.Sleep(1000);
+            Thread thread = new Thread(AutoFunction);
+            thread.Start();
+        }
+        #endregion
+
+        #region FIB缩放Get
+        private void btnFIBMagGet_Click(object sender, EventArgs e)
+        {
+            float ret = iSEM.GetFIBMagnification();
+            if (float.IsNaN(ret))
+            {
+                txtFIBMag.Text = "NaN";
+                txtFIBMag.Enabled = false;
+                btnFIBMagSet.Enabled = false;
+            }
+            else
+            {
+                txtFIBMag.Text = ret.ToString();
+                btnFIBMagSet.Enabled = true;
+            }
+        }
+        #endregion
+
+        #region FIB缩放Set
+        private void btnFIBMagSet_Click(object sender, EventArgs e)
+        {
+            float set = 0;
+            if (float.TryParse(txtFIBMag.Text, out set))
+            {
+                iSEM.SetFIBMagnification(set);
+            }
+        }
+        #endregion
+
+        #region FIB焦距Get
+        private void btnFIBWDGet_Click(object sender, EventArgs e)
+        {
+            float ret = iSEM.GetFIBObjectivePotential();
+            if (float.IsNaN(ret))
+            {
+                txtFIBWD.Text = "NaN";
+                txtFIBWD.Enabled = false;
+                btnFIBWDSet.Enabled = false;
+            }
+            else
+            {
+                txtFIBWD.Text = ret.ToString();
+                btnFIBWDSet.Enabled = true;
+            }
+        }
+        #endregion
+
+        #region FIB焦距Set
+        private void btnFIBWDSet_Click(object sender, EventArgs e)
+        {
+            float set = 0;
+            if (float.TryParse(txtFIBWD.Text, out set))
+            {
+                iSEM.SetFIBObjectivePotential(set);
+            }
+        }
+        #endregion
+
+        #region FIB电子束移动
+        private void btnFIBBeamShiftXGet_Click(object sender, EventArgs e)
+        {
+            float ret = iSEM.GetFIBBeamShiftX();
+            if (float.IsNaN(ret))
+            {
+                txtFIBBeamShiftX.Text = "NaN";
+                txtFIBBeamShiftX.Enabled = false;
+                btnFIBBeamShiftXSet.Enabled = false;
+            }
+            else
+            {
+                txtFIBBeamShiftX.Text = ret.ToString();
+                btnFIBBeamShiftXSet.Enabled = true;
+            }
+        }
+
+        private void btnFIBBeamShiftXSet_Click(object sender, EventArgs e)
+        {
+            float set = 0;
+            if (float.TryParse(txtFIBBeamShiftX.Text, out set))
+            {
+                iSEM.SetFIBBeamShiftX(set);
+            }
+        }
+
+        private void btnFIBBeamShiftYGet_Click(object sender, EventArgs e)
+        {
+            float ret = iSEM.GetFIBBeamShiftY();
+            if (float.IsNaN(ret))
+            {
+                txtFIBBeamShiftY.Text = "NaN";
+                txtFIBBeamShiftY.Enabled = false;
+                btnFIBBeamShiftYSet.Enabled = false;
+            }
+            else
+            {
+                txtFIBBeamShiftY.Text = ret.ToString();
+                btnFIBBeamShiftYSet.Enabled = true;
+            }
+        }
+
+        private void btnFIBBeamShiftYSet_Click(object sender, EventArgs e)
+        {
+            float set = 0;
+            if (float.TryParse(txtFIBBeamShiftY.Text, out set))
+            {
+                iSEM.SetFIBBeamShiftY(set);
+            }
+        }
+        #endregion
+
+        #region 执行宏文件
+        private void btnMCF_Click(object sender, EventArgs e)
+        {
+            OpenFileDialog sfd = new OpenFileDialog();
+            sfd.Title = "选择宏文件:";
+            sfd.InitialDirectory = @"C:\ProgramData\Carl Zeiss\SmartSEM\User\Default";
+            sfd.Filter = "MLF文件|*.MLF";
+            if (sfd.ShowDialog() == DialogResult.OK)
+            {
+                string fn = Path.GetFileNameWithoutExtension(sfd.FileName).ToUpper();
+                iSEM.CMDMCFFilename(fn);
+                
+            }
+        }
+        #endregion
+
+        #region FIB消像散
+        private void btnFIBAstigmatismXGet_Click(object sender, EventArgs e)
+        {
+            float ret = iSEM.GetFIBAstigmatismX();
+            if (float.IsNaN(ret))
+            {
+                txtFIBAstigmatismX.Text = "NaN";
+                txtFIBAstigmatismX.Enabled = false;
+                btnFIBAstigmatismXSet.Enabled = false;
+            }
+            else
+            {
+                txtFIBAstigmatismX.Text = ret.ToString();
+                btnFIBAstigmatismXSet.Enabled = true;
+            }
+        }
+
+        private void btnFIBAstigmatismXSet_Click(object sender, EventArgs e)
+        {
+            float set = 0;
+            if (float.TryParse(txtFIBAstigmatismX.Text, out set))
+            {
+                iSEM.SetFIBAstigmatismX(set);
+            }
+        }
+
+        private void btnFIBAstigmatismYGet_Click(object sender, EventArgs e)
+        {
+            float ret = iSEM.GetFIBAstigmatismY();
+            if (float.IsNaN(ret))
+            {
+                txtFIBAstigmatismY.Text = "NaN";
+                txtFIBAstigmatismY.Enabled = false;
+                btnFIBAstigmatismYSet.Enabled = false;
+            }
+            else
+            {
+                txtFIBAstigmatismY.Text = ret.ToString();
+                btnFIBAstigmatismYSet.Enabled = true;
+            }
+        }
+
+        private void btnFIBAstigmatismYSet_Click(object sender, EventArgs e)
+        {
+            float set = 0;
+            if (float.TryParse(txtFIBAstigmatismY.Text, out set))
+            {
+                iSEM.SetFIBAstigmatismY(set);
+            }
+        }
+        #endregion
+
+        #region 移动样品台XY
+        private void btnMoveXY_Click(object sender, EventArgs e)
+        {
+            float setx = 0;
+            float sety = 0;
+            if (!float.TryParse(txtStageX.Text, out setx))
+            {
+                return;
+            }
+            if(!float.TryParse(txtStageY.Text,out sety))
+            {
+                return;
+            }
+            btnMoveXY.BackColor = Color.Red;
+            iSEM.MoveStageXY(setx, sety);
+            Thread.Sleep(500);
+            Thread th = new Thread(MoveStagexy);
+            th.Start();
+        }
+
+        private void MoveStagexy()
+        {
+            float ret = 111;
+            while(true)
+            {
+                ret = iSEM.GetStageIs();
+                if(ret==0)
+                {
+                    btnMoveXY.BackColor = Color.Lime;
+                    break;
+                }
+            }
+        }
+
+        #endregion
+
+        #region 获取分辨率
+        private void btnImageStoreGet_Click(object sender, EventArgs e)
+        {
+            int[] ret = iSEM.GetImageStore();
+            lblImageStore.Text = ret[0].ToString() + "*" + ret[1].ToString();
+        }
+        #endregion
+
+        #region 设置分辨率
+        private void btnImageStoreSet_Click(object sender, EventArgs e)
+        {
+            if (cmbImageStore.SelectedIndex > -1 && cmbImageStore.SelectedIndex < 12)
+            {
+                iSEM.SetImageStore(cmbImageStore.SelectedIndex);
+            }
+        }
+        #endregion
+
+        #region 样品台急停
+        private void btnAbort_Click(object sender, EventArgs e)
+        {
+            iSEM.CmdStageAbort();
+        }
+        #endregion
     }
 }

+ 2 - 1
HOZProject/Program.cs

@@ -16,7 +16,8 @@ namespace HOZProject
         {
             Application.EnableVisualStyles();
             Application.SetCompatibleTextRenderingDefault(false);
-            Application.Run(new FormUCMain());
+            //Application.Run(new FormUCMain());
+            Application.Run(new FormUnitControl());
         }
     }
 }

+ 8 - 0
HOZProject/UnitControl.csproj

@@ -34,6 +34,14 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="FileManager, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\bin\Debug\FileManager.dll</HintPath>
+    </Reference>
+    <Reference Include="MeasureData, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\bin\Debug\MeasureData.dll</HintPath>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core" />
     <Reference Include="System.Xml.Linq" />

+ 32 - 4
MeasureData/CutHole.cs

@@ -7,18 +7,21 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 
+using FileManager;
+using System.Xml;
+
 namespace MeasureData
 {
     
      //PT工序类型
-    enum PTType
+    public enum PTType
     {
         Have,
         No
     }
 
     //操作步骤,在操作失败时,反馈的状态
-    enum Operation
+    public enum Operation
     {
         Init,
         PTInsert,
@@ -32,7 +35,7 @@ namespace MeasureData
     }
 
     //测试结果
-    enum State
+    public enum State
     {
         Unmeasured,
         Failed,
@@ -40,7 +43,7 @@ namespace MeasureData
     }
 
     //切割孔
-    class CutHole
+    public class CutHole: Convertinterface
     {
         #region 样品名
         /// <summary>
@@ -158,5 +161,30 @@ namespace MeasureData
         }
 
         //样品孔存储xml文档
+        public void Serialize(bool isStoring, XmlDocument xml, XmlNode rootNode)
+        {
+
+            Slo<CutHole> slo = new Slo<CutHole> ();
+
+            xString SampleName = new xString();
+            SampleName.AssignValue(this.SampleName);
+            slo.Register("SampleName", SampleName);
+            
+
+            if (isStoring)
+            {
+                slo.Serialize(true, xml, rootNode);
+            }
+            else
+            {
+                slo.Serialize(false, xml, rootNode);
+
+                this.SampleName = SampleName.value();
+               
+
+            }
+        }
+    
     }
+
 }

+ 4 - 0
MeasureData/MeasureData.csproj

@@ -32,6 +32,10 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="FileManager, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\bin\Debug\FileManager.dll</HintPath>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core" />
     <Reference Include="System.Xml.Linq" />

+ 30 - 1
MeasureData/MeasureFile.cs

@@ -7,9 +7,12 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 
+using FileManager;
+using System.Xml;
+
 namespace MeasureData
 {
-    class MeasureFile
+    public class MeasureFile:Convertinterface
     {
         #region 内容
         //文件名
@@ -40,6 +43,31 @@ namespace MeasureData
         }
 
         //XML文件保存
+        //样品孔存储xml文档
+        public void Serialize(bool isStoring, XmlDocument xml, XmlNode rootNode)
+        {
+
+            Slo<MeasureFile> slo = new Slo<MeasureFile>();
+
+            xString FileName = new xString();
+            this.FileName = "aaaaa";
+            FileName.AssignValue(this.FileName);
+            slo.Register("FileName", FileName);
+
+
+            if (isStoring)
+            {
+                slo.Serialize(true, xml, rootNode);
+            }
+            else
+            {
+                slo.Serialize(false, xml, rootNode);
+
+                this.FileName = FileName.value();
+
+
+            }
+        }
         #endregion
 
         //构造函数
@@ -66,6 +94,7 @@ namespace MeasureData
         //保存
         public void Save()
         {
+            //Serialize();
         }
 
         //另存为

+ 1 - 1
MeasureData/SemPosition.cs

@@ -10,7 +10,7 @@ using System.Threading.Tasks;
 namespace MeasureData
 {
     //六轴坐标系统
-    class SemPosition
+    public class SemPosition
     {
 
         private float m_x, m_y, m_z, m_r, m_t, m_m;

+ 93 - 0
MeasureThread/Measure.cs

@@ -0,0 +1,93 @@
+//时间:20200610
+//作者:郝爽
+//功能:测量线程
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using SmartSEMControl;
+using MeasureData;
+
+namespace MeasureThread
+{
+    public class Measure
+    {
+        //全局只有一个fatorySEM
+        static FactoryHardware factorySEM = FactoryHardware.Instance;
+        ISEMControl iSEM = factorySEM.ISEM;
+
+        //测量文件
+        private MeasureFile m_measureFile;
+        public MeasureFile MeasureFile
+        {
+            get { return this.m_measureFile; }
+            set { this.m_measureFile = value; }
+        }
+
+        //测量的切割孔
+        private List<MeasureData.CutHole> m_cutHoles;
+        public List<MeasureData.CutHole> cutHoles
+        {
+            get { return this.m_cutHoles; }
+            set { this.m_cutHoles = value; }
+        }
+
+        //工作文件夹
+        private string m_WorkingFolder;
+        public string WorkingFolder
+        {
+            get { return this.m_WorkingFolder; }
+            set { this.m_WorkingFolder = value; }
+        }
+
+        //线程状态
+        private ThreadState m_ThreadStatus;
+        public ThreadState ThreadStatus
+        {
+            get { return this.m_ThreadStatus; }
+            set { this.m_ThreadStatus = value; }
+        }
+
+        //// SEM data general
+        //CSEMDataGnrPtr m_pSEMDataGnr;
+
+        ////MeasureAppFormName
+        //CString m_strMAppFormName;
+
+        //HWND m_hWnd;
+
+        //COTSHardwareMgrPtr m_pHardwareMgr;
+
+        //构造函数
+        public Measure()
+        {
+        }
+
+        //初始化测量业务
+        public bool InitMeas(MeasureFile a_measureFile, List<CutHole> a_listMeasuableHoles)
+        {
+            return false;
+        }
+
+        //初始化测量业务
+        public bool InitMeas(MeasureFile a_measureFile)
+        {
+            return false;
+        }
+
+        //第一个孔的测试过程
+        public void FirstHole()
+        {
+            
+        }
+
+        //非第一个孔的测试过程
+        public void OtherHole()
+        {
+        }
+
+    }
+}

+ 5 - 0
MeasureThread/MeasureThread.csproj

@@ -32,6 +32,10 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="MeasureData, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\bin\Debug\MeasureData.dll</HintPath>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core" />
     <Reference Include="System.Xml.Linq" />
@@ -44,6 +48,7 @@
   <ItemGroup>
     <Compile Include="Measure.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="ThreadStatus.cs" />
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\SmartSEMControl\SmartSEMControl.csproj">

+ 132 - 0
MeasureThread/ThreadStatus.cs

@@ -0,0 +1,132 @@
+//时间:20200611
+//作者:郝爽
+//功能:测量状态
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MeasureThread
+{
+    //测试结果
+    public enum ThreadState
+    {
+        Ready,     //就绪
+        InProcess, //进行中
+        Waiting,   //等待,半自动化测试过程的状态
+        Failed,    //失败
+        Success    //成功
+    }
+
+    //计算时间类型
+    public enum THREAD_TIME_TYPE
+    {
+        START = 1,
+        STOPPED = 2,
+    }
+
+    public class ThreadStatus
+    {
+        //线程状态
+        private ThreadState m_threadState;
+        public ThreadState STATE
+        {
+            get { return this.m_threadState; }
+            set { this.m_threadState = value; }
+        }
+
+        //线程开始的时间
+        private DateTime m_startTime;
+        public DateTime StartTime
+        {
+            get { return this.m_startTime; }
+            set { this.m_startTime = value; }
+        }
+
+        //线程结束的时间
+        private DateTime m_endTime;
+        public DateTime EndTime
+        {
+            get { return this.m_endTime; }
+            set { this.m_endTime = value; }
+        }
+
+        //线程使用的时间
+        private TimeSpan m_UsedTime;
+        public TimeSpan UsedTime
+        {
+            get { return this.m_UsedTime; }
+            set { this.m_UsedTime = value; }
+        }
+
+        //线程当前开始的时间
+        private DateTime m_CurrentStartTime;
+        public DateTime CurrentStartTime
+        {
+            get { return this.m_CurrentStartTime; }
+            set { this.m_CurrentStartTime = value; }
+        }
+
+        //构造函数
+        public ThreadStatus()
+        {
+            Init();
+        }
+
+        public void Init()
+        {
+            m_threadState = ThreadState.Ready;
+            m_startTime = new DateTime();
+            m_endTime = new DateTime();
+            m_CurrentStartTime = new DateTime();
+            m_UsedTime = m_endTime - m_startTime;
+        }
+
+        // 计算时间
+        public bool ComputeTime(THREAD_TIME_TYPE a_nType)
+        {
+            if (a_nType == THREAD_TIME_TYPE.START)
+            {
+                if (m_startTime == new DateTime())
+                {
+                    m_startTime = DateTime.Now;
+                    m_CurrentStartTime = m_startTime;
+                }
+                else
+                {
+                    m_CurrentStartTime = DateTime.Now;
+                }
+                m_endTime = DateTime.Now;
+            }
+            else if (a_nType == THREAD_TIME_TYPE.STOPPED)
+            {
+                // set current time as end time
+                m_endTime = DateTime.Now;
+
+                // compute used time
+                TimeSpan timeUsed = new TimeSpan();
+
+                if (m_CurrentStartTime == m_startTime)
+                {
+                    // first compute time
+                    timeUsed = m_endTime - m_startTime;
+                }
+                else
+                {
+                    // not the first compute time
+                    timeUsed = m_UsedTime + ( m_endTime - m_CurrentStartTime);
+                }
+
+                m_UsedTime = timeUsed;
+            }
+            else
+            {
+                return false;
+            }
+
+            return true;
+
+        }
+    }
+}

+ 56 - 10
SmartSEMControl/HardwareInterface.cs

@@ -38,8 +38,8 @@ namespace SmartSEMControl
         public ISEMControl ISEM
         {
             get { return m_iSEM; }
-        } //属性,只能当前类创建 
-    
+        } //属性,只能当前类创建         
+
     }
     //SEM控制
     public interface ISEMControl
@@ -48,10 +48,22 @@ namespace SmartSEMControl
         float GetMagnification();
         Boolean SetMagnification(float set);
 
+        //FIB缩放
+        float GetFIBMagnification();
+        Boolean SetFIBMagnification(float set);
+
         //焦距
         float GetWorkingDistance();
         Boolean SetWorkingDistance(float set);
 
+        //FIB焦距
+        float GetFIBObjectivePotential();
+        Boolean SetFIBObjectivePotential(float set);
+
+        //自动对焦
+        Boolean CmdAutoFocusCoarse();
+        Boolean CmdAutoFocusFine();
+
         //亮度
         float GetBrightness();
         Boolean SetBrightness(float set);
@@ -73,6 +85,12 @@ namespace SmartSEMControl
         Boolean SetAstigmatismX(float set);
         Boolean SetAstigmatismY(float set);
 
+        //FIB消像散
+        float GetFIBAstigmatismX();
+        float GetFIBAstigmatismY();
+        Boolean SetFIBAstigmatismX(float set);
+        Boolean SetFIBAstigmatismY(float set);
+
         //自动消像散
         Boolean CmdAutoStig();
 
@@ -82,9 +100,9 @@ namespace SmartSEMControl
 
         //抓图
         Boolean GrabImage(String filename, short xoff, short yoff, short width, short height, short type);
-        //解冻
-        Boolean ImageFrozen();
         //冻结
+        Boolean ImageFrozen();
+        //解冻
         Boolean ImageLive();
         //获取分辨率
         int[] GetImageStore();
@@ -115,11 +133,34 @@ namespace SmartSEMControl
         //像素读取PixelSize
         float GetPixelSize();
 
+        //电子束移动接口
+        float GetBeamShiftX();
+        float GetBeamShiftY();
+        Boolean SetBeamShiftX(float set);
+        Boolean SetBeamShiftY(float set);
+
+        //FIB电子束移动接口
+        float GetFIBBeamShiftX();
+        float GetFIBBeamShiftY();
+        Boolean SetFIBBeamShiftX(float set);
+        Boolean SetFIBBeamShiftY(float set);
+
         //电子束校正设置
         float GetTiltCorrection();
         Boolean SetTiltCorrectionOff();
         Boolean SetTiltCorrectionOn();
 
+        //读取FIB模式
+        float GetFIBMode();
+
+        //工作状态读取
+        float GetFIBIMAGING();
+        //工作状态选择
+        Boolean CmdFIBModeSEM();    //SEM模式
+        Boolean CmdFIBModeFIB();    //FIB模式
+        Boolean CmdFIBModeMILL();   //MILL模式
+
+
         //开启电压
         Boolean CmdOpenVoltage();
 
@@ -144,6 +185,15 @@ namespace SmartSEMControl
         //清除控件
         Boolean Dispose();
 
+
+
+
+        //Pt的控制
+        //PT针插入
+        void InsertPT();
+        //PT针退出
+        void OutputPT();
+
     }
 
     interface FIBControl
@@ -152,13 +202,9 @@ namespace SmartSEMControl
 
     }
 
-    interface PtControl
+    interface IPtControl
     {
-        //Pt的控制
-        //PT针插入
-        void InsertPT();
-        //PT针退出
-        void OutputPT();
+       
     }
 
     interface StageControl

+ 321 - 6
SmartSEMControl/SmartSEM.cs

@@ -67,6 +67,19 @@ namespace SmartSEMControl
         private String AP_STAGE_AT_R = "AP_STAGE_AT_R";
         //M轴坐标
         private String AP_STAGE_AT_M = "AP_STAGE_AT_M";
+
+        //FIB缩放
+        private String AP_FIB_MAGNIFICATION = "AP_FIB_MAGNIFICATION";
+        //FIB焦距
+        private String AP_FIB_OBJECTIVE_POTENTIAL = "AP_FIB_OBJECTIVE_POTENTIAL";
+        //FIB消像散X
+        private String AP_FIB_STIGMATOR_X = "AP_FIB_STIGMATOR_X";
+        //FIB消像散Y
+        private String AP_FIB_STIGMATOR_Y = "AP_FIB_STIGMATOR_Y";
+        //FIB光束移动X
+        private String AP_FIB_BEAM_SHIFT_X = "AP_FIB_BEAM_SHIFT_X";
+        //FIB光束移动Y
+        private String AP_FIB_BEAM_SHIFT_Y = "AP_FIB_BEAM_SHIFT_Y";
         #endregion
 
         #region 数字参数
@@ -86,7 +99,12 @@ namespace SmartSEMControl
         //样品台状态
         private String DP_STAGE_IS = "DP_STAGE_IS";
         //自动函数状态
-        private String DP_AUTO_FUNCTION = "DP_AUTO_FUNCTION";        
+        private String DP_AUTO_FUNCTION = "DP_AUTO_FUNCTION";
+
+        //FIB模式
+        private String DP_FIB_MODE = "DP_FIB_MODE";
+        //FIB_IMAGING
+        private String DP_FIB_IMAGING = "DP_FIB_IMAGING";
         #endregion
 
         #region 命令
@@ -102,6 +120,18 @@ namespace SmartSEMControl
         private String CMD_AUTO_STIG = "CMD_AUTO_STIG";
         //样品台急停
         private String CMD_STAGE_ABORT = "CMD_STAGE_ABORT";
+        //FIB模式选择
+        private String CMD_FIB_MODE_SEM = "CMD_FIB_MODE_SEM";
+        private String CMD_FIB_MODE_FIB = "CMD_FIB_MODE_FIB";
+        private String CMD_FIB_MODE_MILL = "CMD_FIB_MODE_MILL";
+        private String CMD_FIB_MODE_SEM_FIB = "CMD_FIB_MODE_SEM_FIB";
+        private String CMD_FIB_MODE_MILL_SEM = "CMD_FIB_MODE_MILL_SEM";
+        private String CMD_FIB_MODE_EXT = "CMD_FIB_MODE_EXT";
+        private String CMD_FIB_MODE_EXT_SEM = "CMD_FIB_MODE_EXT_SEM";
+        private String CMD_FIB_MODE_ARGON_SEM = "CMD_FIB_MODE_ARGON_SEM";
+        private String CMD_FIB_MODE_DRIFT_SEM = "CMD_FIB_MODE_DRIFT_SEM";
+        private String CMD_FIB_MODE_DRIFT_FIB = "CMD_FIB_MODE_DRIFT_FIB";
+        private String CMD_FIB_MODE_ARGON = "CMD_FIB_MODE_ARGON";
         #endregion
 
         #region 宏文件命令
@@ -302,7 +332,7 @@ namespace SmartSEMControl
         }
         #endregion
 
-        #region 放大缩小
+        #region SEM缩
         /// <summary>
         /// 读取缩放倍数
         /// </summary>
@@ -331,7 +361,7 @@ namespace SmartSEMControl
         }
         #endregion
 
-        #region 焦距
+        #region SEM焦距
         /// <summary>
         /// 读取工作距离
         /// </summary>
@@ -520,7 +550,7 @@ namespace SmartSEMControl
         }
         #endregion
 
-        #region 消像散
+        #region SEM消像散
         /// <summary>
         /// 读取消像散X
         /// </summary>
@@ -702,7 +732,7 @@ namespace SmartSEMControl
                 }
                 else
                 {
-                    ImageFrozen();
+                    ImageLive();
                     return true;
                 }
             }
@@ -731,7 +761,7 @@ namespace SmartSEMControl
         }
         #endregion
 
-        #region 电子束移动接口
+        #region SEM电子束移动接口
         /// <summary>
         /// 获取电子束移动接口X
         /// </summary>
@@ -1207,5 +1237,290 @@ namespace SmartSEMControl
             }
         }
         #endregion
+
+        #region FIB缩放
+        /// <summary>
+        /// 读取缩放倍数
+        /// </summary>
+        /// <returns>true:float or false:NaN</returns>
+        public float GetFIBMagnification()
+        {
+            float ret = 0;
+            if (ReadParams(AP_FIB_MAGNIFICATION, ref ret))
+            {
+                return ret;
+            }
+            else
+            {
+                return float.NaN;
+            }
+        }
+
+        /// <summary>
+        /// 设置缩放倍数
+        /// </summary>
+        /// <param name="set">倍数</param>
+        /// <returns>true or false</returns>
+        public Boolean SetFIBMagnification(float set)
+        {
+            return WriteParams(AP_FIB_MAGNIFICATION, set);
+        }
+        #endregion
+
+        #region FIB焦距
+        /// <summary>
+        /// 读取工作距离AP_FIB_OBJECTIVE_POTENTIAL
+        /// </summary>
+        /// <returns>true:float or false:NaN</returns>
+        public float GetFIBObjectivePotential()
+        {
+            float ret = 0;
+            if (ReadParams(AP_FIB_OBJECTIVE_POTENTIAL, ref ret))
+            {
+                return ret;
+            }
+            else
+            {
+                return float.NaN;
+            }
+        }
+
+        /// <summary>
+        /// 设置焦距
+        /// </summary>
+        /// <param name="set">焦距</param>
+        /// <returns>true or false</returns>
+        public Boolean SetFIBObjectivePotential(float set)
+        {
+            return WriteParams(AP_FIB_OBJECTIVE_POTENTIAL, set);
+        }
+        #endregion  
+
+        #region FIB消像散
+        /// <summary>
+        /// 读取消像散X
+        /// </summary>
+        /// <returns>true:float or false:NaN</returns>
+        public float GetFIBAstigmatismX()
+        {
+            float ret = 0;
+            if (ReadParams(AP_FIB_STIGMATOR_X, ref ret))
+            {
+                return ret;
+            }
+            else
+            {
+                return float.NaN;
+            }
+        }
+
+        /// <summary>
+        /// 读取消像散Y
+        /// </summary>
+        /// <returns>true:float or false:NaN</returns>
+        public float GetFIBAstigmatismY()
+        {
+            float ret = 0;
+            if (ReadParams(AP_FIB_STIGMATOR_Y, ref ret))
+            {
+                return ret;
+            }
+            else
+            {
+                return float.NaN;
+            }
+        }
+
+        /// <summary>
+        /// 设置消像散X
+        /// </summary>
+        /// <param name="set">对比度</param>
+        /// <returns>true or false</returns>
+        public Boolean SetFIBAstigmatismX(float set)
+        {
+            return WriteParams(AP_FIB_STIGMATOR_X, set);
+        }
+
+        /// <summary>
+        /// 设置消像散Y
+        /// </summary>
+        /// <param name="set">对比度</param>
+        /// <returns>true or false</returns>
+        public Boolean SetFIBAstigmatismY(float set)
+        {
+            return WriteParams(AP_FIB_STIGMATOR_Y, set);
+        }
+        #endregion
+
+        #region FIB电子束移动接口
+        /// <summary>
+        /// 获取电子束移动接口X
+        /// </summary>
+        /// <returns>true:float or false:NaN</returns>
+        public float GetFIBBeamShiftX()
+        {
+            float ret = 0;
+            if (ReadParams(AP_FIB_BEAM_SHIFT_X, ref ret))
+            {
+                return ret;
+            }
+            else
+            {
+                return float.NaN;
+            }
+        }
+
+        /// <summary>
+        /// 获取电子束移动接口Y
+        /// </summary>
+        /// <returns>true:float or false:NaN</returns>
+        public float GetFIBBeamShiftY()
+        {
+            float ret = 0;
+            if (ReadParams(AP_FIB_BEAM_SHIFT_Y, ref ret))
+            {
+                return ret;
+            }
+            else
+            {
+                return float.NaN;
+            }
+        }
+
+        /// <summary>
+        /// 设置电子束移动接口X
+        /// </summary>
+        /// <param name="set">X坐标</param>
+        /// <returns>true or false</returns>
+        public Boolean SetFIBBeamShiftX(float set)
+        {
+            return WriteParams(AP_FIB_BEAM_SHIFT_X, set);
+        }
+
+        /// <summary>
+        /// 设置电子束移动接口Y
+        /// </summary>
+        /// <param name="set">X坐标</param>
+        /// <returns>true or false</returns>
+        public Boolean SetFIBBeamShiftY(float set)
+        {
+            return WriteParams(AP_FIB_BEAM_SHIFT_Y, set);
+        }
+        #endregion
+
+        #region FIB模式
+        /// <summary>
+        /// 获取FIB模式
+        /// </summary>
+        /// <returns>true:float or false:NaN</returns>
+        public float GetFIBMode()
+        {
+            float ret = 0;
+            if (ReadParams(DP_FIB_MODE, ref ret))
+            {
+                return ret;
+            }
+            else
+            {
+                return float.NaN;
+            }
+        }
+        #endregion
+
+        #region 工作模式选择
+        //SEM模式
+        public Boolean CmdFIBModeSEM()
+        {
+            return ExecuteCmd(CMD_FIB_MODE_SEM);
+        }
+
+        //FIB模式
+        public Boolean CmdFIBModeFIB()
+        {
+            return ExecuteCmd(CMD_FIB_MODE_FIB);
+        }
+
+        //铣削模式
+        public Boolean CmdFIBModeMILL()
+        {
+            return ExecuteCmd(CMD_FIB_MODE_MILL);
+        }
+
+        //SEM+FIB模式
+        public Boolean CmdFIBModeSEMAndFIB()
+        {
+            return ExecuteCmd(CMD_FIB_MODE_SEM_FIB);
+        }
+
+        //铣削+SEM模式
+        public Boolean CmdFIBModeMILLAndSEM()
+        {
+            return ExecuteCmd(CMD_FIB_MODE_MILL_SEM);
+        }
+
+        //EXT模式
+        public Boolean CmdFIBModeEXT()
+        {
+            return ExecuteCmd(CMD_FIB_MODE_EXT);
+        }
+
+        //EXT+SEM模式
+        public Boolean CmdFIBModeEXTAndSEM()
+        {
+            return ExecuteCmd(CMD_FIB_MODE_EXT_SEM);
+        }
+
+        //Argon(氩)+SEM模式
+        public Boolean CmdFIBModeARGONAndSEM()
+        {
+            return ExecuteCmd(CMD_FIB_MODE_ARGON_SEM);
+        }
+
+        //DRIFT(流)+SEM模式
+        public Boolean CmdFIBModeDRIFTAndSEM()
+        {
+            return ExecuteCmd(CMD_FIB_MODE_DRIFT_SEM);
+        }
+
+        //DRIFT(流)+FIB模式
+        public Boolean CmdFIBModeDRIFTAndFIB()
+        {
+            return ExecuteCmd(CMD_FIB_MODE_DRIFT_FIB);
+        }
+
+        //Argon(氩)模式
+        public Boolean CmdFIBModeARGON()
+        {
+            return ExecuteCmd(CMD_FIB_MODE_ARGON);
+        }
+        #endregion
+
+        #region 工作模式读取
+        /// <summary>
+        /// 工作模式读取
+        /// </summary>
+        /// <returns>0:SEM 1:FIB 2:MILL</returns>
+        public float GetFIBIMAGING()
+        {
+            float ret = 0;
+            if (ReadParams(DP_FIB_IMAGING, ref ret))
+            {
+                return ret;
+            }
+            else
+            {
+                return float.NaN;
+            }
+        }
+        #endregion
+
+        //PT针插入
+        public void InsertPT()
+        {
+        }
+        //PT针退出
+        public void OutputPT()
+        {
+        }
     }
 }

Някои файлове не бяха показани, защото твърде много файлове са промени