@@ -5,67 +5,72 @@ export interface Archiver {
55 url : string ;
66}
77
8- export class Trace {
9- public name : string ;
10- public axis : number ;
11- public lineWidth : number ;
12- public lineStyle : number ;
13- public traceType : number ;
14- public color : Color ;
15- public pointType : number ;
16- public pointSize : number ;
17- public visible : boolean ;
18- public yPv : string ;
19- public xPv ?: string | null ;
20- public bufferSize ?: number ;
21- public plotMode ?: number ;
22- public antiAlias ?: boolean ;
23- public concatenateData ?: boolean ;
24- public updateDelay ?: number ;
25- public updateMode ?: number ;
26- public archive ?: Archiver | undefined ;
27-
28- public constructor ( {
29- name = "" ,
30- axis = 0 ,
31- lineWidth = 0 ,
32- lineStyle = 0 ,
33- traceType = 2 ,
34- color = ColorUtils . fromRgba ( 0 , 0 , 255 ) ,
35- pointType = 0 ,
36- pointSize = 1 ,
37- visible = true ,
38- xPv = "" ,
39- yPv = "" ,
40- fromOpi = false ,
41- antiAlias = true ,
42- bufferSize = 100 ,
43- concatenateData = true ,
44- updateDelay = 100 ,
45- updateMode = 0 ,
46- plotMode = 0 ,
47- archive = { name : "" , url : "" }
48- } = { } ) {
49- // xPV property only exists on XYPlot
50- if ( xPv ) this . xPv = xPv ;
51- this . yPv = yPv ;
52- this . axis = axis ;
53- this . name = name || ( yPv ? yPv : "" ) ;
54- this . lineWidth = lineWidth ;
55- this . lineStyle = lineStyle ;
56- this . traceType = traceType ;
57- this . color = color ;
58- this . pointType = pointType ;
59- this . pointSize = pointSize ;
60- this . visible = visible ;
61- if ( archive ) this . archive = archive ;
62- if ( fromOpi ) {
63- this . antiAlias = antiAlias ;
64- this . bufferSize = bufferSize ;
65- this . concatenateData = concatenateData ;
66- this . updateDelay = updateDelay ;
67- this . updateMode = updateMode ;
68- this . plotMode = plotMode ;
69- }
70- }
8+ export interface Trace {
9+ name : string ;
10+ axis : number ;
11+ lineWidth : number ;
12+ lineStyle : number ;
13+ traceType : number ;
14+ color : Color ;
15+ pointType : number ;
16+ pointSize : number ;
17+ visible : boolean ;
18+ yPv : string ;
19+ xPv ?: string | null ;
20+ bufferSize ?: number ;
21+ plotMode ?: number ;
22+ antiAlias ?: boolean ;
23+ concatenateData ?: boolean ;
24+ updateDelay ?: number ;
25+ updateMode ?: number ;
26+ archive ?: Archiver | undefined ;
7127}
28+
29+ /**
30+ * Set default values for properties not yet
31+ * set, otherwise use set property. Uses same
32+ * default values as csstudio.opibuilder.xygraph.
33+ */
34+ export const newTrace = ( config : {
35+ name ?: string ;
36+ axis ?: number ;
37+ lineWidth ?: number ;
38+ lineStyle ?: number ;
39+ traceType ?: number ;
40+ color ?: Color ;
41+ pointType ?: number ;
42+ pointSize ?: number ;
43+ visible ?: boolean ;
44+ yPv ?: string ;
45+ xPv ?: string | null ;
46+ bufferSize ?: number ;
47+ plotMode ?: number ;
48+ antiAlias ?: boolean ;
49+ concatenateData ?: boolean ;
50+ updateDelay ?: number ;
51+ updateMode ?: number ;
52+ archive ?: Archiver | undefined ;
53+ fromOpi ?: boolean ;
54+ } ) : Trace => ( {
55+ name : config . name || ( config . yPv ? config . yPv : "" ) ,
56+ axis : config . axis ?? 0 ,
57+ lineWidth : config . lineWidth ?? 0 ,
58+ lineStyle : config . lineStyle ?? 0 ,
59+ traceType : config . traceType ?? 2 ,
60+ archive : config . archive ?? { name : "" , url : "" } ,
61+ color : config . color ?? ColorUtils . fromRgba ( 0 , 0 , 255 ) ,
62+ pointType : config . pointType ?? 0 ,
63+ pointSize : config . pointSize ?? 1 ,
64+ visible : config . visible ?? true ,
65+ ...( config . xPv && { xPv : config . xPv ?? "" } ) ,
66+ yPv : config . yPv ?? "" ,
67+ // Legacy opi props
68+ ...( config . fromOpi && {
69+ antiAlias : config . antiAlias ?? true ,
70+ bufferSize : config . bufferSize ?? 100 ,
71+ concatenateData : config . concatenateData ?? true ,
72+ updateDelay : config . updateDelay ?? 100 ,
73+ updateMode : config . updateMode ?? 0 ,
74+ plotMode : config . plotMode ?? 0
75+ } )
76+ } ) ;
0 commit comments