public async Task <bool> StartCharge()
        {
            IsPrecharging = true;

            latestChargeCurrent = 0;

            // Send 50ma so that the voltage can be measured
            ChargerService.RequestedVoltage = RequestedVoltage;
            ChargerService.RequestedCurrent = 0.05f;

            ChargerService.SupplyCurrentLimit = SupplyCurrentLimit;
            batteryIntegrator = 0;

            ChargerService.StopCharge();

            if (await ChargerService.WaitUntilChargerStopped(1000) == false)
            {
                return(false);
            }

            ChargerService.RequestedVoltage = BatteryService.BatteryData.EstimatePackVoltageFromCMUs / 1000;
            ChargerService.StartCharge();

            if (await ChargerService.WaitUntilChargerStarted(3000) == false ||
                await ChargerService.WaitUntilVoltageReached(RequestedVoltage, 10, 10000) == false)
            {
                await StopCharge();

                return(false);
            }

            await BatteryService.EngageContactors();

            if (await BatteryService.WaitUntilContactorsEngage(10000) == false)
            {
                await StopCharge();

                return(false);
            }

            StartTimer();

            IsPrecharging = false;

            return(true);
        }
Exemplo n.º 2
0
        public async Task <bool> StopCharge()
        {
            ChargerService.StopCharge();

            if (!await ChargerService.WaitUntilChargerStopped(3000))
            {
                return(false);
            }

            BatteryService.DisengageContactors();

            if (!await BatteryService.WaitUntilContactorsDisengage(3000))
            {
                return(false);
            }

            StopTimer();

            return(true);
        }
 private BatteryDischargeService()
 {
     batteryService = BatteryService.Instance;
     canControl     = new CanControl(0x508);
 }