Commit 0458a2a4 authored by 潘栩锋's avatar 潘栩锋 🚴

添加 flyad添加电脑备份AD盒参数。

parent 87cb1e4e
......@@ -232,6 +232,7 @@
<TextBox Style="{StaticResource TextBoxStyle_itemContent}" Text="{Binding HVelocity2}" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<Button Content="设置" Command="{Binding SetVelocityParamCmd}" Style="{StaticResource ButtonStyle}"/>
<Button Content="保存" Click="button_save_velocity_Click" Style="{StaticResource ButtonStyle}"/>
<Button Content="加载" Click="button_load_velocity_Click" Style="{StaticResource ButtonStyle}"/>
</StackPanel>
......
......@@ -24,6 +24,7 @@ using Microsoft.Win32;
using System.IO;
using System.Threading.Tasks;
using Unity;
using GalaSoft.MvvmLight.Command;
namespace Flyad7_WPF
{
......@@ -40,6 +41,8 @@ namespace Flyad7_WPF
AutoSync mAutoSync;
AutoGetGridAdv autoGetGridAdv;
GridAdvVm gridAdvVm;
MainWindowVm viewModel;
public MainWindow()
{
InitializeComponent();
......@@ -60,7 +63,8 @@ namespace Flyad7_WPF
mAutoSync = Container.Resolve<AutoSync>();
gridAdvVm = Container.Resolve<GridAdvVm>();
gridAdvVm.Init(chart3);
viewModel = new MainWindowVm();
this.DataContext = flyad;
this.grid_viewModel.DataContext = this;
......@@ -73,6 +77,7 @@ namespace Flyad7_WPF
flyad.GridEvent += flyad_GridEvent;
flyad.TimeGridEvent += flyad_TimeGridEvent;
groupBox4.DataContext = viewModel;
FObjBase.PollModule.Current.Start();
}
......@@ -638,4 +643,64 @@ namespace Flyad7_WPF
}
}
public class MainWindowVm : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// runto 速度 pps
/// </summary>
public UInt32 Velocity { get; set; } = 8000;
/// <summary>
/// 开始速度 pps
/// </summary>
public UInt32 SVelocity { get; set; } = 200;
/// <summary>
/// 加速时间 ms
/// </summary>
public UInt32 ATime { get; set; } = 300;
/// <summary>
/// 减速时间 ms
/// </summary>
public UInt32 DTime { get; set; } = 200;
/// <summary>
/// 归0 第1段速 pps
/// </summary>
public UInt32 HVelocity1 { get; set; } = 4000;
/// <summary>
/// 归0 第2段速 pps
/// </summary>
public UInt32 HVelocity2 { get; set; } = 500;
public RelayCommand SetVelocityParamCmd { get; private set; }
FlyAD7 flyAD7;
public MainWindowVm() {
SetVelocityParamCmd = new RelayCommand(SetVelocityParam);
}
public void Init(FlyAD7 flyAD7)
{
this.flyAD7 = flyAD7;
Misc.BindingOperations.SetBinding(this.flyAD7, nameof(this.flyAD7.Velocity), this, nameof(Velocity));
Misc.BindingOperations.SetBinding(this.flyAD7, nameof(this.flyAD7.SVelocity), this, nameof(SVelocity));
Misc.BindingOperations.SetBinding(this.flyAD7, nameof(this.flyAD7.ATime), this, nameof(ATime));
Misc.BindingOperations.SetBinding(this.flyAD7, nameof(this.flyAD7.DTime), this, nameof(DTime));
Misc.BindingOperations.SetBinding(this.flyAD7, nameof(this.flyAD7.HVelocity1), this, nameof(HVelocity1));
Misc.BindingOperations.SetBinding(this.flyAD7, nameof(this.flyAD7.HVelocity2), this, nameof(HVelocity2));
}
private void SetVelocityParam()
{
flyAD7.SetPosParam(Velocity, SVelocity, ATime, DTime, HVelocity1, HVelocity2);
}
}
}
......@@ -62,23 +62,11 @@
<Button Content="清空主轴列表" Click="button_pos2clear_Click" />
</WrapPanel>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="3">
<Button Content="纵向偏移设置" Click="button_setPos2Shift_Click" />
<TextBox Text="{Binding Pos2Shift}" />
</StackPanel>
<StackPanel Orientation="Vertical" Margin="3">
<TextBlock Margin="3" Name="textBlock_pos2Comp" FontSize="16">
<Run Text="纵向补偿:" />
<Run Text="{Binding Pos2Comp, Mode=OneWay}" />
</TextBlock>
<StackPanel Orientation="Horizontal">
<Button Content="设置" Click="button_pos2comp_Click"/>
<TextBox Text="{Binding Pos2Comp}"/>
</StackPanel>
</StackPanel>
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal" Margin="3">
<Button Content="纵向偏移设置" Click="button_setPos2Shift_Click" />
<TextBox Text="{Binding Pos2Shift}" />
</StackPanel>
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<Button Content="进入同步状态" Click="button_syncBegin_Click" />
<TextBox Text="{Binding Distance}" />
......
......@@ -40,7 +40,6 @@ namespace Flyad7_WPF
this.flyad = flyad;
this.mAutoSync = mAutoSync;
textBlock_pos1LCShift.DataContext = this.flyad;
textBlock_pos2Comp.DataContext = this.flyad;
textBlock_position2.DataContext = this.flyad;
textBlock_marker.DataContext = this.flyad;
......@@ -113,8 +112,7 @@ namespace Flyad7_WPF
private void button_pos2comp_Click(object sender, RoutedEventArgs e)
{
flyad.Pos2Comp = Pos2Comp;
MessageBox.Show("flyad.Pos2Comp = " + Pos2Comp.ToString() );
}
private void button_clear_Click(object sender, RoutedEventArgs e)
......
......@@ -24,10 +24,11 @@ namespace FLY.Thick.Base.UI
public void Init(
IUnityContainer container,
IFlyADService flyAdService,
ITDGageService gageService)
ITDGageService gageService,
IInitParamService initParamService)
{
viewModel = new PgFlyAdVm();
viewModel.Init(flyAdService, gageService);
viewModel.Init(flyAdService, gageService, initParamService);
this.DataContext = viewModel;
container.BuildUp(mircoGage);
}
......@@ -49,12 +50,72 @@ namespace FLY.Thick.Base.UI
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
#region 备份参数
public MOTORTYPE Backup_MotorType { get; set; } = MOTORTYPE.SERVO;
public UInt16 Backup_PosOfGrid { get; set; } = 10;
public UInt16 Backup_Ratio01 { get; set; } = 4;
public UInt16 Backup_Ratio02 { get; set; } = 1;
public Int16 Backup_PosOffset { get; set; } = 0;
public UInt32 Backup_JogVelocity { get; set; } = 300;
#endregion
#region 备份参数
public bool IsMotorTypeModified => MotorType != Backup_MotorType;
public bool IsPosOfGridModified => PosOfGrid != Backup_PosOfGrid;
public bool IsRatio01Modified => Ratio01 != Backup_Ratio01;
public bool IsRatio02Modified => Ratio02 != Backup_Ratio02;
public bool IsPosOffsetModified => PosOffset != Backup_PosOffset;
public bool IsJogVelocityModified => JogVelocity != Backup_JogVelocity;
#endregion
#region initparam
public double Encoder1_mmpp { get; set; }
public int PosLength { get; set; }
/// <summary>
/// 设置的速度,与 实际速度比例 Speed1 = VScan*Speed1Scale
/// </summary>
public double Speed1Scale { get; set; }
#region 速度
/// <summary>
/// 调试时速度,向前走,向后走 Velocity Of JOG
/// </summary>
public UInt32 VJOG { get; set; }
/// <summary>
/// 开始速度 Start Velocity
/// </summary>
public UInt32 SVelocity { set; get; }
/// <summary>
/// 加速时间
/// </summary>
public UInt32 ATime { set; get; }
/// <summary>
/// 减速时间
/// </summary>
public UInt32 DTime { set; get; }
/// <summary>
/// 归0速度1
/// </summary>
public UInt32 HVelocity1 { set; get; }
/// <summary>
/// 归0速度2
/// </summary>
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; }
......@@ -64,6 +125,7 @@ namespace FLY.Thick.Base.UI
IFlyADService flyAdService;
ITDGageService gageService;
IInitParamService initParamService;
public PgFlyAdVm()
{
......@@ -77,7 +139,8 @@ namespace FLY.Thick.Base.UI
public void Init(
IFlyADService flyAdService,
ITDGageService gageService)
ITDGageService gageService,
IInitParamService initParamService)
{
this.flyAdService = flyAdService;
this.gageService = gageService;
......@@ -96,7 +159,29 @@ namespace FLY.Thick.Base.UI
Misc.BindingOperations.SetBinding(this.flyAdService, nameof(this.flyAdService.GridSmooth), this, nameof(GridSmooth));
Misc.BindingOperations.SetBinding(this.flyAdService, nameof(this.flyAdService.IsCalSpeed), this, nameof(IsCalSpeed));
Misc.BindingOperations.SetBinding(this.flyAdService, nameof(this.flyAdService.ADLag), this, nameof(ADLag));
Misc.BindingOperations.SetBinding(this.flyAdService, nameof(this.flyAdService.HasPosMaxMin), this, nameof(HasPosMaxMin));
Misc.BindingOperations.SetBinding(this.flyAdService, nameof(this.flyAdService.PosMin), this, nameof(PosMin));
Misc.BindingOperations.SetBinding(this.flyAdService, nameof(this.flyAdService.PosMax), this, nameof(PosMax));
Misc.BindingOperations.SetBinding(this.flyAdService, nameof(this.flyAdService.Backup_MotorType), this, nameof(Backup_MotorType));
Misc.BindingOperations.SetBinding(this.flyAdService, nameof(this.flyAdService.Backup_PosOfGrid), this, nameof(Backup_PosOfGrid));
Misc.BindingOperations.SetBinding(this.flyAdService, nameof(this.flyAdService.Backup_Ratio01), this, nameof(Backup_Ratio01));
Misc.BindingOperations.SetBinding(this.flyAdService, nameof(this.flyAdService.Backup_Ratio02), this, nameof(Backup_Ratio02));
Misc.BindingOperations.SetBinding(this.flyAdService, nameof(this.flyAdService.Backup_PosOffset), this, nameof(Backup_PosOffset));
Misc.BindingOperations.SetBinding(this.flyAdService, nameof(this.flyAdService.Backup_JogVelocity), this, nameof(Backup_JogVelocity));
Misc.BindingOperations.SetBinding(this.initParamService, nameof(this.initParamService.Encoder1_mmpp), this, nameof(Encoder1_mmpp));
Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.Speed1Scale), this, nameof(Speed1Scale));
Misc.BindingOperations.SetBinding(this.initParamService, nameof(this.initParamService.PosLength), this, nameof(PosLength));
Misc.BindingOperations.SetBinding(initParamService, nameof(initParamService.VJOG), this, nameof(VJOG));
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));
}
private void Apply()
{
......@@ -121,11 +206,46 @@ namespace FLY.Thick.Base.UI
flyAdService.IsCalSpeed = this.IsCalSpeed;
flyAdService.ADLag = this.ADLag;
flyAdService.HasPosMaxMin = this.HasPosMaxMin;
flyAdService.PosMin = this.PosMin;
flyAdService.PosMax = this.PosMax;
flyAdService.Backup_MotorType = this.MotorType;
flyAdService.Backup_PosOfGrid = this.PosOfGrid;
flyAdService.Backup_Ratio01 = this.Ratio01;
flyAdService.Backup_Ratio02 = this.Ratio02;
flyAdService.Backup_PosOffset = this.PosOffset;
flyAdService.Backup_JogVelocity = this.JogVelocity;
FLY.ControlLibrary.Window_Tip.Show("应用成功",
null,
TimeSpan.FromSeconds(2));
}
private void Apply2()
{
if (!WdPassword.Authorize("InitParam"))
return;
initParamService.Encoder1_mmpp = Encoder1_mmpp;
initParamService.PosLength = PosLength;
initParamService.VJOG = this.VJOG;
initParamService.SVelocity = this.SVelocity;
initParamService.ATime = this.ATime;
initParamService.DTime = this.DTime;
initParamService.HVelocity1 = this.HVelocity1;
initParamService.HVelocity2 = this.HVelocity2;
FLY.ControlLibrary.Window_Tip.Show("应用成功",
null,
TimeSpan.FromSeconds(2));
}
private void RunTo()
{
gageService.StartP2(STARTP2_MODE.RUNTO, TargetPos);
......
......@@ -52,6 +52,19 @@ namespace FLY.Thick.Base.Client
/// </summary>
public UInt32 JogVelocity { get; set; }
public int ADLag { get; set; }
public bool HasPosMaxMin { get; set; }
public int PosMin { get; set; }
public int PosMax { get; set; }
#region 备份参数
public MOTORTYPE Backup_MotorType { get; set; }
public UInt16 Backup_PosOfGrid { get; set; }
public UInt16 Backup_Ratio01 { get; set; }
public UInt16 Backup_Ratio02 { get; set; }
public Int16 Backup_PosOffset { get; set; }
public UInt32 Backup_JogVelocity { get; set; }
#endregion
/// <summary>
/// 参数应用
/// </summary>
......
......@@ -27,6 +27,19 @@ namespace FLY.Thick.Base.IService
bool IsCalSpeed { get; set; }
int ADLag { get; set; }
bool HasPosMaxMin { get; set; }
int PosMin { get; set; }
int PosMax { get; set; }
#region 备份参数
MOTORTYPE Backup_MotorType { get; set; }
UInt16 Backup_PosOfGrid { get; set; }
UInt16 Backup_Ratio01 { get; set; }
UInt16 Backup_Ratio02 { get; set; }
Int16 Backup_PosOffset { get; set; }
UInt32 Backup_JogVelocity { get; set; }
#endregion
/// <summary>
/// 获取序列码
/// </summary>
......
......@@ -149,6 +149,81 @@ namespace FLY.Thick.Base.Server
flyad.ADLag = value;
}
}
public bool HasPosMaxMin
{
get { return flyad.HasPosMaxMin; }
set
{
flyad.HasPosMaxMin = value;
}
}
public int PosMin
{
get { return flyad.PosMin; }
set
{
flyad.PosMin = value;
}
}
public int PosMax
{
get { return flyad.PosMax; }
set
{
flyad.PosMax = value;
}
}
public MOTORTYPE Backup_MotorType
{
get { return (MOTORTYPE)flyad.Backup_MotorType; }
set
{
flyad.Backup_MotorType = (FlyADBase.MOTORTYPE)value;
}
}
public UInt16 Backup_PosOfGrid
{
get { return flyad.Backup_PosOfGrid; }
set
{
flyad.Backup_PosOfGrid = value;
}
}
public UInt16 Backup_Ratio01
{
get { return flyad.Backup_Ratio01; }
set
{
flyad.Backup_Ratio01 = value;
}
}
public UInt16 Backup_Ratio02
{
get { return flyad.Backup_Ratio02; }
set
{
flyad.Backup_Ratio02 = value;
}
}
public Int16 Backup_PosOffset
{
get { return flyad.Backup_PosOffset; }
set
{
flyad.Backup_PosOffset = value;
}
}
public UInt32 Backup_JogVelocity
{
get { return flyad.Backup_JogVelocity; }
set
{
flyad.Backup_JogVelocity = value;
}
}
FlyAD7 flyad;
AD2ThkHandler ad2thk;
public FlyAdService()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment