CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum
Deutsche Version English version russian version 
It is currently Mon May 22, 2017 10:33 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Thu Nov 17, 2016 2:36 pm 
Offline

Joined: Thu Jun 16, 2016 10:56 am
Posts: 8
Hello,

I would like to set up an automated software build system on a scripting base.
Therefore I start a batch file containing the "codesys --runscript" commands for a python script to compile a codesys project with the option --enablescripttracing.
This works fine, but the trace output is not redirected into a file completely.
On cmd prompt the batch file output ist redirected via "build.bat >> log1.dat" - ok
Within build.bat the python "print()" script commands are redirected via "> log2.dat Codesys --runscript ..." - ok
But the codesys compiler messages are displayed within cmd prompt :|

How can I redirect the messages that come out of codesys during e.g. the python command "app.create_boot_application(bootapppath)" ?

Best regards
Dirk


Top
   
PostPosted: Thu Nov 17, 2016 5:49 pm 
Offline
Frequent User
Frequent User

Joined: Tue Nov 13, 2012 9:20 am
Posts: 192
Hi DBe.

DBe wrote:
How can I redirect the messages that come out of codesys during e.g. the python command "app.create_boot_application(bootapppath)" ?

Here some example code:
Code:
CompileCategory = Guid("{97F48D64-A2A3-4856-B640-75C046E37EA9}")

found = projects.primary.find("Application", True)
app = found[0]

# Clear messages from Build category
system.clear_messages(CompileCategory)

app.create_boot_application(r"C:\Temp\App.app")

# Get message objects which contain all the data
severities = {
   Severity.FatalError : "Fatal error", Severity.Error : "Error",
   Severity.Warning : "Warning", Severity.Information : "Information",
   Severity.Text : "Text"
   }
msgs = system.get_message_objects(CompileCategory)
for msg in msgs:
   sev = severities[msg.severity]
   print("{} {}{}: {}".format(sev, msg.prefix, msg.number, msg.text))

# Or: Get only the message text
msgs = system.get_messages(CompileCategory)
for msg in msgs:
   print(msg)

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: Fri Nov 18, 2016 9:38 am 
Offline

Joined: Thu Jun 16, 2016 10:56 am
Posts: 8
Hi Martin,

thank you very much! The compile information is printed within cmd prompt AND log file now :) .
During project creation I do a SVN checkout (via codesys addon). These reports are printed within cmd prompt only.
Is there another GUID available for this too?

BR
Dirk


Top
   
PostPosted: Fri Nov 18, 2016 12:22 pm 
Offline
Frequent User
Frequent User

Joined: Tue Nov 13, 2012 9:20 am
Posts: 192
Hi DBe.

DBe wrote:
Is there another GUID available for this too?

Use the following code to get a list of all available message categories:
Code:
guids = system.get_message_categories(False)
for guid in guids:
   print("GUID: {} Description: {}".format(guid, system.get_message_category_description(guid)))

If you replace "False" with "True" in "get_message_categories()" you only get the active message categories.

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: Fri Nov 18, 2016 2:08 pm 
Offline

Joined: Thu Jun 16, 2016 10:56 am
Posts: 8
Hi Martin,

works fine - thank you!
Only one small remark:
"HMI Meldungen" has no constructor? Therefore you algo fails.
But a try-catch filters this.

BR
Dirk


Top
   
PostPosted: Mon Nov 21, 2016 1:58 pm 
Offline
Frequent User
Frequent User

Joined: Tue Nov 13, 2012 9:20 am
Posts: 192
Hi DBe.

DBe wrote:
"HMI Meldungen" has no constructor? Therefore you algo fails.

Which version of CODESYS do you use when this error happened?

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: Tue Dec 06, 2016 8:50 am 
Offline

Joined: Thu Jun 16, 2016 10:56 am
Posts: 8
Hi Martin,

I use Codesys 3.5 SP5 Patch 7 with a build profile 3.5 SP3.
Using these commands:
Code:
for guid in guids:
print("GUID: {} Description: {}".format(guid, system.get_message_category_description(guid)))

I get these errors:
Code:
Skript Meldungen: Information: Build.py(23): Ausnahmefehler (<type 'exceptions.A
ttributeError'>, AttributeError(u'F\xfcr dieses Objekt wurde kein parameterloser
 Konstruktor definiert.',), <traceback object at 0x000000000000002B>)
Skript Meldungen: Information: Build.py(23):       print("GUID: {} Description:
{}".format(guid, system.get_message_category_description(guid)))
Skript Meldungen: Information: Build.py(23): Ausnahmefehler (<type 'exceptions.A
ttributeError'>, AttributeError(u'F\xfcr dieses Objekt wurde kein parameterloser
 Konstruktor definiert.',), <traceback object at 0x000000000000002C>)


Kind regards
Dirk


Top
   
PostPosted: Wed Dec 07, 2016 9:56 am 
Offline
Frequent User
Frequent User

Joined: Tue Nov 13, 2012 9:20 am
Posts: 192
Hi Dirk.

DBe wrote:
I use Codesys 3.5 SP5 Patch 7 with a build profile 3.5 SP3.

The problem is not the HMI category. It's only the last working category before the error.

I tried it with two newer versions. With CODESYS V3.5 SP6 the problem still exists. With CODESYS V3.5 SP7 there is no error.

BR
Martin

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

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


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

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 2 guests


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