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