Esempio n. 1
0
        protected override void OnOpen()
        {
            base.OnOpen();
            Logger.Instance.Log($"WebSocket Client Connected! ");

            string[] split = Context.RequestUri.AbsolutePath.Split('/');
            int      _id   = Convert.ToInt32(split[split.Length - 1]);

            if (split[split.Length - 2] == "room")
            {
                BaseRoom _room = RoomsController.GetRoomsList().FirstOrDefault(room => room.roomId == _id);
                if (_room != null)
                {
                    _room.OnOpenWebSocket();
                }
            }
            else if (split[split.Length - 2] == "channel")
            {
                RadioChannel _channel = RadioController.radioChannels.FirstOrDefault(channel => channel.channelId == _id);
                if (_channel != null)
                {
                    _channel.OnOpenWebSocket();
                }
            }
        }
Esempio n. 2
0
        public async Task StopRadio(params string[] _)
        {
            if (Context.Guild == null)
            {
                await ReplyAsync(Base.Sentences.CommandDontPm(Context.Guild));

                return;
            }
            Utilities.CheckAvailability(Context.Guild, Program.Module.Radio);
            await p.DoAction(Context.User, Program.Module.Radio);

            RadioChannel radio = p.radios.Find(x => x.m_guildId == Context.Guild.Id);

            if (radio == null)
            {
                await ReplyAsync(Sentences.RadioNotStarted(Context.Guild));
            }
            else
            {
                await radio.Stop();

                p.radios.Remove(radio);
                await ReplyAsync(Base.Sentences.DoneStr(Context.Guild));
            }
        }
        private IEnumerable <RadioChannel> ManuallyScanForChannels(RadioChannel channelStart, RadioChannel channelStop)
        {
            try
            {
                Log.DebugFormat("Starting manual Crazyradio USB dongle ChannelScan. StartChannel: {0}, StopChannel: {1}.", channelStart, channelStop);

                var results = new List <RadioChannel>();

                var ackPacket = new byte[] { 0xFF };
                for (var currentChannel = channelStart; currentChannel <= channelStop; currentChannel++)
                {
                    Channel = currentChannel;
                    var result = SendData(ackPacket);
                }

                Log.Debug("Manual Crazyradio USB dongle ChannelScan completed.");

                return(results);
            }
            catch (Exception ex)
            {
                var message = string.Format("Failed running manual Crazyradio USB dongle channel scan. Start Channel: {0}, Stop Channel: {1}.", channelStart, channelStop);
                Log.Error(message);
                throw new CrazyradioDriverException(message, ex);
            }
        }
Esempio n. 4
0
        public async Task AddRadio(params string[] words)
        {
            Utilities.CheckAvailability(Context.Guild.Id, Program.Module.Radio);
            await p.DoAction(Context.User, Context.Guild.Id, Program.Module.Radio);

            if (p.youtubeService == null)
            {
                await ReplyAsync(Base.Sentences.NoApiKey(Context.Guild.Id));
            }
            else
            if (words.Length == 0)
            {
                await ReplyAsync(Sentences.RadioNeedArg(Context.Guild.Id));
            }
            else if (p.radios.Any(x => x.m_guildId == Context.Guild.Id) && !p.radios.Find(x => x.m_guildId == Context.Guild.Id).CanAddMusic())
            {
                await ReplyAsync(Sentences.RadioTooMany(Context.Guild.Id));
            }
            else
            {
                if (!p.radios.Any(x => x.m_guildId == Context.Guild.Id))
                {
                    if (!await StartRadio(Context.Channel))
                    {
                        return;
                    }
                }
                var result = await Features.Entertainment.YouTube.SearchYouTube(words, Program.p.youtubeService);

                if (result.error == Features.Entertainment.Error.YouTube.None)
                {
                    RadioChannel radio = p.radios.Find(x => x.m_guildId == Context.Guild.Id);
                    if (radio.ContainMusic(result.answer.url))
                    {
                        await ReplyAsync(Sentences.RadioAlreadyInList(Context.Guild.Id));

                        return;
                    }
                    await ReplyAsync(Sentences.SongAdded(Context.Guild.Id, result.answer.name));

                    string fileName = "Saves/Radio/" + radio.m_guildId + "/" + Utilities.CleanWord(result.answer.name) + ".mp3";
                    radio.AddMusic(fileName, result.answer.name, result.answer.url, result.answer.imageUrl, Context.User.ToString());
                    ProcessStartInfo youtubeDownload = new ProcessStartInfo()
                    {
                        FileName       = "youtube-dl",
                        Arguments      = $"-x --audio-format mp3 -o " + fileName + " " + result.answer.url,
                        CreateNoWindow = true
                    };
                    youtubeDownload.WindowStyle = ProcessWindowStyle.Hidden;
                    Process.Start(youtubeDownload).WaitForExit();
                    radio.StopDownloading(result.answer.url);
                    await radio.Play();
                }
                else
                {
                    await ReplyAsync("YouTube error: " + result.error);
                }
            }
        }
