using CommunityToolkit.Mvvm.Input;
using FLY.Thick.Base.Common;
using FLY.Thick.Base.IService;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using Unity;
namespace FLY.Thick.Base.UI
{
///
/// Page_FlyAD.xaml 的交互逻辑
///
public partial class PgFlyAd : Page
{
PgFlyAdVm viewModel;
public PgFlyAd()
{
InitializeComponent();
if (System.ComponentModel.LicenseManager.UsageMode != System.ComponentModel.LicenseUsageMode.Runtime)
return;
this.Loaded += UcGridGraph_Loaded;
this.Unloaded += UcGridGraph_Unloaded;
}
private void UcGridGraph_Unloaded(object sender, RoutedEventArgs e)
{
viewModel.DisposeBinding();
}
private void UcGridGraph_Loaded(object sender, RoutedEventArgs e)
{
viewModel.SetBinding();
}
[InjectionMethod]
public void Init(
IUnityContainer container,
IFlyADService flyAdService,
ITDGageService gageService,
IInitParamService initParamService)
{
viewModel = new PgFlyAdVm();
viewModel.Init(flyAdService, gageService, initParamService);
this.DataContext = viewModel;
container.BuildUp(mircoGage);
}
}
public class PgFlyAdVm : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
#region 参数
public IPEndPoint EP { get; set; }
public UInt16 PosOfGrid { get; set; }
public MOTORTYPE MotorType { set; get; }
public UInt16 Ratio01 { get; set; }
public UInt16 Ratio02 { get; set; }
public Int16 PosOffset { set; get; }//脉冲平移
public UInt32 JogVelocity { set; get; }
public int GridSmooth { get; set; }
public bool IsCalSpeed { get; set; }
public int ADLag { get; set; }
public bool HasPosMaxMin { get; set; }
public int PosMin { get; set; }
public int PosMax { get; set; }
#endregion
public int Version { get; set; }
public int HardwareVersion { get; set; }
#region initparam
public double Encoder1_mmpp { get; set; }
public int PosLength { get; set; }
///
/// 设置的速度,与 实际速度比例 Speed1 = VScan*Speed1Scale
///
public double Speed1Scale { get; set; }
#region 速度
///
/// 调试时速度,向前走,向后走 Velocity Of JOG
///
public UInt32 VJOG { get; set; }
///
/// 开始速度 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
public int TargetPos { get; set; }
#region Command
public RelayCommand ApplyCmd { get; }
public RelayCommand Apply2Cmd { get; }
public RelayCommand RunToCmd { get; }
public RelayCommand BackwCmd { get; }
public RelayCommand ForwCmd { get; }
public RelayCommand OrgCmd { get; }
public RelayCommand StopCmd { get; }
#endregion
IFlyADService flyAdService;
ITDGageService gageService;
IInitParamService initParamService;
Dictionary