Author Topic: Gerenal clarification question  (Read 10862 times)

Offline Rafal_Typiak

  • PLUS+1 Expert
  • ****
  • Posts: 51
  • Karma: +1/-0
Gerenal clarification question
« on: February 27, 2020, 09:01:33 AM »
Hello,
I'm using guide for some time now and there has always been a question that's been bugging me but I always felt too stupid to ask it. Finally, I've mustered the courage to do so, so ......
My question is this:
In a normal circumstances - when you simply put blocks onto a page - is every block being executed?
Say you have an example from the attachment. You have two pages which output to a switch block. If you 'switch' inputs, does this act as an 'if' statement in C/C++, meaning that stuff that's not being passed through is not being executed? Or does the code in both pages executes, but only one is being passed through? And if so, does that mean that the only way to have code NOT executed, is to put it into a module?

Thanks for any help clarifying this for me,
Cheers,
Rafal Typiak

Offline FluidPowerTom

  • PLUS+1 Guru
  • *****
  • Posts: 363
  • Karma: +33/-0
Re: Gerenal clarification question
« Reply #1 on: February 27, 2020, 05:37:21 PM »
Rafal, both blocks will be executed, so it's not like an 'IF' statement in that sense.  Well, maybe it is like an 'IF' statement but one where both/all conditions are calculated outside of it, and the 'IF' statement itself is simply deciding which calculation to map to your output variable.

Modules, I believe, are the only way to have code not be executed if you're using the graphical GUIDE components.  You can also use a Structured Text POU in GUIDE within which you can have actual 'IF' statements, and additionally you can have a boolean deciding when to execute that POU.
Controls Engineer
Hydra-Power Systems

Offline Rafal_Typiak

  • PLUS+1 Expert
  • ****
  • Posts: 51
  • Karma: +1/-0
Re: Gerenal clarification question
« Reply #2 on: February 27, 2020, 08:23:35 PM »
Thanks,
that's what I was assuming. Now I know and can sleep well again  :P

Cheers,
Rafal

Offline oiltronic

  • PLUS+1 Guru
  • *****
  • Posts: 170
  • Karma: +15/-0
Re: Gerenal clarification question
« Reply #3 on: March 09, 2020, 06:52:01 PM »
I can imagine code generator, compiler, and optimizer scenarios that would only execute the code in the selected branch, so I wouldn't be too certain.  Can someone from Danfoss enlighten us?

Offline jlindholm

  • Administrator
  • PLUS+1 Developer
  • *
  • Posts: 21
  • Karma: +2/-0
Re: Gerenal clarification question
« Reply #4 on: March 13, 2020, 08:55:52 AM »
Hello oiltronic.
I think FluidPowerTom did a good explanation of how the code is interpreted in PLUS+1 GUIDE.
What's written their is correct to my understanding.

BR
Jonas