Esempio n. 5
0
 public static void AddChannel(RadioChannel channel)
 {
     if (Server != null && Settings.Instance.Server.EnableWebSocketRoomInfo)
     {
         Server.AddWebSocketService <Broadcast>($"/channel/{channel.channelId}");
         BroadcastState();
     }
 }
Esempio n. 6
0
        // We remove the bot from empty voice channels
        private async Task VoiceUpdate(SocketUser user, SocketVoiceState state, SocketVoiceState _)
        {
            RadioChannel radio = radios.Find(x => x.m_guildId == ((IGuildUser)user).GuildId);

            if (radio != null && await radio.IsChanEmpty())
            {
                await radio.Stop();

                radios.Remove(radio);
            }
        }
Esempio n. 7
0
        public async Task RemoveRadio(params string[] args)
        {
            if (Context.Guild == null)
            {
                await ReplyAsync(Base.Sentences.CommandDontPm(Context.Guild));

                return;
            }
            Utilities.CheckAvailability(Context.Guild, Program.Module.Radio);
            await p.DoAction(Context.User, Program.Module.Radio);

            RadioChannel radio = p.radios.Find(x => x.m_guildId == Context.Guild.Id);

            if (radio == null)
            {
                await ReplyAsync(Sentences.RadioNotStarted(Context.Guild));
            }
            else
            {
                string title = string.Join(" ", args);
                if (await radio.RemoveSong(Context.Channel, title))
                {
                    await ReplyAsync(Base.Sentences.DoneStr(Context.Guild));
                }
                else
                {
                    List <int> indexs = new List <int>();
                    foreach (var str in args)
                    {
                        if (int.TryParse(str, out int res))
                        {
                            if (!indexs.Contains(res))
                            {
                                indexs.Add(res);
                            }
                        }
                        else
                        {
                            indexs = null;
                            break;
                        }
                    }
                    if (indexs == null || !await radio.RemoveSong(Context.Channel, indexs))
                    {
                        await ReplyAsync(Sentences.InvalidSong(Context.Guild));
                    }
                    else
                    {
                        await ReplyAsync(Base.Sentences.DoneStr(Context.Guild));
                    }
                }
            }
        }
Esempio n. 8
0
        public IEnumerable <ScanChannelsResult> ScanChannels(RadioChannel channelStart = RadioChannel.Channel1, RadioChannel channelStop = RadioChannel.Channel125)
        {
            if (channelStop < channelStart)
            {
                const string message = "Stop channel must be a higher channel number than start channel.";
                Log.Error(message);
                throw new ArgumentException(message);
            }

            Log.DebugFormat("Attemping to scan channels in range. StartChannel: {0}, StopChannel: {1}.", channelStart, channelStop);

            var channelBackup  = Channel;
            var dataRateBackup = DataRate;

            var results = new List <ScanChannelsResult>();

            var results250Kps = ScanChannelsUsingDataRate(RadioDataRate.DataRate250Kps, channelStart, channelStop);

            if (results250Kps.Channels.Any())
            {
                results.Add(results250Kps);
            }

            var results1Mps = ScanChannelsUsingDataRate(RadioDataRate.DataRate1Mps, channelStart, channelStop);

            if (results1Mps.Channels.Any())
            {
                results.Add(results1Mps);
            }

            var results2Mps = ScanChannelsUsingDataRate(RadioDataRate.DataRate2Mps, channelStart, channelStop);

            if (results2Mps.Channels.Any())
            {
                results.Add(results2Mps);
            }

            Log.DebugFormat("Results of scanning channels in range. Found: {0}. StartChannel: {1}, StopChannel: {2}.", results.Count(), channelStart, channelStop);
            Log.Debug("Reverting data rate and channel to original values.");

            if (channelBackup != null)
            {
                Channel = channelBackup;
            }
            if (dataRateBackup != null)
            {
                DataRate = dataRateBackup;
            }

            return(results);
        }
            public RCONChannelInfo(string _path)
            {
                string[] split = _path.Split('/');
                int      _id   = Convert.ToInt32(split[split.Length - 1]);

                RadioChannel _channel = RadioController.radioChannels.First(x => x.channelId == _id);

                channelId   = _channel.channelInfo.channelId;
                name        = _channel.channelInfo.name;
                icon        = _channel.channelInfo.iconUrl;
                difficulty  = _channel.channelInfo.currentLevelOptions.difficulty.ToString();
                currentSong = _channel.channelInfo.currentSong == null ? "NULL" : _channel.channelInfo.currentSong.songName;
                queueLength = _channel.radioQueue.Count;
            }
Esempio n. 10
0
        private RadioChannel GetRadioChannel(string name, bool create)
        {
            RadioChannel radioChannel;

            lock (_radioChannels)
            {
                radioChannel = _radioChannels.FirstOrDefault(r => r.Name == name);
                if (radioChannel == null && create)
                {
                    radioChannel = new RadioChannel(name);
                    _radioChannels.Add(radioChannel);
                }
            }

            return(radioChannel);
        }
Esempio n. 11
0
        public async Task addRadio(params string[] words)
        {
            p.doAction(Context.User, Context.Guild.Id, Program.Module.Radio);
            if (words.Length == 0)
            {
                await ReplyAsync(Sentences.radioNeedArg(Context.Guild.Id));
            }
            else if (p.radios.Any(x => x.m_guildId == Context.Guild.Id) && !p.radios.Find(x => x.m_guildId == Context.Guild.Id).CanAddMusic())
            {
                await ReplyAsync(Sentences.radioTooMany(Context.Guild.Id));
            }
            else
            {
                if (!p.radios.Any(x => x.m_guildId == Context.Guild.Id))
                {
                    if (!await StartRadio(Context.Channel))
                    {
                        return;
                    }
                }
                Tuple <string, string> youtubeResult = await YoutubeModule.GetYoutubeVideo(words, Context.Channel);

                if (youtubeResult != null)
                {
                    RadioChannel radio = p.radios.Find(x => x.m_guildId == Context.Guild.Id);
                    if (radio.ContainMusic(youtubeResult.Item1))
                    {
                        await ReplyAsync(Sentences.radioAlreadyInList(Context.Guild.Id));

                        return;
                    }
                    radio.AddMusic("Saves/Radio/" + radio.m_guildId + "/" + Program.cleanWord(youtubeResult.Item2) + ".mp3", youtubeResult.Item2, youtubeResult.Item1, await Context.Guild.GetUserAsync(Sentences.myId), Context.Guild.Id.ToString());
                    YouTubeVideo video = GetYoutubeVideo(youtubeResult.Item1);
                    if (video == null)
                    {
                        radio.RemoveSong(youtubeResult.Item1);
                        await ReplyAsync(Sentences.cantDownload(Context.Guild.Id));
                    }
                    else
                    {
                        await ReplyAsync(youtubeResult.Item2 + " was added to the list.");

                        DownloadAudio(video, radio, youtubeResult.Item1, Program.cleanWord(youtubeResult.Item2));
                    }
                }
            }
        }
Esempio n. 12
0
        private void StartRadioScanningChannels(RadioChannel channelStart, RadioChannel channelStop)
        {
            try
            {
                Log.DebugFormat("Starting firmware level channel scan. StartChannel: {0}, StopChannel: {1}.", channelStart, channelStop);

                ControlTransferOut(CrazyradioRequest.ScanChannels, (short)channelStart, (short)channelStop, 1, new byte[] { 0xFF });

                Log.DebugFormat("Successfully started firmware level channel scan. StartChannel: {0}, StopChannel: {1}.", channelStart, channelStop);
            }
            catch (Exception ex)
            {
                var message = string.Format("Failed starting firmware level channel scan. Start Channel: {0}, Stop Channel: {1}.", channelStart, channelStop);
                Log.Error(message);
                throw new CrazyradioDriverException(message, ex);
            }
        }
        public void AddNewRadioChannel()
        {
            var channel = new RadioChannel
            {
                ChannelName = string.Empty,
            };

            var channelViewModel = new ChannelViewModel {
                RadioChannel = channel, DialogService = dialogService
            };

            if (dialogService.ShowDialog(channelViewModel) == true)
            {
                RadioChannels.Add(channel);
                SaveRadioChannels();
            }
        }
        private void SetChannel(RadioChannel channel)
        {
            try
            {
                Log.DebugFormat("Setting Crazyradio USB dongle Channel to {0}.", channel);

                ControlTransferOut(CrazyradioRequest.SetChannel, (short)channel, 0, 0, new byte[0]);

                Log.DebugFormat("Successfully set Crazyradio USB dongle Channel to {0}.", channel);
            }
            catch (Exception ex)
            {
                var message = string.Format("Failed setting Crazyradio USB dongle channel to {0}.", channel);
                Log.Error(message);
                throw new CrazyradioDriverException(message, ex);
            }
        }
Esempio n. 15
0
        public async Task stopRadio(params string[] words)
        {
            p.doAction(Context.User, Context.Guild.Id, Program.Module.Radio);
            RadioChannel radio = p.radios.Find(x => x.m_guildId == Context.Guild.Id);

            if (radio == null)
            {
                await ReplyAsync(Sentences.radioNotStarted(Context.Guild.Id));
            }
            else
            {
                await radio.Stop();

                p.radios.Remove(radio);
                await ReplyAsync(Sentences.doneStr(Context.Guild.Id));
            }
        }
        private ScanChannelsResult ScanChannelsUsingDataRate(RadioDataRate dataRate, RadioChannel channelStart, RadioChannel channelStop)
        {
            var results = new List <RadioChannel>();

            DataRate = dataRate;

            if (FirmwareVersion.CompareTo(MinimumCrazyradioFastFirmwareChannelScanFirmware) >= 0)
            {
                StartRadioScanningChannels(channelStart, channelStop);
                results.AddRange(GetRadioChannelScanningResults());
            }
            else             // slow pc level channel scan
            {
                results.AddRange(ManuallyScanForChannels(channelStart, channelStop));
            }

            return(new ScanChannelsResult(dataRate, results));
        }
Esempio n. 17
0
        private void DownloadAudio(YouTubeVideo video, RadioChannel radio, string url, string title)
        {
            File.WriteAllBytes("Saves/Radio/" + radio.m_guildId + "/" + title + "." + video.FileExtension, video.GetBytes());
            MediaFile inputFile = new MediaFile {
                Filename = "Saves/Radio/" + radio.m_guildId + "/" + title + "." + video.FileExtension
            };
            MediaFile outputFile = new MediaFile {
                Filename = "Saves/Radio/" + radio.m_guildId + "/" + title + ".mp3"
            };

            using (Engine engine = new Engine())
            {
                engine.Convert(inputFile, outputFile);
            }
            radio.StopDownloading(url);
            File.Delete("Saves/Radio/" + radio.m_guildId + "/" + title + "." + video.FileExtension);
            radio.Play();
        }
