Home AMX User Forum NetLinx Studio

Need some help and ideas

I was told that I need to develop something that will do the following:

1.> If a clients system is inactive for 24 hours. It will need to turn off all the audio zones, and turn off all the source equipment.

2.> If any push from any device is recieved it will reset the timer.

3.> The code needs to be independent ( module maybe ) so we can add it to other programs we have done in the past.


I am thinking that the easiest way would be to create a timeline event but I haven't ever done this before, so I am looking for suggestions.

Thanks

Chris Ondrovic

Comments

  • dthorsondthorson Posts: 103
    A re-triggering timeline would work great.

    If you have your system off in a sub routine it would be minimal amount of code, a module would be overkill.
  • Joe HebertJoe Hebert Posts: 2,159
    This should get you headed in the right direction.
    DEFINE_DEVICE
    
    dvTP1	= 10001:1:0
    dvTP2	= 10002:1:0
    
    DEFINE_CONSTANT
    
    nResetTL	= 1 //reset timeline id
    
    DEFINE_VARIABLE
    
    DEV	dvTPs[]	= {dvTP1,dvTP2} //array of all the TPs
    
    LONG	lResetT[] = {86400000}	//24 hours in milliseconds
    
    DEFINE_FUNCTION fnSystemOff () {
       //do whatever
    }
    
    DEFINE_FUNCTION fnResetTimer () {
    
       //kill the timeline if it is active
       IF(TIMELINE_ACTIVE(nResetTL)) TIMELINE_KILL(nResetTL)
       //and then create a fresh one
       TIMELINE_CREATE (nResetTL,lResetT,1,TIMELINE_ABSOLUTE,TIMELINE_ONCE)
    }
    
    DEFINE_EVENT
    
    //trap all button events for all TPs
    BUTTON_EVENT[dvTPs,0] {
    
       PUSH: {
          //if any button is pushed reset the timer
          fnResetTimer()
       }
    }
    
    TIMELINE_EVENT[nResetTL] {
    
       //time is up - let's turn everything off
       fnSystemOff()
    
    }
    
  • ondrovicondrovic Posts: 217
    Thanks guys I will give it a try and see where this takes me. :)
  • ondrovicondrovic Posts: 217
    Joe,

    Thanks it does exactly what I was looking for. I have one more question. Is there a way to get a realtime update of the amount of time that is left in the timeline? If there is whats the best way to do that?

    Thanks again
  • jweatherjweather Posts: 320
    LONG TIMELINE_GET (LONG Id)

    ie,
    TimeLeft = TIMELINE_GET(nResetTL)

    returns the number of milliseconds elapsed since the start of the timer. Make sure you know about Help/NetLinx Keywords in Studio -- it's very helpful as a quick reference. Just searching the index for "timeline" yields a lot of useful info.

    Jeremy
Sign In or Register to comment.