beautypg.com

7 conditional compilation, Figure 60: custom menu example — home screen, Figure 61: custom menu example — view-data window – Campbell Scientific CR800 and CR850 Measurement and Control Systems User Manual

Page 199

background image

Section 7. Installation

199

 

'Measure Two Thermocouples

TCDiff

(TCTemp(),2,mV2500C,1,TypeT,RefTemp,True,0,250,1.0,0)

CallTable

TempC

'Call data table

'Menu Item "Make Notes" Support Code

If

CycleNotes = "Accept"

Then

CallTable

Notes

'Write data to Notes data table

CycleNotes = "Accepted"

'Write "Accepted" after written

Delay

(1,500,mSec)

'Pause so user can read "Accepted"

SelectNote = ""

'Clear pick list note

EnterNote = ""

'Clear free entry note

CycleNotes = "??????"

'Write ????? as a null prompt

EndIf

If

CycleNotes = "Clear"

Then

'Clear notes when requested

SelectNote = ""

'Clear pick list note

EnterNote = ""

'Clear free entry note

CycleNotes = "??????"

'Write ????? as a null prompt

EndIf

'Menu Item "Control" Menu Support Code

CountDown = CountDown - 1

'Count down by 1

If

CountDown <= 0

'Stop count down from passing 0

CountDown = 0

EndIf

If

CountDown > 0

Then

StartFlag = True

'Indicate countdown started

EndIf

If

StartFlag = True

AND

CountDown = 0

Then

'Interprocess count down

'and manual LED

ToggleLED = True
StartFlag = False

EndIf

If

StartFlag = True

AND

CountDown <> 0

Then

'Interprocess count down and manual LED

ToggleLED = False

EndIf

PortSet

(4,ToggleLED)

'Set control port according

'to result of processing

NextScan

EndProg

 

7.8.7 Conditional Compilation

When a CRBasic user program is sent to the CR800, an exact copy of the program
is saved as a file on the CPU: drive

(p. 316).

A binary version of the program, the

"operating program", is created by the CR800 compiler and written to Operating
Memory

(p. 317).

This is the program version that runs the CR800.

CRBasic allows definition of # conditional code in the user program that the
CR800 compiler includes, depending on the conditional settings, in the operating
program. This means the user-written program is evaluated for conditional
statements and an operating program that includes only the requested statements
is written to operating memory. In addition, all CRBasic dataloggers accept
program files or Include() instruction files with .DLD extensions. This gets
around the system filters that look at file extensions for specific loggers; it makes
possible the writing of a single file of code to run on multiple CRBasic
dataloggers.