2 using System.Collections.Generic;
5 using Newtonsoft.Json.Linq;
7 using System.Net.Sockets;
17 #region Builtin Methods
20 #region Custom Methods
28 string MsgType = inputJson[
"MsgType"].ToString();
30 if (MsgType==
"ControlInput")
33 string inputControlType = inputJson[
"InputControlType"].ToString();
36 float throttle =
float.Parse(inputJson[
"Throttle"].ToString());
37 float stickyThrottle =
float.Parse(inputJson[
"StickyThrottle"].ToString());
38 float pitch =
float.Parse(inputJson[
"Pitch"].ToString());
39 float roll =
float.Parse(inputJson[
"Roll"].ToString());
40 float yaw =
float.Parse(inputJson[
"Yaw"].ToString());
41 float brake =
float.Parse(inputJson[
"Brake"].ToString());
42 int flaps =
int.Parse(inputJson[
"Flaps"].ToString());
61 else if (MsgType==
"Camera")
64 bool isActive =
bool.Parse(inputJson[
"IsActive"].ToString());
66 int activeCamera =
int.Parse(inputJson[
"ActiveCamera"].ToString());
67 bool isCapture =
bool.Parse(inputJson[
"IsCapture"].ToString());
68 int captureCamera =
int.Parse(inputJson[
"CaptureCamera"].ToString());
69 int captureType =
int.Parse(inputJson[
"CaptureType"].ToString());
70 int captureWidth =
int.Parse(inputJson[
"CaptureWidth"].ToString());
71 int captureHeight =
int.Parse(inputJson[
"CaptureHeight"].ToString());
74 StaticCameraSchema.MsgType =
"Camera";
76 StaticCameraSchema.IsActive = isActive;
77 StaticCameraSchema.ActiveCamera = activeCamera;
79 StaticCameraSchema.IsCapture = isCapture;
80 StaticCameraSchema.CaptureCamera = captureCamera;
81 StaticCameraSchema.CaptureType = captureType;
82 StaticCameraSchema.CaptureWidth = captureWidth;
83 StaticCameraSchema.CaptureHeight = captureHeight;
89 else if (MsgType==
"Level")
91 bool levelReload =
bool.Parse(inputJson[
"LevelReload"].ToString());
93 bool isActive =
bool.Parse(inputJson[
"IsActive"].ToString());
96 StaticLevelSchema.MsgType =
"Level";
98 StaticLevelSchema.LevelReload = levelReload;
99 StaticLevelSchema.IsActive = isActive;
105 else if (MsgType==
"TOD")
108 float sunLatitude =
float.Parse(inputJson[
"SunLatitude"].ToString());
109 float sunLongitude =
float.Parse(inputJson[
"SunLongitude"].ToString());
110 int hour =
int.Parse(inputJson[
"Hour"].ToString());
111 int minute =
int.Parse(inputJson[
"Minute"].ToString());
112 bool isActive =
bool.Parse(inputJson[
"IsActive"].ToString());
115 StaticTODSchema.MsgType =
"TOD";
117 StaticTODSchema.SunLatitude = sunLatitude;
118 StaticTODSchema.SunLongitude =sunLongitude;
119 StaticTODSchema.Hour = hour;
120 StaticTODSchema.Minute = minute;
121 StaticTODSchema.IsActive = isActive;
127 else if (MsgType==
"Weather")
130 bool isClouds =
bool.Parse(inputJson[
"IsClouds"].ToString());
131 bool isFog =
bool.Parse(inputJson[
"IsFog"].ToString());
134 StaticWeatherSchema.MsgType =
"Weather";
136 StaticWeatherSchema.IsClouds = isClouds;
138 StaticWeatherSchema.IsFog =isFog;
144 else if (MsgType==
"Audio")
147 bool isActive =
bool.Parse(inputJson[
"IsActive"].ToString());
148 bool enableAudio =
bool.Parse(inputJson[
"EnableAudio"].ToString());
151 StaticAudioSchema.MsgType =
"Audio";
153 StaticAudioSchema.IsActive = isActive;
155 StaticAudioSchema.EnableAudio =enableAudio;
160 else if (MsgType==
"UI")
163 bool isActive =
bool.Parse(inputJson[
"IsActive"].ToString());
164 bool showUIElements =
bool.Parse(inputJson[
"ShowUIElements"].ToString());
167 StaticUISchema.MsgType =
"UI";
169 StaticUISchema.IsActive = isActive;
171 StaticUISchema.ShowUIElements = showUIElements;
178 else if (MsgType==
"Lidar")
180 float range =
float.Parse(inputJson[
"Range"].ToString());
181 int density =
int.Parse(inputJson[
"Density"].ToString());
184 StaticLidarSchema.MsgType =
"Weather";
186 StaticLidarSchema.Range = range;
188 StaticLidarSchema.Density =density;
196 else if (MsgType==
"UIControls")
199 bool ifExit =
bool.Parse(inputJson[
"ifExit"].ToString());
211 else if (MsgType==
"ClientInfo")
213 bool isActive =
bool.Parse(inputJson[
"IsActive"].ToString());
214 string clientIP = inputJson[
"clientIP"].ToString();
215 string clientPort = inputJson[
"clientPort"].ToString();
216 StaticClientInfo.IsActive = isActive;
217 StaticClientInfo.ClientIP = clientIP;
218 StaticClientInfo.ClientPort = clientPort;
224 else if (MsgType==
"Fuel")
231 else if (MsgType==
"StartUp")
239 else if (MsgType==
"Output")