靶机服务端(适用于Linux系统控制靶机的情况)
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.

43 lines
1.2 KiB

4 weeks ago
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;
}
}
public class RequestTargetResetPosition : ModbusRTU_WriteSingleHoldingRegister, IEGFramework
{
public RequestTargetResetPosition()
{
this.DeviceAddress = 0x01;
this.RegisterAddress = 0x700A;
this.Value = 0x01;
EG.Print("[TargetSend]" + this.ToProtocolByteData().ToStringByHex());
}
}