Exemplo n.º 1
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;
                }
            }
        }