Bool Toggle

38 views
Skip to first unread message

eric_...@yahoo.com

unread,
Jun 8, 2017, 4:14:50 PM6/8/17
to Sedona Framework
I'm fairly new to the Sedona framework and I'm trying to create a boolean toggle object. Something to simply toggle a boolean out slot, based on an action or "true" value of a boolean "in" slot.

This simple code crashes my VM and I'm looking for some guidance on how to go about this properly...

virtual override void changed(Slot slot)
    {
    if(in)
        {
        out =!out;
        }
    }

I'm assuming as long as "in" is true, the out gets toggled endlessly and causes the VM to hang up.

Is there any way to write this to only happen once?


Mateusz Klatecki

unread,
Jun 8, 2017, 4:51:17 PM6/8/17
to sedo...@googlegroups.com
virtual override void changed(Slot slot)
    {
    if(slot == YourComponentClassName.in && in) //if changed slot is in and in is true
        {
        out =!out; //toggle out
        }
    }

best regards
Mateusz 

--
You received this message because you are subscribed to the Google Groups "Sedona Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sedonadev+unsubscribe@googlegroups.com.
To post to this group, send email to sedo...@googlegroups.com.
Visit this group at https://groups.google.com/group/sedonadev.
For more options, visit https://groups.google.com/d/optout.

keith bradley

unread,
Jun 8, 2017, 9:02:43 PM6/8/17
to sedo...@googlegroups.com
Eric,

When you over ride the changed callback you must run the super version of it:

super.changed

... so I would put that line first inside your changed call back.

Also ... I would not even do it there.

You could setup the execute callback to save the last value.
Then if in does not match saved ... and in is true ... that would mean you got a new positive edge.

Then you can out := !out.

Don't forget to save the new in value.













Murat Egrikavuk

unread,
Jun 9, 2017, 4:32:48 AM6/9/17
to sedo...@googlegroups.com

It is true and important that super.changed(..) must be called.

However, Mateusz's solution is better in principle, because anything you put in the execute() method runs once every cycle. This check, however, needs to be done only when the in value changes.

best regards
Mateusz 

To unsubscribe from this group and stop receiving emails from it, send an email to sedonadev+...@googlegroups.com.

To post to this group, send email to sedo...@googlegroups.com.
Visit this group at https://groups.google.com/group/sedonadev.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Sedona Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sedonadev+...@googlegroups.com.

To post to this group, send email to sedo...@googlegroups.com.
Visit this group at https://groups.google.com/group/sedonadev.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Sedona Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sedonadev+...@googlegroups.com.

keith bradley

unread,
Jun 9, 2017, 1:39:43 PM6/9/17
to sedo...@googlegroups.com
Ah !! ... good to know.

Thanks Murat !!


best regards
Mateusz 

To unsubscribe from this group and stop receiving emails from it, send an email to sedonadev+unsubscribe@googlegroups.com.

To post to this group, send email to sedo...@googlegroups.com.
Visit this group at https://groups.google.com/group/sedonadev.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Sedona Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sedonadev+unsubscribe@googlegroups.com.

To post to this group, send email to sedo...@googlegroups.com.
Visit this group at https://groups.google.com/group/sedonadev.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Sedona Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sedonadev+unsubscribe@googlegroups.com.

To post to this group, send email to sedo...@googlegroups.com.
Visit this group at https://groups.google.com/group/sedonadev.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Sedona Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sedonadev+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages