전송 웨이팅 타임 추가
This commit is contained in:
76
transmit.h
76
transmit.h
@@ -123,6 +123,10 @@ const char transmit_html[] PROGMEM = R"rawliteral(
|
||||
background: linear-gradient(135deg, #f2994a 0%, #f2c94c 100%);
|
||||
color: white;
|
||||
}
|
||||
.btn-info {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: white;
|
||||
}
|
||||
.btn:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0,0,0,0.3); }
|
||||
|
||||
.message-list {
|
||||
@@ -357,6 +361,15 @@ const char transmit_html[] PROGMEM = R"rawliteral(
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group" style="margin-bottom: 15px;">
|
||||
<label>Send All Once - Waiting Time (ms)</label>
|
||||
<input type="number" id="send-all-delay" value="10" min="0" max="1000"
|
||||
style="max-width: 200px; padding: 10px; border: 2px solid #ddd; border-radius: 5px;">
|
||||
<small style="color: #666; margin-top: 5px; display: block;">
|
||||
Delay between messages when using "Send All Once" button
|
||||
</small>
|
||||
</div>
|
||||
|
||||
<div class="form-group" style="margin-bottom: 15px;">
|
||||
<label>Data Bytes (Hex)</label>
|
||||
<div class="data-bytes">
|
||||
@@ -381,6 +394,7 @@ const char transmit_html[] PROGMEM = R"rawliteral(
|
||||
<div style="margin-bottom: 15px; display: flex; gap: 10px; flex-wrap: wrap;">
|
||||
<button class="btn btn-success" onclick="startAll()">Start All</button>
|
||||
<button class="btn btn-danger" onclick="stopAll()">Stop All</button>
|
||||
<button class="btn btn-info" onclick="sendAllOnce()">📤 Send All Once</button>
|
||||
<button class="btn btn-danger" onclick="clearAll()">Clear All</button>
|
||||
</div>
|
||||
|
||||
@@ -587,6 +601,11 @@ const char transmit_html[] PROGMEM = R"rawliteral(
|
||||
}
|
||||
|
||||
function sendCanMessage(id, type, dlc, data) {
|
||||
if (!ws || ws.readyState !== WebSocket.OPEN) {
|
||||
alert('WebSocket not connected!');
|
||||
return;
|
||||
}
|
||||
|
||||
const cmd = {
|
||||
cmd: 'sendCan',
|
||||
id: id,
|
||||
@@ -594,7 +613,9 @@ const char transmit_html[] PROGMEM = R"rawliteral(
|
||||
dlc: dlc,
|
||||
data: data.join('')
|
||||
};
|
||||
|
||||
ws.send(JSON.stringify(cmd));
|
||||
console.log('Sent CAN message: ID=' + id + ', DLC=' + dlc + ', Data=' + data.join(''));
|
||||
}
|
||||
|
||||
function updateMessageList() {
|
||||
@@ -664,6 +685,61 @@ const char transmit_html[] PROGMEM = R"rawliteral(
|
||||
updateMessageList();
|
||||
}
|
||||
|
||||
function sendAllOnce() {
|
||||
if (messages.length === 0) {
|
||||
alert('No messages in the list!');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ws || ws.readyState !== WebSocket.OPEN) {
|
||||
alert('WebSocket not connected!');
|
||||
return;
|
||||
}
|
||||
|
||||
const delayMs = parseInt(document.getElementById('send-all-delay').value) || 10;
|
||||
|
||||
// 버튼 비활성화 및 시각적 피드백
|
||||
const btn = event.target;
|
||||
const originalText = btn.innerHTML;
|
||||
btn.disabled = true;
|
||||
btn.innerHTML = '⏳ Sending...';
|
||||
|
||||
let sentCount = 0;
|
||||
|
||||
// 순차적으로 메시지 전송 (딜레이 포함)
|
||||
function sendNext(index) {
|
||||
if (index >= messages.length) {
|
||||
// 모든 메시지 전송 완료
|
||||
console.log('Sent all messages once: ' + sentCount + ' messages');
|
||||
|
||||
btn.innerHTML = '✓ Sent ' + sentCount + ' msgs';
|
||||
btn.style.background = 'linear-gradient(135deg, #11998e 0%, #38ef7d 100%)';
|
||||
|
||||
setTimeout(() => {
|
||||
btn.innerHTML = originalText;
|
||||
btn.style.background = '';
|
||||
btn.disabled = false;
|
||||
}, 2000);
|
||||
return;
|
||||
}
|
||||
|
||||
const msg = messages[index];
|
||||
sendCanMessage(msg.id, msg.type, msg.dlc, msg.data);
|
||||
sentCount++;
|
||||
|
||||
// 진행 상황 표시
|
||||
btn.innerHTML = '⏳ Sending ' + (index + 1) + '/' + messages.length;
|
||||
|
||||
// 다음 메시지 전송 (딜레이 후)
|
||||
setTimeout(() => {
|
||||
sendNext(index + 1);
|
||||
}, delayMs);
|
||||
}
|
||||
|
||||
// 첫 번째 메시지부터 시작
|
||||
sendNext(0);
|
||||
}
|
||||
|
||||
function clearAll() {
|
||||
if (confirm('Clear all messages?')) {
|
||||
stopAll();
|
||||
|
||||
Reference in New Issue
Block a user