修改了仿真监控和模型监控
This commit is contained in:
parent
04767fe971
commit
a6a6892897
Binary file not shown.
@ -112,16 +112,26 @@ class ModelMonitor extends HTMLElement {
|
||||
|
||||
// 修改 startMonitoring 方法
|
||||
async startMonitoring() {
|
||||
const domainId = this.shadowRoot.querySelector('.domain-input').value.trim();
|
||||
this.domainId = domainId;
|
||||
const savedSelection = localStorage.getItem('xnsim-selection');
|
||||
const selection = savedSelection ? JSON.parse(savedSelection) : {};
|
||||
const confID = selection.configurationId;
|
||||
|
||||
// 验证域ID是否为有效的数字字符串
|
||||
if (!/^\d+$/.test(domainId)) {
|
||||
console.error('域ID必须是有效的数字');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// 获取构型参数
|
||||
const configResponse = await fetch(`/api/configurations/${confID}`);
|
||||
if (!configResponse.ok) {
|
||||
throw new Error('获取构型参数失败');
|
||||
}
|
||||
const configData = await configResponse.json();
|
||||
|
||||
// 从构型参数中提取域ID
|
||||
const domainId = configData.DomainID;
|
||||
if (!domainId) {
|
||||
throw new Error('构型参数中未找到有效的域ID');
|
||||
}
|
||||
this.domainId = domainId;
|
||||
|
||||
// 首先检查DDS监控状态
|
||||
const ddsStatusResponse = await fetch('/api/dds-monitor/status');
|
||||
const ddsStatusData = await ddsStatusResponse.json();
|
||||
@ -251,18 +261,15 @@ class ModelMonitor extends HTMLElement {
|
||||
}
|
||||
|
||||
updateUI() {
|
||||
const input = this.shadowRoot.querySelector('.domain-input');
|
||||
const startButton = this.shadowRoot.querySelector('.start-button');
|
||||
const stopButton = this.shadowRoot.querySelector('.stop-button');
|
||||
const statusDisplay = this.shadowRoot.querySelector('.status-display');
|
||||
const modelTableBody = this.shadowRoot.querySelector('#model-table-body');
|
||||
|
||||
if (this.monitorStatus.isMonitoring) {
|
||||
input.disabled = true;
|
||||
startButton.disabled = true;
|
||||
stopButton.disabled = false;
|
||||
} else {
|
||||
input.disabled = false;
|
||||
startButton.disabled = false;
|
||||
stopButton.disabled = true;
|
||||
}
|
||||
@ -393,19 +400,6 @@ class ModelMonitor extends HTMLElement {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.domain-input {
|
||||
padding: 8px 12px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
font-size: 14px;
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
.domain-input:disabled {
|
||||
background-color: #f5f5f5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.control-button {
|
||||
padding: 8px 16px;
|
||||
border: none;
|
||||
@ -545,10 +539,6 @@ class ModelMonitor extends HTMLElement {
|
||||
<div class="toolbar-section">
|
||||
<div class="toolbar">
|
||||
<div class="toolbar-left">
|
||||
<div class="input-group">
|
||||
<label class="input-label">DDS通信域ID:</label>
|
||||
<input type="text" class="domain-input" value="10">
|
||||
</div>
|
||||
<button class="control-button start-button" onclick="this.getRootNode().host.startMonitoring()">开始监控</button>
|
||||
<button class="control-button stop-button" onclick="this.getRootNode().host.stopMonitoring()">停止监控</button>
|
||||
</div>
|
||||
|
@ -116,14 +116,9 @@ class SimulationMonitor extends HTMLElement {
|
||||
|
||||
// 修改 startMonitoring 方法
|
||||
async startMonitoring() {
|
||||
const domainId = this.shadowRoot.querySelector('.domain-input').value.trim();
|
||||
this.domainId = domainId;
|
||||
|
||||
// 验证域ID是否为有效的数字字符串
|
||||
if (!/^\d+$/.test(domainId)) {
|
||||
console.error('域ID必须是有效的数字');
|
||||
return;
|
||||
}
|
||||
const savedSelection = localStorage.getItem('xnsim-selection');
|
||||
const selection = savedSelection ? JSON.parse(savedSelection) : {};
|
||||
const confID = selection.configurationId;
|
||||
|
||||
// 如果已经在监控中,直接返回
|
||||
if (this.monitorStatus.isMonitoring) {
|
||||
@ -132,6 +127,20 @@ class SimulationMonitor extends HTMLElement {
|
||||
}
|
||||
|
||||
try {
|
||||
// 获取构型参数
|
||||
const configResponse = await fetch(`/api/configurations/${confID}`);
|
||||
if (!configResponse.ok) {
|
||||
throw new Error('获取构型参数失败');
|
||||
}
|
||||
const configData = await configResponse.json();
|
||||
|
||||
// 从构型参数中提取域ID
|
||||
const domainId = configData.DomainID;
|
||||
if (!domainId) {
|
||||
throw new Error('构型参数中未找到有效的域ID');
|
||||
}
|
||||
this.domainId = domainId;
|
||||
|
||||
// 首先检查DDS监控状态
|
||||
const ddsStatusResponse = await fetch('/api/dds-monitor/status');
|
||||
const ddsStatusData = await ddsStatusResponse.json();
|
||||
@ -276,7 +285,6 @@ class SimulationMonitor extends HTMLElement {
|
||||
}
|
||||
|
||||
updateUI() {
|
||||
const input = this.shadowRoot.querySelector('.domain-input');
|
||||
const startButton = this.shadowRoot.querySelector('.start-button');
|
||||
const stopButton = this.shadowRoot.querySelector('.stop-button');
|
||||
const statusDisplay = this.shadowRoot.querySelector('.status-display');
|
||||
@ -285,11 +293,9 @@ class SimulationMonitor extends HTMLElement {
|
||||
const threadTableBody = this.shadowRoot.querySelector('#thread-table-body');
|
||||
|
||||
if (this.monitorStatus.isMonitoring) {
|
||||
input.disabled = true;
|
||||
startButton.disabled = true;
|
||||
stopButton.disabled = false;
|
||||
} else {
|
||||
input.disabled = false;
|
||||
startButton.disabled = false;
|
||||
stopButton.disabled = true;
|
||||
}
|
||||
@ -301,82 +307,53 @@ class SimulationMonitor extends HTMLElement {
|
||||
}
|
||||
|
||||
// 更新引擎信息
|
||||
const engineInfoFields = [
|
||||
{ label: '引擎名称', key: 'name' },
|
||||
{ label: '引擎ID', key: 'id' },
|
||||
{ label: '引擎状态', key: 'status' },
|
||||
{ label: '引擎亲和性', key: 'affinity' },
|
||||
{ label: '线程数', key: 'threadCount' }
|
||||
];
|
||||
const engineInfoItems = engineInfo.querySelectorAll('.status-item');
|
||||
engineInfoItems.forEach(item => {
|
||||
const label = item.querySelector('.status-label').textContent;
|
||||
const valueElement = item.querySelector('.status-value');
|
||||
|
||||
engineInfo.innerHTML = `
|
||||
<div class="status-grid">
|
||||
${engineInfoFields.map(field => {
|
||||
let value = '未知';
|
||||
let color = '#666';
|
||||
|
||||
if (this.monitorStatus.isMonitoring && this.systemInfo?.engineInfo) {
|
||||
if (field.key === 'status') {
|
||||
const status = this.systemInfo.engineInfo[field.key];
|
||||
const statusInfo = this.getStatusDisplay(status);
|
||||
value = statusInfo.text;
|
||||
color = statusInfo.color;
|
||||
} else {
|
||||
value = this.systemInfo.engineInfo[field.key] || '未知';
|
||||
switch(label) {
|
||||
case '引擎名称':
|
||||
valueElement.textContent = this.systemInfo?.engineInfo?.name || 'XNSim';
|
||||
valueElement.style.color = '#666';
|
||||
break;
|
||||
case '引擎ID':
|
||||
valueElement.textContent = this.systemInfo?.engineInfo?.id || '未知';
|
||||
valueElement.style.color = '#666';
|
||||
break;
|
||||
case '引擎状态':
|
||||
const statusInfo = this.getStatusDisplay(this.systemInfo?.engineInfo?.status || 0);
|
||||
valueElement.textContent = statusInfo.text;
|
||||
valueElement.style.color = statusInfo.color;
|
||||
break;
|
||||
case '引擎亲和性':
|
||||
valueElement.textContent = this.systemInfo?.engineInfo?.affinity || '未知';
|
||||
valueElement.style.color = '#666';
|
||||
break;
|
||||
case '线程数':
|
||||
valueElement.textContent = this.systemInfo?.engineInfo?.threadCount || '未知';
|
||||
valueElement.style.color = '#666';
|
||||
break;
|
||||
}
|
||||
} else if (field.key === 'status') {
|
||||
const statusInfo = this.getStatusDisplay(0);
|
||||
value = statusInfo.text;
|
||||
color = statusInfo.color;
|
||||
}
|
||||
|
||||
return `
|
||||
<div class="status-item">
|
||||
<div class="status-label">${field.label}</div>
|
||||
<div class="status-value" style="color: ${color}">${value}</div>
|
||||
</div>
|
||||
`;
|
||||
}).join('')}
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
|
||||
// 更新核心状态
|
||||
const coreStatusFields = [
|
||||
{ label: '主框架状态', key: 'fw' },
|
||||
{ label: '时间管理器状态', key: 'tm' },
|
||||
{ label: '事件管理器状态', key: 'em' },
|
||||
{ label: '环境管理器状态', key: 'sd' },
|
||||
{ label: '线程管理器状态', key: 'thm' },
|
||||
{ label: '模型管理器状态', key: 'mm' },
|
||||
{ label: '服务管理器状态', key: 'sm' },
|
||||
{ label: 'DDS管理器状态', key: 'dm' }
|
||||
];
|
||||
const coreStatusItems = coreStatus.querySelectorAll('.status-item');
|
||||
coreStatusItems.forEach(item => {
|
||||
const label = item.querySelector('.status-label').textContent;
|
||||
const valueElement = item.querySelector('.status-value');
|
||||
const key = this.getCoreStatusKey(label);
|
||||
|
||||
// 确保coreStatus元素存在
|
||||
if (!coreStatus) {
|
||||
console.error('找不到核心状态元素');
|
||||
return;
|
||||
}
|
||||
|
||||
// 无论是否有数据,都显示状态项
|
||||
coreStatus.innerHTML = `
|
||||
<div class="status-grid">
|
||||
${coreStatusFields.map(field => {
|
||||
const status = this.monitorStatus.isMonitoring && this.systemInfo?.coreStatus ?
|
||||
this.systemInfo.coreStatus[field.key] : 0;
|
||||
if (key) {
|
||||
const status = this.systemInfo?.coreStatus?.[key] || 0;
|
||||
const statusInfo = this.getCoreStatusDisplay(status);
|
||||
return `
|
||||
<div class="status-item">
|
||||
<div class="status-label">${field.label}</div>
|
||||
<div class="status-value" style="color: ${statusInfo.color}">${statusInfo.text}</div>
|
||||
</div>
|
||||
`;
|
||||
}).join('')}
|
||||
</div>
|
||||
`;
|
||||
valueElement.textContent = statusInfo.text;
|
||||
valueElement.style.color = statusInfo.color;
|
||||
}
|
||||
});
|
||||
|
||||
// 更新线程表格
|
||||
if (this.monitorStatus.isMonitoring && this.threadInfo && Array.isArray(this.threadInfo)) {
|
||||
if (this.threadInfo && Array.isArray(this.threadInfo)) {
|
||||
threadTableBody.innerHTML = this.threadInfo.map(thread => {
|
||||
const statusInfo = this.getThreadStatusDisplay(thread.status);
|
||||
return `
|
||||
@ -411,6 +388,20 @@ class SimulationMonitor extends HTMLElement {
|
||||
}
|
||||
}
|
||||
|
||||
getCoreStatusKey(label) {
|
||||
const keyMap = {
|
||||
'主框架状态': 'fw',
|
||||
'时间管理器状态': 'tm',
|
||||
'事件管理器状态': 'em',
|
||||
'环境管理器状态': 'sd',
|
||||
'线程管理器状态': 'thm',
|
||||
'模型管理器状态': 'mm',
|
||||
'服务管理器状态': 'sm',
|
||||
'DDS管理器状态': 'dm'
|
||||
};
|
||||
return keyMap[label];
|
||||
}
|
||||
|
||||
async stopMonitoring() {
|
||||
try {
|
||||
const response = await fetch('/api/system-monitor/stop', {
|
||||
@ -419,6 +410,30 @@ class SimulationMonitor extends HTMLElement {
|
||||
const data = await response.json();
|
||||
if (response.ok) {
|
||||
this.monitorStatus = data.status;
|
||||
// 立即停止状态检查
|
||||
this.stopStatusCheck();
|
||||
// 清空数据
|
||||
this.systemInfo = {
|
||||
engineInfo: {
|
||||
name: 'XNSim',
|
||||
id: '未知',
|
||||
status: 0,
|
||||
affinity: '未知',
|
||||
threadCount: '未知'
|
||||
},
|
||||
coreStatus: {
|
||||
fw: 0,
|
||||
tm: 0,
|
||||
em: 0,
|
||||
sd: 0,
|
||||
thm: 0,
|
||||
mm: 0,
|
||||
sm: 0,
|
||||
dm: 0
|
||||
}
|
||||
};
|
||||
this.threadInfo = null;
|
||||
// 更新UI
|
||||
this.updateUI();
|
||||
} else {
|
||||
console.error('停止监控失败:', data.error);
|
||||
@ -505,19 +520,6 @@ class SimulationMonitor extends HTMLElement {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.domain-input {
|
||||
padding: 8px 12px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
font-size: 14px;
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
.domain-input:disabled {
|
||||
background-color: #f5f5f5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.control-button {
|
||||
padding: 8px 16px;
|
||||
border: none;
|
||||
@ -712,10 +714,6 @@ class SimulationMonitor extends HTMLElement {
|
||||
<div class="toolbar-section">
|
||||
<div class="toolbar">
|
||||
<div class="toolbar-left">
|
||||
<div class="input-group">
|
||||
<label class="input-label">DDS通信域ID:</label>
|
||||
<input type="text" class="domain-input" value="10">
|
||||
</div>
|
||||
<button class="control-button start-button" onclick="this.getRootNode().host.startMonitoring()">开始监控</button>
|
||||
<button class="control-button stop-button" onclick="this.getRootNode().host.stopMonitoring()">停止监控</button>
|
||||
</div>
|
||||
@ -726,11 +724,69 @@ class SimulationMonitor extends HTMLElement {
|
||||
<div class="left-panel">
|
||||
<div class="panel-section">
|
||||
<h3>引擎信息</h3>
|
||||
<div class="info-grid" id="engine-info"></div>
|
||||
<div class="info-grid" id="engine-info">
|
||||
<div class="status-grid">
|
||||
<div class="status-item">
|
||||
<div class="status-label">引擎名称</div>
|
||||
<div class="status-value" style="color: #666">XNSim</div>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<div class="status-label">引擎ID</div>
|
||||
<div class="status-value" style="color: #666">未知</div>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<div class="status-label">引擎状态</div>
|
||||
<div class="status-value" style="color: #999999">未运行</div>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<div class="status-label">引擎亲和性</div>
|
||||
<div class="status-value" style="color: #666">未知</div>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<div class="status-label">线程数</div>
|
||||
<div class="status-value" style="color: #666">未知</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-section">
|
||||
<h3>核心状态</h3>
|
||||
<div class="info-grid" id="core-status"></div>
|
||||
<div class="info-grid" id="core-status">
|
||||
<div class="status-grid">
|
||||
<div class="status-item">
|
||||
<div class="status-label">主框架状态</div>
|
||||
<div class="status-value" style="color: #999999">未加载</div>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<div class="status-label">时间管理器状态</div>
|
||||
<div class="status-value" style="color: #999999">未加载</div>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<div class="status-label">事件管理器状态</div>
|
||||
<div class="status-value" style="color: #999999">未加载</div>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<div class="status-label">环境管理器状态</div>
|
||||
<div class="status-value" style="color: #999999">未加载</div>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<div class="status-label">线程管理器状态</div>
|
||||
<div class="status-value" style="color: #999999">未加载</div>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<div class="status-label">模型管理器状态</div>
|
||||
<div class="status-value" style="color: #999999">未加载</div>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<div class="status-label">服务管理器状态</div>
|
||||
<div class="status-value" style="color: #999999">未加载</div>
|
||||
</div>
|
||||
<div class="status-item">
|
||||
<div class="status-label">DDS管理器状态</div>
|
||||
<div class="status-value" style="color: #999999">未加载</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="right-panel">
|
||||
|
@ -20,7 +20,7 @@ class TodoComponent extends HTMLElement {
|
||||
this.currentUser = null;
|
||||
this.editingTodo = null;
|
||||
this.isInitialized = false;
|
||||
this.showCompleted = true;
|
||||
this.showCompleted = false;
|
||||
}
|
||||
|
||||
// 初始化组件
|
||||
@ -1057,7 +1057,7 @@ class TodoComponent extends HTMLElement {
|
||||
this.currentUser = null;
|
||||
this.editingTodo = null;
|
||||
this.isInitialized = false;
|
||||
this.showCompleted = true;
|
||||
this.showCompleted = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user