This sample Netlinx program is an example of automating the reboot of the master. It contains the following variables:
TIME_TO_REBOOT to hold the time of day for the reboot to happen. Default is 11:59pm
DAY_TO_REBOOT to hold what day of the week to reboot on. 1 = Sun .. 7 = Sat, 0 = daily and is the default.
PROGRAM_NAME='NX Reboot Example'
(***********************************************************)
(* DEVICE NUMBER DEFINITIONS GO BELOW *)
(***********************************************************)
DEFINE_DEVICE
dvMaster = 0:1:0
(***********************************************************)
(* CONSTANT DEFINITIONS GO BELOW *)
(***********************************************************)
DEFINE_CONSTANT
TL_Reboot = 1
(***********************************************************)
(* VARIABLE DEFINITIONS GO BELOW *)
(***********************************************************)
DEFINE_VARIABLE
LONG TL_Reboot_times[1] = {500} // check for reboot every 1/2 second
CHAR TIME_TO_REBOOT[8] = '23:59:00' // 11:59pm
SINTEGER DAY_TO_REBOOT = 0 // 0 everyday, 1-7 Sunday - Saturday
(***********************************************************)
(* STARTUP CODE GOES BELOW *)
(***********************************************************)
DEFINE_START
TIMELINE_CREATE(TL_Reboot,TL_Reboot_times,1,TIMELINE_ABSOLUTE,TIMELINE_REPEAT)
(***********************************************************)
(* THE EVENTS GOES BELOW *)
(***********************************************************)
DEFINE_EVENT
TIMELINE_EVENT[TL_Reboot]
{
IF((DAY_OF_WEEK(DATE) = DAY_TO_REBOOT) or ( DAY_TO_REBOOT = 0))
{
IF(time = time_to_reboot)
{
send_command dvMaster,"'REBOOT'"
}
}
}
(***********************************************************)
(* THE ACTUAL PROGRAM GOES BELOW *)
(***********************************************************)
DEFINE_PROGRAM
(***********************************************************)
(* END OF PROGRAM *)
(* DO NOT PUT ANY CODE BELOW THIS COMMENT *)
(***********************************************************)