using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows.Forms;
using Prism.Commands;
using Prism.Mvvm;
using SHJX.Service.Common.ExtendElement;
using SHJX.Service.Common.ReadXML;
using SHJX.Service.Common.UserDelegate;
using SHJX.Service.Control.ServiceController;
using SHJX.Service.Model.Control;
using SHJX.Service.Model.Dao;
using SHJX.Service.Model.MvvmCommon;
namespace SHJX.Service.ModelView
{
public class SettingViewModel : BindableBase
{
private readonly ReadConfigUtil _config;
private readonly SettingController _controller;
public SettingViewModel(ReadConfigUtil config)
{
_config = config;
_controller = new SettingController(_config);
InitData();
}
#region DataBind
///
/// 加热阶段信息
///
public ObservableCollection HeatData { get; set; }
///
/// 冷却
///
public ObservableCollection CoolingData { get; set; }
///
/// PID
///
public ObservableCollection PIDs { get; set; }
///
/// 速度
///
public ObservableCollection SpeedInfos { get; set; }
///
/// 液体
///
public ObservableCollection LiquidWashes { get; set; }
public ObservableCollection LiquidTotals { get; set; }
public ObservableCollection LiquidAmount { get; set; }
///
/// 滴定值
///
public ObservableCollection TitrationValue { get; set; }
public ObservableCollection Wavekeys { get; set; }
public void InitData()
{
PortName = _config.Port;
AutoFindPort = _config.IsAutoGetPort;
AutoWriteSpeed = _config.SpeedWrite;
isStartHeat = _config.OpenAppStartHeat;
TemplateFilePath = _config.TemplateFilePath;
PreheatTemperature = _config.PreheatTemperature;
AddWaterTemperature = _config.AddWaterTemperature;
SampleResultFilePath = _config.ResultWordFilePath;
CoolingPipeWatingTime = _config.CoolingPipeWatingTime;
DissolveMoveDistance = _config.DissolveMoveDistance;
ManiGrabFeedback = _config.ManiGrabFeedBack;
DripNozzleFeedBack = _config.DripNozzleFeedBack;
IsAddCupFeedBack = _config.IsAddCupFeedBack;
ExportTypeByExcel=_config.ExportTypeByExcel;
ExportTypeByWord = _config.ExportTypeByWord;
IsAddCupBiaoDingBubei = _config.IsAddCupBiaoDingBubei;
SpeedInfos = new ObservableCollection(_config.GetSpeed);
PIDs = new ObservableCollection(_controller.GetData());
LiquidAmount = new ObservableCollection(_config.DropOnceAmounts);
LiquidWashes = new ObservableCollection(_controller.GetData());
LiquidTotals = new ObservableCollection(_controller.GetData());
HeatData = new ObservableCollection(_controller.GetData());
CoolingData = new ObservableCollection(_controller.GetData());
TitrationValue = new ObservableCollection(_controller.GetData());
Wavekeys = new ObservableCollection((from wave in _controller.GetWavekeys() select wave.WaveKey).ToList());
WavekeysCurrentShow = Wavekeys.FirstOrDefault();
lowCalibrationValue = _controller.GetBlankCalibrationValue(Wavekeys.FirstOrDefault(),"Low","标定");
lowBlankValue = _controller.GetBlankCalibrationValue(Wavekeys.FirstOrDefault(), "Low","空白");
highCalibrationValue = _controller.GetBlankCalibrationValue(Wavekeys.FirstOrDefault(), "High","标定");
highBlankValue = _controller.GetBlankCalibrationValue(Wavekeys.FirstOrDefault(), "High", "空白");
}
#region titration
public TitrationValue Titration
{
get => TitrationValue.FirstOrDefault();
set
{
TitrationValue.ToArray()[0] = value;
RaisePropertyChanged(nameof(Titration));
}
}
#endregion
#region
private string _portName;
public string PortName
{
get => _portName;
set => SetProperty(ref _portName, value);
}
private bool _autoFindPort;
public bool AutoFindPort
{
get => _autoFindPort;
set => SetProperty(ref _autoFindPort, value);
}
private string wavekeysCurrentShow;
public string WavekeysCurrentShow
{
get => wavekeysCurrentShow;
set => SetProperty(ref wavekeysCurrentShow, value);
}
private double lowCalibrationValue;
public double LowCalibrationValue
{
get => lowCalibrationValue;
set => SetProperty(ref lowCalibrationValue, value);
}
private double lowBlankValue;
public double LowBlankValue
{
get => lowBlankValue;
set => SetProperty(ref lowBlankValue, value);
}
private double highCalibrationValue;
public double HighCalibrationValue
{
get => highCalibrationValue;
set => SetProperty(ref highCalibrationValue, value);
}
private double highBlankValue;
public double HighBlankValue
{
get => highBlankValue;
set => SetProperty(ref highBlankValue, value);
}
#endregion
private bool _maniGrabFeedback;
public bool ManiGrabFeedback
{
get => _maniGrabFeedback;
set => SetProperty(ref _maniGrabFeedback, value);
}
private bool _dripNozzleFeedBack;
public bool DripNozzleFeedBack
{
get => _dripNozzleFeedBack;
set => SetProperty(ref _dripNozzleFeedBack, value);
}
private bool _IsAddCupFeedBack;
public bool IsAddCupFeedBack
{
get => _IsAddCupFeedBack;
set => SetProperty(ref _IsAddCupFeedBack, value);
}
private bool _IsAddCupBiaoDingBubei;
public bool IsAddCupBiaoDingBubei
{
get => _IsAddCupBiaoDingBubei;
set => SetProperty(ref _IsAddCupBiaoDingBubei, value);
}
private bool _IsExportTypeByExcel;
public bool ExportTypeByExcel
{
get => _IsExportTypeByExcel;
set => SetProperty(ref _IsExportTypeByExcel, value);
}
private bool _IsExportTypeByWord;
public bool ExportTypeByWord
{
get => _IsExportTypeByWord;
set => SetProperty(ref _IsExportTypeByWord, value);
}
private bool _autoWriteSpeed;
public bool AutoWriteSpeed
{
get => _autoWriteSpeed;
set => SetProperty(ref _autoWriteSpeed, value);
}
public string templateFilePath;
public string TemplateFilePath
{
get => templateFilePath;
set => SetProperty(ref templateFilePath, value);
}
public string sampleResultFilePath;
public string SampleResultFilePath
{
get => sampleResultFilePath;
set => SetProperty(ref sampleResultFilePath, value);
}
///
/// 是否开机自动加热
///
private bool isStartHeat;
public bool IsStartHeat
{
get => isStartHeat;
set => SetProperty(ref isStartHeat, value);
}
private double _preheatTemperature;
public double PreheatTemperature
{
get => _preheatTemperature;
set => SetProperty(ref _preheatTemperature, value);
}
private double _addWaterTemperature;
public double AddWaterTemperature
{
get => _addWaterTemperature;
set => SetProperty(ref _addWaterTemperature, value);
}
private double _coolingPipeWatingTime;
public double CoolingPipeWatingTime
{
get => _coolingPipeWatingTime;
set => SetProperty(ref _coolingPipeWatingTime, value);
}
private double _dissolveMoveDistance;
public double DissolveMoveDistance
{
get => _dissolveMoveDistance;
set => SetProperty(ref _dissolveMoveDistance, value);
}
#endregion
#region Command
///
/// 更新配置
///
public DelegateCommand