Skip to content
4 changes: 2 additions & 2 deletions src/types/axis.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ describe("Axis", () => {
autoscale: false,
minimum: 0,
maximum: 100,
scaleFont: new Font(),
titleFont: new Font(FontStyle.Bold),
scaleFont: new Font(12),
titleFont: new Font(14, FontStyle.Bold),
onRight: false,
xAxis: false
});
Expand Down
4 changes: 2 additions & 2 deletions src/types/axis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export class Axis {
autoscale = false,
minimum = 0,
maximum = 100,
titleFont = new Font(FontStyle.Bold),
scaleFont = new Font(),
titleFont = new Font(14, FontStyle.Bold),
scaleFont = new Font(12, FontStyle.Regular),
onRight = false,
fromOpi = false
} = {}) {
Expand Down
2 changes: 1 addition & 1 deletion src/types/font.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class Font {
) {
this.typeface = typeface ?? "Liberation sans";
this.style = style ?? FontStyle.Regular;
this.size = size;
this.size = size ?? 14;
this.name = name;
}

Expand Down
72 changes: 72 additions & 0 deletions src/types/plt.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { Axis } from "./axis";
import { Color } from "./color";
import { Font } from "./font";
import { Plt } from "./plt";
import { Trace } from "./trace";

describe("Plt", () => {
it("constructs the plt with values", (): void => {
const testValues = {
title: "Testing",
axes: [new Axis(), new Axis({ color: Color.RED })],
pvlist: [new Trace({ yPv: "TEST" })],
background: Color.WHITE,
foreground: Color.RED,
scroll: false,
grid: true,
scrollStep: 5,
updatePeriod: 10,
bufferSize: 2000,
titleFont: new Font(14),
labelFont: new Font(8),
legendFont: new Font(8),
scaleFont: new Font(6),
start: "10 minutes",
end: "now"
};
const plt = new Plt(testValues);
const actualValues = {
title: "Testing",
axes: [new Axis(), new Axis({ color: Color.RED })],
pvlist: [new Trace({ yPv: "TEST" })],
backgroundColor: Color.WHITE,
foregroundColor: Color.RED,
scroll: false,
showGrid: true,
scrollStep: 5,
updatePeriod: 10,
bufferSize: 2000,
titleFont: new Font(14),
labelFont: new Font(8),
legendFont: new Font(8),
scaleFont: new Font(6),
start: "10 minutes",
end: "now"
};
expect(plt).toEqual(actualValues);
expect(plt).toBeInstanceOf(Plt);
});

it("construct the trace with only defaults", (): void => {
const plt = new Plt();
expect(plt).toEqual({
axes: [new Axis()],
pvlist: [new Trace()],
title: "",
backgroundColor: Color.WHITE,
foregroundColor: Color.BLACK,
scroll: true,
showGrid: false,
scrollStep: 5,
updatePeriod: 0,
bufferSize: 5000,
titleFont: new Font(),
labelFont: new Font(),
legendFont: new Font(),
scaleFont: new Font(),
start: "1 minute",
end: "now"
});
expect(plt).toBeInstanceOf(Plt);
});
});
63 changes: 63 additions & 0 deletions src/types/plt.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { Axes, Axis } from "./axis";
import { Color } from "./color";
import { Font } from "./font";
import { Trace } from "./trace";

export class Plt {
public title: string;
public axes: Axes;
public pvlist: Trace[];
public backgroundColor: Color;
public foregroundColor: Color;
public scroll: boolean;
public scrollStep: number;
public updatePeriod: number;
public bufferSize: number;
public start: string;
public end: string;
public showGrid: boolean;
public titleFont: Font;
public scaleFont: Font;
public labelFont: Font;
public legendFont: Font;

/**
* Set default values for properties not yet
* set, otherwise use set property.
*/
public constructor({
title = "",
axes = [new Axis()],
pvlist = [new Trace()],
background = Color.WHITE,
foreground = Color.BLACK,
scroll = true,
grid = false,
scrollStep = 5,
updatePeriod = 0,
bufferSize = 5000,
titleFont = new Font(),
labelFont = new Font(),
legendFont = new Font(),
scaleFont = new Font(),
start = "1 minute",
end = "now"
} = {}) {
this.backgroundColor = background;
this.foregroundColor = foreground;
this.title = title;
this.scroll = scroll;
this.scrollStep = scrollStep;
this.axes = axes;
this.pvlist = pvlist;
this.updatePeriod = updatePeriod;
this.bufferSize = bufferSize;
this.showGrid = grid;
this.start = start;
this.end = end;
this.titleFont = titleFont;
this.scaleFont = scaleFont;
this.labelFont = labelFont;
this.legendFont = legendFont;
}
}
7 changes: 5 additions & 2 deletions src/types/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import { WidgetActions } from "../ui/widgets/widgetActions";
import { Border } from "./border";
import { Position } from "./position";
import { PV } from "./pv";
import { Trace } from "./trace";
import { Archiver, Trace } from "./trace";
import { Axes, Axis } from "./axis";
import { Points } from "./points";
import { Plt } from "./plt";

export type GenericProp =
| string
Expand All @@ -27,7 +28,9 @@ export type GenericProp =
| Trace[]
| Axes
| Axis
| Points;
| Points
| Archiver
| Plt;

export interface Expression {
boolExp: string;
Expand Down
12 changes: 10 additions & 2 deletions src/types/trace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ describe("Trace", () => {
pointSize: 10,
visible: false,
xPv: "TEST-01:PV",
yPv: "TEST-02:PV"
yPv: "TEST-02:PV",
archive: {
name: "Test",
url: "Testing.diamond.ac.uk"
}
};
const trace = new Trace(testValues);

Expand All @@ -34,7 +38,11 @@ describe("Trace", () => {
pointType: 0,
pointSize: 1,
visible: true,
yPv: ""
yPv: "",
archive: {
name: "",
url: ""
}
});
expect(trace).toBeInstanceOf(Trace);
});
Expand Down
10 changes: 9 additions & 1 deletion src/types/trace.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { Color } from "./color";

export interface Archiver {
name: string;
url: string;
}

export class Trace {
public name: string;
public axis: number;
Expand All @@ -18,6 +23,7 @@ export class Trace {
public concatenateData?: boolean;
public updateDelay?: number;
public updateMode?: number;
public archive?: Archiver | undefined;

public constructor({
name = "",
Expand All @@ -37,7 +43,8 @@ export class Trace {
concatenateData = true,
updateDelay = 100,
updateMode = 0,
plotMode = 0
plotMode = 0,
archive = { name: "", url: "" }
} = {}) {
// xPV property only exists on XYPlot
if (xPv) this.xPv = xPv;
Expand All @@ -51,6 +58,7 @@ export class Trace {
this.pointType = pointType;
this.pointSize = pointSize;
this.visible = visible;
if (archive) this.archive = archive;
if (fromOpi) {
this.antiAlias = antiAlias;
this.bufferSize = bufferSize;
Expand Down
Loading
Loading