@oicl/openbridge-webcomponents-full-bundle 2.2.0-next.18 → 2.2.0-next.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/bundle/openbridge-webcomponents.bundle.js +141 -145
  2. package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
  3. package/custom-elements.json +593 -2034
  4. package/dist/automation/automation-button/abstract-automation-button-storybook-helpers.d.ts +20 -0
  5. package/dist/automation/automation-button/abstract-automation-button-storybook-helpers.d.ts.map +1 -1
  6. package/dist/automation/automation-button/abstract-automation-button-storybook-helpers.js +1 -0
  7. package/dist/automation/automation-button/abstract-automation-button-storybook-helpers.js.map +1 -1
  8. package/dist/automation/automation-button/abstract-automation-button.d.ts +5 -5
  9. package/dist/automation/automation-button/abstract-automation-button.d.ts.map +1 -1
  10. package/dist/automation/automation-button/abstract-automation-button.js +21 -47
  11. package/dist/automation/automation-button/abstract-automation-button.js.map +1 -1
  12. package/dist/automation/automation-button/badge-layout.d.ts +5 -7
  13. package/dist/automation/automation-button/badge-layout.d.ts.map +1 -1
  14. package/dist/automation/automation-button/badge-layout.js +32 -14
  15. package/dist/automation/automation-button/badge-layout.js.map +1 -1
  16. package/dist/automation/automation-button/badge-settings-controller.d.ts +11 -0
  17. package/dist/automation/automation-button/badge-settings-controller.d.ts.map +1 -0
  18. package/dist/automation/automation-button/badge-settings-controller.js +13 -0
  19. package/dist/automation/automation-button/badge-settings-controller.js.map +1 -0
  20. package/dist/automation/automation-button/badge-symbols.d.ts +37 -0
  21. package/dist/automation/automation-button/badge-symbols.d.ts.map +1 -0
  22. package/dist/automation/automation-button/badge-symbols.js +84 -0
  23. package/dist/automation/automation-button/badge-symbols.js.map +1 -0
  24. package/dist/automation/automation-tank/automation-tank.d.ts +5 -4
  25. package/dist/automation/automation-tank/automation-tank.d.ts.map +1 -1
  26. package/dist/automation/automation-tank/automation-tank.js +13 -47
  27. package/dist/automation/automation-tank/automation-tank.js.map +1 -1
  28. package/dist/automation/specialty-tank/abstract-specialty-tank.d.ts +5 -4
  29. package/dist/automation/specialty-tank/abstract-specialty-tank.d.ts.map +1 -1
  30. package/dist/automation/specialty-tank/abstract-specialty-tank.js +14 -47
  31. package/dist/automation/specialty-tank/abstract-specialty-tank.js.map +1 -1
  32. package/dist/automation/specialty-tank/specialty-tank-story-meta.d.ts +6 -1
  33. package/dist/automation/specialty-tank/specialty-tank-story-meta.d.ts.map +1 -1
  34. package/dist/automation/specialty-tank/specialty-tank-story-meta.js +10 -0
  35. package/dist/automation/specialty-tank/specialty-tank-story-meta.js.map +1 -1
  36. package/package.json +1 -1
  37. package/src/automation/automation-button/abstract-automation-button-storybook-helpers.ts +3 -0
  38. package/src/automation/automation-button/abstract-automation-button.ts +39 -81
  39. package/src/automation/automation-button/badge-layout.ts +13 -21
  40. package/src/automation/automation-button/badge-settings-controller.ts +33 -0
  41. package/src/automation/automation-button/badge-symbols.spec.ts +203 -0
  42. package/src/automation/automation-button/badge-symbols.ts +178 -0
  43. package/src/automation/automation-tank/automation-tank.stories.ts +15 -0
  44. package/src/automation/automation-tank/automation-tank.ts +36 -73
  45. package/src/automation/heat-exchanger/heat-exchanger.stories.ts +2 -0
  46. package/src/automation/heat-pump/heat-pump.stories.ts +2 -0
  47. package/src/automation/hydraulic-separator/hydraulic-separator.stories.ts +2 -0
  48. package/src/automation/pump/pump.stories.ts +44 -0
  49. package/src/automation/specialty-tank/abstract-specialty-tank.ts +36 -73
  50. package/src/automation/specialty-tank/specialty-tank-story-meta.ts +19 -1
