Skip to content

Commit

Permalink
Merge pull request #253 from neilenns/neilenns/issue252
Browse files Browse the repository at this point in the history
Add a blocking state to station state action
  • Loading branch information
neilenns authored Aug 21, 2024
2 parents 71ef960 + edbfb3e commit 593d53b
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 19 deletions.
33 changes: 17 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,23 @@ configure the station status action like this to show that RX is enabled and the
### Station status settings <!-- omit from toc -->

| Setting | Description | Default |
| ------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- |
| Title | The title to show on the action. Optional. | Station callsign and listen to value |
| Callsign | The callsign for the station you want to display status for. Required. | |
| Listen to | What status to display on the button, either RX, TX, or XCA. Required. | RX |
| Show last callsigns | Sets the number of last received callsigns to display, newest to oldest, and will age off after five minutes. Only supported when listen to is set to `RX` or `XCA`. If set to `0` no last received callsigns will be shown. | `0` |
| Active comms | The image to display when a transmission is actively taking place. Optional. | ![Orange background](docs/images/stationstatus-receiving.png) |
| Listening | The image to display when the station is active. Optional. | ![Green background](docs/images/stationstatus-listening.png) |
| Not listening | The image to display when the station is not currently active. Optional. | ![Black background](docs/images/stationstatus-notlistening.png) |
| Unavailable | The image to display when the station is not added in TrackAudio. Optional, defaults to a warning icon. | ![Warning icon](docs/images/stationstatus-unavailable.png) |
| Show callsign | Show the callsign on the action. | false |
| Show frequency | Show the callsign's frequency on the action. | false |
| Show last received callsign | Show the last received callsign on the action. | true |
| Show listen to | Show the listen to value on the action. | false |
| Show title | Show the title on the action. | true |
| Clear callsigns after (minutes) | How long to leave callsigns displayed before they age off. Set to 0 to persist callsigns until they are pushed by newer callsigns. | 3 minutes |
| Setting | Description | Default |
| ------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
| Title | The title to show on the action. Optional. | Station callsign and listen to value |
| Callsign | The callsign for the station you want to display status for. Required. | |
| Listen to | What status to display on the button, either RX, TX, or XCA. Required. | RX |
| Show last callsigns | Sets the number of last received callsigns to display, newest to oldest, and will age off after five minutes. Only supported when listen to is set to `RX` or `XCA`. If set to `0` no last received callsigns will be shown. | `0` |
| Active comms | The image to display when a transmission is actively taking place. Optional. | ![Orange background](docs/images/stationstatus-receiving.png) |
| Blocked | The image to display when both an aircraft and the ATC position are transmitting at the same time. Optional. | ![Green/orange gradient background](docs/images/stationstatus-blocked.png) |
| Listening | The image to display when the station is active. Optional. | ![Green background](docs/images/stationstatus-listening.png) |
| Not listening | The image to display when the station is not currently active. Optional. | ![Black background](docs/images/stationstatus-notlistening.png) |
| Unavailable | The image to display when the station is not added in TrackAudio. Optional, defaults to a warning icon. | ![Warning icon](docs/images/stationstatus-unavailable.png) |
| Show callsign | Show the callsign on the action. | false |
| Show frequency | Show the callsign's frequency on the action. | false |
| Show last received callsign | Show the last received callsign on the action. | true |
| Show listen to | Show the listen to value on the action. | false |
| Show title | Show the title on the action. | true |
| Clear callsigns after (minutes) | How long to leave callsigns displayed before they age off. Set to 0 to persist callsigns until they are pushed by newer callsigns. | 3 minutes |

## Configuring a hotline action

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions com.neil-enns.trackaudio.sdPlugin/pi/stationStatus.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@
></sdpi-file>
</sdpi-item>

<sdpi-item label="Blocked">
<sdpi-file
setting="blockedCommsImagePath"
accept="image/png, image/jpeg, image/svg+xml"
></sdpi-file>
</sdpi-item>

<sdpi-item label="Listening">
<sdpi-file
setting="listeningImagePath"
Expand Down
Binary file added docs/images/stationstatus-blocked.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/actions/stationStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ export class StationStatus extends SingletonAction<StationSettings> {
}

export interface StationSettings {
clearAfterInMinutes?: number;
blockedCommsImagePath?: string;
activeCommsImagePath?: string;
callsign?: string;
clearAfterInMinutes?: number;
lastReceivedCallsignCount?: number;
listeningImagePath?: string;
listenTo: ListenTo | null;
Expand Down
34 changes: 32 additions & 2 deletions src/controllers/stationStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ const StateColor = {
LISTENING: "#060",
NOT_LISTENING: "black",
UNAVAILABLE: "black",
BLOCKING: "yellow",
};

const defaultTemplatePath = "images/actions/stationStatus/template.svg";
const defaultUnavailableTemplatePath =
"images/actions/stationStatus/unavailable.svg";
const defaultBlockedCommsImagePath = "images/actions/stationStatus/blocked.svg";

/**
* A StationStatus action, for use with ActionManager. Tracks the settings,
* state and StreamDeck action for an individual action in a profile.
Expand All @@ -38,9 +41,11 @@ export class StationStatusController extends BaseController {
// number of callsigns to track changes.
private _lastReceivedCallsignHistory: LRUCache<string, string> | undefined;
private _lastReceivedCallsign: string | undefined = undefined;
private _notListeningImagePath?: string;
private _listeningImagePath?: string;

private _blockedCommsImagePath?: string;
private _activeCommsImagePath?: string;
private _listeningImagePath?: string;
private _notListeningImagePath?: string;
private _unavailableImagePath?: string;

/**
Expand Down Expand Up @@ -86,6 +91,21 @@ export class StationStatusController extends BaseController {
this._listeningImagePath = stringOrUndefined(newValue);
}

/**
* Returns the blockingImagePath or the default blocking image path if the
* user didn't specify a custom icon.
*/
get blockedCommsImagePath(): string {
return this._blockedCommsImagePath ?? defaultBlockedCommsImagePath;
}

/**
* Sets the activeCommsImagePath and re-compiles the SVG template if necessary.
*/
set blockedCommsImagePath(newValue: string | undefined) {
this._blockedCommsImagePath = stringOrUndefined(newValue);
}

/**
* Returns the activeCommsImagePath or the default template path if the
* user didn't specify a custom icon.
Expand Down Expand Up @@ -282,6 +302,7 @@ export class StationStatusController extends BaseController {
}

this.activeCommsImagePath = newValue.activeCommsImagePath;
this.blockedCommsImagePath = newValue.blockedCommsImagePath;
this.listeningImagePath = newValue.listeningImagePath;
this.notListeningImagePath = newValue.notListeningImagePath;
this.unavailableImagePath = newValue.unavailableImagePath;
Expand Down Expand Up @@ -483,6 +504,15 @@ export class StationStatusController extends BaseController {
return;
}

if (this.isReceiving && this.isTransmitting) {
this.setImage(this.blockedCommsImagePath, {
...replacements,
stateColor: StateColor.BLOCKING,
state: "blocking",
});
return;
}

if (this.isReceiving || this.isTransmitting) {
this.setImage(this.activeCommsImagePath, {
...replacements,
Expand Down

0 comments on commit 593d53b

Please sign in to comment.