162 lines
4.3 KiB
C#
162 lines
4.3 KiB
C#
namespace OMNIPruefung.ViewModels.Features
|
|
{
|
|
using OmniPlus.Features;
|
|
using OMNIPruefung.ViewModels.Base;
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
public class OMNISysParameters : VM<OMNIPlusVM>
|
|
{
|
|
private SystemParameters parameters;
|
|
|
|
public OMNISysParameters(SystemParameters parameters)
|
|
{
|
|
this.parameters = parameters;
|
|
|
|
if (this.parameters is null)
|
|
{
|
|
this.parameters = new SystemParameters();
|
|
}
|
|
|
|
this.BuildInfo = this.parameters.BuildInfo.Value;
|
|
this.Manifactured = this.parameters.ManifacturingTime.DateTime;
|
|
this.Timedrift = this.parameters.SystemTime.DateTime;
|
|
this.Reboots = this.parameters.RebootsCount;
|
|
this.Version = this.parameters.VersionAndType.Value;
|
|
var voltage = Math.Max(this.parameters.BatteryVoltage.Volts, (ushort)1);
|
|
this.Voltage = (double)voltage / 1000D;
|
|
this.ADCCounts = this.parameters.BatteryVoltage.ADCCount;
|
|
this.Sealed = this.parameters.FactorySealed;
|
|
this.IsValid = this.parameters.IsValid;
|
|
}
|
|
|
|
private string buildInfo;
|
|
public string BuildInfo
|
|
{
|
|
get => this.buildInfo;
|
|
set
|
|
{
|
|
this.buildInfo = value;
|
|
|
|
this.NotifyPropertyChanged(nameof(this.BuildInfo));
|
|
}
|
|
}
|
|
|
|
private DateTime manifactured;
|
|
public DateTime Manifactured
|
|
{
|
|
get => this.manifactured;
|
|
set
|
|
{
|
|
this.manifactured = value;
|
|
|
|
this.NotifyPropertyChanged(nameof(this.Manifactured));
|
|
}
|
|
}
|
|
|
|
private DateTime timedrift;
|
|
public DateTime Timedrift
|
|
{
|
|
get => this.timedrift;
|
|
set
|
|
{
|
|
this.timedrift = value;
|
|
|
|
this.NotifyPropertyChanged(nameof(this.Timedrift));
|
|
}
|
|
}
|
|
|
|
private byte reboots;
|
|
public byte Reboots
|
|
{
|
|
get => this.reboots;
|
|
set
|
|
{
|
|
this.reboots = value;
|
|
|
|
this.NotifyPropertyChanged(nameof(this.Reboots));
|
|
}
|
|
}
|
|
|
|
private string version;
|
|
public string Version
|
|
{
|
|
get => this.version;
|
|
set
|
|
{
|
|
this.version = value;
|
|
|
|
this.NotifyPropertyChanged(nameof(this.Version));
|
|
}
|
|
}
|
|
|
|
private double voltage;
|
|
public double Voltage
|
|
{
|
|
get => this.voltage;
|
|
set
|
|
{
|
|
this.voltage = value;
|
|
|
|
this.NotifyPropertyChanged(nameof(this.Voltage));
|
|
}
|
|
}
|
|
|
|
private uint adc;
|
|
public uint ADCCounts
|
|
{
|
|
get => this.adc;
|
|
set
|
|
{
|
|
this.adc = value;
|
|
|
|
this.NotifyPropertyChanged(nameof(this.ADCCounts));
|
|
}
|
|
}
|
|
|
|
private bool @sealed;
|
|
public bool Sealed
|
|
{
|
|
get => this.@sealed;
|
|
set
|
|
{
|
|
this.@sealed = value;
|
|
|
|
this.NotifyPropertyChanged(nameof(this.Sealed));
|
|
}
|
|
}
|
|
|
|
private bool isvalid;
|
|
public bool IsValid
|
|
{
|
|
get => this.isvalid;
|
|
set
|
|
{
|
|
this.isvalid = value;
|
|
|
|
this.NotifyPropertyChanged(nameof(this.IsValid));
|
|
}
|
|
}
|
|
|
|
public Dictionary<string, string> ToDictionary()
|
|
{
|
|
var dictionary = new Dictionary<string, string>();
|
|
|
|
dictionary["Version & Type: "] = this.Version;
|
|
dictionary["Build info: "] = this.BuildInfo;
|
|
dictionary["Manifactured: "] = $"{this.Manifactured:yyyy-MM-dd}";
|
|
dictionary["Last update: "] = $"{this.Timedrift:yyyy-MM-dd HH:mm:ss}";
|
|
dictionary["Battery voltage: "] = $"{this.Voltage:0.000}V";
|
|
dictionary["ADC counts: "] = $"{this.ADCCounts}";
|
|
dictionary["Reboots count: "] = $"{this.Reboots}";
|
|
dictionary["Factory sealed: "] = $"{this.Sealed}";
|
|
|
|
return dictionary;
|
|
}
|
|
|
|
public static implicit operator OMNISysParameters(SystemParameters parameters)
|
|
=> new OMNISysParameters(parameters);
|
|
}
|
|
}
|