Esempio n. 1
0
 private void UpdateIntensitiesAndSuppressed(object sender, EventArgs e)
 {
     for (int i = 1; i <= numChannelsDisplayed; i++)
     {
         UpdateIntensity(i, DMXController.GetLevel(i), DMXController.IsSuppressed(i));
     }
 }
Esempio n. 2
0
 protected virtual void Tick(object sender, EventArgs e)
 {
     if (_up)
     {
         _current += _increment;
         if (_current >= _end)
         {
             Finish();
         }
         else
         {
             foreach (Photon pair in _chans)
             {
                 DMXController.SetLevel(_setterName, pair.Channel, Convert.ToInt32(Math.Floor((_level * _current * pair.Intensity) / 65025)));
             }
         }
     }
     else
     {
         _current -= _increment;
         if (_current <= _end)
         {
             Finish();
         }
         else
         {
             foreach (Photon pair in _chans)
             {
                 DMXController.SetLevel(_setterName, pair.Channel, Convert.ToInt32(Math.Floor((_level * _current * pair.Intensity) / 65025)));
             }
         }
     }
 }
Esempio n. 3
0
 public void SetOverride(bool overrideHTP)
 {
     foreach (Photon photon in _photons)
     {
         DMXController.SetOverride(photon.Channel, overrideHTP);
     }
 }
Esempio n. 4
0
        public void MoveTo(Point point, double fadeTime, string sender)
        {
            if (!HasPan || !HasTilt)
            {
                throw new FixtureNotMovableException();
            }

            if (fadeTime == 0)
            {
                int tiltCoarse = (int)point.Y / 256;
                int tiltFine   = (int)point.Y % 256;
                int panCoarse  = (int)point.X / 256;
                int panFine    = (int)point.X % 256;
                DMXController.SetLevel(Name, GetTiltCoarseAttr.Photons[0].Channel, tiltCoarse);
                DMXController.SetLevel(Name, GetTiltFineAttr.Photons[0].Channel, tiltFine);
                DMXController.SetLevel(Name, GetPanCoarseAttr.Photons[0].Channel, panCoarse);
                DMXController.SetLevel(Name, GetPanFineAttr.Photons[0].Channel, panFine);
            }
            else
            {
                //Tilt
                PanTiltCoarseFineFader fader = new PanTiltCoarseFineFader(sender, GetTiltCoarseAttr.Photons[0].Channel, GetTiltFineAttr.Photons[0].Channel, (int)point.Y, GetPanCoarseAttr.Photons[0].Channel, GetPanFineAttr.Photons[0].Channel, (int)point.X, fadeTime);

                lock (m_lock)
                {
                    fader.Run(new FaderDoneCallback(DoneMoving));
                    Monitor.Wait(m_lock);
                }
            }
        }
Esempio n. 5
0
 /*
  * Unsuppress all channels that belong to a fixture.
  */
 public void Unsuppress()
 {
     for (int i = startChannel; i <= endChannel; i++)
     {
         DMXController.Unsuppress(i);
     }
 }
Esempio n. 6
0
        public void SetLevel(int intensity, string sender)
        {
            if (_snapOn && intensity > 0)
            {
                intensity = 255;
            }

            foreach (Photon photon in _photons)
            {
                DMXController.SetLevel(sender, photon.Channel, (int)(intensity * photon.Intensity / 255.0));
            }
        }
Esempio n. 7
0
 //The Pan will use the superclass _end and _start etc.
 public PanTiltCoarseFineFader(string setterName, int panCoarseChannel, int panFineChannel, int panBigEnd, int tiltCoarseChannel, int tiltFineChannel, int tiltBigEnd, double fadeTimeSecs)
     : base(setterName, panCoarseChannel, (DMXController.GetLevel(panCoarseChannel) * 256) + DMXController.GetLevel(panFineChannel), panBigEnd, fadeTimeSecs)
 {
     _panCoarseChannel  = panCoarseChannel;
     _panFineChannel    = panFineChannel;
     _tiltCoarseChannel = tiltCoarseChannel;
     _tiltFineChannel   = tiltFineChannel;
     _tiltStart         = (DMXController.GetLevel(tiltCoarseChannel) * 256) + DMXController.GetLevel(tiltFineChannel);
     _tiltEnd           = tiltBigEnd;
     _tiltIncrement     = Math.Abs(_tiltStart - _tiltEnd) / Math.Ceiling((_ms / FADER_TIMER_TICK_INTERVAL) * (100 / Controller.Rate));
     _tiltCurrent       = _tiltStart;
 }
Esempio n. 8
0
        public int GetLevel()
        {
            // A bit of a hack; we reverse engineer the level based on one photon
            // (might be weird if some of these channels were set by a different source)

            // Get channel's level
            int dmxValue = DMXController.GetLevel(_photons[0].Channel);

            // Return the level scaled by the photon's intensity
            // (the inverse of what we did in SetLevel)
            return((dmxValue * 255) / _photons[0].Intensity);
        }
