types/src/types/config.ts

232 lines
4.1 KiB
TypeScript

export enum Switches {
YES = 'Yes',
NO = 'No',
ON = 'On',
OFF = 'Off',
}
export interface Field {
title: string;
name: string;
condition?: string;
}
export interface Panel {
layout: string;
panels?: {
[name: string]: Panel;
};
fields?: Field[];
condition?: string;
}
export interface Dialog {
title: string;
layout: string;
help?: string;
panels: {
[name: string]: Panel;
};
fields: Field[];
// TODO:
// settingSelector
// commandButton
}
export interface Dialogs {
[name: string]: Dialog;
}
export interface GroupChildMenu {
title: string;
condition: string;
}
export interface SubMenu {
type: 'subMenu';
title: string;
page: number;
condition: string;
}
export interface GroupMenu {
type: 'groupMenu';
title: string;
groupChildMenus: {
[name: string]: GroupChildMenu;
};
}
export interface Menu {
title: string;
subMenus: {
[name: string]: SubMenu | GroupMenu;
};
}
export interface Menus {
[name: string]: Menu;
}
export interface ArrayShape {
columns: number;
rows: number;
}
export enum ConstantTypes {
SCALAR = 'scalar',
BITS = 'bits',
ARRAY = 'array',
STRING = 'string',
}
export type ConstantSize = 'U08' | 'S08' | 'U16' | 'S16' | 'U32' | 'S32' | 'S64' | 'F32' | 'ASCII';
export interface ScalarConstant {
type: ConstantTypes.SCALAR;
size: ConstantSize;
offset?: number;
units: string;
scale: number | string;
transform: number | string;
min: number | string;
max: number | string;
digits: number;
}
export interface BitsConstant {
type: ConstantTypes.BITS;
size: ConstantSize;
offset?: number;
address: number[];
values: string[];
}
export interface ArrayConstant {
type: ConstantTypes.ARRAY;
size: ConstantSize;
offset?: number;
shape: ArrayShape;
units: string;
scale: number | string;
transform: number | string;
min: number | string;
max: number | string;
digits: number;
}
export interface StringConstant {
type: ConstantTypes.SCALAR;
size: ConstantSize;
length: number;
}
export interface OutputChannel {
type: ConstantTypes.SCALAR | ConstantTypes.BITS;
size: ConstantSize;
offset: number;
units: string;
scale: number | string;
transform: number | string;
}
export interface SimpleConstant {
value: string;
}
export type Constant = ScalarConstant | BitsConstant | ArrayConstant | StringConstant;
export interface Constants {
[name: string]: Constant;
}
export interface Page {
number: number;
size: number;
data: Constants;
}
export interface Help {
[key: string]: string;
}
export interface Curve {
title: string;
labels: string[];
xAxis: number[];
yAxis: number[];
xBins: string[];
yBins: string[];
size: number[];
gauge?: string;
}
export interface Table {
map: string;
title: string;
page: number;
help?: string;
xBins: string[];
yBins: string[];
xyLabels: string[];
zBins: string[];
gridHeight: number;
gridOrient: number[];
upDownLabel: string[];
}
export interface OutputChannels {
[name: string]: OutputChannel | SimpleConstant;
}
export interface DatalogEntry {
name: string;
label: string;
type: 'int' | 'float';
format: string;
condition: string;
}
export interface Config {
[key: string]: any;
megaTune: {
// rome-ignore lint/suspicious/noRedeclare: <explanation>
[key: string]: any;
signature: string;
MTversion: number;
queryCommand: string;
versionInfo: string;
};
tunerStudio: {
// rome-ignore lint/suspicious/noRedeclare: <explanation>
[key: string]: any;
iniSpecVersion: number;
};
pcVariables: Constants;
constants: {
pages: Page[];
};
defines: {
[name: string]: string[];
};
menus: Menus;
help: Help;
dialogs: {
// rome-ignore lint/suspicious/noRedeclare: <explanation>
[name: string]: Dialog;
};
curves: {
// rome-ignore lint/suspicious/noRedeclare: <explanation>
[name: string]: Curve;
};
tables: {
// rome-ignore lint/suspicious/noRedeclare: <explanation>
[name: string]: Table;
};
outputChannels: OutputChannels;
datalog: {
// rome-ignore lint/suspicious/noRedeclare: <explanation>
[name: string]: DatalogEntry;
};
}