test commit
This commit is contained in:
391
web.html
Normal file
391
web.html
Normal file
@@ -0,0 +1,391 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ko">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>LoadCell 실시간 무게 측정</title>
|
||||
|
||||
<!-- Chart.js CDN -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js"></script>
|
||||
|
||||
<!-- Socket.IO CDN -->
|
||||
<script src="https://cdn.socket.io/4.5.4/socket.io.min.js"></script>
|
||||
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
min-height: 100vh;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 1400px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.header {
|
||||
text-align: center;
|
||||
color: white;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.header h1 {
|
||||
font-size: 2.5em;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.status {
|
||||
display: inline-block;
|
||||
padding: 8px 16px;
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border-radius: 20px;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
.status.connected {
|
||||
background: rgba(76, 175, 80, 0.8);
|
||||
}
|
||||
|
||||
.main-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 350px;
|
||||
gap: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.card {
|
||||
background: white;
|
||||
border-radius: 15px;
|
||||
padding: 25px;
|
||||
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.chart-container {
|
||||
position: relative;
|
||||
height: 400px;
|
||||
}
|
||||
|
||||
.current-weight {
|
||||
text-align: center;
|
||||
padding: 20px;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: white;
|
||||
border-radius: 10px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.current-weight .value {
|
||||
font-size: 3.5em;
|
||||
font-weight: bold;
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
.current-weight .unit {
|
||||
font-size: 1.2em;
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.controls {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 10px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
padding: 12px 20px;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
font-size: 1em;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: #667eea;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
background: #f0f0f0;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.btn-danger {
|
||||
background: #e74c3c;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-success {
|
||||
background: #4CAF50;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.log-container {
|
||||
background: #f8f9fa;
|
||||
border-radius: 8px;
|
||||
padding: 15px;
|
||||
height: 200px;
|
||||
overflow-y: auto;
|
||||
font-family: 'Courier New', monospace;
|
||||
font-size: 0.85em;
|
||||
}
|
||||
|
||||
.log-item {
|
||||
padding: 5px 0;
|
||||
border-bottom: 1px solid #e0e0e0;
|
||||
}
|
||||
|
||||
.stats-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 15px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
text-align: center;
|
||||
padding: 15px;
|
||||
background: #f8f9fa;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 0.9em;
|
||||
color: #666;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: 1.8em;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
.main-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<h1>LoadCell 실시간 용량 측정</h1>
|
||||
<div class="status" id="connectionStatus">연결 대기 중...</div>
|
||||
</div>
|
||||
|
||||
<div class="main-grid">
|
||||
<div class="card">
|
||||
<h2 style="margin-bottom: 20px;">실시간 용량 그래프</h2>
|
||||
<div class="chart-container">
|
||||
<canvas id="weightChart"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h2 style="margin-bottom: 20px;">측정 정보</h2>
|
||||
|
||||
<div class="density-input" style="margin-bottom: 15px;">
|
||||
<label style="font-size: 0.9em; color: #666;">밀도 (g/mL):</label>
|
||||
<input type="number" id="densityInput" value="1.0" min="0.1" max="10" step="0.01"
|
||||
style="width: 80px; padding: 5px; border: 1px solid #ddd; border-radius: 4px; margin-left: 10px;">
|
||||
<button class="btn btn-secondary" onclick="setDensity()"
|
||||
style="padding: 5px 10px; margin-left: 5px;">적용</button>
|
||||
</div>
|
||||
|
||||
<div class="current-weight"
|
||||
style="background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%); margin-top: 10px;">
|
||||
<div class="label">현재 용량</div>
|
||||
<div class="value" id="currentVolume">0.0</div>
|
||||
<div class="unit">mL</div>
|
||||
</div>
|
||||
|
||||
<h3 style="margin-top: 20px; margin-bottom: 10px; color: #333;">배뇨 측정 통계</h3>
|
||||
<div class="stats-grid">
|
||||
<div class="stat-item">
|
||||
<div class="stat-label">Voided Volume</div>
|
||||
<div class="stat-value" id="voidedVolume">0.0<span style="font-size:0.5em">mL</span></div>
|
||||
</div>
|
||||
<div class="stat-item">
|
||||
<div class="stat-label">Voided Time</div>
|
||||
<div class="stat-value" id="voidedTime">0.0<span style="font-size:0.5em">s</span></div>
|
||||
</div>
|
||||
<div class="stat-item">
|
||||
<div class="stat-label">Max Flow Rate</div>
|
||||
<div class="stat-value" id="maxFlowRate">0.0<span style="font-size:0.5em">mL/s</span></div>
|
||||
</div>
|
||||
<div class="stat-item">
|
||||
<div class="stat-label">Max Flow Time</div>
|
||||
<div class="stat-value" id="maxFlowTime">0.0<span style="font-size:0.5em">s</span></div>
|
||||
</div>
|
||||
<div class="stat-item">
|
||||
<div class="stat-label">Ave Flow Rate</div>
|
||||
<div class="stat-value" id="aveFlowRate">0.0<span style="font-size:0.5em">mL/s</span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="controls">
|
||||
<button class="btn btn-primary" onclick="sendCommand('tare')">영점 조절</button>
|
||||
<button class="btn btn-secondary" onclick="sendCommand('pause')">일시정지</button>
|
||||
<button class="btn btn-success" onclick="sendCommand('resume')">재시작</button>
|
||||
<button class="btn btn-danger" onclick="resetMeasurement()">초기화</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h2 style="margin-bottom: 15px;">시스템 로그</h2>
|
||||
<div class="log-container" id="logContainer"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const socket = io();
|
||||
const ctx = document.getElementById('weightChart').getContext('2d');
|
||||
const maxDataPoints = 50;
|
||||
|
||||
const weightChart = new Chart(ctx, {
|
||||
type: 'line',
|
||||
data: {
|
||||
labels: [],
|
||||
datasets: [{
|
||||
label: '용량 (mL)',
|
||||
data: [],
|
||||
borderColor: '#667eea',
|
||||
backgroundColor: 'rgba(102, 126, 234, 0.1)',
|
||||
borderWidth: 2,
|
||||
tension: 0.4,
|
||||
fill: true,
|
||||
pointRadius: 3,
|
||||
pointHoverRadius: 5
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: false,
|
||||
animation: { duration: 200 },
|
||||
scales: {
|
||||
x: { display: true, title: { display: true, text: '시간' } },
|
||||
y: { beginAtZero: true, title: { display: true, text: '용량 (mL)' } }
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
let currentDensity = 1.0;
|
||||
|
||||
socket.on('connect', function () {
|
||||
updateConnectionStatus(true);
|
||||
addLog('서버에 연결되었습니다.');
|
||||
});
|
||||
|
||||
socket.on('disconnect', function () {
|
||||
updateConnectionStatus(false);
|
||||
addLog('서버 연결이 끊어졌습니다.');
|
||||
});
|
||||
|
||||
socket.on('weight_data', function (data) {
|
||||
const volume = data.volume_ml || 0;
|
||||
const timestamp = new Date().toLocaleTimeString();
|
||||
|
||||
weightChart.data.labels.push(timestamp);
|
||||
weightChart.data.datasets[0].data.push(volume);
|
||||
|
||||
if (weightChart.data.labels.length > maxDataPoints) {
|
||||
weightChart.data.labels.shift();
|
||||
weightChart.data.datasets[0].data.shift();
|
||||
}
|
||||
weightChart.update('none');
|
||||
|
||||
document.getElementById('currentVolume').textContent = volume.toFixed(1);
|
||||
});
|
||||
|
||||
socket.on('measurement_result', function (data) {
|
||||
document.getElementById('voidedVolume').innerHTML = (data.voided_volume || 0).toFixed(1) + '<span style="font-size:0.5em">mL</span>';
|
||||
document.getElementById('voidedTime').innerHTML = (data.voided_time || 0).toFixed(1) + '<span style="font-size:0.5em">s</span>';
|
||||
document.getElementById('maxFlowRate').innerHTML = (data.max_flow_rate || 0).toFixed(2) + '<span style="font-size:0.5em">mL/s</span>';
|
||||
document.getElementById('maxFlowTime').innerHTML = (data.max_flow_time || 0).toFixed(1) + '<span style="font-size:0.5em">s</span>';
|
||||
if (data.ave_flow_rate !== undefined) {
|
||||
document.getElementById('aveFlowRate').innerHTML = data.ave_flow_rate.toFixed(2) + '<span style="font-size:0.5em">mL/s</span>';
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('log_message', function (data) { addLog(data.message); });
|
||||
socket.on('command_result', function (data) {
|
||||
addLog(data.success ? 'Okay: ' + data.message : 'Error: ' + data.message);
|
||||
});
|
||||
|
||||
function updateConnectionStatus(connected) {
|
||||
const statusEl = document.getElementById('connectionStatus');
|
||||
if (connected) {
|
||||
statusEl.textContent = '연결됨';
|
||||
statusEl.classList.add('connected');
|
||||
} else {
|
||||
statusEl.textContent = '연결 끊김';
|
||||
statusEl.classList.remove('connected');
|
||||
}
|
||||
}
|
||||
|
||||
function sendCommand(cmd) {
|
||||
socket.emit('send_command', { command: cmd });
|
||||
addLog('명령 전송: ' + cmd);
|
||||
}
|
||||
|
||||
function setDensity() {
|
||||
const densityInput = document.getElementById('densityInput');
|
||||
const density = parseFloat(densityInput.value);
|
||||
if (density > 0) {
|
||||
currentDensity = density;
|
||||
socket.emit('set_density', { density: density });
|
||||
addLog('밀도 설정: ' + density + ' g/mL');
|
||||
} else {
|
||||
addLog('밀도는 0보다 커야 합니다.');
|
||||
}
|
||||
}
|
||||
|
||||
function resetMeasurement() {
|
||||
weightChart.data.labels = [];
|
||||
weightChart.data.datasets[0].data = [];
|
||||
weightChart.update();
|
||||
|
||||
document.getElementById('currentVolume').textContent = '0.0';
|
||||
document.getElementById('voidedVolume').innerHTML = '0.0<span style="font-size:0.5em">mL</span>';
|
||||
document.getElementById('voidedTime').innerHTML = '0.0<span style="font-size:0.5em">s</span>';
|
||||
document.getElementById('maxFlowRate').innerHTML = '0.0<span style="font-size:0.5em">mL/s</span>';
|
||||
document.getElementById('maxFlowTime').innerHTML = '0.0<span style="font-size:0.5em">s</span>';
|
||||
document.getElementById('aveFlowRate').innerHTML = '0.0<span style="font-size:0.5em">mL/s</span>';
|
||||
|
||||
socket.emit('reset_measurement');
|
||||
sendCommand('tare');
|
||||
addLog('측정 데이터 초기화');
|
||||
}
|
||||
|
||||
function addLog(message) {
|
||||
const logContainer = document.getElementById('logContainer');
|
||||
const logItem = document.createElement('div');
|
||||
logItem.className = 'log-item';
|
||||
logItem.textContent = `[${new Date().toLocaleTimeString()}] ${message}`;
|
||||
logContainer.appendChild(logItem);
|
||||
logContainer.scrollTop = logContainer.scrollHeight;
|
||||
if (logContainer.children.length > 50) logContainer.removeChild(logContainer.firstChild);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user