Folder reorganize 1
This commit is contained in:
63
includes/millprojected60_min_tempfix.php
Normal file
63
includes/millprojected60_min_tempfix.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
include("../dbinfo.php");
|
||||
include("../dbinfo2.php");
|
||||
|
||||
// Connection 1: East mill data (dbinfo.php - 192.168.0.10)
|
||||
$con = mysqli_connect('192.168.0.10', 'corey', '41945549', 'controls');
|
||||
|
||||
// Connection 2: West mill data (192.168.0.9)
|
||||
$con2 = mysqli_connect('192.168.0.9', 'corey', '41945549', 'controls');
|
||||
|
||||
// Calculate hours remaining until 5am
|
||||
$hoursSinceFive = (time() < strtotime('5:00'))
|
||||
? (time() + 86400 - strtotime('5:00')) / 3600
|
||||
: (time() - strtotime('5:00')) / 3600;
|
||||
$hoursRemaining = max(0, 24 - $hoursSinceFive);
|
||||
|
||||
// Get east mill data from primary server
|
||||
$eastLatest = 0;
|
||||
$eastHourAgo = 0;
|
||||
$eastResult = mysqli_query($con, "SELECT easttotground FROM easttotalground ORDER BY id DESC LIMIT 1");
|
||||
if ($eastResult && $row = mysqli_fetch_assoc($eastResult)) {
|
||||
$eastLatest = (float) $row['easttotground'];
|
||||
}
|
||||
$eastHourAgoResult = mysqli_query($con, "SELECT easttotground FROM easttotalground ORDER BY id DESC LIMIT 3599, 1");
|
||||
if ($eastHourAgoResult && $row = mysqli_fetch_assoc($eastHourAgoResult)) {
|
||||
$eastHourAgo = (float) $row['easttotground'];
|
||||
}
|
||||
|
||||
// Get west mill data from secondary server (192.168.0.9)
|
||||
$westLatest = 0;
|
||||
$westHourAgo = 0;
|
||||
if ($con2) {
|
||||
$westResult = mysqli_query($con2, "SELECT MODBUSENET_TABLE900_WTOTGROUND_VALUE FROM westtotalground ORDER BY id DESC LIMIT 1");
|
||||
if ($westResult && $row = mysqli_fetch_assoc($westResult)) {
|
||||
$westLatest = (float) $row['MODBUSENET_TABLE900_WTOTGROUND_VALUE'];
|
||||
}
|
||||
$westHourAgoResult = mysqli_query($con2, "SELECT MODBUSENET_TABLE900_WTOTGROUND_VALUE FROM westtotalground ORDER BY id DESC LIMIT 3599, 1");
|
||||
if ($westHourAgoResult && $row = mysqli_fetch_assoc($westHourAgoResult)) {
|
||||
$westHourAgo = (float) $row['MODBUSENET_TABLE900_WTOTGROUND_VALUE'];
|
||||
}
|
||||
}
|
||||
|
||||
// Get current day total from primary server
|
||||
$totalToday = 0;
|
||||
$totalResult = mysqli_query($con, "SELECT MillTotalGround FROM mill_total_ground ORDER BY id DESC LIMIT 1");
|
||||
if ($totalResult && $row = mysqli_fetch_assoc($totalResult)) {
|
||||
$totalToday = (float) $row['MillTotalGround'];
|
||||
}
|
||||
|
||||
mysqli_close($con);
|
||||
if ($con2) {
|
||||
mysqli_close($con2);
|
||||
}
|
||||
|
||||
// Calculate projections
|
||||
$eastProjected = ($eastLatest - $eastHourAgo) * $hoursRemaining;
|
||||
$westProjected = ($westLatest - $westHourAgo) * $hoursRemaining;
|
||||
$millProjected = $totalToday + $eastProjected + $westProjected;
|
||||
?>
|
||||
|
||||
|
||||
<?php echo round($millProjected); ?>
|
||||
|
||||
Reference in New Issue
Block a user