Skip to content

Commit dbb9e3c

Browse files
author
Chris Jakeman
committed
Explains the JSON needed by SetCabControls
1 parent b499ec9 commit dbb9e3c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Source/RunActivity/Viewer3D/WebServices/WebServer.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,18 +247,26 @@ IEnumerable<string> GetValues()
247247
public IEnumerable<TrainDpuDisplay.ListLabel> TrainDpuDisplay([QueryField] bool normalText) => Viewer.TrainDpuDisplayList(normalText);
248248
#endregion
249249

250+
#region /API/CABCONTROLS
250251
// Note: to see the JSON, use "localhost:2150/API/CABCONTROLS" - Beware: case matters
251252
// Note: to run the webpage, use "localhost:2150/CabControls/index.html" - case doesn't matter
252253
// or use "localhost:2150/CabControls/"
253254
// Do not use "localhost:2150/CabControls/"
254255
// as that will return the webpage, but the path will be "/" not "/CabControls/ and the appropriate scripts will not be loaded.
255256

256-
#region /API/CABCONTROLS
257257
[Route(HttpVerbs.Get, "/CABCONTROLS")]
258258
public IEnumerable<ControlValue> CabControls() => ((MSTSLocomotiveViewer)Viewer.PlayerLocomotiveViewer).GetWebControlValueList();
259259
#endregion
260260

261261
#region /API/CABCONTROLS
262+
// SetCabControls() expects a request passing an array of ControlValuePost objects using JSON.
263+
// For example:
264+
// [{ "TypeName": "THROTTLE" // A CABViewControlTypes name - must be uppercase.
265+
// , "ControlIndex": 1 // This property is optional and used in rendering cab view
266+
// , "Value": 0.50 // A floating-point value
267+
// }
268+
// ]
269+
262270
[Route(HttpVerbs.Post, "/CABCONTROLS")]
263271
public async Task SetCabControls()
264272
{
@@ -282,4 +290,4 @@ public async Task SetCabControls()
282290
public double Time() => Viewer.Simulator.ClockTime;
283291
#endregion
284292
}
285-
}
293+
}

0 commit comments

Comments
 (0)