Esempio n. 1
0
 private void toggle_lamp(Driver d)
 {
     if (d.State.State)
     {
         d.Disable();
     }
     else
     {
         d.Enable();
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Create a new machine configuration representation in memory from a file on disk
        /// </summary>
        /// <param name="PathToFile">The path to the configuration XML file</param>
        public void LoadConfig(string PathToFile)
        {
            MachineConfiguration config = MachineConfiguration.FromFile(PathToFile);
            foreach (CoilConfigFileEntry ce in config.PRCoils)
            {
                Driver d = new Driver(this, ce.Name, PinProc.PRDecode(_machineType, ce.Number));
                Log("Adding driver " + d.ToString());
                _coils.Add(d.Number, d.Name, d);
            }

            foreach (LampConfigFileEntry le in config.PRLamps)
            {
                Driver d = new Driver(this, le.Name, PinProc.PRDecode(_machineType, le.Number));
                Log("Adding lamp " + d.ToString());
                _lamps.Add(d.Number, d.Name, d);
            }

            foreach (GIConfigFileEntry ge in config.PRGI)
            {
                Driver d = new Driver(this, ge.Name, PinProc.PRDecode(_machineType, ge.Number));
                _gi.Add(d.Number, d.Name, d);
            }

            foreach (SwitchConfigFileEntry se in config.PRSwitches)
            {

                Switch s = new Switch(this, se.Name, PinProc.PRDecode(_machineType, se.Number), se.Type);

                _proc.switch_update_rule(s.Number,
                    EventType.SwitchClosedDebounced,
                    new SwitchRule { NotifyHost = true, ReloadActive = false },
                    null,
                    false
                );
                _proc.switch_update_rule(s.Number,
                    EventType.SwitchOpenDebounced,
                    new SwitchRule { NotifyHost = true, ReloadActive = false },
                    null,
                    false
                );
                Log("Adding switch " + s.ToString());
                _switches.Add(s.Number, s.Name, s);
            }

            /// TODO: THIS SHOULD RETURN A LIST OF STATES
            EventType[] states = _proc.switch_get_states();
            foreach (Switch s in _switches.Values)
            {
                s.SetState(states[s.Number] == EventType.SwitchClosedDebounced);
            }

            _num_balls_total = config.PRGame.numBalls;
            _config = config;

            if (_config.PRGame.displayMonitor)
            {
            }
        }
Esempio n. 3
0
 public void resolve_driver_with_game(GameController game)
 {
     if (name.StartsWith("coil:"))
         this.driver = game.Coils[name.Substring(5)];
     else if (name.StartsWith("lamp:"))
         this.driver = game.Lamps[name.Substring(5)];
     else
         this.driver = game.Lamps[name];
 }