Example #1
0
 private void trackBar8_Scroll(object sender, EventArgs e)
 {
     label10.Text = "" + trackBar8.Value;
     OpenDMX.setDmxValue(8, (byte)trackBar8.Value);
     OpenDMX.writeData();
     OpenDMX.setDmxValue(8, (byte)trackBar8.Value);
     OpenDMX.writeData();
     mostRecentData[7] = (byte)trackBar8.Value;
 }
Example #2
0
        private void Main_Load(object sender, EventArgs e)
        {
            try
            {
                OpenDMX.start();                                            //find and connect to devive (first found if multiple)
                if (OpenDMX.status == FT_STATUS.FT_DEVICE_NOT_FOUND)        //update status
                {
                    toolStripStatusLabel1.Text = "No Enttec USB Device Found";
                }
                else if (OpenDMX.status == FT_STATUS.FT_OK)
                {
                    toolStripStatusLabel1.Text = "Found DMX on USB";
                }
                else
                {
                    toolStripStatusLabel1.Text = "Error Opening Device";
                }
            }
            catch (Exception exp)
            {
                Console.WriteLine(exp);
                toolStripStatusLabel1.Text = "Error Connecting to Enttec USB Device";
            }

            // On initialization, reset alll lights to zero
            OpenDMX.setDmxValue(1, 0);
            OpenDMX.setDmxValue(2, 0);
            OpenDMX.setDmxValue(3, 0);
            OpenDMX.setDmxValue(4, 0);
            OpenDMX.setDmxValue(5, 0);
            OpenDMX.setDmxValue(6, 0);
            OpenDMX.setDmxValue(7, 0);
            OpenDMX.setDmxValue(8, 0);
            OpenDMX.writeData();

            // For some reason we need duplication...
            OpenDMX.setDmxValue(1, 0);
            OpenDMX.setDmxValue(2, 0);
            OpenDMX.setDmxValue(3, 0);
            OpenDMX.setDmxValue(4, 0);
            OpenDMX.setDmxValue(5, 0);
            OpenDMX.setDmxValue(6, 0);
            OpenDMX.setDmxValue(7, 0);
            OpenDMX.setDmxValue(8, 0);
            OpenDMX.writeData();


            for (int i = 0; i < 8; i++)
            {
                mostRecentData[i] = 0;
            }
        }
Example #3
0
        private void btnAllOn_Click(object sender, EventArgs e)
        {
            if (OpenDMX.status == FT_STATUS.FT_DEVICE_NOT_FOUND)
            {
                toolStripStatusLabel1.Text = "No Enttec USB Device Found";
            }
            else
            {
                toolStripStatusLabel1.Text = "Found DMX on USB";
            }
            OpenDMX.setDmxValue(1, 255);
            OpenDMX.setDmxValue(2, 255);
            OpenDMX.setDmxValue(3, 255);
            OpenDMX.setDmxValue(4, 255);
            OpenDMX.setDmxValue(5, 255);
            OpenDMX.setDmxValue(6, 255);
            OpenDMX.setDmxValue(7, 255);
            OpenDMX.setDmxValue(8, 255);
            OpenDMX.writeData();

            // For some reason we need duplication...
            OpenDMX.setDmxValue(1, 255);
            OpenDMX.setDmxValue(2, 255);
            OpenDMX.setDmxValue(3, 255);
            OpenDMX.setDmxValue(4, 255);
            OpenDMX.setDmxValue(5, 255);
            OpenDMX.setDmxValue(6, 255);
            OpenDMX.setDmxValue(7, 255);
            OpenDMX.setDmxValue(8, 255);
            OpenDMX.writeData();

            setSliders(255);

            for (int i = 0; i < 8; i++)
            {
                mostRecentData[i] = 255;
            }
        }
Example #4
0
        public Main()
        {
            InitializeComponent();

            trackBars = new TrackBar[]
            {
                trackBar1,
                trackBar2,
                trackBar3,
                trackBar4,
                trackBar5,
                trackBar6,
                trackBar7,
                trackBar8
            };

            labels = new Label[]
            {
                label1,
                label2,
                label5,
                label6,
                label7,
                label8,
                label9,
                label10
            };

            HandleOscPacket callback = delegate(OscPacket packet)
            {
                if (packet is OscMessage)
                {
                    var msg = (OscMessage)packet;
                    if (msg.Address == "/dmx")
                    {
                        messageQueue.Enqueue(msg);
                    }
                }
                else if (packet is OscBundle)
                {
                    var bundle = (OscBundle)packet;
                    foreach (OscMessage msg in bundle.Messages)
                    {
                        if (msg.Address == "/dmx")
                        {
                            messageQueue.Enqueue(msg);
                        }
                    }
                }
            };

            updateThread = new Thread(delegate()
            {
                OscMessage message;
                while (true)
                {
                    if (messageQueue.Count > 0)
                    {
                        message = messageQueue.Dequeue();
                        if (message != null && OpenDMX.status == FT_STATUS.FT_OK)
                        {
                            int channels = Math.Min(message.Arguments.Count, OpenDMX.UNIVERSE_SIZE);
                            for (int i = 0; i < channels; i++)
                            {
                                try
                                {
                                    float value  = Convert.ToSingle(message.Arguments[i]);
                                    byte byteVal = (byte)(value * 255);
                                    OpenDMX.setDmxValue(i + 1, byteVal);

                                    mostRecentData[i] = byteVal;
                                }
                                catch (Exception)
                                {
                                }
                            }

                            OpenDMX.streamData();
                        }
                    }
                }
            }
                                      );
            updateThread.Start();

            listener = new UDPListener(7000, callback);

            refreshTimer.Interval = 500; //ms
            refreshTimer.Tick    += new EventHandler(timer_Tick);
            refreshTimer.Start();
        }