Esempio n. 18
0
        private IEnumerable <RadioChannel> ManuallyScanForChannels(RadioChannel channelStart, RadioChannel channelStop)
        {
            try
            {
                Log.DebugFormat("Starting manual channel scan. StartChannel: {0}, StopChannel: {1}.", channelStart, channelStop);

                var results = new List <RadioChannel>();

                var ping = new byte[] { 0xFF };
                for (var currentChannel = channelStart; currentChannel <= channelStop; currentChannel++)
                {
                    Channel = currentChannel;

                    Log.DebugFormat("Sending data {0} on channel data {1}.", BitConverter.ToString(ping), currentChannel);
                    var ack = SendData(ping);
                    Log.DebugFormat("Received data {0} on channel {1}.", BitConverter.ToString(ping), currentChannel);

                    if (ack != null && ack.Length > 0)
                    {
                        var ackReceivedBytes = (byte)(ack[0] & 0x01);
                        var ackReceived      = Convert.ToBoolean(ackReceivedBytes);

                        Log.DebugFormat("AckReceived? {0} (Bytes: {1}) on channel {2}.", ackReceived, BitConverter.ToString(new[] { ackReceivedBytes }), currentChannel);

                        if (ackReceived)
                        {
                            Log.DebugFormat("Adding channel {0} to results.", currentChannel);
                            results.Add(currentChannel);
                        }
                    }
                }

                Log.DebugFormat("Manual channel scan completed with {0} results. StartChannel: {1}, StopChannel: {2}.", results, channelStart, channelStop);

                return(results);
            }
            catch (Exception ex)
            {
                var message = string.Format("Failed running manual Crazyradio channel scan. Start Channel: {0}, Stop Channel: {1}.", channelStart, channelStop);
                Log.Error(message);
                throw new CrazyradioDriverException(message, ex);
            }
        }
Esempio n. 19
0
        public override bool Equals(object obj)
        {
            if (obj is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, obj))
            {
                return(true);
            }
            if (obj.GetType() != GetType())
            {
                return(false);
            }

            RadioChannel other = (RadioChannel)obj;

            return(Id == other.Id && Url == other.Url);
        }
Esempio n. 20
0
        public async Task skipRadio(params string[] words)
        {
            p.doAction(Context.User, Context.Guild.Id, Program.Module.Radio);
            RadioChannel radio = p.radios.Find(x => x.m_guildId == Context.Guild.Id);

            if (radio == null)
            {
                await ReplyAsync(Sentences.radioNotStarted(Context.Guild.Id));
            }
            else
            {
                bool suceed = await radio.Skip(Context.Channel);

                if (!suceed)
                {
                    await ReplyAsync(Sentences.radioNoSong(Context.Guild.Id));
                }
            }
        }
Esempio n. 21
0
 // Use this for initialization
 void Awake()
 {
     if (customSongs == null)
     {
         customSongs = GameObject.FindWithTag("GameController").GetComponent <CustomSongs>();
     }
     mixer = (AudioMixer)Resources.Load("AudioMixer");
     //radioChannels[0] = new RadioChannel(1, 0.2f, channelSounds[0].clips);
     //radioChannels[1] = new RadioChannel(2, 0.2f, channelSounds[1].clips);
     radioChannels[0]          = new RadioChannel(1, 0.2f, radioStatic);
     radioChannels[1]          = new RadioChannel(2, 0.2f, radioStatic);
     radioChannels[2]          = new RadioChannel(3, 0.2f, radioStatic);
     radioChannels[3]          = new RadioChannel(4, 0.2f, radioStatic, true);
     radioChannels[4]          = new RadioChannel(5, 0.2f, radioStatic, true);
     radioChannels[1].messages = channelSounds[1].clips;
     radioChannels[2].messages = channelSounds[2].clips;
     radioChannels[3].messages = channelSounds[3].clips;
     radioChannels[4].messages = channelSounds[4].clips;
     radioText.text            = currentChannel.ToString();
     StartCoroutine(setSounds());
 }
Esempio n. 22
0
    public void PlayChannel(int index)
    {
        if (Channels.Count == 0)
        {
            return;
        }

        int i = index % (Channels.Count == 0 ? 1 : Channels.Count);

        if (i < 0)
        {
            i += Channels.Count;
        }

        Pause();

        currentChannelIndex = i;
        CurrentChannel      = Channels[currentChannelIndex];

        Resume();
    }
