Ejemplo n.º 1
0
        public Terminal()
        {
            InitializeComponent();

            // wypelnij liste wszystkimi dostepnymi portami szeregowymi
            foreach (string port in SerialPort.GetPortNames())
            {
                port_comboBox.Items.Add(port);
            }

            // wybierz pierwszy element z listy
            port_comboBox.SelectedIndex = port_comboBox.Items.Count - 1;

            // wypelnij liste command code
            foreach (ModemRequest m in ModemRequest.GetListOfCommands())
            {
                commandCode_comboBox.Items.Add(m.Name);
            }
            commandCode_comboBox.SelectedIndex = 5;

            // wszystkie przychodzące ramki będą pokazywane w polu tekstowym
            modemCommunication.TerminalOutput = WriteToTerminal;

            // eventy od zaznaczania radio boxow
            EIGHTPSK_RadioButton.Checked += ModulationChanged;
            BPSK_RadioButton.Checked     += ModulationChanged;
            QPSK_RadioButton.Checked     += ModulationChanged;
            BPSK_PNA_RadioButton.Checked += ModulationChanged;

            PHY_RadioButton.Checked += ModeChanged;
            DL_RadioButton.Checked  += ModeChanged;
        }
Ejemplo n.º 2
0
        private void ModeChanged(object sender, RoutedEventArgs e)
        {
            byte[] frame = null;
            if ((bool)DL_RadioButton.IsChecked)
            {
                frame = ModemRequest.CreateFrame(Command.MIB_WriteRequest, null, Mode.DL, 0, false);
                commandCode_comboBox.SelectedIndex = 5;
            }
            else if ((bool)PHY_RadioButton.IsChecked)
            {
                frame = ModemRequest.CreateFrame(Command.MIB_WriteRequest, null, Mode.PHY, 0, false);
                commandCode_comboBox.SelectedIndex = 4;
            }

            if (modemCommunication.Port.IsOpen)
            {
                modemCommunication.SendFrame(frame);
            }
        }
Ejemplo n.º 3
0
        private void SendButtonClick(object sender, RoutedEventArgs e)
        {
            if (modemCommunication.Port.IsOpen)
            {
                Command command    = ModemRequest.GetCommandFromName(commandCode_comboBox.SelectedItem.ToString());
                byte[]  asciiBytes = Encoding.ASCII.GetBytes(ascii_TextBox.Text);
                Mode    mode       = DL_RadioButton.IsChecked == true ? Mode.DL : Mode.PHY;

                Modulation modulation;
                if (BPSK_RadioButton.IsChecked == true)
                {
                    modulation = Modulation.BPSK;
                }
                else if (QPSK_RadioButton.IsChecked == true)
                {
                    modulation = Modulation.QPSK;
                }
                else if (EIGHTPSK_RadioButton.IsChecked == true)
                {
                    modulation = Modulation.EIGHT_PSK;
                }
                else
                {
                    modulation = Modulation.BPSK_WITH_PNA;
                }

                byte[] frame = ModemRequest.CreateFrame(command, asciiBytes, mode, modulation, (bool)FEC_CheckBox.IsChecked);

                //byte cmd = ModemRequest.GetCCFromName(commandCode_comboBox.SelectedItem.ToString());
                //byte[] frame = ModemCommunication.MakeFrame(cmd, asciiBytes);
                if (frame != null)
                {
                    modemCommunication.SendFrame(frame);
                }
            }
        }