Files
charger/charger-gui/operations/DischargeOperation.cs
T

49 lines
1.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace charger_gui.operations
{
class DischargeOperation : AutomaticOperation
{
const float MIN_VOLTAGE = 10.8f;
private int passed;
private bool isComplete = false;
public override string Status
{
get
{
if (isComplete) return "Discharging complete in " + passed + " seconds";
else return "Discharging, passed " + passed + " seconds";
}
}
public DischargeOperation(Logger log, MainWindowViewModel model) : base(log, model)
{
}
protected override void Work()
{
log.Log("Discharging started");
var start = DateTime.Now;
model.IsCharging = false;
model.IsLampOn = true;
Thread.Sleep(500);
while (model.U3 > MIN_VOLTAGE)
{
Thread.Sleep(1000);
passed = (int)((DateTime.Now - start).TotalSeconds);
OnStatusChanged();
log.Log("Discharging " + passed + "s " + model.U3.ToString("F4"));
}
log.Log("Discharging complete in " + passed + " seconds");
model.IsLampOn = false;
isComplete = true;
OnStatusChanged();
}
}
}