feature/IO-3205-Paint-Scale-Integrations: Checkpoint

This commit is contained in:
Dave Richer
2025-04-28 11:29:35 -04:00
parent cf8a19575f
commit fb24eafcc8
4 changed files with 33 additions and 21 deletions

View File

@@ -373,17 +373,17 @@ app.whenReady().then(async () => {
}
});
//Dynamically load ipcMain handlers once ready.
try {
// Replace 'path/to/your/file' with the actual path to your file
const module = await import("./ipc/ipcMainConfig");
log.debug("Successfully loaded ipcMainConfig");
// You can now use anything exported from the module
// For example:
// module.someFunction()
log.debug("Successfully loaded ipcMainConfig", module);
// Initialize cron tasks after loading ipcMainConfig
await module.initializeCronTasks();
log.info("Cron tasks initialized successfully");
} catch (error) {
log.error("Failed to load ipcMainConfig", {
log.error("Failed to load ipcMainConfig or initialize cron tasks", {
...ErrorTypeCheck(error),
});
}

View File

@@ -101,6 +101,25 @@ interface GraphQLResponse {
}>;
}
const initializeCronTasks = async () => {
try {
// Fetch input and output configurations
const inputConfigs = await SettingsPaintScaleInputConfigsGet();
const outputConfigs = await SettingsPaintScaleOutputConfigsGet();
// Start input cron tasks
await handlePaintScaleInputCron(inputConfigs);
log.info("Initialized input cron tasks on app startup");
// Start output cron tasks
await handlePaintScaleOutputCron(outputConfigs);
log.info("Initialized output cron tasks on app startup");
} catch (error) {
log.error("Error initializing cron tasks on app startup:", error);
}
};
// Log all IPC messages and their payloads
const logIpcMessages = (): void => {
Object.keys(ipcTypes.toMain).forEach((key) => {
@@ -171,6 +190,7 @@ const inputTypeHandlers: Record<
(store.get("app.bodyshop") as BodyShop)?.shopname || "",
);
// TODO Clear up how to fetch API URL
const response = await axios.post(
"https://your-api-base-url/mixdata/upload",
formData,
@@ -610,4 +630,6 @@ ipcMain.on(ipcTypes.toMain.updates.download, () => {
});
});
export { initializeCronTasks };
logIpcMessages();

View File

@@ -10,12 +10,8 @@ import {
StartWatcher,
StopWatcher,
} from "../watcher/watcher";
import { PaintScaleConfig } from "./paintScale";
interface PaintScaleConfig {
id: string;
path: string | null;
type: string;
}
// Initialize paint scale input configs in store if not set
if (!Store.get("settings.paintScaleInputConfigs")) {
@@ -136,7 +132,7 @@ const SettingEmsOutFilePathSet = async (): Promise<string> => {
};
const SettingsPaintScaleInputConfigsGet = async (
_event: IpcMainInvokeEvent,
_event?: IpcMainInvokeEvent,
): Promise<PaintScaleConfig[]> => {
try {
const configs = Store.get("settings.paintScaleInputConfigs") as PaintScaleConfig[];
@@ -188,7 +184,7 @@ const SettingsPaintScaleInputPathSet = async (
};
const SettingsPaintScaleOutputConfigsGet = async (
_event: IpcMainInvokeEvent,
_event?: IpcMainInvokeEvent,
): Promise<PaintScaleConfig[]> => {
try {
const configs = Store.get("settings.paintScaleOutputConfigs") as PaintScaleConfig[];

View File

@@ -1,17 +1,11 @@
// src/types/paintScale.ts
export enum PaintScaleType {
PPG = 'PPG',
// Add other types as needed
}
export interface PaintScaleConfig {
id: string;
path: string | null;
path?: string;
type: PaintScaleType;
pollingInterval: number;
}
export const paintScaleTypeOptions = [
{ value: PaintScaleType.PPG, label: 'PPG' },
// Add other options as needed
];
}