Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Get path of runtime project

rickj
2021-06-06
2021-06-11
  • rickj

    rickj - 2021-06-06

    I want to embed HTML and/or PDF doicumentation files into a project and then access them from a visualization screen using the HTML browser component. Is there a global variable or system function that contains/returns the project's root directory on the tagret runtime? I know I can poke around with a file manager and emperically find the path but thios is different for simulation builds than for live PLC builds and I suspect it could vary from one vendor PLC to another. I would like to find a solution that is independent of these variations.

    Thanks in advance for any help.

     
  • m.prestel

    m.prestel - 2021-06-07

    Hey,
    $PlcLogic$/$visu$ is the placeholder to use.

    Best regards,
    Marcel

     
  • rickj

    rickj - 2021-06-07

    How to get the contents of the placeholders? Placing them in the visu browser element's URL doesn't seem to work. Does this only work when executing shell command via windows/linux OS? I wish to display documents on a visualization screen using the html brwser element.

    Is there a way to get the placeholder contents into a PLC stgring variable?

     
  • m.prestel

    m.prestel - 2021-06-10

    If you are using the webvisu and want to display a file located in $PlcLogic$/$visu$ (same folder where e.g. the webvisu.htm is located), you can simply use the file name.

    SysFile should be able to resolve the placeholder.

    Best regards,
    Marcel

     
  • rickj

    rickj - 2021-06-10

    Thanks Marcel. I still haven't figured out how to use the placeholder $PlcLogic$/$visu$ but you have given a very helpful about SysFile. If I embed an external file I can use SysFileGetPath('/App/Filename',Path,80) to get the path where it's stored. I can then compose a string containing the full path+filename for tyher browser. For anyone else interested a code snippet below:

    VAR
        // Path will contain full path minus file name
        Path            : STRING;
    
        // Application - name of application in object tree
        // index.html  - name of embedded file
        Filename        : STRING:='Application/index.html';
    END_VAR
    
    SysFile.SysFileGetPath(Filename, Path, 80);
    
     

    Last edit: rickj 2021-06-10
  • m.prestel

    m.prestel - 2021-06-10

    The webserver will only serve files located in $PlcLogic$/$visu$.
    You cannot access any other files apart from this folder and its subfolder.

    Best regards,
    Marcel

     
  • rickj

    rickj - 2021-06-11

    Hi Marcel,

    VAR_INPUT
        Path        : STRING;
    END_VARcode
    
    SysFile.SysFileGetPath('$$PlcLogic$$/$$visu$$',Path,80);
    
    // Returns Path ='%ProgramData%/CODESYS/Simulation/PlcLogic/visu/'
    

    Placing "file://%ProgramData%/CODESYS/Simulation/PlcLogic/visu/" into codesys embedded browser URL field displays the following:

    Codesys Embeded Browser:

    Can’t reach this page
    
    β€’Make sure the web address is correct
    β€’Search for this site on Bing
    β€’Refresh the page
    

    Placing "file://C:/ProgramData/CODESYS/Simulation/PlcLogic/visu/" into codesys embedded browser URL field displays a directory listign as expected.

    So I am still unable to resolve the placeholder you suggest into a form that can be usaed in the embedded codesys browser. I don't see how the webserve plays into this at all, since I'm only wishing to display static html files located in the same file sapce as the runtime project.

    Can you show some example of how to use the placeholder or how to resolve it to a form useable by the embedded browser?

     
  • rickj

    rickj - 2021-06-11

    Hi Marcel,

    VAR_INPUT
        Path        : STRING;
    END_VARcode
    
    SysFile.SysFileGetPath('$$PlcLogic$$/$$visu$$',Path,80);
    
    // Returns Path ='%ProgramData%/CODESYS/Simulation/PlcLogic/visu/'
    

    Placing "file://%ProgramData%/CODESYS/Simulation/PlcLogic/visu/" into codesys embedded browser URL field displays the following:

    Codesys Embeded Browser:

    Can’t reach this page
    
    β€’Make sure the web address is correct
    β€’Search for this site on Bing
    β€’Refresh the page
    

    Placing "file://C:/ProgramData/CODESYS/Simulation/PlcLogic/visu/" into codesys embedded browser URL field displays a directory listign as expected.

    So I am still unable to resolve the placeholder you suggest into a form that can be usaed in the embedded codesys browser. I don't see how the webserve plays into this at all, since I'm only wishing to display static html files located in the same file sapce as the runtime project.

    Can you show some example of how to use the placeholder or how to resolve it to a form useable by the embedded browser?

     
  • m.prestel

    m.prestel - 2021-06-11

    Hello @rickj,

    I think you misunderstand me.
    Only files located in $PlcLogic$/$visu$ will be served by the webserver (I dont know what happens if you use the Runtime Simulation inside CODESYS..)
    If you want to display your custom PDF documentation inside the webvisualization, make sure that you copy this file into $PlcLogic$/$visu$.

    The url for the browser element inside the webvisu should be something like this:
    http://<ip-addr>:8080/<pdf-filename></pdf-filename></ip-addr>

    Best regards,
    Marcel

     

Log in to post a comment.