Поправил UI, добавил команду автотренировки аккумулятора
This commit is contained in:
@@ -32,18 +32,19 @@ namespace charger_gui.operations
|
||||
model.IsCharging = true;
|
||||
model.IsLampOn = false;
|
||||
Thread.Sleep(500);
|
||||
while (model.U2Acc < MAX_VOLTAGE)
|
||||
while (model.U3 < MAX_VOLTAGE)
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
passed = (int)((DateTime.Now - start).TotalSeconds);
|
||||
OnStatusChanged();
|
||||
log.Log("Charging " + passed + "s " + model.U2Acc.ToString("F4"));
|
||||
if (model.U1Acc < 10f)
|
||||
log.Log("Charging " + passed + "s " + model.U3.ToString("F4"));
|
||||
if (model.U2 < 10f)
|
||||
{
|
||||
log.Log("Charging error: NO POWER. " + model.U1Acc.ToString("F4"));
|
||||
log.Log("Charging error: NO POWER. " + model.U2.ToString("F4"));
|
||||
}
|
||||
}
|
||||
log.Log("Charging complete in " + passed + " seconds");
|
||||
model.IsCharging = false;
|
||||
isComplete = true;
|
||||
OnStatusChanged();
|
||||
}
|
||||
|
||||
@@ -32,14 +32,15 @@ namespace charger_gui.operations
|
||||
model.IsCharging = false;
|
||||
model.IsLampOn = true;
|
||||
Thread.Sleep(500);
|
||||
while (model.U2Acc > MIN_VOLTAGE)
|
||||
while (model.U3 > MIN_VOLTAGE)
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
passed = (int)((DateTime.Now - start).TotalSeconds);
|
||||
OnStatusChanged();
|
||||
log.Log("Discharging " + passed + "s " + model.U2Acc.ToString("F4"));
|
||||
log.Log("Discharging " + passed + "s " + model.U3.ToString("F4"));
|
||||
}
|
||||
log.Log("Discharging complete in " + passed + " seconds");
|
||||
model.IsLampOn = false;
|
||||
isComplete = true;
|
||||
OnStatusChanged();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
namespace charger_gui.operations
|
||||
{
|
||||
class TrainOperation : AutomaticOperation
|
||||
{
|
||||
const float MAX_VOLTAGE = 14.5f;
|
||||
|
||||
private int passed;
|
||||
private bool isComplete = false;
|
||||
private int duration;
|
||||
public override string Status
|
||||
{
|
||||
get
|
||||
{
|
||||
if (isComplete) return "Training complete in " + passed + " seconds";
|
||||
else return "Training, passed " + passed + " seconds (of " + duration + ")";
|
||||
}
|
||||
}
|
||||
|
||||
public TrainOperation(Logger log, MainWindowViewModel model, int duration) : base(log, model)
|
||||
{
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
protected override void Work()
|
||||
{
|
||||
log.Log("Training started");
|
||||
var start = DateTime.Now;
|
||||
while (passed < duration)
|
||||
{
|
||||
model.IsCharging = true;
|
||||
model.IsLampOn = false;
|
||||
Thread.Sleep(1000);
|
||||
model.IsCharging = false;
|
||||
model.IsLampOn = false;
|
||||
Thread.Sleep(50);
|
||||
model.IsCharging = false;
|
||||
model.IsLampOn = true;
|
||||
Thread.Sleep(1000);
|
||||
model.IsCharging = false;
|
||||
model.IsLampOn = false;
|
||||
Thread.Sleep(50);
|
||||
passed = (int)((DateTime.Now - start).TotalSeconds);
|
||||
OnStatusChanged();
|
||||
log.Log("Training" + passed + "s " + model.U3.ToString("F4"));
|
||||
if (model.U2 < 10f)
|
||||
{
|
||||
log.Log("Training error: NO POWER. " + model.U2.ToString("F4"));
|
||||
}
|
||||
}
|
||||
log.Log("Training complete in " + passed + " seconds");
|
||||
model.IsCharging = false;
|
||||
model.IsLampOn = false;
|
||||
isComplete = true;
|
||||
OnStatusChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user