Skip to content

Commit

Permalink
Merge branch 'feature/config-file-format'
Browse files Browse the repository at this point in the history
  • Loading branch information
porst17 committed Mar 25, 2024
2 parents 6eab407 + 563b08c commit f31973c
Show file tree
Hide file tree
Showing 13 changed files with 664 additions and 29 deletions.
File renamed without changes.
2 changes: 2 additions & 0 deletions config/general.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
general:
backgroundImage: config/assets/background.webp
172 changes: 172 additions & 0 deletions config/interaction.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
interaction:
slotActivationDelay: 1
slotDeactivationDelay: 1
slotGroups:
- id: technology
type: action-card
slots:
- {
id: technology-1,
x: 0,
y: 0,
angle: 0,
card: { x: 0, y: 0, angle: 0 },
}
- {
id: technology-2,
x: 0,
y: 0,
angle: 0,
card: { x: 0, y: 0, angle: 0 },
}
- {
id: technology-3,
x: 0,
y: 0,
angle: 0,
card: { x: 0, y: 0, angle: 0 },
}
cards:
- id: technology-card-1
url: technology-card-1.png
title:
en: 'T-Tech-en-1'
de: 'T-Tech-de-1'
description:
en: 'D-Tech-en-1'
de: 'D-Tech-de-1'
- id: technology-card-2
url: technology-card-2.png
title:
en: 'T-Tech-en-2'
de: 'T-Tech-de-2'
description:
en: 'D-Tech-en-2'
de: 'D-Tech-de-2'
- id: technology-card-3
url: technology-card-3.png
title:
en: 'T-Tech-en-3'
de: 'T-Tech-de-3'
description:
en: 'D-Tech-en-3'
de: 'D-Tech-de-3'
- id: technology-card-4
url: technology-card-4.png
title:
en: 'T-Tech-en-4'
de: 'T-Tech-de-4'
description:
en: 'D-Tech-en-4'
de: 'D-Tech-de-4'
- id: policy
type: action-card
slots:
- { id: policy-1, x: 0, y: 0, angle: 0, card: { x: 0, y: 0, angle: 0 } }
- { id: policy-2, x: 0, y: 0, angle: 0, card: { x: 0, y: 0, angle: 0 } }
- { id: policy-3, x: 0, y: 0, angle: 0, card: { x: 0, y: 0, angle: 0 } }
cards:
- id: policy-card-1
url: policy-card-1.png
title:
en: 'T-Pol-en-1'
de: 'T-Pol-de-1'
description:
en: 'D-Pol-en-1'
de: 'D-Pol-de-1'
- id: policy-card-2
url: policy-card-2.png
title:
en: 'T-Pol-en-2'
de: 'T-Pol-de-2'
description:
en: 'D-Pol-en-2'
de: 'D-Pol-de-2'
- id: policy-card-3
url: policy-card-3.png
title:
en: 'T-Pol-en-3'
de: 'T-Pol-de-3'
description:
en: 'D-Pol-en-3'
de: 'D-Pol-de-3'
- id: policy-card-4
url: policy-card-4.png
title:
en: 'T-Pol-en-4'
de: 'T-Pol-de-4'
description:
en: 'D-Pol-en-4'
de: 'D-Pol-de-4'
- id: event
type: event-card
slots:
- { id: event, x: 0, y: 0, angle: 0, card: { x: 0, y: 0, angle: 0 } }
cards:
- id: event-card-1
url: event-card-1.png
title:
en: 'T-Ev-en-1'
de: 'T-Ev-de-1'
description:
en: 'D-Ev-en-1'
de: 'D-Ev-de-1'
- id: event-card-2
url: event-card-2.png
title:
en: 'T-Ev-en-2'
de: 'T-Ev-de-2'
description:
en: 'D-Ev-en-2'
de: 'D-Ev-de-2'
- id: event-card-3
url: event-card-3.png
title:
en: 'T-Ev-en-3'
de: 'T-Ev-de-3'
description:
en: 'D-Ev-en-3'
de: 'D-Ev-de-3'
- id: event-card-4
url: event-card-4.png
title:
en: 'T-Ev-en-4'
de: 'T-Ev-de-4'
description:
en: 'D-Ev-en-4'
de: 'D-Ev-de-4'
- id: reduce
type: basic
slots:
- { id: reduce-1, x: 0, y: 0, angle: 0 }
- { id: reduce-2, x: 0, y: 0, angle: 0 }
- { id: reduce-3, x: 0, y: 0, angle: 0 }
parameterTransformIds: [reduce, reduce, reduce]
- id: reuse
type: basic
slots:
- { id: reuse-1, x: 0, y: 0, angle: 0 }
- { id: reuse-2, x: 0, y: 0, angle: 0 }
- { id: reuse-3, x: 0, y: 0, angle: 0 }
parameterTransformIds: [reuse, reuse, reuse]
- id: repair
type: basic
slots:
- { id: repair-1, x: 0, y: 0, angle: 0 }
- { id: repair-2, x: 0, y: 0, angle: 0 }
- { id: repair-3, x: 0, y: 0, angle: 0 }
parameterTransformIds: [repair, repair, repair]
- id: refurbish
type: basic
slots:
- { id: refurbish-1, x: 0, y: 0, angle: 0 }
- { id: refurbish-2, x: 0, y: 0, angle: 0 }
- { id: refurbish-3, x: 0, y: 0, angle: 0 }
parameterTransformIds: [refurbish, refurbish, refurbish]
- id: recycle
type: basic
slots:
- { id: recycle-1, x: 0, y: 0, angle: 0 }
- { id: recycle-2, x: 0, y: 0, angle: 0 }
- { id: recycle-3, x: 0, y: 0, angle: 0 }
parameterTransformIds: [recycle, recycle, recycle]
File renamed without changes.
File renamed without changes.
File renamed without changes.
23 changes: 23 additions & 0 deletions config/triggers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
triggers:
- id: test-1
events:
- condition:
'some condition based on the model elements (stocks, flows etc)'
url: 'url to the image'
- condition:
'some condition based on the model elements (stocks, flows etc)'
url: 'url to the image'
- condition:
'some condition based on the model elements (stocks, flows etc)'
url: 'url to the image'
- id: test-2
events:
- condition:
'some condition based on the model elements (stocks, flows etc)'
url: 'url to the image'
- condition:
'some condition based on the model elements (stocks, flows etc)'
url: 'url to the image'
- condition:
'some condition based on the model elements (stocks, flows etc)'
url: 'url to the image'
4 changes: 1 addition & 3 deletions src/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
<body>
<div id="fixed-size-container">
<div id="top-level-container">
<div id="illustration-panel">
<img src="../img/background.webp" />
</div>
<div id="illustration-panel"></div>
<div id="viz-panel">
<div id="model-viz-container"></div>
<div id="circularity-index-container" class="score">
Expand Down
9 changes: 6 additions & 3 deletions src/ts/builtin-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ import { DeepReadonly } from 'ts-essentials';

