Автозаряд и авторазряд will do well.
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
namespace charger_gui.operations
|
||||
{
|
||||
class ChargeOperation : AutomaticOperation
|
||||
{
|
||||
const float MAX_VOLTAGE = 14.5f;
|
||||
|
||||
private int passed;
|
||||
private bool isComplete = false;
|
||||
public override string Status
|
||||
{
|
||||
get
|
||||
{
|
||||
if (isComplete) return "Charging complete in " + passed + " seconds";
|
||||
else return "Charging, passed " + passed + " seconds";
|
||||
}
|
||||
}
|
||||
|
||||
public ChargeOperation(Logger log, MainWindowViewModel model) : base(log, model)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Work()
|
||||
{
|
||||
log.Log("Charging started");
|
||||
var start = DateTime.Now;
|
||||
model.IsCharging = true;
|
||||
model.IsLampOn = false;
|
||||
Thread.Sleep(500);
|
||||
while (model.U2Acc < 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 error: NO POWER. " + model.U1Acc.ToString("F4"));
|
||||
}
|
||||
}
|
||||
log.Log("Charging complete in " + passed + " seconds");
|
||||
isComplete = true;
|
||||
OnStatusChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user