using CommunityToolkit.Mvvm.Input;
using FLY.Thick.Base.Common;
using FLY.Thick.Base.IService;
using System;
using System.ComponentModel;
using System.Windows.Controls;
using Unity;
namespace FLY.Thick.Base.UI
{
///
/// Page_Initparam.xaml 的交互逻辑
///
public partial class PgInitparam : Page
{
PgInitParamVm viewModel;
public PgInitparam()
{
InitializeComponent();
}
[InjectionMethod]
public void Init(IInitParamService initParamService)
{
viewModel = new PgInitParamVm();
viewModel.Init(initParamService);
this.DataContext = viewModel;
}
}
public class PgInitParamVm : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
#region 参数
///
/// 扫描架长
///
public int PosLength { get; set; }
public bool IsTimeGridAdvEnabled { get; set; }
///
/// 自动归原点间距,次数
///
public int AutoOrgInterval { get; set; }
///
/// 编码器1 mm/pulse
///
public double Encoder1_mmpp { get; set; }
///
/// 设置的速度,与 实际速度比例 Speed1 = VScan*Speed1Scale
///
public double Speed1Scale { get; set; }
///
/// 线速度来源
///
public FilmVSRC FilmVSrc { get; set; }
///
/// 最小线速度 m/min
///
public int FilmVThreshold { get; set; }
///
/// 线速度:编码器2 mm/pulse
///
public double Encoder2_mmpp { get; set; }
///
/// 线速度:1圈多少mm
///
public double MmOfR { get; set; }
///
/// 数据有效源
///
public DATAVALIDSRC DataValidSrc { get; set; }
///
/// 当数据有效状态改变,自动按F1,F3
///
public bool AutoF1F3 { get; set; }
///
/// 当数据有效状态 无效->有效 ,等待多久重新扫描 ,单位s
///
public int ReStartDelay { get; set; }
///
/// 有按样标定硬件
///
public bool HasProfileSample { get; set; }
///
/// 有小托辊
///
public bool HasHold { get; set; }
///
/// 打孔器偏移量
///
public int PunchOffset { get; set; }
///
/// 有打孔器
///
public bool HasPunch { get; set; }
///
/// 有纵向光纤传感器
///
public bool HasVSign { get; set; }
///
/// 纵向光纤传感器与X光偏移 mm
///
public int VSignOffset { get; set; }
///
/// 有横向光纤传感器
///
public bool HasHSign { get; set; }
///
/// 有机架修正功能
///
public bool HasScanCorr { get; set; }
#region 速度
///
/// 扫描时速度 Velocity Of Scan
///
public UInt32 VScan { get; set; }
///
/// 调试时速度,向前走,向后走 Velocity Of JOG
///
public UInt32 VJOG { get; set; }
///
/// 精确速度 Velocity Of Accuracy 如: 机架修正, 样品取样, 机架信息获取
///
public UInt32 VAccuracy { set; get; }
///
/// 开始速度 Start Velocity
///
public UInt32 SVelocity { set; get; }
///
/// 加速时间
///
public UInt32 ATime { set; get; }
///
/// 减速时间
///
public UInt32 DTime { set; get; }
///
/// 归0速度1
///
public UInt32 HVelocity1 { set; get; }
///
/// 归0速度2
///
public UInt32 HVelocity2 { set; get; }
#endregion
#endregion
#region Command
public RelayCommand ApplyCmd { get; }
#endregion
IInitParamService initParamService;
public PgInitParamVm()
{
ApplyCmd = new RelayCommand(Apply);
}
public void Init(IInitParamService initParamService)
{
this.initParamService = initParamService;
Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.PosLength), this, nameof(PosLength));
Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.IsTimeGridAdvEnabled), this, nameof(IsTimeGridAdvEnabled));
Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.AutoOrgInterval), this, nameof(AutoOrgInterval));
Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.Encoder1_mmpp), this, nameof(Encoder1_mmpp));
Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.Speed1Scale), this, nameof(Speed1Scale));
Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.FilmVSrc), this, nameof(FilmVSrc));
Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.FilmVThreshold), this, nameof(FilmVThreshold));
Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.Encoder2_mmpp), this, nameof(Encoder2_mmpp));
Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.MmOfR), this, nameof(MmOfR));
Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.DataValidSrc), this, nameof(DataValidSrc));
Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.AutoF1F3), this, nameof(AutoF1F3));
Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.ReStartDelay), this, nameof(ReStartDelay));
Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.HasProfileSample), this, nameof(HasProfileSample));
Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.HasHold), this, nameof(HasHold));
Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.VScan), this, nameof(VScan));
Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.VJOG), this, nameof(VJOG));
Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.VAccuracy), this, nameof(VAccuracy));
Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.SVelocity), this, nameof(SVelocity));
Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.ATime), this, nameof(ATime));
Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.DTime), this, nameof(DTime));
Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.HVelocity1), this, nameof(HVelocity1));
Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.HVelocity2), this, nameof(HVelocity2));
Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.PunchOffset), this, nameof(PunchOffset));
Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.HasPunch), this, nameof(HasPunch));
Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.VSignOffset), this, nameof(VSignOffset));
Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.HasVSign), this, nameof(HasVSign));
Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.HasHSign), this, nameof(HasHSign));
Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.HasScanCorr), this, nameof(HasScanCorr));
}
private void Apply()
{
if (!WdPassword.Authorize("InitParam"))
return;
initParamService.PosLength = this.PosLength;
initParamService.IsTimeGridAdvEnabled = this.IsTimeGridAdvEnabled;
initParamService.AutoOrgInterval = this.AutoOrgInterval;
initParamService.Encoder1_mmpp = this.Encoder1_mmpp;
initParamService.Speed1Scale = this.Speed1Scale;
initParamService.FilmVSrc = this.FilmVSrc;
initParamService.FilmVThreshold = this.FilmVThreshold;
initParamService.Encoder2_mmpp = this.Encoder2_mmpp;
initParamService.MmOfR = this.MmOfR;
initParamService.DataValidSrc = this.DataValidSrc;
initParamService.AutoF1F3 = this.AutoF1F3;
initParamService.ReStartDelay = this.ReStartDelay;
initParamService.HasProfileSample = this.HasProfileSample;
initParamService.HasHold = this.HasHold;
initParamService.VScan = this.VScan;
initParamService.VJOG = this.VJOG;
initParamService.VAccuracy = this.VAccuracy;
initParamService.SVelocity = this.SVelocity;
initParamService.ATime = this.ATime;
initParamService.DTime = this.DTime;
initParamService.HVelocity1 = this.HVelocity1;
initParamService.HVelocity2 = this.HVelocity2;
initParamService.HasPunch = this.HasPunch;
initParamService.PunchOffset = this.PunchOffset;
initParamService.HasVSign = this.HasVSign;
initParamService.VSignOffset = this.VSignOffset;
initParamService.HasHSign = this.HasHSign;
initParamService.HasScanCorr = this.HasScanCorr;
initParamService.Apply();
FLY.ControlLibrary.Window_Tip.Show("应用成功",
null,
TimeSpan.FromSeconds(2));
}
}
}