Ejemplo n.º 1
0
        static async Task Main(string[] args)
        {
            ProcDevice PROC = null;

            try
            {
                Console.WriteLine("Creating PROC");
                PROC = new ProcDevice(MachineType.PDB);
                await Task.Delay(100);

                PROC?.Reset(1);

                //load machine config.
                var config = MachineConfiguration.FromFile("machine.json");

                //create collections to pass into the setup.
                //The GameController does this for you in LoadConfig, but this is to test without a game
                _switches = new AttrCollection <ushort, string, Switch>();
                _leds     = new AttrCollection <ushort, string, LED>();
                _coils    = new AttrCollection <ushort, string, IDriver>();

                //setup machine items to be able to process events.
                (PROC as ProcDevice).SetupProcMachine(config, _switches: _switches, _leds: _leds, _coils: _coils);

                //listen for cancel keypress and end run loop
                Console.CancelKeyPress += (sender, eventArgs) =>
                {
                    Console.WriteLine("ctrl+C triggered");
                    source.Cancel();
                    eventArgs.Cancel = true;
                };



                //run game loop
                await RunLoop(PROC);

                //close console
                Console.WriteLine("netprocgame closing...");
                await Task.Delay(500);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Ejemplo n.º 2
0
        public void Test1()
        {
            ProcDevice proc = null;

            try
            {
                proc = new ProcDevice(MACHINE_TYPE);
                System.Threading.Thread.Sleep(100);
                proc.Reset(1);
                proc?.Close();
                Assert.True(true); //got this far to pass as device is initialized in ProcDevice constructor
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                proc?.Close();
                throw;
            }
        }