diff --git a/Release/database/XNSim.db b/Release/database/XNSim.db
index ae47f18..0e2cae0 100644
Binary files a/Release/database/XNSim.db and b/Release/database/XNSim.db differ
diff --git a/XNSimHtml/components/data-monitor.js b/XNSimHtml/components/data-monitor.js
index cdb4abd..236b996 100644
--- a/XNSimHtml/components/data-monitor.js
+++ b/XNSimHtml/components/data-monitor.js
@@ -53,6 +53,7 @@ class DataMonitor extends HTMLElement {
this.initializeComponent();
// 重新启动定时器
this.startDataUpdateTimer();
+
}
async initializeComponent() {
@@ -185,13 +186,17 @@ class DataMonitor extends HTMLElement {
InterfaceName: item.InterfaceName,
ModelStructName: item.ModelStructName,
InjectValue: '',
+ InjectFrequency: 100,
monitorData: '',
- isMonitoring: false
+ isMonitoring: false,
+ isInjecting: false
});
// 创建新行
const tbody = this.shadowRoot.querySelector('.data-table tbody');
const tr = document.createElement('tr');
+ tr.setAttribute('data-interface', item.InterfaceName);
+ tr.setAttribute('data-struct', item.ModelStructName);
tr.innerHTML = `
${item.InterfaceName} |
${item.ModelStructName} |
@@ -204,146 +209,27 @@ class DataMonitor extends HTMLElement {
data-interface="${item.InterfaceName}"
data-struct="${item.ModelStructName}">
+
+
+ |
-
+
|
`;
- // 为输入框绑定事件
- const input = tr.querySelector('.inject-input');
- input.addEventListener('input', (e) => {
- const value = e.target.value;
- const interfaceName = e.target.dataset.interface;
- const modelStructName = e.target.dataset.struct;
-
- // 检查接口类型
- const isArray = this.isInterfaceArray(interfaceName, modelStructName);
-
- // 只允许数字、小数点、负号和逗号
- const validValue = value.replace(/[^0-9.,-]/g, '');
- if (value !== validValue) {
- e.target.value = validValue;
- }
-
- // 验证格式
- const isValid = this.validateInjectValue(validValue, isArray, interfaceName, modelStructName);
- e.target.classList.toggle('invalid', !isValid);
-
- // 实时更新表格数据
- const row = this.tableData.find(r =>
- r.InterfaceName === interfaceName &&
- r.ModelStructName === modelStructName
- );
- if (row) {
- row.InjectValue = validValue;
- }
- });
-
- input.addEventListener('change', (e) => {
- const interfaceName = e.target.dataset.interface;
- const modelStructName = e.target.dataset.struct;
- const value = e.target.value;
-
- // 检查接口类型
- const isArray = this.isInterfaceArray(interfaceName, modelStructName);
-
- // 验证格式
- if (!this.validateInjectValue(value, isArray, interfaceName, modelStructName)) {
- e.target.value = '';
- // 清空表格数据中的注入值
- const row = this.tableData.find(r =>
- r.InterfaceName === interfaceName &&
- r.ModelStructName === modelStructName
- );
- if (row) {
- row.InjectValue = '';
- }
- return;
- }
-
- // 更新表格数据
- const row = this.tableData.find(r =>
- r.InterfaceName === interfaceName &&
- r.ModelStructName === modelStructName
- );
- if (row) {
- row.InjectValue = value;
- }
- });
-
- // 为按钮绑定事件
- const deleteButton = tr.querySelector('.action-button.delete');
- deleteButton.addEventListener('click', () => {
- this.handleDelete(item.InterfaceName, item.ModelStructName);
- });
-
- const plotButton = tr.querySelector('.action-button.plot');
- plotButton.addEventListener('click', () => {
- this.handlePlot(item.InterfaceName, item.ModelStructName);
- });
-
- const injectButton = tr.querySelector('.action-button.inject-once');
- injectButton.addEventListener('click', async () => {
- // 检查监控状态
- const statusIndicator = this.shadowRoot.getElementById('statusIndicator');
- if (!statusIndicator || !statusIndicator.classList.contains('active')) {
- return;
- }
-
- const row = this.tableData.find(r =>
- r.InterfaceName === item.InterfaceName &&
- r.ModelStructName === item.ModelStructName
- );
-
- if (!row) {
- return;
- }
-
- if (!row.InjectValue || row.InjectValue.trim() === '') {
- alert('请先输入注入值');
- return;
- }
-
- // 检查接口类型和注入值格式
- const isArray = this.isInterfaceArray(item.InterfaceName, item.ModelStructName);
- if (!this.validateInjectValue(row.InjectValue, isArray, item.InterfaceName, item.ModelStructName)) {
- alert(isArray ? '请输入正确格式的数组数据(用逗号分隔的数字)' : '请输入单个数字');
- return;
- }
-
- try {
- // 构造接口数据
- const interfaceData = {
- [item.InterfaceName]: row.InjectValue
- };
-
- // 调用注入接口
- const response = await fetch('/api/data-monitor/inject', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json'
- },
- body: JSON.stringify({
- structName: item.ModelStructName,
- interfaceNameAndData: JSON.stringify(interfaceData)
- })
- });
-
- const result = await response.json();
- if (!result.success) {
- throw new Error(result.message);
- }
- } catch (error) {
- console.error('注入失败:', error);
- alert(`注入失败: ${error.message}`);
- }
- });
-
tbody.appendChild(tr);
}
}
@@ -1069,6 +955,33 @@ class DataMonitor extends HTMLElement {
box-shadow: 0 0 0 2px rgba(255, 77, 79, 0.2);
}
+ .frequency-input {
+ width: 100%;
+ padding: 4px 8px;
+ border: 1px solid #d9d9d9;
+ border-radius: 4px;
+ font-size: 14px;
+ box-sizing: border-box;
+ }
+
+ .frequency-input:focus {
+ border-color: #1890ff;
+ outline: none;
+ box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
+ }
+
+ .frequency-input:disabled {
+ background-color: #f5f5f5;
+ cursor: not-allowed;
+ }
+
+ .action-button:disabled {
+ background-color: #f5f5f5;
+ color: #d9d9d9;
+ border-color: #d9d9d9;
+ cursor: not-allowed;
+ }
+
.floating-chart-window {
position: fixed;
width: 400px;
@@ -1140,6 +1053,22 @@ class DataMonitor extends HTMLElement {
width: 100% !important;
height: 100% !important;
}
+
+ .action-button.active {
+ background-color: #ff4d4f;
+ color: white;
+ border-color: #ff4d4f;
+ }
+
+ .action-button.active:hover {
+ background-color: #ff7875;
+ border-color: #ff7875;
+ }
+
+ .inject-input:disabled {
+ background-color: #f5f5f5;
+ cursor: not-allowed;
+ }