CR1000 HTML coding of cellphone connectivity_Campbellsci论坛问答

Hi,

New to the forum but have been lurking for a while. I am interested in optimizing the default html interface for my PPP configured CR1000s so that data can be viewed easily with a cell phone. In addition, I would like to be able to trigger flags and set variables via cell phone. Does anyone have any experience with html coding that can do that?

CR1000 HTML coding of cellphone connectivity_Campbellsci论坛问答

On another note... When is someone going to make an APP (iPhone that is) for that? :)

-Dylan

新对话如下:

Hello Dylan,

Look at the WebPageBegin/WebPageEnd instructions (and HTTPOut) in the help file. You can use the SetValue command to set any variable in a program. I would caution, however, that HTML coding in CRBasic isn't for the faint of heart. The use of quotes to enclose strings and character codes to represent quotes becomes quite mind-racking after a while :)

Below is some code that I adapted for a demo I was doing. Essentially, this creates an HTML page that has an input box, and depending upon the value entered, one of several images is displayed. The code that parses the input string was written by someone else around here -- I adapted it for my use. And now for the caveats & disclaimers :) I am probably not the most efficient HTML hand-coder you have met -- there are likely better ways to accomplish what I have done. But, last time I ran the program (maybe a year ago?) it worked.

Oh, regarding an app for your iPhone -- would a LoggerNet client that runs in any browser meet your needs? That is, LoggerNet server running on a Windows or Linux box somewhere, with browser-based clients (Numeric Display, Status monitor, etc) to display the data?

Good luck with the HTML, Dana W.

'Control web page
Dim value_begin_pos, value_end_pos, set_value
Public Flag_value, image As String, flagtext As String

WebPageBegin("control.html",commands)
If InStr(1,commands,"command=SetValue",2) > 0 Then
value_begin_pos = InStr(1,commands,"value=",2)
value_end_pos = InStr(value_begin_pos,commands,"&",2)
If value_end_pos = 0 Then value_end_pos = Len(commands)
If value_begin_pos >= 1 Then
set_value = Mid(commands,value_begin_pos + 6,value_end_pos - value_begin_pos - 5)
Flag_value = set_value
EndIf
EndIf

If Flag_value > 6 Then Flag_Value = 0
If Flag_value=0 Then
image = "/CPU/jr.gif"
flagtext = "Pirate"
EndIf
If Flag_value=1 Then
image = "/CPU/au.gif"
flagtext = "Australian"
EndIf
If Flag_value=2 Then
image = "/CPU/br.gif"
Flagtext="Brazilian"
EndIf
If Flag_value=3 Then
image = "/CPU/ca.gif"
Flagtext="Canadian"
EndIf
If Flag_value=4 Then
image = "/CPU/uk.gif"
Flagtext="British"
EndIf
If Flag_value=5 Then
image = "/CPU/us.gif"
Flagtext="American"
EndIf
If Flag_value=6 Then
image = "/CPU/sa.gif"
Flagtext="South African"
EndIf

