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

59 lines
1.4 KiB

using System.Numerics;
using EGFramework;
public class RequestColorStartScan : ModbusRTU_WriteSingleHoldingRegister
{
public RequestColorStartScan()
{
this.DeviceAddress = 0x01;
this.RegisterAddress = 0x3007;
this.Value = 0x02;
}
}
public class RequestColorStopScan : ModbusRTU_WriteSingleHoldingRegister
{
public RequestColorStopScan()
{
this.DeviceAddress = 0x01;
this.RegisterAddress = 0x3007;
this.Value = 0x01;
}
}
public class RequestColorSingleRead : ModbusRTU_ReadHoldingRegisters
{
public RequestColorSingleRead()
{
this.DeviceAddress = 0x01;
this.RegisterAddress = 0x00;
this.ReadCount = 3;
}
}
public class ResponseColorSensor : ModbusRTU_Response
{
public Vector3 ColorRGB { set; get; }
public Vector3 ColorHSV { 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 >= 3)
{
ColorRGB = new Vector3(HoldingRegister[0] / 1000f, HoldingRegister[1] / 1000f, HoldingRegister[2] / 1000f);
ColorHSV = ColorRGB.RGBToHSV();
}
else
{
return false;
}
return result;
}
}