Commit d194a39f authored by Cloud's avatar Cloud

Resolve stash pop conflicts in modelicaExporter.js with camelCase instance names

parent 231f4574
......@@ -87,6 +87,7 @@ export function exportToModelica(data, modelName = 'Circuit') {
}
});
const usedPackages = new Set();
// 占位 — 后续回填 import 语句
const importInsertIdx = lines.length;
......@@ -95,7 +96,7 @@ export function exportToModelica(data, modelName = 'Circuit') {
nodes.forEach((node, idx) => {
const td = node.data?.templateData;
const type = td?.type;
const label = node.data?.label || `comp_${idx}`;
const label = node.data?.label || '';
const mapping = getModelMapping(type);
......@@ -104,8 +105,11 @@ export function exportToModelica(data, modelName = 'Circuit') {
if (mapping && mapping.modelName) {
baseName = mapping.modelName.charAt(0).toLowerCase() + mapping.modelName.slice(1);
} else {
baseName = toMoId(label);
const safeLabel = label || (type || 'comp');
baseName = safeLabel.replace(/[-_]([a-zA-Z])/g, (_, c) => c.toUpperCase());
baseName = toMoId(baseName); // Enforce valid Mo ID
}
// 按 baseName 分组计数,生成唯一序号
if (!instanceCounter[baseName]) instanceCounter[baseName] = 0;
instanceCounter[baseName]++;
......@@ -193,6 +197,7 @@ export function exportToModelica(data, modelName = 'Circuit') {
// 插入组件声明
declLines.forEach(l => lines.push(l));
lines.push('');
// ===== 2. 构建流程节点端口到连接源的映射 =====
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment