1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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

Download Logging2.bas
(2.3 KB , Aug. 26, 2008)