UNPKG

typed-ocpp

Version:

A library for type-aware parsing, serialization and validation of OCPP 1.6, OCPP 2.0 and OCPP 2.1 messages

63 lines 2.18 kB
export var Models; (function (Models) { class EnergyExchange { convert(value, source, target, numberOfPhases) { switch (source) { case target: return value; case 'A': return this.ampsToWatts(value, numberOfPhases); case 'W': return this.wattsToAmps(value, numberOfPhases); default: throw new Error('should not be here'); } } } Models.EnergyExchange = EnergyExchange; class ChargingStation extends EnergyExchange { } Models.ChargingStation = ChargingStation; class ACChargingStation extends ChargingStation { #phaseVoltage; constructor(phaseVoltage) { super(); this.#phaseVoltage = phaseVoltage; } ampsToWatts(value, numberOfPhases = 3) { return value * (this.#phaseVoltage * numberOfPhases); } wattsToAmps(value, numberOfPhases = 3) { return value / (this.#phaseVoltage * numberOfPhases); } } Models.ACChargingStation = ACChargingStation; class ChargingSession extends EnergyExchange { } Models.ChargingSession = ChargingSession; class ACChargingSession extends ChargingSession { #phaseVoltage; constructor(phaseVoltage) { super(); this.#phaseVoltage = phaseVoltage; } ampsToWatts(value, numberOfPhases = 3) { return value * (this.#phaseVoltage * numberOfPhases); } wattsToAmps(value, numberOfPhases = 3) { return value / (this.#phaseVoltage * numberOfPhases); } } Models.ACChargingSession = ACChargingSession; class DCChargingSession extends ChargingSession { #batteryVoltage; constructor(batteryVoltage) { super(); this.#batteryVoltage = batteryVoltage; } ampsToWatts(value) { return value * this.#batteryVoltage; } wattsToAmps(value) { return value / this.#batteryVoltage; } } Models.DCChargingSession = DCChargingSession; })(Models || (Models = {})); //# sourceMappingURL=models.js.map