CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Mon Oct 22, 2018 1:22 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Wed Sep 20, 2017 8:36 am 
Offline

Joined: Tue Sep 19, 2017 3:02 pm
Posts: 2
Hello,

I am trying to start CoDeSys with a batch file like this and execute a python script afterwards:

Code:
start "" CoDeSys.exe --profile="CODESYS V3.5 SP10 Patch 4" --enablescripttracing --runscript=%PYTHON_PATH% --scriptargs=%XML_PATH%


This works well so far but I need to pass the --profile argument more generic. So is there a way to read the installed CoDeSys profile from the used computer in a batch script?
If not...is it possible to do some hack? I saw a folder called "Profiles" in the Codesys installation folder. Maybe I could scan the file names there to get the latest installed profile.

Greetings


Top
   
PostPosted: Thu Sep 21, 2017 10:04 am 
Offline
Frequent User
Frequent User

Joined: Tue Nov 13, 2012 9:20 am
Posts: 232
Hi P_Groebner.

P_Groebner wrote:
So is there a way to read the installed CoDeSys profile from the used computer in a batch script?

You can find the profile name inside the content of sys.version.

Here some example code:
Code:
from __future__ import print_function

import sys
print("--- sys.version")
print(sys.version)

Output from CODESYS V3.5 SP11:
Code:
--- sys.version
2.7.7 (CODESYS.exe CODESYS V3.5 SP11, ScriptEngine.plugin 3.5.11.0)

I think the best way to get the profile name is to match the executable name, which you can get from sys.executable, and the plug-in name 'ScriptEngine.plugin' with the leading comma and extract what is between them.

BR
Martin

_________________
Check out the CODESYS store: http://store.codesys.com/

CODESYS® a trademark of 3S-Smart Software Solutions GmbH
Inspiring Automation Solutions


Top
   
PostPosted: Thu Sep 21, 2017 10:50 am 
Offline

Joined: Tue Sep 19, 2017 3:02 pm
Posts: 2
Hi M.Keller and thank you for your answer.

okay I may not have expressed myself very well, sorry. I need to read the profile before I start CoDeSys and execute my python script. I need to read it in my batch file (outside of the CoDeSys IDE), where I start CoDeSys, so that I can do something like:

Code:
start "" CoDeSys.exe --profile=%CODESYS_PROFILE% --enablescripttracing --runscript=%PYTHON_PATH%


What I did now is to scan the Profiles folder (Default path: C:\Program Files (x86)\3S CODESYS\CODESYS\Profiles) and list all file names with a *profile extension. Afterwards I can choose the profile I want and store it in a variable. The batch script code looks like follows(you should be able to execute it, if CoDeSys is installed in the specified directory):

Code:
@echo off

cd C:\Program Files (x86)\3S CODESYS\CODESYS\Profiles

echo List all installed CoDeSys profiles:
setlocal enableextensions enabledelayedexpansion
set /a count = 0
for %%f in (*.profile) do  (
   set /a count += 1
   echo !count!: %%~nf
)
endlocal

rem Choose profile
echo(
SET /p PROFILE_NUMB=Choose the profile you want to use by entering a number:

rem Get profile
setlocal enableextensions enabledelayedexpansion
set /a count = 0
for %%f in (*.profile) do  (
   set /a count += 1
   if !count!==%PROFILE_NUMB% (
      SET CODESYSPROFILE=%%~nf
      goto commonExit
   )
)
endlocal

:commonExit
echo %CODESYSPROFILE%
pause
exit


Can you give me a short feedback on this solution? I guess it is not guaranteed, that it will work in the future. Iam also grateful for further suggestions on how to solve this.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 3 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: aritra666 and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited