Project Information

swtroelofs
2012-09-26
2022-03-23
  • swtroelofs - 2012-09-26

    Hi all,

    A question:
    In the Project Information dialog (under POUs) I tick the box: 'Automatically generate POUs for property access'.
    Now in my program I can read the version of the program with this line:

    VAR
    VersionNumber : VERSION;
    end_var
    VersionNumber := GetVersion();
    

    When I compile the program I get the following error message:

    Zitat:
    ambigous use of name 'GetVersion'

    This is because the function GetVersion is also declared in 2 libraries.
    I can use the GetVersion functions of the libraries by using the library namespace like so:
    VersionNumber := SM3_Basic.GetVersion();

    But how do I use the GetVersion function of my project?

    Thanks,
    Stefan

     
  • TimvH

    TimvH - 2012-09-26

    As you can see in the "Project Information - Summary" dialog, the fields in bold letters are used to identify a library.
    When you create your own library you can put the objects in the POU pool which are part of your library.
    Because of the introduction of library versioning in V3 you need to fill in these fields (mandatory).
    In the library you can add your own namespace to identify the specific getversion function (no ambiguous use) in the project.

     
  • TimvH

    TimvH - 2012-09-26

    I couldn't resist to find out how it can be done. I used CoDeSys V3.5 SP1 P2 with the Control Win.
    - Right click on the "Application" and choose Properties
    - Go to the Tab "Information"
    - Here you can fill in your version number
    When you download your application, also this information is loaded in the PLC. I noticed it is not changed when doing online changes.

    To access this information from your application you need to add the Library CmpApp. This is not documented, but it works with the code you can find below:

    VAR
       sVersion: STRING;
       pApp : POINTER TO CmpApp.APPLICATION;
       prInfo : POINTER TO CmpApp.Application_INFO;
       pResAGAI: POINTER TO CmpApp.SysTypes.RTS_IEC_RESULT;
       pResAGC: POINTER TO CmpApp.SysTypes.RTS_IEC_RESULT;
    END_VAR
    
    // Get Pointer to current application
    pApp := AppGetCurrent(pResult:= pResAGC);
    // Get Pointer to Application information
    prInfo := AppGetApplicationInfo(pApp:= pApp, pResult:= pResAGAI);
    // Get version from Application information
    sVersion := prInfo^.pstVersion^;
    
     
  • swtroelofs - 2012-09-27

    I have tried your code, and it works well.
    Thank you!

     
  • jzhvymetal - 2012-10-10

    Updated Function to get all application information from the Application

     FUNCTION GetAppInfo : BOOL
    (*'******************************************************************************
    '* This Function gets the application information.
    '*
    '* Function requires the system library CmpApp
    '* 
    '*******************************************************************************
    *)
    VAR_OUTPUT
       strProjectName: STRING(255);
       strDescription: STRING(255);
       strProfile: STRING(255);
       strVersion: STRING(255);
       strLastChanges: STRING(255);
    END_VAR
    VAR
       tResult: DWORD;
       tFirstApp: POINTER TO APPLICATION;
       pAppInfo: POINTER TO APPLICATION_INFO;
       pString : POINTER TO STRING;
    END_VAR
    
    tFirstApp := AppGetFirstApp(pResult := tResult);
    IF tFirstApp <> 0 THEN
       pAppInfo :=AppGetApplicationInfo(tFirstApp, tResult);
       strProjectName :=pAppInfo^.pstProjectName^;
       strDescription:=pAppInfo^.pstDescription^;
       strProfile:=pAppInfo^.pstProfile^;
       strVersion:=pAppInfo^.pstVersion^;
       strLastChanges:=DT_TO_STRING(pAppInfo^.dtLastChanges);
    END_IF
    
     
    • krstech

      krstech - 2022-03-23

      thank you! works for me.

       
    • krstech

      krstech - 2022-03-23

      thank you! works for me.

       
  • jackiechooi - 2017-03-08

    Here is the example of using the 'AppGetProjectInformation' and 'AppGetApplicationInfo'.

    VAR
       pApp : POINTER TO APPLICATION;
       pAppInfo : POINTER TO APPLICATION_INFO;
       pProInfo : PROJECT_INFO;
       pResAppInfo : RTS_IEC_RESULT;
       pResCur : RTS_IEC_RESULT;
       pResProInfo : RTS_IEC_RESULT;
    END_VAR
    
    // Get Pointer to current application
    pApp := AppGetCurrent(pResult:= pResCur);
    // Get Pointer to Application information
    pAppInfo := AppGetApplicationInfo(pApp:= pApp, pResult:= pResAppInfo);
    // Get Result of Project information
    // to use this AppGetProjectInformation with Project_Info structure, user need to enable the "Automatically generate 'Project Information' POUs" in the Project Information dialog.  
    pResProInfo := AppGetProjectInformation(pApp:= pApp, pInfo:= ADR(pProInfo));
    
     

Log in to post a comment.