public Controller(KeyTorpedo tKey, OxygenMonitor oxyMonitor, TempMonitor tempMonitor, AirlockDoorMonitor doorMonitor, RadarMonitor radarMonitor, DepthMonitor depthMonitor, int maxDepth) { //// sees -> insure the parameters are not null Contract.Requires(tKey != null); Contract.Requires(oxyMonitor != null); Contract.Requires(tempMonitor != null); Contract.Requires(doorMonitor != null); Contract.Requires(radarMonitor != null); Contract.Requires(depthMonitor != null); this.tKey = tKey; this.oxyMonitor = oxyMonitor; this.tempMonitor = tempMonitor; this.doorMonitor = doorMonitor; this.radarMonitor = radarMonitor; this.depthMonitor = depthMonitor; // Imports subDashboard = new SubControlDashboard(); // a => b is equivalent to (not a) or b // When there is one door closed the sub dashboard start light should be turned on Contract.Invariant(!(doorState == AirlockDoorState.oneClosed) || subDashboard.subStartLight == SubControlState.on); // When there is two doors closed the sub dashboard start light should be turned on Contract.Invariant(!(doorState == AirlockDoorState.twoClosed) || subDashboard.subStartLight == SubControlState.on); // When the temperature is high the dashboard temperature light should be turned on Contract.Invariant(!(tempState == TempState.highTemp) || subDashboard.temperature == SubControlState.on); // When the oxygen is low the dashboard low oxygen light warning must be on Contract.Invariant(!(oxygenState == OxygenState.lowOxygen) || subDashboard.lowOxygenLight == SubControlState.on); // When there is no oxygen is the dashboard no oxygen warning must be on Contract.Invariant(!(oxygenState == OxygenState.noOxygen) || subDashboard.NoOxygen == SubControlState.on); // When there is a sub closeby the dashboard radar warning must be on Contract.Invariant(!(radarState == RadarState.yesDetection) || subDashboard.radar == SubControlState.on); }
public SubControlSystem(int maxDepth) { Contract.Requires(maxDepth > 0); tKey = new KeyTorpedo(); oMonitor = new OxygenMonitor(); tMonitor = new TempMonitor(); dMonitor = new AirlockDoorMonitor(); rMonitor = new RadarMonitor(); depthMonitor = new DepthMonitor(maxDepth); controller = new Controller(tKey, oMonitor, tMonitor, dMonitor, rMonitor, depthMonitor, maxDepth); }