I found some interesting new features with SP8, example the title mentioned flags among the arguments of the open.
Though it looks well documented, I'm not sure if it is working.
I have tried the followings and (opening and saving, closing the project) with the below examples, none of them worked for me. (means after reaopening the project with the GUI, it asked me to update for compiler version and showed my old settings -> no update actually happened)
Any idea why?
  proj=projects.open(proj_path,update_flags=(VersionUpdateFlags.SilentMode|VersionUpdateFlags.UpdateAll));
  proj=projects.open(proj_path,update_flags=(VersionUpdateFlags.SilentMode|VersionUpdateFlags.UpdateAll|VersionUpdateFlags.UpdateCompiler|VersionUpdateFlags.UpdateDevices));
  proj=projects.open(proj_path,             encryption_password=None,             session_user=None,             session_password=None,             primary=True,             update_flags=(VersionUpdateFlags.SilentMode|VersionUpdateFlags.UpdateAll|VersionUpdateFlags.UpdateCompiler|VersionUpdateFlags.UpdateDevices));
Thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2016-04-20
Originally created by: M.Schaber
Hi, etamgul,
etamgul hat geschrieben:
I found some interesting new features with SP8, example the title mentioned flags among the arguments of the open.
Though it looks well documented, I'm not sure if it is working.
I have tried the followings and (opening and saving, closing the project) with the below examples, none of them worked for me. (means after reaopening the project with the GUI, it asked me to update for compiler version and showed my old settings -> no update actually happened)
Any idea why? [...]
One guess: Your script loads and then directly saves the project. However, the "Update Environment" mechanism only kicks in when CODESYS gets idle after the project is loaded.
I guess artificially raising the idle event by calling the .NET API System.Windows.Forms.Application.RaiseIdle() could fix the problem.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks, could you give me an example how to do that?
Also how to wait till the process finishes? (is there a feedback or delay with <random> s?)</random>
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2016-04-21
Originally created by: M.Schaber
Hi,
At the beginning of the script:
importSystem
Then, later, after loading the project (but before saving it)
foriinrange(10):
  System.Windows.Forms.Application.DoEvents()
  System.Windows.Forms.Application.RaiseIdle(System.EventArgs.Empty)
Please tell us whether it works or not. If it works, we'll include a similar code in the ScriptEngine eventually. If it doesn't work, I'll file a bug report so we can investigate the problem and provide a bug fix.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Okay I gave up experimenting with the RaiseIdle:
But you gave me an idea (I basically only wanted to update the projects when the compiler or any other version changes).
So instead of trying to raise the event that executes the update I used the SendKey .net method to navigate and do 'semi-manually' the keystrokes..
This one works on my side, though it will not necessarly work every time (depends how fast the IDE processes the sent keys):
  # navigateto"Set all to newest"button
  System.Windows.Forms.SendKeys.Send("{TAB}");
  System.Windows.Forms.SendKeys.Send("{TAB}");
  System.Windows.Forms.SendKeys.Send("{TAB}");
  # Hitandconfirm
  System.Windows.Forms.SendKeys.Send("{ENTER}");
  System.Windows.Forms.SendKeys.Send("{ENTER}");
  # NavigatetoOK
  System.Windows.Forms.SendKeys.Send("{TAB}");
  # confirm
  System.Windows.Forms.SendKeys.Send("{ENTER}");
  Â
  # raiseaprojectupdatewindow
  system.commands[("project", "checkavailableversions")].execute();
