Add ability to manually trigger O2 alarms, plus some more tidying.
This commit is contained in:
parent
66fff69396
commit
fb211a9426
|
@ -65,6 +65,7 @@ namespace IngameScript
|
|||
}
|
||||
|
||||
Console.Print($"Found {_sequences.Count} sequences.");
|
||||
Console.UpdateTickCount();
|
||||
}
|
||||
|
||||
public void Main(string argument, UpdateType updateSource)
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace IngameScript
|
|||
public class AirZone
|
||||
{
|
||||
public string Name { get; private set; }
|
||||
public bool Triggered { get; private set; } = false;
|
||||
public bool Triggered { get; set; } = false;
|
||||
public List<IMyAirVent> Vents { get; } = new List<IMyAirVent>();
|
||||
|
||||
private Program _program;
|
||||
|
|
|
@ -86,6 +86,7 @@ namespace IngameScript
|
|||
_jobs.Add(zone.Monitor());
|
||||
}
|
||||
Runtime.UpdateFrequency = UpdateFrequency.Update100;
|
||||
Console.UpdateTickCount();
|
||||
}
|
||||
|
||||
public void Main(string argument, UpdateType updateSource)
|
||||
|
@ -95,19 +96,33 @@ namespace IngameScript
|
|||
if (argument != "")
|
||||
{
|
||||
_cli.TryParse(argument);
|
||||
if (_cli.Switch("reset"))
|
||||
if (_cli.Switch("reset") || _cli.Switch("trigger"))
|
||||
{
|
||||
List<string> zonesToReset;
|
||||
if (_cli.ArgumentCount == 0) zonesToReset = _zones.Keys.ToList();
|
||||
else zonesToReset = new List<string>();
|
||||
for (int i = 0; i < _cli.ArgumentCount; i++) zonesToReset.Add(_cli.Argument(i));
|
||||
|
||||
foreach (string zone in zonesToReset)
|
||||
List<string> zonesToControl;
|
||||
if (_cli.ArgumentCount == 0) zonesToControl = _zones.Keys.ToList();
|
||||
else zonesToControl = new List<string>();
|
||||
for (int i = 0; i < _cli.ArgumentCount; i++)
|
||||
{
|
||||
string zone = _cli.Argument(i);
|
||||
if (!_zones.ContainsKey(zone))
|
||||
{
|
||||
Console.Print($"Ignoring non-existent zone '{zone}'");
|
||||
continue;
|
||||
}
|
||||
zonesToControl.Add(zone);
|
||||
}
|
||||
|
||||
foreach (string zone in zonesToControl)
|
||||
{
|
||||
if (_cli.Switch("reset"))
|
||||
{
|
||||
Console.Print($"Resetting {zone}.");
|
||||
if (_zones.ContainsKey(zone)) _zones[zone].Reset();
|
||||
|
||||
_zones[zone].Reset();
|
||||
}
|
||||
if (_cli.Switch("trigger"))
|
||||
{
|
||||
Console.Print($"Manually triggering {zone}.");
|
||||
_zones[zone].Triggered = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -119,6 +134,7 @@ namespace IngameScript
|
|||
Console.Print("WARNING: Monitoring job exited. Zone no longer being monitored.");
|
||||
}
|
||||
|
||||
_updateDisplays();
|
||||
}
|
||||
|
||||
// write diagnostics to any configured display screens
|
||||
|
@ -132,7 +148,7 @@ namespace IngameScript
|
|||
{
|
||||
_displayBuffer.Append(zone.Name);
|
||||
_displayBuffer.Append(": ");
|
||||
_displayBuffer.Append(zone.Triggered ? "ALARM TRIPPED " : "NOMINAL ");
|
||||
_displayBuffer.Append(zone.Triggered ? "ALARM TRIPPED " : "nominal ");
|
||||
foreach (IMyAirVent vent in zone.Vents)
|
||||
{
|
||||
_displayBuffer.Append((int)(vent.GetOxygenLevel() * 100F));
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace IngameScript
|
|||
if (referenceVent != null) foreach (Airlock airlock in _airlocks.Values) { airlock.ReferenceVent = referenceVent; }
|
||||
|
||||
Console.Print($"Found {_airlocks.Count} airlocks.");
|
||||
Console.PrintLower($"Airlock Controller\nTotal Ticks: 0");
|
||||
Console.UpdateTickCount();
|
||||
}
|
||||
|
||||
public void Main(string argument, UpdateType updateSource)
|
||||
|
|
|
@ -38,6 +38,7 @@ namespace IngameScript
|
|||
}
|
||||
|
||||
Console.Print($"Found {_doors.Keys.Count} doors.");
|
||||
Console.UpdateTickCount();
|
||||
}
|
||||
|
||||
public void Main(string argument, UpdateType updateSource)
|
||||
|
|
|
@ -64,7 +64,7 @@ namespace IngameScript
|
|||
// Write the "standard" text to the lower console
|
||||
public void UpdateTickCount()
|
||||
{
|
||||
PrintLower($"Airlock Controller\nTotal Ticks: {++_tickCount}");
|
||||
PrintLower($"{_programName}\nTotal Ticks: {++_tickCount}");
|
||||
}
|
||||
|
||||
// Most programs probably want to use UpdateTickCount to get program name and
|
||||
|
|
Loading…
Reference in New Issue
Block a user