IncludeSection
IncludeSection() can be used to organize program components, such as constants, variables, subroutines, functions and more, into reusable libraries. This approach is commonly used for systems with many components and measurements that require large programs. Using IncludeSection() can significantly shorten the main program for easier reading and maintenance and allows code to be easily shared among data loggers.
Syntax
IncludeSection( "SectionName","Device:Filename" )
Following is an example of using two IncludeSection() instructions to specify two sections of program code named Constants and Variables. These sections of code are located in an Include file named File_Lib.crb.
Main Program
ConstTable(Const_Table)
IncludeSection("Constants", "CPU:File_Lib.crb")
EndConstTable
IncludeSection("Variables", "CPU:File_Lib.crb")
DataTable (Test,1,-1)
DataInterval (0,15,Sec,10)
Minimum (1,BaseVolts,FP2,False,False)
Sample (1,BaseTemp,FP2)
EndTable
BeginProg
Scan (1,Sec,0,0)
PanelTemp (BaseTemp,15000)
Battery (BaseVolts)
' add additional measurements and instructions
CallTable Test
NextScan
EndProg
File_Lib.crb
#If Section = "Constants" Then
Const ExampleConst = 100
Const Stat01_COMMS = True
Const Stat02_COMMS = True
Const Stat03_COMMS = True
Const Stat04_COMMS = True
Const Stat05_COMMS = True
Const Stat06_COMMS = True
Const Stat07_COMMS = true
Const Stat08_COMMS = true
Const Stat09_COMMS = True
Const Stat10_COMMS = True
Const Stat11_COMMS = True
#EndIf
#If Section = "Variables" Then
Public BaseTemp
Public BaseVolts
Public VWData(12,42)
Alias VWData(1,1) = Batt_Volt01
Alias VWData(1,2) = CPU_Temp01
Alias VWData(1,3) = S01_Freq
Alias VWData(1,4) = S01_Amp
Alias VWData(1,5) = S01_SigNoisR
Alias VWData(1,6) = S01_NoisFreq
Alias VWData(1,7) = S01_DecayRat
Alias VWData(1,8) = S01_Therm
Alias VWData(1,9) = S01_Temp
Alias VWData(1,10)= S01_Digits
Alias VWData(1,11)= S01_EngOu
Alias VWData(1,40) = DigitsBL01_Chan1
Alias VWData(1,41) = TempBL01_Chan1
Alias VWData(1,42) = PressBL01_Chan1
#EndIf
Remarks
The key idea behind IncludeSection() is that it inserts external code directly at the location of the IncludeSection() statement in the main program. The included sections can contain constants, variables, functions, subroutines, data tables, and more. Using IncludeSection() makes it easier to navigate to the main scan of the program and streamlines maintenance and code sharing across data loggers.
NOTE: Beginning with OS
Parameters
"SectionName"
The name of the section of code to be included in the main program. The name must be enclosed in quotation marks.
"Device:FileName"
Used to specify the file that contains the sections of code that should be executed. The Device on which the file is stored must be specified and the entire string must be enclosed in quotation marks. Device is CPU
The USR device is an area of memory that can be set up by the user by assigning a value to the datalogger UsrDriveSize setting in the Status table. This drive must be set to at least 8192 bytes, in 512-byte increments (if the value entered is not a multiple of 512 bytes, the size will be rounded up).
The Include filename can also be an expression, such as "CPU:" + StationNameSetting + ".cr6", where StationNameSetting inserts the station name of the datalogger.
Type: Variable
