Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Tue Jun 19, 2018 7:08 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: My first project
PostPosted: Tue Dec 04, 2012 4:28 am 
Offline

Joined: Tue Dec 04, 2012 3:34 am
Posts: 3
Hi, I am completely new to RS.
My programming project is to make a temperature monitor doing the following steps.
1. Read data from a web server with temperature readings
2. Parse the text data and extract the temperature data
3. Analyse the temperatures, if the temperature drops below or rises above a certain threshold, make an alarm by sending an email
Sound easy, but I already met the wall. I have investigated the sample files and the documentation but are not able to figure out how to get the data from the webpage into a variable.
Can someone help me?
Karl


Top
 Profile  
Reply with quote  
 Post subject: Re: My first project
PostPosted: Tue Dec 04, 2012 5:45 am 
Offline

Joined: Fri Feb 12, 2010 1:32 pm
Posts: 228
Location: Switzerland
mrxyz wrote:
Sound easy, but I already met the wall. I have investigated the sample files and the documentation but are not able to figure out how to get the data from the webpage into a variable.


Welcome to Realstudio :)

Look at the language reference: http://docs.realsoftware.com/index.php/HTTPSocket

There's an example down the page:

Dim socket1 As New HTTPSocket
Dim data As String = socket1.Get("http://www.realsoftware.com/", 30)


Top
 Profile  
Reply with quote  
 Post subject: Re: My first project
PostPosted: Tue Dec 04, 2012 8:39 am 
Offline
User avatar

Joined: Sun Oct 28, 2012 4:54 am
Posts: 264
Location: Herts, UK
:)

I am a complete beginner too but learning slowly

Try this quick example I am sure that there is a much better way but maybe is enough to get you started hopefully.

Just drag a TextArea + Label + Pushbutton onto a new form and add the following code behind the pushbutton Action event.


Dim myTextFileContents As String
Dim http As New HTTPSocket

http.Yield = True
myTextFileContents = http.Get("http://justgoodit.web44.net/TempSensor.html", 10)

TextArea1.text = myTextFileContents

Dim rg as New RegEx
Dim myMatch as RegExMatch
rg.SearchPattern="sensor2..."
myMatch=rg.search(TextArea1.text)

if myMatch <> Nil then
Label1.text=myMatch.SubExpressionString(0)

Dim s as string = Label1.text
s = right(s, Len(s)-8)

If s <= "50" then
MsgBox("temp below 50 send email alert")

//Send email code
//http://docs.realsoftware.com/index.php/SMTPSocket

else
Msgbox("temp normal do nothing")
end

end if

_________________
Real Studio 2012 R2
SysInfo
BackTrack Linux/BackBox Linux/Debian Lenny/Windows 7/Windows 8/OpenWRT/OpenBSD
& Yes it's me in the Avatar


Top
 Profile  
Reply with quote  
 Post subject: Re: My first project
PostPosted: Wed Dec 05, 2012 3:58 am 
Offline

Joined: Tue Dec 04, 2012 3:34 am
Posts: 3
Thank you for your advice.
Your suggestion should work in most cases, my temperature server work differently.
My specific temp. server has the following static IP-address "129.177.222.33"
This work : HTMLViewer.LoadURL "http://129.177.222.33/"
but getting the content using a HTTPsocket do not work, and I don't understand why.
The "HTTP Example" which is part of the RS sample files, is extracting the text data from the webpage,
but I haven't figured out how it works :(
All help is appreciated. K.


Top
 Profile  
Reply with quote  
 Post subject: Re: My first project
PostPosted: Wed Dec 05, 2012 5:44 am 
Offline
User avatar

Joined: Sun Oct 28, 2012 4:54 am
Posts: 264
Location: Herts, UK
:D

I just noticed that Sensatronics devices support SNMP protocol

http://support.sensatronics.com/index.php?_m=knowledgebase&_a=viewarticle&kbarticleid=35&nav=0,3,23

