[ '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 " $label $safeValue $unit "; } // Helper function for rendering progress bars function renderProgressBar($value, $id = "progresstanks") { $safeValue = htmlspecialchars($value); return ""; } // Helper function for tank level rows function renderTankRow($label, $value) { return " $label " . renderProgressBar($value) . " "; } // 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'] ]; ?>
$data): ?> $levelValue): ?>
Data source:
Endpoint error:
Scale Data
Cane In Today: Tons
Cane In Yesterday: Tons
YTD Cane Total Tons: Tons
Overview
Vapor 2: PSI
Tank Levels
Total Syrup Level:
Total A1 Molasses:
Total A2 Molasses:
Total B Molasses: