コード例 #1
0
        private void sendUDPUpdate(RadioUpdate update)
        {
            byte[] bytes = Encoding.ASCII.GetBytes(JsonConvert.SerializeObject(update) + "\n");

            //unicast
            send("127.0.0.1", 5056, bytes);
        }
コード例 #2
0
        public MainWindow()
        {
            InitializeComponent();

            // radio1.radioId = 0;

            //allows click and drag anywhere on the window
            //   this.containerPanel.MouseLeftButtonDown += WrapPanel_MouseLeftButtonDown;

            radio1.radioLabel.Content = "UHF Test";
            radio1.radioId = 0;
            radio1.radioFrequency.Text = "120.0";

            radio2.radioId = 1;
            radio2.radioLabel.Content = "VHF Test";
            radio2.radioFrequency.Text = "150.0";

            radio3.radioId = 2;
            radio3.radioLabel.Content = "FM Test";
            radio3.radioFrequency.Text = "30.0";

            Task.Run(() =>
               {

               while (!end)
               {
                   Thread.Sleep(300);

                   Application.Current.Dispatcher.Invoke(new Action(() =>
                       {
                           RadioUpdate update = new RadioUpdate();

                           update.radios = new RadioInformation[3];

                           update.radios[0] = new RadioInformation();
                           update.radios[0].name = "UHF";
                           update.radios[0].frequency = Double.Parse(radio1.radioFrequency.Text) * MHZ;
                           update.radios[0].volume = (float)radio1.radioVolume.Value;
                           update.radios[0].modulation = 0;

                           update.radios[1] = new RadioInformation();
                           update.radios[1].name = "VHF";
                           update.radios[1].frequency = Double.Parse(radio2.radioFrequency.Text) * MHZ;
                           update.radios[1].volume = (float)radio2.radioVolume.Value;
                           update.radios[1].modulation = 0;

                           update.radios[2] = new RadioInformation();
                           update.radios[2].name = "FM";
                           update.radios[2].frequency = Double.Parse(radio3.radioFrequency.Text) * MHZ;
                           update.radios[2].volume = (float)radio3.radioVolume.Value;
                           update.radios[2].modulation = 1;

                           update.selected = selected;

                           sendUDPUpdate(update);

                       }));

               }
               });
        }
コード例 #3
0
        private void sendUDPUpdate(RadioUpdate update)
        {
            byte[] bytes = Encoding.ASCII.GetBytes(JsonConvert.SerializeObject(update) + "\n");

            //unicast
            send("127.0.0.1", 5056, bytes);
        }
コード例 #4
0
        public MainWindow()
        {
            InitializeComponent();

            // radio1.radioId = 0;


            //allows click and drag anywhere on the window
            //   this.containerPanel.MouseLeftButtonDown += WrapPanel_MouseLeftButtonDown;

            radio1.radioLabel.Content  = "UHF Test";
            radio1.radioId             = 0;
            radio1.radioFrequency.Text = "120.0";

            radio2.radioId             = 1;
            radio2.radioLabel.Content  = "VHF Test";
            radio2.radioFrequency.Text = "150.0";

            radio3.radioId             = 2;
            radio3.radioLabel.Content  = "FM Test";
            radio3.radioFrequency.Text = "30.0";



            Task.Run(() =>
            {
                while (!end)
                {
                    Thread.Sleep(300);


                    Application.Current.Dispatcher.Invoke(new Action(() =>
                    {
                        RadioUpdate update = new RadioUpdate();

                        update.radios = new RadioInformation[3];

                        update.radios[0]            = new RadioInformation();
                        update.radios[0].name       = "UHF";
                        update.radios[0].frequency  = Double.Parse(radio1.radioFrequency.Text) * MHZ;
                        update.radios[0].volume     = (float)radio1.radioVolume.Value;
                        update.radios[0].modulation = 0;

                        update.radios[1]            = new RadioInformation();
                        update.radios[1].name       = "VHF";
                        update.radios[1].frequency  = Double.Parse(radio2.radioFrequency.Text) * MHZ;
                        update.radios[1].volume     = (float)radio2.radioVolume.Value;
                        update.radios[1].modulation = 0;

                        update.radios[2]            = new RadioInformation();
                        update.radios[2].name       = "FM";
                        update.radios[2].frequency  = Double.Parse(radio3.radioFrequency.Text) * MHZ;
                        update.radios[2].volume     = (float)radio3.radioVolume.Value;
                        update.radios[2].modulation = 1;

                        update.selected = selected;

                        sendUDPUpdate(update);
                    }));
                }
            });
        }