public MainWindow()
        {
            InitializeComponent();

            dlgPortSettings = null;
            comPort         = null;

            tblMain.SelectedIndex = 0;
            psSector = 0;

            pmOTP = new OTP();

            cw1_fosc = 1;
            cw1_sut  = 3;
            cw1_rcm  = 1;
            cw1_osco = true;

            cw2_mmode = 1;
            cw2_tcyc  = 2;
            cw2_lvdt  = 6;
            cw2_pmod  = 1;
            cw2_mcre  = true;
            cw2_wdte  = true;

            DataContext = this;
        }
        public MainWindow()
        {
            InitializeComponent();

            dlgPortSettings = null;
            comPort = null;

            tblMain.SelectedIndex = 0;
            psSector = 0;

            pmOTP = new OTP();

            cw1_fosc = 1;
            cw1_sut = 3;
            cw1_rcm = 1;
            cw1_osco = true;

            cw2_mmode = 1;
            cw2_tcyc = 2;
            cw2_lvdt = 6;
            cw2_pmod = 1;
            cw2_mcre = true;
            cw2_wdte = true;

            DataContext = this;
        }
        private void btnPortSettings_Click(object sender, RoutedEventArgs e)
        {
            if (dlgPortSettings == null)
            {
                dlgPortSettings = new SerialSettings();

                dlgPortSettings.Closed += (o, evt) => dlgPortSettings = null;

                dlgPortSettings.Show();
            }
            else
            {
                dlgPortSettings.Activate();
                dlgPortSettings.Show();
            }
        }
        private void btnPortSettings_Click(object sender, RoutedEventArgs e)
        {
            if (dlgPortSettings == null)
            {
                dlgPortSettings = new SerialSettings();

                dlgPortSettings.Closed += (o, evt) => dlgPortSettings = null;

                dlgPortSettings.Show();
            }
            else
            {
                dlgPortSettings.Activate();
                dlgPortSettings.Show();
            }
        }