public int get_mode() { Log.Verbose($"Get mode"); byte[] response = get_status_bank(); if (response != null) { switch_mode = (load_mode)((response[3] >> 1) & 3); } return((int)switch_mode); }
public int get_Mode() { Log.Verbose($"Get KP184 on or off"); byte[] message = new byte[8]; // wacky special read at 0x300 means get them all and the format of the return message is... special send_message(command.read_registers, 0x300, 0, ref message); delay(); byte[] response = get_response(23); if (response != null) { switch_mode = (load_mode)((response[3] >> 1) & 7); // TODO (chs): then look this up, the values in the status are wacky } return((int)switch_mode); }
////////////////////////////////////////////////////////////////////// // get the KP184 status public void get_status() { byte[] response = get_status_bank(); if (response != null) { switch_status = (load_switch)(response[3] & 1); switch_mode = (load_mode)((response[3] >> 1) & 3); // TODO (chs): then look this up, the values in the status are wacky voltage = ((uint)response[offset_voltage] << 16) | ((uint)response[offset_voltage + 1] << 8) | response[offset_voltage + 2]; current = ((uint)response[offset_current] << 16) | ((uint)response[offset_current + 1] << 8) | response[offset_current + 2]; Log.Info("Status:"); Log.Info($" Switch is {switch_status}"); Log.Info($" Mode is {load_mode_as_string(switch_mode)}"); Log.Info($" Current is {current}"); Log.Info($" Voltage is {voltage}"); } }
////////////////////////////////////////////////////////////////////// // get the KP184 status public void get_status() { byte[] message = new byte[8]; // wacky special read at 0x300 means get them all and the format of the return message is... special send_message(command.read_registers, 0x300, 0, ref message); delay(); byte[] response = get_response(23); if (response != null) { switch_status = (load_switch)(response[3] & 1); switch_mode = (load_mode)((response[3] >> 1) & 7); // TODO (chs): then look this up, the values in the status are wacky voltage = ((uint)response[5] << 16) | ((uint)response[6] << 8) | response[7]; current = ((uint)response[8] << 16) | ((uint)response[9] << 8) | response[10]; Log.Info("Status:"); Log.Info($" Switch is {switch_status}"); Log.Info($" Mode is {switch_mode}"); Log.Info($" Current is {current}"); Log.Info($" Voltage is {voltage}"); } }
public void set_mode(load_mode mode) { Log.Verbose($"Set mode to {mode}"); write_register(register.load_mode, (uint)mode); }
public static string load_mode_as_string(load_mode mode) { return(Enum.GetName(typeof(load_mode), mode)); }