Const ForReading = 1 Const TristateUseDefault = -2 Dim FSO Set FSO = CreateObject("Scripting.FileSystemObject") Dim FilePath FilePath = "C:\BM1707\bm1707.temp" set cn = CreateObject("ADODB.Connection") cn.connectionstring = "Driver={MySQL ODBC 5.1 Driver};Server=localhost;DataBase=test; " &_ "USER=usr;PASSWORD=psw;" cn.open If FSO.FileExists(FilePath) Then Dim file Set file = FSO.GetFile(FilePath) Dim TextFileStream Set TextFileStream = file.OpenAsTextStream(ForReading,TristateUseDefault) Do While Not TextFileStream.AtEndOfStream Dim line line = TextFileStream.ReadLine curday = Mid(Line,2,2) curmnth = Mid(Line,5,2) curyear = Mid(Line,8,4) curData = Mid(Line,2,10) curhour = Mid(Line,13,2) curmin = Mid(Line,16,2) cursec = Mid(Line,19,2) curdt = curyear & curmnth & curday & curhour & curmin & cursec curhour = Cint(curhour) curmin = Cint(curmin) cursec = Cint(cursec) aspdate = CDate(curData) javadt = ((((aspdate - 25569) * 24 + curhour) * 60 + curmin) * 60 + cursec) * 1000 sqlStr = "SELECT Count( * ) FROM temperatures WHERE javadatetime = " & javadt res = cn.execute(sqlStr) if res(0)="0" then line = trim(Mid(Line,24)) cnt = 1 lst = Split(line) for each str in lst nm = "" val = "" vals = Split(str,"=") for each z in vals if nm = "" then nm = z else val = Replace(z,",",".") end if next if (nm <> "") and (val <> "") then cmdStr = "INSERT INTO temperatures" &_ "(measurementdatetime, thermometerid, value, javadatetime, thermometername)" &_ "VALUES ('" & curdt & "','" & cnt & "','" & val & "','" & javadt & "','" & nm & "')" cn.execute cmdStr End If cnt = cnt + 1 next End if Loop TextFileStream.Close Set TextFileStream = Nothing End If cn.close
$rcn = mysql_connect("localhost","usr","psw"); mysql_select_db("test"); $termid = " and `thermometerid` = 2"; $last = "order by `measurementdatetime`"; $from = ""; $to = ""; $funk = "MIN"; if (isset($_GET['termid'])) $termid=" and `thermometerid` = ".$_GET['termid']; if (isset($_GET['last'])) $last="order by `measurementdatetime` desc, 'termid' limit ".$_GET['last']; if (isset($_GET['from'])) $from=" and `measurementdatetime` >= ".$_GET['from']; if (isset($_GET['to'])) $to=" and `measurementdatetime` <= ".$_GET['to']; if (isset($_GET['funk'])) $funk="".$_GET['funk']; $sqlstr = "SELECT MIN(`javadatetime`) as javadatetime, ROUND(".$funk."(`value`),1) as value FROM `temperatures` WHERE 1 ".$termid." ".$from." ".$to." group by TO_DAYS(`measurementdatetime`) ".$last; $res = mysql_query($sqlstr); $number = mysql_num_rows($res); printf("["); $first = false; if ($number > 0) { while ($row=mysql_fetch_array($res)) { if ($first) printf(","); printf("["); printf($row['javadatetime']); printf(", "); printf($row['value']); printf("]"); $first = true; } } printf("]"); mysql_close();
var cnt = 0, seriesOptions = [], names = ['MAX','AVG', 'MIN']; createAll(); function createAll() { cnt = 0; $.each(names, function(i, name) { $.getJSON('http://tarasii.dyndns.org/minmax.php?termid=2&funk='+name, function(data) { seriesOptions[i] = {name: name, data: data, tooltip: { yDecimals: 1}}; cnt++; if (cnt == names.length) { createChart(); } }); }); } function createChart() { window.chart = new Highcharts.StockChart({ chart : { renderTo : 'container'}, title : { text : 'Day Temperature Statistics'}, xAxis : { maxZoom : 1 * 24 * 3600000 // fourteen days}, series : seriesOptions }); }
function createGauge(inGauge) { inGauge.jqxLinearGauge({ orientation: 'vertical', width: 80, height: 150, ticksMajor: { size: '10%', interval: 10 }, ticksMinor: { size: '5%', interval: 2.5, style: { 'stroke-width': 1, stroke: '#aaaaaa'} }, max: 40, min: -40, pointer: { size: '5%' }, colorScheme: 'scheme05', labels: {position: 'far', interval: 20, formatValue: function (value, position) { if (value === -40) { return '°C'; } return value + '°'; } }, animationDuration: 100 }); };
On Error Resume Next set cn = CreateObject("ADODB.Connection") cn.connectionstring = "Driver={MySQL ODBC 5.1 Driver};Server=localhost;DataBase=test; " &_ "USER=usr;PASSWORD=pwd;" cn.open sqlStr = "SELECT t.value as vl, transactiondatetime,thermometername FROM temperatures t where thermometername='Outdor' order by transactiondatetime desc limit 1; " res = cn.execute(sqlStr) str = FormatNumber(res(0),1,-1,0,0) str = Replace(Str,",",".") cn.close Set cn = Nothing strURL = "http://openweathermap.org/data/post" strDatatoSend ="user=usr&password=pwd&temp="&str&"&lat=50.5193&long=30.5915&alt=100" Dim objHTTP Set objHTTP = CreateObject("Microsoft.XMLHTTP") 'Create XML HTTP object for the Post method objHTTP.open "POST", strURL, False, "usr", "pwd" 'Opening the HTTP post method objHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" objHTTP.send strDatatoSend 'Sending the request Set objHTTP = Nothing
function updateList() { $.getJSON('http://openweathermap.org/data/2.1/weather/station/46933?type=json&callback=?', function(json) { $.each(json, function(i, head) { if(i=="main"){ curTmp = Math.round((head.temp-273)*10)/10; if (curTmp>0){ $('#main').html('<p>+'+curTmp+'°C</p>'); }else{ $('#main').html('<p>-'+curTmp+'°C</p>'); } } }); }); }
Source: https://habr.com/ru/post/155869/
All Articles