Decision component for simulation only
Moderator: Benj
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Decision component for simulation only
Is it possible to have a dragable decision component that the true branch is accessed during simulation only?
The false branch is for when running of hardware.
I have set up a few flowcharts that work like this but there are a fair few steps involved.
Would be nice to drag a single decision branch instead.
The false branch is for when running of hardware.
I have set up a few flowcharts that work like this but there are a fair few steps involved.
Would be nice to drag a single decision branch instead.
Martin
- Steve
- Matrix Staff
- Posts: 3427
- Joined: Tue Jan 03, 2006 3:59 pm
- Has thanked: 114 times
- Been thanked: 422 times
- Contact:
Re: Decision component for simulation only
Hi Martin,
That's a good idea. I'm sure Ben and Leigh know a few tricks, but in the meantime, here's a possible workaround...
1) Create a variable and set it to zero ("IsSimulating = 0").
2) Use a simulation event (e.g. Time::GetMillisecs) to set it to a value
3) Use an "if (IsSimulating <> 0)" decision to determine if you are simulating or not
I've not tested this, but it should work because step 2 will be ignored in the microcontroller code and so "IsSimulating" will remain zero when running on a device but will be set to a non-zero value when simulating.
Regards,
Steve.
That's a good idea. I'm sure Ben and Leigh know a few tricks, but in the meantime, here's a possible workaround...
1) Create a variable and set it to zero ("IsSimulating = 0").
2) Use a simulation event (e.g. Time::GetMillisecs) to set it to a value
3) Use an "if (IsSimulating <> 0)" decision to determine if you are simulating or not
I've not tested this, but it should work because step 2 will be ignored in the microcontroller code and so "IsSimulating" will remain zero when running on a device but will be set to a non-zero value when simulating.
Regards,
Steve.
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: Decision component for simulation only
Thanks Steve, and for reminding me to comment
I've done this with a "Simulating" property (value 0 or 1)
Set the property value in a Ev event Simulation Start,
and clear the property value in a Ev event Simulation Stop.
I think this idea came from Ben, so he probably does similar.
Leigh
I've done this with a "Simulating" property (value 0 or 1)
Set the property value in a Ev event Simulation Start,
and clear the property value in a Ev event Simulation Stop.
I think this idea came from Ben, so he probably does similar.
Leigh
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Decision component for simulation only
Thanks Guys,
I have been following this post.
Just thought a more instant solution would be beneficial for all?
I have been following this post.
Just thought a more instant solution would be beneficial for all?
Martin
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Decision component for simulation only
Hello,
Yes a great idea Martin,
Here's a quick go at a simple component complete with source.
I'll add an icon and a simple GUI and add it to the v8 release.
Inside the decision icon just add this code.
No = MCU, Yes = Sim Runtime
Yes a great idea Martin,
Here's a quick go at a simple component complete with source.
I'll add an icon and a simple GUI and add it to the v8 release.
Inside the decision icon just add this code.
Code: Select all
IsSim1::Check()
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Decision component for simulation only
Hi Ben,
Just looked into this.
Do you have to add to flowchart, ,, & if using component?
If so, do you believe its easier than this?
Just looked into this.
Do you have to add to flowchart
Code: Select all
Ev_Initialise
Code: Select all
Ev_Comp_Start
Code: Select all
Ev_Start
Code: Select all
Ev_Stop
Code: Select all
.Return = Sim
If so, do you believe its easier than this?
Martin
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Decision component for simulation only
Hi Martin,
You shouldn't have to add any of that.
It should be a case of add the component, Add the code to the decision icon. Job done
You shouldn't have to add any of that.
It should be a case of add the component, Add the code to the decision icon. Job done
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Decision component for simulation only
Thanks Ben,
Tested on hardware and working better than expected as did not need to add, So no need to memorise!
It works buy just using the the component: I will be adding Is Sim component to every flowchart that uses RX interrupt!
Woops Sorry, I did not see the words source, so thought Flowchart posted was an example.Benj wrote:You shouldn't have to add any of that.
Tested on hardware and working better than expected as did not need to add
Code: Select all
IsSim1::Check()
It works buy just using the the component: I will be adding Is Sim component to every flowchart that uses RX interrupt!
Martin