Example #1
0
        private static bool InitializeOutputSystem(AbstractOutput DesiredOutputSystem)
        {
            if (DesiredOutputSystem == null)
                throw new ArgumentNullException ("DesiredOutputSystem", "DesiredOutputSystem must be specified to initialize the system");

            bool success = false;

            SkipInput = true;
            System.Threading.Thread skip_input_buffer = new System.Threading.Thread (FlushKeyboard);
            skip_input_buffer.IsBackground = true;
            skip_input_buffer.Start ();

            ActiveOutputSystem = DesiredOutputSystem;
            success = ActiveOutputSystem.InitializeSystem ();

            string outputType = ActiveOutputSystem.GetType ().Name.Trim ();
            if (outputType == "") {
                outputType = "Unknown";
            }

            if (success) {
                Console.WriteLine ("- Connected to '{0}' via '{1}'", outputType, ActiveOutputSystem.Identifier);

                // Don't allow a shorter animation time than the output system processing can manage
                Light_Animation_Latency = Math.Max (ActiveOutputSystem.ProcessingLatency + 1, Light_Animation_Target_Latency);

                // Update number of lights, (re-)initalize the light queues
                LightSystem.SetLightCount (ActiveOutputSystem.LightCount);
                CreateLightQueues (LightSystem.LIGHT_COUNT);
            } else {
                Console.WriteLine ("- Could not connect to '{0}'", outputType);
            }

            SkipInput = false;
            if (skip_input_buffer.IsAlive)
                skip_input_buffer.Abort ();

            return success;
        }