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

How can I get all the standard library attribute names

dblessin
2014-02-12
2014-05-02
  • dblessin

    dblessin - 2014-02-12

    hello,

    I'm trying to modify the "ProjectInfoExample.py" example script, to write all Standard library/project attributes (of course only the ones which a writable, I know that the Project attribute *.project is read only).
    In the example file there's company, title, version, default_namespace, author and SpecialDeviceId. But there are also IsEndUserLibrary, LanguageModulAttribute and SpecialDeviceId.
    I wasn't able to find a Definition of the Standard attributes in the help file...

    best regards

     
  • Anonymous - 2014-02-13

    Originally created by: M.Schaber

    hi,

    I don't have your "ProjectInfoExample.py" example script. But my "ProjectInfoCreation.py" script which seems to circulate contains the following snippet:

    \# now we set a custom value...
    info.values["SpecialDeviceId"] = "PLC0815_4711"
    

    As the commment says, this is an example of how to set custom values which are not covered by the explicit API. There is no "registry" of valid values - an End-User can just define a value for his own company (by convention), and then access it e. G. via the generated IEC code. Also, OEMs can extend CODESYS with their own plugins, and thus define values which have "real" semantics for their plugins.

    The api was modeled after the fields which were available in the CODESYS UI back then. As the project settings UI allows to set arbitrary values on the "Properties" tab page, the scripting API also provides this possibility via the dictionary interface.

    Some of those values are recommended by the coding guidelines (which are included in the online help), for example, see the Section Libraries -> Guidelines for creating Libraries -> Library Development Summary -> CODESYS LibDevSummary V3.5.4.0 -> Concepts and Elements -> Library Properties defines the following properties:

             Name Type Description 
    Required Company                Text    Serves for structuring (filter) in theAdd Librarydialog 
    Required Title                  Text    Name of the library 
    Required Version                Version Library verison 
             Released               Bool    A library should not be modified after having been released 
             Author                 Text    Author of the current library version 
             DefaultNamespace       Text    World-wide unique prefix, for defining the scope of the symbols of the library 
             Description            Text    Short description of the purpose of the library 
             Placeholder            Text    which Placeholder should be used for referencing the library 
             IsContainerLibrary     Bool    This library follwos the rules for a Container Library 
             IsInterfaceLibrary     Bool    This library follows the rules for a Interface Library 
             LanguageModelAttribute Text    The access on symbols of the library is only possible via Namespace/Prefix 
             IsEndUserLibrary       Bool    This Library is especially designed for the needs of end users  
    
     
  • dblessin

    dblessin - 2014-02-14

    I'd like to read (and if possible write) exactly These values. But when I try to execute the script Codesys replies:
    'ScriptObject' object has no Attribute 'IsEndUserLibrary'
    ...

    The same happens wit the languagemodelattribute and the specialdeviceid, is it possible to read/write These attributes?

     
  • Anonymous - 2014-02-14

    Originally created by: M.Schaber

    Yes, of course, you use the dictionary syntax, as it is shown in the example script:

    \# now we set a custom value...
    info.values["SpecialDeviceId"] = "PLC0815_4711"
    

    As I wrote, this dictionary syntax allows to read and write arbitrary values. But in that case, it also is your obligation to use the correct type (as it is when using the "Properties" page in the UI).

    Internally, the project information object contains just a dictionary with strings as keys and objects as values. There is nothing special about values like "title" and "version" compared to the others. The only exception is that they have more convenient ways to configure them via explicit scripting API and UI form, in addition to the generic access via the "Properties" page and the dictionary syntax.

     
  • dblessin

    dblessin - 2014-02-14

    That works, thank you

    only Thing, DefaultNamespace must be written whitout an underline or space.

    default_namespace = info.values["DefaultNamespace"]

     
  • Anonymous - 2014-02-14

    Originally created by: M.Schaber

    Hi,

    dblessin hat geschrieben:
    DefaultNamespace must be written whitout an underline or space.
    default_namespace = info.values["DefaultNamespace"]

    Thanks for the hint, I did correct my table above, and I did inform our documentation department so they correct the online help.

     
  • davec

    davec - 2014-04-30

    Hi,
    where can i find the "ProjectInfoExample.py" or "ProjectInfoCreation.py" example script you mentioned in the previous post ?

    Regards,
    Dave

     
  • Anonymous - 2014-05-02

    Originally created by: M.Schaber

    Hi, Dave,

    For the "ProjectInfoExample.py", you need to ask dblessin.

    I did attach the "ProjectInfoCreation.py" file to this post.

    HTH,
    Markus

    ProjectInfoCreation.py [1.52 KiB]

     

Log in to post a comment.