It may be easier to develop an RB app as an SNMP server to capture temparature events

http://pbsw-code.net/code/realbasic/classes/pbsw-SNMP/documentation/index.html

ActiveXperts Software even has an off the shelf ready product that supports the sentronic devices so why would you want
to develop something anyhow.?

http://www.activexperts.com/activmonitor/environmental/cm/

_________________
Real Studio 2012 R2
SysInfo
BackTrack Linux/BackBox Linux/Debian Lenny/Windows 7/Windows 8/OpenWRT/OpenBSD
& Yes it's me in the Avatar


Top
 Profile  
Reply with quote  
 Post subject: Re: My first project
PostPosted: Thu Dec 06, 2012 4:32 am 
Offline

Joined: Tue Dec 04, 2012 3:34 am
Posts: 3
Just to answer p0wn3d

We have invested a fair amount into temperature monitors and sensors over the years.
The monitors has now been discontinued and they are not longer supported by companies like ActiveXperts.
We have the ActiveXperts Software, an earlier version (v.6) have been working well for many years on Win XP,
but when the Temp Servers broke down and replaced by new computers running windows 7 we got problems.
The newest ActiveXperts Software v.7.4 works well in Win 7 but don't support our temp monitors, the older v.6 is unstable on win7.
So I have to investigate other solutions.

Regarding SNMP I dont have a clue what that is :(

Karl


Top
 Profile  
Reply with quote  
 Post subject: Re: My first project
PostPosted: Thu Dec 06, 2012 5:02 am 
Offline
User avatar

Joined: Tue Jan 04, 2011 3:02 am
Posts: 1236
Location: Jönköping, Sweden
mrxyz wrote:
Thank you for your advice.
Your suggestion should work in most cases, my temperature server work differently.
My specific temp. server has the following static IP-address "129.177.222.33"
This work : HTMLViewer.LoadURL "http://129.177.222.33/"
but getting the content using a HTTPsocket do not work, and I don't understand why.
The "HTTP Example" which is part of the RS sample files, is extracting the text data from the webpage,
but I haven't figured out how it works :(
All help is appreciated. K.


You could use the HTTPSocket to receive the Page Source and then simply parse it and get the content you're after.
Let me know if you need help with that and what content you need to 'extract' :)

_________________
Image http://www.linkedin.com/in/albinkiland
Dev. iMac 27" + 2x22" LG (2.8GHz Intel Core i7, 12GB RAM, 120GB SSD) OS X 10.8
Xojo Pro 2013r1


Top
 Profile  
Reply with quote  
 Post subject: Re: My first project
PostPosted: Thu Dec 06, 2012 11:07 am 
Offline
User avatar

Joined: Sun Oct 28, 2012 4:54 am
Posts: 264
Location: Herts, UK
:shock:

You could just access the raw XML data via HTTP would be less effort I would think

http://129.177.222.33/xmldata

http://www.sensatronics.com/downloads/programmers_guides/programmers_guide_em1.html

_________________
Real Studio 2012 R2
SysInfo
BackTrack Linux/BackBox Linux/Debian Lenny/Windows 7/Windows 8/OpenWRT/OpenBSD
& Yes it's me in the Avatar


Top
 Profile  
Reply with quote  
 Post subject: Re: My first project
PostPosted: Thu Dec 06, 2012 1:29 pm 
Offline
User avatar

Joined: Tue Jan 04, 2011 3:02 am
Posts: 1236
Location: Jönköping, Sweden
p0wn3d wrote:
:shock:

You could just access the raw XML data via HTTP would be less effort I would think

http://129.177.222.33/xmldata

http://www.sensatronics.com/downloads/programmers_guides/programmers_guide_em1.html

Yepp!
Use that ;)

_________________
Image http://www.linkedin.com/in/albinkiland
Dev. iMac 27" + 2x22" LG (2.8GHz Intel Core i7, 12GB RAM, 120GB SSD) OS X 10.8
Xojo Pro 2013r1


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group