Re: Conditional AND triggers

3,869 views
Skip to first unread message

gansb...@gmail.com

unread,
Mar 17, 2015, 7:48:59 AM3/17/15
to automa...@googlegroups.com
Thanks for the reply. Will wait because I like the look and style of this but need something in the interim.

On Tuesday, 10 March 2015 02:44:02 UTC, Automate developer wrote:
Creating conditional AND triggers is currently a bit complex since Automate is so low-level.
I'am still trying to come up with an easier solution, but here are some examples on how you can currently make them:

Time AND place
This example is using the “Nested Fork” method, it’s using the Time window and Location at blocks, but it could be any conditional blocks. The most battery consuming condition should be the most nested.
If the [time AND place] blocks are performing any length operations you may need to Fork it since it could otherwise be aborted by the Fiber stop block at any time.


            :
+-----------+-----------------------+
|           |                       |
|  When in time window? -----+      |
|           |                |      |
|         Fork -----+   Fiber stop  |
|       childURI    |    childURI   |
|           |       |        |      |
+-----------+       |        +------+
                    |
             Is at location? ---+
                    |           |
         +----------+           |
         |          |           |
         |   [time AND place]   |
         |          |           |
         |          +-----------+
         |          |           |
         |  When at location? --+
         |          |
         +----------+


Using the Variable give & take blocks
Coming soon.

Automate developer

unread,
Mar 9, 2015, 10:44:02 PM3/9/15
to automa...@googlegroups.com
Creating conditional AND triggers is currently a bit complex since Automate is so low-level.
I'am still trying to come up with an easier solution, but here are some examples on how you can currently make them:

Nested Fork method
This example is using the “Nested Fork” method, it’s using the Time window and Location at blocks, but it could be any conditional blocks. The most battery consuming condition should be the most nested.
If the [time AND place] blocks are performing any length operations you may need to Fork it since it could otherwise be aborted by the Fiber stop block at any time.
http://llamalab.com/automate/community/flows/1864

            :
+---------->+<----------------------+

|           |                       |
|  When in time window? -----+      |
|           |                |      |
|         Fork -----+   Fiber stop  |
|       childURI    |    childURI   |
|           |       |        |      |
+-----------+       |        +------+
                    |
             Is at location? ---+
                    |           |
         +--------->+           |
         |          |           |
         |   [time AND place]   |
         |          |           |
         |          +<----------+

         |          |           |
         |  When at location? --+
         |          |
         +----------+


Barrier/latch method using the Variable give & take blocks
Automate currently doesn't have an "latch" or "barrier" block but it can be emulated using the Variables give/take blocks.
The "Condition forks" should also check the current state if required using an additional condition block with proceed Immediately as seen in above example.
        :
      Fork1 --> (see "Condition forks" below)
        :
      ForkN -->
(see "Condition forks" below)
        |
+------>+
|  Variables take
|    vars: b
|       |
|  Variables set
|  bits = (bits & ~(b >> 16)) | (b & 0xFFFF)   /* mask in upper 16 bits, flag in lower. */
|       |
| Expression true --+
|   bits = 0b11     |   /* 0b11 for 2 forks, 0b111 for 3, etc. */
|       |           |
|   (all true)      |
+-------+<----------+

   "Condition forks"
          :
+-------->+
| When Time window --------+   /* Can be any condition, Location at, etc.. */
|         |                |
|    Variable set   Variable set
|      b = 0b1      b = 0b1 << 16    /* 0b1 for Fork1, 0b10 for Fork2, 0b100 for Fork3, etc.. */
|         +<---------------+
|    Variable give
|       vars: b
+---------+

paul...@gmail.com

unread,
Sep 28, 2015, 7:57:50 PM9/28/15
to Automate
A screen shot or template would really help here, having trouble figuring out exactly how this all flows.

Automate developer

unread,
Sep 28, 2015, 8:17:12 PM9/28/15
to Automate, paul...@gmail.com
It's basically just a child fiber (childURI) running during the time window, it's started at the beginning of it using the Fork block, and then stopped with the Fiber stop block at the end.
This concept can be used for any condition block, not just the Time window block.
The created child fiber, coming from the NEW dot on the Fork, is a sub-flow you can make as any other.

I'll make some example flows.

destructi...@gmail.com

