Пример #1
0
        public bool loadSettingFromFile()
        {
            string strAppDataPath     = Environment.GetEnvironmentVariable("APPDATA");
            string strSettingFilePath = Path.Combine(strAppDataPath, "DoSA-Open_2D");

            string strSettingFileFullName = Path.Combine(strSettingFilePath, "setting.ini");


            // CSettingData.ProgramDirectory 가 초기화 되어 있어야 한다.
            if (m_manageFile.isExistFile(strSettingFileFullName) == false)
            {
                CNotice.noticeWarningID("TCFD");
                return(false);
            }

            try
            {
                XmlSerializer xmlSerializer = new XmlSerializer(typeof(CSettingDataClone));
                StreamReader  reader        = new StreamReader(strSettingFileFullName);

                CSettingDataClone settingDataClone = new CSettingDataClone();
                settingDataClone = (CSettingDataClone)xmlSerializer.Deserialize(reader);

                settingDataClone.copyCloneToSettingData();

                reader.Close();
            }
            catch (Exception ex)
            {
                CNotice.printTrace(ex.Message);
                CNotice.printTraceID("AEOW");
            }

            return(true);
        }
Пример #2
0
        private void buttonSolenoidGuide_Click(object sender, EventArgs e)
        {
            string      strHelpFileFullName;
            CultureInfo ctInfo = Thread.CurrentThread.CurrentCulture;

            if (ctInfo.Name == "en-US")
            {
                strHelpFileFullName = Path.Combine(CSettingData.m_strProgramDirName, "Help", "Solenoid_Sample_ENG.pdf");
            }
            else if (ctInfo.Name == "ko-KR")
            {
                strHelpFileFullName = Path.Combine(CSettingData.m_strProgramDirName, "Help", "Solenoid_Sample_KOR.pdf");
            }
            else
            {
                return;
            }

            if (m_manageFile.isExistFile(strHelpFileFullName) == false)
            {
                CNotice.noticeWarningID("HFDN1");
                return;
            }

            System.Diagnostics.Process.Start(strHelpFileFullName);
        }
Пример #3
0
        public static void moveFEMM(int iPosX, int iPosY, int iSizeX = 500, int iSizeY = 900)
        {
            try
            {
                Process[] processList = Process.GetProcessesByName("femm");

                if (processList.Length > 1)
                {
                    CNotice.noticeWarningID("OOFP");
                    return;
                }

                if (processList.Length != 1)
                {
                    return;
                }

                Process femmProcess = processList[0];

                Thread.Sleep(100);
                MoveWindow(femmProcess.MainWindowHandle, iPosX, iPosY, iSizeX, iSizeY, true);
            }
            catch (Exception ex)
            {
                CNotice.printLog(ex.Message);
                return;
            }
        }
Пример #4
0
        public static void showFEMM()
        {
            Process[] processList = Process.GetProcessesByName("femm");

            if (processList.Length > 1)
            {
                CNotice.noticeWarningID("OOFP");
                return;
            }

            if (processList.Length != 1)
            {
                return;
            }

            Process femmProcess = processList[0];

            Thread.Sleep(100);

            // 윈도우가 최소화 되어 있다면 활성화 시킨다
            ShowWindowAsync(femmProcess.MainWindowHandle, SW_SHOWNORMAL);

            // 윈도우에 포커스를 줘서 최상위로 만든다
            SetForegroundWindow(femmProcess.MainWindowHandle);
        }
Пример #5
0
        public static bool isOpenedWindow()
        {
            Process[] processList = Process.GetProcessesByName("femm");

            if (processList.Length > 1)
            {
                CNotice.noticeWarningID("OOFP");
                return(false);
            }

            if (processList.Length != 1)
            {
                return(false);
            }

            Process femmProcess = processList[0];

            // Window 닫혀 있으면 Main Window Handle 값이 null 이다.
            if (femmProcess.MainWindowTitle != "")
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #6
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            /// 완벽한 입력인 상태에서만 Draw 및 저장이 가능한다.
            if (isInputDataOK() == false)
            {
                DialogResult = DialogResult.Cancel;
                return;
            }

            if (PartType == EMKind.COIL && FaceType == EMFaceType.POLYGON)
            {
                if (false == isRectangleShapeInPopup())
                {
                    if (CSettingData.m_emLanguage == EMLanguage.Korean)
                    {
                        CNotice.noticeWarning("Coil 의 형상이 직사각형이 아닙니다.\nCoil 지정을 취소합니다.");
                    }
                    else
                    {
                        CNotice.noticeWarning("The shape of the Coil is not rectangular.\n.Cancels the Coil assignment.");
                    }

                    DialogResult = DialogResult.Cancel;
                    return;
                }
            }

            // 확인을 위해 임시 생성한다.
            CFace faceTemp = makeFaceInPopup();

            if (faceTemp == null)
            {
                CNotice.noticeWarningID("TWAP1");
                DialogResult = DialogResult.Cancel;
                return;
            }

            if (false == faceTemp.isShapeOK())
            {
                CNotice.printLogID("TWAP3");
                DialogResult = DialogResult.Cancel;
                return;
            }

            FormMain formMain = ((FormMain)this.Owner);

            if (formMain != null)
            {
                // 혹시 FEMM 의 화면이 닫힌 경우 FEMM 의 화면을 복원합니다.
                formMain.reopenFEMM();
            }

            m_strPartName = textBoxPartName.Text;

            // 문제가 없으면 정상 종료를 리턴한다.
            DialogResult = DialogResult.OK;
        }
Пример #7
0
        public bool isDesignShapeOK(double dStroke = 0)
        {
            CFace  face      = null;
            bool   bError    = false;
            CParts nodeParts = null;

            // Moving Part 를 Stroke 만큼 이동시킨다.
            foreach (CNode node in NodeList)
            {
                if (node.GetType().BaseType.Name == "CParts")
                {
                    nodeParts = (CParts)node;

                    if (nodeParts.MovingPart == EMMoving.MOVING)
                    {
                        face = nodeParts.Face;
                        face.BasePoint.m_dY = face.BasePoint.m_dY + dStroke;
                    }
                }
            }

            if (isIntersectedAllLines() == true)
            {
                CNotice.noticeWarningID("LCBP");
                bError = true;
            }

            if (isContactedMovingParts() == true)
            {
                CNotice.noticeWarningID("IHOT");
                bError = true;
            }

            // Moving Part 를 Stroke 만큼 복원 시킨다.
            foreach (CNode node in NodeList)
            {
                if (node.GetType().BaseType.Name == "CParts")
                {
                    nodeParts = (CParts)node;

                    if (nodeParts.MovingPart == EMMoving.MOVING)
                    {
                        face = nodeParts.Face;
                        face.BasePoint.m_dY = face.BasePoint.m_dY - dStroke;
                    }
                }
            }

            if (bError == true)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Пример #8
0
        public static void moveGmshWindow(int iPosX, int iPosY, int iSizeX = 1024, int iSizeY = 768)
        {
            Process[] processList = Process.GetProcessesByName("gmsh");

            if (processList.Length > 1)
            {
                CNotice.noticeWarningID("OOFP");
                return;
            }

            if (processList.Length != 1)
            {
                return;
            }

            Thread.Sleep(100);
            MoveWindow(m_process.MainWindowHandle, iPosX, iPosY, iSizeX, iSizeY, true);
        }
Пример #9
0
        public bool loadSettingFromFile()
        {
            string strAppDataPath     = Environment.GetEnvironmentVariable("APPDATA");
            string strSettingFilePath = Path.Combine(strAppDataPath, "DoSA-2D");

            string strSettingFileFullName = Path.Combine(strSettingFilePath, "setting.ini");


            // CSettingData.ProgramDirectory 가 초기화 되어 있어야 한다.
            if (m_manageFile.isExistFile(strSettingFileFullName) == false)
            {
                CNotice.noticeWarningID("TCFD");
                return(false);
            }

            try
            {
                XmlSerializer xmlSerializer = new XmlSerializer(typeof(CSettingDataClone));
                StreamReader  reader        = new StreamReader(strSettingFileFullName);

                CSettingDataClone settingDataClone = new CSettingDataClone();
                settingDataClone = (CSettingDataClone)xmlSerializer.Deserialize(reader);

                settingDataClone.copyCloneToSettingData();

                reader.Close();

                // 혹시 데이터의 오류는 발생하더라도 하나만 오류가 발생한다.
                // 따라서 다른 항목까지 다시 설정하지 않도록 오류가 있는 데이터라도 파일에서 읽어드림과 동시에 창에 입력해 둔다.
                uploadSettingData();
            }
            catch (Exception ex)
            {
                CNotice.printLog(ex.Message);
                CNotice.printLogID("AEOW");
            }

            return(true);
        }
Пример #10
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            /// 완벽한 입력인 상태에서만 Draw 및 저장이 가능한다.
            if (isInputDataOK() == false)
            {
                return;
            }

            /// 형상 유효성 확인
            ///
            CFace face = makeFace();

            if (face == null)
            {
                CNotice.noticeWarningID("TWAP1");
                return;
            }

            if (false == face.isShapeOK())
            {
                CNotice.printTraceID("TWAP3");
                return;
            }

            m_strPartName     = textBoxPartName.Text;
            this.DialogResult = DialogResult.OK;

            FormMain formMain = ((FormMain)this.Owner);

            if (formMain == null)
            {
                CNotice.printTraceID("CNGM");
                return;
            }

            // 혹시 FEMM 의 화면이 닫힌 경우 FEMM 의 화면을 복원합니다.
            formMain.reopenFEMM();
        }
Пример #11
0
        public void buttonDraw_Click(object sender, EventArgs e)
        {
            try
            {
                /// 완벽한 입력인 상태에서만 Draw 가 가능한다.
                bool retOK = isInputDataOK();

                if (retOK == false)
                {
                    return;
                }

                /// [문제]
                ///  - Form 에서는 Parent를 사용할 수 없어 Owner 속성을 사용하지만
                ///    종종 Owner 가 null 로 넘어오는 문제가 발생한다.
                /// [해결]
                ///  - PopupShape 창을 생성하기 전에 Owner 속성을 FormMain 으로 초기화 해 두어야
                ///    확실하게 FormMain 을 얻을 수 있다.
                FormMain formMain = ((FormMain)this.Owner);

                if (formMain == null)
                {
                    CNotice.printLogID("CNGM");
                    return;
                }

                /// 형상 유효성 확인을 위해 임시로 생성한다.
                ///
                CFace faceTemp = makeFaceInPopup();

                if (faceTemp == null)
                {
                    CNotice.noticeWarningID("TWAP1");
                    return;
                }

                if (false == faceTemp.isShapeOK())
                {
                    CNotice.printLogID("TWAP3");
                    return;
                }

                CScriptFEMM femm = formMain.m_femm;

                femm.deleteAll();

                /// 1. 작업 중인 Face 를 제외하고 형상 그리기
                foreach (CDataNode node in formMain.m_design.GetNodeList)
                {
                    if (node.GetType().BaseType.Name == "CShapeParts")
                    {
                        if (node.NodeName != m_strPartName)
                        {
                            ((CShapeParts)node).Face.drawFace(femm);
                        }
                    }
                }

                // FEMM 을 최상위로 올린다.
                CProgramFEMM.showFEMM();

                // 혹시 FEMM 의 화면이 닫힌 경우 FEMM 의 화면을 복원합니다.
                formMain.reopenFEMM();

                /// 2. 작업중인 Face 형상 그리기
                faceTemp.drawFace(femm);
            }
            catch (Exception ex)
            {
                CNotice.printLog(ex.Message);
            }
        }
