does somebody know how to edit variables in codesys. When i say edit i mean change an existing one. Maybe set the Input_3 to AT%IX100.0:BOOL. Or add new variable Output_3. For example if i have:
VAR_GLOBALÂ Â (*----------------INPUT----------------*)Â Â Input_1Â Â Â Â Â Â AT%IX10.0:Â Â BOOL;Â Â Input_2Â Â Â Â Â Â AT%IX10.1:Â Â BOOL;Â Â Input_3Â Â Â Â Â Â AT%IX10.2:Â Â BOOL;Â Â (*----------------OUTPUTS----------------*)Â Â Output_1Â Â Â Â AT%QX10.0:Â Â BOOL;Â Â Output_2Â Â Â Â AT%QX10.1:Â Â BOOL;Â Â Output_3Â Â Â Â AT%QX10.2:Â Â BOOL;END_VAR
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
M.Keller hat geschrieben:
Hi sarma_men.
Look at the thread Modify GVL constant variable in this forum.
BR
Martin
Thank you for your answer. The thing is, i dont get it, what people are talking about in that thread you linked. when i export the input/output variables to IO_export.xml i am able to search variables with:
Can you please write few lines to show me how to use "pou.textual_declaration.text" and
"pou.textual_implementation.text" to read from my example file Input_1?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
project_path=r"C:\Project\test.project"Â
\#project.close(project_path);ifprojects.primary:
  projects.primary.close()p=projects.open(project_path);pou=p.find('Main_Program', True)[0]
\# readandprintthedeclarationoftheprogramdecl=pou.get_interface_text()print(decl)
I've almoust did it but i need sugestions from you. I cant implement "pou.textual_declaration.text and pou.textual_implementation.text". I am getting error when i try with those two. But in the help i have found few sample codes, and i got it to work.
But with this piece of code i can only get to the local variables from the POU. Can i change something to get to the global varibales?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
sarma_men hat geschrieben:
But with this piece of code i can only get to the local variables from the POU. Can i change something to get to the global varibales?
Global variables in CODESYS are declared in GVL object(s) which is short for "Global Variable List". See the online help of CODESYS.
In the scripting you have to find your GVL object(s) by name or by the type Guid for GVL objects. If you have the script object you can access the variables through .
The following code shows how to find the GVL objects by the type Guid:
fromSystemimportGuidtypeGuid=Guid("{FFBFA93A-B94D-45fc-A329-229860183B1D}")children=projects.primary.get_children(True)forchildinchildren:Â Â ifchild.type==typeGuid:Â Â Â Â print("GVL: "+child.get_name(True)
Import: With the specified type Guid you will also find other objects which declare global variables! For example the "Persistent Variables" and NVL/"Network Variable List" sender(s).
BR
Martin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2016-05-12
Originally created by: M.Schaber
Hi, sarma_men,
sarma_men hat geschrieben:
Didnt want to open a new topic only for one question. Is it possible to get project path and project name?
If the question is totally unrelated to the existing topic, you actually should open a new topic. This will help other users to find your question if they have the same problem, and avoid disturbing the users which are only interested in this topic.
Hallo forum,
does somebody know how to edit variables in codesys. When i say edit i mean change an existing one. Maybe set the Input_3 to AT%IX100.0:BOOL. Or add new variable Output_3. For example if i have:
Hi sarma_men.
Look at the thread Modify GVL constant variable in this forum.
BR
Martin
Thank you for your answer. The thing is, i dont get it, what people are talking about in that thread you linked. when i export the input/output variables to IO_export.xml i am able to search variables with:
just a normal xml parse-ing. but i want to run this script directily in codesys. how can i get access to the object of the IO variables?
Originally created by: M.Schaber
Hi,
If you use pou.textual_declaration.text and pou.textual_implementation.text, you do not need to parse XML.
I am getting the error Name 'pou' is not defined.
Can you please write few lines to show me how to use "pou.textual_declaration.text" and
"pou.textual_implementation.text" to read from my example file Input_1?
I've almoust did it but i need sugestions from you. I cant implement "pou.textual_declaration.text and pou.textual_implementation.text". I am getting error when i try with those two. But in the help i have found few sample codes, and i got it to work.
But with this piece of code i can only get to the local variables from the POU. Can i change something to get to the global varibales?
Hi sarma_men.
Global variables in CODESYS are declared in GVL object(s) which is short for "Global Variable List". See the online help of CODESYS.
In the scripting you have to find your GVL object(s) by name or by the type Guid for GVL objects. If you have the script object you can access the variables through .
The following code shows how to find the GVL objects by the type Guid:
Import: With the specified type Guid you will also find other objects which declare global variables! For example the "Persistent Variables" and NVL/"Network Variable List" sender(s).
BR
Martin
Didnt want to open a new topic only for one question. Is it possible to get project path and project name?
when i do
i get
can i somehow extract from "proj":
Originally created by: M.Schaber
Hi, sarma_men,
If the question is totally unrelated to the existing topic, you actually should open a new topic. This will help other users to find your question if they have the same problem, and avoid disturbing the users which are only interested in this topic.
i get
can i somehow extract from "proj":
With the path property, you can extract the project path as a whole:
This should give you "C:\Project\test\test123.project" in the above example.
python standard library or the .NET framework to split it into directory path and file name.
HTH,
Markus