unread,
Nov 13, 2015, 10:23:48 AM11/13/15
to Automate

Could you create a small flow that shows the actual block and line construction of this method and load it to the community so I can tinker with it, I have a flow that I am wanting to build and if I can use this method it won't be so massive that the app force closes, I have tried to build it with if blocks, but its to heavy for the app to finish the flow before it forces the app to crash.

On Monday, March 9, 2015 at 9:44:02 PM UTC-5, Henrik Lindqvist wrote:
Creating conditional AND triggers is currently a bit complex since Automate is so low-level.
I'am still trying to come up with an easier solution, but here are some examples on how you can currently make them:

Nested Fork method
This example is using the “Nested Fork” method, it’s using the Time window and Location at blocks, but it could be any conditional blocks. The most battery consuming condition should be the most nested.
If the [time AND place] blocks are performing any length operations you may need to Fork it since it could otherwise be aborted by the Fiber stop block at any time.


            :
+-----------+-----------------------+

|           |                       |
|  When in time window? -----+      |
|           |                |      |
|         Fork -----+   Fiber stop  |
|       childURI    |    childURI   |
|           |       |        |      |
+-----------+       |        +------+
                    |
             Is at location? ---+
                    |           |
         +----------+           |
         |          |           |
         |   [time AND place]   |
         |          |           |
         |          +-----------+
         |          |           |
         |  When at location? --+
         |          |
         +----------+


Queue method using the Variable give & take blocks
Example coming soon.

Henrik Lindqvist

unread,
Nov 13, 2015, 6:35:31 PM11/13/15
to Automate, destructi...@gmail.com

paul...@gmail.com

unread,
Nov 14, 2015, 4:54:19 PM11/14/15
to Automate
I added a slightly more complex flow. Took me a long time to figure out and it's been working well for several weeks now http://llamalab.com/automate/community/flows/1875

a google user

unread,
Nov 24, 2015, 2:23:50 AM11/24/15
to Automate
in training we had a logic board where you had to wire blocks similar to flowcharts depending on your given objective.
there were logic blocks for not, or & and. or & and took two signals each. might be a solution, a double wide block with two inputs.

Henrik Lindqvist

unread,
Nov 24, 2015, 7:30:27 PM11/24/15
to Automate
There's a big difference. A flowchart is a finite-state machine, it isn't a circuit board with a "continuous current".
So logic blocks would be superfluous when the Expression true block support the logic operators,

bitbyte...@gmail.com

unread,
Oct 5, 2016, 7:41:52 PM10/5/16
to automa...@googlegroups.com

This works like twenty-times better :P

1. Begin =>
2. Is condition one true?
3.  Yes => Good. Is condition two true?
4.    Yup => Amazing! Go to the output.
5.    No => Dammit. Wait for it to become true.
6.      It's True Now => Go to Line 2
7.  No => Too bad. Wait for it to become true.
8.    It's True Now => Go to Line 3

jckl...@gmail.com

unread,
Jan 3, 2017, 3:19:44 PM1/3/17
to Automate
Can someone tell me if my logic is off here?

http://llamalab.com/automate/community/flows/9367

hyper...@gmail.com

unread,
Feb 7, 2017, 9:53:11 PM2/7/17
to Automate
Maybe a way to create reusable blocks?

* Create a flow with a "flow begin" block and one or more "result" blocks
* Turn that flow into a block
* Place that block in other flows
* The "begin" and "result" blocks become connectors

Then you can build complex logic into simple blocks and reuse them.

As for waiting for multiple events, a "join" block would be useful; it proceeds once another (specified) fibre finishes or is stopped. Or you can test whether the other fibre is still running.

Henrik "The Developer" Lindqvist

unread,
Feb 13, 2017, 4:00:37 PM2/13/17
to Automate, hyper...@gmail.com
A way to return a value at the end of a flow/fiber is on the to-do list.
The Fiber stopped block is the "join" block.
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

foundobjec...@gmail.com

unread,
Jan 4, 2020, 9:29:00 PM1/4/20
to Automate
Wouldn't global variables make this simple?

start
|
fork
/ \
/ fork
A / \
B C

A: check place and set global variable place, repeat

B: check time and set global variable time, repeat


C: if Gvar_time and Gvar_place ....


The concurrency method seems more complicated.

?


Henrik "The Developer" Lindqvist

