操控平台后端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

174 lines
4.9 KiB

using Bodk.Device.Storage.EventArgs;
namespace Bodk.Device.Storage.Modules;
/// <summary>
/// 龙门X
/// </summary>
/// <param name="alarmEventHandler"></param>
/// <param name="motionTimeoutAlarmEventHandler"></param>
/// <param name="writeCoilRegisterFunc"></param>
/// <param name="readCoilRegisterFunc"></param>
/// <param name="readHoldingRegistersFunc"></param>
/// <param name="writeHoldingRegistersFunc"></param>
public class GantryX(
Action<object?, AlarmChangedEventArg> alarmEventHandler,
Action<object?, MotionTimeoutAlarmChangedEventArg> motionTimeoutAlarmEventHandler,
Func<ushort, bool[], Task> writeCoilRegisterFunc,
Func<ushort, ushort, Task<bool[]>> readCoilRegisterFunc,
Func<ushort, ushort, Task<ushort[]>> readHoldingRegistersFunc,
Func<ushort, ushort[], Task> writeHoldingRegistersFunc)
: ModuleBase(alarmEventHandler, motionTimeoutAlarmEventHandler, writeCoilRegisterFunc, readCoilRegisterFunc,
readHoldingRegistersFunc, writeHoldingRegistersFunc)
{
public override string Name => "GantryX";
public override string Descirption => "龙门X轴";
public override int Id => 5;
internal override ushort? EnableAddress => 104;
internal override ushort? ResetAddress => 124;
internal override ushort? CleanAddress => 144;
internal override ushort? GotoOriginAddress => 164;
internal override ushort? ForwardAddress => 184;
internal override ushort? BackwardAddress => 204;
internal override ushort? RelativeMoveAddress => 224;
internal override ushort? AbsoluteMoveAddress => 244;
internal override ushort? MotionTimeoutAlarmAddress => 284;
internal override ushort? AlarmAddress => 304;
internal override ushort? IsEnabledAddress => 334;
internal override ushort? OriginFlagAddress => 354;
internal override ushort? MoveDistanceAddress => 108;
internal override ushort? CurrentPositionAddress => 132;
internal override ushort? ManualSpeedAddress => 1008;
internal override ushort? AutoSpeedAddress => 1048;
internal override ushort? AccDecAddress => 1088;
internal override ushort? GotoOriginHighSpeedAddress => 1128;
internal override ushort? GotoOriginLowSpeedAddress => 1152;
internal ushort StandbyAddress => 1420;
internal ushort GraspFoamLidAddress => 1422;
internal ushort PlaceFoamLidAddress => 1424;
internal ushort BipolarModuleAAddress => 1384;
internal ushort BipolarModuleBAddress => 1386;
internal ushort BipolarModuleCAddress => 1388;
internal ushort UnipolarModuleAAddress => 1390;
internal ushort UnipolarModuleBAddress => 1392;
internal ushort UnipolarModuleCAddress => 1394;
/// <summary>
/// 移动到待机位
/// </summary>
public async Task MoveToStandbyPositionAsync()
{
await AbsoluteMoveAsync(await ReadFloat(StandbyAddress));
}
/// <summary>
/// 移动到抓取泡沫盖位
/// </summary>
public async Task MoveToGraspFoamLidPositionAsync()
{
await AbsoluteMoveAsync(await ReadFloat(GraspFoamLidAddress));
}
/// <summary>
/// 移动到放泡沫盖位
/// </summary>
public async Task MoveToPlaceFoamLidPositionAsync()
{
await AbsoluteMoveAsync(await ReadFloat(PlaceFoamLidAddress));
}
/// <summary>
/// 移动到双极模组A位
/// </summary>
public async Task MoveToBipolarModuleAPositionAsync()
{
await AbsoluteMoveAsync(await ReadFloat(BipolarModuleAAddress));
}
/// <summary>
/// 移动到双极模组B位
/// </summary>
public async Task MoveToBipolarModuleBPositionAsync()
{
await AbsoluteMoveAsync(await ReadFloat(BipolarModuleBAddress));
}
/// <summary>
/// 移动到双极模组C位
/// </summary>
public async Task MoveToBipolarModuleCPositionAsync()
{
await AbsoluteMoveAsync(await ReadFloat(BipolarModuleCAddress));
}
/// <summary>
/// 移动到单极模组A位
/// </summary>
public async Task MoveToUnipolarModuleAPositionAsync()
{
await AbsoluteMoveAsync(await ReadFloat(UnipolarModuleAAddress));
}
/// <summary>
/// 移动到单极模组B位
/// </summary>
public async Task MoveToUnipolarModuleBPositionAsync()
{
await AbsoluteMoveAsync(await ReadFloat(UnipolarModuleBAddress));
}
/// <summary>
/// 移动到单极模组C位
/// </summary>
public async Task MoveToUnipolarModuleCPositionAsync()
{
await AbsoluteMoveAsync(await ReadFloat(UnipolarModuleCAddress));
}
/// <summary>
/// 待机位
/// </summary>
public float StandbyPosition
{
get
{
_standbyPosition ??= ReadFloat(StandbyAddress).Result;
return _standbyPosition.Value;
}
set
{
_standbyPosition = value;
WriteFloat(StandbyAddress, value);
}
}
private float? _standbyPosition;
}