Skip to content

Commit

Permalink
refactor: rename config fields for more semantically sound names
Browse files Browse the repository at this point in the history
  • Loading branch information
Zakrok09 committed Aug 29, 2024
1 parent e2c163e commit fe6e2d0
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 40 deletions.
13 changes: 0 additions & 13 deletions packages/serpenta/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion packages/serpenta/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
"svelte": "^4.2.7",
"svelte-check": "^3.6.0",
"tailwindcss": "3.4.3",
"tsdoc-markdown": "^0.6.0",
"typescript": "^5.0.0",
"typescript-eslint": "^8.0.0",
"vite": "^5.0.11",
Expand Down
24 changes: 9 additions & 15 deletions packages/serpenta/src/lib/appShell/SerpentaConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,46 +19,40 @@ export interface SerpentaConfig {
latest_timestamp?: Writable<number>;

generic_command_name?: string;
stores?: {
fsm_name?: string;
};
fsm_store_name?: string;
}

export interface FinalizedContext {
appWindow: any;
pod_name: string;

grand_data_distributor: DataDistributor;
data_distributor: DataDistributor;
window_engine: WindowEngine<any>;
command_invocation: CommandInvocation;
grand_charter: Writable<Map<string, PlotBuffer>>;

big_error: Writable<ErrorStatus>;
error_status: Writable<ErrorStatus>;
latest_timestamp: Writable<number>;

generic_command_name: string;
stores: {
fsm_name: string;
};
pod_command_name: string;
fsm_store_name: string;
}

export function defineConfig(config: SerpentaConfig): FinalizedContext {
return {
appWindow: config.appWindow,
pod_name: config.pod_name,

grand_data_distributor: config.grand_data_distributor,
data_distributor: config.grand_data_distributor,
window_engine: config.window_engine,
command_invocation: config.command_invocation,
grand_charter: config.grand_charter || writable(new Map<string, PlotBuffer>()),

big_error: config.big_error || writable<ErrorStatus>(ErrorStatus.SAFE),
error_status: config.big_error || writable<ErrorStatus>(ErrorStatus.SAFE),
latest_timestamp: config.latest_timestamp || writable<number>(0),

generic_command_name: config.generic_command_name || "send_command",
stores: {
fsm_name: config.stores?.fsm_name || "FSMState"
}
pod_command_name: config.generic_command_name || "send_command",
fsm_store_name: config.fsm_store_name || "FSMState"
};
}

Expand Down
5 changes: 2 additions & 3 deletions packages/serpenta/src/lib/appShell/SerpentaShell.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script lang="ts">
import { initializeStores, Modal, Toast } from "@skeletonlabs/skeleton";
import { BottomBar, TitleBar } from "$lib";
import { onDestroy, setContext } from "svelte";
Expand All @@ -8,12 +7,12 @@
export let config: FinalizedContext;
setContext<FinalizedContext>("serpenta-context", config);
config.grand_data_distributor.start(50);
config.data_distributor.start(50);
initializeStores();
onDestroy(async () => {
config.grand_data_distributor.kill();
config.data_distributor.kill();
});
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
const commandInvoker = context.command_invocation;
let send = async () => {
await commandInvoker.invokeCommand<void>(context.generic_command_name, { cmdName: cmd, val })
await commandInvoker.invokeCommand<void>(context.pod_command_name, { cmdName: cmd, val })
.then(returned => {
console.log(`Command ${cmd} sent with val: ${val}`);
successCallback(returned);
Expand Down
2 changes: 1 addition & 1 deletion packages/serpenta/src/lib/components/data/Store.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
const context = getSerpentaContext();
const latestTimestamp = context.latest_timestamp;
const gdd: DataDistributor = context.grand_data_distributor;
const gdd: DataDistributor = context.data_distributor;
const STALE_DATA_TICKS = 10_000;
export let datatype: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/serpenta/src/lib/components/graphic/FSM.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { onDestroy, onMount } from "svelte";
import { getSerpentaContext } from "$lib";
const gdd = getSerpentaContext().grand_data_distributor;
const gdd = getSerpentaContext().data_distributor;
let boot_state: SVGGElement;
let est_con_state: SVGGElement;
Expand Down
6 changes: 3 additions & 3 deletions packages/serpenta/src/lib/components/page/BottomBar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import type { Writable } from "svelte/store";
const context = getSerpentaContext();
const gdd: DataDistributor = context.grand_data_distributor;
const bigErrorStatus: Writable<ErrorStatus> = context.big_error;
const fsmStateName: string = context.stores.fsm_name;
const gdd: DataDistributor = context.data_distributor;
const bigErrorStatus: Writable<ErrorStatus> = context.error_status;
const fsmStateName: string = context.fsm_store_name.fsm_name;
const podName: string = context.pod_name;
let time = new Date().toLocaleTimeString([], {
Expand Down
4 changes: 2 additions & 2 deletions packages/serpenta/src/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Reexport your entry components here
import CommandButton from "$lib/components/control/CommandButton.svelte";
import TauriCommandButton from "$lib/components/control/TauriCommandButton.svelte";
import CommandButton from "$lib/components/control/PodCommandButton.svelte";
import TauriCommandButton from "$lib/components/control/BackendCommandButton.svelte";
import ToggleCommandButton from "$lib/components/control/ToggleCommandButton.svelte";
import Status from "$lib/components/data/Status.svelte";
import Battery from "$lib/components/graphic/Battery.svelte";
Expand Down

0 comments on commit fe6e2d0

Please sign in to comment.