Esempio n. 9
0
        public static void StartProgram()
        {
            //Load the default lighting config.  If the directory does not exist, create it.
            if (!Directory.Exists(Utilities.PROGRAM_FILES_PATH))
            {
                Directory.CreateDirectory(Utilities.PROGRAM_FILES_PATH);
            }
            //If the file does not exist, create it.
            if (!File.Exists(Utilities.PROGRAM_FILES_PATH + "\\Default.lsc"))
            {
                FileStream f = File.Create(Utilities.PROGRAM_FILES_PATH + "\\Default.lsc");
                f.Close();
            }
            Stream inputStream = File.OpenRead(Utilities.PROGRAM_FILES_PATH + "\\Default.lsc");

            try
            {
                //Attempt to deserialize from the lighting config file.
                BinaryFormatter deserializer = new BinaryFormatter();
                _lightingSystemConfiguration = (LightingSystemConfiguration)deserializer.Deserialize(inputStream);
            }
            catch (System.Runtime.Serialization.SerializationException e)
            {
                MessageBox.Show("The default configuration file could not be found.  The system will create a new one.");
            }
            catch (Exception e)
            {
                Utilities.ReportError(e);
            }
            finally
            {
                inputStream.Close();
            }

            //Start DMX
            DMXController.StartDMX();

            //Start other static classes
            Total_DMX_Control_WPF.Fixtures.Start();

            ////Connect to iTunes Jukebox Server
            //if (Properties.Settings.Default.EnableItunesJukeboxSupport)
            //{
            //    _lightingCommunication.ConnectToServer(Properties.Settings.Default.ItunesJukeboxServerIdentifier,
            //        Properties.Settings.Default.ItunesJukeboxPort,
            //        "Total DMX Control", ClientType.LIGHTING, new Version());
            //}
            //DMXController.SetLevel("START", 62, 255);
            //DMXController.SetLevel("START", 63, 255);
            WindowManager.ShowMainWindow();
        }
Esempio n. 10
0
 public override void Kill()
 {
     if (_timer != null)
     {
         _timer.Stop();
     }
     foreach (Photon pair in _chans)
     {
         DMXController.SetLevel(_setterName, pair.Channel, 0);
     }
     if (_callback != null)
     {
         _callback();
     }
 }
Esempio n. 11
0
 protected virtual void Finish()
 {
     if (_timer != null)
     {
         _timer.Stop();
     }
     foreach (Photon pair in _chans)
     {
         DMXController.SetLevel(_setterName, pair.Channel, (_level * _end * pair.Intensity) / 65025);
     }
     if (_callback != null)
     {
         _callback();
     }
 }
Esempio n. 12
0
        /*
         * Everything that should happen when the program is closing.
         */
        public static void EndProgram()
        {
            DMXController.StopDMX();
            //TODO: this isn't quite right; make sure that if someone disables
            //support while the program is running that we disconnect from
            //the iTunes jukebox server then
            //if (_lightingCommunication != null && Properties.Settings.Default.EnableItunesJukeboxSupport)
            //{
            //    _lightingCommunication.DisconnectFromServer();
            //}

            _lightingSystemConfiguration.Serialize(Utilities.PROGRAM_FILES_PATH);


            DeregisterAllDisplayers();
            _appClosing = true;
            Application.Current.Shutdown();
        }
Esempio n. 13
0
 protected override void Tick(object sender, EventArgs e)
 {
     if (_up)
     {
         //The normal "superclass" variables store the Pan values.
         _current     += _increment;
         _tiltCurrent += _tiltIncrement;
         if (_current >= _end)
         {
             Finish();
         }
         else
         {
             double fine   = _current % 256;
             double coarse = _current / 256;
             DMXController.SetLevel(_setterName, _panFineChannel, Convert.ToInt32(Math.Floor((_level * fine) / 255)));
             DMXController.SetLevel(_setterName, _panCoarseChannel, Convert.ToInt32(Math.Floor((_level * coarse) / 255)));
             double tiltFine   = _tiltCurrent % 256;
             double tiltCoarse = _tiltCurrent / 256;
             DMXController.SetLevel(_setterName, _tiltFineChannel, Convert.ToInt32(Math.Floor((_level * tiltFine) / 255)));
             DMXController.SetLevel(_setterName, _tiltCoarseChannel, Convert.ToInt32(Math.Floor((_level * tiltCoarse) / 255)));
         }
     }
     else
     {
         _current     -= _increment;
         _tiltCurrent -= _tiltIncrement;
         if (_current <= _end)
         {
             Finish();
         }
         else
         {
             double fine   = _current % 256;
             double coarse = _current / 256;
             DMXController.SetLevel(_setterName, _panFineChannel, Convert.ToInt32(Math.Floor((_level * fine) / 255)));
             DMXController.SetLevel(_setterName, _panCoarseChannel, Convert.ToInt32(Math.Floor((_level * coarse) / 255)));
             double tiltFine   = _tiltCurrent % 256;
             double tiltCoarse = _tiltCurrent / 256;
             DMXController.SetLevel(_setterName, _tiltFineChannel, Convert.ToInt32(Math.Floor((_level * tiltFine) / 255)));
             DMXController.SetLevel(_setterName, _tiltCoarseChannel, Convert.ToInt32(Math.Floor((_level * tiltCoarse) / 255)));
         }
     }
 }
