public MainWindow()
        {
            bool ConnectionSuccesful = false;
            InitializeComponent();

            GetSettings();
            sw.NewSettingsSaved += new EventHandler(sw_NewSettingsSaved);
            while (!ConnectionSuccesful)
            {

                try
                {
                    comms = new comms(Settings);
                    ConnectionSuccesful = true;
                }
                catch (Exception e)
                {
                    MessageBox.Show("Error connecting to device\r\n" + e.Message);
                    sw.ShowDialog();
                }
            }
            eng = new Pioneer1120Engine(comms);
            eng.UpdateStatus();
            System.Threading.Thread.Sleep(1000);
            tabController1.SetDeviceState(eng.DevState);
            tabController1.MessagesReadyToSend += new EventHandler(tabController1_MessagesReadyToSend);
            eng.DeviceStateUpdateFromDevice += new EventHandler(eng_DeviceStateUpdateFromDevice);

            eng.SetDevChangedDel(UpdateDevState);
        }
        public Pioneer1120Engine(comms comms)
        {
            Received = new Queue<string>();
            Comms = comms;
            SendData("VU");

            // create thread to listen and receive responses
            bw.DoWork += RX;
            bw.RunWorkerAsync();
        }
        public Pioneer1120Engine(comms comms)
        {
            DevState = new Pioneer1120.Pioneer1120State();
            DevState.LastKnownFLStatus = string.Empty;
            RspTypes = Enum.GetNames(typeof(PioneerProtocol.ResponseMsgType)).ToList();
            Received = new Queue<string>();
            Comms = comms;
            //SendData("VU");

            // create thread to listen and receive responses
            bw.DoWork += RX;
            bw.ProgressChanged += new ProgressChangedEventHandler(bw_ProgressChanged);
            bw.WorkerReportsProgress = true;
            bw.RunWorkerAsync();
        }
 void sw_NewSettingsSaved(object sender, EventArgs e)
 {
     Settings = sw.settingsOnClose;
     comms = new comms(Settings);
 }