346 lines
8.7 KiB
TypeScript
346 lines
8.7 KiB
TypeScript
/* eslint-disable */
|
|
import Long from "long";
|
|
import _m0 from "protobufjs/minimal";
|
|
import { BatteryStatus48TL } from "../VictronV1/BatteryStatus48TL";
|
|
|
|
export const protobufPackage = "";
|
|
|
|
export enum DeviceType {
|
|
UnknownDevice = 0,
|
|
Grid = 1,
|
|
Shore = 2,
|
|
AcInBus = 3,
|
|
AcOutBus = 4,
|
|
AcBus = 5,
|
|
DcBus = 6,
|
|
Inverter = 7,
|
|
Battery48TL200 = 8,
|
|
PvInverter = 9,
|
|
Mppt = 10,
|
|
Generator = 11,
|
|
AcLoad = 12,
|
|
DcLoad = 13,
|
|
Losses = 14,
|
|
BatteryHeater = 15,
|
|
UNRECOGNIZED = -1,
|
|
}
|
|
|
|
export function deviceTypeFromJSON(object: any): DeviceType {
|
|
switch (object) {
|
|
case 0:
|
|
case "UnknownDevice":
|
|
return DeviceType.UnknownDevice;
|
|
case 1:
|
|
case "Grid":
|
|
return DeviceType.Grid;
|
|
case 2:
|
|
case "Shore":
|
|
return DeviceType.Shore;
|
|
case 3:
|
|
case "AcInBus":
|
|
return DeviceType.AcInBus;
|
|
case 4:
|
|
case "AcOutBus":
|
|
return DeviceType.AcOutBus;
|
|
case 5:
|
|
case "AcBus":
|
|
return DeviceType.AcBus;
|
|
case 6:
|
|
case "DcBus":
|
|
return DeviceType.DcBus;
|
|
case 7:
|
|
case "Inverter":
|
|
return DeviceType.Inverter;
|
|
case 8:
|
|
case "Battery48TL200":
|
|
return DeviceType.Battery48TL200;
|
|
case 9:
|
|
case "PvInverter":
|
|
return DeviceType.PvInverter;
|
|
case 10:
|
|
case "Mppt":
|
|
return DeviceType.Mppt;
|
|
case 11:
|
|
case "Generator":
|
|
return DeviceType.Generator;
|
|
case 12:
|
|
case "AcLoad":
|
|
return DeviceType.AcLoad;
|
|
case 13:
|
|
case "DcLoad":
|
|
return DeviceType.DcLoad;
|
|
case 14:
|
|
case "Losses":
|
|
return DeviceType.Losses;
|
|
case 15:
|
|
case "BatteryHeater":
|
|
return DeviceType.BatteryHeater;
|
|
case -1:
|
|
case "UNRECOGNIZED":
|
|
default:
|
|
return DeviceType.UNRECOGNIZED;
|
|
}
|
|
}
|
|
|
|
export function deviceTypeToJSON(object: DeviceType): string {
|
|
switch (object) {
|
|
case DeviceType.UnknownDevice:
|
|
return "UnknownDevice";
|
|
case DeviceType.Grid:
|
|
return "Grid";
|
|
case DeviceType.Shore:
|
|
return "Shore";
|
|
case DeviceType.AcInBus:
|
|
return "AcInBus";
|
|
case DeviceType.AcOutBus:
|
|
return "AcOutBus";
|
|
case DeviceType.AcBus:
|
|
return "AcBus";
|
|
case DeviceType.DcBus:
|
|
return "DcBus";
|
|
case DeviceType.Inverter:
|
|
return "Inverter";
|
|
case DeviceType.Battery48TL200:
|
|
return "Battery48TL200";
|
|
case DeviceType.PvInverter:
|
|
return "PvInverter";
|
|
case DeviceType.Mppt:
|
|
return "Mppt";
|
|
case DeviceType.Generator:
|
|
return "Generator";
|
|
case DeviceType.AcLoad:
|
|
return "AcLoad";
|
|
case DeviceType.DcLoad:
|
|
return "DcLoad";
|
|
case DeviceType.Losses:
|
|
return "Losses";
|
|
case DeviceType.BatteryHeater:
|
|
return "BatteryHeater";
|
|
default:
|
|
return "UNKNOWN";
|
|
}
|
|
}
|
|
|
|
export interface Phase {
|
|
voltage: number;
|
|
current: number;
|
|
power: number;
|
|
}
|
|
|
|
export interface Device {
|
|
type: DeviceType;
|
|
phases: Phase[];
|
|
devices: Device[];
|
|
batteryData: BatteryStatus48TL | undefined;
|
|
}
|
|
|
|
function createBasePhase(): Phase {
|
|
return { voltage: 0, current: 0, power: 0 };
|
|
}
|
|
|
|
export const Phase = {
|
|
encode(message: Phase, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
|
if (message.voltage !== 0) {
|
|
writer.uint32(13).float(message.voltage);
|
|
}
|
|
if (message.current !== 0) {
|
|
writer.uint32(21).float(message.current);
|
|
}
|
|
if (message.power !== 0) {
|
|
writer.uint32(29).float(message.power);
|
|
}
|
|
return writer;
|
|
},
|
|
|
|
decode(input: _m0.Reader | Uint8Array, length?: number): Phase {
|
|
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
|
let end = length === undefined ? reader.len : reader.pos + length;
|
|
const message = createBasePhase();
|
|
while (reader.pos < end) {
|
|
const tag = reader.uint32();
|
|
switch (tag >>> 3) {
|
|
case 1:
|
|
message.voltage = reader.float();
|
|
break;
|
|
case 2:
|
|
message.current = reader.float();
|
|
break;
|
|
case 3:
|
|
message.power = reader.float();
|
|
break;
|
|
default:
|
|
reader.skipType(tag & 7);
|
|
break;
|
|
}
|
|
}
|
|
return message;
|
|
},
|
|
|
|
fromJSON(object: any): Phase {
|
|
return {
|
|
voltage: isSet(object.voltage) ? Number(object.voltage) : 0,
|
|
current: isSet(object.current) ? Number(object.current) : 0,
|
|
power: isSet(object.power) ? Number(object.power) : 0,
|
|
};
|
|
},
|
|
|
|
toJSON(message: Phase): unknown {
|
|
const obj: any = {};
|
|
message.voltage !== undefined && (obj.voltage = message.voltage);
|
|
message.current !== undefined && (obj.current = message.current);
|
|
message.power !== undefined && (obj.power = message.power);
|
|
return obj;
|
|
},
|
|
|
|
fromPartial<I extends Exact<DeepPartial<Phase>, I>>(object: I): Phase {
|
|
const message = createBasePhase();
|
|
message.voltage = object.voltage ?? 0;
|
|
message.current = object.current ?? 0;
|
|
message.power = object.power ?? 0;
|
|
return message;
|
|
},
|
|
};
|
|
|
|
function createBaseDevice(): Device {
|
|
return { type: 0, phases: [], devices: [], batteryData: undefined };
|
|
}
|
|
|
|
export const Device = {
|
|
encode(
|
|
message: Device,
|
|
writer: _m0.Writer = _m0.Writer.create()
|
|
): _m0.Writer {
|
|
if (message.type !== 0) {
|
|
writer.uint32(8).int32(message.type);
|
|
}
|
|
for (const v of message.phases) {
|
|
Phase.encode(v!, writer.uint32(34).fork()).ldelim();
|
|
}
|
|
for (const v of message.devices) {
|
|
Device.encode(v!, writer.uint32(42).fork()).ldelim();
|
|
}
|
|
if (message.batteryData !== undefined) {
|
|
BatteryStatus48TL.encode(
|
|
message.batteryData,
|
|
writer.uint32(82).fork()
|
|
).ldelim();
|
|
}
|
|
return writer;
|
|
},
|
|
|
|
decode(input: _m0.Reader | Uint8Array, length?: number): Device {
|
|
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
|
let end = length === undefined ? reader.len : reader.pos + length;
|
|
const message = createBaseDevice();
|
|
while (reader.pos < end) {
|
|
const tag = reader.uint32();
|
|
switch (tag >>> 3) {
|
|
case 1:
|
|
message.type = reader.int32() as any;
|
|
break;
|
|
case 4:
|
|
message.phases.push(Phase.decode(reader, reader.uint32()));
|
|
break;
|
|
case 5:
|
|
message.devices.push(Device.decode(reader, reader.uint32()));
|
|
break;
|
|
case 10:
|
|
message.batteryData = BatteryStatus48TL.decode(
|
|
reader,
|
|
reader.uint32()
|
|
);
|
|
break;
|
|
default:
|
|
reader.skipType(tag & 7);
|
|
break;
|
|
}
|
|
}
|
|
return message;
|
|
},
|
|
|
|
fromJSON(object: any): Device {
|
|
return {
|
|
type: isSet(object.type) ? deviceTypeFromJSON(object.type) : 0,
|
|
phases: Array.isArray(object?.phases)
|
|
? object.phases.map((e: any) => Phase.fromJSON(e))
|
|
: [],
|
|
devices: Array.isArray(object?.devices)
|
|
? object.devices.map((e: any) => Device.fromJSON(e))
|
|
: [],
|
|
batteryData: isSet(object.batteryData)
|
|
? BatteryStatus48TL.fromJSON(object.batteryData)
|
|
: undefined,
|
|
};
|
|
},
|
|
|
|
toJSON(message: Device): unknown {
|
|
const obj: any = {};
|
|
message.type !== undefined && (obj.type = deviceTypeToJSON(message.type));
|
|
if (message.phases) {
|
|
obj.phases = message.phases.map((e) => (e ? Phase.toJSON(e) : undefined));
|
|
} else {
|
|
obj.phases = [];
|
|
}
|
|
if (message.devices) {
|
|
obj.devices = message.devices.map((e) =>
|
|
e ? Device.toJSON(e) : undefined
|
|
);
|
|
} else {
|
|
obj.devices = [];
|
|
}
|
|
message.batteryData !== undefined &&
|
|
(obj.batteryData = message.batteryData
|
|
? BatteryStatus48TL.toJSON(message.batteryData)
|
|
: undefined);
|
|
return obj;
|
|
},
|
|
|
|
fromPartial<I extends Exact<DeepPartial<Device>, I>>(object: I): Device {
|
|
const message = createBaseDevice();
|
|
message.type = object.type ?? 0;
|
|
message.phases = object.phases?.map((e) => Phase.fromPartial(e)) || [];
|
|
message.devices = object.devices?.map((e) => Device.fromPartial(e)) || [];
|
|
message.batteryData =
|
|
object.batteryData !== undefined && object.batteryData !== null
|
|
? BatteryStatus48TL.fromPartial(object.batteryData)
|
|
: undefined;
|
|
return message;
|
|
},
|
|
};
|
|
|
|
type Builtin =
|
|
| Date
|
|
| Function
|
|
| Uint8Array
|
|
| string
|
|
| number
|
|
| boolean
|
|
| undefined;
|
|
|
|
export type DeepPartial<T> = T extends Builtin
|
|
? T
|
|
: T extends Array<infer U>
|
|
? Array<DeepPartial<U>>
|
|
: T extends ReadonlyArray<infer U>
|
|
? ReadonlyArray<DeepPartial<U>>
|
|
: T extends {}
|
|
? { [K in keyof T]?: DeepPartial<T[K]> }
|
|
: Partial<T>;
|
|
|
|
type KeysOfUnion<T> = T extends T ? keyof T : never;
|
|
export type Exact<P, I extends P> = P extends Builtin
|
|
? P
|
|
: P & { [K in keyof P]: Exact<P[K], I[K]> } & Record<
|
|
Exclude<keyof I, KeysOfUnion<P>>,
|
|
never
|
|
>;
|
|
|
|
if (_m0.util.Long !== Long) {
|
|
_m0.util.Long = Long as any;
|
|
_m0.configure();
|
|
}
|
|
|
|
function isSet(value: any): boolean {
|
|
return value !== null && value !== undefined;
|
|
}
|