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

112
test/API/domoresim.php Normal file
View File

@@ -0,0 +1,112 @@
<?php
const DOMORE_SIM_URL = 'http://192.168.4.253/data/json?test=WX0';
$fetchedAt = new DateTimeImmutable('now', new DateTimeZone('America/Chicago'));
$rawResponse = null;
$displayPayload = null;
$errorMessage = null;
$httpStatus = null;
$curl = curl_init(DOMORE_SIM_URL);
curl_setopt_array(
$curl,
[
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CONNECTTIMEOUT => 3,
CURLOPT_TIMEOUT => 5,
]
);
$rawResponse = curl_exec($curl);
if ($rawResponse === false) {
$errorMessage = curl_error($curl) ?: 'Unknown cURL error';
} else {
$httpStatus = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$decoded = json_decode($rawResponse, true);
if (json_last_error() === JSON_ERROR_NONE) {
$displayPayload = json_encode(
$decoded,
JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES
);
} else {
$displayPayload = $rawResponse;
}
}
curl_close($curl);
$escapedUrl = htmlspecialchars(DOMORE_SIM_URL, ENT_QUOTES, 'UTF-8');
$escapedFetched = htmlspecialchars(
$fetchedAt->format('Y-m-d H:i:s T'),
ENT_QUOTES,
'UTF-8'
);
$escapedStatus = $httpStatus !== null ? (int) $httpStatus : null;
$escapedError = $errorMessage !== null
? htmlspecialchars($errorMessage, ENT_QUOTES, 'UTF-8')
: null;
$escapedPayload = htmlspecialchars(
$displayPayload ?? 'No payload received.',
ENT_NOQUOTES,
'UTF-8'
);
?><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="refresh" content="1">
<title>DCS DoMore SIM Feed</title>
<style>
body {
margin: 0;
padding: 1.5rem;
font-family: Consolas, "Courier New", monospace;
background-color: #111;
color: #f0f0f0;
}
pre {
margin: 0;
white-space: pre-wrap;
word-break: break-word;
}
.status {
margin-bottom: 1rem;
font-size: 0.9rem;
color: #aaa;
}
.status strong {
color: #fff;
}
.error {
color: #ff6b6b;
}
</style>
</head>
<body>
<div class="status">
<strong>Source:</strong>
<?php echo $escapedUrl; ?><br>
<strong>Fetched:</strong>
<?php echo $escapedFetched; ?><br>
<?php if ($escapedStatus !== null) : ?>
<strong>HTTP Status:</strong> <?php echo $escapedStatus; ?><br>
<?php endif; ?>
<strong>Auto-refresh:</strong> 1 seconds
</div>
<?php if ($errorMessage !== null) : ?>
<p class="error">
Failed to retrieve feed:
<?php echo $escapedError; ?>
</p>
<?php else : ?>
<pre>
<?php echo $escapedPayload; ?>
</pre>
<?php endif; ?>
</body>
</html>

140
test/API/opceapitrend.php Normal file
View File

@@ -0,0 +1,140 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Rate Trend</title>
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.6/dist/chart.umd.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-date-fns@3.0.0/dist/chartjs-adapter-date-fns.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-zoom@2.0.1/dist/chartjs-plugin-zoom.min.js"></script>
<style>
body { background:#1f2a30; color:#fff; font-family:Arial,sans-serif; margin:0; padding:20px; }
.trend-card { max-width:960px; margin:0 auto; background:#263445; border-radius:12px; padding:20px; box-shadow:0 10px 25px rgba(0,0,0,.35); }
canvas { width:100%; height:420px; }
.header { display:flex; align-items:center; justify-content:space-between; margin-bottom:12px; }
.status-dot { width:12px; height:12px; border-radius:50%; margin-right:6px; background:#27ae60; animation:pulse 2s infinite; }
@keyframes pulse { 0%{opacity:.4;} 50%{opacity:1;} 100%{opacity:.4;} }
.controls { display:flex; gap:12px; flex-wrap:wrap; }
button { background:#3498db; border:none; color:#fff; padding:8px 16px; border-radius:6px; cursor:pointer; font-weight:600; }
button:hover { background:#2980b9; }
</style>
</head>
<body>
<div class="trend-card">
<div class="header">
<h2>West Mills Rate</h2>
<div style="display:flex; align-items:center;">
<span class="status-dot"></span>
<small id="lastTimestamp">Waiting…</small>
</div>
</div>
<div class="controls">
<button id="resetZoom">Reset Zoom</button>
<span>Sampling every 1&nbsp;s</span>
</div>
<canvas id="rateChart"></canvas>
</div>
<script>
const url = "http://192.168.0.10:57080/read?item=192.168.0.10->opc.tcp://192.168.0.10:49320/->ns=2;s=WEST MILLS.MILL CONTROL.RATE";
const pollMs = 1000;
const maxPoints = 1800;
Chart.register(ChartZoom);
const ctx = document.getElementById('rateChart').getContext('2d');
const rateChart = new Chart(ctx, {
type: 'line',
data: {
labels: [],
datasets: [{
label: 'Rate (tph)',
data: [],
spanGaps: true,
tension: 0.25,
borderColor: '#27ae60',
backgroundColor: 'rgba(39,174,96,0.12)',
borderWidth: 2,
pointRadius: 0
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
scales: {
x: {
type: 'time',
ticks: { color:'#bdc3c7' },
grid: { color:'rgba(255,255,255,0.08)' }
},
y: {
beginAtZero: true,
ticks: { color:'#bdc3c7' },
grid: { color:'rgba(255,255,255,0.08)' }
}
},
plugins: {
legend: { labels:{ color:'#ecf0f1' } },
zoom: {
pan: {
enabled: true,
mode: 'x'
},
zoom: {
wheel: { enabled: true, modifierKey: 'shift' },
pinch: { enabled: true },
mode: 'x'
}
}
}
}
});
$('#resetZoom').on('click', () => {
rateChart.resetZoom();
});
setInterval(() => {
$.ajax({
type: "GET",
contentType: "application/json; charset=utf-8",
url,
dataType: "json",
cache: false,
success: function (response) {
if (!response?.data?.length) { return; }
const item = response.data[0];
const ts = new Date(item.SourceTimestamp);
const value = parseFloat(item.Value);
rateChart.data.labels.push(ts);
rateChart.data.datasets[0].data.push(value);
if (rateChart.data.labels.length > maxPoints) {
rateChart.data.labels.shift();
rateChart.data.datasets[0].data.shift();
}
rateChart.update('none');
$('#lastTimestamp').text(`Last update: ${ts.toLocaleString()} (${value.toFixed(2)} tph)`);
},
error: function () {
$('#lastTimestamp').text('Connection error');
}
});
}, pollMs);
<?php
$ch = curl_init("http://192.168.0.10:57080/read?item=...");
curl_setopt_array($ch, [
CURLOPT_NOBODY => true, // HEAD request
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 5,
]);
curl_exec($ch);
$headers = curl_getinfo($ch);
curl_close($ch);
?>
</script>
</body>
</html>