@ -51,7 +51,7 @@ import {
isUndefined ,
isUndefined ,
isUndefinedOrNull ,
isUndefinedOrNull ,
mergeDeep ,
mergeDeep ,
mergeDeepIgnoreArray ,
mergeDeepIgnoreArray , objectHashCode ,
parseFunction
parseFunction
} from '@core/utils' ;
} from '@core/utils' ;
import { BehaviorSubject , forkJoin , Observable , Observer , of , Subject } from 'rxjs' ;
import { BehaviorSubject , forkJoin , Observable , Observer , of , Subject } from 'rxjs' ;
@ -82,7 +82,7 @@ import { TbUnit } from '@shared/models/unit.models';
export interface ScadaSymbolApi {
export interface ScadaSymbolApi {
generateElementId : ( ) = > string ;
generateElementId : ( ) = > string ;
formatValue ( value : any , dec? : number , units? : string , showZeroDecimals? : boolean ) : string | undefined ;
formatValue ( value : any , dec? : number , units? : string , showZeroDecimals? : boolean ) : string | undefined ;
formatValue ( value : any , settings : ValueFormatId Settings ) : string ;
formatValue ( value : any , settings : ValueFormatSettings ) : string ;
text : ( element : Element | Element [ ] , text : string ) = > void ;
text : ( element : Element | Element [ ] , text : string ) = > void ;
font : ( element : Element | Element [ ] , font : Font , color : string ) = > void ;
font : ( element : Element | Element [ ] , font : Font , color : string ) = > void ;
icon : ( element : Element | Element [ ] , icon : string , size? : number , color? : string , center? : boolean ) = > void ;
icon : ( element : Element | Element [ ] , icon : string , size? : number , color? : string , center? : boolean ) = > void ;
@ -184,10 +184,6 @@ export interface ScadaSymbolMetadata {
properties : FormProperty [ ] ;
properties : FormProperty [ ] ;
}
}
interface ValueFormatIdSettings extends ValueFormatSettings {
id? : number ;
}
export const emptyMetadata = ( width? : number , height? : number ) : ScadaSymbolMetadata = > ( {
export const emptyMetadata = ( width? : number , height? : number ) : ScadaSymbolMetadata = > ( {
title : '' ,
title : '' ,
widgetSizeX : width ? Math . max ( Math . round ( width / 100 ) , 1 ) : 3 ,
widgetSizeX : width ? Math . max ( Math . round ( width / 100 ) , 1 ) : 3 ,
@ -828,28 +824,28 @@ export class ScadaSymbolObject {
}
}
private unitSymbol ( unit : TbUnit ) : string {
private unitSymbol ( unit : TbUnit ) : string {
return this . ctx . $scope . $injector . get ( this . ctx . servicesMap . get ( ' unitService' ) ) . getTargetUnitSymbol ( unit ) ;
return this . ctx . unitService . getTargetUnitSymbol ( unit ) ;
}
}
private convertUnitValue ( value : number , unit : TbUnit ) : number {
private convertUnitValue ( value : number , unit : TbUnit ) : number {
return this . ctx . $scope . $injector . get ( this . ctx . servicesMap . get ( ' unitService' ) ) . convertUnitValue ( value , unit ) ;
return this . ctx . unitService . convertUnitValue ( value , unit ) ;
}
}
private formatValue ( value : any , settings : ValueFormatId Settings ) : string ;
private formatValue ( value : any , settings : ValueFormatSettings ) : string ;
private formatValue ( value : any , dec? : number , units? : string , showZeroDecimals? : boolean ) : string | undefined ;
private formatValue ( value : any , dec? : number , units? : string , showZeroDecimals? : boolean ) : string | undefined ;
private formatValue ( value : any , settingsOrDec? : ValueFormatIdSettings | number , units? : string , showZeroDecimals? : boolean ) : string {
private formatValue ( value : any , settingsOrDec? : ValueFormatSettings | number , units? : string , showZeroDecimals? : boolean ) : string {
const id = ( settingsOrDec as ValueFormatIdSettings ) ? . id || 0 ;
let valueFormatSettings : ValueFormatSettings ;
if ( ! this . valueProcessor [ id ] ) {
if ( typeof settingsOrDec === 'object' ) {
let valueFormatSettings : ValueFormatSettings ;
valueFormatSettings = deepClone ( settingsOrDec ) ;
if ( typeof settingsOrDec === 'object' ) {
} else {
valueFormatSettings = deepClone ( settingsOrDec , [ 'id' ] ) ;
valueFormatSettings = {
} else {
units ,
valueFormatSettings = {
decimals : settingsOrDec ,
units ,
showZeroDecimals
decimals : settingsOrDec ,
showZeroDecimals
}
}
}
}
const id = objectHashCode ( valueFormatSettings ) + '' ;
if ( ! this . valueProcessor [ id ] ) {
this . valueProcessor [ id ] = ValueFormatProcessor . fromSettings ( this . ctx . $injector , valueFormatSettings ) ;
this . valueProcessor [ id ] = ValueFormatProcessor . fromSettings ( this . ctx . $injector , valueFormatSettings ) ;
}
}
return this . valueProcessor [ id ] . format ( value ) ;
return this . valueProcessor [ id ] . format ( value ) ;