[Message Prev][Message
Next][Thread Prev][Thread Next][Message
Index][Thread Index]
RE: Current Cost data extract
Google for "activestate", I think they do a community
version which is free.
There are I'm sure many others out there, I tend to use Linux to run this
sort of thing though (although I'll probably do something Windows based
when
I get round to it)
-----Original Message-----
From: ukha_d@xxxxxxx [mailto:ukha_d@xxxxxxx] On Behalf Of
Peter Church
Sent: 13 February 2012 09:43
To: ukha_d@xxxxxxx
Subject: RE: [ukha_d] Current Cost data extract
Thanks Alex
"drop on a Perl interpreter" might be beyond my rough and ready
capabilities, but I'll see if I can have a go.
Any recommendations of one for Windows?
P
From: ukha_d@xxxxxxx [mailto:ukha_d@xxxxxxx] On Behalf Of
Alex Monaghan
Sent: 13 February 2012 08:04
To: ukha_d@xxxxxxx
Subject: RE: [ukha_d] Current Cost data extract
I used this Perl script on a Linux box a while back (not got round to
re-configuring after Google ditched the Windows app). Very rough &
ready,
looks like it was cobbled together from a snippet of someone else's example
code, but you should be able to drop on a Perl interpreter make a few
tweaks
and you'll be running again.
#!/usr/bin/perl -w
use strict;
use Device::SerialPort;
use XML::Parser;
use XML::XPath;
use DBI;
my $port = Device::SerialPort->new("/dev/ttyUSB0");
my $dbh = DBI->connect("dbi:mysql:ccost:localhost:3306",
"ccost", "ccost");
$port->baudrate(57600);
$port->parity("none");
$port->handshake("none");
$port->databits(8);
$port->stopbits(1);
$port->read_char_time(0);
$port->read_const_time(1);
print "\nStart\n";
# read data until new data is not found five times in a row while (1) { my
$readData = &read(5); if ($readData ne "") { #print
$readData; eval { my
$xml = XML::XPath->new(xml => $readData); my $date =
$xml->find('//msg/time'); my $watts = $xml->find('//msg/ch1/watts');
#print
$date, "," , $watts, "\n"; # prepare the query my $sth
=
$dbh->prepare("insert into readings(date, reading) values(now(),
$watts)");
# execute the query
$sth->execute();
}
}
}
$port->close();
print "\nEnd\n";
sub read()
{
my $maxCnt = shift;
my $notFndCnt = 0;
# clear the read buffer variables
my $readChars = 0; my $readBytes = ""; my $readBuffer =
"";
while ($notFndCnt < $maxCnt) {
# Read serial port data
($readChars, $readBytes) = $port->read(1);
#print $readBytes;
$readBuffer .= $readBytes;
if ($readChars == 0) {
$notFndCnt++;
} else {
$notFndCnt = 0;
}
}
#print "\n";
$readBuffer;
}
-----Original Message-----
From: ukha_d@xxxxxxx <mailto:ukha_d%40yahoogroups.com>
[mailto:ukha_d@xxxxxxx
<mailto:ukha_d%40yahoogroups.com>
] On Behalf
Of peter_church
Sent: 12 February 2012 08:26
To: ukha_d@xxxxxxx <mailto:ukha_d%40yahoogroups.com>
Subject: [ukha_d] Current Cost data extract
Hi all,
I've searched the web on this and cannot find anything suitable, but was
wondering if anyone here has a homebrew solution to this (or a pointer to
something I missed).
I was using Google to gather the data from my CurrentCost unit, but was
ignoring their web part but instead pulling out my own values from the
local
database that Google was creating on my machine.
Since Google discontinued their monitoring service their software no longer
seems to be working (obviously I suppose).
Does anyone have a simple solution to retriveing the CurrentCost info into
a
local database? All the ones ont the web contain a fancy front end or
upload
to the web which I don't want.
I've tried writing my own in VB (my only language) but it uses all
resources
of the processor which is a bit of a problem - down to my limitations I
guess.
Many thanks in advance
Pete
------------------------------------
UKHA_D Main Index |
UKHA_D Thread Index |
UKHA_D Home |
Archives Home
|