Home AMX User Forum NetLinx Studio

Learning Timelines

This is going to be a dumb question, but I'm going nuts trying to figure out how timelines work.

I tried to create a timeline for my underground sprinklers:
timeline_event[tlSprinklers] {

    // turn all zones off
    off[dev_axf1_8relay1,1]
    off[dev_axf1_8relay1,2]
    off[dev_axf1_8relay1,3]
    off[dev_axf1_8relay1,4]
    off[dev_axf1_8relay1,5]
    
    // keep track of sequence for use elsewhere in program
    varTlSprinklersSeq = timeline.sequence
    
    // advance to the correct zone
    switch(timeline.sequence) {
	case 1: { on[dev_axf1_8relay1,1] }
	case 2: { on[dev_axf1_8relay1,2] }
	case 3: { on[dev_axf1_8relay1,3] }
	case 4: { on[dev_axf1_8relay1,4] on[dev_axf1_8relay1,5] }
	case 5: { 
	    off[dev_axf1_8relay1,1]
	    off[dev_axf1_8relay1,2]
	    off[dev_axf1_8relay1,3]
	    off[dev_axf1_8relay1,4]
	    off[dev_axf1_8relay1,5]
	}
    } // switch
} // timeline_event

Technically, case 5 shouldn't need those off commands as they were already executed above, but I tossed them in during troubleshooting when the thing wouldn't turn off.

I am starting the timeline with:
button_event [devAllMSP, 16] { 
    push: { 
	to [devAllMSP, 16]
	if (timeline_active(tlSprinklers)) { timeline_set (tlSprinklers, 5) }	// shut it down
	else { 	// start it up
	    varTimeArray[1] = 9000
	    varTimeArray[2] = 3000
	    varTimeArray[3] = 6000
	    varTimeArray[4] = 15000
	    varTimeArray[5] = 1
	    timeline_create(tlSprinklers, varTimeArray, 5, timeline_relative, timeline_once)	    
	} // else
   } // push
} // button_event

Seems straightforward enough. I also added the ability to "cycle" to the next zone:
button_event [devAllMSP, 15] { 
    push: { 
	to [devAllMSP, 15]  
	if (timeline_active(tlSprinklers)) { timeline_set (tlSprinklers, varTlSprinklersSeq + 1) }
    } // push
} // button_event

The timeline does not behave as expected:

1. When I turn it on, it takes several seconds before it activates, which is rather annoying. Same thing if I try to cycle - it just sits there for awhile before responding.

2. When I cycle to the next zone, it actually activates each zone in turn first! For example, say zone 2 is on, and I switch to zone 3. After several seconds, zone 2 will go off. Then zone 1 will come on for a few seconds, and go off. Zone 2 comes on, goes off. Zone 3 comes on and starts running. What's that all about??

I think I've followed the docs well enough here.. am I missing something? Did I do something wrong? I've been at this for several hours and am quite frustrated at this point. :(

Thank you for any advice.

Comments

  • Seems straightforward enough. I also added the ability to "cycle" to the next zone:
    button_event [devAllMSP, 15] { 
        push: { 
    	to [devAllMSP, 15]  
    	if (timeline_active(tlSprinklers)) { timeline_set (tlSprinklers, varTlSprinklersSeq + 1) }
        } // push
    } // button_event
    

    The timeline does not behave as expected:

    1. When I turn it on, it takes several seconds before it activates, which is rather annoying. Same thing if I try to cycle - it just sits there for awhile before responding.

    2. When I cycle to the next zone, it actually activates each zone in turn first! For example, say zone 2 is on, and I switch to zone 3. After several seconds, zone 2 will go off. Then zone 1 will come on for a few seconds, and go off. Zone 2 comes on, goes off. Zone 3 comes on and starts running. What's that all about??

    I think I've followed the docs well enough here.. am I missing something? Did I do something wrong? I've been at this for several hours and am quite frustrated at this point. :(

    Thank you for any advice.

    It's not possible to modify the sequence number because it is tracked within the Timeline instance only.

    If you want to jump to the next sequence, you have to set the timer to trigger the next sequence. In your case, to get to sequence 3 started right now, the command is
    TIMELINE_SET(tlSprinklers,varTimeArray[3])
    
    Personally I always set my timer some milliseconds before the time of the array.
    TIMELINE_SET(tlSprinklers,varTimeArray[3]-10)
    
Sign In or Register to comment.