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.
31 lines
921 B
31 lines
921 B
using EGFramework; |
|
|
|
public class RequestTargetControl : ModbusRTU_WriteMultiHoldingRegister, IEGFramework |
|
{ |
|
public bool IsBack { set; get; } = false; |
|
public ushort Speed { set; get; } = 2000; |
|
public ushort Position { set; get; } = 0; |
|
|
|
public RequestTargetControl(ushort speed,ushort position,bool isBack) |
|
{ |
|
this.DeviceAddress = 0x01; |
|
this.RegisterStartAddress = 68; |
|
this.Speed = speed; |
|
this.Position = position; |
|
this.IsBack = isBack; |
|
this.Values = GetValues(); |
|
EG.Print("[TargetSend]" + this.ToProtocolByteData().ToStringByHex()); |
|
} |
|
public ushort[] GetValues() |
|
{ |
|
ushort[] resultValues = { Speed,0x00,0x00,Position}; |
|
if (IsBack) |
|
{ |
|
ushort max = 65535; |
|
resultValues[2] = max; |
|
resultValues[3] = (ushort)(max - Position); |
|
} |
|
|
|
return resultValues; |
|
} |
|
}
|
|
|