@@ -10,26 +10,6 @@ extension SettingsParser on Json {
1010 }
1111}
1212
13- /// Settings relating to video.
14- class VideoSettings {
15- /// How many frames to render per second.
16- ///
17- /// This does not affect how many frames are sent by the rover per second.
18- final int fps;
19-
20- /// A const constructor.
21- const VideoSettings ({required this .fps});
22-
23- /// Parses a [VideoSettings] from JSON.
24- VideoSettings .fromJson (Json ? json) :
25- fps = (json? ["fps" ] ?? 60 ) as int ;
26-
27- /// Serializes these settings in JSON format.
28- Json toJson () => {
29- "fps" : fps,
30- };
31- }
32-
3313/// Settings relating to science.
3414class ScienceSettings {
3515 /// How many frames to render per second.
@@ -140,16 +120,12 @@ class NetworkSettings {
140120 /// the tank when it's being used.
141121 final SocketInfo tankSocket;
142122
143- /// The address and port of the Rover's GPS
144- final SocketInfo marsSocket;
145-
146123 /// Creates a new network settings object.
147124 NetworkSettings ({
148125 required this .subsystemsSocket,
149126 required this .videoSocket,
150127 required this .autonomySocket,
151128 required this .tankSocket,
152- required this .marsSocket,
153129 required this .connectionTimeout,
154130 });
155131
@@ -159,7 +135,6 @@ class NetworkSettings {
159135 videoSocket = json? .getSocket ("videoSocket" ) ?? SocketInfo .raw ("192.168.1.30" , 8002 ),
160136 autonomySocket = json? .getSocket ("autonomySocket" ) ?? SocketInfo .raw ("192.168.1.30" , 8003 ),
161137 tankSocket = json? .getSocket ("tankSocket" ) ?? SocketInfo .raw ("192.168.1.40" , 8000 ),
162- marsSocket = json? .getSocket ("marsSocket" ) ?? SocketInfo .raw ("192.168.1.50" , 8006 ),
163138 connectionTimeout = json? ["connectionTimeout" ] ?? 5 ;
164139
165140 /// Serializes these settings to JSON.
@@ -168,34 +143,10 @@ class NetworkSettings {
168143 "videoSocket" : videoSocket.toJson (),
169144 "autonomySocket" : autonomySocket.toJson (),
170145 "tankSocket" : tankSocket.toJson (),
171- "marsSocket" : marsSocket.toJson (),
172146 "connectionTimeout" : connectionTimeout,
173147 };
174148}
175149
176- /// Settings relating to autonomy.
177- class AutonomySettings {
178- /// The precision of the GPS grid.
179- ///
180- /// Since GPS coordinates are decimal values, we divide by this value to get the index of the cell
181- /// each coordinate belongs to. Smaller sizes means more blocks, but we should be careful that the
182- /// blocks are big enough to the margin of error of our GPS. This value must be synced with the
183- /// value in the autonomy program, or else the UI will not be accurate to the rover's logic.
184- final double blockSize;
185-
186- /// A const constructor.
187- const AutonomySettings ({required this .blockSize});
188-
189- /// Parses autonomy settings from a JSON map.
190- AutonomySettings .fromJson (Json ? json) :
191- blockSize = json? ["blockSize" ] ?? 1.0 ;
192-
193- /// Serializes these settings to JSON.
194- Json toJson () => {
195- "blockSize" : blockSize,
196- };
197- }
198-
199150/// Settings relating to easter eggs.
200151///
201152/// Implement these! Ask Levi for details.
@@ -223,14 +174,63 @@ class EasterEggsSettings {
223174 };
224175}
225176
177+ /// Controls the way the Dashboard views split.
178+ enum SplitMode {
179+ /// Two views are split horizontally, one atop the other.
180+ horizontal ("Top and bottom" ),
181+ /// Two views are split vertically, side-by-side.
182+ vertical ("Side by side" );
183+
184+ /// The name to show in the UI.
185+ final String humanName;
186+ /// A const constructor.
187+ const SplitMode (this .humanName);
188+ }
189+
190+ /// Settings related to the dashboard itself, not the rover.
191+ class DashboardSettings {
192+ /// How the Dashboard should split when only two views are present.
193+ final SplitMode splitMode;
194+
195+ /// The precision of the GPS grid.
196+ ///
197+ /// Since GPS coordinates are decimal values, we divide by this value to get the index of the cell
198+ /// each coordinate belongs to. Smaller sizes means more blocks, but we should be careful that the
199+ /// blocks are big enough to the margin of error of our GPS. This value must be synced with the
200+ /// value in the autonomy program, or else the UI will not be accurate to the rover's logic.
201+ final double mapBlockSize;
202+
203+ /// How many frames to render per second.
204+ ///
205+ /// This does not affect how many frames are sent by the rover per second.
206+ final int maxFps;
207+
208+ /// A const constructor.
209+ const DashboardSettings ({
210+ required this .splitMode,
211+ required this .mapBlockSize,
212+ required this .maxFps,
213+ });
214+
215+ /// Parses Dashboard settings from JSON.
216+ DashboardSettings .fromJson (Json ? json) :
217+ splitMode = SplitMode .values[json? ["splitMode" ] ?? SplitMode .horizontal.index],
218+ mapBlockSize = json? ["mapBlockSize" ] ?? 1.0 ,
219+ maxFps = (json? ["maxFps" ] ?? 60 ) as int ;
220+
221+ /// Serializes these settings to JSON.
222+ Json toJson () => {
223+ "splitMode" : splitMode.index,
224+ "mapBlockSize" : mapBlockSize,
225+ "maxFps" : maxFps,
226+ };
227+ }
228+
226229/// Contains the settings for running the dashboard and the rover.
227230class Settings {
228231 /// Settings for the network, like IP addresses and ports.
229232 final NetworkSettings network;
230233
231- /// Settings for video display.
232- final VideoSettings video;
233-
234234 /// Settings for easter eggs.
235235 ///
236236 /// Please, please, please -- do not remove these (Levi Lesches, '25).
@@ -242,35 +242,32 @@ class Settings {
242242 /// Settings for the science analysis.
243243 final ScienceSettings science;
244244
245- /// Settings for the autonomy display .
246- final AutonomySettings autonomy ;
245+ /// Settings related to the dashboard itself .
246+ final DashboardSettings dashboard ;
247247
248248 /// A const constructor.
249249 const Settings ({
250250 required this .network,
251- required this .video,
252251 required this .easterEggs,
253252 required this .science,
254253 required this .arm,
255- required this .autonomy ,
254+ required this .dashboard ,
256255 });
257256
258257 /// Initialize settings from Json.
259258 Settings .fromJson (Json json) :
260- autonomy = AutonomySettings .fromJson (json["autonomy" ]),
261259 network = NetworkSettings .fromJson (json["network" ]),
262- video = VideoSettings .fromJson (json["video" ]),
263260 easterEggs = EasterEggsSettings .fromJson (json["easterEggs" ]),
264261 science = ScienceSettings .fromJson (json["science" ]),
265- arm = ArmSettings .fromJson (json["arm" ]);
262+ arm = ArmSettings .fromJson (json["arm" ]),
263+ dashboard = DashboardSettings .fromJson (json["dashboard" ]);
266264
267265 /// Converts the data from the settings instance to Json.
268266 Json toJson () => {
269- "autonomy" : autonomy.toJson (),
270267 "network" : network.toJson (),
271- "video" : video.toJson (),
272268 "easterEggs" : easterEggs.toJson (),
273269 "science" : science.toJson (),
274270 "arm" : arm.toJson (),
271+ "dashboard" : dashboard.toJson (),
275272 };
276273}
0 commit comments