Controller works like crazy when i shut down the system.
espen.sandorf
Posts: 29
This is my first attempt of writing a timeline, and i made it work with som help from this forum. But when i choose shut down the system and the timeline begins. The processor in the controller works like crazy and everything happens really slow, like bringing a up a popup?? This must have somthing to do with the timeline since that is the only new thing in this program.
by the way how do i get the code in a grey area as most people do when posting on the forum??
anyway heres the coding i'm trying.
PROGRAM_NAME='cShutdown'
DEFINE_CONSTANT
TL1 = 1
DEFINE_VARIABLE
LONG lOneSecondTick[] = { 1000 } // second tick
INTEGER nMySecondCount // manually count passes
DEFINE_EVENT
BUTTON_EVENT[dvTP,39] //IF dvTP,39 EXIT IS PUSHED, EXIT PAGE IS SHOWN AND THE COUNTDOWN TIMELINE BEGINS.
{
PUSH:
{
TIMELINE_CREATE(TL1,lOneSecondTick,1,TIMELINE_RELATIVE,TIMELINE_REPEAT)
nMySecondCount = 0
}
}
TIMELINE_EVENT[TL1]
{
IF(TIMELINE.REPETITION = 20) // 20x repeated
{
DO_PUSH(dvTP,210)
PanelPage ('Main2')
TIMELINE_KILL(TL1)
nMySecondCount = 0
}
ELSE
{
SEND_COMMAND dvTP,"'^TXT-300,0,',ITOA(20 - TIMELINE.REPETITION)"
}
}
BUTTON_EVENT[dvTP,40] //CANCEL THE TIMELINE AND RETURN TO MAIN PAGE
{
PUSH:
{
TIMELINE_KILL(TL1)
nMySecondCount = 0
}
}
BUTTON_EVENT[dvTP,210] //OFF BUTTON IS PUSHED BEFORE THE TIMELINE IS DONE. THE SYSTEM IS SHUT DOWN AND THE TIMELINE IS CANCLED.
{
PUSH:
{
TIMELINE_KILL(TL1)
nMySecondCount = 0
PanelPage ('Main2')
}
}
(****************************************************TIDSBESTEMT AUTOSHUTDOWN*********************************************************************************************************************)
(*************************************************************************************************************************************************************************************************)
DEFINE_PROGRAM
IF (TIME = '18:00:00') // TIDSBASERT AUTOSHUTDOWN
{
DO_PUSH(dvTP,39)
PanelPage ('Exit2')
SEND_COMMAND dvTP,"'WAKE'"
}
by the way how do i get the code in a grey area as most people do when posting on the forum??
anyway heres the coding i'm trying.
PROGRAM_NAME='cShutdown'
DEFINE_CONSTANT
TL1 = 1
DEFINE_VARIABLE
LONG lOneSecondTick[] = { 1000 } // second tick
INTEGER nMySecondCount // manually count passes
DEFINE_EVENT
BUTTON_EVENT[dvTP,39] //IF dvTP,39 EXIT IS PUSHED, EXIT PAGE IS SHOWN AND THE COUNTDOWN TIMELINE BEGINS.
{
PUSH:
{
TIMELINE_CREATE(TL1,lOneSecondTick,1,TIMELINE_RELATIVE,TIMELINE_REPEAT)
nMySecondCount = 0
}
}
TIMELINE_EVENT[TL1]
{
IF(TIMELINE.REPETITION = 20) // 20x repeated
{
DO_PUSH(dvTP,210)
PanelPage ('Main2')
TIMELINE_KILL(TL1)
nMySecondCount = 0
}
ELSE
{
SEND_COMMAND dvTP,"'^TXT-300,0,',ITOA(20 - TIMELINE.REPETITION)"
}
}
BUTTON_EVENT[dvTP,40] //CANCEL THE TIMELINE AND RETURN TO MAIN PAGE
{
PUSH:
{
TIMELINE_KILL(TL1)
nMySecondCount = 0
}
}
BUTTON_EVENT[dvTP,210] //OFF BUTTON IS PUSHED BEFORE THE TIMELINE IS DONE. THE SYSTEM IS SHUT DOWN AND THE TIMELINE IS CANCLED.
{
PUSH:
{
TIMELINE_KILL(TL1)
nMySecondCount = 0
PanelPage ('Main2')
}
}
(****************************************************TIDSBESTEMT AUTOSHUTDOWN*********************************************************************************************************************)
(*************************************************************************************************************************************************************************************************)
DEFINE_PROGRAM
IF (TIME = '18:00:00') // TIDSBASERT AUTOSHUTDOWN
{
DO_PUSH(dvTP,39)
PanelPage ('Exit2')
SEND_COMMAND dvTP,"'WAKE'"
}
0
Comments
see:http://www.amxforums.com/misc.php?do=bbcode
There are probably some oddities in the code that aren't right, but I don't think they are serious as far as basic functionality. For example, in your timeline_event you kill the timeline and display page 'Main2'. You also do_push button 210 which also kills the timeline and displays the same page. I suggest that there is a redundancy.
So, the good news is that you appear to have a working timeline that is doing mostly what you want.
The bad news is that if your programming is causing you angst, you probably need to look elsewhere.
There really may be some dependencies with the rest of the code. Some general hints:
- If an Event is coming, the execution of the DEFINE_PROGRAM will be breaked. So if the DEFINE_PROGRAM is pretty large, it may not be executed completely.
- in general with the check IF(TIME='18:00:00'), it may be happen that in this one second the IF is executed several 100 times, because a NI may run several hundred loops in a second thru DEFINE_PROGRAM, and so the instructions of the IF will be stacked.
I'we made the changes so i dont kill the timeline several times.
And the IF(TIME='18:00:00'), was the one that crashed the system. But what is the proper way to get something to happend at 18.00?? I have a customer that needs a autoshutdown in over 100 rooms at that time. Good thing i havent uploaded that code yet =P
IF (TIMELINE_ACTIVE(TL1))
{
TIMELINE_KILL(TL1)
}
This would avoid an error if the timeline was not active and you could use the statement anywhere, as many times as you would like.
Not that this is causing the problem, but programmatically, you could do this to avoid the conflict.
IF (TIME=18:00:00 AND !nFlag)
{
LOCAL_VAR INTEGER _ON = 1
fnInitiateShutDown() //trigger the function
nFlag = _ON
}
IF (TIME=18:00:01 AND nFlag)
{
LOCAL_VAR INTEGER _OFF = 0
nFlag = _OFF
}
This should work for you.
Chris
There are other ways to accomplish this, but I think this will do what you want.
Jeff
Jeff
When i write a DO-Push dvTp, 210 it will execute this set of codes.
You could enclose the conditional in a wait statement and see if that helps:
Jeff
but what happens now if the controller misses the exact 18:00:00 time? Could i maybe make it check for 18.00.?? to make it look for that whole minute?
Jeff