public void StartCharge(EnumAddressDirection chargeDirection) { Task.Run(() => { try { SpinWait.SpinUntil(() => false, 2000); IsCharging = true; OnUpdateChargeStatusEvent?.Invoke(this, IsCharging); while (BatteryStatus.Percentage < 100 && IsCharging) { SpinWait.SpinUntil(() => false, 2000); BatteryStatus.Percentage = Math.Min(BatteryStatus.Percentage + 10, 100); OnUpdateBatteryStatusEvent?.Invoke(this, BatteryStatus); } } catch (Exception ex) { OnLogErrorEvent?.Invoke(this, new MessageHandlerArgs() { ClassMethodName = GetType().Name + ":" + System.Reflection.MethodBase.GetCurrentMethod().Name, Message = ex.Message }); } SpinWait.SpinUntil(() => false, 2000); IsCharging = false; OnUpdateChargeStatusEvent?.Invoke(this, IsCharging); }); }
public void GetBatteryAndChargeStatus() { var localData = LocalPackage.MainFlowHandler.localData; OnUpdateBatteryStatusEvent?.Invoke(this, new BatteryStatus() { Percentage = (int)localData.BatteryInfo.SOC, Voltage = localData.BatteryInfo.V }); OnUpdateChargeStatusEvent?.Invoke(this, localData.MIPCData.Charging); }
public void StopCharge() { if (IsCharging) { Task.Run(() => { SpinWait.SpinUntil(() => false, 2000); IsCharging = false; }); } else { OnUpdateChargeStatusEvent?.Invoke(this, IsCharging); } }
public void StopCharge() { if (LocalPackage.MainFlowHandler.localData.MIPCData.Charging) { Task.Run(() => { LocalPackage.MainFlowHandler.StopCharging(); SpinWait.SpinUntil(() => !LocalPackage.MainFlowHandler.localData.MIPCData.Charging, 30 * 1000); OnUpdateChargeStatusEvent?.Invoke(this, LocalPackage.MainFlowHandler.localData.MIPCData.Charging); }); } else { OnUpdateChargeStatusEvent?.Invoke(this, LocalPackage.MainFlowHandler.localData.MIPCData.Charging); } }
public void StartCharge(EnumAddressDirection chargeDirection) { if (!LocalPackage.MainFlowHandler.localData.MIPCData.Charging) { Task.Run(() => { LocalPackage.MainFlowHandler.StartChargingByAddressID(Vehicle.Instance.MoveStatus.LastAddress.Id); SpinWait.SpinUntil(() => LocalPackage.MainFlowHandler.localData.MIPCData.Charging, 30 * 1000); OnUpdateChargeStatusEvent?.Invoke(this, LocalPackage.MainFlowHandler.localData.MIPCData.Charging); }); } else { OnUpdateChargeStatusEvent?.Invoke(this, LocalPackage.MainFlowHandler.localData.MIPCData.Charging); } }
public void GetBatteryAndChargeStatus() { OnUpdateBatteryStatusEvent?.Invoke(this, BatteryStatus); OnUpdateChargeStatusEvent?.Invoke(this, IsCharging); }