Would be cool to access the buttons with some guid or other method, the problem is that execute() is a blocking call.. so workarounds for workaround.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2016-04-22
Originally created by: M.Schaber
Hi, etamgul,
etamgul hat geschrieben:
Does this work on your side?
The second script worked for me on a small toy project, but it failed on a bigger project.
My mistake was to believe that the version compatibility manager kicks in on the Application.Idle() event. While this is true, it only happens after both the project background loading and the loading of all libraries is finished, and this needs more time (more Idle() events) for bigger projects.
Currently, there's no direct way to force this to happen.
As a workaround, using clean_all() or check_all_pool_objects() on the project, or a build on the application should also trigger those events, so issuing one of them followed by a few rounds of DoEvents() and RaiseIdle() should update the project.
Could you please re-check if it is working or not?
Link is not available to the public and this issue was reported with SP8,
now I checked it with SP10 and none of the above examples are working.
Update: jira is running now, issue is still not addressed (Bug is in OPEN, Fix Version/s: Not Planned). Good to see.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2017-04-05
Originally created by: M.Schaber
Hi, Etamgul,
Sorry that the issue is not fixed yet. As there's a workaround, it was priorized rather low, so higher priority issues were fixed first.
I triggered our product management to boost the priority a little bit, so the issue will now most likely be fixed with one of the next service packs. (It's already too late for the upcoming V3.5 SP11, which is already fully planned, but there's rather good chances for SP12.)
Regards,
M.Schaber
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is this issue of idling before loading libraries resolved in Codesys 3.5.18.40 ? I am also curious about this version as there seem to be huge difference in the compiler versions which don't recognize the versions with older storage format.
Last edit: srigan1986 2023-11-24
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I found some interesting new features with SP8, example the title mentioned flags among the arguments of the open.
Though it looks well documented, I'm not sure if it is working.
I have tried the followings and (opening and saving, closing the project) with the below examples, none of them worked for me. (means after reaopening the project with the GUI, it asked me to update for compiler version and showed my old settings -> no update actually happened)
Any idea why?
Thanks
Originally created by: M.Schaber
Hi, etamgul,
One guess: Your script loads and then directly saves the project. However, the "Update Environment" mechanism only kicks in when CODESYS gets idle after the project is loaded.
I guess artificially raising the idle event by calling the .NET API System.Windows.Forms.Application.RaiseIdle() could fix the problem.
Thanks, could you give me an example how to do that?
Also how to wait till the process finishes? (is there a feedback or delay with <random> s?)</random>
Originally created by: M.Schaber
Hi,
At the beginning of the script:
Then, later, after loading the project (but before saving it)
If that does not work, try the following instead:
Please tell us whether it works or not. If it works, we'll include a similar code in the ScriptEngine eventually. If it doesn't work, I'll file a bug report so we can investigate the problem and provide a bug fix.
Are you sure that we are still talking about codesys scriptengine?
I have tried to execute the suggested codepieces but Codesys throws me an exception
Has anybody ever tried testing this or is there something I missed in codesys setup?
Originally created by: M.Schaber
Hi, etamgul,
Yes, as the CODESYS ScriptEngine allows access to most .NET Framework APIs.
Has anybody ever tried testing this or is there something I missed in codesys setup?
It was a mistake in my example code (I simplified to much during copy-paste). The import line needs to be replaced with:
Sorry for the trouble...
I only tried to import the 'System' based on some quick google search.
Unfortunately none of the above examples work (they get executed though, it just seem that the compiler update does not happen).
Does this work on your side?
Okay I gave up experimenting with the RaiseIdle:
But you gave me an idea (I basically only wanted to update the projects when the compiler or any other version changes).
So instead of trying to raise the event that executes the update I used the SendKey .net method to navigate and do 'semi-manually' the keystrokes..
This one works on my side, though it will not necessarly work every time (depends how fast the IDE processes the sent keys):
Would be cool to access the buttons with some guid or other method, the problem is that execute() is a blocking call.. so workarounds for workaround.
Originally created by: M.Schaber
Hi, etamgul,
The second script worked for me on a small toy project, but it failed on a bigger project.
My mistake was to believe that the version compatibility manager kicks in on the Application.Idle() event. While this is true, it only happens after both the project background loading and the loading of all libraries is finished, and this needs more time (more Idle() events) for bigger projects.
Currently, there's no direct way to force this to happen.
As a workaround, using clean_all() or check_all_pool_objects() on the project, or a build on the application should also trigger those events, so issuing one of them followed by a few rounds of DoEvents() and RaiseIdle() should update the project.
I filed the bug report CDS-48995
HTH,
Markus
Could you please re-check if it is working or not?
Link is not available to the public and this issue was reported with SP8,
now I checked it with SP10 and none of the above examples are working.
Update: jira is running now, issue is still not addressed (Bug is in OPEN, Fix Version/s: Not Planned). Good to see.
Originally created by: M.Schaber
Hi, Etamgul,
Sorry that the issue is not fixed yet. As there's a workaround, it was priorized rather low, so higher priority issues were fixed first.
I triggered our product management to boost the priority a little bit, so the issue will now most likely be fixed with one of the next service packs. (It's already too late for the upcoming V3.5 SP11, which is already fully planned, but there's rather good chances for SP12.)
Regards,
M.Schaber
Is this issue of idling before loading libraries resolved in Codesys 3.5.18.40 ?
Is this issue of idling before loading libraries resolved in Codesys 3.5.18.40 ? I am also curious about this version as there seem to be huge difference in the compiler versions which don't recognize the versions with older storage format.
Last edit: srigan1986 2023-11-24