Ejemplo n.º 1
0
        private bool getMeshNodeCoordinate(string strMeshFileFullName, ref List <double> listDataX, ref List <double> listDataY, ref List <double> listDataZ)
        {
            CReadFile readFile = new CReadFile();

            List <string> listBlockLines = new List <string>();
            List <double> listColumnData = new List <double>();

            try
            {
                readFile.readBlock(strMeshFileFullName, ref listBlockLines, "$Nodes", "$EndNodes");

                foreach (string strLine in listBlockLines)
                {
                    CParsing.getDataInAllLine(strLine, ref listColumnData, ' ');

                    // 3개의 데이터일때만 좌표 데이터 이다.
                    if (listColumnData.Count == 3)
                    {
                        listDataX.Add(listColumnData[0]);
                        listDataY.Add(listColumnData[1]);
                        listDataZ.Add(listColumnData[2]);
                    }

                    listColumnData.Clear();
                }
            }
            catch (Exception ex)
            {
                CNotice.printTrace(ex.Message);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 2
0
        public static bool checkPreviousFEMM()
        {
            try
            {
                // FEMM 설치 메인 디렉토리를 얻어낸다.
                string strFEMMDirName = Path.GetDirectoryName(CSettingData.m_strFemmExeFileFullName);
                strFEMMDirName = strFEMMDirName.Remove(strFEMMDirName.IndexOf("bin"));

                // readme.txt 의 첫 줄을 읽어낸다.
                string strReadmeFileFullName = Path.Combine(strFEMMDirName, "readme.txt");

                CReadFile readFile       = new CReadFile();
                string    strVersionFEMM = readFile.getLine(strReadmeFileFullName, 1);      // 내용 : FEMM 4.2 12Jan2016

                // readme.txt 에서 FEMM 4.2 버전의 Build 날짜를 읽어낸다.
                char[]   separators = { ' ' };
                string[] strArray;
                strArray = strVersionFEMM.Split(separators, StringSplitOptions.None);
                string strVersionDate = strArray[2];                                        // 내용 : 12Jan2016

                if (strVersionDate.Length < 9)
                {
                    CNotice.printLogID("TWAP4");
                    return(false);
                }

                DateTime currentDataTime = new DateTime();
                DateTime limitDataTime   = new DateTime();

                limitDataTime   = Convert.ToDateTime("24Sep2017");
                currentDataTime = Convert.ToDateTime(strVersionDate);

                // 24Sep2017 보다 이전 버전이면 true 를 리턴한다.
                if (currentDataTime < limitDataTime)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                CNotice.printLog(ex.Message);
                return(false);
            }
        }
Ejemplo n.º 3
0
        public bool attachDefault(string strExperimentFullName, CPoint pointBoundaryBlock)
        {
            CReadFile   readFile   = new CReadFile();
            CManageFile manageFile = new CManageFile();

            List <string> listString = new List <string>();
            string        strLine    = string.Empty;

            char[]   separators = { ' ', '\t' };
            string[] strArray;

            string strFileName         = Path.GetFileNameWithoutExtension(strExperimentFullName);
            string strTempFileFullName = Path.Combine(Path.GetDirectoryName(strExperimentFullName), strFileName + "_temp.fem");

            if (manageFile.isExistFile(strExperimentFullName) == false)
            {
                CNotice.printTraceID("NFFF");
                return(false);
            }
            else
            {
                File.Move(strExperimentFullName, strTempFileFullName);
            }

            StreamWriter writeFile    = new StreamWriter(strExperimentFullName);
            int          iNumBlock    = 0;
            int          nCountBlock  = 0;
            bool         bBlockLabels = false;

            try
            {
                readFile.getAllLines(strTempFileFullName, ref listString);

                for (int i = 0; i < listString.Count; i++)
                {
                    strLine = listString[i];

                    strArray = strLine.Split(separators, StringSplitOptions.None);

                    if (strArray[0] == "[NumBlockLabels]")
                    {
                        iNumBlock    = Int32.Parse(strArray[2]);
                        nCountBlock  = 0;
                        bBlockLabels = true;

                        writeFile.WriteLine(strLine);

                        /// 구분 Label 행은 건너 뛴다.
                        continue;
                    }

                    if (bBlockLabels == true)
                    {
                        if (pointBoundaryBlock.m_dX == Double.Parse(strArray[0]) && pointBoundaryBlock.m_dY == Double.Parse(strArray[1]))
                        {
                            if (strArray.Length != 9)
                            {
                                CNotice.printTraceID("TWAP2");
                                return(false);
                            }

                            /// dettach block setting
                            strArray[8] = "2";
                            strLine     = string.Empty;

                            foreach (string str in strArray)
                            {
                                strLine += str + '\t';
                            }
                        }

                        nCountBlock++;

                        if (nCountBlock >= iNumBlock)
                        {
                            bBlockLabels = false;
                        }
                    }

                    writeFile.WriteLine(strLine);
                }

                File.Delete(strTempFileFullName);
            }
            catch (Exception ex)
            {
                CNotice.printTrace(ex.Message);
                writeFile.Close();
                return(false);
            }

            writeFile.Close();
            return(true);
        }
Ejemplo n.º 4
0
        // 코일에 대한 문자열 라인을 넘겨 받아서 코일 객체를 초기화 한다.
        public bool readObject(List <string> listStringLines)
        {
            CReadFile readFile = new CReadFile();
            string    strTemp;

            string[] arrayString;

            List <string> listInformationLines = new List <string>();
            List <string> listShapeLines       = new List <string>();

            bool bShapeLine = false;

            if (m_kindKey != EMKind.STEEL)
            {
                CNotice.printTraceID("YATT6");
                return(false);
            }

            try
            {
                // Shape 라인과 정보 라인을 분리한다.
                foreach (string strLine in listStringLines)
                {
                    if (readFile.isEndLine(strLine) == "Shape")
                    {
                        bShapeLine = false;
                    }

                    if (bShapeLine == true)
                    {
                        listShapeLines.Add(strLine);
                    }
                    else
                    {
                        if (readFile.isBeginLine(strLine) == "Shape")
                        {
                            bShapeLine = true;
                        }
                        else
                        {
                            listInformationLines.Add(strLine);
                        }
                    }
                }

                // 정보 라인을 처리한다.
                foreach (string strLine in listInformationLines)
                {
                    strTemp = strLine.Trim('\t');

                    arrayString = strTemp.Split('=');

                    if (arrayString.Length != 2)
                    {
                        CNotice.noticeWarningID("TIAP5");
                        return(false);
                    }

                    switch (arrayString[0])
                    {
                    // CNode
                    case "NodeName":
                        NodeName = arrayString[1];
                        break;

                    case "KindKey":
                        m_kindKey = (EMKind)Enum.Parse(typeof(EMKind), arrayString[1]);
                        break;

                    // CParts
                    case "MovingParts":
                        MovingPart = (EMMoving)Enum.Parse(typeof(EMMoving), arrayString[1]);
                        break;

                    // CSteel
                    case "Material":
                        Material = arrayString[1];
                        break;

                    default:
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                CNotice.printTrace(ex.Message);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 5
0
        // 코일에 대한 문자열 라인을 넘겨 받아서 코일 객체를 초기화 한다.
        public bool readObject(List <string> listStringLines)
        {
            CReadFile readFile = new CReadFile();
            string    strTemp;

            string[] arrayString;

            List <string> listInformationLines = new List <string>();
            List <string> listShapeLines       = new List <string>();

            bool bShapeLine = false;

            if (m_kindKey != EMKind.COIL)
            {
                CNotice.printTraceID("YATT7");
                return(false);
            }

            try
            {
                // Shape 라인과 정보 라인을 분리한다.
                foreach (string strLine in listStringLines)
                {
                    if (readFile.isEndLine(strLine) == "Shape")
                    {
                        bShapeLine = false;
                    }

                    if (bShapeLine == true)
                    {
                        listShapeLines.Add(strLine);
                    }
                    else
                    {
                        if (readFile.isBeginLine(strLine) == "Shape")
                        {
                            bShapeLine = true;
                        }
                        else
                        {
                            listInformationLines.Add(strLine);
                        }
                    }
                }

                // 정보 라인을 처리한다.
                foreach (string strLine in listInformationLines)
                {
                    strTemp = strLine.Trim('\t');

                    arrayString = strTemp.Split('=');


                    switch (arrayString[0])
                    {
                    // CNode
                    case "NodeName":
                        NodeName = arrayString[1];
                        break;

                    case "KindKey":
                        m_kindKey = (EMKind)Enum.Parse(typeof(EMKind), arrayString[1]);
                        break;

                    // CParts
                    case "MovingParts":
                        MovingPart = (EMMoving)Enum.Parse(typeof(EMMoving), arrayString[1]);
                        break;

                    // CCoil
                    case "Material":
                        Material = arrayString[1];
                        break;

                    case "CurrentDirection":
                        CurrentDirection = (EMCurrentDirection)Enum.Parse(typeof(EMCurrentDirection), arrayString[1]);
                        break;

                    case "Turns":
                        Turns = Convert.ToInt16(arrayString[1]);
                        break;

                    case "Resistance":
                        Resistance = Convert.ToDouble(arrayString[1]);
                        break;

                    case "Layers":
                        Layers = Convert.ToInt16(arrayString[1]);
                        break;

                    case "TurnsOfOneLayer":
                        TurnsOfOneLayer = Convert.ToInt16(arrayString[1]);
                        break;

                    case "CoilWireGrade":
                        CoilWireGrade = (EMCoilWireGrade)Enum.Parse(typeof(EMCoilWireGrade), arrayString[1]);
                        break;

                    case "InnerDiameter":
                        InnerDiameter = Convert.ToDouble(arrayString[1]);
                        break;

                    case "OuterDiameter":
                        OuterDiameter = Convert.ToDouble(arrayString[1]);
                        break;

                    case "Height":
                        Height = Convert.ToDouble(arrayString[1]);
                        break;

                    case "CopperDiameter":
                        CopperDiameter = Convert.ToDouble(arrayString[1]);
                        break;

                    case "WireDiameter":
                        WireDiameter = Convert.ToDouble(arrayString[1]);
                        break;

                    case "Temperature":
                        Temperature = Convert.ToDouble(arrayString[1]);
                        break;

                    case "HorizontalCoefficient":
                        HorizontalCoefficient = Convert.ToDouble(arrayString[1]);
                        break;

                    case "VerticalCoefficient":
                        VerticalCoefficient = Convert.ToDouble(arrayString[1]);
                        break;

                    case "ResistanceCoefficient":
                        ResistanceCoefficient = Convert.ToDouble(arrayString[1]);
                        break;

                    default:
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                CNotice.printTrace(ex.Message);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 6
0
        // 코일에 대한 문자열 라인을 넘겨 받아서 코일 객체를 초기화 한다.
        public bool readObject(List <string> listStringLines)
        {
            CReadFile readFile = new CReadFile();
            string    strTemp;

            string[] arrayString;

            List <string> listInformationLines = new List <string>();
            List <string> listShapeLines       = new List <string>();

            bool bShapeLine = false;

            if (KindKey != EMKind.MAGNET)
            {
                CNotice.printLogID("YATT5");
                return(false);
            }

            try
            {
                // Shape 라인과 정보 라인을 분리한다.
                foreach (string strLine in listStringLines)
                {
                    if (readFile.isEndLine(strLine) == "Shape")
                    {
                        bShapeLine = false;
                    }

                    if (bShapeLine == true)
                    {
                        listShapeLines.Add(strLine);
                    }
                    else
                    {
                        if (readFile.isBeginLine(strLine) == "Shape")
                        {
                            bShapeLine = true;
                        }
                        else
                        {
                            listInformationLines.Add(strLine);
                        }
                    }
                }

                // 정보 라인을 처리한다.
                foreach (string strLine in listInformationLines)
                {
                    strTemp = strLine.Trim('\t');

                    arrayString = strTemp.Split('=');

                    if (arrayString.Length != 2)
                    {
                        CNotice.noticeWarningID("TIAP4");
                        return(false);
                    }

                    switch (arrayString[0])
                    {
                    // CNode
                    case "NodeName":
                        NodeName = arrayString[1];
                        break;

                    case "KindKey":
                        KindKey = (EMKind)Enum.Parse(typeof(EMKind), arrayString[1]);
                        break;

                    // CParts
                    case "MovingParts":
                        MovingPart = (EMMoving)Enum.Parse(typeof(EMMoving), arrayString[1]);
                        break;

                    // CMagnet
                    case "Material":

                        m_strMaterialName = arrayString[1];

                        // FEMM (21Apr2019)에서 NdFeB 40 MGOe 빠져 있어서 호환이 되지 않아 강제로 N40 으로 변경한다.
                        // 추후에 FEMM 에 NdFeB 40 MGOe 가 Legacy 로 추가되면 아래의 코드를 삭제하라.
                        if (CProgramFEMM.getYearFEMM() >= 2019)
                        {
                            if (m_strMaterialName == "NdFeB 40 MGOe")
                            {
                                m_strMaterialName = "N40";
                            }
                        }

                        if (CMaterialListInFEMM.isMagnetlInList(m_strMaterialName) == false)
                        {
                            // 현재의 버전에서 사용할 수 없는 재질이 존재한다면 공백으로 처리하고
                            // 동작 중에 공백을 사용해서 재질이 초기화 되지 않음을 확인한다.
                            m_strMaterialName = "";
                        }

                        break;

                    case "MagnetDirection":
                        emMagnetDirection = (EMMagnetDirection)Enum.Parse(typeof(EMMagnetDirection), arrayString[1]);
                        break;

                    default:
                        break;
                    }
                }

                // Shape 정보가 있는 경우만 m_face 를 생성하고 읽기 작업을 진행한다.
                if (listShapeLines.Count > 0)
                {
                    m_face = new CFace();
                    m_face.readObject(listShapeLines);
                }
            }
            catch (Exception ex)
            {
                CNotice.printLog(ex.Message);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 7
0
        // 코일에 대한 문자열 라인을 넘겨 받아서 코일 객체를 초기화 한다.
        public bool readObject(List <string> listStringLines)
        {
            CReadFile readFile = new CReadFile();
            string    strTemp;

            string[] arrayString;

            List <string> listInformationLines = new List <string>();
            List <string> listShapeLines       = new List <string>();

            bool bShapeLine = false;

            if (KindKey != EMKind.COIL)
            {
                CNotice.printLogID("YATT7");
                return(false);
            }

            try
            {
                // Shape 라인과 정보 라인을 분리한다.
                foreach (string strLine in listStringLines)
                {
                    if (readFile.isEndLine(strLine) == "Shape")
                    {
                        bShapeLine = false;
                    }

                    if (bShapeLine == true)
                    {
                        listShapeLines.Add(strLine);
                    }
                    else
                    {
                        if (readFile.isBeginLine(strLine) == "Shape")
                        {
                            bShapeLine = true;
                        }
                        else
                        {
                            listInformationLines.Add(strLine);
                        }
                    }
                }

                // 정보 라인을 처리한다.
                foreach (string strLine in listInformationLines)
                {
                    strTemp = strLine.Trim('\t');

                    arrayString = strTemp.Split('=');


                    switch (arrayString[0])
                    {
                    // CNode
                    case "NodeName":
                        NodeName = arrayString[1];
                        break;

                    case "KindKey":
                        KindKey = (EMKind)Enum.Parse(typeof(EMKind), arrayString[1]);
                        break;

                    // CParts
                    case "MovingParts":
                        MovingPart = (EMMoving)Enum.Parse(typeof(EMMoving), arrayString[1]);
                        break;

                    // CCoil
                    case "Material":
                        if (CMaterialListInFEMM.isCoilWIreInList(arrayString[1]) == true)
                        {
                            m_strMaterialName = arrayString[1];
                        }
                        else
                        {
                            // 현재의 버전에서 사용할 수 없는 재질이 존재한다면 공백으로 처리하고
                            // 동작 중에 공백을 사용해서 재질이 초기화 되지 않음을 확인한다.
                            m_strMaterialName = "";
                        }
                        break;

                    case "CurrentDirection":
                        CurrentDirection = (EMCurrentDirection)Enum.Parse(typeof(EMCurrentDirection), arrayString[1]);
                        break;

                    case "Turns":
                        Turns = Convert.ToInt16(arrayString[1]);
                        break;

                    case "Resistance":
                        Resistance = Convert.ToDouble(arrayString[1]);
                        break;

                    case "Resistance_20":
                        Resistance_20 = Convert.ToDouble(arrayString[1]);
                        break;

                    case "Layers":
                        Layers = Convert.ToInt16(arrayString[1]);
                        break;

                    case "TurnsOfOneLayer":
                        TurnsOfOneLayer = Convert.ToInt16(arrayString[1]);
                        break;

                    case "CoilWireGrade":
                        CoilWireGrade = (EMCoilWireGrade)Enum.Parse(typeof(EMCoilWireGrade), arrayString[1]);
                        break;

                    case "InnerDiameter":
                        InnerDiameter = Convert.ToDouble(arrayString[1]);
                        break;

                    case "OuterDiameter":
                        OuterDiameter = Convert.ToDouble(arrayString[1]);
                        break;

                    case "Height":
                        Height = Convert.ToDouble(arrayString[1]);
                        break;

                    case "CopperDiameter":
                        CopperDiameter = Convert.ToDouble(arrayString[1]);
                        break;

                    case "WireDiameter":
                        WireDiameter = Convert.ToDouble(arrayString[1]);
                        break;

                    case "Temperature":
                        Temperature = Convert.ToDouble(arrayString[1]);
                        break;

                    case "HorizontalCoefficient":
                        HorizontalCoefficient = Convert.ToDouble(arrayString[1]);
                        break;

                    case "VerticalCoefficient":
                        VerticalCoefficient = Convert.ToDouble(arrayString[1]);
                        break;

                    case "ResistanceCoefficient":
                        ResistanceCoefficient = Convert.ToDouble(arrayString[1]);
                        break;

                    default:
                        break;
                    }
                }

                // Shape 정보가 있는 경우만 m_face 를 생성하고 읽기 작업을 진행한다.
                if (listShapeLines.Count > 0)
                {
                    m_face = new CFace();
                    m_face.readObject(listShapeLines);
                }
            }
            catch (Exception ex)
            {
                CNotice.printLog(ex.Message);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 8
0
        // 코일에 대한 문자열 라인을 넘겨 받아서 코일 객체를 초기화 한다.
        public bool readObject(List <string> listStringLines)
        {
            CReadFile readFile = new CReadFile();
            string    strTemp;

            string[] arrayString;

            List <string> listInformationLines = new List <string>();
            List <string> listShapeLines       = new List <string>();

            bool bShapeLine = false;

            if (KindKey != EMKind.NON_KIND)
            {
                CNotice.printLog("NON_KIND 가 아닌 객체가 CNonKind 로 열리려고 한다.");
                return(false);
            }

            try
            {
                // Shape 라인과 정보 라인을 분리한다.
                foreach (string strLine in listStringLines)
                {
                    if (readFile.isEndLine(strLine) == "Shape")
                    {
                        bShapeLine = false;
                    }

                    if (bShapeLine == true)
                    {
                        listShapeLines.Add(strLine);
                    }
                    else
                    {
                        if (readFile.isBeginLine(strLine) == "Shape")
                        {
                            bShapeLine = true;
                        }
                        else
                        {
                            listInformationLines.Add(strLine);
                        }
                    }
                }

                // 정보 라인을 처리한다.
                foreach (string strLine in listInformationLines)
                {
                    strTemp = strLine.Trim('\t');

                    arrayString = strTemp.Split('=');

                    /// 각 줄의 String 배열은 항상 2개이여야 한다.
                    if (arrayString.Length != 2)
                    {
                        CNotice.printLog("Non-Kind 데이터에 문제가 있습니다.");
                        return(false);
                    }

                    switch (arrayString[0])
                    {
                    // CNode
                    case "NodeName":
                        NodeName = arrayString[1];
                        break;

                    case "KindKey":
                        KindKey = (EMKind)Enum.Parse(typeof(EMKind), arrayString[1]);
                        break;

                    // Non Kind 는 CNode 의 정보와 CShapParts 의 Face 정보만 필요하기 때문에
                    // 나머지 정보는 저장하지 않는다.
                    //
                    // CShapeParts
                    //case "MovingParts":
                    //    MovingPart = (EMMoving)Enum.Parse(typeof(EMMoving), arrayString[1]);
                    //    break;

                    default:
                        break;
                    }
                }

                // Shape 정보가 있는 경우만 m_face 를 생성하고 읽기 작업을 진행한다.
                if (listShapeLines.Count > 0)
                {
                    m_face = new CFace();

                    if (m_face == null)
                    {
                        CNotice.printLogID("IIAT");
                    }
                    else
                    {
                        m_face.readObject(listShapeLines);
                    }
                }
            }
            catch (Exception ex)
            {
                CNotice.printLog(ex.Message);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 9
0
        // 코일에 대한 문자열 라인을 넘겨 받아서 코일 객체를 초기화 한다.
        public bool readObject(List <string> listStringLines)
        {
            CReadFile readFile = new CReadFile();
            string    strTemp;

            string[] arrayString;

            List <string> listInformationLines = new List <string>();
            List <string> listShapeLines       = new List <string>();

            bool bShapeLine = false;

            if (KindKey != EMKind.STEEL)
            {
                CNotice.printLogID("YATT6");
                return(false);
            }

            try
            {
                // Shape 라인과 정보 라인을 분리한다.
                foreach (string strLine in listStringLines)
                {
                    if (readFile.isEndLine(strLine) == "Shape")
                    {
                        bShapeLine = false;
                    }

                    if (bShapeLine == true)
                    {
                        listShapeLines.Add(strLine);
                    }
                    else
                    {
                        if (readFile.isBeginLine(strLine) == "Shape")
                        {
                            bShapeLine = true;
                        }
                        else
                        {
                            listInformationLines.Add(strLine);
                        }
                    }
                }

                // 정보 라인을 처리한다.
                foreach (string strLine in listInformationLines)
                {
                    strTemp = strLine.Trim('\t');

                    arrayString = strTemp.Split('=');

                    if (arrayString.Length != 2)
                    {
                        CNotice.noticeWarningID("TIAP5");
                        return(false);
                    }

                    switch (arrayString[0])
                    {
                    // CNode
                    case "NodeName":
                        NodeName = arrayString[1];
                        break;

                    case "KindKey":
                        KindKey = (EMKind)Enum.Parse(typeof(EMKind), arrayString[1]);
                        break;

                    // CParts
                    case "MovingParts":
                        MovingPart = (EMMoving)Enum.Parse(typeof(EMMoving), arrayString[1]);
                        break;

                    // CSteel
                    case "Material":
                        if (CMaterialListInFEMM.isSteelInList(arrayString[1]) == true)
                        {
                            m_strMaterialName = arrayString[1];
                        }
                        else
                        {
                            // 현재의 버전에서 사용할 수 없는 재질이 존재한다면 공백으로 처리하고
                            // 동작 중에 공백을 사용해서 재질이 초기화 되지 않음을 확인한다.
                            m_strMaterialName = "";
                        }
                        break;

                    default:
                        break;
                    }
                }

                // Shape 정보가 있는 경우만 m_face 를 생성하고 읽기 작업을 진행한다.
                if (listShapeLines.Count > 0)
                {
                    m_face = new CFace();
                    m_face.readObject(listShapeLines);
                }
            }
            catch (Exception ex)
            {
                CNotice.printLog(ex.Message);
                return(false);
            }

            return(true);
        }