Skip to content

Commit

Permalink
Support observed stations (#67)
Browse files Browse the repository at this point in the history
* Support observer status
Fixes #64

* More spellcheck
  • Loading branch information
neilenns authored Jan 7, 2025
1 parent 65e7ec3 commit 58c1ab1
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 11 deletions.
7 changes: 5 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,19 @@
"Addv",
"Atis",
"atisletter",
"callsign",
"elgato",
"getv",
"handlev",
"KHIO",
"KLMT",
"KPDX",
"KUAO",
"KLMT",
"streamdeck",
"Typeguard",
"Updatev",
"vatis",
"vatisstatus"
"vatisstatus",
"Verdana"
]
}
7 changes: 7 additions & 0 deletions com.neil-enns.vatis.sdPlugin/ui/atisLetter.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@
></sdpi-file>
</sdpi-item>

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

<sdpi-item label="Unavailable">
<sdpi-file
setting="unavailableImagePath"
Expand Down
1 change: 1 addition & 0 deletions src/actions/atisLetter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export interface AtisLetterSettings {
showAltimeter?: boolean;
showWind?: boolean;
currentImagePath?: string;
observerImagePath?: string;
showLetter?: boolean;
showTitle?: boolean;
station?: string;
Expand Down
43 changes: 34 additions & 9 deletions src/controllers/atisLetter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
} from "@interfaces/messages";
import TitleBuilder from "@root/utils/titleBuilder";
import { stringOrUndefined } from "@root/utils/utils";
import { BaseController } from "./baseController";
import debounce from "debounce";
import { BaseController } from "./baseController";

const defaultTemplatePath = "images/actions/atisLetter/template.svg";
const defaultUnavailableTemplatePath = "images/actions/atisLetter/template.svg";
Expand All @@ -33,6 +33,7 @@ export class AtisLetterController extends BaseController {
private _settings: AtisLetterSettings | null = null;

private _currentImagePath?: string;
private _observerImagePath?: string;
private _unavailableImagePath?: string;
private _updatedImagePath?: string;

Expand Down Expand Up @@ -122,6 +123,21 @@ export class AtisLetterController extends BaseController {
this._currentImagePath = stringOrUndefined(newValue);
}

/**
* Returns the observerImagePath or the default template path if the
* user didn't specify a custom icon.
*/
get observerImagePath(): string {
return this._observerImagePath ?? defaultTemplatePath;
}

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

/**
* Returns the updatedImagePath or the default template path if the user
* didn't specify a custom icon.
Expand Down Expand Up @@ -206,6 +222,7 @@ export class AtisLetterController extends BaseController {
this._settings = newValue;

this.currentImagePath = newValue.currentImagePath;
this.observerImagePath = newValue.observerImagePath;
this.unavailableImagePath = newValue.unavailableImagePath;
this.updatedImagePath = newValue.updatedImagePath;

Expand Down Expand Up @@ -236,7 +253,7 @@ export class AtisLetterController extends BaseController {
}

/**
* Sets the current AITS letter.
* Sets the current ATIS letter.
*/
set letter(newLetter: string | undefined) {
this._letter = newLetter;
Expand Down Expand Up @@ -325,7 +342,7 @@ export class AtisLetterController extends BaseController {
}

/**
* Enables automatic refreshing of the title and backgruond image when
* Enables automatic refreshing of the title and background image when
* properties are updated.
*/
public enableUpdates() {
Expand All @@ -337,7 +354,10 @@ export class AtisLetterController extends BaseController {
*/
private refreshImage() {
const replacements = {
isConnected: this.isConnected,
connectionStatus: this.connectionStatus,
isConnected:
this.connectionStatus === NetworkConnectionStatus.Connected ||
NetworkConnectionStatus.Observer,
isNewAtis: this.isNewAtis,
letter: this.letter,
pressure: {
Expand All @@ -350,17 +370,22 @@ export class AtisLetterController extends BaseController {
wind: this.wind,
};

if (!this.isConnected) {
this.setImage(this.unavailableImagePath, replacements);
if (this.isNewAtis) {
this.setImage(this.updatedImagePath, replacements);
return;
}

if (this.isNewAtis) {
this.setImage(this.updatedImagePath, replacements);
if (this.connectionStatus === NetworkConnectionStatus.Connected) {
this.setImage(this.currentImagePath, replacements);
return;
}

if (this.connectionStatus === NetworkConnectionStatus.Observer) {
this.setImage(this.observerImagePath, replacements);
return;
}

this.setImage(this.currentImagePath, replacements);
this.setImage(this.unavailableImagePath, replacements);
}

/**
Expand Down

0 comments on commit 58c1ab1

Please sign in to comment.