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(); this.EGRegisterMessageEvent(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().StartTarget(); break; case (int)TypeControlFunction.StopShooting: this.GetModule().RevertTarget(); break; case (int)TypeControlFunction.Status: this.EGSendMessage(new RequestControlStatus() { TargetID = this.GetModule().Setting.DeviceID, FunctionCode = data.FunctionCode, IsStart = this.GetModule().CurrentRotation > 0, Position = this.GetModule().CurrentPosition }, sender, type); return; } } this.EGSendMessage(new RequestControl() { TargetID = this.GetModule().Setting.DeviceID, FunctionCode = data.FunctionCode, ExecuteSuccess = true, ErrorCode = 0 }, sender, type); } }