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

48 lines
1.8 KiB

4 weeks ago
using EGFramework;
public class ModelControlServer : EGModule, IEGFramework
{
public const int TCPListenPort = 6557;
public const int UDPListenPort = 6558;
public override void Init()
{
this.EGTCPServerListen(TCPListenPort);
this.EGUDPListen(UDPListenPort);
this.EGOnMessage<ResponseControl>();
this.EGRegisterMessageEvent<ResponseControl>(OnResponseControl);
// throw new NotImplementedException();
}
public void OnResponseControl(ResponseControl data, string sender, ProtocolType type)
{
if (type == ProtocolType.TCPServer || type == ProtocolType.UDP)
{
switch (data.FunctionCode)
{
case (int)TypeControlFunction.StartShooting:
this.GetModule<ModelTrackControl>().StartTarget();
break;
case (int)TypeControlFunction.StopShooting:
this.GetModule<ModelTrackControl>().RevertTarget();
break;
case (int)TypeControlFunction.Status:
this.EGSendMessage(new RequestControlStatus()
{
TargetID = this.GetModule<ModelParamSetting>().Setting.DeviceID,
FunctionCode = data.FunctionCode,
IsStart = this.GetModule<ModelTrackControl>().CurrentRotation > 0,
Position = this.GetModule<ModelTrackControl>().CurrentPosition
}, sender, type);
return;
}
}
this.EGSendMessage(new RequestControl()
{
TargetID = this.GetModule<ModelParamSetting>().Setting.DeviceID,
FunctionCode = data.FunctionCode,
ExecuteSuccess = true,
ErrorCode = 0
}, sender, type);
}
}