操控平台后端代码
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.

131 lines
3.7 KiB

using Bodk.Device.Storage.EventArgs;
namespace Bodk.Device.Storage.Modules;
/// <summary>
/// 转盘
/// </summary>
/// <param name="alarmEventHandler"></param>
/// <param name="motionTimeoutAlarmEventHandler"></param>
/// <param name="writeCoilsRegisterFunc"></param>
/// <param name="readCoilsRegisterFunc"></param>
/// <param name="readHoldingRegistersFunc"></param>
/// <param name="writeHoldingRegistersFunc"></param>
public class Turntable(
Action<object?, AlarmChangedEventArg> alarmEventHandler,
Action<object?, MotionTimeoutAlarmChangedEventArg> motionTimeoutAlarmEventHandler,
Func<ushort, bool[], Task> writeCoilsRegisterFunc,
Func<ushort, ushort, Task<bool[]>> readCoilsRegisterFunc,
Func<ushort, ushort, Task<ushort[]>> readHoldingRegistersFunc,
Func<ushort, ushort[], Task> writeHoldingRegistersFunc)
: ModuleBase(alarmEventHandler, motionTimeoutAlarmEventHandler, writeCoilsRegisterFunc, readCoilsRegisterFunc,
readHoldingRegistersFunc, writeHoldingRegistersFunc)
{
public override string Name => "Turntable";
public override string Descirption => "转盘";
public override int Id => 1;
internal override ushort? MotionTimeoutAlarmAddress => 280;
internal override ushort? AlarmAddress => 300;
internal override ushort? IsEnabledAddress => 330;
internal override ushort? EnableAddress => 100;
internal override ushort? ResetAddress => 120;
internal override ushort? CleanAddress => 140;
internal override ushort? GotoOriginAddress => 160;
internal override ushort? OriginFlagAddress => 350;
internal override ushort? ForwardAddress => 180;
internal override ushort? BackwardAddress => 200;
internal override ushort? RelativeMoveAddress => 220;
internal override ushort? AbsoluteMoveAddress => 240;
internal override ushort? MoveDistanceAddress => 100;
internal override ushort? CurrentPositionAddress => 124;
internal override ushort? ManualSpeedAddress => 1000;
internal override ushort? AutoSpeedAddress => 1040;
internal override ushort? AccDecAddress => 1080;
internal override ushort? GotoOriginHighSpeedAddress => 1120;
internal override ushort? GotoOriginLowSpeedAddress => 1144;
private static ushort A1PositionAddress => 1364;
private static ushort B1PositionAddress => 1366;
private static ushort C1PositionAddress => 1368;
/// <summary>
/// A1坐标
/// </summary>
public float A1Position
{
get
{
_a1Position ??= ReadFloat(A1PositionAddress).Result;
return _a1Position.Value;
}
set
{
_a1Position = value;
WriteFloat(A1PositionAddress, value).Wait();
_a1Position = ReadFloat(A1PositionAddress).Result;
}
}
/// <summary>
/// B1坐标
/// </summary>
public float B1Position
{
get
{
_b1Position ??= ReadFloat(B1PositionAddress).Result;
return _b1Position.Value;
}
set
{
_b1Position = value;
WriteFloat(B1PositionAddress, value).Wait();
_b1Position = ReadFloat(B1PositionAddress).Result;
}
}
/// <summary>
/// C1坐标
/// </summary>
public float C1Position
{
get
{
_c1Position ??= ReadFloat(C1PositionAddress).Result;
return _c1Position.Value;
}
set
{
_c1Position = value;
WriteFloat(C1PositionAddress, value).Wait();
_c1Position = ReadFloat(C1PositionAddress).Result;
}
}
private float? _a1Position;
private float? _b1Position;
private float? _c1Position;
}