const CONFIG_BASE_URL = new URL('./config/', window.location.href);
const CONFIG_FILENAMES = [
'00-model.yaml',
'10-simulation.yaml',
'20-parameter-transforms.yaml',
'general.yaml',
'model.yaml',
'simulation.yaml',
'parameter-transforms.yaml',
'interaction.yaml',
'triggers.yaml',
] as const;

const CONFIG_URLS = CONFIG_FILENAMES.map(
Expand Down
94 changes: 88 additions & 6 deletions src/ts/config/config-schema-types.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
* - {@link https://github.com/grantila/typeconv}
*/

export interface ParameterTransform {
id: string;
script: string;
}

export interface InitialParameters {
abandonExcessRate: number;
abandonRate: number;
Expand Down Expand Up @@ -51,8 +46,88 @@ export interface InitialStocks {
supplyOfRepairedPhones: number;
}

export interface ParameterTransform {
id: string;
script: string;
}

export interface BasicSlot {
id: string;
x: number;
y: number;
angle?: number;
}

export interface BasicSlotGroup {
id: string;
type: 'basic';
slots: BasicSlot[];
parameterTransformIds: string[];
}

export interface SlotWithCard {
id: string;
x: number;
y: number;
angle?: number;
card: {
x: number;
y: number;
angle?: number;
};
}

export interface I18NString {
[key: string]: string;
}

export interface ActionCard {
id: string;
url: string;
title: I18NString;
description: I18NString;
}

export interface ActionCardSlotGroup {
id: string;
type: 'action-card';
slots: SlotWithCard[];
cards: ActionCard[];
}

export interface EventCard {
id: string;
url: string;
title: I18NString;
description: I18NString;
}

export interface EventCardSlotGroup {
id: string;
type: 'event-card';
slots: SlotWithCard[];
cards: EventCard[];
}

export type SlotGroup =
| BasicSlotGroup
| ActionCardSlotGroup
| EventCardSlotGroup;

export interface TriggerCondition {
condition: string;
url: string;
}

export interface Trigger {
id: string;
events: TriggerCondition[];
}

export interface Config {
parameterTransforms: ParameterTransform[];
general: {
backgroundImage: string;
};
model: {
initialParameters: InitialParameters;
initialStocks: InitialStocks;
Expand All @@ -61,4 +136,11 @@ export interface Config {
deltaPerSecond: number;
maxStepSize: number;
};
parameterTransforms: ParameterTransform[];
interaction: {
slotActivationDelay: number;
slotDeactivationDelay: number;
slotGroups: SlotGroup[];
};
triggers: Trigger[];
}
Loading

0 comments on commit f31973c

Please sign in to comment.