You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
913 B

export interface PointKeyInfo {
description: string
pointId: string
unit?: string
Lower?: string
Upper?: string
}
export function parsePointKey(key: string | number | undefined | null): PointKeyInfo {
const safeKey = key !== undefined && key !== null ? String(key) : ''
const [description = '', pointId = '', unit = '', Lower = '', Upper = ''] = safeKey.split('|')
return { description, pointId, unit, Lower, Upper }
}
export function buildPointKeyFromInfo(info: Partial<PointKeyInfo>): string {
const { description = '', pointId = '', unit = '', Lower = '', Upper = '' } = info || {}
return [description, pointId, unit, Lower, Upper].join('|')
}
export function buildPointTitle(info: PointKeyInfo, fallback: string): string {
if (info.description && info.pointId)
return `${info.description} (${info.pointId})`
if (info.description)
return info.description
return fallback
}