HTTPOut("<!DOCTYPE html Public" + CHR(34) + "-//W3C//DTD XHTML 1.0 Transitional//EN" + CHR(34) + + CHR(34) +"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" + CHR(34) + "><html xmlns=" + CHR(34) + "http://www.w3.org/1999/xhtml" + CHR(34) + ">")
HTTPOut("<head>")
HTTPOut("<meta http-equiv=" + CHR(34) + "Content-Language" + CHR(34) + "content=" + CHR(34) + "en-us" + CHR(34) + "/>")
HTTPOut("<meta http-equiv=" + CHR(34) + "Content-Type" + CHR(34) + "content=" + CHR(34) + "text/html; charset=utf-8" + CHR(34) + "/>")
HTTPOut("<meta http-equiv=" + CHR(34) + "refresh" + CHR(34) + "content=" + CHR(34) + "300" + CHR(34)+ ">")
HTTPOut("<title>Control CR1000 Datalogger</title>")
HTTPOut("<style type=" + CHR(34) + "text/css" + CHR(34) + ">")
HTTPOut(".Heading1 {")
HTTPOut(" color: #0000FF;")
HTTPOut(" font-family: "+ CHR(34) + "Arial Black" + CHR(34) +";")
HTTPOut(" font-size: x-large;")
HTTPOut("}")
HTTPOut(".BodyStyle {")
HTTPOut(" font-size: large;")
HTTPOut(" color: #808080;")
HTTPOut(" margin-left: 36px;")
HTTPOut("}"
HTTPOut(".style1 {")
HTTPOut(" border-width: 0px;")
HTTPOut("}")
HTTPOut(".Heading2 {")
HTTPOut(" color: #CC0033;")
HTTPOut(" font-family: "+ CHR(34) + "Arial Black" + CHR(34) +";")
HTTPOut(" font-size: large;")
HTTPOut("}")
HTTPOut("</style>")
HTTPOut("</head>")
HTTPOut("<BODY>")
HTTPOut("<p class="+ CHR(34) +"Heading1"+ CHR(34) +">    CR1000 Datalogger Control</p>")
HTTPOut("<form><p>" + CHR(13))
HTTPOut("<input type='hidden' name='command' value='SetValue'>" + CHR(13))
HTTPOut("<input type='hidden' name='table' value='public'>" + CHR(13))
HTTPOut("<input type='hidden' name='field' value='Flag_value'>" + CHR(13))
HTTPOut("<p class="+ CHR(34) +"BodyStyle"+ CHR(34) +">Flag to Set high: <input type='text' name='value' value='" + Flag_value + "'>" + CHR(13))
HTTPOut("<input type='submit' value='Set'>" + CHR(13))
HTTPOut("</form>" + CHR(13))
HTTPOut("<p class="+ CHR(34) +"BodyStyle"+ CHR(34) +">Valid Flags are 1 through 6</a></p>")
HTTPOut("<br>")
HTTPOut("<p>")
HTTPOut("         <img alt="+ CHR(34)+"Fly the " + FlagText + " Flag" + CHR(34) + "src="+ CHR(34) + image + CHR(34) + "width="+ CHR(34) +"135"+ CHR(34) + "height="+ CHR(34) +"68" + CHR(34) + "/></p>")
HTTPOut("<p class="+ CHR(34) +"Heading2"+ CHR(34) +">      Flying the " + FlagText +" Flag</a></p>")
HTTPOut("<BR>")
HTTPOut("<p class="+ CHR(34) +"BodyStyle"+ CHR(34) +"><a href="+ CHR(34) +"default.html"+ CHR(34)+ "style="+ CHR(34) + "color: #808080"+ CHR(34) +">Back to the Home Page</a></p>")
HTTPOut("</body></html>" + CHR(13))
WebPageEnd

新对话如下:

Thanks Dana,

I will definitely use pieces of this setvalue code. Does anyone have any experience optimizing their CR1000 HTML code for cellphone display? The default html interface is fine on my iPhone because I can easily zoom, but other cellphones need a more compatible display. It seems to me like a very powerful and useful interface to have since we are always with our cellphones but not always with our computers... this, of course, will change as our computers and cell phones seem to be becoming one and the same.

-Dylan

新对话如下:

Dylan,
I once used RTMCPro to generate small data screens for a blackberry. Screen was generated from weather station data and the RTMC image was FTP'd to a website. Used the browser in the blackberry to view the data.
Was certainly easier than HTML coding in the logger.
Good Luck,
IslandMan

分享到:

原文链接:,转发请注明来源!
海洋仪器网 仪器使用 CR1000 HTML coding of cellphone connectivity_Campbellsci论坛问答
「CR1000 HTML coding of cellphone connectivity_Campbellsci论坛问答」评论列表

发表评论