Skip to content

Commit a79cbfb

Browse files
authored
Store component information for each parameter in mrc_mechanism blocks (#321)
* In upgrade_project.ts: Incremented version to 0.0.6. Added upgradeFrom_005_to_006. In mrc_mechanism.ts: Store component information for each parameter. * Reverted changes to upgrade_project.ts. Removed parametersHaveComponentInformation and mrcParametersHaveComponentInformation from mrc_mechanism.ts. These were set, but never actually used. Removed upgrade_005_to_006 from mrc_mechanism.ts.
1 parent 66ed284 commit a79cbfb

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/blocks/mrc_mechanism.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ export const FIELD_TYPE = 'TYPE';
4848
type Parameter = {
4949
name: string,
5050
type: string,
51+
componentId?: string,
52+
componentPortsIndex?: number, // The zero-based number when iterating through component.ports.
5153
};
5254

5355
type MechanismExtraState = {
@@ -105,10 +107,7 @@ const MECHANISM = {
105107
};
106108
extraState.parameters = [];
107109
this.mrcParameters.forEach((arg) => {
108-
extraState.parameters!.push({
109-
name: arg.name,
110-
type: arg.type,
111-
});
110+
extraState.parameters!.push({...arg});
112111
});
113112
if (this.mrcImportModule) {
114113
extraState.importModule = this.mrcImportModule;
@@ -125,10 +124,7 @@ const MECHANISM = {
125124
this.mrcParameters = [];
126125
if (extraState.parameters) {
127126
extraState.parameters.forEach((arg) => {
128-
this.mrcParameters.push({
129-
name: arg.name,
130-
type: arg.type,
131-
});
127+
this.mrcParameters.push({...arg});
132128
});
133129
}
134130
this.updateBlock_();
@@ -289,11 +285,15 @@ const MECHANISM = {
289285
}
290286
this.mrcParameters = [];
291287
components.forEach(component => {
288+
let componentPortsIndex = 0;
292289
for (const port in component.ports) {
293290
this.mrcParameters.push({
294291
name: port,
295292
type: component.ports[port],
293+
componentId: component.componentId,
294+
componentPortsIndex,
296295
});
296+
componentPortsIndex++;
297297
}
298298
});
299299
this.updateBlock_();
@@ -363,13 +363,17 @@ export function createMechanismBlock(
363363
const inputs: {[key: string]: any} = {};
364364
let i = 0;
365365
components.forEach(component => {
366+
let componentPortsIndex = 0;
366367
for (const port in component.ports) {
367368
const parameterType = component.ports[port];
368369
extraState.parameters?.push({
369370
name: port,
370371
type: parameterType,
372+
componentId: component.componentId,
373+
componentPortsIndex,
371374
});
372375
inputs['ARG' + i] = createPort(parameterType);
376+
componentPortsIndex++;
373377
i++;
374378
}
375379
});

0 commit comments

Comments
 (0)