@@ -0,0 +1,203 @@
1
+ import {describe, it, expect, afterEach} from 'vitest';
2
+ import type {LitElement} from 'lit';
3
+ import '../pump/pump.js';
4
+ import '../automation-tank/automation-tank.js';
5
+ import '../heat-pump/heat-pump.js';
6
+ import {
7
+ AutomationButtonBadgeAlert,
8
+ AutomationButtonBadgeCommandLocked,
9
+ AutomationButtonBadgeControl,
10
+ AutomationButtonBadgeInterlock,
11
+ } from './abstract-automation-button.js';
12
+ import {ObcAutomationBadgeType as T} from '../automation-badge/automation-badge.js';
13
+ import {
14
+ AutomationBadgeSymbolOverride,
15
+ automationBadgeType,
16
+ getAutomationBadgeSymbolOverride,
17
+ mergeBadgeSymbolOverride,
18
+ setAutomationBadgeSymbolOverride,
19
+ } from './badge-symbols.js';
20
+ import {setAutomationBadgeLayout} from './badge-layout.js';
21
+
22
+ describe('automationBadgeType', () => {
23
+ it('maps every badge value to its symbol, and none to no badge', () => {
24
+ expect(automationBadgeType('control', 'auto')).toBe(T.Auto);
25
+ expect(automationBadgeType('alert', 'shelved')).toBe(T.AlertShelved);
26
+ expect(automationBadgeType('interlock', 'simulation')).toBe(T.Simulation);
27
+ expect(automationBadgeType('commandLocked', 'command-locked')).toBe(
28
+ T.CommandLocked
29
+ );
30
+ expect(automationBadgeType('commandLocked', 'none')).toBeNull();
31
+ });
32
+
33
+ it('draws the letter an override names, in either case', () => {
34
+ expect(
35
+ automationBadgeType('commandLocked', 'simulation', {
36
+ commandLocked: {simulation: 's'},
37
+ })
38
+ ).toBe(T.LetterS);
39
+ expect(
40
+ automationBadgeType('control', 'manual', {control: {manual: 'M'}})
41
+ ).toBe(T.LetterM);
42
+ });
43
+
44
+ it('keeps the symbol of a value the override leaves out', () => {
45
+ const override: AutomationBadgeSymbolOverride = {
46
+ commandLocked: {simulation: 's'},
47
+ };
48
+ expect(
49
+ automationBadgeType('commandLocked', 'command-locked', override)
50
+ ).toBe(T.CommandLocked);
51
+ expect(automationBadgeType('interlock', 'simulation', override)).toBe(
52
+ T.Simulation
53
+ );
54
+ });
55
+
56
+ it('draws no badge for a value that is not a badge value, inherited keys included', () => {
57
+ expect(
58
+ automationBadgeType('control', 'toString', {control: {auto: 'a'}})
59
+ ).toBeNull();
60
+ expect(automationBadgeType('alert', 'constructor')).toBeNull();
61
+ });
62
+
63
+ it('keeps no badge for none, whatever the override', () => {
64
+ expect(
65
+ automationBadgeType('commandLocked', 'none', {
66
+ commandLocked: {none: 'n'} as never,
67
+ })
68
+ ).toBeNull();
69
+ });
70
+ });
71
+
72
+ describe('mergeBadgeSymbolOverride', () => {
73
+ it('puts local letters on top of the global ones, value by value', () => {
74
+ expect(
75
+ mergeBadgeSymbolOverride(
76
+ {commandLocked: {simulation: 's', 'command-locked': 'c'}},
77
+ {commandLocked: {simulation: 'x'}, interlock: {simulation: 'm'}}
78
+ )
79
+ ).toEqual({
80
+ commandLocked: {simulation: 'x', 'command-locked': 'c'},
81
+ interlock: {simulation: 'm'},
82
+ });
83
+ });
84
+
85
+ it('keeps a global letter where the local value is undefined', () => {
86
+ const merged = mergeBadgeSymbolOverride(
87
+ {commandLocked: {simulation: 's'}},
88
+ {commandLocked: {simulation: undefined}}
89
+ );
90
+ expect(merged.commandLocked?.simulation).toBe('s');
91
+ });
92
+
93
+ it('lets a local null bring the symbol back', () => {
94
+ const merged = mergeBadgeSymbolOverride(
95
+ {commandLocked: {simulation: 's'}},
96
+ {commandLocked: {simulation: null}}
97
+ );
98
+ expect(automationBadgeType('commandLocked', 'simulation', merged)).toBe(
99
+ T.Simulation
100
+ );
101
+ });
102
+ });
103
+
104
+ const mounted: HTMLElement[] = [];
105
+ afterEach(() => {
106
+ mounted.splice(0).forEach((el) => el.remove());
107
+ setAutomationBadgeSymbolOverride(undefined);
108
+ setAutomationBadgeLayout(undefined);
109
+ });
110
+
111
+ type BadgeHost = LitElement & {
112
+ badgeControl: string;
113
+ badgeAlert: string;
114
+ badgeInterlock: string;
115
+ badgeCommandLocked: string;
116
+ badgeSymbolOverride?: AutomationBadgeSymbolOverride;
117
+ };
118
+
119
+ async function mount(tag: string): Promise<BadgeHost> {
120
+ const el = document.createElement(tag) as BadgeHost;
121
+ el.badgeControl = AutomationButtonBadgeControl.Auto;
122
+ el.badgeAlert = AutomationButtonBadgeAlert.Alarm;
123
+ el.badgeInterlock = AutomationButtonBadgeInterlock.Simulation;
124
+ el.badgeCommandLocked = AutomationButtonBadgeCommandLocked.Simulation;
125
+ document.body.appendChild(el);
126
+ mounted.push(el);
127
+ await el.updateComplete;
128
+ return el;
129
+ }
130
+
131
+ /** The badge types in control, alert, interlock, command-locked order. */
132
+ function badges(el: BadgeHost): string[] {
133
+ const root = el.shadowRoot!;
134
+ const typeOf = (badge: Element | null) =>
135
+ (badge as unknown as {type: string} | null)?.type ?? null;
136
+ if (root.querySelector('slot[name="badge-top-left"]')) {
137
+ return ['top-left', 'top-right', 'bottom-left', 'bottom-right']
138
+ .map((corner) =>
139
+ typeOf(
140
+ root.querySelector(
141
+ `slot[name="badge-${corner}"] obc-automation-badge`
142
+ )
143
+ )
144
+ )
145
+ .filter((type): type is string => type !== null);
146
+ }
147
+ return [...root.querySelectorAll('obc-automation-badge')].map((badge) =>
148
+ typeOf(badge)!
149
+ );
150
+ }
151
+
152
+ describe.each(['obc-pump', 'obc-automation-tank', 'obc-heat-pump'])(
153
+ 'badge symbols on %s',
154
+ (tag) => {
155
+ it('draws the symbols by default', async () => {
156
+ const el = await mount(tag);
157
+ expect(badges(el)).toEqual([T.Auto, T.Alarm, T.Simulation, T.Simulation]);
158
+ });
159
+
160
+ it('re-renders when the global override changes', async () => {
161
+ const el = await mount(tag);
162
+ setAutomationBadgeSymbolOverride({commandLocked: {simulation: 's'}});
163
+ await el.updateComplete;
164
+ expect(badges(el)).toEqual([T.Auto, T.Alarm, T.Simulation, T.LetterS]);
165
+ });
166
+
167
+ it('lets the local override win over the global one', async () => {
168
+ setAutomationBadgeSymbolOverride({
169
+ commandLocked: {simulation: 's'},
170
+ interlock: {simulation: 's'},
171
+ });
172
+ const el = await mount(tag);
173
+ el.badgeSymbolOverride = {
174
+ commandLocked: {simulation: null},
175
+ interlock: {simulation: 'm'},
176
+ };
177
+ await el.updateComplete;
178
+ expect(badges(el)).toEqual([T.Auto, T.Alarm, T.LetterM, T.Simulation]);
179
+ });
180
+
181
+ it('picks up an override set while it was detached', async () => {
182
+ const el = await mount(tag);
183
+ el.remove();
184
+ setAutomationBadgeSymbolOverride({control: {auto: 'a'}});
185
+ document.body.appendChild(el);
186
+ await el.updateComplete;
187
+ expect(badges(el)[0]).toBe(T.LetterA);
188
+ });
189
+ }
190
+ );
191
+
192
+ describe('global override', () => {
193
+ it('returns a copy, and undefined restores the symbols', () => {
194
+ setAutomationBadgeSymbolOverride({commandLocked: {simulation: 's'}});
195
+ const copy = getAutomationBadgeSymbolOverride();
196
+ copy.commandLocked!.simulation = 'x';
197
+ expect(getAutomationBadgeSymbolOverride()).toEqual({
198
+ commandLocked: {simulation: 's'},
199
+ });
200
+ setAutomationBadgeSymbolOverride(undefined);
201
+ expect(getAutomationBadgeSymbolOverride()).toEqual({});
202
+ });
203
+ });
@@ -0,0 +1,178 @@
1
+ /**
2
+ * Badge symbols of the automation devices, and letters that replace them.
3
+ *
4
+ * Maps each value of the four badge properties (`badgeControl`, `badgeAlert`,
5
+ * `badgeInterlock`, `badgeCommandLocked`) to the `obc-automation-badge` type
6
+ * it draws. An app can draw a letter instead of a symbol: for every device
7
+ * with `setAutomationBadgeSymbolOverride()`, for one device with its
8
+ * `badgeSymbolOverride` property, which wins over the app-wide one.
9
+ *
10
+ * Merge rules, per badge value:
11
+ * - a value left out keeps the letter underneath it, or the symbol,
12
+ * - `null` brings the symbol back, over an app-wide letter.
13
+ *
14
+ * ```ts
15
+ * setAutomationBadgeSymbolOverride({commandLocked: {simulation: 's'}});
16
+ * ```
17
+ *
18
+ * The buttons, `obc-automation-tank` and the specialty tanks all read this
19
+ * module, so the four enums map to the same badge everywhere.
20
+ *
21
+ * @module
22
+ */
23
+ import type {
24
+ AutomationButtonBadgeAlert,
25
+ AutomationButtonBadgeCommandLocked,
26
+ AutomationButtonBadgeControl,
27
+ AutomationButtonBadgeInterlock,
28
+ } from './abstract-automation-button.js';
29
+ import {ObcAutomationBadgeType} from '../automation-badge/automation-badge.js';
30
+ import {GlobalSetting} from '../../internal/global-setting.js';
31
+
32
+ /** The letters `obc-automation-badge` draws: `letter-a` to `letter-z`. */
33
+ type LowercaseLetter = `${ObcAutomationBadgeType}` extends infer Type
34
+ ? Type extends `letter-${infer Letter}`
35
+ ? Letter
36
+ : never
37
+ : never;
38
+
39
+ /** One letter, either case; the badge draws it as a capital. */
40
+ export type AutomationBadgeLetter =
41
+ LowercaseLetter | Uppercase<LowercaseLetter>;
42
+
43
+ /** A letter per badge value. `null` keeps the symbol. */
44
+ export type AutomationBadgeLetters<Value extends string> = Partial<
45
+ Record<Exclude<`${Value}`, 'none'>, AutomationBadgeLetter | null>
46
+ >;
47
+
48
+ /** Letters that replace badge symbols, per badge property. */
49
+ export interface AutomationBadgeSymbolOverride {
50
+ control?: AutomationBadgeLetters<AutomationButtonBadgeControl>;
51
+ alert?: AutomationBadgeLetters<AutomationButtonBadgeAlert>;
52
+ interlock?: AutomationBadgeLetters<AutomationButtonBadgeInterlock>;
53
+ commandLocked?: AutomationBadgeLetters<AutomationButtonBadgeCommandLocked>;
54
+ }
55
+
56
+ export type AutomationBadgeGroup = keyof AutomationBadgeSymbolOverride;
57
+
58
+ const groups: AutomationBadgeGroup[] = [
59
+ 'control',
60
+ 'alert',
61
+ 'interlock',
62
+ 'commandLocked',
63
+ ];
64
+
65
+ const T = ObcAutomationBadgeType;
66
+
67
+ const symbols = {
68
+ control: {
69
+ local: T.Local,
70
+ 'local-only': T.LocalOnly,
71
+ manual: T.Manual,
72
+ 'manual-only': T.ManualOnly,
73
+ auto: T.Auto,
74
+ },
75
+ alert: {
76
+ silence: T.AlertSilenced,
77
+ shelved: T.AlertShelved,
78
+ caution: T.Caution,
79
+ warning: T.Warning,
80
+ alarm: T.Alarm,
81
+ 'level-critical': T.LevelCritical,
82
+ 'level-high': T.LevelHigh,
83
+ 'level-medium': T.LevelMedium,
84
+ 'level-low': T.LevelLow,
85
+ 'level-diagnostic': T.LevelDiagnostic,
86
+ },
87
+ interlock: {
88
+ interlock: T.Interlock,
89
+ 'interlock-inhibit': T.InterlockInhibit,
90
+ simulation: T.Simulation,
91
+ },
92
+ commandLocked: {
93
+ 'command-locked': T.CommandLocked,
94
+ simulation: T.Simulation,
95
+ },
96
+ } satisfies {
97
+ [G in AutomationBadgeGroup]-?: Record<
98
+ keyof NonNullable<AutomationBadgeSymbolOverride[G]>,
99
+ ObcAutomationBadgeType
100
+ >;
101
+ };
102
+
103
+ /**
104
+ * The badge type a badge property value draws: the letter `override` names
105
+ * for it, else its symbol. `null` for `none`.
106
+ */
107
+ export function automationBadgeType(
108
+ group: AutomationBadgeGroup,
109
+ value: string,
110
+ override?: AutomationBadgeSymbolOverride
111
+ ): ObcAutomationBadgeType | null {
112
+ const table = symbols[group] as Record<string, ObcAutomationBadgeType>;
113
+ // A value from an attribute can name an inherited key such as `toString`.
114
+ if (!Object.prototype.hasOwnProperty.call(table, value)) {
115
+ return null;
116
+ }
117
+ const symbol = table[value];
118
+ const letters = override?.[group] as
119
+ Record<string, AutomationBadgeLetter | null | undefined> | undefined;
120
+ const letter = letters?.[value];
121
+ return letter
122
+ ? (`letter-${letter.toLowerCase()}` as ObcAutomationBadgeType)
123
+ : symbol;
124
+ }
125
+
126
+ /** `base` with the letters `override` names put on top of it. */
127
+ export function mergeBadgeSymbolOverride(
128
+ base: AutomationBadgeSymbolOverride | undefined,
129
+ override: AutomationBadgeSymbolOverride | undefined
130
+ ): AutomationBadgeSymbolOverride {
131
+ const result: AutomationBadgeSymbolOverride = {...base};
132
+ if (!override) {
133
+ return result;
134
+ }
135
+ for (const group of groups) {
136
+ const letters = override[group];
137
+ if (!letters) {
138
+ continue;
139
+ }
140
+ // An entry set to `undefined` is left out, like a layout corner; `null` is kept.
141
+ const merged: Record<string, AutomationBadgeLetter | null> = {
142
+ ...base?.[group],
143
+ };
144
+ for (const [value, letter] of Object.entries(letters)) {
145
+ if (letter !== undefined) {
146
+ merged[value] = letter;
147
+ }
148
+ }
149
+ Object.assign(result, {[group]: merged});
150
+ }
151
+ return result;
152
+ }
153
+
154
+ /** The app-wide letters; a device re-renders on a change through `BadgeSettingsController`. */
155
+ export const badgeSymbolOverrideSetting =
156
+ new GlobalSetting<AutomationBadgeSymbolOverride>({});
157
+
158
+ /**
159
+ * Sets the letters that replace badge symbols on every automation device on
160
+ * the page, and re-renders the ones already connected. `undefined` restores
161
+ * the symbols.
162
+ */
163
+ export function setAutomationBadgeSymbolOverride(
164
+ override: AutomationBadgeSymbolOverride | undefined
165
+ ): void {
166
+ badgeSymbolOverrideSetting.set(mergeBadgeSymbolOverride(undefined, override));
167
+ }
168
+
169
+ export function getAutomationBadgeSymbolOverride(): AutomationBadgeSymbolOverride {
170
+ return mergeBadgeSymbolOverride(undefined, badgeSymbolOverrideSetting.get());
171
+ }
172
+
173
+ /** The app-wide letters with a device's own letters on top. */
174
+ export function currentBadgeSymbolOverride(
175
+ local: AutomationBadgeSymbolOverride | undefined
176
+ ): AutomationBadgeSymbolOverride {
177
+ return mergeBadgeSymbolOverride(badgeSymbolOverrideSetting.get(), local);
178
+ }
@@ -122,6 +122,7 @@ const renderTankEl = (args: StoryArgs, slotted: unknown = nothing) => html`
122
122
  .badgeAlert=${args.badgeAlert}
123
123
  .badgeInterlock=${args.badgeInterlock}
124
124
  .badgeCommandLocked=${args.badgeCommandLocked}
125
+ .badgeSymbolOverride=${args.badgeSymbolOverride}
125
126
  .setpoint=${args.setpoint}
126
127
  .newSetpoint=${args.newSetpoint}
127
128
  .touching=${args.touching}
@@ -253,6 +254,9 @@ const meta: Meta<StoryArgs> = {
253
254
  options: Object.values(AutomationButtonBadgeCommandLocked),
254
255
  control: {type: 'select'},
255
256
  },
257
+ badgeSymbolOverride: {
258
+ control: {type: 'object'},
259
+ },
256
260
  setpoint: {
257
261
  control: {type: 'number', min: 0, max: 10_000},
258
262
  description:
@@ -298,6 +302,17 @@ export const AtmosphericWithBadges: Story = {
298
302
  },
299
303
  };
300
304
 
305
+ export const AtmosphericWithBadgeLetters: Story = {
306
+ args: {
307
+ type: TankType.atmospheric,
308
+ badgeControl: AutomationButtonBadgeControl.Auto,
309
+ badgeAlert: AutomationButtonBadgeAlert.Silence,
310
+ badgeInterlock: AutomationButtonBadgeInterlock.Simulation,
311
+ badgeCommandLocked: AutomationButtonBadgeCommandLocked.Simulation,
312
+ badgeSymbolOverride: {commandLocked: {simulation: 's'}},
313
+ },
314
+ };
315
+
301
316
  export const Pressurized: Story = {
302
317
  args: {type: TankType.pressurized},
303
318
  };
@@ -11,7 +11,12 @@ import {property, state} from 'lit/decorators.js';
11
11
  import compentStyle from './automation-tank.css?inline';
12
12
  import {LineMedium} from '../index.js';
13
13
  import '../automation-badge/automation-badge.js';
14
- import {ObcAutomationBadgeType} from '../automation-badge/automation-badge.js';
14
+ import {
15
+ AutomationBadgeSymbolOverride,
16
+ automationBadgeType,
17
+ currentBadgeSymbolOverride,
18
+ } from '../automation-button/badge-symbols.js';
19
+ import {BadgeSettingsController} from '../automation-button/badge-settings-controller.js';
15
20
  import {
16
21
  AutomationButtonBadgeAlert,
17
22
  AutomationButtonBadgeCommandLocked,
@@ -170,6 +175,7 @@ export enum TankChartMode {
170
175
  * `<obc-automation-badge>` as fallback content for the `badges` slot, so any
171
176
  * slotted content wins. The cell orders the four badges control, alert,
172
177
  * interlock, commandLocked, left to right.
178
+ * @property badgeSymbolOverride - Letters that replace badge symbols on this device, per badge property and value, on top of the app-wide ones set with `setAutomationBadgeSymbolOverride()`; for example `{commandLocked: {simulation: 's'}}`. `null` brings the symbol back.
173
179
  * @slot badges - Custom badges to be displayed in the badge area.
174
180
  * @slot tag - Text or element for the tank's tag/label.
175
181
  * @slot readout - Replaces the entire readout content block.
@@ -244,6 +250,14 @@ export class ObcAutomationTank extends AdviceMixin(SetpointMixin(LitElement)) {
244
250
  @property({type: String})
245
251
  badgeCommandLocked: AutomationButtonBadgeCommandLocked =
246
252
  AutomationButtonBadgeCommandLocked.None;
253
+ @property({attribute: false}) badgeSymbolOverride:
254
+ AutomationBadgeSymbolOverride | undefined = undefined;
255
+
256
+ constructor() {
257
+ super();
258
+ // Registers itself on the host; nothing else holds it.
259
+ new BadgeSettingsController(this);
260
+ }
247
261
 
248
262
  @state() private _cellWidth = 0;
249
263
  @state() private _cellHeight = 0;
@@ -270,74 +284,6 @@ export class ObcAutomationTank extends AdviceMixin(SetpointMixin(LitElement)) {
270
284
  return this.compact || this.static;
271
285
  }
272
286
 
273
- private _badgeAlertType(): ObcAutomationBadgeType | null {
274
- switch (this.badgeAlert) {
275
- case AutomationButtonBadgeAlert.Silence:
276
- return ObcAutomationBadgeType.AlertSilenced;
277
- case AutomationButtonBadgeAlert.Shelved:
278
- return ObcAutomationBadgeType.AlertShelved;
279
- case AutomationButtonBadgeAlert.Caution:
280
- return ObcAutomationBadgeType.Caution;
281
- case AutomationButtonBadgeAlert.Warning:
282
- return ObcAutomationBadgeType.Warning;
283
- case AutomationButtonBadgeAlert.Alarm:
284
- return ObcAutomationBadgeType.Alarm;
285
- case AutomationButtonBadgeAlert.LevelCritical:
286
- return ObcAutomationBadgeType.LevelCritical;
287
- case AutomationButtonBadgeAlert.LevelHigh:
288
- return ObcAutomationBadgeType.LevelHigh;
289
- case AutomationButtonBadgeAlert.LevelMedium:
290
- return ObcAutomationBadgeType.LevelMedium;
291
- case AutomationButtonBadgeAlert.LevelLow:
292
- return ObcAutomationBadgeType.LevelLow;
293
- case AutomationButtonBadgeAlert.LevelDiagnostic:
294
- return ObcAutomationBadgeType.LevelDiagnostic;
295
- default:
296
- return null;
297
- }
298
- }
299
-
300
- private _badgeControlType(): ObcAutomationBadgeType | null {
301
- switch (this.badgeControl) {
302
- case AutomationButtonBadgeControl.Local:
303
- return ObcAutomationBadgeType.Local;
304
- case AutomationButtonBadgeControl.LocalOnly:
305
- return ObcAutomationBadgeType.LocalOnly;
306
- case AutomationButtonBadgeControl.Manual:
307
- return ObcAutomationBadgeType.Manual;
308
- case AutomationButtonBadgeControl.ManualOnly:
309
- return ObcAutomationBadgeType.ManualOnly;
310
- case AutomationButtonBadgeControl.Auto:
311
- return ObcAutomationBadgeType.Auto;
312
- default:
313
- return null;
314
- }
315
- }
316
-
317
- private _badgeInterlockType(): ObcAutomationBadgeType | null {
318
- switch (this.badgeInterlock) {
319
- case AutomationButtonBadgeInterlock.Interlock:
320
- return ObcAutomationBadgeType.Interlock;
321
- case AutomationButtonBadgeInterlock.InterlockInhibit:
322
- return ObcAutomationBadgeType.InterlockInhibit;
323
- case AutomationButtonBadgeInterlock.Simulation:
324
- return ObcAutomationBadgeType.Simulation;
325
- default:
326
- return null;
327
- }
328
- }
329
-
330
- private _badgeCommandLockedType(): ObcAutomationBadgeType | null {
331
- switch (this.badgeCommandLocked) {
332
- case AutomationButtonBadgeCommandLocked.CommandLocked:
333
- return ObcAutomationBadgeType.CommandLocked;
334
- case AutomationButtonBadgeCommandLocked.Simulation:
335
- return ObcAutomationBadgeType.Simulation;
336
- default:
337
- return null;
338
- }
339
- }
340
-
341
287
  private get _usesGaugeTrend(): boolean {
342
288
  return (
343
289
  this.chartMode === TankChartMode.graph ||
@@ -632,10 +578,27 @@ export class ObcAutomationTank extends AdviceMixin(SetpointMixin(LitElement)) {
632
578
  // Compact and static collapse their empty cells so the tank frame absorbs
633
579
  // the space; non-compact cells sit in the inner `.grid` and always reserve
634
580
  // their min-content rows (automation-components.md § Tank rendering).
635
- const controlBadge = this._badgeControlType();
636
- const alertBadge = this._badgeAlertType();
637
- const interlockBadge = this._badgeInterlockType();
638
- const commandLockedBadge = this._badgeCommandLockedType();
581
+ const symbolOverride = currentBadgeSymbolOverride(this.badgeSymbolOverride);
582
+ const controlBadge = automationBadgeType(
583
+ 'control',
584
+ this.badgeControl,
585
+ symbolOverride
586
+ );
587
+ const alertBadge = automationBadgeType(
588
+ 'alert',
589
+ this.badgeAlert,
590
+ symbolOverride
591
+ );
592
+ const interlockBadge = automationBadgeType(
593
+ 'interlock',
594
+ this.badgeInterlock,
595
+ symbolOverride
596
+ );
597
+ const commandLockedBadge = automationBadgeType(
598
+ 'commandLocked',
599
+ this.badgeCommandLocked,
600
+ symbolOverride
601
+ );
639
602
  const hasEnumBadges =
640
603
  controlBadge !== null ||
641
604
  alertBadge !== null ||
@@ -23,4 +23,6 @@ export const Medium: SpecialtyTankStory = specialtyTankStories.Medium;
23
23
  export const Static: SpecialtyTankStory = specialtyTankStories.Static;
24
24
  export const WithoutIcon: SpecialtyTankStory = specialtyTankStories.WithoutIcon;
25
25
  export const WithBadges: SpecialtyTankStory = specialtyTankStories.WithBadges;
26
+ export const WithBadgeLetters: SpecialtyTankStory =
27
+ specialtyTankStories.WithBadgeLetters;
26
28
  export const WithAlert: SpecialtyTankStory = specialtyTankStories.WithAlert;
@@ -23,4 +23,6 @@ export const Medium: SpecialtyTankStory = specialtyTankStories.Medium;
23
23
  export const Static: SpecialtyTankStory = specialtyTankStories.Static;
24
24
  export const WithoutIcon: SpecialtyTankStory = specialtyTankStories.WithoutIcon;
25
25
  export const WithBadges: SpecialtyTankStory = specialtyTankStories.WithBadges;
26
+ export const WithBadgeLetters: SpecialtyTankStory =
27
+ specialtyTankStories.WithBadgeLetters;
26
28
  export const WithAlert: SpecialtyTankStory = specialtyTankStories.WithAlert;
@@ -23,4 +23,6 @@ export const Medium: SpecialtyTankStory = specialtyTankStories.Medium;
23
23
  export const Static: SpecialtyTankStory = specialtyTankStories.Static;
24
24
  export const WithoutIcon: SpecialtyTankStory = specialtyTankStories.WithoutIcon;
25
25
  export const WithBadges: SpecialtyTankStory = specialtyTankStories.WithBadges;
26
+ export const WithBadgeLetters: SpecialtyTankStory =
27
+ specialtyTankStories.WithBadgeLetters;
26
28
  export const WithAlert: SpecialtyTankStory = specialtyTankStories.WithAlert;
@@ -20,6 +20,7 @@ import {
20
20
  AutomationButtonBadgeKind,
21
21
  setAutomationBadgeLayout,
22
22
  } from '../automation-button/badge-layout.js';
23
+ import {setAutomationBadgeSymbolOverride} from '../automation-button/badge-symbols.js';
23
24
 
24
25
  const meta: Meta<typeof ObcPump> = {
25
26
  title: 'Automation/Automation Devices/Pump',
@@ -138,3 +139,46 @@ export const BadgeLayoutGlobal: Story = {
138
139
  },
139
140
  },
140
141
  };
142
+
143
+ const simulationBadges = {
144
+ ...allBadges,
145
+ badgeInterlock: AutomationButtonBadgeInterlock.Simulation,
146
+ badgeCommandLocked: AutomationButtonBadgeCommandLocked.Simulation,
147
+ };
148
+
149
+ export const BadgeSymbolsLocal: Story = {
150
+ args: {
151
+ ...simulationBadges,
152
+ badgeSymbolOverride: {
153
+ control: {auto: 'a'},
154
+ commandLocked: {simulation: 's'},
155
+ },
156
+ },
157
+ parameters: {
158
+ docs: {
159
+ description: {
160
+ story:
161
+ 'This pump draws A for auto and S for simulation on the command-locked corner; the interlock corner keeps the simulation cube.',
162
+ },
163
+ },
164
+ },
165
+ };
166
+
167
+ export const BadgeSymbolsGlobal: Story = {
168
+ args: simulationBadges,
169
+ beforeEach: () => {
170
+ setAutomationBadgeSymbolOverride({
171
+ interlock: {simulation: 's'},
172
+ commandLocked: {simulation: 's'},
173
+ });
174
+ return () => setAutomationBadgeSymbolOverride(undefined);
175
+ },
176
+ parameters: {
177
+ docs: {
178
+ description: {
179
+ story:
180
+ 'The app-wide override from `setAutomationBadgeSymbolOverride()` draws S for simulation on every device.',
181
+ },
182
+ },
183
+ },
184
+ };