unread,
Jan 5, 2020, 12:33:34 PM1/5/20
to Automate
It's already possible to have "global variables" within the same flow, i.e. the Atomic blocks.
The complication isn't checking nor storing the state, it's communicating it the the final/base fiber. Currently it's done using the Variables give/take block.

John F

unread,
Feb 24, 2020, 10:40:53 AM2/24/20
to Automate
This is an interesting problem. I had an idea today I thought it was worth mentioning. Is it possible to add a feature to the Variable Set block that allows one to get lower-level data into the given variable? For example, Variable Set: sta = Start of Time Window ... Variable Set: fin = End of Time Window. I'm not sure how location data works, but presumably high and low latitude and longitude or something. This list of available low-level data might include some things that are lumped together in a test block at the moment (or perhaps such blocks could be adjusted to output data only through the YES dot). The problem isn't so much that Automate is low-level, but the opposite - it often makes a comparison or checks a state and exits either through YES or NO (without setting an output variable, or they could be linked, although that would look ugly and confusing). Hence you have to deal with other tests in the branches thus formed. I understand that the Expression true? block areadly allows all the necessary conditionals in text form, so in the example you used, you could set the variables as described above and then AND them in that block.

That's really two suggestions, but doing a similar thing. E.g. instead of a binary condition such as Car mode enabled?, you could either have that in the Variable set block as part of the secondary selection, or the Car mode enabled? block could have a checkbox like [ ] Result always through YES (0/1). In either case, the variable (i.e. the given variable in Variable set, or the output variable of the dedicated block) would contain 0 or 1, which can be logically ANDed or ORed, etc. with other data. It would also provide very useful access to those variables thereafter for other purposes.

One other thought is that if the output of a block is forced to the YES, it might be possible to use the NO in that case to indicate failure or undefined results or something.

Henrik "The Developer" Lindqvist

unread,
Feb 25, 2020, 10:14:39 PM2/25/20
to Automate
The block takes input variables because the "comparison" is either done by the system, or it's done by Automate but in pure Java, for speed and without having the flow in memory.
Making every condition block output a boolean /yes/no variables has been considered, it could save a few block is some cases.

Failure state is neither YES or NO, e.g is wi-if enabled? a failure to check does not mean it's disabled.

John F

unread,
Feb 26, 2020, 4:52:15 PM2/26/20
to Automate
I'm pleased my idea was plausible, but yes I see that it won't fit for all conditions. Do you have a solution, or are you still considering different possibilities? It's a fairly old thread.

I realise the failure state is neither yes or no. But wait - now I'm wondering why this is necessary at all. What's wrong with this?:

<< Is current time within time window? >>
      YES              NO
       |               |
   [Var: Tm=1]     [Var: Tm=0]    ordinary variable set blocks
       |               |
                 \                              /
                   \                          /
                      \                    /
                         - - - - - - - -
                                |
<< Is location within location window? >>
      YES              NO
       |               |
   [Var: Lc=1]     [Var: Lc=0]    ordinary variable set blocks
       |               |
        \             /
         \           /
          \         /
           - - - - -
               |
<< Expression true?  (Ti && Lc) = 1 >>
          YES               NO

Henrik "The Developer" Lindqvist

unread,
Mar 1, 2020, 3:46:32 PM3/1/20
to Automate
The problem is that when Proceed=When changed your flowchart doesn't work, since it would first await time, the pause again to await location.

John F

unread,
Mar 1, 2020, 7:14:31 PM3/1/20
to Automate
But why would you put Proceed=When changed? Why wouldn't you put it as Proceed=Immediately on both, on a manually timed loop?

Henrik "The Developer" Lindqvist

unread,
Mar 5, 2020, 3:26:14 PM3/5/20
to Automate
For a manually loop sure, but that's not very "automated".

tschandl...@gmail.com

unread,
May 10, 2020, 10:23:25 AM5/10/20
to Automate
Can you please help me? I want to compare the values of 3 arrays and switch the output signal by changing one value. I searched the forum and the community for explanations but found nothing helpful.

Henrik "The Developer" Lindqvist

unread,
May 10, 2020, 2:59:12 PM5/10/20
to Automate
Use the contains() function to check if an array contains a value. Use the Expression true block to evaluate it.
Reply all
Reply to author
Forward
0 new messages