예제 #1
0
        /// <summary>
        ///This function is called when executing the action.
        /// </summary>
        ///<returns>true, if the action performed successfully</returns>
        public bool Execute(ActionCallingContext ctx)
        {
            string pVal = "no";

            ctx.GetParameter("loadFromLua", ref pVal);
            bool loadFromLua = true;

            if (pVal == "no")
            {
                loadFromLua = false;
            }

            string errStr;

            string projectName = EProjectManager.GetInstance()
                                 .GetCurrentProjectName();

            EProjectManager.GetInstance().CheckProjectName(ref projectName);

            int res = ProjectManager.GetInstance().LoadDescription(out errStr,
                                                                   projectName, loadFromLua);

            if (res > 0)
            {
                MessageBox.Show(errStr, "EPlaner", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return(false);
            }


            return(true);
        }
예제 #2
0
        /// <summary>
        ///This function is called when executing the action.
        /// </summary>
        ///<returns>true, if the action performed successfully</returns>
        public bool Execute(ActionCallingContext ctx)
        {
            try
            {
                if (EProjectManager.GetInstance().GetCurrentPrj() == null)
                {
                    MessageBox.Show("Нет открытого проекта!", "EPlaner",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    ModeFrm.OnSetNewValue OnSetNewValueFunction = null;
                    bool isRebuiltTree = true;

                    ModeFrm.GetInstance().ShowModes(
                        TechObject.TechObjectManager.GetInstance(),
                        false, false, null, null, OnSetNewValueFunction,
                        isRebuiltTree);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            return(true);
        }
예제 #3
0
        public override RequestCode OnSelect(
            StorableObject[] arrSelectedObjects,
            SelectionContext oContext)
        {
            // Execute standard operation.
            base.OnSelect(arrSelectedObjects, oContext);

            if (EProjectManager.GetInstance().GetEditInteraction() != this)
            {
                return(RequestCode.Stop);
            }

            Function oF = SearchSelectedObjectFunction(arrSelectedObjects[0]);

            if (oF != null)
            {
                Editor.ITreeViewItem newEditorItem = Editor.Editor
                                                     .GetInstance().EditorForm.GetActiveItem();
                if (newEditorItem == null)
                {
                    return(RequestCode.Nothing);
                }

                if (newEditorItem != null)
                {
                    ExecuteForEditor(newEditorItem, oF);
                }
            }

            return(RequestCode.Select |
                   RequestCode.NoPreselect |
                   RequestCode.NoMultiSelect);
        }
예제 #4
0
        private void OnUserPreCloseProject(IEventParameter iEventParameter)
        {
            string projectName =
                (new EventParameterString(iEventParameter)).String;
            int dot_pos = projectName.LastIndexOf('\\');

            if (dot_pos > 0)
            {
                projectName = projectName.Substring(dot_pos + 1);
            }

            projectName = projectName.Remove(projectName.IndexOf('.'));

            string currentProjectName = EProjectManager.GetInstance()
                                        .GetCurrentProjectName();

            if (projectName == currentProjectName)
            {
                EProjectManager.GetInstance().SaveAndClose();

                DFrm.GetInstance().ShowNoDevices();

                EProjectManager.GetInstance().ResetCurrentPrj();
                EProjectManager.isPreCloseProjectComplete = true;
            }
        }
예제 #5
0
 public static EProjectManager GetInstance()
 {
     if (instance == null)
     {
         instance = new EProjectManager();
     }
     return(instance);
 }
예제 #6
0
        public override RequestCode OnStart(InteractionContext pContext)
        {
            EProjectManager.GetInstance().SetEditInteraction(this);

            return(RequestCode.Select |
                   RequestCode.NoPreselect |
                   RequestCode.NoMultiSelect);
        }
예제 #7
0
        private void synchBtn_Click(object sender, EventArgs e)
        {
            bool saveDescrSilentMode = false;

            EProjectManager.GetInstance().SyncAndSave(saveDescrSilentMode);

            Editor.Editor.GetInstance().EditorForm.RefreshTree();

            RefreshTree();
        }
예제 #8
0
        private void OnNotifyPageChanged(IEventParameter eventParameter)
        {
            var interaction = EProjectManager.GetInstance()
                              .GetEditInteraction();

            if (interaction != null && interaction.IsFinish == false)
            {
                EProjectManager.GetInstance().StartEditModesWithDelay();
            }
        }
예제 #9
0
 /// <summary>
 /// Инициализация.
 /// </summary>
 public void Init()
 {
     this.editor            = Editor.Editor.GetInstance();
     this.techObjectManager = TechObjectManager.GetInstance();
     Logs.Init(new LogFrm());
     this.IOManager = IOManager.GetInstance();
     DeviceManager.GetInstance();
     this.projectConfiguration = ProjectConfiguration.GetInstance();
     EProjectManager.GetInstance();
     BaseTechObjectManager.GetInstance();
 }
예제 #10
0
        /// <summary>
        /// Инициализация.
        /// </summary>
        public void Init()
        {
            CheckLibsAndFiles();

            editor            = Editor.Editor.GetInstance();
            techObjectManager = TechObjectManager.GetInstance();
            Logs.Init(new LogFrm());
            IOManager = IOManager.GetInstance();
            DeviceManager.GetInstance();
            projectConfiguration = ProjectConfiguration.GetInstance();
            EProjectManager.GetInstance();
            BaseTechObjectManager.GetInstance();
        }
예제 #11
0
        public override void OnStop()
        {
            base.OnStop();

            if (!isFinish)                         //Перезапуск взаимодействия при необходимости.
            {
                DelegateWithParameters dlgtStart = //Создаем делегат.
                                                   new DelegateWithParameters(
                    EProjectManager.GetInstance().StartEditModesWithDelay);

                dlgtStart.BeginInvoke(300, null, null);
            }
        }
예제 #12
0
        /// <summary>
        ///This function is called when executing the action.
        /// </summary>
        ///<returns>true, if the action performed successfully</returns>
        public bool Execute(ActionCallingContext ctx)
        {
            if (EProjectManager.GetInstance().GetCurrentPrj() == null)
            {
                MessageBox.Show("Нет открытого проекта!", "EPlaner",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                //Редактирование объектов.
                ProjectManager.GetInstance().Edit();
            }

            return(true);
        }
예제 #13
0
        private void OnMainEnd(IEventParameter iEventParameter)
        {
            if (EProjectManager.GetInstance().GetCurrentPrj() != null)
            {
                EProjectManager.GetInstance().SaveAndClose();

                ////Проверяю, закрыт ли проект(выполнено ли PreCloseProject)
                //// Или же он закрыт "варварски"
                if (EProjectManager.isPreCloseProjectComplete == false)
                {
                    // Если проект закрыт варварски, то при новом открытия окна не открывать
                    DFrm.SaveCfg(false);
                    ModeFrm.SaveCfg(false);
                    Editor.EditorCtrl.SaveCfg(false);
                }
            }
        }
예제 #14
0
        /// <summary>
        ///This function is called when executing the action.
        /// </summary>
        ///<returns>true, if the action performed successfully</returns>
        public bool Execute(ActionCallingContext ctx)
        {
            try
            {
                string pVal = "no";
                ctx.GetParameter("silentMode", ref pVal);
                bool silentMode = false;
                if (pVal == "yes")
                {
                    silentMode = true;
                }

                if (EProjectManager.GetInstance().GetCurrentPrj() == null)
                {
                    if (!silentMode)
                    {
                        MessageBox.Show("Нет открытого проекта!", "EPlaner",
                                        MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else
                {
                    var currentThread = System.Threading.Thread.CurrentThread;
                    currentThread.CurrentCulture = StaticHelper.CommonConst
                                                   .CultureWithDotInsteadComma;

                    string projectName = EProjectManager.GetInstance()
                                         .GetCurrentProjectName();
                    EProjectManager.GetInstance()
                    .CheckProjectName(ref projectName);
                    string path = ProjectManager.GetInstance()
                                  .GetPtusaProjectsPath(projectName) + projectName;
                    ProjectManager.GetInstance().SaveAsLua(projectName, path,
                                                           silentMode);

                    SVGStatisticsSaver.Save(path);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            return(true);
        }
예제 #15
0
        private void OnMainEnd(IEventParameter iEventParameter)
        {
            if (EProjectManager.GetInstance().GetCurrentPrj() != null)
            {
                EProjectManager.GetInstance().SaveAndClose();

                // Проверяю, закрыт ли проект(выполнено ли PreCloseProject)
                // или же он закрыт через закрытие окна Eplan
                if (EProjectManager.isPreCloseProjectComplete == false)
                {
                    // Если проект закрыт через крестик
                    // при новом открытии Eplan не открывать окна
                    DFrm.SaveCfg(false);
                    ModeFrm.SaveCfg(false);
                    Editor.NewEditorControl.SaveCfg(false);
                }
            }

            idleTimeModule.Stop();
        }
예제 #16
0
        public void SaveAndClose()
        {
            EProjectManager.GetInstance().SyncAndSave();
            EProjectManager.GetInstance().StopEditModes();

            // Проверка и сохранение состояний окон.
            ModeFrm.CheckShown();
            ModeFrm.SaveCfg(ModeFrm.modeIsShown);
            DFrm.CheckShown();
            DFrm.SaveCfg(DFrm.deviceIsShown);
            Editor.EditorCtrl.CheckShown();
            Editor.EditorCtrl.SaveCfg();

            if (Editor.Editor.GetInstance().IsShown())
            {
                Editor.Editor.GetInstance().CloseEditor();
            }

            DFrm.GetInstance().CloseEditor();
        }
예제 #17
0
        /// <summary>
        /// Закрыть приложение.
        /// </summary>
        public static void CloseApplication()
        {
            Process eplanProcess = Process.GetCurrentProcess();
            var     isClosed     = eplanProcess.CloseMainWindow();

            if (isClosed == false)
            {
                var project = EProjectManager.GetInstance().GetCurrentPrj();
                if (project != null)
                {
                    EProjectManager.GetInstance().SyncAndSave();
                    Thread.Sleep(500);
                    project.Close();
                }
                Thread.Sleep(500);
                eplanProcess.Kill();
            }
            else
            {
                eplanProcess.Close();
            }
        }
예제 #18
0
 /// <summary>
 ///This function is called when executing the action.
 /// </summary>
 ///<returns>true, if the action performed successfully</returns>
 public bool Execute(ActionCallingContext ctx)
 {
     try
     {
         Project currentProject = EProjectManager.GetInstance().
                                  GetCurrentPrj();
         if (currentProject == null)
         {
             MessageBox.Show("Нет открытого проекта!", "EPlaner",
                             MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
         else
         {
             var interProjectExchangeStarter = new InterprojectExchange
                                               .InterprojectExchangeStarter();
             interProjectExchangeStarter.Start();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     return(true);
 }
 /// <summary>
 ///This function is called when executing the action.
 /// </summary>
 ///<returns>true, if the action performed successfully</returns>
 public bool Execute(ActionCallingContext ctx)
 {
     try
     {
         Project currentProject = EProjectManager.GetInstance()
                                  .GetCurrentPrj();
         if (currentProject == null)
         {
             MessageBox.Show("Нет открытого проекта!", "EPlaner",
                             MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
         else
         {
             ProjectManager.GetInstance().SaveAsExcelDescription(
                 currentProject.ProjectDirectoryPath + @"\DOC\" +
                 currentProject.ProjectName + ".xlsx");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     return(true);
 }
 /// <summary>
 ///This function is called when executing the action.
 /// </summary>
 ///<returns>true, if the action performed successfully</returns>
 public bool Execute(ActionCallingContext ctx)
 {
     try
     {
         Project currentProject = EProjectManager.GetInstance().
                                  GetCurrentPrj();
         if (currentProject == null)
         {
             MessageBox.Show("Нет открытого проекта!", "EPlaner",
                             MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
         else
         {
             // Синхронизация названий модулей и устройств в текущем
             // проекте.
             ProjectManager.GetInstance().UpdateModulesBinding();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     return(true);
 }
예제 #21
0
 public ProjectHealthChecker()
 {
     projectManager  = ProjectManager.GetInstance();
     eProjectManager = EProjectManager.GetInstance();
 }
예제 #22
0
        private void OnPostOpenProject(IEventParameter iEventParameter)
        {
            //Если нет активного проекта, считываем описание и работаем с ним.
            if (EProjectManager.GetInstance().GetCurrentPrj() == null)
            {
                //Получение текущего проекта.
                Eplan.EplApi.HEServices.SelectionSet selection =
                    new Eplan.EplApi.HEServices.SelectionSet();
                selection.LockSelectionByDefault = false;
                selection.LockProjectByDefault   = false;

                EProjectManager.GetInstance().SetCurrentPrj(
                    selection.GetCurrentProject(true));

                String        strAction = "LoadDescriptionAction";
                ActionManager oAMnr     = new ActionManager();
                Eplan.EplApi.ApplicationFramework.Action oAction =
                    oAMnr.FindAction(strAction);
                ActionCallingContext ctx = new ActionCallingContext();

                if (oAction != null)
                {
                    oAction.Execute(ctx);
                }

                strAction = "ShowTechObjectsAction";
                oAction   = oAMnr.FindAction(strAction);

                if (oAction != null)
                {
                    //Восстановление при необходимости окна редактора.
                    string path = Environment.GetFolderPath(
                        Environment.SpecialFolder.ApplicationData) +
                                  @"\Eplan\eplan.cfg";
                    PInvoke.IniFile ini = new PInvoke.IniFile(path);
                    string          res = ini.ReadString("main", "show_obj_window",
                                                         "false");

                    if (res == "true")
                    {
                        oAction.Execute(ctx);
                    }
                }

                strAction = "ShowDevicesAction";
                oAction   = oAMnr.FindAction(strAction);

                if (oAction != null)
                {
                    //Восстановление при необходимости окна устройств.
                    string path = Environment.GetFolderPath(
                        Environment.SpecialFolder.ApplicationData) +
                                  @"\Eplan\eplan.cfg";
                    PInvoke.IniFile ini = new PInvoke.IniFile(path);
                    string          res = ini.ReadString("main", "show_dev_window",
                                                         "false");

                    if (res == "true")
                    {
                        oAction.Execute(ctx);
                    }
                }

                strAction = "ShowOperationsAction";
                oAction   = oAMnr.FindAction(strAction);

                if (oAction != null)
                {
                    //Восстановление при необходимости окна операций.
                    string path = Environment.GetFolderPath(
                        Environment.SpecialFolder.ApplicationData) +
                                  @"\Eplan\eplan.cfg";
                    PInvoke.IniFile ini = new PInvoke.IniFile(path);
                    string          res = ini.ReadString("main", "show_oper_window",
                                                         "false");

                    if (res == "true")
                    {
                        oAction.Execute(ctx);
                    }
                }

                // Проект открыт, ставим флаг в изначальное состояние.
                EProjectManager.isPreCloseProjectComplete = false;
            }
        }
예제 #23
0
        public override RequestCode OnSelect(
            StorableObject[] arrSelectedObjects,
            SelectionContext oContext)
        {
            // Execute standard operation.
            base.OnSelect(arrSelectedObjects, oContext);

            if (EProjectManager.GetInstance().GetEditInteraction() != this)
            {
                return(RequestCode.Stop);
            }

            Function oF = null;

            if (arrSelectedObjects[0] is Rectangle)
            {
                string oFName =
                    (arrSelectedObjects[0] as Rectangle).Properties.get_PROPUSER_TEST(1);

                oF = Function.FromStringIdentifier(oFName) as Function;
            }

            if (arrSelectedObjects[0] is Function)
            {
                oF = arrSelectedObjects[0] as Function;
            }

            if (oF != null)
            {
                Editor.ITreeViewItem item = Editor.Editor.GetInstance().EForm.GetActiveItem();

                if (item == null)
                {
                    return(RequestCode.Nothing);
                }

                if (item.IsUseDevList)
                {
                    string devName;
                    string objectName;
                    int    objectNumber;
                    string deviceType;
                    int    deviceNumbe;

                    bool res = Device.DeviceManager.CheckDeviceName(oF.Name,
                                                                    out devName, out objectName, out objectNumber, out deviceType,
                                                                    out deviceNumbe);

                    if (res)
                    {
                        string oldDevices = " " + item.EditText[1] + " ";
                        string newDevices = "";
                        //Для корректного поиска отделяем пробелами.
                        devName = " " + devName + " ";

                        if (oldDevices.Contains(devName))
                        {
                            newDevices = oldDevices.Replace(devName, " ");
                        }
                        else
                        {
                            newDevices = oldDevices + devName.Trim();
                        }
                        Editor.Editor.GetInstance().EForm.SetNewVal(newDevices);

                        //Обновление списка устройств при его наличии.
                        if (DFrm.GetInstance().IsVisible() == true)
                        {
                            Device.DeviceType[]    devTypes;
                            Device.DeviceSubType[] devSubTypes;
                            item.GetDevTypes(out devTypes, out devSubTypes);

                            DFrm.GetInstance().ShowDevices(
                                Device.DeviceManager.GetInstance(),
                                devTypes, devSubTypes, false, true,
                                item.EditText[1], null);
                        }
                    }
                }
            }

            return(RequestCode.Select | RequestCode.NoPreselect | RequestCode.NoMultiSelect);
        }
예제 #24
0
        /// <summary>
        /// Считывание описания.
        /// </summary>
        public int LoadDescription(out string errStr,
                                   string projectName, bool loadFromLua)
        {
            errStr = "";
            Logs.Clear();
            EProjectManager.GetInstance().ProjectDataIsLoaded = false;

            string LuaStr;
            int    res = 0;

            var oProgress = new Eplan.EplApi.Base.Progress("EnhancedProgress");

            oProgress.SetAllowCancel(false);
            oProgress.SetTitle("Считывание данных проекта");

            try
            {
                oProgress.BeginPart(15, "Считывание IO");
                projectConfiguration.ReadIO();
                oProgress.EndPart();

                oProgress.BeginPart(15, "Считывание устройств");
                if (projectConfiguration.DevicesIsRead == true)
                {
                    projectConfiguration.SynchronizeDevices();
                }
                else
                {
                    projectConfiguration.ReadDevices();
                }
                oProgress.EndPart();

                oProgress.BeginPart(25, "Считывание привязки устройств");
                projectConfiguration.ReadBinding();
                oProgress.EndPart();

                if (loadFromLua)
                {
                    EncodingDetector.MainFilesEncoding = null;

                    oProgress.BeginPart(15, "Считывание технологических " +
                                        "объектов");
                    res = LoadDescriptionFromFile(out LuaStr, out errStr,
                                                  projectName,
                                                  $"\\{ProjectDescriptionSaver.MainTechObjectsFileName}");
                    techObjectManager.LoadDescription(LuaStr, projectName);
                    errStr = "";
                    LuaStr = "";
                    res    = LoadDescriptionFromFile(out LuaStr, out errStr,
                                                     projectName,
                                                     $"\\{ProjectDescriptionSaver.MainRestrictionsFileName}");
                    techObjectManager.LoadRestriction(LuaStr);
                    oProgress.EndPart();
                }

                oProgress.BeginPart(15, "Проверка данных");
                projectConfiguration.Check();
                oProgress.EndPart();

                oProgress.BeginPart(15, "Расчет IO-Link");
                IOManager.CalculateIOLinkAdresses();
                oProgress.EndPart(true);
                EProjectManager.GetInstance().ProjectDataIsLoaded = true;
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
                oProgress.EndPart(true);
                EProjectManager.GetInstance().ProjectDataIsLoaded = false;
            }

            return(res);
        }
예제 #25
0
 private void OnMainStart(IEventParameter iEventParameter)
 {
     idleTimeModule.BeforeClosingProject +=
         EProjectManager.GetInstance().SyncAndSave;
     idleTimeModule.Start(AddInModule.OriginalAssemblyPath);
 }
예제 #26
0
        /// <summary>
        /// Формирование общей структуры базы каналов
        /// </summary>
        private static XmlElement WriteCommonXMLPart(XmlDocument xmlDoc)
        {
            string     nsDriver     = "http://brestmilk.by/driver/";
            string     prefixDriver = "driver";
            XmlElement firstLevel   = xmlDoc.CreateElement(prefixDriver, "inf", nsDriver);

            firstLevel.InnerText = "BASE F11F3DCC-09F8-4D04-BCB7-81D5D7C48C78";
            xmlDoc.DocumentElement.AppendChild(firstLevel);
            firstLevel           = xmlDoc.CreateElement(prefixDriver, "dbbuild", nsDriver);
            firstLevel.InnerText = "4";
            xmlDoc.DocumentElement.AppendChild(firstLevel);
            firstLevel = xmlDoc.CreateElement(prefixDriver, prefixDriver, nsDriver);
            xmlDoc.DocumentElement.AppendChild(firstLevel);

            XmlElement secondLevel = xmlDoc.CreateElement(prefixDriver, "id", nsDriver);

            secondLevel.InnerText = "1";
            firstLevel.AppendChild(secondLevel);
            secondLevel           = xmlDoc.CreateElement(prefixDriver, "tid", nsDriver);
            secondLevel.InnerText = "0";
            firstLevel.AppendChild(secondLevel);
            secondLevel           = xmlDoc.CreateElement(prefixDriver, "dllname", nsDriver);
            secondLevel.InnerText = "PAC_easy_drv_LZ.dll";
            firstLevel.AppendChild(secondLevel);
            secondLevel           = xmlDoc.CreateElement(prefixDriver, "access", nsDriver);
            secondLevel.InnerText = "2";
            firstLevel.AppendChild(secondLevel);
            secondLevel           = xmlDoc.CreateElement(prefixDriver, "maxsubtypescount", nsDriver);
            secondLevel.InnerText = "10";
            firstLevel.AppendChild(secondLevel);
            secondLevel           = xmlDoc.CreateElement(prefixDriver, "enabled", nsDriver);
            secondLevel.InnerText = "-1";
            firstLevel.AppendChild(secondLevel);
            secondLevel           = xmlDoc.CreateElement(prefixDriver, "descr", nsDriver);
            secondLevel.InnerText = "Система PLC-X1";
            firstLevel.AppendChild(secondLevel);
            secondLevel           = xmlDoc.CreateElement(prefixDriver, "drvname", nsDriver);
            secondLevel.InnerText = Path.GetFileNameWithoutExtension(xmlDoc.BaseURI);
            firstLevel.AppendChild(secondLevel);
            secondLevel           = xmlDoc.CreateElement(prefixDriver, "defname", nsDriver);
            secondLevel.InnerText = "Opc Driver";
            firstLevel.AppendChild(secondLevel);
            secondLevel           = xmlDoc.CreateElement(prefixDriver, "defdescr", nsDriver);
            secondLevel.InnerText = "Универсальный драйвер для протоколов Modbus и SNMP";
            firstLevel.AppendChild(secondLevel);
            secondLevel = xmlDoc.CreateElement(prefixDriver, "communication", nsDriver);
            secondLevel.SetAttribute(
                "xmlns:communication", "http://brestmilk.by/communication/");
            firstLevel.AppendChild(secondLevel);

            string     nsParam    = "http://brestmilk.by/parameters/";
            string     pefixParam = "parameters";
            XmlElement thirdLevel = xmlDoc.CreateElement(
                "communication", pefixParam, "http://brestmilk.by/communication/");

            thirdLevel.SetAttribute("xmlns:parameters", nsParam);
            secondLevel.AppendChild(thirdLevel);

            XmlElement forthLevel = xmlDoc.CreateElement(
                pefixParam, "parameter", nsParam);

            thirdLevel.AppendChild(forthLevel);
            XmlElement fifthLevel =
                xmlDoc.CreateElement(pefixParam, "name", nsParam);

            fifthLevel.InnerText = "TYPE";
            forthLevel.AppendChild(fifthLevel);
            fifthLevel           = xmlDoc.CreateElement(pefixParam, "value", nsParam);
            fifthLevel.InnerText = "COM";
            forthLevel.AppendChild(fifthLevel);

            forthLevel = xmlDoc.CreateElement(pefixParam, "parameter", nsParam);
            thirdLevel.AppendChild(forthLevel);
            fifthLevel           = xmlDoc.CreateElement(pefixParam, "name", nsParam);
            fifthLevel.InnerText = "PORTNAME";
            forthLevel.AppendChild(fifthLevel);
            fifthLevel           = xmlDoc.CreateElement(pefixParam, "value", nsParam);
            fifthLevel.InnerText = "COM4";
            forthLevel.AppendChild(fifthLevel);

            forthLevel = xmlDoc.CreateElement(pefixParam, "parameter", nsParam);
            thirdLevel.AppendChild(forthLevel);
            fifthLevel           = xmlDoc.CreateElement(pefixParam, "name", nsParam);
            fifthLevel.InnerText = "SPEED";
            forthLevel.AppendChild(fifthLevel);
            fifthLevel           = xmlDoc.CreateElement(pefixParam, "value", nsParam);
            fifthLevel.InnerText = "12";
            forthLevel.AppendChild(fifthLevel);

            forthLevel = xmlDoc.CreateElement(pefixParam, "parameter", nsParam);
            thirdLevel.AppendChild(forthLevel);
            fifthLevel           = xmlDoc.CreateElement(pefixParam, "name", nsParam);
            fifthLevel.InnerText = "PARITY";
            forthLevel.AppendChild(fifthLevel);
            fifthLevel           = xmlDoc.CreateElement(pefixParam, "value", nsParam);
            fifthLevel.InnerText = "0";
            forthLevel.AppendChild(fifthLevel);

            forthLevel = xmlDoc.CreateElement(pefixParam, "parameter", nsParam);
            thirdLevel.AppendChild(forthLevel);
            fifthLevel           = xmlDoc.CreateElement(pefixParam, "name", nsParam);
            fifthLevel.InnerText = "DATABITS";
            forthLevel.AppendChild(fifthLevel);
            fifthLevel           = xmlDoc.CreateElement(pefixParam, "value", nsParam);
            fifthLevel.InnerText = "4";
            forthLevel.AppendChild(fifthLevel);

            forthLevel = xmlDoc.CreateElement(pefixParam, "parameter", nsParam);
            thirdLevel.AppendChild(forthLevel);
            fifthLevel           = xmlDoc.CreateElement(pefixParam, "name", nsParam);
            fifthLevel.InnerText = "STOPBITS";
            forthLevel.AppendChild(fifthLevel);
            fifthLevel           = xmlDoc.CreateElement(pefixParam, "value", nsParam);
            fifthLevel.InnerText = "0";
            forthLevel.AppendChild(fifthLevel);

            secondLevel = xmlDoc.CreateElement(prefixDriver, "init_parameters",
                                               nsDriver);
            secondLevel.SetAttribute("xmlns:parameters", nsParam);
            firstLevel.AppendChild(secondLevel);

            thirdLevel = xmlDoc.CreateElement(pefixParam, "parameter", nsParam);
            secondLevel.AppendChild(thirdLevel);
            fifthLevel           = xmlDoc.CreateElement(pefixParam, "name", nsParam);
            fifthLevel.InnerText = "IP";
            thirdLevel.AppendChild(fifthLevel);
            fifthLevel           = xmlDoc.CreateElement(pefixParam, "value", nsParam);
            fifthLevel.InnerText = "IP127.0.0.1";
            thirdLevel.AppendChild(fifthLevel);

            thirdLevel = xmlDoc.CreateElement(pefixParam, "parameter", nsParam);
            secondLevel.AppendChild(thirdLevel);
            fifthLevel           = xmlDoc.CreateElement(pefixParam, "name", nsParam);
            fifthLevel.InnerText = "PLC_NAME";
            thirdLevel.AppendChild(fifthLevel);
            fifthLevel = xmlDoc.CreateElement(pefixParam, "value", nsParam);
            if (string.IsNullOrEmpty(EProjectManager.GetInstance().GetCurrentProjectName()))
            {
                Logs.AddMessage("Не задано PLC_NAME.");
                fifthLevel.InnerText = "PLC_NAME";
            }
            else
            {
                string projectName = EProjectManager.GetInstance().GetCurrentProjectName();
                EProjectManager.GetInstance().CheckProjectName(ref projectName);
                fifthLevel.InnerText = projectName;
            }

            thirdLevel.AppendChild(fifthLevel);

            thirdLevel = xmlDoc.CreateElement(pefixParam, "parameter", nsParam);
            secondLevel.AppendChild(thirdLevel);
            fifthLevel           = xmlDoc.CreateElement(pefixParam, "name", nsParam);
            fifthLevel.InnerText = "PORT";
            thirdLevel.AppendChild(fifthLevel);
            fifthLevel           = xmlDoc.CreateElement(pefixParam, "value", nsParam);
            fifthLevel.InnerText = "10000";
            thirdLevel.AppendChild(fifthLevel);

            thirdLevel = xmlDoc.CreateElement(pefixParam, "parameter", nsParam);
            secondLevel.AppendChild(thirdLevel);
            fifthLevel           = xmlDoc.CreateElement(pefixParam, "name", nsParam);
            fifthLevel.InnerText = "Kontroller";
            thirdLevel.AppendChild(fifthLevel);
            fifthLevel           = xmlDoc.CreateElement(pefixParam, "value", nsParam);
            fifthLevel.InnerText = "LINUX";
            thirdLevel.AppendChild(fifthLevel);

            secondLevel = xmlDoc.CreateElement(
                prefixDriver, "common_parameters", nsDriver);
            secondLevel.SetAttribute("xmlns:parameters", nsParam);
            firstLevel.AppendChild(secondLevel);

            secondLevel = xmlDoc.CreateElement(
                prefixDriver, "final_parameters", nsDriver);
            secondLevel.SetAttribute("xmlns:parameters", nsParam);
            firstLevel.AppendChild(secondLevel);

            secondLevel = xmlDoc.CreateElement(prefixDriver, "subtypes", nsDriver);
            secondLevel.SetAttribute("xmlns:subtypes",
                                     "http://brestmilk.by/subtypes/");
            firstLevel.AppendChild(secondLevel);
            return(secondLevel);
        }