Exemple #1
0
        /// <summary>
        /// Change the waveform
        /// </summary>
        private void OnWaveformButton(object sender, EventArgs e)
        {
            if (this.port == null || !this.port.IsOpen)
            {
                MessageBox.Show("Cannot send data - COM port is not open.");
                return;
            }

            if (waveformComboBox.SelectedIndex < 0)
            {
                return;
            }

            var message = new DNOSMessage(DNOSMessage.DNOSProtocolCommand.AD9833, (byte)DNOSMessage.AD9833Command.Waveform, (byte)waveformComboBox.SelectedItem);

            WriteSerial(message.Payload());
        }
Exemple #2
0
        private void pulseGenStartButton_Click(object sender, EventArgs args)
        {
            try
            {
                if (this.port == null || !this.port.IsOpen)
                {
                    throw new Exception("Cannot send data - COM port is not open.");
                }

                var message = new DNOSMessage(DNOSMessage.DNOSProtocolCommand.PulseGen, (byte)DNOSMessage.PulseGenCommand.Start, new byte[] { });
                WriteSerial(message.Payload());
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
Exemple #3
0
        private void freqSweepStopButton_Click(object sender, EventArgs args)
        {
            try
            {
                if (this.port == null || !this.port.IsOpen)
                {
                    throw new Exception("Cannot send data - COM port is not open.");
                }

                var message = new DNOSMessage(DNOSMessage.DNOSProtocolCommand.AD9833, (byte)DNOSMessage.AD9833Command.FreqSweepStop, new byte[] { });

                WriteSerial(message.Payload());
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return;
            }
        }
Exemple #4
0
        private void freqSweepSend_Click(object sender, EventArgs args)
        {
            try
            {
                if (this.port == null || !this.port.IsOpen)
                {
                    throw new Exception("Cannot send data - COM port is not open.");
                }

                if (this.freqSweepModeComboBox.SelectedIndex < 0)
                {
                    return;
                }

                var freqStart = uint.Parse(this.freqStartBox.Text);
                var freqEnd   = uint.Parse(this.freqEndBox.Text);
                var timeStep  = uint.Parse(this.timeStepTextBox.Text);
                var freqGrad  = uint.Parse(this.freqGradientBox.Text);

                // build data
                using (var writer = new BinaryWriter(new MemoryStream()))
                {
                    writer.Write((byte)freqSweepModeComboBox.SelectedItem);
                    writer.Write(freqStart);
                    writer.Write(freqEnd);
                    writer.Write(timeStep);
                    writer.Write(freqGrad);

                    byte[] data = ((MemoryStream)writer.BaseStream).ToArray();

                    var message = new DNOSMessage(DNOSMessage.DNOSProtocolCommand.AD9833, (byte)DNOSMessage.AD9833Command.FreqSweepBegin, data);
                    WriteSerial(message.Payload());
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return;
            }
        }
Exemple #5
0
        private void OnFrequencyButton(object sender, EventArgs args)
        {
            try
            {
                if (this.port == null || !this.port.IsOpen)
                {
                    throw new Exception("Cannot send data - COM port is not open.");
                }

                int value = int.Parse(frequencyTextBox.Text);

                var freq = BitConverter.GetBytes(value);

                var message = new DNOSMessage(DNOSMessage.DNOSProtocolCommand.AD9833, (byte)DNOSMessage.AD9833Command.Frequency, freq);
                WriteSerial(message.Payload());
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return;
            }
        }
Exemple #6
0
        private void pulseGenConfigureButton_Click(object sender, EventArgs args)
        {
            byte[] states = { 0, 1, 0, 1, 0 };
            uint[] micros = { 30000, 350, 400, 450, 500 };

            try
            {
                if (this.port == null || !this.port.IsOpen)
                {
                    throw new Exception("Cannot send data - COM port is not open.");
                }

                // build data
                using (var writer = new BinaryWriter(new MemoryStream()))
                {
                    writer.Write(states.Length);
                    writer.Write(states);

                    foreach (uint i in micros)
                    {
                        writer.Write(i);
                    }

                    byte[] data = ((MemoryStream)writer.BaseStream).ToArray();

                    var message = new DNOSMessage(DNOSMessage.DNOSProtocolCommand.PulseGen,
                                                  (byte)DNOSMessage.PulseGenCommand.Configure,
                                                  data);

                    byte[] payload = message.Payload();
                    WriteSerial(payload);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }