Skip to content

Commit

Permalink
Merge pull request #884 from intechstudio/feat/MultiRuntime
Browse files Browse the repository at this point in the history
Added multiple runtime handling
  • Loading branch information
SukuWc authored Jan 6, 2025
2 parents c0f980a + 92b56c6 commit 8128f49
Show file tree
Hide file tree
Showing 56 changed files with 2,234 additions and 2,062 deletions.
7 changes: 0 additions & 7 deletions src/electron/ipcmain_serialport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ const RECONNECT_INTERVAL = 1000;

let port_disovery_interval;

/* const setIntervalAsync = (fn, ms) => {
fn().then(() => {
port_disovery_interval = setTimeout(() => setIntervalAsync(fn, ms), ms);
});
};
*/

// Basic serial usage
async function attemptSerialConnection() {
if (serial.mainWindow !== undefined) {
Expand Down
23 changes: 10 additions & 13 deletions src/renderer/App.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script>
<script lang="ts">
import { modal } from "./main/modals/modal.store";
import "./preload-window-config";
Expand Down Expand Up @@ -29,7 +29,7 @@
import { watchResize } from "svelte-watch-resize";
import { debug_lowlevel_store } from "./main/panels/WebsocketMonitor/WebsocketMonitor.store";
import { runtime, logger } from "./runtime/runtime.store";
import { logger } from "./runtime/runtime.store";
import MiddlePanelContainer from "./main/MiddlePanelContainer.svelte";
import { addPackageAction, removePackageAction } from "./lib/_configs";
Expand All @@ -39,9 +39,10 @@
reduced_motion_store,
} from "../renderer/runtime/animations";
import { instructions } from "./serialport/instructions";
import VersionUpdateBar from "./main/VersionUpdateBar.svelte";
import "redefine-custom-elements";
import { runtime_manager } from "./runtime/runtime-manager.store";
import { get } from "svelte/store";
console.log("Hello from Svelte main.js");
Expand Down Expand Up @@ -109,15 +110,11 @@
}
case "execute-lua-script":
console.log(`Sending script: ${data.script}`);
instructions
.sendImmediateToGrid(
data.targetDx ?? -127,
data.targetDy ?? -127,
data.script
)
.catch((e) => {
console.warn(e);
});
runtime_manager.LUAExecImmediate(
data.targetDx ?? -127,
data.targetDy ?? -127,
data.script
);
break;
case "add-action": {
addPackageAction({
Expand All @@ -131,7 +128,7 @@
break;
}
case "change-page": {
runtime.change_page(data.num);
get(runtime_manager).active.runtime.change_page(data.num);
break;
}
case "persist-github-package": {
Expand Down
21 changes: 5 additions & 16 deletions src/renderer/config-blocks/LedColor.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script lang="ts" context="module">
import { runtime } from "./../runtime/runtime.store";
import type { ActionBlockInformation } from "./ActionBlockInformation.ts";
// Component for the untoggled "header" of the component
import RegularActionBlockFace from "./headers/RegularActionBlockFace.svelte";
Expand Down Expand Up @@ -48,19 +47,18 @@ A -> B : AB-First step
*/
import { onMount, createEventDispatcher, onDestroy } from "svelte";
import { onMount, createEventDispatcher } from "svelte";
import { MeltCombo } from "@intechstudio/grid-uikit";
import { GridScript } from "@intechstudio/grid-protocol";
import Toggle from "../main/user-interface/Toggle.svelte";
import { get } from "svelte/store";
import { ElementType } from "@intechstudio/grid-protocol";
import SendFeedback from "../main/user-interface/SendFeedback.svelte";
import { Validator } from "./_validators";
import { Script } from "./_script_parsers.js";
import { LocalDefinitions, user_input } from "../runtime/runtime.store";
import { GridEvent } from "./../runtime/runtime";
import { LocalDefinitions } from "../runtime/runtime.store";
import { GridAction, GridElement, GridEvent } from "./../runtime/runtime";
export let config;
export let config: GridAction;
export let index;
let event = config.parent as GridEvent;
Expand Down Expand Up @@ -155,13 +153,7 @@ A -> B : AB-First step
});
suggestions = _suggestions.map((s, i) => {
if (i === 1) {
const ui = get(user_input);
const target = runtime.findElement(
ui.dx,
ui.dy,
ui.pagenumber,
ui.elementnumber
);
const target = event.parent as GridElement;
switch (target.type) {
case ElementType.BUTTON:
return [
Expand Down Expand Up @@ -473,9 +465,6 @@ A -> B : AB-First step
sendData();
}
let suggestionElement1 = undefined;
let suggestionElement2 = undefined;
</script>

<svelte:window bind:innerWidth={sidebarWidth} />
Expand Down
21 changes: 4 additions & 17 deletions src/renderer/config-blocks/LedPhase.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,15 @@
</script>

<script lang="ts">
import { onMount, createEventDispatcher, onDestroy } from "svelte";
import { onMount, createEventDispatcher } from "svelte";
import { MeltCombo } from "@intechstudio/grid-uikit";
import { GridScript } from "@intechstudio/grid-protocol";
import { Script } from "./_script_parsers.js";
import {
LocalDefinitions,
runtime,
user_input,
} from "../runtime/runtime.store";
import { LocalDefinitions } from "../runtime/runtime.store";
import { Validator } from "./_validators";
import { get } from "svelte/store";
import { ElementType } from "@intechstudio/grid-protocol";
import { GridEvent } from "./../runtime/runtime";
import { GridElement, GridEvent } from "./../runtime/runtime";
export let config;
export let index;
Expand Down Expand Up @@ -135,13 +130,7 @@
});
suggestions = _suggestions.map((s, i) => {
if (i === 1) {
const ui = get(user_input);
const target = runtime.findElement(
ui.dx,
ui.dy,
ui.pagenumber,
ui.elementnumber
);
const target = event.parent as GridElement;
switch (target.type) {
case ElementType.BUTTON:
return [
Expand Down Expand Up @@ -175,8 +164,6 @@
onMount(() => {
updateSuggestions();
});
let suggestionElement = undefined;
</script>

<config-led-phase
Expand Down
23 changes: 16 additions & 7 deletions src/renderer/config-blocks/Macro.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,15 @@
};
</script>

<script>
<script lang="ts">
/* ========== Macro block documentation ==========
1. Detect key press
2. Display the key assuming layout is English-US
3. Assembly the grid command parameters
4. Send changes to grid
*/
import { runtime } from "../runtime/runtime.store";
import { createEventDispatcher, onDestroy, onMount } from "svelte";
import { createEventDispatcher, onMount } from "svelte";
import { clickOutside } from "../main/_actions/click-outside.action";
Expand All @@ -61,6 +59,13 @@
import * as keyMap_de from "../../external/macro/map-de.json";
import { MoltenPushButton } from "@intechstudio/grid-uikit";
import {
GridAction,
GridElement,
GridEvent,
GridPage,
GridRuntime,
} from "../runtime/runtime";
const layouts = [
{ name: "En", lookup: keyMap_en.default },
Expand All @@ -70,10 +75,14 @@
let layout = layouts[0];
export let config;
export let config: GridAction;
export let index;
export let eventInfo;
export let elementInfo;
let event = config.parent as GridEvent;
let element = event.parent as GridElement;
let page = element.parent as GridPage;
let module = page.parent as GridModule;
let runtime = module.parent as GridRuntime;
let macroInputField;
Expand Down
13 changes: 13 additions & 0 deletions src/renderer/lib/_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,17 @@ export class Grid {
// Check if all stacks are empty, meaning all parentheses are closed correctly
return [...stacks.values()].every((stack) => stack.length === 0);
}

static getClosestEvent(events: number[], event: number) {
if (events.map((e) => Number(e)).includes(Number(event))) {
return event;
}

//Select closest event type if incoming device does not have the corrently selected event type
const closestEvent = Math.min(
...events.map((e) => Number(e)).filter((e) => e > 0)
);

return closestEvent !== Infinity ? closestEvent : 0;
}
}
18 changes: 11 additions & 7 deletions src/renderer/main/FirmwareCheck.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script>
<script lang="ts">
import { get } from "svelte/store";
/*
STATE 0 | No notification (Init state)
Expand All @@ -11,14 +11,11 @@ STATE 6 | Error | Button -> STATE 0 (Close notification)
*/
import { onMount } from "svelte";
import { appSettings } from "../runtime/app-helper.store";
import { runtime } from "../runtime/runtime.store";
import { fade } from "svelte/transition";
import { escape } from "svelte/internal";
import { Analytics } from "../runtime/analytics.js";
import { runtime_manager } from "../runtime/runtime-manager.store";
import { GridRuntime } from "../runtime/runtime";
const configuration = window.ctxProcess.configuration();
Expand Down Expand Up @@ -47,6 +44,13 @@ STATE 6 | Error | Button -> STATE 0 (Close notification)
};
// check for parsed modules
let runtime: GridRuntime;
$: {
runtime = $runtime_manager.active.runtime;
$appSettings.firmwareNotificationState = 0;
}
$: {
let firmwareMismatchFound = false;
Expand All @@ -60,7 +64,7 @@ STATE 6 | Error | Button -> STATE 0 (Close notification)
}
// check modules for firmware mismatch
runtime.modules.forEach((device) => {
$runtime.modules.forEach((device) => {
if ($appSettings.firmwareNotificationState == 6) {
$appSettings.firmwareNotificationState = 0;
uploadProgressText = "";
Expand Down
14 changes: 9 additions & 5 deletions src/renderer/main/MiddlePanelContainer.svelte
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
<script>
import { derived } from "svelte/store";
<script lang="ts">
import CursorLog from "./user-interface/cursor-log/CursorLog.svelte";
import Tracker from "./user-interface/Tracker.svelte";
import ActiveChanges from "./user-interface/ActiveChanges.svelte";
import ModulConnectionDialog from "./user-interface/ModulConnectionDialog.svelte";
import { fade, blur, fly } from "svelte/transition";
import { runtime } from "../runtime/runtime.store";
import { writeBuffer } from "../runtime/engine.store.ts";
import { appSettings } from "../runtime/app-helper.store";
import GridLayout from "./grid-layout/GridLayout.svelte";
import ModuleHangingDialog from "./user-interface/ModuleHangingDialog.svelte";
import StickyContainer from "./user-interface/StickyContainer.svelte";
import { onDestroy, onMount } from "svelte";
import ControlSurface from "./panels/configuration/components/ControlSurface.svelte";
import { runtime_manager } from "../runtime/runtime-manager.store";
import { GridRuntime } from "../runtime/runtime";
let logLength = 0;
let trackerVisible = true;
Expand All @@ -29,7 +28,10 @@
let showFixedStickyContainer = false;
let gridLayout;
function handleResize(e) {
let runtime: GridRuntime;
$: runtime = $runtime_manager.active.runtime;
function handleResize() {
const stickyContainer = document.getElementById("sticky-container");
const container = document.getElementById("container");
const contRect = container.getBoundingClientRect();
Expand Down Expand Up @@ -64,6 +66,7 @@
let showModuleHangingDialog = false;
let moduleHangingTimeout = undefined;
/*
const pendingActions = derived(writeBuffer, ($writeBuffer) => {
return $writeBuffer.filter((e) => e.descr.class_name !== "HEARTBEAT");
});
Expand All @@ -82,6 +85,7 @@
showModuleHangingDialog = false;
}
}
*/
</script>

<div
Expand Down
Loading

0 comments on commit 8128f49

Please sign in to comment.