zoukankan      html  css  js  c++  java
  • EPLAN API 入门系列 基础篇

    1、Project::Hierarchy
    
    Eplan::EplApi::DataModel::Project::Hierarchy Enumeration
    
    Hierarchy level of the device structure
    
    C#
    
    public enum Hierarchy {
      Functional,
      Plant,
      Place,
      Location,
      Installation,
      Document,
      UserDef
    }
    
    End Enum
    
    Members           Description 
    Functional         Functional assignment (==) 
    Plant                Higher-level function (=) 
    Place                Installation site (++) 
    Location           Mounting location (+) 
    Installation       Higher level function number 
    Document        Document type (&) 
    UserDef           User-defined (#) 
    
    2、StorableObject
    
    Eplan::EplApi::DataModel::StorableObject:
    
    The parent of all API classes representing P8 project and its structure.
    
    Eplan::EplApi::DataModel::StorableObject
        Eplan::EplApi::DataModel::Article
        Eplan::EplApi::DataModel::ArticleReference
        Eplan::EplApi::DataModel::CommunicationEntity
        Eplan::EplApi::DataModel::Connection
        Eplan::EplApi::DataModel::DeviceListEntry
        Eplan::EplApi::DataModel::E3D::PlaceHolder3D
        Eplan::EplApi::DataModel::E3D::Placement3D
        Eplan::EplApi::DataModel::FunctionDefinition
        Eplan::EplApi::DataModel::Location
        Eplan::EplApi::DataModel::MasterData::FunctionDefinitionLibrary
        Eplan::EplApi::DataModel::MasterData::Symbol
        Eplan::EplApi::DataModel::MasterData::SymbolLibrary
        Eplan::EplApi::DataModel::MergedArticleReference
        Eplan::EplApi::DataModel::MergedConnection
        Eplan::EplApi::DataModel::MergedFunction
        Eplan::EplApi::DataModel::OptionBase
        Eplan::EplApi::DataModel::Placement
        Eplan::EplApi::DataModel::PlcIO
        Eplan::EplApi::DataModel::Project
        Eplan::EplApi::DataModel::ReportBlock
    
    2.1 plan::EplApi::DataModel::Project
    
    Class representing P8 project.
    
    2.2 Eplan::EplApi::DataModel::Page
    
    Example
    
    The following example shows how to use class Page.
    
    [C#] 
    private Page Page_Example1(Project oProject, string strProjectPath, string strPageName) 
    {     
     if (oProject == null)     
     {        
       ProjectManager oProjManager = new ProjectManager();
       if (oProjManager.CurrentProject == null)            
          oProject = oProjManager.OpenProject(strProjectPath);         
       else           
          oProject = oProjManager.CurrentProject;     
      }
    
      oProject.Filter.Name = strPageName;         
      PageoProject.Filter.ExactNameMatching = true; 
      arrPages[] = oProject.Pages;
    
      if (arrPages.Length == 0)         
      return null;
    
      return arrPages[0]; 
    }
    
    2.3 Eplan::EplApi::DataModel::Article
    
    This class represents articles in the Eplan.EplApi.DataModel.Projec.
    
    Example
    
    The following example shows how to use class Article.
    
    [C#]
    private void Article_Example1(Project oProject)
    {
       foreach (Article oArticle in oProject.Articles)
       {
           if ("BECK.KL2012" == oArticle.PartNr)
           {
               if (!oArticle.Properties.ARTICLE_DEPTH.IsEmpty)
                   WriteMessage("ARTICLE_DEPTH : " + oArticle.Properties.ARTICLE_DEPTH);
               if (!oArticle.Properties.ARTICLE_VARIANT.IsEmpty)
                   WriteMessage("ARTICLE_VARIANT : " + oArticle.Properties.ARTICLE_VARIANT);
    
               foreach (int nIndex in oArticle.Properties.ARTICLE_FREE_DATA_DESCRIPTION.Indexes)
                   WriteMessage("ARTICLE_FREE_DATA_DESCRIPTION[" + nIndex + "] : " + oArticle.Properties.ARTICLE_FREE_DATA_DESCRIPTION[nIndex]);
    
               foreach (int nIndex in oArticle.Properties.ARTICLE_FREE_DATA_UNIT.Indexes)
                   WriteMessage("ARTICLE_FREE_DATA_UNIT[" + nIndex + "] : " + oArticle.Properties.ARTICLE_FREE_DATA_UNIT[nIndex]);
    
               foreach (int nIndex in oArticle.Properties.ARTICLE_FREE_DATA_VALUE.Indexes)
                   WriteMessage("ARTICLE_FREE_DATA_VALUE[" + nIndex + "] :" + oArticle.Properties.ARTICLE_FREE_DATA_VALUE[nIndex]);
           }
       }
    }
    
    2.2 plan::EplApi::DataModel::ArticleReference
    
    This class represents a part reference on a project, function, or a connection.
    
    [C#]
        Article oArticle = new Article();
        oArticle.Create(oProject, "KUKA.KR30-3", "1");            //empty Article is created in a Project
        bool bResult = oArticle.LoadFromMasterdata();             //Article is filled with data from system parts database
    
        oProject.AddArticleReference("KUKA.KR30-3", "1", 1);      //reference to the Article is created on a Project
        oFunction.AddArticleReference("KUKA.KR30-3", "1", 1);     //reference to the Article is created on a Function
        oConnection.AddArticleReference("KUKA.KR30-3", "1", 1);   //reference to the Article is created on a Connection
    
    2.4 Eplan::EplApi::DataModel::Connection
    
        Some properties of Data model classes are not linked with their owners even if from the syntax it may seem otherwise. Like in this line: oRectangle.Pen.ColorId = 5, the ColorId of the Pen is changed but oRectangle object doesn't know about it since the Pen property is a stand alone value not aware of oRectangle object existence. This remark applies to the following Connection properties: Articles, Shieldings, SubConnections, SymbolReferences, Pins.
    
    2.5 Eplan::EplApi::DataModel::Function
    
        A class that represents logical devices (or device sub-components) of Eplan.EplApi.DataModel.Project's Eplan.EplApi.DataModel.Page.
    
    Example
    
    The following example shows how to create and place Function on page.
    
    [C#
    
    string strSymbolLibName = "DIC_WUPD";
    string strSymbolName = "MW";
    int nVariant = 1;
    
    //First get SymbolVariant
     SymbolLibrary oSymbolLibrary = new SymbolLibrary(oProject, strSymbolLibName);
     Symbol oSymbol = new Symbol(oSymbolLibrary, strSymbolName);
     SymbolVariant oSymbolVariant = new SymbolVariant();
     oSymbolVariant.Initialize(oSymbol, nVariant);
    
    //Create Function
     Function oNewFunction = new Function();
     oNewFunction.Create(oPage, oSymbolVariant);
    
    //Set function name
     oNewFunction.Name = "=AP+ST1-M1";
     oNewFunction.VisibleName = "M1";
    
    //Set pins descriptions
     oNewFunction.Properties.FUNC_CONNECTIONDESIGNATION[1] = "1";
     oNewFunction.Properties.FUNC_CONNECTIONDESIGNATION[2] = "2";
     oNewFunction.Properties.FUNC_CONNECTIONDESIGNATION[3] = "PE";
                
     //Set location
     oNewFunction.Location = new PointD(120.0, 215.0);
    
     Next example shows how to build connection between two functions. 
    
    [C#]
    
    string strSymbolLibName = "DIC_WUPD";
    string strSymbolName = "M3";
    int nVariant = 0;
    
    SymbolLibrary oSymbolLibrary = new SymbolLibrary(oProject, strSymbolLibName);
    Symbol oSymbol = new Symbol(oSymbolLibrary, strSymbolName);
    SymbolVariant oSymbolVariant = new SymbolVariant();
    oSymbolVariant.Initialize(oSymbol, nVariant);
    
    Function oFunction = new Function();
    oFunction.Create(oPage, oSymbolVariant);
    oFunction.Name = "A";
    oFunction.Location = new PointD(100, 100);
    
    Function oFunction2 = new Function();
    oFunction2.Create(oPage, oSymbolVariant);
    oFunction2.Name = "B";
    oFunction2.Location = new PointD(100, 50);
    
    new Eplan.EplApi.HEServices.Generate().Connections(oPage.Project);
    
    //oFunction.Pins[3].TargetPins[0].ParentFunction.Name == "=+-B"
    
    2.6 Eplan.EplApi.Base.SchemeSetting
    
    Settings
    are used to save values of variables beyond the runtime of the program and to
    make them available again the next time program is run (similar to the Windows
    registry). A setting has a unique identifier in the system. A value or a list
    of values can be saved to a setting. It is possible to group settings into
    structures Eplan.EplApi.Base.SchemeSetting.
    
    Example
    
    Access to a setting of the system
    
    try
    {
      String strGuiLanguage= new Settings().GetStringSetting("USER.SYSTEM.GUI.LANGUAGE", 0);
      System.Windows.Forms.MessageBox.Show("The user interface language is set to: "+ strGuiLanguage);
    }
    catch (BaseException exc)
    {
      String strMessage= exc.Message;
      System.Windows.Forms.MessageBox.Show("Exception: " + strMessage);
    }
  • 相关阅读:
    如何巧妙着运用「位运算」来解决问题?
    一文读懂一台计算机是如何把数据发送给另一台计算机的
    Java集合与泛型中的几个陷阱,你掉进了几个?
    【链表问题】打卡10:将搜索二叉树转换成双向链表
    【链表问题】打卡9:将单链表的每K个节点之间逆序
    【链表问题】打卡8:复制含有随机指针节点的链表
    单例模式中的volatile关键字
    链表回文判断(基于链表反转)—Java实现
    设计模式之单例模式
    Spring的IoC与AOP的理解
  • 原文地址:https://www.cnblogs.com/AriLee/p/2839691.html
Copyright © 2011-2022 走看看