private void ChannelMapGrid_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) { ChannelMapEntryWrapper entry_wrapper = channel_map_[e.RowIndex]; ChannelMapEntry entry = entry_wrapper.MapEntry; switch (ColumnIndexToEnum(e.ColumnIndex)) { case ColumnEnum.Number: e.Value = entry.Number; break; case ColumnEnum.Callsign: e.Value = entry.Callsign; break; case ColumnEnum.Physical: e.Value = entry.PhysicalChannel; break; case ColumnEnum.Status: e.Value = entry_wrapper.QAMStatus; break; case ColumnEnum.OTA: e.Value = entry_wrapper.ExistsAsOTA; break; case ColumnEnum.Listing: { List <Service> listings = entry_wrapper.listings; switch (listings.Count) { case 1: e.Value = listings[0]; break; case 0: e.Value = "None selected"; break; default: e.Value = "Multiple selected!!"; break; } } break; case ColumnEnum.Action: e.Value = entry_wrapper.selected_action; break; } }
static internal Dictionary <int, ChannelMapEntry> ParseXmlChannelMap(XmlDocument xml_channel_map) { Console.WriteLine("Parsing XML channel map"); Dictionary <int, ChannelMapEntry> channel_map = new Dictionary <int, ChannelMapEntry>(); XmlNodeList channel_nodes = xml_channel_map.SelectNodes("channels/channel"); foreach (XmlNode channel_node in channel_nodes) { string callsign = Encoding.UTF8.GetString( Convert.FromBase64String(channel_node.SelectSingleNode("name/text()").Value)); int number = int.Parse(channel_node.SelectSingleNode("number/text()").Value); string modulation_string = channel_node.SelectSingleNode("modulation/text()").Value; ModulationType modulation; switch (modulation_string) { case "QAM256": modulation = ModulationType.BDA_MOD_256QAM; break; case "QAM64": modulation = ModulationType.BDA_MOD_64QAM; break; case "8VSB": modulation = ModulationType.BDA_MOD_8VSB; break; default: modulation = ModulationType.BDA_MOD_MAX; break; } string physical_channel_string = channel_node.SelectSingleNode("eia/text()").Value; string[] physical_channel_parts = physical_channel_string.Split(new char[] { '.' }); ChannelNumber physical_channel = new ChannelNumber( int.Parse(physical_channel_parts[0]), int.Parse(physical_channel_parts[1])); ChannelMapEntry entry = new ChannelMapEntry(number, callsign, modulation, physical_channel); channel_map[number] = entry; } return(channel_map); }
internal static Dictionary<int, ChannelMapEntry> ParseXmlChannelMap(XmlDocument xml_channel_map) { Console.WriteLine("Parsing XML channel map"); Dictionary<int, ChannelMapEntry> channel_map = new Dictionary<int, ChannelMapEntry>(); XmlNodeList channel_nodes = xml_channel_map.SelectNodes("channels/channel"); foreach (XmlNode channel_node in channel_nodes) { string callsign = Encoding.UTF8.GetString( Convert.FromBase64String(channel_node.SelectSingleNode("name/text()").Value)); int number = int.Parse(channel_node.SelectSingleNode("number/text()").Value); string modulation_string = channel_node.SelectSingleNode("modulation/text()").Value; ModulationType modulation; switch (modulation_string) { case "QAM256": modulation = ModulationType.BDA_MOD_256QAM; break; case "QAM64": modulation = ModulationType.BDA_MOD_64QAM; break; case "8VSB": modulation = ModulationType.BDA_MOD_8VSB; break; default: modulation = ModulationType.BDA_MOD_MAX; break; } string physical_channel_string = channel_node.SelectSingleNode("eia/text()").Value; string[] physical_channel_parts = physical_channel_string.Split(new char[] { '.' }); ChannelNumber physical_channel = new ChannelNumber( int.Parse(physical_channel_parts[0]), int.Parse(physical_channel_parts[1])); ChannelMapEntry entry = new ChannelMapEntry(number, callsign, modulation, physical_channel); channel_map[number] = entry; } return channel_map; }
int IComparable.CompareTo(object obj) { ChannelMapEntry other_entry = (ChannelMapEntry)obj; return(number_.CompareTo(other_entry.number_)); }
private static bool QAMTuningInfoMatchesMapEntry(ChannelTuningInfo tuning_info, ChannelMapEntry entry) { return (entry.PhysicalChannel.Number == tuning_info.PhysicalNumber && entry.PhysicalChannel.SubNumber == tuning_info.SubNumber && entry.Modulation == tuning_info.ModulationType); }
private ChannelMapEntryWrapper(ChannelMapEntry entry) { channel_map_entry_ = entry; qam_status_ = DetermineQAMChannelStatus(entry, out exists_as_ota_); selected_action_ = CorrectiveAction.None; }
private static List<Channel> FindMatchingQAMChannels(ChannelMapEntry entry, Lineup qam_lineup) { // if the channel has an unsupported modulation, skip it. if (entry.HasUnsupportedModulation()) return new List<Channel>(); int key = ChannelNumberToInt(entry.PhysicalChannel.Number, entry.PhysicalChannel.SubNumber); if (qam_channels_by_num.ContainsKey(key)) { List<Channel> matching_channels = qam_channels_by_num[key]; // remove any where the modulation doesn't match. bool has_unmatched_modulation = false; foreach (Channel ch in matching_channels) { if (ch.TuningInfos == null || ch.TuningInfos.Empty || ((ChannelTuningInfo)ch.TuningInfos.First).ModulationType != entry.Modulation) { has_unmatched_modulation = true; break; } } if (!has_unmatched_modulation) return matching_channels; List<Channel> filtered_matching_channels = new List<Channel>(); foreach (Channel ch in matching_channels) if (ch.TuningInfos != null && !ch.TuningInfos.Empty && ((ChannelTuningInfo)ch.TuningInfos.First).ModulationType == entry.Modulation) { filtered_matching_channels.Add(ch); } return filtered_matching_channels; } return null; }
private static Channel FindCCardChannelForMapEntry(ChannelMapEntry entry, Lineup cablecard_lineup) { int key = ChannelNumberToInt(entry.Number, 0); if (ccard_channels_by_num.ContainsKey(key)) return ccard_channels_by_num[key].First(); return null; }
private static QAMChannelStatus DetermineQAMChannelStatus(ChannelMapEntry entry, out bool exists_as_ota) { exists_as_ota = false; Channel cablecard_channel = FindCCardChannelForMapEntry(entry, cablecard_lineup); List<Channel> matching_qam_channels = FindMatchingQAMChannels(entry, qam_lineup); List<MergedChannel> referencing_merged_channels = (null == cablecard_channel) ? null : ChannelEditing.GetReferencingMergedChannels(cablecard_channel); if (cablecard_channel != null && cablecard_channel.Service != null) exists_as_ota = ota_callsigns.Contains(cablecard_channel.Service.CallSign) || ota_callsigns.Contains(cablecard_channel.Service.CallSign + "DT"); if (null == cablecard_channel || referencing_merged_channels.Count == 0) { if (null == matching_qam_channels) { return QAMChannelStatus.NoCCChannelOrQAM; } else { return QAMChannelStatus.NoCCChannelWithQAM; } } // If we get here, the CableCARD channel at least exists. Check if it is merged with other CableCARD channels on // different QAM channels. If so, that needs to be fixed before ClearQAM channel state can be worried about. foreach (MergedChannel mc in referencing_merged_channels) { bool this_channel_first = false; foreach (TuningInfo ti in mc.TuningInfos) { ChannelTuningInfo cti = ti as ChannelTuningInfo; if (cti == null) continue; // skip any TuningInfos that are not ChannelTuningInfo if (IsTuningInfoOnCCardTuner(cti)) { int channel_number = cti.PhysicalNumber; if (ChannelMapParser.channel_map.ContainsKey(channel_number) && ChannelNumbersEquivalent(entry.PhysicalChannel, ChannelMapParser.channel_map[channel_number].PhysicalChannel)) { this_channel_first = true; } else { return (this_channel_first) ? QAMChannelStatus.ConflictingCCFirst : QAMChannelStatus.ConflictingCCNotFirst; } } } } if (null == matching_qam_channels) { foreach (MergedChannel mc in referencing_merged_channels) foreach (TuningInfo ti in mc.TuningInfos) { ChannelTuningInfo cti = ti as ChannelTuningInfo; if (cti == null) continue; // skip any TuningInfos that are not ChannelTuningInfo if (cti.Device == null) continue; // check for non-CableCARD tuning infos in the referencing merged channel if (!IsTuningInfoOnCCardTuner(cti)) return QAMChannelStatus.IncorrectQAM; } return (exists_as_ota) ? QAMChannelStatus.OTAOnly : QAMChannelStatus.NotExisting; } // if we get this far, both the cablecard and the QAM channel exist. Check to see if they are merged together. bool found_matching_qam = false; bool has_CCard_EIA_merged = false; foreach (MergedChannel mc in referencing_merged_channels) { foreach (TuningInfo ti in mc.TuningInfos) { // ignore WMI tuning infos or non-ChannelTuningInfos if (ti.Device == null) continue; ChannelTuningInfo channel_tuning_info = ti as ChannelTuningInfo; if (channel_tuning_info == null) continue; // skip any TuningInfos that are not ChannelTuningInfo if (IsTuningInfoOnCCardTuner(channel_tuning_info)) { if (channel_tuning_info.SubNumber != 0) has_CCard_EIA_merged = true; else continue; } else if (IsTuningInfoOnQAMTuner(channel_tuning_info)) { if (QAMTuningInfoMatchesMapEntry(channel_tuning_info, entry)) { found_matching_qam = true; } else { // If there is a non-matching channel merged, that takes priority over whether the // matching QAM channel is also there. return QAMChannelStatus.IncorrectQAM; } } else { // unknown tuner type - ignore for now } } } if (found_matching_qam) { return (has_CCard_EIA_merged) ? QAMChannelStatus.ProperlyMergedWithExtraneousCCard : QAMChannelStatus.ProperlyMerged; } // QAM and CCard channels both exist, but are not merged together. Check if the QAM channel is merged // with another CableCARD channel. List<MergedChannel> qam_merged_channels = new List<MergedChannel>(); foreach (Channel ch in matching_qam_channels) { qam_merged_channels.AddRange(ChannelEditing.GetReferencingMergedChannels(ch)); } foreach (MergedChannel mc in qam_merged_channels) { foreach (TuningInfo ti in mc.TuningInfos) { ChannelTuningInfo cti = ti as ChannelTuningInfo; if (cti == null) continue; // skip any TuningInfos that are not ChannelTuningInfo if (IsTuningInfoOnCCardTuner(cti)) return QAMChannelStatus.ExistingDupeCCard; } } return QAMChannelStatus.ExistingUnmerged; }
public static ChannelMapEntryWrapper CreateOrGetWrapperForEntry(ChannelMapEntry entry) { int number = entry.Number; if (wrappers_by_num_.ContainsKey(number)) { ChannelMapEntryWrapper wrapper = wrappers_by_num_[number]; if (!entry.Equals(wrapper.MapEntry)) throw new Exception("Conflicting channel map entry already exists!"); return wrapper; } else { ChannelMapEntryWrapper wrapper = new ChannelMapEntryWrapper(entry); wrappers_by_num_.Add(number, wrapper); int qam_key = ChannelNumberToInt(entry.PhysicalChannel); if (!wrappers_by_qam_key_.ContainsKey(qam_key)) { wrappers_by_qam_key_.Add(qam_key, new List<ChannelMapEntryWrapper>()); } wrappers_by_qam_key_[qam_key].Add(wrapper); return wrapper; } }