Folder reorganize 1

This commit is contained in:
Rucus
2026-02-17 12:44:37 -06:00
parent ec99d85bc2
commit f0ae0ab905
17427 changed files with 2071 additions and 1059030 deletions

256
data/overview2.php Normal file
View File

@@ -0,0 +1,256 @@
<?php
// phpcs:ignoreFile
date_default_timezone_set('America/Chicago');
$curDate = date('l, M j, Y h:i:s a');
$configuredBaseUrl = getenv('LASUCA_FEED_URL');
$roundedid = [];
$rounded = [];
$rounded1 = [];
$ID = [];
$value = [];
$endpointDataLoaded = false;
$endpointErrorMessage = null;
try {
if ($configuredBaseUrl !== false && $configuredBaseUrl !== '') {
$baseUrl = rtrim($configuredBaseUrl, '/');
} else {
$baseUrl = 'https://192.168.0.10';
}
$endpointUrl = rtrim($baseUrl, '/') . '/shared-endpoint/public/index.php';
$scheme = parse_url($endpointUrl, PHP_URL_SCHEME) ?: 'http';
$context = null;
if (strcasecmp($scheme, 'https') === 0) {
$host = parse_url($endpointUrl, PHP_URL_HOST) ?: 'localhost';
if (in_array($host, ['localhost', '127.0.0.1', '192.168.0.10', '192.168.0.16'], true)) {
$context = stream_context_create([
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
],
]);
}
}
$response = @file_get_contents($endpointUrl, false, $context ?: null);
if ($response === false && strcasecmp($scheme, 'https') === 0) {
$fallbackUrl = preg_replace('#^https#i', 'http', $endpointUrl);
$response = @file_get_contents($fallbackUrl);
if ($response !== false) {
$endpointUrl = $fallbackUrl;
}
}
if ($response === false) {
throw new RuntimeException('Unable to reach shared endpoint: ' . $endpointUrl);
}
try {
$payload = json_decode($response, true, flags: JSON_THROW_ON_ERROR);
} catch (JsonException $exception) {
throw new RuntimeException('Malformed JSON from shared endpoint', 0, $exception);
}
if (($payload['status'] ?? null) !== 'ok') {
$message = $payload['message'] ?? 'unknown error';
throw new RuntimeException('Shared endpoint returned an error: ' . $message);
}
if (!isset($payload['items']) || !is_array($payload['items'])) {
$snippet = substr(strip_tags($response), 0, 200);
throw new RuntimeException('Shared endpoint response missing items. Snippet: ' . $snippet);
}
foreach ($payload['items'] as $item) {
$tagKey = str_pad((string) $item['tagId'], 5, '0', STR_PAD_LEFT);
$value[$item['name']] = $item['value'];
$rounded[$item['name']] = $item['rounded1'];
$rounded1[$item['name']] = $item['rounded2'];
$roundedid[$tagKey] = $item['rounded2'];
$ID[$tagKey] = $item['value'];
}
$endpointDataLoaded = true;
} catch (Throwable $exception) {
$endpointErrorMessage = $exception->getMessage();
error_log('Milling shared endpoint failed: ' . $endpointErrorMessage);
}
$dataSourceLabel = 'Shared endpoint';
if (!$endpointDataLoaded) {
require __DIR__ . '/../items.php';
require __DIR__ . '/../items2dec.php';
$dataSourceLabel = 'Legacy items.php data';
}
// Helper function for rendering data rows
function renderDataRow($label, $value, $unit = "") {
$safeValue = htmlspecialchars($value);
return "<tr>
<td id=\"vtitle\">$label</td>
<td id=\"sum-count\">$safeValue</td>
<td id=\"vtitle\">$unit</td>
</tr>";
}
// Helper function for rendering progress bars
function renderProgressBar($value, $id = "progresstanks") {
$safeValue = htmlspecialchars($value);
return "<progress id=\"$id\" data-label=\"{$safeValue}%\" max=\"100\" value=\"{$safeValue}\"></progress>";
}
// Helper function for tank level rows
function renderTankRow($label, $value) {
return "<tr>
<td id=\"vtitle\">$label</td>
<td colspan=\"2\">" . renderProgressBar($value) . "</td>
</tr>";
}
// Define data arrays for cleaner loops
$overviewData = [
'Live Steam Pressure:' => [$value['PT_001'], 'PSI'],
'Exhaust Pressure:' => [$roundedid['00302'], 'PSI'],
'Exhaust Pressure At Pan 9:' => [$value['PAN9 EXST'], 'PSI'],
'Vapor Pressure at Pan 8:' => [$value['VAPORPRES'], 'PSI'],
'Pan 8 Level:' => [$value['PAN8 LVL'], '%'],
'Vapor Header Pressure:' => [$value['VAPOR HDR PRES'], 'PSI'],
'New Evap Vapor Valve:' => [$value['35kVaporValve'], '%'],
'Final Molasses Temp:' => [$value['FinalMolTemp'], 'F'],
'Cold Water Inj Temp:' => [$value['Cold Water Injection'], 'F'],
'Hot Water Inj Temp:' => [$value['Hot Water Injection'], 'F'],
'City Water Pressure:' => [$value['CityWaterPressure'], 'PSI'],
'House Air Pressure:' => [$value['HouseAirPressure'], 'PSI'],
'Clear Juice Make Up Daily TOT:' => [$value['Clear Juice Make Up Daily TOT'], 'Gallons'],
];
$tankLevels = [
'Juice Tank 1 Level:' => $value['Juice Tank1'],
'Juice Tank 2 Level:' => $value['Juice Tank2'],
'Syrup RCVR Level:' => $value['Syrup RCVR'],
'Syrup Overflow Level:' => $value['Syrup Overflow Lvl'],
'A1 Molasses RCVR Level:' => $value['A1 RCVR'],
'A1 Molasses Overflow Level:' => $value['A1 Molasses Overflow Lvl'],
'A2 Molasses RCVR Level:' => $value['A2 RCVR'],
'A2 Molasses Overflow Level:' => $value['A2 Molasses Overflow Lvl'],
'B Molasses RCVR Level:' => $value['B RCVR'],
'B Molasses Overflow Level:' => $value['B Molasses Overflow Lvl'],
'Condensate Water Level:' => $value['CondensateWater'],
'Sweetwater Level:' => $value['SweetwaterTank'],
'Cold Water Inj Level:' => $value['Cold Water Injection LVL'],
'Flash Tank Level:' => $value['FlashTankLVL']
];
?>
<div>
<table width="100%" border="1" cellspacing="0" cellpadding="2">
<tr >
<td id="datetime" colspan="4">
<?php echo $curDate; ?>
</td>
</tr>
<?php require __DIR__ . '/../includes/alerts.php'; ?>
<!-- Scale Data Section -->
<tr class="milling-alt-row">
<td id="vtitle" colspan="4">
Data source: <?php echo htmlspecialchars($dataSourceLabel, ENT_QUOTES, 'UTF-8'); ?>
<?php if ($endpointErrorMessage !== null) : ?>
<br><small class="text-muted">Endpoint error: <?php echo htmlspecialchars($endpointErrorMessage, ENT_QUOTES, 'UTF-8'); ?></small>
<?php endif; ?>
</td>
</tr>
<tr>
<td colspan="3" id="title">Scale Data</td>
</tr>
<tr>
<td id="vtitle">Cane In Today:</td>
<td id="sum-count"><?php include("../includes/tonsin.php"); ?></td>
<td id="vtitle">Tons</td>
</tr>
<tr>
<td id="vtitle">Cane In Yesterday:</td>
<td id="sum-count"><?php include("../includes/tonsinprev.php"); ?></td>
<td id="vtitle">Tons</td>
</tr>
<tr>
<td id="vtitle">YTD Cane Total Tons:</td>
<td id="sum-count"><?php include("../includes/tonsintot.php"); ?></td>
<td id="vtitle">Tons</td>
</tr>
<!-- Overview Section -->
<tr>
<td colspan="3" id="title">Overview</td>
</tr>
<tr>
<td id="vtitle">Vapor 2:</td>
<td id="sum-count"><?php include("../includes/Vapor2.php"); ?></td>
<td id="vtitle">PSI</td>
</tr>
<?php foreach ($overviewData as $label => $data): ?>
<?php echo renderDataRow($label, $data[0], $data[1]); ?>
<?php endforeach; ?>
<!-- Tank Levels Section -->
<tr>
<td colspan="3" id="title">Tank Levels</td>
</tr>
<?php foreach ($tankLevels as $label => $levelValue): ?>
<?php echo renderTankRow($label, $levelValue); ?>
<?php endforeach; ?>
<!-- Special case: Total Syrup Levels with calculation -->
<tr>
<td id="vtitle">Total Syrup Level:</td>
<td colspan="2">
<?php
$totalSyrup = round(($value['Syrup Overflow Lvl'] * 0.874919) + ($value['Syrup RCVR'] * 0.125081), 0);
echo renderProgressBar($totalSyrup);
?>
</td>
</tr>
<tr>
<td id="vtitle">Total A1 Molasses:</td>
<td colspan="2">
<?php
$totalSyrup = round(($value['A1 Molasses Overflow Lvl'] * 0.571302) + ($value['A1 RCVR'] * 0.428698), 0);
echo renderProgressBar($totalSyrup);
?>
</td>
</tr>
<tr>
<td id="vtitle">Total A2 Molasses:</td>
<td colspan="2">
<?php
$totalSyrup = round(($value['A2 Molasses Overflow Lvl'] * 0.573925) + ($value['A2 RCVR'] * 0.426075), 0);
echo renderProgressBar($totalSyrup);
?>
</td>
</tr>
<tr>
<td id="vtitle">Total B Molasses:</td>
<td colspan="2">
<?php
$totalSyrup = round(($value['B Molasses Overflow Lvl'] * 0.757982) + ($value['B RCVR'] * 0.242018), 0);
echo renderProgressBar($totalSyrup);
?>
</td>
</tr>
</table>
</div>