fix bug: initialization output events were not properly routed to the plant

This commit is contained in:
Joeri Exelmans 2025-11-01 11:34:46 +01:00
parent 3a409dfe1e
commit 5dbe51d871
2 changed files with 5 additions and 3 deletions

View file

@ -394,7 +394,6 @@ export function fire(simtime: number, t: Transition, ts: Map<string, Transition[
// transition actions // transition actions
environment = addEventParam(environment.enterScope("<transition>"), label); environment = addEventParam(environment.enterScope("<transition>"), label);
for (const action of label.actions) { for (const action of label.actions) {
console.log('environment after adding event param:', environment);
({environment, history, ...rest} = execAction(action, {environment, history, ...rest}, [t.uid])); ({environment, history, ...rest} = execAction(action, {environment, history, ...rest}, [t.uid]));
} }
environment = environment.dropScope(); environment = environment.dropScope();

View file

@ -115,6 +115,7 @@ export function coupledExecution<T extends {[name: string]: any}>(models: {[name
if (events.length > 0) { if (events.length > 0) {
const [event, ...rest] = events; const [event, ...rest] = events;
const destination = conns[model+'.'+event.name]; const destination = conns[model+'.'+event.name];
console.log(model, '.', event, destination);
if (destination === undefined) { if (destination === undefined) {
// ignore // ignore
console.log(`${model}.${event.name} goes nowhere`); console.log(`${model}.${event.name} goes nowhere`);
@ -160,11 +161,13 @@ export function coupledExecution<T extends {[name: string]: any}>(models: {[name
// @ts-ignore // @ts-ignore
state[modelName] = modelState; state[modelName] = modelState;
} }
console.log('all outputs:', allOutputs);
// 2. handle all output events (models' outputs may be inputs for each other) // 2. handle all output events (models' outputs may be inputs for each other)
let finalOutputs = []; let finalOutputs = [];
for (const [modelName, outputEvents] of allOutputs) { for (const [modelName, outputEvent] of allOutputs) {
console.log('what about', modelName, outputEvent);
let newOutputs; let newOutputs;
[newOutputs, state] = processOutputs(0, outputEvents, modelName, state); [newOutputs, state] = processOutputs(0, [outputEvent], modelName, state);
finalOutputs.push(...newOutputs); finalOutputs.push(...newOutputs);
} }
return [finalOutputs, state]; return [finalOutputs, state];