Home AMX User Forum AMX General Discussion

Create Timeline within a Timeline?

My first post here so please excuse me if I have trouble describing my issue!
I have a piece of code which runs a timer for 5 mins to show on a TP. I am using a repeating timeline for this with events dependant on the value of timeline.repetition. At the first event a timer appears and a second timeline is triggered to send IR commands to a DVD recorder for finalising a disc. The timer displays for the 5 minutes and then disappears. This is all working OK except that the second timeline only runs once, despite being set as a repeating timeline.
Is there any limitation regarding creating a repeating timeline within a timeline event?

Thanks for your help

Comments

  • Jimweir192Jimweir192 Posts: 502
    Can you post your code?

    There is no reason I am aware of that stops you do what you wish within a timeline_event.
  • Ed CorinEd Corin Posts: 8
    Here's the function that initiates the original timeline and the subsequent timeline events. I think everything is there to allow it to make sense.

    define_variable
    integer finalise_ir_list[]	= {21,23,23,21,21,21,21,24,21}
    long tl_Finalise_ir_time[]  	= { 2000 }
    integer finalise_ir_cmd
    
    define_function fnFinalise()
        {
        
        tlFinalise.nRunsFor = 3000		
    	
        //set times for when the events are going to occur
        tlFinalise.nEvent1				= 3000		
        tlFinalise.nEvent2				= 1		
    	
        tlFinalise.nCountdownTimer = tlFinalise.nRunsFor + 1    /
        timeline_create(tl_Finalise, tlconst_cntdwn_time, length_array(tlconst_cntdwn_time), timeline_absolute, timeline_repeat)
        }
    
    timeline_event[tl_Finalise]
        {
        slong slResult
        char sTimeRemaining[8]
        
        tlFinalise.nReps = timeline.repetition
        tlFinalise.nTime = timeline.time
        
        if(timeline.repetition == tlFinalise.nRunsFor)
    	{
    	timeline_kill(tl_Finalise)  //kill the timeline
    	}
        else
    	{
    	
    	if(tlFinalise.nCountdownTimer > 0)
    	    {
    	    tlFinalise.nCountdownTimer--
    	    }
        
    	//this code provides a level on the panel to show progress...
    	slResult = fn_ScaleRange(tlFinalise.nCountdownTimer, 0, tlFinalise.nRunsFor, 3000, 0)
    	send_level dvCV7,15,slResult
    	
    	//nEvent1
    	if(tlFinalise.nEvent1)  
    	    {
    	    if(tlFinalise.nCountdownTimer == tlFinalise.nEvent1)
    		{
    		send_command vdvCV7,"'@PPN-Finalise Timer'"
    		
    		finalise_ir_cmd = 0
    		timeline_create(tl_Finalise_ir,tl_finalise_ir_time,length_array(tl_finalise_ir_time),timeline_absolute,timeline_repeat)
    		}
    	    }
    		    
    	//nEvent2
    	if(tlFinalise.nEvent2)  
    	    {
    	    if(tlFinalise.nCountdownTimer == tlFinalise.nEvent2)
    		{
    		send_command vdvCV7,"'@PPF-Finalise Timer'"
    		send_command devFinalisingDVR,"'SP',eject"
    		}
    	    }
    	}
        }
    
    timeline_event[tl_Finalise_ir]
        {
        tlFinalise_ir.nReps = timeline.repetition
        tlFinalise_ir.nTime = timeline.time
        if(tlFinalise_ir.nReps < max_length_array (finalise_ir_list))
    	{
    	finalise_ir_cmd ++
    	send_command devFinalisingDVR,"'SP',finalise_ir_list[finalise_ir_cmd]"
    	}
        else 
    	{
    	//timeline_kill (tl_finalise_ir)
    	}
        }
    
  • Jimweir192Jimweir192 Posts: 502
    Sorry only got a minute to look at the code, but I suspect the
    else 
    	{
    	//timeline_kill (tl_finalise_ir)
    	}
    
    under your tl_Finalise_ir event is being processed when your Max_Length_array is checked.

    Put some debug / send_string 0 messages in there and you'll be able to see where the code is taking you...

    will look again later if I get a sec.
  • Jimweir192Jimweir192 Posts: 502
    your finalise_ir_list[] is returning 0 when checked as when you initialised it you are not defining a length

    either
    define_variable
    integer finalise_ir_list[9]	= {21,23,23,21,21,21,21,24,21}
    

    or Set_Length_Array elsewhere in your code

    hth
  • Ed CorinEd Corin Posts: 8
    Thanks for your help. I'll give that a try
  • Ed CorinEd Corin Posts: 8
    OK. It turned out that in the define_constant section if I changed the timeline number to 5 instead of 4 then it worked OK. I guess there must be something somewhere in my code that caused it but I'm beaten as to where.
  • Before you changed the number, did you have 2 timeline ids that were the same? If so, that was the cause of the problem. When the finalise timeline hit the point where it was at it's run for length, it terminated itself. If the second timeline had the same ID as the first, it would terminate at that point as well, probably after running once.
  • Ed CorinEd Corin Posts: 8
    No, Timeline ID's were all unique.
Sign In or Register to comment.