靶机服务端(适用于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.
 
 
 
 

136 lines
3.2 KiB

using EGFramework;
public class RequestTrackEnabled : ModbusRTU_WriteSingleHoldingRegister, IEGFramework
{
public RequestTrackEnabled()
{
this.DeviceAddress = 0x03;
this.RegisterAddress = 0xB6;
this.Value = 0x01;
}
}
public class RequestTrackDisabled : ModbusRTU_WriteSingleHoldingRegister, IEGFramework
{
public RequestTrackDisabled()
{
this.DeviceAddress = 0x03;
this.RegisterAddress = 0xB6;
this.Value = 0x02;
}
}
public class RequestTrackSpeed: ModbusRTU_WriteSingleHoldingRegister, IEGFramework
{
public RequestTrackSpeed(ushort speed)
{
this.DeviceAddress = 0x03;
this.RegisterAddress = 0x56;
this.Value = speed;
}
}
public class RequestTrackStop : ModbusRTU_WriteSingleHoldingRegister, IEGFramework
{
public RequestTrackStop()
{
this.DeviceAddress = 0x03;
this.RegisterAddress = 0x66;
this.Value = 0x00;
}
}
public class RequestTrackMove : ModbusRTU_WriteSingleHoldingRegister, IEGFramework
{
public RequestTrackMove()
{
this.DeviceAddress = 0x03;
this.RegisterAddress = 0x66;
this.Value = 0x01;
}
}
public class RequestTrackBack : ModbusRTU_WriteSingleHoldingRegister, IEGFramework
{
public RequestTrackBack()
{
this.DeviceAddress = 0x03;
this.RegisterAddress = 0x66;
this.Value = 0x02;
}
}
public class RequestTrackBreak : ModbusRTU_WriteSingleHoldingRegister, IEGFramework
{
public RequestTrackBreak()
{
this.DeviceAddress = 0x03;
this.RegisterAddress = 0x66;
this.Value = 0x03;
}
}
public class RequestTrackReadEnabled: ModbusRTU_ReadHoldingRegisters, IEGFramework
{
public RequestTrackReadEnabled()
{
this.DeviceAddress = 0x03;
this.RegisterAddress = 0xB6;
this.ReadCount = 0x01;
}
}
public class ResponseTrack : ModbusRTU_Response, IEGFramework
{
public uint ResValue { set; get; }
public override bool TrySetData(string protocolData, byte[] protocolBytes)
{
bool result = base.TrySetData(protocolData, protocolBytes);
if (!result)
{
return false;
}
if (this.HoldingRegister != null && this.HoldingRegister.Length >= 1)
{
ResValue = HoldingRegister[0];
}
else
{
return false;
}
return result;
}
}
public class RequestTargetReadEnabled: ModbusRTU_ReadHoldingRegisters, IEGFramework
{
public RequestTargetReadEnabled()
{
this.DeviceAddress = 0x01;
this.RegisterAddress = 0x00;
this.ReadCount = 0x01;
}
}
public class ResponseTarget : ModbusRTU_Response, IEGFramework
{
public uint ResValue { set; get; }
public override bool TrySetData(string protocolData, byte[] protocolBytes)
{
bool result = base.TrySetData(protocolData, protocolBytes);
if (!result)
{
return false;
}
if (this.HoldingRegister != null && this.HoldingRegister.Length >= 1)
{
ResValue = HoldingRegister[0];
}
else
{
return false;
}
return result;
}
}