Post by pernockham on Is there a pragma for init/instantiation of local variables in FB (like in Methods)
CODESYS Forge
talk
(Post)
Im using a pointer as input for a FB and for convenience I like to use 'referenced' variable internally. I use this setup in methods which works because internal variables are instantiated for each call. In a FB these variables are instantiated and initiated for the first call only. Is there a pragma/attribute available that changes this behaviour to mirror a 'method'-call?
Last updated: 2024-10-31
Post by micik on Python scripting - print whole project tree
CODESYS Forge
talk
(Post)
Hello, I have found a script for printing device tree in Codesys project. This script is available as code snippet as an exmaple for using Python in Codesys. However I feel main documentation is lacking. For example, where can I find that object has "is_device" attribute? Code examples are given here: https://content.helpme-codesys.com/en/CODESYS%20Scripting/_cds_access_cds_func_in_python_scripts.html However, I have a question how to print the whole Project tree and not just devices? Of course I need to remove check: if treeobj.is_device: But simply removing this test condition will not produce what I want. I need to print PLC Logic, Application, ad other nodes in the Project tree. Where to find this documentation?
Last updated: 2024-08-12
Post by manuknecht on Persistence Manager does not save alphabetically first value
CODESYS Forge
talk
(Post)
I have several libraries which contain values that should be saved on a PLC. As apparently no Persistent Variable List is available within Libraries, I use the Persistence Manager to create a Persistence Channel in the Project which imports the library. I then specify the persistence channel in the library using the {attribute 'ac_persist':='PersistenceChannel_CT'} specifier. This generally works very well and gives me exactly the properties I require. However, it came to my attention that the (alphabetially) first value from the library is not saved in the created ASCII file. When checking the content of the Persistence Channel, it shows all the variables as defined in the library. But the created file does not contain the first value and it is not restored after restart or reset. (see attached picture) I disabled Periodic Saving and set xSaveOnChange to TRUE and so the file usually updates immediately after changing one of the values. When changing the first value, it does not update which is consistent with this value not being saved. I also created a sample project and library from scratch which shows the same issue both using a Raspberry Pi and using a Linux machine. Does someone know what the reason for this could be or did someone make similar experiences? Looking forward to hearing your suggestions. Thanks in advance and best wishes Manuel
Last updated: 2023-10-17
To search for an exact phrase, put it in quotes. Example: "getting started docs"
To exclude a word or phrase, put a dash in front of it. Example: docs -help
To search on specific fields, use these field names instead of a general text search. You can group with AND
or OR
.