Exemplo n.º 1
0
        public void WireUp(Animatroller.Simulator.SimulatorForm sim)
        {
            sim.AddDigitalInput_Momentarily(inputArm);
            sim.AddDigitalInput_Momentarily(inputDisarm);
            sim.AddDigitalInput_Momentarily(inputDump);
            sim.AddDigitalInput_Momentarily(inputReset);

            sim.AddDigitalInput_Momentarily(inputNextSong);

            sim.AutoWireUsingReflection(this);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Animatroller.Simulator.SimulatorForm simForm = null;
            Animatroller.Framework.Expander.DMXPro dmxPro = null;
            Animatroller.Framework.Expander.IOExpander ioExpander = null;

            var sceneArgs = new List<string>();
            foreach (var arg in args)
            {
                switch (arg)
                {
                    case "SIM":
                        simForm = new Animatroller.Simulator.SimulatorForm();
                        break;

                    case "DMXPRO":
                        dmxPro = new Animatroller.Framework.Expander.DMXPro(Properties.Settings.Default.DMXProPort);
                        break;

                    case "IOEXP":
                        ioExpander = new Animatroller.Framework.Expander.IOExpander(Properties.Settings.Default.IOExpanderPort);
                        break;

                    default:
                        sceneArgs.Add(arg);
                        break;
                }
            }

            //var scene = new TestScene();
            //            var scene = new TestScene2();
            //var scene = new HalloweenScene();
            //var scene = new XmasScene();
            var scene = new XmasScene2(sceneArgs);

            if (simForm != null)
                scene.WireUp(simForm);
            if (dmxPro != null)
                scene.WireUp(dmxPro);
            if (ioExpander != null)
                scene.WireUp(ioExpander);

            Executor.Current.Start();
            Executor.Current.Run();

            if (simForm != null)
            {
                simForm.Show();
                simForm.FormClosing += (sender, e) =>
                    {
                        // Do this on a separate thread so it won't block the Main UI thread
                        var stopTask = new Task(() => Executor.Current.Stop());
                        stopTask.Start();

                        while (!Executor.Current.EverythingStopped())
                        {
                            System.Windows.Forms.Application.DoEvents();
                            System.Threading.Thread.Sleep(50);
                        }
                        stopTask.Wait();
                    };
                System.Windows.Forms.Application.Run(simForm);

                Executor.Current.WaitToStop(5000);
            }
            else
            {
                Console.ReadLine();
                Executor.Current.Stop();
                Executor.Current.WaitToStop(5000);
            }
        }
Exemplo n.º 3
0
        public static void Main(string[] args)
        {
            Console.SetWindowSize(180, 70);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // Variables for al types of IO expanders, etc
            Animatroller.Simulator.SimulatorForm simForm = null;

            // Figure out which IO expanders to use, taken from command line (space-separated)
            var sceneArgs = new List<string>();
            string sceneName = string.Empty;
            foreach (var arg in args)
            {
                var parts = arg.Split('=');
                parts[0] = parts[0].ToUpper();

                switch (parts[0])
                {
                    case "SCENE":
                        sceneName = parts[1].ToUpper();
                        break;

                    case "SIM":
                        // WinForms simulator
                        simForm = new Animatroller.Simulator.SimulatorForm();
                        break;

                    case "OFFLINE":
                        Executor.Current.IsOffline = true;
                        break;

                    default:
                        // Pass other parameters to the scene. Can be used to load test data to operating hours, etc
                        sceneArgs.Add(arg);
                        break;
                }
            }

            // Load scene
            var sceneInterfaceType = typeof(IScene);

            var scenesAssembly = System.Reflection.Assembly.LoadFile(Path.Combine(Path.GetDirectoryName(sceneInterfaceType.Assembly.Location), "Scenes.dll"));

            var sceneTypes = scenesAssembly.GetTypes()
                .Where(p => sceneInterfaceType.IsAssignableFrom(p) &&
                    !p.IsInterface &&
                    !p.IsAbstract);

            var sceneType = sceneTypes.SingleOrDefault(x => x.Name.Equals(sceneName, StringComparison.OrdinalIgnoreCase));
            if (sceneType == null)
                throw new ArgumentException("Missing start scene");

            Executor.Current.KeyStoragePrefix = sceneType.Name;

            IScene scene = (IScene)Activator.CreateInstance(sceneType, sceneArgs);

            // Register the scene (so it can be properly stopped)
            Executor.Current.Register(scene);

            // Wire up the instantiated expanders
            if (simForm != null)
            {
                simForm.AutoWireUsingReflection(scene);
            }

            // Run
            Executor.Current.Run();

            Executor.Current.SetScenePersistance(scene);

            if (simForm != null)
            {
                simForm.Show();
                simForm.FormClosing += (sender, e) =>
                    {
                        simForm.PendingClose = true;

                        // Do this on a separate thread so it won't block the Main UI thread
                        var stopTask = new Task(() => Executor.Current.Stop());
                        stopTask.Start();

                        while (!Executor.Current.EverythingStopped())
                        {
                            System.Windows.Forms.Application.DoEvents();
                            System.Threading.Thread.Sleep(50);
                        }
                        stopTask.Wait();
                    };
                // If using the simulator then run it until the form is closed. Otherwise run until NewLine
                // in command prompt
                Application.Run(simForm);

                Executor.Current.WaitToStop(5000);
            }
            else
            {
                Console.ReadLine();
                Executor.Current.Stop();
                Executor.Current.WaitToStop(5000);
            }
        }
