Ejemplo n.º 1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // List aviable COM ports and select last in list
            string[] aviablePorts = System.IO.Ports.SerialPort.GetPortNames();
            for (int i = 0; i < aviablePorts.Length; i++) comboBox_COM.Items.Add(aviablePorts[i]);
            comboBox_COM.SelectedIndex = comboBox_COM.Items.Count - 1;

            // Create scope objects
            scopeA = Oscilloscope.CreateScope("scope_settings.ini", "");
            if (scopeA != null)
            {
                scopeB = Oscilloscope.CreateScope("scope_settings.ini", "");
                scopeC = Oscilloscope.CreateScope("scope_settings.ini", "");
                scopeD = Oscilloscope.CreateScope("scope_settings.ini", "");
            }

            // Set default scope channels
            comboBox_scopeA0.SelectedIndex = 0;
            comboBox_scopeA1.SelectedIndex = 1;
            comboBox_scopeA2.SelectedIndex = 2;
            comboBox_scopeAtrig.SelectedIndex = 12;
            comboBox_scopeB0.SelectedIndex = 3;
            comboBox_scopeB1.SelectedIndex = 4;
            comboBox_scopeB2.SelectedIndex = 5;
            comboBox_scopeBtrig.SelectedIndex = 13;
            comboBox_scopeC0.SelectedIndex = 6;
            comboBox_scopeC1.SelectedIndex = 7;
            comboBox_scopeC2.SelectedIndex = 8;
            comboBox_scopeCtrig.SelectedIndex = 14;
            comboBox_scopeD0.SelectedIndex = 9;
            comboBox_scopeD1.SelectedIndex = 10;
            comboBox_scopeD2.SelectedIndex = 11;
            comboBox_scopeDtrig.SelectedIndex = 15;

            // Show scopes (else disable scope form controls if .dll error)
            if (scopeA != null) scopeA.ShowScope();
            else
            {
                label_scopeA.Enabled = false;
                comboBox_scopeA0.Enabled = false;
                comboBox_scopeA1.Enabled = false;
                comboBox_scopeA2.Enabled = false;
                comboBox_scopeAtrig.Enabled = false;
            }
            if (scopeB != null) scopeB.ShowScope();
            else
            {
                label_scopeB.Enabled = false;
                comboBox_scopeB0.Enabled = false;
                comboBox_scopeB1.Enabled = false;
                comboBox_scopeB2.Enabled = false;
                comboBox_scopeBtrig.Enabled = false;
            }
            if (scopeC != null) scopeC.ShowScope();
            else
            {
                label_scopeC.Enabled = false;
                comboBox_scopeC0.Enabled = false;
                comboBox_scopeC1.Enabled = false;
                comboBox_scopeC2.Enabled = false;
                comboBox_scopeCtrig.Enabled = false;
            }
            if (scopeD != null) scopeD.ShowScope();
            else
            {
                label_scopeD.Enabled = false;
                comboBox_scopeD0.Enabled = false;
                comboBox_scopeD1.Enabled = false;
                comboBox_scopeD2.Enabled = false;
                comboBox_scopeDtrig.Enabled = false;
            }

            // Create new DAQ32 data object
            data = new DAQ32data();

            // Start for update timer
            formUpdateTimer = new Timer();
            formUpdateTimer.Interval = 50;
            formUpdateTimer.Tick += new EventHandler(formUpdateTimer_Tick);
            formUpdateTimer.Start();
        }
