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 FObjBase;
using GeneralGommunication;
......@@ -11,6 +13,8 @@ using System.ComponentModel;
using System.IO;
using System.Linq;
namespace FlyADBase
{
public partial class FlyAd2021B2 : IFlyADClient
......@@ -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_Zero((asyncContext, retData) => PosOffset = (Int16)retData, null);
core.GetSysParam_MotorType((asyncContext, retData) => MotorType = (MOTORTYPE)retData, null);
......@@ -681,26 +686,26 @@ namespace FlyADBase
core.GetRunParam_DecTime((asyncContext, retData) => DTime = (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
}
else
{
//参数不保存在设备中, 保存在电脑。
//参数写入到设备。
//core.BuildMultiTrans(() =>
//{
#if ENABLE_MULTI_TRANS
core.BuildMultiTrans(() =>{
#endif
core.SetSysParam_MotorType(MotorType, null, null);
core.SetSysParam_Ratio01(Ratio01, null, null);
core.SetSysParam_Ratio02(Ratio02, null, null);
core.SetSysParam_Zero(PosOffset, null, null);
core.SetSysParam_Jog(JogVelocity, null, null);
core.SetSysParam_Apply(null, null);
//});
//NotifyPropertyChanged(nameof(MotorType));
//NotifyPropertyChanged(nameof(Ratio01));
//NotifyPropertyChanged(nameof(Ratio02));
//NotifyPropertyChanged(nameof(PosOffset));
//NotifyPropertyChanged(nameof(JogVelocity));
#if ENABLE_MULTI_TRANS
});
#endif
}
GetAccess();
......@@ -710,13 +715,17 @@ namespace FlyADBase
isReadyContext.Reset();
sysTickContext.Reset();
calSpeed.Reset();
#if ENABLE_MULTI_TRANS
core.BuildMultiTrans(() =>{
#endif
GetRunResult();
GetOut();
GetIn();
GetEnc1();
GetEnc2();
#if ENABLE_MULTI_TRANS
});
#endif
advAfterContected();
......@@ -887,37 +896,44 @@ namespace FlyADBase
/// <param name="enable"></param>
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();
}, null);
#if ENABLE_MULTI_TRANS
});
#endif
}
#region 速度参数
#region 速度参数
/// <summary>
/// 设置速度参数
/// </summary>
/// <param name="velocity">runto 速度 pps</param>
/// <param name="sv">开始速度 pps</param>
/// <param name="atime">加速时间 ms</param>
/// <param name="dtime">减速时间 ms</param>
/// <param name="hspeed1">归0 第1段速 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.BuildMultiTrans(() =>{
#endif
core.SetRunParam_SV(sv, null, null);
core.SetRunParam_AccTime(atime, null, null);
core.SetRunParam_DecTime(dtime, null, null);
core.SetRunParam_HSpd1(hspeed1, null, null);
core.SetRunParam_HSpd2(hspeed2, null, null);
core.GetRunParam_V((asyncContext, retData) => Velocity = (UInt32)retData, null);
core.GetRunParam_SV((asyncContext, retData) => SVelocity = (UInt32)retData, null);
core.GetRunParam_AccTime((asyncContext, retData) => ATime = (UInt32)retData, null);
core.GetRunParam_DecTime((asyncContext, retData) => DTime = (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>
/// 设置速度
......@@ -925,9 +941,15 @@ namespace FlyADBase
/// <param name="velocity"></param>
public void SetVelocity(UInt32 velocity)
{
#if ENABLE_MULTI_TRANS
core.BuildMultiTrans(() =>{
#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
core.Forw(126, null, null);
}
#endregion
#endregion
#endregion
#endregion
}
......
......@@ -125,13 +125,12 @@ namespace FlyADBase
/// <summary>
/// 设置速度参数
/// </summary>
/// <param name="velocity">runto 速度 pps</param>
/// <param name="sv">开始速度 pps</param>
/// <param name="atime">加速时间 ms</param>
/// <param name="dtime">减速时间 ms</param>
/// <param name="hspeed1">归0 第1段速 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>
......
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