Exemplo n.º 4
0
        public static void Main(string[] args)
        {
            var logConfig = new LoggerConfiguration()
                            .Enrich.FromLogContext()
                            .MinimumLevel.Verbose()
                            .WriteTo.ColoredConsole(outputTemplate: TraceTemplate)
                            .WriteTo.Trace(outputTemplate: TraceTemplate)
                            .WriteTo.RollingFile(
                pathFormat: Path.Combine(AppContext.BaseDirectory, "Logs", "log-{Date}.txt"),
                outputTemplate: FileTemplate);

            if (!string.IsNullOrEmpty(SceneRunner.Properties.Settings.Default.SeqServerURL))
            {
                logConfig = logConfig.WriteTo.Seq(
                    serverUrl: SceneRunner.Properties.Settings.Default.SeqServerURL,
                    apiKey: SceneRunner.Properties.Settings.Default.SeqApiKey,
                    restrictedToMinimumLevel: Serilog.Events.LogEventLevel.Debug);
            }

            log = Log.Logger = logConfig.CreateLogger();

            Log.Logger.Information("Starting up!");

            Executor.Current.SetLogger(log);

            Console.SetWindowSize(Math.Min(Console.LargestWindowWidth, 180), Math.Min(Console.LargestWindowHeight, 70));
            Console.SetWindowPosition(0, 0);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // Variables for al types of IO expanders, etc
            Animatroller.Simulator.SimulatorForm simForm = null;

            // Figure out which IO expanders to use, taken from command line (space-separated)
            var    sceneArgs = new List <string>();
            string sceneName = string.Empty;

            foreach (var arg in args)
            {
                var parts = arg.Split('=');
                parts[0] = parts[0].ToUpper();

                switch (parts[0])
                {
                case "SCENE":
                    sceneName = parts[1].ToUpper();
                    break;

                case "SIM":
                    // WinForms simulator
                    simForm = new Animatroller.Simulator.SimulatorForm();
                    break;

                case "OFFLINE":
                    Executor.Current.IsOffline = true;
                    break;

                default:
                    // Pass other parameters to the scene. Can be used to load test data to operating hours, etc
                    sceneArgs.Add(arg);
                    break;
                }
            }


            // Load scene
            var sceneInterfaceType = typeof(IScene);

            var scenesAssembly = System.Reflection.Assembly.LoadFile(Path.Combine(Path.GetDirectoryName(sceneInterfaceType.Assembly.Location), "Scenes.dll"));

            var sceneTypes = scenesAssembly.GetTypes()
                             .Where(p => sceneInterfaceType.IsAssignableFrom(p) &&
                                    !p.IsInterface &&
                                    !p.IsAbstract);

            var sceneType = sceneTypes.SingleOrDefault(x => x.Name.Equals(sceneName, StringComparison.OrdinalIgnoreCase));

            if (sceneType == null)
            {
                throw new ArgumentException("Missing start scene");
            }

            Executor.Current.KeyStoragePrefix = sceneType.Name;

            IScene scene = (IScene)Activator.CreateInstance(sceneType, sceneArgs);


            // Register the scene (so it can be properly stopped)
            Executor.Current.Register(scene);

            // Wire up the instantiated expanders
            if (simForm != null)
            {
                simForm.AutoWireUsingReflection(scene);
            }

            // Run
            Executor.Current.Run();

            Executor.Current.SetScenePersistance(scene);

            if (simForm != null)
            {
                simForm.Show();
                simForm.FormClosing += (sender, e) =>
                {
                    simForm.PendingClose = true;

                    // Do this on a separate thread so it won't block the Main UI thread
                    var stopTask = new Task(() => Executor.Current.Stop());
                    stopTask.Start();

                    while (!Executor.Current.EverythingStopped())
                    {
                        System.Windows.Forms.Application.DoEvents();
                        System.Threading.Thread.Sleep(50);
                    }
                    stopTask.Wait();
                };
                // If using the simulator then run it until the form is closed. Otherwise run until NewLine
                // in command prompt
                Application.Run(simForm);

                Executor.Current.WaitToStop(5000);
            }
            else
            {
                Console.ReadLine();
                Executor.Current.Stop();
                Executor.Current.WaitToStop(5000);
            }
        }