Esempio n. 23
0
    void Start()
    {
        Instance = this;

        if (Channels == null)
        {
            Channels = new List <RadioChannel>();
        }
        IsPlaying = false;

        //Channels.Insert(0, RadioChannel.NoChannel);
        if (Channels.Count > 0)
        {
            CurrentChannel = Channels[0];
        }
        currentChannelIndex = 0;

        foreach (RadioChannel channel in Channels)
        {
            channel.AudioSource = AudioSource;
            channel.Reset();
        }
    }
Esempio n. 24
0
    IEnumerator cycleClips(RadioChannel channel)
    {
        if (radioIsPlaying)
        {
            StartCoroutine(degradeBattery());
            yield return(new WaitForSeconds((channel.channelSounds.clip.length - channel.channelSounds.time) + channel.WaitBwClipsDuration));

            if (radioIsPlaying)
            {
                if (!channel.isCommsChannel)
                {
                    if (channel.currentTrack == channel.messages.Length - 1)
                    {
                        channel.currentTrack = 0;
                    }
                    else
                    {
                        channel.currentTrack++;
                    }
                    channel.channelSounds.clip = channel.messages[channel.currentTrack];
                    channel.channelSounds.Play();
                }
                else
                {
                    if (!channel.commsActive)
                    {
                        if (channel.channelSounds.clip != channel.idleSound)
                        {
                            channel.channelSounds.clip = channel.idleSound;
                        }
                        channel.channelSounds.Play();
                    }
                }
                StartCoroutine(cycleClips(channel));
            }
        }
    }
Esempio n. 25
0
        public async Task <List <RadioChannel> > GetRadioChannels()
        {
            var channels = new List <RadioChannel>();

            using (var httpClient = new HttpClient())
            {
                var response = await httpClient.GetAsync(baseUrl + "channels");

                if (response.IsSuccessStatusCode)
                {
                    XDocument xmlresponse = XDocument.Parse(response.Content.ReadAsStringAsync().Result);
                    foreach (var item in xmlresponse.Descendants("channel"))
                    {
                        var channel = new RadioChannel()
                        {
                            Name = (string)item.Attribute("name"),
                            Id   = (string)item.Attribute("id")
                        };
                        channels.Add(channel);
                    }
                }
            }
            return(channels);
        }
