rem Logging2.bas rem rem last revision on 2005 November 21 rem rem start/stop data logging: F1_BUTTON rem force log entry: F2_BUTTON rem reset logging: press F1 + F2 on reset rem change from Logging.bas: rem - do not use CODE8 reset mode since it cannot be invoked rem from the macro - reset read/write pointers directly instead CONST LOG_TIMEOUT = 100 // log every 10 secs ////////////////////////////////////////////////////////////////////// Customer_ID_Macro: ////////////////////////////////////////////////////////////////////// write " Logging 2 " END ////////////////////////////////////////////////////////////////////// Reset_Macro: ////////////////////////////////////////////////////////////////////// CONST LOG_OFF = 0 CONST LOG_ON = 1 #log_mode = LOG_OFF CONST LOG_OFF_MODE = 0000 CONST LOG_ON_MODE = 0150 CONST LOG_RESET_MODE = 0300 // can NOT be used from a macro ! &CODE8 = LOG_OFF_MODE // set registers to log &LOG_REG1 = addr(&DISPLAY) &LOG_REG2 = addr(&TOTAL1) &TIMER1 = 0 #temp = 0 // reset log memory if |F1_BUTTON = on AND |F2_BUTTON = on then gosub reset_logging endif END ////////////////////////////// reset_logging: ////////////////////////////// &LOG_READ_POINTER = 0 &LOG_WRITE_POINTER = 0 write "" write "reset" return ////////////////////////////////////////////////////////////////////// F1_Button_Macro: ////////////////////////////////////////////////////////////////////// write "" if #log_mode = LOG_OFF then #log_mode = LOG_ON &CODE8 = LOG_ON_MODE write "start" else #log_mode = LOG_OFF &CODE8 = LOG_OFF_MODE write "stop" endif END ////////////////////////////////////////////////////////////////////// F2_Button_Macro: ////////////////////////////////////////////////////////////////////// if #log_mode = LOG_ON then FORCE_LOG write "" write "force" endif END ////////////////////////////////////////////////////////////////////// Main_Macro: ////////////////////////////////////////////////////////////////////// // do some calculations within the macro and include result in log &TOTAL1 = &CH1 ^ 2 + SQR(&CH2) / &CH2 + 123 if #log_mode = LOG_OFF then &TIMER1 = 0 elsif &TIMER1 >= LOG_TIMEOUT then FORCE_LOG &TIMER1 = 0 endif END