Пример #12
0
        // 코일에 대한 문자열 라인을 넘겨 받아서 코일 객체를 초기화 한다.
        public bool readObject(List <string> listStringLines)
        {
            string strTemp;

            string[] arrayString;

            try
            {
                foreach (string strLine in listStringLines)
                {
                    strTemp = strLine.Trim('\t');

                    arrayString = strTemp.Split('=');

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

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

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

                    // CExperiment
                    case "MeshSizePercent":
                        MeshSizePercent = Convert.ToDouble(arrayString[1]);
                        break;

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

                    // CForceExperiment
                    case "Voltage":
                        Voltage = Convert.ToDouble(arrayString[1]);
                        break;

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

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

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

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

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

            return(true);
        }
Пример #13
0
        private bool isInputDataOK()
        {
            /// 1. 입력값 확인
            ///
            if (textBoxPartName.Text.Length == 0)
            {
                CNotice.noticeWarningID("PEAP");
                return(false);
            }

            for (int i = 0; i < ListPointUI.Count; i++)
            {
                if (ListPointUI[i].StrCoordX.Trim().Length == 0)
                {
                    CNotice.noticeWarningID("PETC");
                    return(false);
                }

                if (ListPointUI[i].StrCoordZ.Trim().Length == 0)
                {
                    CNotice.noticeWarningID("PETC");
                    return(false);
                }
            }

            string strX1, strY1, strX2, strY2;

            /// 동일한 좌표값이 점이 중복으로 있는 경우
            for (int i = 0; i < ListPointUI.Count - 1; i++)
            {
                for (int j = i + 1; j < ListPointUI.Count; j++)
                {
                    strX1 = ListPointUI[i].StrCoordX.Trim();
                    strY1 = ListPointUI[i].StrCoordZ.Trim();
                    strX2 = ListPointUI[j].StrCoordX.Trim();
                    strY2 = ListPointUI[j].StrCoordZ.Trim();

                    if (strX1 == strX2 && strY1 == strY2)
                    {
                        CNotice.noticeWarningID("TATP");
                        return(false);
                    }
                }
            }

            /// 파트 초기 생성때는 m_strPartName = string.Empty 로 PopupShape 객체를 생성하고,
            /// 파트 수정 때는 m_strPartName 에 이름을 넣어서  PopupShape 객체를 생성하기 때문에 파트의 수정인지를 m_strPartName 로 파악한다.
            if (m_strPartName.Length == 0)
            {
                /// [문제]
                ///  - Form 에서는 Parent를 사용할 수 없어 Owner 속성을 사용하지만
                ///    종종 Owner 가 null 로 넘어오는 문제가 발생한다.
                /// [해결]
                ///  - PopupShape 창을 생성하기 전에 Owner 속성을 FormMain 으로 초기화 해 두어야
                ///    확실하게 FormMain 을 얻을 수 있다.
                FormMain formMain = ((FormMain)this.Owner);

                if (formMain == null)
                {
                    CNotice.printLogID("CNGM");
                    return(false);
                }

                if (true == formMain.m_design.isExistNode(textBoxPartName.Text))
                {
                    CNotice.noticeWarningID("TPAE");
                    return(false);
                }
            }

            return(true);
        }
Пример #14
0
        /// <summary>
        /// 좌표입력 컨트롤을 하나 추가한다
        /// </summary>
        /// <param name="pointControl">좌표 객체</param>
        /// <param name="panel">좌표를 추가할 Panel</param>
        private CPointUI addPointControl(CPointUI pointControl, bool showButton, Panel panel)
        {
            pointControl.Dock        = DockStyle.Top;
            pointControl.IsRectangle = showButton;

            try
            {
                #region ------------------------- 이벤트 호출 영역 ------------------------------
                /// 이벤트 호출 영역은 addControlPoint() 안에 있으나 호출 때 동작하는 영역이 아니다.
                /// 단, 함수내에 있는 이유는 addControlPoint() 안에 있어서
                /// 파라메터로 넘어오는 변수를 직접 접근할 수 있어, 이벤트 함수의 변수 접근 문제를 해결했다.
                ///
                pointControl.AddCoordinates += (s, e) =>
                {
                    /// 추가 버튼 클릭했을때 현재 컨트롤 아래 추가
                    /// - 컨트롤 추가
                    ///  * addPointControl() 의 호출 영역을 호출 한다.
                    CPointUI current = this.addPointControl(new CPointUI(), showButton, panel);

                    /// - 컨트롤 정렬
                    List <CPointUI> sortList = new List <CPointUI>();
                    for (int i = 0; i < panel.Controls.Count; i++)
                    {
                        CPointUI c = panel.Controls[i] as CPointUI;
                        if (c.Equals(current))
                        {
                            continue;                    // 현재 추가된 항목은 통과
                        }
                        if (c.Equals(pointControl))
                        {
                            break;                         // 버튼 클릭한 항목을때 그 위쪽은 탐색할 필요 없으므로 루프 종료
                        }
                        sortList.Add(c);
                    }

                    for (int i = sortList.Count - 1; i >= 0; i--)
                    {
                        sortList[i].BringToFront();
                    }

                    this.resetSequence();
                };

                /// addPointControl() 이 호출될 때 실행되지 않고 이벤트가 발생할 때 동작한다.
                pointControl.RemoveCoordinates += (s, e) =>
                {
                    if (this.m_faceType == EMFaceType.RECTANGLE)
                    {
                        if (this.panelPointControl.Controls.Count == RECTANGLE_CONTROL_COUNT)
                        {
                            e.Cancel = true;
                            CNotice.noticeWarningID("RRAL");
                            return;
                        }
                    }
                    else
                    {
                        if (this.panelPointControl.Controls.Count <= MIN_POLYGON_CONTROL_COUNT)
                        {
                            e.Cancel = true;
                            CNotice.noticeWarningID("PRAL");
                            return;
                        }
                    }
                };

                /// addControlPoint() 이 호출될 때 실행되지 않고 이벤트가 발생할 때 동작한다.
                pointControl.RemoveComplete += (s, e) =>
                {
                    this.resetSequence();

                    // 생성창에서만 Add 버튼을 하나로 표시한다
                    if (m_bCreatePopupWindow == true)
                    {
                        /// PointControl 삭제때 Add 버튼 하나만 표시하기
                        ///
                        /// 정렬이 끝난 후에 PointControl Panel 의 가장 아래 PointControl ADD 버튼만 보이게 하여
                        /// PointControl 의 삽입이 항상 아래에서만 이루어지도록 해서 Tab 의 문제를 해결 했다.
                        for (int i = 0; i < panelPointControl.Controls.Count; i++)
                        {
                            if (i == 0)
                            {
                                ((CPointUI)panelPointControl.Controls[i]).showAddButton();
                            }
                            else
                            {
                                ((CPointUI)panelPointControl.Controls[i]).hideAddButton();
                            }
                        }
                    }
                };
                #endregion

                #region ------------------------ 함수 호출 영역 -----------------------------

                panel.Controls.Add(pointControl);
                pointControl.BringToFront();

                this.resetSequence();

                // 생성창에서만 Add 버튼을 하나로 표시한다
                if (m_bCreatePopupWindow == true)
                {
                    /// 2. PointControl 추가때 Add 버튼 하나만 표시하기
                    ///
                    /// 정렬이 끝난 후에 PointControl Panel 의 가장 아래 PointControl ADD 버튼만 보이게 하여
                    /// PointControl 의 삽입이 항상 아래에서만 이루어지도록 해서 Tab 의 문제를 해결 했다.
                    for (int i = 0; i < panelPointControl.Controls.Count; i++)
                    {
                        if (i == 0)
                        {
                            ((CPointUI)panelPointControl.Controls[i]).showAddButton();
                        }
                        else
                        {
                            ((CPointUI)panelPointControl.Controls[i]).hideAddButton();
                        }
                    }
                }

                return(pointControl);

                #endregion
            }
            catch (Exception ex)
            {
                CNotice.printLog(ex.Message);
                return(null);
            }
        }
Пример #15
0
        public bool readObject(List <string> listStringLines)
        {
            string strTemp;

            string[] arrayString;

            try
            {
                CPoint point = null;

                // 형상 라인을 처리한다.
                foreach (string strLine in listStringLines)
                {
                    strTemp = strLine.Trim('\t');

                    arrayString = strTemp.Split('=');

                    /// 각 줄의 String 배열은 항상 2개이여야 한다.
                    if (arrayString.Length != 2)
                    {
                        CNotice.noticeWarningID("TIAP5");
                        return(false);
                    }

                    switch (arrayString[0])
                    {
                    case "BasePointX":
                        BasePoint.X = Double.Parse(arrayString[1]);
                        break;

                    case "BasePointY":
                        BasePoint.Y = Double.Parse(arrayString[1]);
                        break;

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

                    case "PointX":
                        // PointX 키워드를 만날때 새로운 CPoint 생성하고,
                        // ArcDriction 키워드를 만날때 생성된 CPoint 를 Face 에 추가한다.
                        // 따라서 저장될때 X, Y, LineKind, ArcDriction 의 순서로 꼭 저장 되어야 한다.
                        point   = new CPoint();
                        point.X = Double.Parse(arrayString[1]);
                        break;

                    case "PointY":
                        if (point != null)
                        {
                            point.Y = Double.Parse(arrayString[1]);
                        }
                        else
                        {
                            CNotice.noticeWarningID("YCWX");
                            return(false);
                        }
                        break;

                    case "LineKind":
                        if (point != null)
                        {
                            point.LineKind = (EMLineKind)Enum.Parse(typeof(EMLineKind), arrayString[1]);
                        }
                        else
                        {
                            CNotice.noticeWarningID("TIAP9");
                            return(false);
                        }
                        break;

                    case "ArcDriction":
                        if (point != null)
                        {
                            point.DirectionArc = (EMDirectionArc)Enum.Parse(typeof(EMDirectionArc), arrayString[1]);
                        }
                        else
                        {
                            CNotice.noticeWarningID("TIAP10");
                            return(false);
                        }

                        // ArcDriction 에서 point 을 저장한다.
                        addPoint(point);
                        break;

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

            return(true);
        }
Пример #16
0
        private bool isInputDataOK()
        {
            try
            {
                // 빈칸 확인으로 null 비교를 사용하지 말라. (.Length == 0 나 "" 를 사용하라)
                if (textBoxName.Text.Length == 0)
                {
                    CNotice.noticeWarningID("PEAN");
                    return(false);
                }

                /// Design 생성이다.
                if (m_strNewKind == "Design")
                {
                    // 디자인을 무조건 프로그램 작업디렉토리에 생성하는 것으로 한다.
                    // 따라서 디자인을 생성할 때의 적용버튼 임으로 작업 디렉토리는 프로그램 작업 디렉토리를 사용하고 있다.
                    List <string> listDirectories = m_manageFile.getDirectoryList(CSettingData.m_strWorkingDirName);

                    // 소문자로 비교하기 위해서 임시로 사용한다.
                    string strOldTempName, strNewTempName;

                    foreach (string directoryName in listDirectories)
                    {
                        // 디렉토리 경로에 GetFileName 을 사용하면 가장 마지막 디렉토리가 넘어온다.
                        strOldTempName = Path.GetFileName(directoryName).ToLower();
                        strNewTempName = m_strName.ToLower();

                        if (strOldTempName == strNewTempName)
                        {
                            // 기존 디자인이 이미 존재할 때 삭제하고 새롭게 시작할지를 물어 온다
                            DialogResult ret = CNotice.noticeWarningOKCancelID("TSDA", "W");

                            if (ret == DialogResult.OK)
                            {
                                m_manageFile.deleteDirectory(directoryName);
                                return(true);
                            }
                            else
                            {
                                return(false);
                            }
                        }
                    }
                }
                /// Experiment 들의 생성이다.
                else
                {
                    /// 호출할 때 Owner 를 FormMain 으로 초기화 해야 확실하게 얻을 수 있다.
                    FormMain formMain = ((FormMain)this.Owner);

                    if (formMain == null)
                    {
                        CNotice.printTraceID("CNGM");
                        return(false);
                    }

                    if (true == formMain.m_design.isExistNode(textBoxName.Text))
                    {
                        CNotice.noticeWarningID("IIAE");
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                CNotice.printTrace(ex.Message);
                return(false);
            }

            return(true);
        }
Пример #17
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);
        }
Пример #18
0
        /// <summary>
        /// 재귀호출을 사용해서 FACE 내부점을 찾아낸다.
        /// 재질 블럭점을 찾는 것이기 때문에 절대좌표를 사용해야 한다.
        ///
        /// 참고 사이트 : http://bowbowbow.tistory.com/24
        /// </summary>
        /// <param name="minX">내부점을 찾는 구간의 X 점 최소값</param>
        /// <param name="maxX">내부점을 찾는 구간의 X 점 최대값</param>
        /// <param name="baseY">내부 좌표값을 찾은 Y 위치 </param>
        /// <returns></returns>
        public CPoint findInsidePoint(CFace face, double minX, double maxX, double baseY)
        {
            int nRightIntersection = 0;
            int nLeftIntersection  = 0;

            int nRightPerchedPoint = 0;
            int nLeftPerchedPoint  = 0;

            // 자리수 정리
            minX  = round(minX);
            maxX  = round(maxX);
            baseY = round(baseY);

            double centerX = (minX + maxX) / 2.0f;

            CLine rightLine = new CLine();
            CLine leftLine  = new CLine();

            /// create a right check line
            rightLine.m_startPoint.m_dX = centerX;
            rightLine.m_startPoint.m_dY = baseY;
            rightLine.m_endPoint.m_dX   = maxX + 10.0f;  // 오른 검색선의 끝을 maxX 보다 10 크게 한다.
            rightLine.m_endPoint.m_dY   = baseY;

            /// create a left check line
            leftLine.m_startPoint.m_dX = centerX;
            leftLine.m_startPoint.m_dY = baseY;
            leftLine.m_endPoint.m_dX   = minX - 10.0f;  // 오른 검색선의 끝을 minX 보다 10 작게 한다.
            leftLine.m_endPoint.m_dY   = baseY;

            /// 매번 생성하는 Property 이기 때문에
            /// LineList 는 새로운 List에  담는 동작 한번만 호출하고, 사용은 새로운 List 를 사용한다.
            List <CLine> listAbsoluteLine = new List <CLine>();

            listAbsoluteLine = face.AbsoluteLineList;

            /// Face 의 선과 검색선의 교차점을 찾는다.
            foreach (CLine line in listAbsoluteLine)
            {
                if (true == isIntersected(line, rightLine))
                {
                    nRightIntersection++;
                }

                if (true == isIntersected(line, leftLine))
                {
                    nLeftIntersection++;
                }
            }

            /// 교차를 검사할때 Face 선의 양점은 고려하지 않는다.
            /// 따라서 검색선에 Face 선의 점을 지나치는 경우는 교차점이 인식되지 못한다.
            /// 라인의 양점이 검색선에 올가가는지도 추가로 검색한다.
            ///
            foreach (CLine line in listAbsoluteLine)
            {
                // 만약 시작과 끝이 같이 올라간 경우라면 검색선에 Face 선이 올라간 경우로 검색에서 제외한다.
                // 라인의 한점만 올라간 경우를 Perched Point 로 사용한다.
                if (true == isPerchedOnLine(rightLine, line.m_startPoint) && true == isPerchedOnLine(rightLine, line.m_endPoint))
                {
                    nRightPerchedPoint += 0;
                }
                else if (true == isPerchedOnLine(rightLine, line.m_startPoint))
                {
                    nRightPerchedPoint++;
                }
                else if (true == isPerchedOnLine(rightLine, line.m_endPoint))
                {
                    nRightPerchedPoint++;
                }

                if (true == isPerchedOnLine(leftLine, line.m_startPoint) && true == isPerchedOnLine(leftLine, line.m_endPoint))
                {
                    nLeftPerchedPoint += 0;
                }
                else if (true == isPerchedOnLine(leftLine, line.m_startPoint))
                {
                    nLeftPerchedPoint++;
                }
                else if (true == isPerchedOnLine(leftLine, line.m_endPoint))
                {
                    nLeftPerchedPoint++;
                }
            }

            if ((nRightPerchedPoint % 2 != 0) || (nLeftPerchedPoint % 2 != 0))
            {
                CNotice.printTrace("findInsidePoint 에서 PerchedPoint 값이 홀수가 되었습니다.");
            }

            /// 점이 올라가는 경우 두점이 같이 올라가기 때문에 한번 교차에 두번 카운팅이 된다.
            /// 따라서 1/2 로 처리한다.
            ///
            nRightIntersection += (int)(nRightPerchedPoint / 2.0f);
            nLeftIntersection  += (int)(nLeftPerchedPoint / 2.0f);

            CPoint point = new CPoint();

            /// 양측이 홀수이면 Inside Point 이다.
            if (EMNumberKind.ODD == getNumberKind(nRightIntersection) && EMNumberKind.ODD == getNumberKind(nLeftIntersection))
            {
                point.m_dX = centerX;
                point.m_dY = baseY;

                return(point);
            }
            /// 왼쪽이 짝수이면 X 값의 최소값과 중심값 사이의 중점을 다시 확인한다.
            else if (EMNumberKind.EVEN == getNumberKind(nLeftIntersection))
            {
                return(findInsidePoint(face, minX, centerX, baseY));
            }
            /// 오른쪽이 짝수이면 X 값의 중심값과 최대값 사이의 중점을 다시 확인한다.
            else if (EMNumberKind.EVEN == getNumberKind(nRightIntersection))
            {
                return(findInsidePoint(face, centerX, maxX, baseY));
            }
            else
            {
                /// Block Point 를 찾기 위해서 findInsidePoint() 를 호출할 때
                /// Face 형상의 문제로 오류가 발생하여 Face 바깥의 지점으로 계산이 리턴되면
                /// Block Point 가 추가되지 못해서
                /// FEMM 에서 Block Point 에 재질 인가 할 때 다른 Block Point 에 인가되는 문제가 발생한다.
                ///
                /// 따라서 findInsidePoint() 에서 내부점을 찾지 못할 때는
                /// 중심의 좌표값을 넘기지 않고 null 을 리턴하여 Block Point 재질 설정 동작을 막는다.
                CNotice.noticeWarningID("FTCT");
                return(null);
            }
        }
Пример #19
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);
        }
Пример #20
0
        public void designCoil()
        {
            if (InnerDiameter <= 0.0f)
            {
                CNotice.noticeWarningID("TIDV");
                return;
            }

            if (OuterDiameter <= 0.0f)
            {
                CNotice.noticeWarningID("TODV");
                return;
            }

            if (OuterDiameter <= InnerDiameter)
            {
                CNotice.noticeWarningID("ODSB");
                return;
            }

            if (Height <= 0.0f)
            {
                CNotice.noticeWarningID("CHVI");
                return;
            }

            if (CopperDiameter <= 0.0f)
            {
                CNotice.noticeWarningID("ETCD");
                return;
            }

            if (HorizontalCoefficient <= 0.0f)
            {
                CNotice.noticeWarningID("ETVF");
                return;
            }

            if (VerticalCoefficient <= 0.0f)
            {
                CNotice.noticeWarningID("ETVF2");
                return;
            }

            if (ResistanceCoefficient <= 0.0f)
            {
                CNotice.noticeWarningID("ETVF1");
                return;
            }

            try
            {
                //*****************************************************************************
                // 수식계산에서 발생하는 예외처리를 하라.
                //*****************************************************************************
                double dCoilAvgDiameter = (InnerDiameter + OuterDiameter) / 2.0f;
                double dWidth           = Math.Abs(OuterDiameter - InnerDiameter) / 2.0f;

                // 동선경을 선택해서 WireDiameter 가 설정이 되지 않는 경우 여기서 자동 계산한다.
                if (WireDiameter == 0.0f)
                {
                    WireDiameter = calculateWireDiameter();
                }

                int iHorizontal_N = (int)((1 / HorizontalCoefficient) * (dWidth / WireDiameter));
                int iVirtical_N   = (int)((1 / VerticalCoefficient) * (Height / WireDiameter));

                // 수평 적층 수가 짝수가 아니면 한층을 뺀다. (짝수 정렬만 가능하다)
                if (iHorizontal_N % 2 != 0)
                {
                    iHorizontal_N -= 1;
                }

                this.Turns           = iHorizontal_N * iVirtical_N;
                this.TurnsOfOneLayer = iVirtical_N;
                this.Layers          = iHorizontal_N;

                double dWireLength = Math.PI * this.Turns * dCoilAvgDiameter;

                // IEC 317, 단위 저항 보간
                double res_a = 0.0, res_b = 0.0, res_c = 0.0;

                // 온도 계수
                double dTemperatureCoefficient = 0.0f;

                if (m_strMaterial == "Copper")
                {
                    // IEC 317, 단위 저항 보간
                    res_a = 0.021771473f;
                    res_b = 0.99730833f;
                    res_c = -1.9999322f;

                    // 온도 계수
                    dTemperatureCoefficient = 0.004041f;
                }
                // 두가지 밖에 없어서 알루미늄의 경우이다.
                else if (m_strMaterial == "Aluminum")
                {
                    // IEC 317, 단위 저항 보간
                    res_a = 0.036438f;
                    res_b = 0.981116f;
                    res_c = -1.995774f;

                    // 온도 계수
                    dTemperatureCoefficient = 0.004308f;
                }
                else
                {
                    CNotice.printTraceID("TIAP1");
                    return;
                }


                double dResistancePerMeter = res_a * (Math.Pow(res_b, CopperDiameter) * Math.Pow(CopperDiameter, res_c));

                dResistancePerMeter = (1 + dTemperatureCoefficient * (this.Temperature - 20.0f)) * dResistancePerMeter;
                this.Resistance     = dResistancePerMeter * dWireLength * ResistanceCoefficient;

                this.Resistance = this.Resistance / 1000.0f;
            }
            catch (Exception ex)
            {
                CNotice.printTrace(ex.Message);
            }
        }
Пример #21
0
        protected bool readShapeInformation(List <string> listShapeLines)
        {
            string strTemp;

            string[] arrayString;

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

                CPoint point = null;

                // 형상 라인을 처리한다.
                foreach (string strLine in listShapeLines)
                {
                    strTemp = strLine.Trim('\t');

                    arrayString = strTemp.Split('=');

                    /// 각 줄의 String 배열은 항상 2개이여야 한다.
                    if (arrayString.Length != 2)
                    {
                        CNotice.noticeWarningID("TIAP5");
                        return(false);
                    }

                    if (m_face == null)
                    {
                        CNotice.printTraceID("IIAT");
                        return(false);
                    }

                    switch (arrayString[0])
                    {
                    case "BasePointX":
                        m_face.BasePoint.m_dX = Double.Parse(arrayString[1]);
                        break;

                    case "BasePointY":
                        m_face.BasePoint.m_dY = Double.Parse(arrayString[1]);
                        break;

                    case "FaceType":
                        m_face.FaceType = (EMFaceType)Enum.Parse(typeof(EMFaceType), arrayString[1]);
                        break;

                    case "PointX":
                        // PointX 키워드를 만날때 새로운 CPoint 생성하고,
                        // ArcDriction 키워드를 만날때 생성된 CPoint 를 Face 에 추가한다.
                        // 따라서 저장될때 X, Y, LineKind, ArcDriction 의 순서로 꼭 저장 되어야 한다.
                        point      = new CPoint();
                        point.m_dX = Double.Parse(arrayString[1]);
                        break;

                    case "PointY":
                        if (point != null)
                        {
                            point.m_dY = Double.Parse(arrayString[1]);
                        }
                        else
                        {
                            CNotice.noticeWarningID("YCWX");
                            return(false);
                        }
                        break;

                    case "LineKind":
                        if (point != null)
                        {
                            point.m_emLineKind = (EMLineKind)Enum.Parse(typeof(EMLineKind), arrayString[1]);
                        }
                        else
                        {
                            CNotice.noticeWarningID("TIAP9");
                            return(false);
                        }
                        break;

                    case "ArcDriction":
                        if (point != null)
                        {
                            point.m_emDirectionArc = (EMDirectionArc)Enum.Parse(typeof(EMDirectionArc), arrayString[1]);
                        }
                        else
                        {
                            CNotice.noticeWarningID("TIAP10");
                            return(false);
                        }

                        // ArcDriction 에서 point 을 저장한다.
                        m_face.addPoint(point);
                        break;

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

            return(true);
        }
Пример #22
0
        public static bool isSettingDataOK(bool bOpenNoticeDialog = true)
        {
            bool bCheck = false;

            bCheck = m_manageFile.isExistFile(m_strFemmExeFileFullName);
            if (bCheck == false)
            {
                if (bOpenNoticeDialog == true)
                {
                    CNotice.noticeWarningID("TEFD");
                }
                else
                {
                    CNotice.printLogID("TEFD");
                }

                return(false);
            }

            bCheck = m_manageFile.isExistDirectory(m_strBaseWorkingDirPath);

            if (bCheck == false)
            {
                if (bOpenNoticeDialog == true)
                {
                    CNotice.noticeWarningID("TDWD");
                }
                else
                {
                    CNotice.printLogID("TDWD");
                }

                return(false);
            }

            bCheck = m_manageFile.isExistDirectory(m_strProgramDirPath);

            if (bCheck == false)
            {
                if (bOpenNoticeDialog == true)
                {
                    CNotice.noticeWarningID("TIAP2");
                }
                else
                {
                    CNotice.printLogID("TIAP2");
                }

                return(false);
            }

            if (m_dMeshLevelPercent <= 0.05f)
            {
                if (bOpenNoticeDialog == true)
                {
                    CNotice.noticeWarningID("TMSL");
                }
                else
                {
                    CNotice.printLogID("TMSL");
                }

                return(false);
            }

            return(true);
        }
Пример #23
0
        private bool isInputDataOK()
        {
            bool bCheck;

            try
            {
                // 빈칸 확인으로 null 비교를 사용하지 말라. (.Length == 0 나 "" 를 사용하라)
                if (textBoxDesignName.Text.Length == 0)
                {
                    CNotice.noticeWarningID("PEAN");
                    return(false);
                }

                if (textBoxSTEPFileFullName.Text.Length == 0)
                {
                    if (CSettingData.m_emLanguage == EMLanguage.Korean)
                    {
                        CNotice.noticeWarning("STEP 파일을 선택해 주세요.");
                    }
                    else
                    {
                        CNotice.noticeWarning("You need to select a STEP file.");
                    }

                    return(false);
                }

                // 가능성은 낮지만 선택한 STEP 파일이 없는지를 검사한다.
                bCheck = m_manageFile.isExistFile(this.textBoxSTEPFileFullName.Text);
                if (bCheck == false)
                {
                    CNotice.printTrace("선택한 STEP 파일이 존재하지 않는다.");
                    return(false);
                }

                // 디자인을 무조건 프로그램 작업디렉토리에 생성하는 것으로 한다.
                // 따라서 디자인을 생성할 때의 적용버튼 임으로 작업 디렉토리는 프로그램 작업 디렉토리를 사용하고 있다.
                List <string> listDirectories = m_manageFile.getDirectoryList(CSettingData.m_strWorkingDirName);

                // 소문자로 비교하기 위해서 임시로 사용한다.
                string strOldTempName, strNewTempName;

                foreach (string directoryName in listDirectories)
                {
                    // 디렉토리 경로에 GetFileName 을 사용하면 가장 마지막 디렉토리가 넘어온다.
                    strOldTempName = Path.GetFileName(directoryName).ToLower();
                    strNewTempName = m_strDesignName.ToLower();

                    if (strOldTempName == strNewTempName)
                    {
                        // 기존 디자인이 이미 존재할 때 삭제하고 새롭게 시작할지를 물어 온다
                        DialogResult ret = CNotice.noticeWarningOKCancelID("TSDA", "W");

                        if (ret == DialogResult.OK)
                        {
                            m_manageFile.deleteDirectory(directoryName);
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                CNotice.printTrace(ex.Message);
                return(false);
            }

            return(true);
        }
Пример #24
0
        private bool isInputDataOK()
        {
            try
            {
                // 빈칸 확인으로 null 비교를 사용하지 말라. (.Length == 0 나 "" 를 사용하라)
                if (textBoxName.Text.Length == 0)
                {
                    CNotice.noticeWarningID("PEAN");
                    return(false);
                }

                /// Design 생성이다.
                if (m_strNewKind == "Design")
                {
                    // 디자인을 무조건 프로그램 작업디렉토리에 생성하는 것으로 한다.
                    // 따라서 디자인을 생성할 때의 적용버튼 임으로 작업 디렉토리는 프로그램 작업 디렉토리를 사용하고 있다.
                    List <string> listDirectories = m_manageFile.getDirectoryList(CSettingData.m_strCurrentWorkingDirPath);

                    // 소문자로 비교하기 위해서 임시로 사용한다.
                    string strOldTempName, strNewTempName;

                    foreach (string directoryName in listDirectories)
                    {
                        // 디렉토리 경로에 GetFileName 을 사용하면 가장 마지막 디렉토리가 넘어온다.
                        strOldTempName = Path.GetFileName(directoryName).ToLower();
                        strNewTempName = m_strName.ToLower();

                        if (strOldTempName == strNewTempName)
                        {
                            // 신규 디자인 이름이 기존 디자인과 겹칠때 기존 디자인을 삭제하는 것은 위험성이 따른다.
                            // 그래서 아래의 동작을 중지한다.
                            //
                            // 기존 디자인이 이미 존재할 때 삭제하고 새롭게 시작할지를 물어 온다
                            //DialogResult ret = CNotice.noticeWarningOKCancelID("TSDA", "W");

                            //if (ret == DialogResult.OK)
                            //{
                            //    m_manageFile.deleteDirectory(directoryName);
                            //    return true;
                            //}
                            //else
                            //    return false;

                            if (CSettingData.m_emLanguage == EMLanguage.Korean)
                            {
                                CNotice.noticeWarning("동일한 이름의 Design 이 이미 존재 합니다.\n다른 디자인명을 사용해 주세요.");
                            }
                            else
                            {
                                CNotice.noticeWarning("A design with the same name already exists.\nPlease use a different design name.");
                            }

                            return(false);
                        }
                    }
                }
                /// Test 들의 생성이다.
                else
                {
                    /// 호출할 때 Owner 를 FormMain 으로 초기화 해야 확실하게 얻을 수 있다.
                    FormMain formMain = ((FormMain)this.Owner);

                    if (formMain == null)
                    {
                        CNotice.printLogID("CNGM");
                        return(false);
                    }

                    if (true == formMain.m_design.isExistNode(textBoxName.Text))
                    {
                        CNotice.noticeWarningID("IIAE");
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                CNotice.printLog(ex.Message);
                return(false);
            }

            return(true);
        }
Пример #25
0
        /// <summary>
        /// 재귀호출을 사용해서 FACE 내부점을 찾아낸다.
        /// 재질 블럭점을 찾는 것이기 때문에 절대좌표를 사용해야 한다.
        ///
        /// 참고 사이트 : http://bowbowbow.tistory.com/24
        /// </summary>
        /// <param name="minX">내부점을 찾는 구간의 X 점 최소값</param>
        /// <param name="maxX">내부점을 찾는 구간의 X 점 최대값</param>
        /// <param name="baseY">내부 좌표값을 찾은 Y 위치 </param>
        /// <returns></returns>
        public CPoint findInsidePoint(CFace face, double minX, double maxX, double minY, double maxY)
        {
            int nRightIntersection = 0;
            int nLeftIntersection  = 0;

            int nRightPerchedPointOnCheckLine = 0;
            int nLeftPerchedPointOnCheckLine  = 0;

            int nPerchedCenterPointOnFaceLine = 0;

            CLine rightCheckLine = new CLine();
            CLine leftCheckLine  = new CLine();

            CPoint centerPoint = new CPoint();

            double baseY   = (minY + maxY) / 2.0f;
            double centerX = (minX + maxX) / 2.0f;

            //// 너무 작은 소수점 이하는 정리한다.
            minX  = roundDigitOfShape(minX);
            maxX  = roundDigitOfShape(maxX);
            baseY = roundDigitOfShape(baseY);

            // 중심점을 만든다.
            centerPoint.X = centerX;
            centerPoint.Y = baseY;

            /// create a right check line
            rightCheckLine.m_startPoint.X = centerX;
            rightCheckLine.m_startPoint.Y = baseY;
            rightCheckLine.m_endPoint.X   = maxX + 10.0f;  // 오른 검색선의 끝을 maxX 보다 10 크게 한다.
            rightCheckLine.m_endPoint.Y   = baseY;

            /// create a left check line
            leftCheckLine.m_startPoint.X = centerX;
            leftCheckLine.m_startPoint.Y = baseY;
            leftCheckLine.m_endPoint.X   = minX - 10.0f;  // 오른 검색선의 끝을 minX 보다 10 작게 한다.
            leftCheckLine.m_endPoint.Y   = baseY;

            /// 매번 생성하는 Property 이기 때문에
            /// LineList 는 새로운 List에  담는 동작 한번만 호출하고, 사용은 새로운 List 를 사용한다.
            List <CLine> listAbsoluteLine = new List <CLine>();

            listAbsoluteLine = face.AbsoluteLineList;

            foreach (CLine line in listAbsoluteLine)
            {
                /// Face 선들과 검색 선의 교차 횟수 확인
                if (true == isIntersected(line, rightCheckLine))
                {
                    nRightIntersection++;
                }

                if (true == isIntersected(line, leftCheckLine))
                {
                    nLeftIntersection++;
                }

                /// Face 선의 양점이 검색 선 위에 올라가 있는지 확인
                if (true == isPerchedOnLine(rightCheckLine, line.m_startPoint))
                {
                    nRightPerchedPointOnCheckLine++;
                }

                if (true == isPerchedOnLine(rightCheckLine, line.m_endPoint))
                {
                    nRightPerchedPointOnCheckLine++;
                }

                if (true == isPerchedOnLine(leftCheckLine, line.m_startPoint))
                {
                    nLeftPerchedPointOnCheckLine++;
                }

                if (true == isPerchedOnLine(leftCheckLine, line.m_endPoint))
                {
                    nLeftPerchedPointOnCheckLine++;
                }

                /// Face 선위에 중심점이 올라가 있는지 확인
                if (true == isPerchedOnLine(line, centerPoint))
                {
                    nPerchedCenterPointOnFaceLine++;
                }
            }


            //-------------------------------------------------------------------
            // 내부점 판단
            //
            // 내부점을 만족하면 Point 를 리턴하고,
            // 만족하지 못하면 측정 면적을 수정하고 재귀호출을 통해 Point 를 찾아낸다.
            //------------------------------------------------------------------
            //
            CPoint point = new CPoint();

            // Center 점이 Face Line 위에 올라가 있으면 우측 1/2 사각형에서 내부점을 찾는다.
            if (nPerchedCenterPointOnFaceLine > 0)
            {
                return(findInsidePoint(face, centerX, maxX, minY, maxY));
            }

            // Face Line 의 양점이 우측 검색 라인에 올라가는 경우는 상측 1/2 사각형에서 내부점을 찾는다.
            if (nRightPerchedPointOnCheckLine > 0 || nLeftPerchedPointOnCheckLine > 0)
            {
                return(findInsidePoint(face, minX, maxX, baseY, maxY));
            }

            // 양측이 홀수이면 Inside Point 이다.
            if (EMNumberKind.ODD == getNumberKind(nRightIntersection) && EMNumberKind.ODD == getNumberKind(nLeftIntersection))
            {
                point.X = centerX;
                point.Y = baseY;

                return(point);
            }
            /// 왼쪽이 짝수이면 X 값의 최소값과 중심값 사이의 중점을 다시 확인한다.
            else if (EMNumberKind.EVEN == getNumberKind(nLeftIntersection))
            {
                return(findInsidePoint(face, minX, centerX, minY, maxY));
            }
            /// 오른쪽이 짝수이면 X 값의 중심값과 최대값 사이의 중점을 다시 확인한다.
            else if (EMNumberKind.EVEN == getNumberKind(nRightIntersection))
            {
                return(findInsidePoint(face, centerX, maxX, minY, maxY));
            }
            else
            {
                /// Block Point 를 찾기 위해서 findInsidePoint() 를 호출할 때
                /// Face 형상의 문제로 오류가 발생하여 Face 바깥의 지점으로 계산이 리턴되면
                /// Block Point 가 추가되지 못해서
                /// FEMM 에서 Block Point 에 재질 인가 할 때 다른 Block Point 에 인가되는 문제가 발생한다.
                ///
                /// 따라서 findInsidePoint() 에서 내부점을 찾지 못할 때는
                /// 중심의 좌표값을 넘기지 않고 null 을 리턴하여 Block Point 재질 설정 동작을 막는다.
                CNotice.noticeWarningID("FTCT");
                return(null);
            }
        }
Пример #26
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);
        }
Пример #27
0
        /// <summary>
        /// Face 안의 형상문제를 확인한다.
        /// </summary>
        public bool isShapeOK()
        {
            ///-----------------------------------------
            /// 1. X 음의 좌료 입력 확인
            ///-----------------------------------------
            /// 축대칭 모델만 사용하기 때문에
            /// 내부 포인트의 X 좌표값은 항상 영보다 커야 한다.
            foreach (CPoint point in m_listRelativePoint)
            {
                if ((point.X + m_basePoint.X) < 0)
                {
                    CNotice.noticeWarningID("YUNX");
                    return(false);
                }
            }

            ///-----------------------------------------
            /// 2. 내부 라인들의 교차 및 겹침 확인
            ///-----------------------------------------
            ///
            /// 매번 생성하는 Property 이기 때문에
            /// LineList 는 새로운 List에  담는 동작 한번만 호출하고, 사용은 새로운 List 를 사용한다.
            List <CLine> listAbsoluteLine = new List <CLine>();

            listAbsoluteLine = AbsoluteLineList;

            if (AbsoluteLineList == null)
            {
                CNotice.noticeWarningID("TWAP");
                return(false);
            }


            /// 아래와 같이 라인의 교차와 겹칩을 판단한다.
            /// 1 line <=> 2 line ... last line
            /// 2 line <=> 3 line ... last line
            /// ...
            /// lsat-2 line <=> last-1 line , last line
            /// last-1 line <=> last line
            for (int i = 0; i < listAbsoluteLine.Count - 1; i++)
            {
                for (int j = i + 1; j < listAbsoluteLine.Count; j++)
                {
                    if (true == m_shapeTools.isIntersected(listAbsoluteLine[i], listAbsoluteLine[j]))
                    {
                        CNotice.noticeWarningID("AIPB");
                        return(false);
                    }

                    if (true == m_shapeTools.isOverlaped(listAbsoluteLine[i], listAbsoluteLine[j]))
                    {
                        CNotice.noticeWarningID("AOPB");
                        return(false);
                    }
                }
            }

            ///-----------------------------------------
            /// 3. 면적 확인을 한다.
            ///-----------------------------------------
            if (m_shapeTools.calcArea(this) == 0)
            {
                CNotice.noticeWarningID("TINA");
                return(false);
            }


            return(true);
        }
Пример #28
0
        // 코일에 대한 문자열 라인을 넘겨 받아서 코일 객체를 초기화 한다.
        public bool readObject(List <string> listStringLines)
        {
            string strTemp;

            string[] arrayString;

            //if (KindKey != EMKind.FORCE_TEST)
            //{
            //    CNotice.printTrace("다른 객체를 ForceTest 로 읽으려고 하고 있습니다.");
            //    return false;
            //}

            try
            {
                foreach (string strLine in listStringLines)
                {
                    strTemp = strLine.Trim('\t');

                    arrayString = strTemp.Split('=');

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

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

                    case "KindKey":
                        // 하위 버전 호환 유지 ver(0.9.15.6)
                        if (arrayString[1] == "FORCE_EXPERIMENT")
                        {
                            arrayString[1] = "FORCE_TEST";
                        }

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

                    // CTest
                    case "MeshSizePercent":
                        MeshSizePercent = Convert.ToDouble(arrayString[1]);
                        break;

                    // CForceTest
                    case "Voltage":
                        Voltage = Convert.ToDouble(arrayString[1]);
                        break;

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

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

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

            return(true);
        }
Пример #29
0
        // 코일에 대한 문자열 라인을 넘겨 받아서 코일 객체를 초기화 한다.
        public bool readObject(List <string> listStringLines)
        {
            string strTemp;

            string[] arrayString;

            //if (KindKey != EMKind.CURRENT_EXPERIMENT)
            //{
            //    CNotice.printTrace("다른 객체를 StrokeExperiment 로 읽으려고 하고 있습니다.");
            //    return false;
            //}

            try
            {
                foreach (string strLine in listStringLines)
                {
                    strTemp = strLine.Trim('\t');

                    arrayString = strTemp.Split('=');

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

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

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

                    // CExperiment
                    case "MeshSizePercent":
                        MeshSizePercent = Convert.ToDouble(arrayString[1]);
                        break;

                    // CCurrentExperiment
                    case "InitialCurrent":
                        InitialCurrent = Convert.ToDouble(arrayString[1]);
                        break;

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

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

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

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

            return(true);
        }