Ejemplo n.º 2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // List aviable COM ports and select last in list
            string[] aviablePorts = System.IO.Ports.SerialPort.GetPortNames();
            for (int i = 0; i < aviablePorts.Length; i++) comboBox_COM.Items.Add(aviablePorts[i]);
            comboBox_COM.SelectedIndex = comboBox_COM.Items.Count - 1;

            // Create scope objects
            scopeA = Oscilloscope.CreateScope(iniFileName, "");
            if (scopeA != null)
            {
                scopeB = Oscilloscope.CreateScope(iniFileName, "");
                scopeC = Oscilloscope.CreateScope(iniFileName, "");
                scopeD = Oscilloscope.CreateScope(iniFileName, "");
            }

            // Set default scope channels
            comboBox_scopeA0.SelectedIndex = 0;
            comboBox_scopeA1.SelectedIndex = 1;
            comboBox_scopeA2.SelectedIndex = 2;
            comboBox_scopeAtrig.SelectedIndex = 12;
            comboBox_scopeB0.SelectedIndex = 3;
            comboBox_scopeB1.SelectedIndex = 4;
            comboBox_scopeB2.SelectedIndex = 5;
            comboBox_scopeBtrig.SelectedIndex = 13;
            comboBox_scopeC0.SelectedIndex = 6;
            comboBox_scopeC1.SelectedIndex = 7;
            comboBox_scopeC2.SelectedIndex = 8;
            comboBox_scopeCtrig.SelectedIndex = 14;
            comboBox_scopeD0.SelectedIndex = 9;
            comboBox_scopeD1.SelectedIndex = 10;
            comboBox_scopeD2.SelectedIndex = 11;
            comboBox_scopeDtrig.SelectedIndex = 15;

            // Show scopes and use default settings if .ini file file not present
            if (scopeA != null)
            {
                scopeA.ShowScope();
                scopeB.ShowScope();
                scopeC.ShowScope();
                scopeD.ShowScope();
                if (!File.Exists(iniFileName))
                {
                    #region default scope settings
                    scopeA.TriggerLevel1 = 2048;
                    scopeA.TriggerLevel2 = 2048;
                    scopeA.TriggerLevel3 = 2048;
                    scopeA.AmplitudeScale1 = 300;
                    scopeA.AmplitudeScale2 = 300;
                    scopeA.AmplitudeScale3 = 300;
                    scopeA.VerticalOffset1 = -2000;
                    scopeA.VerticalOffset2 = -2000;
                    scopeA.VerticalOffset3 = -2000;
                    scopeA.SamplesPerGridCell = 100;
                    scopeA.CellSize = 35;
                    scopeA.Width = 630;
                    scopeA.Height = 470;
                    scopeB.TriggerLevel1 = 2048;
                    scopeB.TriggerLevel2 = 2048;
                    scopeB.TriggerLevel3 = 2048;
                    scopeB.AmplitudeScale1 = 300;
                    scopeB.AmplitudeScale2 = 300;
                    scopeB.AmplitudeScale3 = 300;
                    scopeB.VerticalOffset1 = -2000;
                    scopeB.VerticalOffset2 = -2000;
                    scopeB.VerticalOffset3 = -2000;
                    scopeB.SamplesPerGridCell = 100;
                    scopeB.CellSize = 35;
                    scopeB.Width = 630;
                    scopeB.Height = 470;
                    scopeC.TriggerLevel1 = 2048;
                    scopeC.TriggerLevel2 = 2048;
                    scopeC.TriggerLevel3 = 2048;
                    scopeC.AmplitudeScale1 = 300;
                    scopeC.AmplitudeScale2 = 300;
                    scopeC.AmplitudeScale3 = 300;
                    scopeC.VerticalOffset1 = -2000;
                    scopeC.VerticalOffset2 = -2000;
                    scopeC.VerticalOffset3 = -2000;
                    scopeC.SamplesPerGridCell = 100;
                    scopeC.CellSize = 35;
                    scopeC.Width = 630;
                    scopeC.Height = 470;
                    scopeD.TriggerLevel1 = 2048;
                    scopeD.TriggerLevel2 = 2048;
                    scopeD.TriggerLevel3 = 2048;
                    scopeD.AmplitudeScale1 = 300;
                    scopeD.AmplitudeScale2 = 300;
                    scopeD.AmplitudeScale3 = 300;
                    scopeD.VerticalOffset1 = -2000;
                    scopeD.VerticalOffset2 = -2000;
                    scopeD.VerticalOffset3 = -2000;
                    scopeD.SamplesPerGridCell = 100;
                    scopeD.CellSize = 35;
                    scopeD.Width = 630;
                    scopeD.Height = 470;
                    #endregion
                }
            }

            // disable scope form controls if scope .dll error
            else
            {
                label_scopeA.Enabled = false;
                comboBox_scopeA0.Enabled = false;
                comboBox_scopeA1.Enabled = false;
                comboBox_scopeA2.Enabled = false;
                comboBox_scopeAtrig.Enabled = false;
                label_scopeB.Enabled = false;
                comboBox_scopeB0.Enabled = false;
                comboBox_scopeB1.Enabled = false;
                comboBox_scopeB2.Enabled = false;
                comboBox_scopeBtrig.Enabled = false;
                label_scopeC.Enabled = false;
                comboBox_scopeC0.Enabled = false;
                comboBox_scopeC1.Enabled = false;
                comboBox_scopeC2.Enabled = false;
                comboBox_scopeCtrig.Enabled = false;
                label_scopeD.Enabled = false;
                comboBox_scopeD0.Enabled = false;
                comboBox_scopeD1.Enabled = false;
                comboBox_scopeD2.Enabled = false;
                comboBox_scopeDtrig.Enabled = false;
            }

            // Create new DAQ32 data object
            data = new DAQ32data();

            // Start for update timer
            formUpdateTimer = new Timer();
            formUpdateTimer.Interval = 50;
            formUpdateTimer.Tick += new EventHandler(formUpdateTimer_Tick);
            formUpdateTimer.Start();
        }