CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum
Deutsche Version English version russian version 
It is currently Tue Oct 17, 2017 2:51 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Thu May 04, 2017 6:17 pm 
Offline

Joined: Tue Jan 17, 2017 12:23 pm
Posts: 5
Hi guys,
I'm looking for some kind of assertion or exception mechanism. I know __try, __catch, __finally. But i don't know how "throw" an exception when something happened. I have seen in help definition of ExceptionCode type, which contains:
Code:
_ _USER _EXCEPTION _BASE := 16#00010000

So maybe it is possible somehow to throw an exception.

Do we have some kind of assertion mechanism in order to stop whole application if some requirements are not fulfilled?
Now I have dummy function to do that:
Code:
FUNCTION assert : BOOL
VAR_INPUT
   stopProgram : BOOL;
END_VAR
VAR
   tmp : INT := 0;
END_VAR


IF stopProgram THEN
   tmp := 1 / tmp;
END_IF


Top
   
PostPosted: Mon Aug 21, 2017 3:45 pm 
Offline

Joined: Wed Mar 01, 2017 4:36 pm
Posts: 1
Same question here! Any new findings?


Top
   
PostPosted: Tue Aug 29, 2017 12:49 pm 
Offline

Joined: Tue Jul 18, 2017 6:19 am
Posts: 20
You can do this:

PROGRAM PLC_PRG
VAR
result : INT;
number5 : INT := 5;
END_VAR

result := 5 / (number5-number5);

It will then "automatically" raise an exception ;-). I had to define a variable because codesys is so unbelievably smart it can detect a division by zero if provided with int literals -.-.

Ofcourse there was nothing useful in the helpfile about throwing an exception...


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: 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