Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » 4DIAC - Framework for Distributed Industrial Automation and Control » Best way to debug algorithms of BFBs
Best way to debug algorithms of BFBs [message #1761382] Wed, 10 May 2017 12:00 Go to next message
Marc Jakobi is currently offline Marc JakobiFriend
Messages: 67
Registered: April 2017
Member
Hi, it's me again!

I am trying out methods to debug the algorithms of BFBs. It currently doesn't seem to be possible using the FBTester.

I launched FORTE in debug mode using Visual Studio and set breakpoints in the class declaration of the exported BFB. This works (as long as I change the C/C++-->General-->Debug Information Format and the Linker-->Debugging-->Generate Debug Info settings in the forte Properties).

However, I cannot see the variable values due to the fact that the ST variables are wrapped by C++ methods. Is there a public method with which I can assign the numeric value of e.g. a CIEC_REAL to a double for the purpose of debugging?

Technically, it would be possible to create temporary data outputs in the FB interface. Internal and temporary variables can then be assigned to these temporary outputs within the respective algorithm. However, this seems more tedious, since the FBs need to be exported and FORTE needs to be rebuilt every time.
Re: Best way to debug algorithms of BFBs [message #1761418 is a reply to message #1761382] Wed, 10 May 2017 20:29 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1584
Registered: January 2014
Senior Member

Hi, I just did a quick test in VS. It allows you to add the function call for a variable (e.g., QO()) as watch expression. When you then unfold you get the return value. If you fold down the base classes till the CIEC_ANY you will find there an union "m_unAyData". This union contains the value of your IEC 61499 variable. You can set the appropriate type (e.g, m_fFloat for a CIEC_REAL). Unfortunately VS does not update the displayed value automatically . But when you reevaluate the watch you'll see that the value has changed and I tested that also the FB takes the new value. It is not as convenient as having C++ variables but at least it gives you some access.
Re: Best way to debug algorithms of BFBs [message #1763293 is a reply to message #1761418] Fri, 12 May 2017 11:58 Go to previous messageGo to next message
Marc Jakobi is currently offline Marc JakobiFriend
Messages: 67
Registered: April 2017
Member
Thank you. That sounds like a good solution.

I have two more concerns about debugging BFBs.

1.
I noticed there is a simple unit test UI in the FBTester (with expected events, etc.). However, it doesn't seem to save any of the test cases (they are lost upon restart of 4diac-IDE). Is this intended behaviour? Also, I have a suggestion: Currently, output data can only be tested if it is linked to an expected event that is being tested. I believe it would be better to not force the WITH expression for unit tests. That way the user could create UT0 .. UTn output arrays that are not linked to any output events and assign internal variables to them in the ST algorithms which can be used in unit tests.

2.
(This one may require its own thread, but it is related to the FBTester, so I decided to post it here)
I have been experiencing strange behaviour when exporting BFBs to FORTE. When changing an algorithm or the interface and then exporting it (overwriting the old header and definition), sometimes the FBTester seems to stop working.
Normally, the input and output variables are all set to their initial values. But in the "bugged" state, this does not happen and the UI shows a "--" symbol next to them.
I initially thought it must have something to do with syntax errors that 4diac IDE and VS don't recognize (i.e. assignments of variables of conflicting types), but when undoing the changes by copying+pasting the old ST code (that worked initially), it still doesn't work. Re-starting the PC, re-building FORTE, etc. often don't fix the issue. And sometimes, it randomly works again.
Is this a known issue and if so, is there a fix?

Update: The second issue seems to be fixable by restarting FORTE a few times.

[Updated on: Fri, 12 May 2017 13:40]

Report message to a moderator

Re: Best way to debug algorithms of BFBs [message #1763314 is a reply to message #1763293] Fri, 12 May 2017 14:40 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1584
Registered: January 2014
Senior Member

The whole testing, unittesting thing we currently have are prototypes and would need some major rework. Currently our main work is to fix sub-applications and after that finally prepare the IDE code for transfer to Eclipse Foundation. After that I think we will definitly also think how a future test concept for FBs will look like. For me it should be completely different from what we have now. I have in my mind something like an own perspective with different debug and test views and no tabs in for that in the FB editor anymore. however this requires quite some thinking and work. As part of this concept I also want to consider how the internals of FBs can be debugged.

For unit tests I find it a bad idea to use internal variables as conditions if a test was working. For me unit testing should only test observable behavior.

Regarding the tester issues: are you always deactivating the tester before stopping forte and reexporting and compiling? When changing anything on the FB you anyhow have to stop forte to have the new code.

Re: Best way to debug algorithms of BFBs [message #1763357 is a reply to message #1763314] Sat, 13 May 2017 11:20 Go to previous messageGo to next message
Marc Jakobi is currently offline Marc JakobiFriend
Messages: 67
Registered: April 2017
Member
I fully agree with you about unit testing only observable behaviour for finished objects with a working implementation. But I find being able to test internal variables can be very useful during the initial development process (i. e. when the internal implementation is not yet complete). I look forward to whatever you come up with in the future. In the meantime, I guess I will stick to simple assertions in VS.

FORTE won't compile if I have an instance of it running, but I probably have forgotten to deactivate the tester sometimes. Thanks for the tip! I will continue working on the project on Monday and see if that fixes it.
Re: Best way to debug algorithms of BFBs [message #1763363 is a reply to message #1763357] Sat, 13 May 2017 14:34 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1584
Registered: January 2014
Senior Member

For debugging an FB I totally agree. Therefore I see definitely some functionality to look into FBs and interact with the internals for future extended debugging features of 4diac.
Re: Best way to debug algorithms of BFBs [message #1763740 is a reply to message #1763363] Fri, 19 May 2017 09:01 Go to previous message
Marc Jakobi is currently offline Marc JakobiFriend
Messages: 67
Registered: April 2017
Member
The FBTester issue still persists to some extent even if the FBTester is deactivated before building. But it is slightly better. To fix it, I have to click on the "Start Testing FB" button with FORTE closed. That will bring up an error message and change the red square (STOP) icon back to a green arrow (GO) icon. Usually, doing this once or twice before starting FORTE fixes the issue. Sometimes, I have to restart 4diac-IDE to get it to work.

EDIT: This behaviour seems to be limited to two of my most complex BFBs.
Strangely, the FBTester of a CFB that contains both of the affected BFBs (among others) seems to work just fine.

EDIT2: After further observation, I have come to the conclusion that the bug seems to occur when a BFB has an array input and/or output (that exceeds a certain length - mine have a length of 96), no matter how simple the algorithms or ECC.

[Updated on: Mon, 22 May 2017 09:32]

Report message to a moderator

Previous Topic:OPC Client in 4diac TERMINATED error
Next Topic:OPC Client only receive date
Goto Forum:
  


Current Time: Tue Apr 23 12:09:40 GMT 2024

Powered by FUDForum. Page generated in 0.03629 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top