Commit 5207ee25 authored by 潘栩锋's avatar 潘栩锋 🚴

1.修复 flyad.B2 开机速度写入 0xFFFFFFFF。 B2程序写错,手动速度 用了 扫描速度,且一开机写了0xFFFFFFFF,导致一开机手动正转,就会快过头,撞烂探头

2.优化 flyad.B2 使用批量写入,启动初始化从 2.4s 缩短到 1s
parent 7bc1dcf7
using AutoMapper; #define ENABLE_MULTI_TRANS
using AutoMapper;
using FlyADBase.Inc; using FlyADBase.Inc;
using FObjBase; using FObjBase;
using GeneralGommunication; using GeneralGommunication;
...@@ -11,6 +13,8 @@ using System.ComponentModel; ...@@ -11,6 +13,8 @@ using System.ComponentModel;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
namespace FlyADBase namespace FlyADBase
{ {
public partial class FlyAd2021B2 : IFlyADClient public partial class FlyAd2021B2 : IFlyADClient
...@@ -667,8 +671,9 @@ namespace FlyADBase ...@@ -667,8 +671,9 @@ namespace FlyADBase
//从设备读取参数 //从设备读取参数
//获取当前全部状态 //获取当前全部状态
//core.BuildMultiTrans(() => #if ENABLE_MULTI_TRANS
//{ core.BuildMultiTrans(() =>{
#endif
core.GetSysParam_Jog((asyncContext, retData) => JogVelocity = (UInt32)retData, null); core.GetSysParam_Jog((asyncContext, retData) => JogVelocity = (UInt32)retData, null);
core.GetSysParam_Zero((asyncContext, retData) => PosOffset = (Int16)retData, null); core.GetSysParam_Zero((asyncContext, retData) => PosOffset = (Int16)retData, null);
core.GetSysParam_MotorType((asyncContext, retData) => MotorType = (MOTORTYPE)retData, null); core.GetSysParam_MotorType((asyncContext, retData) => MotorType = (MOTORTYPE)retData, null);
...@@ -681,26 +686,26 @@ namespace FlyADBase ...@@ -681,26 +686,26 @@ namespace FlyADBase
core.GetRunParam_DecTime((asyncContext, retData) => DTime = (UInt32)retData, null); core.GetRunParam_DecTime((asyncContext, retData) => DTime = (UInt32)retData, null);
core.GetRunParam_HSpd1((asyncContext, retData) => HVelocity1 = (UInt32)retData, null); core.GetRunParam_HSpd1((asyncContext, retData) => HVelocity1 = (UInt32)retData, null);
core.GetRunParam_HSpd2((asyncContext, retData) => HVelocity2 = (UInt32)retData, null); core.GetRunParam_HSpd2((asyncContext, retData) => HVelocity2 = (UInt32)retData, null);
//}); #if ENABLE_MULTI_TRANS
});
#endif
} }
else else
{ {
//参数不保存在设备中, 保存在电脑。 //参数不保存在设备中, 保存在电脑。
//参数写入到设备。 //参数写入到设备。
//core.BuildMultiTrans(() => #if ENABLE_MULTI_TRANS
//{ core.BuildMultiTrans(() =>{
#endif
core.SetSysParam_MotorType(MotorType, null, null); core.SetSysParam_MotorType(MotorType, null, null);
core.SetSysParam_Ratio01(Ratio01, null, null); core.SetSysParam_Ratio01(Ratio01, null, null);
core.SetSysParam_Ratio02(Ratio02, null, null); core.SetSysParam_Ratio02(Ratio02, null, null);
core.SetSysParam_Zero(PosOffset, null, null); core.SetSysParam_Zero(PosOffset, null, null);
core.SetSysParam_Jog(JogVelocity, null, null); core.SetSysParam_Jog(JogVelocity, null, null);
core.SetSysParam_Apply(null, null); core.SetSysParam_Apply(null, null);
//}); #if ENABLE_MULTI_TRANS
//NotifyPropertyChanged(nameof(MotorType)); });
//NotifyPropertyChanged(nameof(Ratio01)); #endif
//NotifyPropertyChanged(nameof(Ratio02));
//NotifyPropertyChanged(nameof(PosOffset));
//NotifyPropertyChanged(nameof(JogVelocity));
} }
GetAccess(); GetAccess();
...@@ -710,13 +715,17 @@ namespace FlyADBase ...@@ -710,13 +715,17 @@ namespace FlyADBase
isReadyContext.Reset(); isReadyContext.Reset();
sysTickContext.Reset(); sysTickContext.Reset();
calSpeed.Reset(); calSpeed.Reset();
#if ENABLE_MULTI_TRANS
GetRunResult(); core.BuildMultiTrans(() =>{
#endif
GetOut(); GetRunResult();
GetIn(); GetOut();
GetEnc1(); GetIn();
GetEnc2(); GetEnc1();
GetEnc2();
#if ENABLE_MULTI_TRANS
});
#endif
advAfterContected(); advAfterContected();
...@@ -887,37 +896,44 @@ namespace FlyADBase ...@@ -887,37 +896,44 @@ namespace FlyADBase
/// <param name="enable"></param> /// <param name="enable"></param>
public void SetOutput(UInt16 mask, UInt16 enable) public void SetOutput(UInt16 mask, UInt16 enable)
{ {
core.SetOutPorts(mask, enable, (asyncConetext, _retData) => #if ENABLE_MULTI_TRANS
{ core.BuildMultiTrans(() =>{
#endif
core.SetOutPorts(mask, enable, null, null);
GetOut(); GetOut();
}, null); #if ENABLE_MULTI_TRANS
});
#endif
} }
#region 速度参数 #region 速度参数
/// <summary> /// <summary>
/// 设置速度参数 /// 设置速度参数
/// </summary> /// </summary>
/// <param name="velocity">runto 速度 pps</param>
/// <param name="sv">开始速度 pps</param> /// <param name="sv">开始速度 pps</param>
/// <param name="atime">加速时间 ms</param> /// <param name="atime">加速时间 ms</param>
/// <param name="dtime">减速时间 ms</param> /// <param name="dtime">减速时间 ms</param>
/// <param name="hspeed1">归0 第1段速 pps</param> /// <param name="hspeed1">归0 第1段速 pps</param>
/// <param name="hspeed2">归0 第2段速 pps</param> /// <param name="hspeed2">归0 第2段速 pps</param>
public void SetPosParam(UInt32 velocity, UInt32 sv, UInt32 atime, UInt32 dtime, UInt32 hspeed1, UInt32 hspeed2) public void SetPosParam(UInt32 sv, UInt32 atime, UInt32 dtime, UInt32 hspeed1, UInt32 hspeed2)
{ {
core.SetRunParam_V(velocity, null, null); #if ENABLE_MULTI_TRANS
core.SetRunParam_SV(sv, null, null); core.BuildMultiTrans(() =>{
core.SetRunParam_AccTime(atime, null, null); #endif
core.SetRunParam_DecTime(dtime, null, null); core.SetRunParam_SV(sv, null, null);
core.SetRunParam_HSpd1(hspeed1, null, null); core.SetRunParam_AccTime(atime, null, null);
core.SetRunParam_HSpd2(hspeed2, null, null); core.SetRunParam_DecTime(dtime, null, null);
core.SetRunParam_HSpd1(hspeed1, null, null);
core.GetRunParam_V((asyncContext, retData) => Velocity = (UInt32)retData, null); core.SetRunParam_HSpd2(hspeed2, null, null);
core.GetRunParam_SV((asyncContext, retData) => SVelocity = (UInt32)retData, null);
core.GetRunParam_AccTime((asyncContext, retData) => ATime = (UInt32)retData, null); core.GetRunParam_SV((asyncContext, retData) => SVelocity = (UInt32)retData, null);
core.GetRunParam_DecTime((asyncContext, retData) => DTime = (UInt32)retData, null); core.GetRunParam_AccTime((asyncContext, retData) => ATime = (UInt32)retData, null);
core.GetRunParam_HSpd1((asyncContext, retData) => HVelocity1 = (UInt32)retData, null); core.GetRunParam_DecTime((asyncContext, retData) => DTime = (UInt32)retData, null);
core.GetRunParam_HSpd2((asyncContext, retData) => HVelocity2 = (UInt32)retData, null); core.GetRunParam_HSpd1((asyncContext, retData) => HVelocity1 = (UInt32)retData, null);
core.GetRunParam_HSpd2((asyncContext, retData) => HVelocity2 = (UInt32)retData, null);
#if ENABLE_MULTI_TRANS
});
#endif
} }
/// <summary> /// <summary>
/// 设置速度 /// 设置速度
...@@ -925,9 +941,15 @@ namespace FlyADBase ...@@ -925,9 +941,15 @@ namespace FlyADBase
/// <param name="velocity"></param> /// <param name="velocity"></param>
public void SetVelocity(UInt32 velocity) public void SetVelocity(UInt32 velocity)
{ {
core.SetRunParam_V(velocity, null, null); #if ENABLE_MULTI_TRANS
core.BuildMultiTrans(() =>{
core.GetRunParam_V((asyncContext, retData) => Velocity = (UInt32)retData, null); #endif
core.SetRunParam_V(velocity, null, null);
core.GetRunParam_V((asyncContext, retData) => Velocity = (UInt32)retData, null);
#if ENABLE_MULTI_TRANS
});
#endif
} }
...@@ -999,9 +1021,9 @@ namespace FlyADBase ...@@ -999,9 +1021,9 @@ namespace FlyADBase
core.Forw(126, null, null); core.Forw(126, null, null);
} }
#endregion #endregion
#endregion #endregion
} }
......
...@@ -125,13 +125,12 @@ namespace FlyADBase ...@@ -125,13 +125,12 @@ namespace FlyADBase
/// <summary> /// <summary>
/// 设置速度参数 /// 设置速度参数
/// </summary> /// </summary>
/// <param name="velocity">runto 速度 pps</param>
/// <param name="sv">开始速度 pps</param> /// <param name="sv">开始速度 pps</param>
/// <param name="atime">加速时间 ms</param> /// <param name="atime">加速时间 ms</param>
/// <param name="dtime">减速时间 ms</param> /// <param name="dtime">减速时间 ms</param>
/// <param name="hspeed1">归0 第1段速 pps</param> /// <param name="hspeed1">归0 第1段速 pps</param>
/// <param name="hspeed2">归0 第2段速 pps</param> /// <param name="hspeed2">归0 第2段速 pps</param>
void SetPosParam(UInt32 velocity, UInt32 sv, UInt32 atime, UInt32 dtime, UInt32 hspeed1, UInt32 hspeed2); void SetPosParam(UInt32 sv, UInt32 atime, UInt32 dtime, UInt32 hspeed1, UInt32 hspeed2);
/// <summary> /// <summary>
/// 设置速度 /// 设置速度
/// </summary> /// </summary>
......
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