修复了编辑非数组变量时不能修改的错误;
修改了导入数据时变量类型不支持时的替换操作
This commit is contained in:
parent
1e07a82611
commit
a9a4b1832e
Binary file not shown.
@ -179,6 +179,10 @@ class VariableForm extends HTMLElement {
|
||||
e.preventDefault();
|
||||
|
||||
const formData = new FormData(form);
|
||||
const isArray = formData.get('interfaceIsArray') ? 1 : 0;
|
||||
const arraySize1 = parseInt(formData.get('interfaceArraySize_1')) || 0;
|
||||
const arraySize2 = parseInt(formData.get('interfaceArraySize_2')) || 0;
|
||||
|
||||
const data = {
|
||||
SystemName: 'XNSim',
|
||||
ProductName: formData.get('productName'),
|
||||
@ -187,9 +191,9 @@ class VariableForm extends HTMLElement {
|
||||
InterfaceName: formData.get('interfaceName'),
|
||||
InterfaceType: formData.get('interfaceType'),
|
||||
InterfaceOption: 1,
|
||||
InterfaceIsArray: formData.get('interfaceIsArray') ? 1 : 0,
|
||||
InterfaceArraySize_1: formData.get('interfaceArraySize_1'),
|
||||
InterfaceArraySize_2: formData.get('interfaceArraySize_2'),
|
||||
InterfaceIsArray: isArray,
|
||||
InterfaceArraySize_1: isArray && arraySize1 > 1 ? arraySize1 : 0,
|
||||
InterfaceArraySize_2: isArray && arraySize1 > 1 ? arraySize2 : 0,
|
||||
InterfaceNotes: formData.get('interfaceNotes')
|
||||
};
|
||||
|
||||
|
@ -41,6 +41,22 @@ function parseArrayDimensions(dimensions) {
|
||||
return { isArray: false, arraySize1: 0, arraySize2: 0 };
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理变量类型替换规则
|
||||
* @param {string} type - 原始变量类型
|
||||
* @returns {string} 替换后的变量类型
|
||||
*/
|
||||
function processVariableType(type) {
|
||||
if (!type) return '';
|
||||
|
||||
const typeMap = {
|
||||
'unsigned char': 'char',
|
||||
'int': 'long'
|
||||
};
|
||||
|
||||
return typeMap[type] || type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析单个工作表
|
||||
* @param {Object} worksheet - Excel工作表对象
|
||||
@ -60,7 +76,7 @@ function parseWorksheet(worksheet, structName) {
|
||||
isArray: dimensions.isArray,
|
||||
arraySize1: dimensions.arraySize1,
|
||||
arraySize2: dimensions.arraySize2,
|
||||
variableType: row['Variable Type'] || ''
|
||||
variableType: processVariableType(row['Variable Type'] || '')
|
||||
};
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user