Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require("config.php");
- $link = mysqli_connect($server, $user, $pwd, $db);
- if (mysqli_connect_errno()) {
- printf("Connect failed: %s\n", mysqli_connect_error());
- exit();
- }
- // Function to get min, max, and corresponding time for a specific column
- function getMinMaxTime($link, $column, $value)
- {
- $sql = "SELECT time(`TIMESTAMP_LOCAL`) AS mytime FROM METEO WHERE `$column` = ? ORDER BY `TIMESTAMP_LOCAL` DESC LIMIT 1";
- $stmt = mysqli_prepare($link, $sql);
- mysqli_stmt_bind_param($stmt, 's', $value);
- mysqli_stmt_execute($stmt);
- $result = mysqli_stmt_get_result($stmt);
- $row = mysqli_fetch_array($result, MYSQLI_ASSOC);
- mysqli_free_result($result);
- return $row ? $row['mytime'] : null;
- }
- // Get last measurement
- $sql = "SELECT * FROM METEO ORDER BY `TIMESTAMP_LOCAL` DESC LIMIT 1";
- $result = mysqli_query($link, $sql);
- $row = mysqli_fetch_array($result, MYSQLI_ASSOC);
- mysqli_free_result($result);
- $last_measure = $row['TIMESTAMP_LOCAL'];
- $temp_out = $row['TEMP'];
- $pressure = $row['PRESSURE'];
- $umidity = $row['HUM'];
- $dew_point = $row['DEW_POINT'];
- $hdex = $row['HDEX'];
- $voltage = $row['voltage'];
- // Get min/max values for the day
- $sql = "SELECT
- MIN(TEMP) AS min_temp, MAX(TEMP) AS max_temp,
- MIN(PRESSURE) AS min_press, MAX(PRESSURE) AS max_press,
- MIN(DEW_POINT) AS min_dp, MAX(DEW_POINT) AS max_dp,
- MIN(HUM) AS min_hum, MAX(HUM) AS max_hum,
- MIN(HDEX) AS min_humidex, MAX(HDEX) AS max_humidex
- FROM METEO WHERE timestamp_local >= CURDATE()";
- $result = mysqli_query($link, $sql);
- $row = mysqli_fetch_array($result, MYSQLI_ASSOC);
- mysqli_free_result($result);
- $TempOutMin = $row['min_temp'];
- $TempOutMax = $row['max_temp'];
- $UmOutMin = $row['min_hum'];
- $UmOutMax = $row['max_hum'];
- $PressureMin = $row['min_press'];
- $PressureMax = $row['max_press'];
- $dp_min = $row['min_dp'];
- $dp_max = $row['max_dp'];
- $hd_min = $row['min_humidex'];
- $hd_max = $row['max_humidex'];
- // Get times for min/max values using the function
- $ttimelow = getMinMaxTime($link, 'TEMP', $TempOutMin);
- $ttimemax = getMinMaxTime($link, 'TEMP', $TempOutMax);
- $ptimelow = getMinMaxTime($link, 'PRESSURE', $PressureMin);
- $ptimemax = getMinMaxTime($link, 'PRESSURE', $PressureMax);
- $htimelow = getMinMaxTime($link, 'HUM', $UmOutMin);
- $htimemax = getMinMaxTime($link, 'HUM', $UmOutMax);
- $dptimelow = getMinMaxTime($link, 'DEW_POINT', $dp_min);
- $dptimemax = getMinMaxTime($link, 'DEW_POINT', $dp_max);
- $hxtimelow = getMinMaxTime($link, 'HDEX', $hd_min);
- $hxtimemax = getMinMaxTime($link, 'HDEX', $hd_max);
- mysqli_close($link);
- ?>
- <!DOCTYPE html>
- <head>
- <meta http-equiv="content-type" content="text/html; charset=UTF-8">
- <link href="https://fonts.googleapis.com/css?family=Indie+Flower" rel="stylesheet">
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
- <link rel="stylesheet" type="text/css" href="css/ddimgtooltip.css" />
- <link rel="stylesheet" href="css/gauges-ss.1.css">
- <style type="text/css">
- a.button {
- appearance: button;
- text-decoration: none;
- color: initial;
- }
- .tg {
- border-collapse: collapse;
- background-color: #f0f0f0; /* Imposta uno sfondo chiaro */
- }
- .tg td,
- .tg th {
- font-family: 'Indie Flower', cursive;
- font-size: 24px;
- padding: 7px 5px;
- border-style: solid;
- border-width: 3px;
- }
- .tg .tg-8n5p {
- font-size: 20px;
- background-color: #656565;
- }
- .container {
- display: flex;
- justify-content: space-between;
- }
- </style>
- <title>MeteoFeletto Dashboard</title>
- </head>
- <body onload="init()">
- <h3 style="color:white"><?php echo "Last measure - " . $last_measure; ?></h3>
- <div class="container">
- <table class="tg">
- <tr>
- <th class="tg-8n5p"></th>
- <th class="tg-8n5p">MIN</th>
- <th class="tg-8n5p">MAX</th>
- </tr>
- <tr>
- <td class="tg-ndw9" rowspan="2">Temp. °C</td>
- <td class="tg-ndw9"><?php echo $TempOutMin; ?></td>
- <td class="tg-ndw9"><?php echo $TempOutMax; ?></td>
- </tr>
- <tr>
- <td class="tg-4na0"><?php echo $ttimelow; ?></td>
- <td class="tg-4na0"><?php echo $ttimemax; ?></td>
- </tr>
- <tr>
- <td class="tg-ndw9" rowspan="2">Humidity RH%</td>
- <td class="tg-ndw9"><?php echo $UmOutMin; ?></td>
- <td class="tg-ndw9"><?php echo $UmOutMax; ?></td>
- </tr>
- <tr>
- <td class="tg-4na0"><?php echo $htimelow; ?></td>
- <td class="tg-4na0"><?php echo $htimemax; ?></td>
- </tr>
- <tr>
- <td class="tg-ndw9" rowspan="2">Pressure hPa</td>
- <td class="tg-ndw9"><?php echo $PressureMin; ?></td>
- <td class="tg-ndw9"><?php echo $PressureMax; ?></td>
- </tr>
- <tr>
- <td class="tg-4na0"><?php echo $ptimelow; ?></td>
- <td class="tg-4na0"><?php echo $ptimemax; ?></td>
- </tr>
- <tr>
- <td class="tg-ndw9" rowspan="2">Dew Point °C</td>
- <td class="tg-ndw9"><?php echo $dp_min; ?></td>
- <td class="tg-ndw9"><?php echo $dp_max; ?></td>
- </tr>
- <tr>
- <td class="tg-4na0"><?php echo $dptimelow; ?></td>
- <td class="tg-4na0"><?php echo $dptimemax; ?></td>
- </tr>
- <tr>
- <td class="tg-ndw9" rowspan="2">App.Temp °C</td>
- <td class="tg-ndw9"><?php echo $hd_min; ?></td>
- <td class="tg-ndw9"><?php echo $hd_max; ?></td>
- </tr>
- <tr>
- <td class="tg-4na0"><?php echo $hxtimelow; ?></td>
- <td class="tg-4na0"><?php echo $hxtimemax; ?></td>
- </tr>
- </table>
- <div class="row">
- <div id="tip_0" class="gauge" rel="imgtip[0]">
- <canvas id="canvas_temp" class="gaugeSizeStd"></canvas>
- </div>
- <div id="tip_1" class="gauge" rel="imgtip[1]">
- <canvas id="canvas_hum" class="gaugeSizeStd"></canvas>
- </div>
- <div id="tip_2" class="gauge" rel="imgtip[2]">
- <canvas id="canvas_dew" class="gaugeSizeStd"></canvas>
- </div>
- </div>
- <div class="row">
- <div id="tip_3" class="gauge" rel="imgtip[3]">
- <canvas id="canvas_hdex" class="gaugeSizeStd"></canvas>
- </div>
- <div id="tip_4" class="gauge" rel="imgtip[4]">
- <canvas id="canvas_baro" class="gaugeSizeStd"></canvas>
- </div>
- <div id="tip_2" class="gauge" rel="imgtip[5]">
- <canvas id="canvas_volt" class="gaugeSizeStd"></canvas>
- </div>
- </div>
- </div>
- <div class="row">
- <a href="meteograph.php?grafico=pressure" class="btn btn-primary">week pressure</a>
- <a href="meteograph.php?grafico=humidity" class="btn btn-primary">week humidity</a>
- <a href="meteograph.php?grafico=temperature" class="btn btn-primary">week temp</a>
- <a href="meteograph.php?grafico=voltage" class="btn btn-primary">week volt</a>
- </div>
- <div class="row">
- <a href="swpi_plot_energy.php" class="btn btn-primary">today power</a>
- <a href="swpi_plot_amp.php" class="btn btn-primary">today amp</a>
- <a href="swpi_plot_volt.php" class="btn btn-primary">today volt</a>
- <a href="swpi_plot_cospi.php" class="btn btn-primary">today cospi</a>
- </div>
- <?php
- if (empty($_POST['DATE'])) {
- $data = date("d-m-Y");
- } else {
- $data = $_POST['DATE'];
- }
- //echo "reqdate = '".$data."';";
- ?>
- <script>
- var scroll = false;
- var tempGauge;
- var pressureGauge;
- var umidityGauge;
- var dewGauge;
- var hdexGauge;
- function init() {
- const voltsections = [
- steelseries.Section(3900, 4050, 'rgba(255, 0, 0, 0.9)'),
- steelseries.Section(4050, 4300, 'rgba(0, 255, 0, 0.6)'),
- steelseries.Section(4300, 4600, 'rgba(34,139,34, 0.6)')
- ];
- const tempsections = [steelseries.Section(-20, -5, 'rgba(0, 0, 220, 0.6)'),
- steelseries.Section(-5, 15, 'rgba(153, 255, 255, 0.6)'),
- steelseries.Section(15, 25, 'rgba(0, 220, 0, 0.6)'),
- steelseries.Section(25, 35, 'rgba(255, 128, 0, 0.6)'),
- steelseries.Section(35, 50, 'rgba(255, 0, 0, 0.9)')
- ];
- const dewsections = [steelseries.Section(-20, -5, 'rgba(0, 0, 220, 0.6)'),
- steelseries.Section(-5, 10, 'rgba(153, 255, 255, 0.6)'),
- steelseries.Section(10, 12, 'rgba(0, 220, 0, 0.6)'),
- steelseries.Section(12, 16, 'rgba(255, 128, 0, 0.6)'),
- steelseries.Section(16, 18, 'rgba(255, 0, 0, 0.9)'),
- steelseries.Section(18, 21, 'rgba(153, 255, 255, 0.6)'),
- steelseries.Section(21, 24, 'rgba(0, 220, 0, 0.6)'),
- steelseries.Section(24, 26, 'rgba(255, 128, 0, 0.6)'),
- steelseries.Section(26, 28, 'rgba(255, 0, 0, 0.9)')
- ];
- const humiditysections = [steelseries.Section(0, 20, 'rgba(255, 0, 0, 0.6)'),
- steelseries.Section(20, 40, 'rgba(255, 128, 0, 0.6)'),
- steelseries.Section(40, 60, 'rgba(0, 220, 0, 0.6)'),
- steelseries.Section(60, 80, 'rgba(153, 255, 255, 0.6)'),
- steelseries.Section(80, 100, 'rgba(0, 0, 220, 0.9)')
- ];
- const humsections = [steelseries.Section(15, 20, 'rgba(153, 255, 255, 0.6)'),
- steelseries.Section(20, 30, 'rgba(0, 220, 0, 0.6)'),
- steelseries.Section(30, 40, 'rgba(255, 125, 125, 0.6)'),
- steelseries.Section(40, 45, 'rgba(255, 128, 0, 0.6)'),
- steelseries.Section(45, 50, 'rgba(255, 0, 0, 0.6)')
- ];
- const sectionsPressute = [steelseries.Section(970, 990, 'rgba(0, 0, 220, 0.6)'),
- steelseries.Section(990, 1000, 'rgba(0, 110, 110, 0.6)'),
- steelseries.Section(1000, 1013, 'rgba(0, 155, 75, 0.6)'),
- steelseries.Section(1013, 1020, 'rgba(0, 255, 0, 0.6)'),
- steelseries.Section(1020, 1030, 'rgba(220, 220, 0, 0.6)'),
- steelseries.Section(1030, 1040, 'rgba(255, 128, 0, 0.6)')
- ];
- umidityGauge = new steelseries.Radial('canvas_hum', {
- gaugeType: steelseries.GaugeType.TYPE4,
- size: 210,
- section: humiditysections,
- minMeasuredValueVisible: true,
- maxMeasuredValueVisible: true,
- thresholdVisible: false,
- titleString: 'Umidity',
- unitString: '%',
- lcdVisible: true
- });
- pressureGauge = new steelseries.Radial('canvas_baro', {
- gaugeType: steelseries.GaugeType.TYPE4,
- minMeasuredValueVisible: true,
- maxMeasuredValueVisible: true,
- size: 201,
- section: sectionsPressute,
- useSectionColors: true,
- titleString: 'Pressure',
- unitString: 'hPa',
- lcdVisible: true,
- minValue: 970,
- maxValue: 1040
- });
- tempGauge = new steelseries.Radial('canvas_temp', {
- size: 210,
- minValue: -15,
- maxValue: 50,
- section: tempsections,
- gaugeType: steelseries.GaugeType.TYPE4,
- minMeasuredValueVisible: true,
- maxMeasuredValueVisible: true,
- thresholdVisible: false,
- titleString: "Temperature",
- unitString: "C",
- lcdVisible: true
- });
- hdexGauge = new steelseries.Radial('canvas_hdex', {
- size: 210,
- minValue: -15,
- maxValue: 50,
- section: tempsections,
- gaugeType: steelseries.GaugeType.TYPE4,
- minMeasuredValueVisible: true,
- maxMeasuredValueVisible: true,
- thresholdVisible: false,
- titleString: "Humidex",
- unitString: "",
- lcdVisible: true
- });
- dewGauge = new steelseries.Radial('canvas_dew', {
- size: 210,
- minValue: -15,
- maxValue: 30,
- section: dewsections,
- gaugeType: steelseries.GaugeType.TYPE4,
- setFrameDesign: steelseries.FrameDesign.TILTED_GRAY,
- minMeasuredValueVisible: true,
- maxMeasuredValueVisible: true,
- thresholdVisible: false,
- titleString: "Dew Point",
- unitString: "C",
- lcdVisible: true
- });
- voltGauge = new steelseries.Radial('canvas_volt', {
- size: 210,
- minValue: 3950,
- maxValue: 4600,
- section: voltsections,
- gaugeType: steelseries.GaugeType.TYPE4,
- setFrameDesign: steelseries.FrameDesign.TILTED_GRAY,
- minMeasuredValueVisible: true,
- maxMeasuredValueVisible: true,
- thresholdVisible: false,
- titleString: "Battery",
- unitString: "mV",
- lcdVisible: true
- });
- tempGauge.setFrameDesign(steelseries.FrameDesign.TILTED_GRAY);
- pressureGauge.setFrameDesign(steelseries.FrameDesign.TILTED_GRAY);
- umidityGauge.setFrameDesign(steelseries.FrameDesign.TILTED_GRAY);
- //dewGauge.setFrameDesign(steelseries.FrameDesign.TILTED_GRAY);
- hdexGauge.setFrameDesign(steelseries.FrameDesign.TILTED_GRAY);
- tempGauge.setBackgroundColor(steelseries.BackgroundColor.LIGHT_GRAY);
- pressureGauge.setBackgroundColor(steelseries.BackgroundColor.LIGHT_GRAY);
- umidityGauge.setBackgroundColor(steelseries.BackgroundColor.LIGHT_GRAY);
- dewGauge.setBackgroundColor(steelseries.BackgroundColor.LIGHT_GRAY);
- hdexGauge.setBackgroundColor(steelseries.BackgroundColor.LIGHT_GRAY);
- voltGauge.setBackgroundColor(steelseries.BackgroundColor.LIGHT_GRAY);
- tempGauge.setValueAnimated(<?php echo $temp_out; ?>);
- tempGauge.setMinMeasuredValue(<?php echo $TempOutMin; ?>);
- tempGauge.setMaxMeasuredValue(<?php echo $TempOutMax; ?>);
- pressureGauge.setValueAnimated(<?php echo $pressure; ?>);
- pressureGauge.setMinMeasuredValue(<?php echo $PressureMin; ?>);
- pressureGauge.setMaxMeasuredValue(<?php echo $PressureMax; ?>);
- umidityGauge.setValueAnimated(<?php echo $umidity; ?>);
- umidityGauge.setMinMeasuredValue(<?php echo $UmOutMin; ?>);
- umidityGauge.setMaxMeasuredValue(<?php echo $UmOutMax; ?>);
- dewGauge.setValueAnimated(<?php echo $dew_point; ?>);
- dewGauge.setMinMeasuredValue(<?php echo $dp_min; ?>);
- dewGauge.setMaxMeasuredValue(<?php echo $dp_max; ?>);
- hdexGauge.setValueAnimated(<?php echo $hdex; ?>);
- hdexGauge.setMinMeasuredValue(<?php echo $hd_min; ?>);
- hdexGauge.setMaxMeasuredValue(<?php echo $hd_max; ?>);
- voltGauge.setValueAnimated(<?php echo $voltage; ?>);
- }
- </script>
- <script src="http://code.jquery.com/jquery-1.3.2.min.js"></script>
- <script src="js/gauges.js"></script>
- <script src="js/tween-min.js"></script>
- <script src="js/steelseries-min.js"></script>
- <script type="text/javascript" src="js/ddimgtooltip1.js"></script>
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
- <script type="text/javascript" src="js/jquery-ui-1.7.2.custom.min.js"></script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement