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.
51 lines
2.0 KiB
51 lines
2.0 KiB
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; |
|
case (int)TypeControlFunction.TrackMove: |
|
this.GetModule<ModelTrackControl>().MoveToPosition(data.Position); |
|
break; |
|
} |
|
} |
|
this.EGSendMessage(new RequestControl() |
|
{ |
|
TargetID = this.GetModule<ModelParamSetting>().Setting.DeviceID, |
|
FunctionCode = data.FunctionCode, |
|
ExecuteSuccess = true, |
|
ErrorCode = 0 |
|
}, sender, type); |
|
} |
|
} |