コード例 #1
0
ファイル: AddPOU.cs プロジェクト: ehsanamid/Engineering
 public AddPouForm(tblController _controller, POUTYPE _poutype)
 {
     controller = _controller;
     poutype    = _poutype;
     //ControllerID = _controller.ControllerID;
     InitializeComponent();
     LoadPouTypes();
     LoadVarProgrammingLanguage();
 }
コード例 #2
0
        private void addUD(bool _isfunction, POUTYPE _poutype, POUEXECUTIONTYPE _pouexecutiontype, string _nodetreename)
        {
            AddUDPouForm addudpouform = new AddUDPouForm();

            if (DialogResult.OK == addudpouform.ShowDialog())
            {
                int _type = 0;
                if (_isfunction)
                {
                    _type = 0;
                }
                else
                {
                    _type = (int)VarType.USERDEFUNED;
                }
                foreach (tblFunction tblfunction in tblSolution.m_tblSolution().m_tblFunctionCollection)
                {
                    if (tblfunction.IsFunction == _isfunction)
                    {
                        if (tblfunction.Type > _type)
                        {
                            _type = tblfunction.Type;
                        }
                    }
                }

                if (CheckUDNameIsValid(addudpouform.pouname))
                {
                    tblPou tblpou = new tblPou();
                    tblpou.pouName       = addudpouform.pouname;
                    tblpou.Description   = addudpouform.poudescription;
                    tblpou.Type          = _poutype;
                    tblpou.Language      = addudpouform.pouLanguageType;
                    tblpou.executiontype = _pouexecutiontype;
                    tblpou.ControllerID  = tblSolution.m_tblSolution().Dummytblcontroller.ControllerID;
                    tblpou.Insert();
                    tblController tblcontroller = tblSolution.m_tblSolution().GetControllerFromID(tblpou.ControllerID);
                    tblcontroller.m_tblPouCollection.Add(tblpou);
                    tblcontroller.SavePouDB();
                    tblFunction _tblfunction = new tblFunction();
                    _tblfunction.FunctionName  = addudpouform.pouname;
                    _tblfunction.Description   = addudpouform.poudescription;
                    _tblfunction.Language      = (int)addudpouform.pouLanguageType;
                    _tblfunction.SolutionID    = tblSolution.m_tblSolution().SolutionID;
                    _tblfunction.FunctionGroup = (int)FunctionGroup.USER_DEFINED;
                    _tblfunction.IsFunction    = _isfunction;
                    _tblfunction.IsStandard    = false;
                    _tblfunction.Extensible    = false;
                    _tblfunction.Overloaded    = false;
                    _tblfunction.Width         = 4;
                    _tblfunction.Mode          = 3;
                    _tblfunction.Type          = _type + 1;
                    int ret = _tblfunction.Insert();
                    if (ret == 0)
                    {
                        //tblSolution.m_tblSolution().functionbyType.Add(_tblfunction.Type, _tblfunction);
                        //tblSolution.m_tblSolution().functionbyName.Add(_tblfunction.FunctionName, _tblfunction);
                        //EWSTreeNode _node;
                        foreach (TreeNode rootnode in treeViewControl.Nodes)
                        {
                            foreach (TreeNode _node in rootnode.Nodes)
                            {
                                //_node = (EWSTreeNode)node;
                                //while (_node.NextNode != null)
                                {
                                    if (_node.Text == _nodetreename)
                                    {
                                        EWSTreeNode node4 = new EWSTreeNode(tblpou.pouName);
                                        node4.NodeID = tblpou.pouID;
                                        if (_isfunction)
                                        {
                                            node4.Nodetype         = TREE_NODE_TYPE.FUNCTION;
                                            node4.ContextMenuStrip = contextMenuStripUDF;
                                        }
                                        else
                                        {
                                            node4.Nodetype         = TREE_NODE_TYPE.FUNCTIONBLOCK;
                                            node4.ContextMenuStrip = contextMenuStripUDFB;
                                        }
                                        switch ((PROGRAM_LANGUAGE)tblpou.Language)
                                        {
                                        case PROGRAM_LANGUAGE.ENUM_PROGRAM_LANGUAGE_FBD:
                                            node4.ImageIndex         = 4;
                                            node4.SelectedImageIndex = 5;
                                            break;

                                        case PROGRAM_LANGUAGE.ENUM_PROGRAM_LANGUAGE_ST:
                                            node4.ImageIndex         = 12;
                                            node4.SelectedImageIndex = 13;
                                            break;
                                        }


                                        _node.Nodes.Add(node4);
                                        return;
                                    }
                                    //   _node = (EWSTreeNode)_node.NextNode;
                                }
                            }
                        }
                    }
                }
            }
        }