export const boardTypes = ['ANA MM', 'MG-ANNOUNCEMENT', 'ICC MM', 'DS1 MM', 'IP', 'DCP MM'] as const; export type BoardType = typeof boardTypes[number]; export class Board { type: BoardType; code: string; hardware: string; firmware: string; ports: number; portsUsed: number; cabinet: number; slot: number; public static fromRaw(raw: RawBoard): Board { const board = new Board(); board.type = raw.Type as BoardType; board.code = raw.Code; if (raw.Vintage.length) { board.hardware = raw.Vintage.split('')[0]; // .replace('HW', ''); board.firmware = raw.Vintage.split('')[1]; // .replace('FW', ''); } const portsArray = raw.Ports.split(','); board.ports = portsArray.length; board.portsUsed = portsArray.filter((port) => port !== 'p' && port !== 'u').length; const [cabinet, slot] = raw.Number.split('V'); board.cabinet = Number(cabinet); board.slot = Number(slot); return board; } } export interface RawBoard { Code: string; Ports: string; Vintage: string; Type: string; Number: string; }