Поправил UI, добавил команду автотренировки аккумулятора
This commit is contained in:
+22
-14
@@ -39,29 +39,37 @@
|
|||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<TextBlock Grid.Row="0" Grid.Column="0" FontSize="20" Text="I_acc"/>
|
<TextBlock Grid.Row="0" Grid.Column="0" FontSize="20" Text="I_acc"/>
|
||||||
<TextBlock Grid.Row="0" Grid.Column="1" FontSize="20" Text="{Binding Path=IAcc,Mode=OneWay,StringFormat=F4}" />
|
<TextBlock Grid.Row="0" Grid.Column="1" FontSize="20" Text="{Binding Path=IAcc,Mode=OneWay,StringFormat=F4}" />
|
||||||
<TextBlock Grid.Row="1" Grid.Column="0" FontSize="20" Text="U1_acc"/>
|
<TextBlock Grid.Row="1" Grid.Column="0" FontSize="20" Text="U2"/>
|
||||||
<TextBlock Grid.Row="1" Grid.Column="1" FontSize="20" Text="{Binding Path=U1Acc,Mode=OneWay,StringFormat=F4}" />
|
<TextBlock Grid.Row="1" Grid.Column="1" FontSize="20" Text="{Binding Path=U2,Mode=OneWay,StringFormat=F4}" />
|
||||||
<TextBlock Grid.Row="2" Grid.Column="0" FontSize="20" Text="U2_acc"/>
|
<TextBlock Grid.Row="2" Grid.Column="0" FontSize="20" Text="U3"/>
|
||||||
<TextBlock Grid.Row="2" Grid.Column="1" FontSize="20" Text="{Binding Path=U2Acc,Mode=OneWay,StringFormat=F4}" />
|
<TextBlock Grid.Row="2" Grid.Column="1" FontSize="20" Text="{Binding Path=U3,Mode=OneWay,StringFormat=F4}" />
|
||||||
<TextBlock Grid.Row="3" Grid.Column="0" FontSize="20" Text="I_lamp"/>
|
<TextBlock Grid.Row="3" Grid.Column="0" FontSize="20" Text="U4"/>
|
||||||
<TextBlock Grid.Row="3" Grid.Column="1" FontSize="20" Text="{Binding Path=ILamp,Mode=OneWay,StringFormat=F4}" />
|
<TextBlock Grid.Row="3" Grid.Column="1" FontSize="20" Text="{Binding Path=U4,Mode=OneWay,StringFormat=F4}" />
|
||||||
<TextBlock Grid.Row="4" Grid.Column="0" FontSize="20" Text="U1_lamp"/>
|
<TextBlock Grid.Row="4" Grid.Column="0" FontSize="20" Text="U5"/>
|
||||||
<TextBlock Grid.Row="4" Grid.Column="1" FontSize="20" Text="{Binding Path=U1Lamp,Mode=OneWay,StringFormat=F4}" />
|
<TextBlock Grid.Row="4" Grid.Column="1" FontSize="20" Text="{Binding Path=U5,Mode=OneWay,StringFormat=F4}" />
|
||||||
<TextBlock Grid.Row="5" Grid.Column="0" FontSize="20" Text="U2_lamp"/>
|
<TextBlock Grid.Row="5" Grid.Column="0" FontSize="20" Text="CHARGE"/>
|
||||||
<TextBlock Grid.Row="5" Grid.Column="1" FontSize="20" Text="{Binding Path=U2Lamp,Mode=OneWay,StringFormat=F4}" />
|
<Ellipse Grid.Row="5" Grid.Column="1" Width="20" Height="20" Fill="{Binding Path=ChargeStatus,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}" />
|
||||||
<TextBlock Grid.Row="6" Grid.Column="0" FontSize="20" Text="CHARGE"/>
|
<TextBlock Grid.Row="6" Grid.Column="0" FontSize="20" Text="LAMP"/>
|
||||||
<Ellipse Grid.Row="6" Grid.Column="1" Width="20" Height="20" Fill="{Binding Path=ChargeStatus,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}" />
|
<Ellipse Grid.Row="6" Grid.Column="1" Width="20" Height="20" Fill="{Binding Path=LampStatus,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}" />
|
||||||
<TextBlock Grid.Row="7" Grid.Column="0" FontSize="20" Text="LAMP"/>
|
|
||||||
<Ellipse Grid.Row="7" Grid.Column="1" Width="20" Height="20" Fill="{Binding Path=LampStatus,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}" />
|
|
||||||
</Grid>
|
</Grid>
|
||||||
<StackPanel Grid.Row="1" Grid.Column="1">
|
<StackPanel Grid.Row="1" Grid.Column="1">
|
||||||
|
<TextBlock FontSize="24" Text="MANUAL"/>
|
||||||
<Button Content="Flip Lamp" Height="40" Click="LampButton_Click"/>
|
<Button Content="Flip Lamp" Height="40" Click="LampButton_Click"/>
|
||||||
<Button Content="Flip Charge" Height="40" Click="FlipChargeButton_Click"/>
|
<Button Content="Flip Charge" Height="40" Click="FlipChargeButton_Click"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Grid.Row="1" Grid.Column="2">
|
<StackPanel Grid.Row="1" Grid.Column="2">
|
||||||
|
<TextBlock FontSize="24" Text="AUTO"/>
|
||||||
<Button Content="Discharge" Height="40" Click="DischargeButton_Click"/>
|
<Button Content="Discharge" Height="40" Click="DischargeButton_Click"/>
|
||||||
<Button Content="Сharge" Height="40" Click="ChargeButton_Click"/>
|
<Button Content="Сharge" Height="40" Click="ChargeButton_Click"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
<StackPanel Grid.Row="1" Grid.Column="3">
|
||||||
|
<TextBlock FontSize="24" Text="TRAIN"/>
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<TextBlock FontSize="20" Text="Duration (s)" Height="40"/>
|
||||||
|
<TextBox Text="{Binding Path=TrainDuration}" FontSize="20" MinWidth="60"/>
|
||||||
|
</StackPanel>
|
||||||
|
<Button Content="GO" Height="40" Click="TrainButton_Click"/>
|
||||||
|
</StackPanel>
|
||||||
<TextBlock Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="4" Text="{Binding Path=OperationStatus,Mode=OneWay}" />
|
<TextBlock Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="4" Text="{Binding Path=OperationStatus,Mode=OneWay}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
|||||||
@@ -79,5 +79,20 @@ namespace charger_gui
|
|||||||
model.CurrentOperation = new ChargeOperation(log, model);
|
model.CurrentOperation = new ChargeOperation(log, model);
|
||||||
model.CurrentOperation.Start();
|
model.CurrentOperation.Start();
|
||||||
}
|
}
|
||||||
|
private void TrainButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (model.CurrentOperation != null)
|
||||||
|
{
|
||||||
|
model.CurrentOperation.Cancel();
|
||||||
|
}
|
||||||
|
model.CurrentOperation = new TrainOperation(log, model, model.TrainDuration);
|
||||||
|
model.CurrentOperation.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnClosed(EventArgs e)
|
||||||
|
{
|
||||||
|
base.OnClosed(e);
|
||||||
|
Application.Current.Shutdown();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
using charger_gui.operations;
|
using charger_gui.operations;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.IO.Ports;
|
using System.IO.Ports;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
|
||||||
namespace charger_gui
|
namespace charger_gui
|
||||||
@@ -38,73 +35,59 @@ namespace charger_gui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private float u1Acc;
|
private float u2;
|
||||||
public float U1Acc
|
public float U2
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return u1Acc;
|
return u2;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
u1Acc = value;
|
u2 = value;
|
||||||
OnPropertyChanged("U1Acc");
|
OnPropertyChanged("U2");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private float u2Acc;
|
private float u3;
|
||||||
public float U2Acc
|
public float U3
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return u2Acc;
|
return u3;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
u2Acc = value;
|
u3 = value;
|
||||||
OnPropertyChanged("U2Acc");
|
OnPropertyChanged("U3");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private float iLamp;
|
private float u4;
|
||||||
public float ILamp
|
public float U4
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return iLamp;
|
return u4;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
iLamp = value;
|
u4 = value;
|
||||||
OnPropertyChanged("ILamp");
|
OnPropertyChanged("U4");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private float u1Lamp;
|
private float u5;
|
||||||
public float U1Lamp
|
public float U5
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return u1Lamp;
|
return u5;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
u1Lamp = value;
|
u5 = value;
|
||||||
OnPropertyChanged("U1Lamp");
|
OnPropertyChanged("U5");
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private float u2Lamp;
|
|
||||||
public float U2Lamp
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return u2Lamp;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
u2Lamp = value;
|
|
||||||
OnPropertyChanged("U2Lamp");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,7 +173,10 @@ namespace charger_gui
|
|||||||
currentOperation.StatusChanged -= OnCurrentOperationStatusChanged;
|
currentOperation.StatusChanged -= OnCurrentOperationStatusChanged;
|
||||||
}
|
}
|
||||||
currentOperation = value;
|
currentOperation = value;
|
||||||
currentOperation.StatusChanged += OnCurrentOperationStatusChanged;
|
if (currentOperation != null)
|
||||||
|
{
|
||||||
|
currentOperation.StatusChanged += OnCurrentOperationStatusChanged;
|
||||||
|
}
|
||||||
OnPropertyChanged("OperationStatus");
|
OnPropertyChanged("OperationStatus");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -209,6 +195,8 @@ namespace charger_gui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int TrainDuration { get; set; }
|
||||||
|
|
||||||
private void FillPorts()
|
private void FillPorts()
|
||||||
{
|
{
|
||||||
ports = new List<string>(SerialPort.GetPortNames());
|
ports = new List<string>(SerialPort.GetPortNames());
|
||||||
|
|||||||
@@ -67,14 +67,13 @@ namespace charger_gui
|
|||||||
IModbusSerialMaster master = ModbusSerialMaster.CreateRtu(serialPort);
|
IModbusSerialMaster master = ModbusSerialMaster.CreateRtu(serialPort);
|
||||||
while (!shouldRestart)
|
while (!shouldRestart)
|
||||||
{
|
{
|
||||||
var r1 = master.ReadHoldingRegisters(SLAVE_ADDRESS, 0, 4);
|
var r1 = master.ReadHoldingRegisters(SLAVE_ADDRESS, 0, 2);
|
||||||
model.IAcc = ToFloat(r1[0], r1[1]);
|
model.IAcc = ToFloat(r1[0], r1[1]);
|
||||||
model.ILamp = ToFloat(r1[2], r1[3]);
|
|
||||||
var r2 = master.ReadHoldingRegisters(SLAVE_ADDRESS, 6, 8);
|
var r2 = master.ReadHoldingRegisters(SLAVE_ADDRESS, 6, 8);
|
||||||
model.U1Acc = ToFloat(r2[0], r2[1]);
|
model.U2 = ToFloat(r2[0], r2[1]);
|
||||||
model.U2Acc = ToFloat(r2[2], r2[3]);
|
model.U3 = ToFloat(r2[2], r2[3]);
|
||||||
model.U1Lamp = ToFloat(r2[4], r2[5]);
|
model.U4 = ToFloat(r2[4], r2[5]);
|
||||||
model.U2Lamp = ToFloat(r2[6], r2[7]);
|
model.U5 = ToFloat(r2[6], r2[7]);
|
||||||
master.WriteSingleRegister(SLAVE_ADDRESS, CHARGE_REGISTER, (ushort)(model.IsCharging ? 1 : 0));
|
master.WriteSingleRegister(SLAVE_ADDRESS, CHARGE_REGISTER, (ushort)(model.IsCharging ? 1 : 0));
|
||||||
master.WriteSingleRegister(SLAVE_ADDRESS, LAMP_REGISTER, (ushort)(model.IsLampOn ? 1 : 0));
|
master.WriteSingleRegister(SLAVE_ADDRESS, LAMP_REGISTER, (ushort)(model.IsLampOn ? 1 : 0));
|
||||||
// ничего не упало, коннект есть значит
|
// ничего не упало, коннект есть значит
|
||||||
|
|||||||
@@ -13,6 +13,22 @@
|
|||||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<Deterministic>true</Deterministic>
|
<Deterministic>true</Deterministic>
|
||||||
|
<PublishUrl>C:\Work\charger\charger-gui\publish\</PublishUrl>
|
||||||
|
<Install>true</Install>
|
||||||
|
<InstallFrom>Disk</InstallFrom>
|
||||||
|
<UpdateEnabled>false</UpdateEnabled>
|
||||||
|
<UpdateMode>Foreground</UpdateMode>
|
||||||
|
<UpdateInterval>7</UpdateInterval>
|
||||||
|
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||||
|
<UpdatePeriodically>false</UpdatePeriodically>
|
||||||
|
<UpdateRequired>false</UpdateRequired>
|
||||||
|
<MapFileExtensions>true</MapFileExtensions>
|
||||||
|
<ApplicationRevision>0</ApplicationRevision>
|
||||||
|
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||||
|
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||||
|
<UseApplicationTrust>false</UseApplicationTrust>
|
||||||
|
<PublishWizardCompleted>true</PublishWizardCompleted>
|
||||||
|
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
@@ -33,6 +49,18 @@
|
|||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<ManifestCertificateThumbprint>BEEA544097F13D7DCC301EAB82DAD11595FA2626</ManifestCertificateThumbprint>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<ManifestKeyFile>charger-gui_TemporaryKey.pfx</ManifestKeyFile>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<GenerateManifests>true</GenerateManifests>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<SignManifests>true</SignManifests>
|
||||||
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="NModbus4, Version=2.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="NModbus4, Version=2.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<HintPath>packages\NModbus4.2.1.0\lib\net40\NModbus4.dll</HintPath>
|
<HintPath>packages\NModbus4.2.1.0\lib\net40\NModbus4.dll</HintPath>
|
||||||
@@ -58,6 +86,7 @@
|
|||||||
</ApplicationDefinition>
|
</ApplicationDefinition>
|
||||||
<Compile Include="Logger.cs" />
|
<Compile Include="Logger.cs" />
|
||||||
<Compile Include="operations\AutomaticOperation.cs" />
|
<Compile Include="operations\AutomaticOperation.cs" />
|
||||||
|
<Compile Include="operations\TrainOperation.cs" />
|
||||||
<Compile Include="operations\ChargeOperation.cs" />
|
<Compile Include="operations\ChargeOperation.cs" />
|
||||||
<Compile Include="operations\DischargeOperation.cs" />
|
<Compile Include="operations\DischargeOperation.cs" />
|
||||||
<Compile Include="UpdateWorker.cs" />
|
<Compile Include="UpdateWorker.cs" />
|
||||||
@@ -93,11 +122,19 @@
|
|||||||
<Generator>ResXFileCodeGenerator</Generator>
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
<None Include="charger-gui_TemporaryKey.pfx" />
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
<None Include="Properties\Settings.settings">
|
<None Include="Properties\Settings.settings">
|
||||||
<Generator>SettingsSingleFileGenerator</Generator>
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||||
|
<Visible>False</Visible>
|
||||||
|
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||||
|
<Install>false</Install>
|
||||||
|
</BootstrapperPackage>
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<PublishUrlHistory />
|
||||||
|
<InstallUrlHistory />
|
||||||
|
<SupportUrlHistory />
|
||||||
|
<UpdateUrlHistory />
|
||||||
|
<BootstrapperUrlHistory />
|
||||||
|
<ErrorReportUrlHistory />
|
||||||
|
<FallbackCulture>ru-RU</FallbackCulture>
|
||||||
|
<VerifyUploadedFiles>false</VerifyUploadedFiles>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
||||||
Binary file not shown.
@@ -32,18 +32,19 @@ namespace charger_gui.operations
|
|||||||
model.IsCharging = true;
|
model.IsCharging = true;
|
||||||
model.IsLampOn = false;
|
model.IsLampOn = false;
|
||||||
Thread.Sleep(500);
|
Thread.Sleep(500);
|
||||||
while (model.U2Acc < MAX_VOLTAGE)
|
while (model.U3 < MAX_VOLTAGE)
|
||||||
{
|
{
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
passed = (int)((DateTime.Now - start).TotalSeconds);
|
passed = (int)((DateTime.Now - start).TotalSeconds);
|
||||||
OnStatusChanged();
|
OnStatusChanged();
|
||||||
log.Log("Charging " + passed + "s " + model.U2Acc.ToString("F4"));
|
log.Log("Charging " + passed + "s " + model.U3.ToString("F4"));
|
||||||
if (model.U1Acc < 10f)
|
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");
|
log.Log("Charging complete in " + passed + " seconds");
|
||||||
|
model.IsCharging = false;
|
||||||
isComplete = true;
|
isComplete = true;
|
||||||
OnStatusChanged();
|
OnStatusChanged();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,14 +32,15 @@ namespace charger_gui.operations
|
|||||||
model.IsCharging = false;
|
model.IsCharging = false;
|
||||||
model.IsLampOn = true;
|
model.IsLampOn = true;
|
||||||
Thread.Sleep(500);
|
Thread.Sleep(500);
|
||||||
while (model.U2Acc > MIN_VOLTAGE)
|
while (model.U3 > MIN_VOLTAGE)
|
||||||
{
|
{
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
passed = (int)((DateTime.Now - start).TotalSeconds);
|
passed = (int)((DateTime.Now - start).TotalSeconds);
|
||||||
OnStatusChanged();
|
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");
|
log.Log("Discharging complete in " + passed + " seconds");
|
||||||
|
model.IsLampOn = false;
|
||||||
isComplete = true;
|
isComplete = true;
|
||||||
OnStatusChanged();
|
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