Specifications
Section 11. Programming Resource Library
11-16
Links will also be created automatically for any HTML, XML, and JPEG files
found on the datalogger in the CPU:, USR:, and CRD: drives. To copy files to
these drives, choose File Control from the Tools menu found in PC400 or in
the Connect screen of LoggerNet.
Although the default home page cannot be accessed by the user for editing, it
can be replaced with HTML code to customize the look of the home page. To
replace the default home page, save the new home page under the name
default.html and copy it to the datalogger. It can be copied to the CPU:, USR:,
or CRD: drive with File Control. Deleting default.html from the datalogger
will cause the CR1000 to use its original default home page.
The CR1000 can be programmed to generate HTML or XML code that can be
viewed by the web browser. EXAMPLE 11.2-1 shows how to use the
CRBASIC k
eywords WebPageBegin/WebPageEnd and HTTPOut to create
HTML code. Note that for HTML code requiring the use of quote marks,
CHR(32) is used, while regular quote marks are used to define the beginning
and end of alphanumeric strings inside the parentheses of the HTTPOut
instruction. For additional information, see the CRBasic editor Help.
EXAMPLE 11.2-1. CRBASIC Code. HTML
'CR1000 Series Datalogger
Dim Commands As String * 200
Public Time(9), RefTemp,
Public Minutes As String, Seconds As String, Temperature As String
DataTable (CR1Temp,True,-1)
DataInterval (0,1,Min,10)
Sample (1,RefTemp,FP2)
Average (1,RefTemp,FP2,False)
EndTable
'Default HTML Page
WebPageBegin ("default.html",Commands)
HTTPOut("<html>")
HTTPOut ("<style>body {background-color: oldlace}</style>")
HTTPOut ("<body><title>Campbell Scientific CR1000 Datalogger</title>")
HTTPOut ("<h2>Welcome To the Campbell Scientific CR1000 Web Site!</h2>")
HTTPOut ("<tr><td style="+ CHR(34) +"width: 290px"+ CHR(34) +">")
HTTPOut ("<a href="+ CHR(34) +"http://www.campbellsci.com"+ CHR(34) +">")
HTTPOut("<img src="+ CHR(34) +"/CPU/SHIELDWEB2.jpg"+ CHR(34) + "width="+ CHR(34) +"128"+CHR(34)+"height="+
CHR(34)+"155"+ CHR(34) + "class="+ CHR(34) +"style1"+ CHR(34) + "/></a></td>")
HTTPOut ("<p><h2> Current Data:</h2></p>")
HTTPOut ("<p>Time: " + time(4) + ":" + minutes + ":" + seconds + "</p>")
HTTPOut ("<p>Temperature: " + Temperature + "</p>")
HTTPOut ("<p><h2> Links:</h2></p>")
HTTPOut ("<p><a href="+ CHR(34) +"monitor.html"+ CHR(34)+">Monitor</a></p>")
HTTPOut ("</body>")
HTTPOut ("</html>")
WebPageEnd
'Monitor Web Page
WebPageBegin("monitor.html",Commands)
HTTPOut("<html>")
HTTPOut ("<style>body {background-color: oldlace}</style>")
HTTPOut("<body>")
HTTPOut("<title>Monitor CR1000 Datalogger Tables</title>")
HTTPOut("<p><h2>CR1000 Data Table Links</h2></p>")
HTTPOut("<p><a href="+ CHR(34) + "command=TableDisplay&table=CR1Temp&records=10"+ CHR(34)+">Display Last 10
Records from DataTable CR1Temp</a></p>")
HTTPOut("<p><a href="+ CHR(34) + "command=NewestRecord&table=CR1Temp"+ CHR(34) + ">Current Record from
CR1Temp Table</a></p>")