Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions src/blocks/mrc_mechanism.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export const FIELD_TYPE = 'TYPE';
type Parameter = {
name: string,
type: string,
componentId?: string,
componentPortsIndex?: number, // The zero-based number when iterating through component.ports.
};

type MechanismExtraState = {
Expand Down Expand Up @@ -105,10 +107,7 @@ const MECHANISM = {
};
extraState.parameters = [];
this.mrcParameters.forEach((arg) => {
extraState.parameters!.push({
name: arg.name,
type: arg.type,
});
extraState.parameters!.push({...arg});
});
if (this.mrcImportModule) {
extraState.importModule = this.mrcImportModule;
Expand All @@ -125,10 +124,7 @@ const MECHANISM = {
this.mrcParameters = [];
if (extraState.parameters) {
extraState.parameters.forEach((arg) => {
this.mrcParameters.push({
name: arg.name,
type: arg.type,
});
this.mrcParameters.push({...arg});
});
}
this.updateBlock_();
Expand Down Expand Up @@ -289,11 +285,15 @@ const MECHANISM = {
}
this.mrcParameters = [];
components.forEach(component => {
let componentPortsIndex = 0;
for (const port in component.ports) {
this.mrcParameters.push({
name: port,
type: component.ports[port],
componentId: component.componentId,
componentPortsIndex,
});
componentPortsIndex++;
}
});
this.updateBlock_();
Expand Down Expand Up @@ -363,13 +363,17 @@ export function createMechanismBlock(
const inputs: {[key: string]: any} = {};
let i = 0;
components.forEach(component => {
let componentPortsIndex = 0;
for (const port in component.ports) {
const parameterType = component.ports[port];
extraState.parameters?.push({
name: port,
type: parameterType,
componentId: component.componentId,
componentPortsIndex,
});
inputs['ARG' + i] = createPort(parameterType);
componentPortsIndex++;
i++;
}
});
Expand Down