Skip to content

Commit

Permalink
additional heuristic for template parsing handling multiple outputs (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mwdchang authored Oct 16, 2024
1 parent 92eee1d commit ad52b1c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/client/hmi-client/src/model-representation/mira/mira.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,12 @@ export const rawTemplatesSummary = (miraModel: MiraModel) => {
return allTemplates;
};

const generateKey = (t: TemplateSummary) => {
if (t.name.split('_').length > 1) {
return `${t.name.split('_')[0]}:${t.subject}:${t.outcome}:${t.controllers.join('-')}`;
}
return `${t.subject}:${t.outcome}:${t.controllers.join('-')}`;
};
export const collapseTemplates = (miraModel: MiraModel) => {
const allTemplates: TemplateSummary[] = [];
const uniqueTemplates: TemplateSummary[] = [];
Expand Down Expand Up @@ -279,7 +285,7 @@ export const collapseTemplates = (miraModel: MiraModel) => {
const matrixMap = new Map<string, MiraTemplate[]>();

allTemplates.forEach((t) => {
const key = `${t.subject}:${t.outcome}:${t.controllers.join('-')}`;
const key = generateKey(t);
if (!tempMatrixMap.has(key)) {
tempMatrixMap.set(key, []);
}
Expand All @@ -295,7 +301,7 @@ export const collapseTemplates = (miraModel: MiraModel) => {

// 3 Rename and sanitize everything
uniqueTemplates.forEach((t) => {
const key = `${t.subject}:${t.outcome}:${t.controllers.join('-')}`;
const key = generateKey(t);
t.name = `template-${check.get(key)}`;
});
tempMatrixMap.forEach((value, key) => {
Expand Down Expand Up @@ -425,7 +431,6 @@ export const createParameterMatrix = (miraModel: MiraModel, miraTemplateParams:
};
};

// const genKey = (t: TemplateSummary) => `${t.subject}:${t.outcome}:${t.controllers.join('-')}`;
export const convertToIGraph = (
miraModel: MiraModel,
initObservableSummary: ObservableSummary,
Expand Down

0 comments on commit ad52b1c

Please sign in to comment.