Skip to content

Commit 3d3e37a

Browse files
committed
Distributed Power: pass LoadUnits to GetDPuStatus()
1 parent 6dd7738 commit 3d3e37a

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

Source/Orts.Simulation/Simulation/RollingStocks/MSTSDieselLocomotive.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ public string GetDPDebugStatus()
930930
return status.ToString();
931931
}
932932

933-
public string GetDpuStatus(bool dataDpu)// used by the TrainDpuInfo window
933+
public string GetDpuStatus(bool dataDpu, CABViewControlUnits loadUnits = CABViewControlUnits.KILO_LBS)// used by the TrainDpuInfo window
934934
{
935935
string throttle = "";
936936
if (ThrottlePercent > 0)

Source/RunActivity/Viewer3D/RollingStock/SubSystems/DistributedPowerInterface.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,18 @@ public void ExitWindow(DPIWindow window)
157157
public class DPDefaultWindow : DPIWindow
158158
{
159159
public bool FullTable;
160+
public CABViewControlUnits LoadUnits = CABViewControlUnits.KILO_LBS;
160161
public DPDefaultWindow(DistributedPowerInterface dpi, CabViewControl control) : base(dpi, 640, 240)
161162
{
162163
var param = (control as CVCScreen).CustomParameters;
163164
if (param.ContainsKey("fulltable")) bool.TryParse(param["fulltable"], out FullTable);
164-
DPITable DPITable = new DPITable(FullTable, fullScreen:true, dpi:dpi);
165+
if (param.ContainsKey("loadunits"))
166+
{
167+
string sUnits = param["loadunits"].ToUpper();
168+
sUnits = sUnits.Replace('/', '_');
169+
CABViewControlUnits.TryParse(sUnits, out LoadUnits);
170+
}
171+
DPITable DPITable = new DPITable(FullTable, LoadUnits, fullScreen:true, dpi:dpi);
165172
AddToLayout(DPITable, new Point(0, 0));
166173
}
167174
}
@@ -360,6 +367,7 @@ public class DPITable : DPIWindow
360367
readonly int RowHeight = 34;
361368
readonly int ColLength = 88;
362369
public bool FullTable = true;
370+
public CABViewControlUnits LoadUnits;
363371

364372
// Change text color
365373
readonly Dictionary<string, Color> ColorCodeCtrl = new Dictionary<string, Color>
@@ -378,11 +386,12 @@ public class DPITable : DPIWindow
378386

379387
protected string[] FirstColumn = { "ID", "Throttle", "Load", "BP", "Flow", "Remote", "ER", "BC", "MR" };
380388

381-
public DPITable(bool fullTable, bool fullScreen, DistributedPowerInterface dpi) : base(dpi, 640, fullTable? 230 : 162)
389+
public DPITable(bool fullTable, CABViewControlUnits loadUnits, bool fullScreen, DistributedPowerInterface dpi) : base(dpi, 640, fullTable? 230 : 162)
382390
{
383391
DPI = dpi;
384392
FullScreen = fullScreen;
385393
FullTable = fullTable;
394+
LoadUnits = loadUnits;
386395
BackgroundColor = DPI.BlackWhiteTheme ? Color.Black : ColorBackground;
387396
SetFont();
388397
string text = "";
@@ -459,7 +468,7 @@ public override void PrepareFrame(DPIStatus dpiStatus)
459468
{
460469
if (dpUId != (train.Cars[i] as MSTSLocomotive).DPUnitID)
461470
{
462-
var status = (train.Cars[i] as MSTSDieselLocomotive).GetDpuStatus(true).Split('\t');
471+
var status = (train.Cars[i] as MSTSDieselLocomotive).GetDpuStatus(true, LoadUnits).Split('\t');
463472
var fence = ((dpUnitId != (dpUnitId = train.Cars[i].RemoteControlGroup)) ? "| " : " ");
464473
tempStatus[k, 0] = fence + status[0].Split('(').First();
465474
for (var j = 1; j < status.Length; j++)

0 commit comments

Comments
 (0)