Esempio n. 26
0
        public ScanChannelsResult ScanChannels(RadioDataRate dataRate, RadioChannel channelStart = RadioChannel.Channel0, RadioChannel channelStop = RadioChannel.Channel125)
        {
            if (channelStart > channelStop)
            {
                const string message = "Stop channel must be a higher channel number than start channel.";
                Log.Error(message);
                throw new ArgumentException(message);
            }

            var channelBackup  = Channel;
            var dataRateBackup = DataRate;

            Log.DebugFormat("About to scan channels for data rate in channel range. StartChannel: {0}, StopChannel: {1}, DataRate: {2}.", channelStart, channelStop);

            var result = ScanChannelsUsingDataRate(dataRate, channelStart, channelStop);

            Log.DebugFormat("Results of scanning channels for data rate in range. Found: {0}. StartChannel: {1}, StopChannel: {2}, DataRate: {3}.", result.Channels.Count(), channelStart, channelStop, dataRate);
            Log.Debug("Reverting data rate and channel to original values.");

            Channel  = channelBackup;
            DataRate = dataRateBackup;

            return(result);
        }
        public IEnumerable<ScanChannelsResult> ScanChannels(RadioChannel channelStart = RadioChannel.Channel1, RadioChannel channelStop = RadioChannel.Channel125)
        {
            if (channelStop < channelStart)
            {
                const string message = "Stop channel must be a higher channel number than start channel.";
                Log.Error(message);
                throw new ArgumentException(message);
            }

            Log.DebugFormat("Attemping to scan channels in range. StartChannel: {0}, StopChannel: {1}.", channelStart, channelStop);

            var channelBackup = Channel;
            var dataRateBackup = DataRate;

            var results = new List<ScanChannelsResult>();

            var results250Kps = ScanChannelsUsingDataRate(RadioDataRate.DataRate250Kps, channelStart, channelStop);
            if (results250Kps.Channels.Any())
            {
                results.Add(results250Kps);
            }

            var results1Mps = ScanChannelsUsingDataRate(RadioDataRate.DataRate1Mps, channelStart, channelStop);
            if (results1Mps.Channels.Any())
            {
                results.Add(results250Kps);
            }

            var results2Mps = ScanChannelsUsingDataRate(RadioDataRate.DataRate2Mps, channelStart, channelStop);
            if (results2Mps.Channels.Any())
            {
                results.Add(results250Kps);
            }

            Log.DebugFormat("Results of scanning channels in range. Found: {0}. StartChannel: {1}, StopChannel: {2}.", results.Count(), channelStart, channelStop);
            Log.Debug("Reverting data rate and channel to original values.");

            Channel = channelBackup;
            DataRate = dataRateBackup;

            return results;
        }
        private IEnumerable<RadioChannel> ManuallyScanForChannels(RadioChannel channelStart, RadioChannel channelStop)
        {
            try
            {
                Log.DebugFormat("Starting manual Crazyradio USB dongle ChannelScan. StartChannel: {0}, StopChannel: {1}.", channelStart, channelStop);

                var results = new List<RadioChannel>();

                var ackPacket = new byte[] {0xFF};
                for (var currentChannel = channelStart; currentChannel <= channelStop; currentChannel++)
                {
                    Channel = currentChannel;
                    var result = SendData(ackPacket);
                }

                Log.Debug("Manual Crazyradio USB dongle ChannelScan completed.");

                return results;
            }
            catch (Exception ex)
            {
                var message = string.Format("Failed running manual Crazyradio USB dongle channel scan. Start Channel: {0}, Stop Channel: {1}.", channelStart, channelStop);
                Log.Error(message);
                throw new CrazyradioDriverException(message, ex);
            }
        }
        private ScanChannelsResult ScanChannelsUsingDataRate(RadioDataRate dataRate, RadioChannel channelStart, RadioChannel channelStop)
        {
            var results = new List<RadioChannel>();

            DataRate = dataRate;

            if (FirmwareVersion.CompareTo(MinimumCrazyradioFastFirmwareChannelScanFirmware) >= 0)
            {
                StartRadioScanningChannels(channelStart, channelStop);
                results.AddRange(GetRadioChannelScanningResults());
            }
            else // slow pc level channel scan
            {
                results.AddRange(ManuallyScanForChannels(channelStart, channelStop));
            }

            return new ScanChannelsResult(dataRate, results);
        }
        private void SetChannel(RadioChannel channel)
        {
            try
            {
                Log.DebugFormat("Setting Crazyradio USB dongle Channel to {0}.", channel);

                ControlTransferOut(CrazyradioRequest.SetChannel, (short) channel, 0, 0, new byte[0]);

                Log.DebugFormat("Successfully set Crazyradio USB dongle Channel to {0}.", channel);
            }
            catch (Exception ex)
            {
                var message = string.Format("Failed setting Crazyradio USB dongle channel to {0}.", channel);
                Log.Error(message);
                throw new CrazyradioDriverException(message, ex);
            }
        }
        public bool ReadAllRadioChannels(out IList<RadioChannel> allradiochannels)
        {
            allradiochannels = new List<RadioChannel>();

            try
            {
                IList<WebChannelGroup> radioGroups = TvServer(_server_index).GetRadioGroups();

                foreach (WebChannelGroup mychannelgroup in radioGroups)
                {
                    if (mychannelgroup.GroupName.ToLower() == "all channels")
                    {
                        IList<WebChannelBasic> allradchannels = TvServer(_server_index).GetRadioChannelsBasic(mychannelgroup.Id);

                        foreach (WebChannelBasic mychannel in allradchannels)
                        {
                            RadioChannel item = new RadioChannel();
                            item.Id = mychannel.Id;
                            item.Name = mychannel.Title;
                            allradiochannels.Add(item);
                        }
                        return true;
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message);
            }
            return false;
        }
        public bool ReadAllRadioChannelsByGroup(int groupId, out IList<RadioChannel> allradiochannels)
        {
            allradiochannels = new List<RadioChannel>();

            try
            {
                IList<WebChannelBasic> allradchannels = TvServer(_server_index).GetRadioChannelsBasic(groupId);

                

                foreach (WebChannelBasic mychannel in allradchannels)
                {
                    RadioChannel item = new RadioChannel();
                    item.Id = mychannel.Id;
                    item.Name = mychannel.Title;
                    allradiochannels.Add(item);
                }
                return true;

            }
            catch (Exception ex)
            {
                Log.Error(ex.Message);
            }
            return false;
        }
Esempio n. 33
0
 public void AddChannel(RadioChannel channel)
 {
     Channels.Add(channel);
 }
        public ScanChannelsResult ScanChannels(RadioDataRate dataRate, RadioChannel channelStart = RadioChannel.Channel1, RadioChannel channelStop = RadioChannel.Channel125)
        {
            if (channelStart < channelStop)
            {
                const string message = "Stop channel must be a higher channel number than start channel.";
                Log.Error(message);
                throw new ArgumentException(message);
            }

            var channelBackup = Channel;
            var dataRateBackup = DataRate;

            Log.DebugFormat("About to scan channels for data rate in channel range. StartChannel: {0}, StopChannel: {1}, DataRate: {2}.", channelStart, channelStop);

            var result = ScanChannelsUsingDataRate(dataRate, channelStart, channelStop);

            Log.DebugFormat("Results of scanning channels for data rate in range. Found: {0}. StartChannel: {1}, StopChannel: {2}, DataRate: {3}.", result.Channels.Count(), channelStart, channelStop, dataRate);
            Log.Debug("Reverting data rate and channel to original values.");

            Channel = channelBackup;
            DataRate = dataRateBackup;

            return result;
        }
Esempio n. 35
0
 public RadioChannelViewModel()
 {
     Channel = new RadioChannel();
 }
Esempio n. 36
0
 public RadioChannelViewModel(RadioChannel rc)
 {
     Channel = rc;
 }
        private void StartRadioScanningChannels(RadioChannel channelStart, RadioChannel channelStop)
        {
            try
            {
                Log.DebugFormat("Starting firmware level Crazyradio USB dongle ChannelScan. StartChannel: {0}, StopChannel: {1}.", channelStart, channelStop);

                ControlTransferOut(CrazyradioRequest.ScanChannels, (short) channelStart, (short) channelStop, 1, new byte[] {0xFF});

                Log.DebugFormat("Successfully started firmware level Crazyradio USB dongle ChannelScan. StartChannel: {0}, StopChannel: {1}.", channelStart, channelStop);
            }
            catch (Exception ex)
            {
                var message = string.Format("Failed starting firmware level Crazyradio USB dongle channel scan. Start Channel: {0}, Stop Channel: {1}.", channelStart, channelStop);
                Log.Error(message);
                throw new CrazyradioDriverException(message, ex);
            }
        }
Esempio n. 38
0
 internal RadioChannelMember(RadioChannel radioChannel, VoiceClient voiceClient, bool isPrimary)
 {
     RadioChannel = radioChannel;
     VoiceClient  = voiceClient;
     IsPrimary    = isPrimary;
 }
 public bool ReadAllRadioChannelsByGroup(int groupid, out IList<IRadioChannel> allRadioChannels)
 {
     allRadioChannels = new List<IRadioChannel>();
     try
     {
         string response = string.Empty;
         string command = PipeCommands.ReadAllRadioChannels.ToString() + groupid.ToString();
         Log.Debug("command=" + command);
         response = PipeClient.Instance.RunSingleCommand(command);
         Log.Debug("response=" + response);
         string[] allRadioChannelsString = response.Split('\n');
         for (int i = 0; i < (allRadioChannelsString.Length-1) / 2; i++)
         {
             RadioChannel myRadiochannel = new RadioChannel();
             myRadiochannel.Id = int.Parse(allRadioChannelsString[2*i]);
             myRadiochannel.Name = allRadioChannelsString[2*i + 1];
             allRadioChannels.Add(myRadiochannel);
         }
     }
     catch (Exception exc)
     {
         Log.Debug("***Error ReadAllRadioChannelsByGroup: Exception=" + exc.Message);
         return false;
     }
     return true;
 }