Esempio n. 14
0
        protected override void Finish()
        {
            if (_timer != null)
            {
                _timer.Stop();
            }
            //just to make sure it ends at the right values for sure.
            double fine   = _end % 256;
            double coarse = _end / 256;

            DMXController.SetLevel(_setterName, _panFineChannel, Convert.ToInt32(Math.Floor((_level * fine) / 255)));
            DMXController.SetLevel(_setterName, _panCoarseChannel, Convert.ToInt32(Math.Floor((_level * coarse) / 255)));
            double tiltFine   = _tiltEnd % 256;
            double tiltCoarse = _tiltEnd / 256;

            DMXController.SetLevel(_setterName, _tiltFineChannel, Convert.ToInt32(Math.Floor((_level * tiltFine) / 255)));
            DMXController.SetLevel(_setterName, _tiltCoarseChannel, Convert.ToInt32(Math.Floor((_level * tiltCoarse) / 255)));
            if (_callback != null)
            {
                _callback();
            }
        }
Esempio n. 15
0
 public void SuppressGreen()
 {
     DMXController.Suppress(startChannel + 2);
 }
Esempio n. 16
0
 public void StopColorStrip()
 {
     DMXController.SetLevel("static", startChannel, 0);
 }
Esempio n. 17
0
        /**
         * These methods allow you to suppress each channel individually instead of all of them together.
         * To suppress all, use the Suppress() and Unsuppress() found in the superclass.
         **/
        #region Suppression

        public void SuppressRed()
        {
            DMXController.Suppress(startChannel + 1);
        }
Esempio n. 18
0
        private void SendDMX()
        {
            if (!connected)
            {
                return;
            }

            // break
            FT_SetBreakOn(deviceHandle);
            System.Threading.Thread.Sleep(1);
            FT_SetBreakOff(deviceHandle);

            string buffer = Microsoft.VisualBasic.Strings.Chr(startCode).ToString() + DMXController.getDMXBuffer();

            // write entire thing

            try
            {
                if (FT_Write(deviceHandle, buffer, buffer.Length, ref bytesWritten) != FT_OK)
                {
                    lastError = "Failed to Write DMX.";
                    throw new Exception(lastError);
                }
            }
            catch (Exception e)
            {
                System.Windows.MessageBoxResult ask = MessageBox.Show("Try again?", "Device Error: " + e.Message, MessageBoxButton.YesNoCancel);
                if (ask == System.Windows.MessageBoxResult.No)
                {
                    Controller.EndProgram();
                }
                else if (ask == System.Windows.MessageBoxResult.Cancel)
                {
                    DMXController.debugging = true;
                    connectionOpen          = false;
                }
            }
        }
Esempio n. 19
0
 public void SetIntensity(int level)
 {
     DMXController.SetLevels(Name, OnOffChannels, level);
 }
Esempio n. 20
0
 public virtual void Off(string sender)
 {
     DMXController.SetLevels(sender, OnOffChannels, 0);
 }
Esempio n. 21
0
 private void btnClearHTP_Click(object sender, RoutedEventArgs e)
 {
     DMXController.FlushHTPAll();
 }
Esempio n. 22
0
 public void SuppressBlue()
 {
     DMXController.Suppress(startChannel + 3);
 }
Esempio n. 23
0
 public void UnsuppressGreen()
 {
     DMXController.Unsuppress(startChannel + 1);
 }
Esempio n. 24
0
 /*
  * Get the level of the specified channel.
  */
 public int GetLevel(int channel)
 {
     return(DMXController.GetLevel(channel));
 }
Esempio n. 25
0
 public void UnsuppressRed()
 {
     DMXController.Unsuppress(startChannel);
 }
Esempio n. 26
0
 public Fader(string setterName, int channel, int end, double fadeTimeSecs) :
     this(setterName, channel, DMXController.GetLevel(channel), end, fadeTimeSecs)
 {
 }
Esempio n. 27
0
 public void UnsuppressBlue()
 {
     DMXController.Unsuppress(startChannel + 2);
 }
Esempio n. 28
0
 /*
  * Generic level setter. Gets called from subclasses.
  * Appends "fix." to the beginning of the senderName for HTP purposes.
  */
 public void SetLevel(int intensity, int channel)
 {
     DMXController.SetLevel(("fix." + name), channel, intensity);
 }