syntax = "proto3";

/*
 This container message is send from Lo To Hi and may contain any allowed message in that direction.
*/
message LoToHi {
 oneof payload {
  uint32 time_stamp = 1;
  bool relais_state = 2; // false: relais are off, true: relais are on
  ErrorFlags error_flags = 3;
  CpState cp_state = 4;
  PpState pp_state = 5;
  uint32 max_charging_current = 6;
  uint32 max_grid_current = 7;
  LockState lock_state = 8;
  PowerMeter power_meter = 9;
 }
}

message ErrorFlags {
  bool diode_fault = 1;
  bool rcd_selftest_failed = 2;
  bool rcd_triggered = 3;
  bool ventilation_not_available = 4;
  bool connector_lock_failed = 5;
  bool cp_signal_fault = 6;
}

enum CpState {
  EVSE_STATE_A = 0;
  EVSE_STATE_B1 = 1;
  EVSE_STATE_B2 = 2;
  EVSE_STATE_C1 = 3;
  EVSE_STATE_C2 = 4;
  EVSE_STATE_D1 = 5;
  EVSE_STATE_D2 = 6;
  EVSE_STATE_E = 7;
  EVSE_STATE_F = 8;
}

enum PpState {
  STATE_NC = 0;
  STATE_13A = 1;
  STATE_20A = 2;
  STATE_32A = 3;
  STATE_70A = 4;
  STATE_FAULT = 5;
}

enum LockState {
  UNDEFINED = 0;
  UNLOCKED = 1;
  LOCKED = 2;
}

message PowerMeter {
  uint32 time_stamp = 1;
  float vrmsL1 = 2;
  float vrmsL2 = 3;
  float vrmsL3 = 4;
  float irmsL1 = 5;
  float irmsL2 = 6;
  float irmsL3 = 7;
  float irmsN = 8;
  float wattHrL1 = 9;
  float wattHrL2 = 10;
  float wattHrL3 = 11;
  float totalWattHr = 12;
  float tempL1 = 13;
  float tempL2 = 14;
  float tempL3 = 15;
  float tempN = 16;
  float wattL1 = 17;
  float wattL2 = 18;
  float wattL3 = 19;
  float freqL1 = 20;
  float freqL2 = 21;
  float freqL3 = 22;
  bool phaseSeqError = 23;
}