Improve EMS interfaces and add LIN decoding.

This commit is contained in:
Patrick Fic
2025-03-17 15:45:45 -07:00
parent 8cfc9ec6a6
commit c03cf5a98f
9 changed files with 414 additions and 229 deletions

View File

@@ -2,11 +2,13 @@ import log from "electron-log/main";
import path from "path";
import errorTypeCheck from "../../util/errorTypeCheck";
import DecodeAD1 from "./decode-ad1";
import { ParsedAD1 } from "./decode-ad1.interface";
import { DecodedAd1 } from "./decode-ad1.interface";
import DecodeAD2 from "./decode-ad2";
import { ParsedAD2 } from "./decode-ad2.interface";
import { DecodedAD2 } from "./decode-ad2.interface";
import DecodeLin from "./decode-lin";
import { DecodedLin } from "./decode-lin.interface";
import DecodeVeh from "./decode-veh";
import { ParsedVeh } from "./decode-veh.interface";
import { DecodedVeh } from "./decode-veh.interface";
async function ImportJob(filepath: string): Promise<void> {
const parsedFilePath = path.parse(filepath);
@@ -17,10 +19,13 @@ async function ImportJob(filepath: string): Promise<void> {
log.debug("Importing Job", extensionlessFilePath);
try {
const ad1: ParsedAD1 = await DecodeAD1(extensionlessFilePath);
const ad2: ParsedAD2 = await DecodeAD2(extensionlessFilePath);
const veh: ParsedVeh = await DecodeVeh(extensionlessFilePath);
log.debug("EMS Object", { ad1, ad2, veh });
//The below all end up returning parts of the job object.
//Some of them return additional info - e.g. owner or vehicle record data at both the job and corresponding table level.
const ad1: DecodedAd1 = await DecodeAD1(extensionlessFilePath);
const ad2: DecodedAD2 = await DecodeAD2(extensionlessFilePath);
const veh: DecodedVeh = await DecodeVeh(extensionlessFilePath);
const lin: DecodedLin[] = await DecodeLin(extensionlessFilePath);
log.debug("EMS Object", { ad1, ad2, veh, lin });
} catch (error) {
log.error("Error encountered while decoding job. ", errorTypeCheck(error));
}