/// <summary>
        /// Initialise a new instance of the SimulationDataProvider class.
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="tuningFrequency"></param>
        public SimulationDataProvider(string fileName, TuningFrequency tuningFrequency)
        {
            this.fileName = fileName;
            this.tuningFrequency = tuningFrequency;

            resourceMutex = new Mutex();
        }
 /// <summary>
 /// Generate a copy of this frequency.
 /// </summary>
 /// <returns>A new instance with the same properties as the old instance.</returns>
 protected void Clone(TuningFrequency newFrequency)
 {
     newFrequency.Frequency      = frequency;
     newFrequency.Provider       = provider;
     newFrequency.CollectionType = collectionType;
     newFrequency.OpenTVCode     = openTVCode;
 }
Beispiel #3
0
 /// <summary>
 /// Initialize a new instance of the TuningSpec class for a DVB satellite frequency.
 /// </summary>
 /// <param name="satellite">The satellite to tune to.</param>
 /// <param name="frequency">The frequency to tune to.</param>
 public TuningSpec(Satellite satellite, SatelliteFrequency frequency)
 {
     this.frequency = frequency;
     this.satellite = satellite;
     symbolRate = frequency.SymbolRate;
     fec = frequency.FEC;
     signalPolarization = frequency.Polarization;
     modulation = frequency.Modulation;
 }
        /// <summary>
        /// Compare another object with this one.
        /// </summary>
        /// <param name="obj">The other object.</param>
        /// <returns>True if the objects are equal; false otherwise.</returns>
        public override bool Equals(object obj)
        {
            TuningFrequency otherFrequency = obj as TuningFrequency;

            if (otherFrequency == null)
            {
                return(false);
            }

            return(EqualTo(otherFrequency));
        }
        /// <summary>
        /// Check if this instance is equal to another.
        /// </summary>
        /// <param name="frequency">The other instance.</param>
        /// <returns></returns>
        public override bool EqualTo(TuningFrequency frequency)
        {
            bool reply = base.EqualTo(frequency);

            if (!reply)
            {
                return(false);
            }

            return(((Satellite)Provider).EqualTo(((Satellite)(frequency.Provider))));
        }
        /// <summary>
        /// Compare another tuning frequency with this one.
        /// </summary>
        /// <param name="compareFrequency">The tuning frequency to be compared to.</param>
        /// <returns>0 if the frequencies are equal, -1 if this instance is less, +1 otherwise.</returns>
        public virtual int CompareTo(object compareFrequency)
        {
            TuningFrequency tuningFrequency = compareFrequency as TuningFrequency;

            if (tuningFrequency != null)
            {
                return(frequency.CompareTo(tuningFrequency.frequency));
            }
            else
            {
                throw (new ArgumentException("Object is not a TuningFrequency"));
            }
        }
Beispiel #7
0
        /// <summary>
        /// Add a new frequency.
        /// </summary>
        /// <param name="newFrequency">The frequency to be added.</param>
        public void AddFrequency(TuningFrequency newFrequency)
        {
            foreach (TuningFrequency oldFrequency in Frequencies)
            {
                if (oldFrequency.Frequency == newFrequency.Frequency)
                {
                    return;
                }

                if (oldFrequency.Frequency > newFrequency.Frequency)
                {
                    Frequencies.Insert(Frequencies.IndexOf(oldFrequency), newFrequency);
                    return;
                }
            }

            Frequencies.Add(newFrequency);
        }
        /// <summary>
        /// Check this frequency for equality with another.
        /// </summary>
        /// <param name="tuningFrequency">The other frequency.</param>
        /// <returns>True if the instances are equal; false otherwise.</returns>
        public virtual bool EqualTo(TuningFrequency tuningFrequency)
        {
            if (frequency != tuningFrequency.Frequency)
            {
                return(false);
            }

            if (provider != tuningFrequency.Provider)
            {
                return(false);
            }

            if (collectionType != tuningFrequency.CollectionType)
            {
                return(false);
            }

            return(true);
        }
        private static bool getStations(TuningFrequency frequency)
        {
            bool tuned = tuneFrequency(frequency);
            if (!tuned)
                return (false);

            FrequencyScanner frequencyScanner = new FrequencyScanner(graph);
            Collection<TVStation> stations = frequencyScanner.FindTVStations(frequency);

            if (stations != null)
            {
                Logger.Instance.Write("Found " + stations.Count + " stations on frequency " + frequency);
                int addedCount = 0;

                foreach (TVStation tvStation in stations)
                {
                    TVStation excludedStation = TVStation.FindExcludedStation(tvStation.OriginalNetworkID, tvStation.TransportStreamID, tvStation.ServiceID);
                    if (excludedStation == null)
                    {
                        if (tvStation.NextFollowingAvailable && tvStation.ScheduleAvailable)
                        {
                            bool added = TVStation.AddStation(tvStation);
                            if (added)
                            {
                                //allStations.Add(tvStation);
                                addedCount++;
                                Logger.Instance.Write("Included station: " + tvStation.FixedLengthName + " (" + tvStation.FullID + " Service type " + tvStation.ServiceType + ")");
                            }
                        }
                        else
                            Logger.Instance.Write("Excluded station: " + tvStation.FixedLengthName + " (" + tvStation.FullID + " Service type " + tvStation.ServiceType + ") No EPG data");
                    }
                    else
                        Logger.Instance.Write("Excluded station: " + tvStation.FixedLengthName + " (" + tvStation.FullID + " Service type " + tvStation.ServiceType + ")");
                }

                Logger.Instance.Write("Added " + addedCount + " stations for frequency " + frequency);
            }
            frequencyScanner = null;
            return (true);
        }
Beispiel #10
0
        /// <summary>
        /// Process a parameter file.
        /// </summary>
        /// <param name="fileName">The name of the file.</param>
        /// <returns>True if the parameters are valid; false otherwise.</returns>
        public int Process(string fileName)
        {
            FileStream fileStream = null;

            try { fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); }
            catch (IOException)
            {
                Logger.Instance.Write("Failed to open " + fileName);
                return (errorCodeNoFile);
            }

            int reply = errorCodeNoError;

            StreamReader streamReader = new StreamReader(fileStream);

            while (!streamReader.EndOfStream && reply == errorCodeNoError)
            {
                string line = streamReader.ReadLine();
                string processLine = line.Replace((char)0x09, ' ');
                processLine = processLine.Replace("\ufffd", "?");

                int commentIndex = processLine.LastIndexOf("//");
                if (commentIndex != -1)
                    processLine = processLine.Substring(0, commentIndex);

                char splitter = ':';
                if (processLine.IndexOf('=') != -1)
                    splitter = '=';

                string[] parts = processLine.Split(new char[] { splitter });
                if (parts.Length > 0)
                {
                    switch (parts[0].Trim().ToUpperInvariant())
                    {
                        case "OUTPUT":
                            Logger.Instance.Write("Processing ini parameter: " + line);
                            if (parts.Length > 2)
                                reply = processOutput(parts[1] + ":" + parts[2]);
                            else
                                reply = processOutput(parts[1]);
                            break;
                        case "TUNER":
                            Logger.Instance.Write("Processing ini parameter: " + line);
                            reply = processTuner(parts[1]);
                            break;
                        case "SATELLITE":
                            Logger.Instance.Write("Processing ini parameter: " + line);
                            reply = processSatellite(parts[1]);
                            break;
                        case "DISH":
                            Logger.Instance.Write("Processing ini parameter: " + line);
                            reply = processDish(parts[1]);
                            break;
                        case "FREQUENCY":
                            currentFrequency = null;
                            reply = processFrequency(parts[1]);
                            break;
                        case "SCANNINGFREQUENCY":
                            Logger.Instance.Write("Processing ini parameter: " + line);
                            reply = processFrequency(parts[1]);
                            break;
                        case "TIMEOUTS":
                            Logger.Instance.Write("Processing ini parameter: " + line);
                            reply = processTimeouts(parts[1]);
                            break;
                        case "STATION":
                            Logger.Instance.Write("Processing ini parameter: " + line);
                            reply = processStation(parts[1]);
                            break;
                        case "OPTION":
                            Logger.Instance.Write("Processing ini parameter: " + line);
                            reply = processOption(parts[1]);
                            break;
                        case "TRACE":
                            Logger.Instance.Write("Processing ini parameter: " + line);
                            reply = processTrace(parts[1]);
                            break;
                        case "DEBUG":
                            Logger.Instance.Write("Processing ini parameter: " + line);
                            reply = processDebug(parts[1]);
                            break;
                        case "LOCATION":
                            Logger.Instance.Write("Processing ini parameter: " + line);
                            reply = processLocation(parts[1]);
                            break;
                        case "LANGUAGE":
                        case "INPUTLANGUAGE":
                            Logger.Instance.Write("Processing ini parameter: " + line);
                            reply = processInputLanguage(parts[1]);
                            break;
                        case "OUTPUTLANGUAGE":
                            Logger.Instance.Write("Processing ini parameter: " + line);
                            reply = processOutputLanguage(parts[1]);
                            break;
                        case "TIMEZONE":
                            Logger.Instance.Write("Processing ini parameter: " + line);
                            reply = processTimeZone(parts[1]);
                            break;
                        case "TSFILE":
                            Logger.Instance.Write("Processing ini parameter: " + line);
                            if (parts.Length > 2)
                                reply = processTSFile(parts[1] + ":" + parts[2]);
                            else
                                reply = processTSFile(parts[1]);
                            break;
                        case "CHANNELS":
                            Logger.Instance.Write("Processing ini parameter: " + line);
                            reply = processChannel(parts[1]);
                            break;
                        case "DISEQC":
                            Logger.Instance.Write("Processing ini parameter: " + line);
                            reply = processDiseqc(parts[1]);
                            break;
                        case "CHARSET":
                            Logger.Instance.Write("Processing ini parameter: " + line);
                            reply = processCharSet(parts[1]);
                            break;
                        case "EITPID":
                            Logger.Instance.Write("Processing ini parameter: " + line);
                            reply = processEITPid(parts[1]);
                            break;
                        case "MHW1PIDS":
                            Logger.Instance.Write("Processing ini parameter: " + line);
                            reply = processMHW1Pids(parts[1]);
                            break;
                        case "MHW2PIDS":
                            Logger.Instance.Write("Processing ini parameter: " + line);
                            reply = processMHW2Pids(parts[1]);
                            break;
                        case "PLUGINFREQUENCY":
                            Logger.Instance.Write("Processing ini parameter: " + line);
                            reply = processPluginFrequency(parts[1]);
                            break;
                        case "[DVBS]":
                            Logger.Instance.Write("Processing ini parameter: " + line);
                            currentFrequency = new SatelliteFrequency();
                            break;
                        case "[DVBT]":
                            Logger.Instance.Write("Processing ini parameter: " + line);
                            currentFrequency = new TerrestrialFrequency();
                            break;
                        case "[DVBC]":
                            Logger.Instance.Write("Processing ini parameter: " + line);
                            currentFrequency = new CableFrequency();
                            break;
                        case "[ATSC]":
                            Logger.Instance.Write("Processing ini parameter: " + line);
                            currentFrequency = new AtscFrequency();
                            break;
                        case "[CLEARQAM]":
                            Logger.Instance.Write("Processing ini parameter: " + line);
                            currentFrequency = new ClearQamFrequency();
                            break;
                        case "[ISDBS]":
                            Logger.Instance.Write("Processing ini parameter: " + line);
                            currentFrequency = new ISDBSatelliteFrequency();
                            break;
                        case "[ISDBT]":
                            Logger.Instance.Write("Processing ini parameter: " + line);
                            currentFrequency = new ISDBTerrestrialFrequency();
                            break;
                        case "TUNINGFILE":
                            Logger.Instance.Write("Processing ini parameter: " + line);
                            reply = processTuningFile(parts[1]);
                            break;
                        case "SCANNED":
                            Logger.Instance.Write("Processing ini parameter: " + line);
                            reply = processScannedChannel(parts[1]);
                            break;
                        case "OFFSET":
                            Logger.Instance.Write("Processing ini parameter: " + line);
                            reply = processOffsetChannel(parts[1]);
                            break;
                        case "INCLUDESERVICE":
                            Logger.Instance.Write("Processing ini parameter: " + line);
                            reply = processIncludeService(parts[1]);
                            break;
                        case "MAXSERVICE":
                            Logger.Instance.Write("Processing ini parameter: " + line);
                            reply = processMaxService(parts[1]);
                            break;
                        case "REPEATEXCLUSION":
                            Logger.Instance.Write("Processing ini parameter: " + line);
                            reply = processRepeatExclusion(parts[1]);
                            break;
                        case "REPEATPHRASE":
                            Logger.Instance.Write("Processing ini parameter: " + line);
                            reply = processRepeatPhrase(parts[1]);
                            break;
                        case "WMCIMPORTNAME":
                            Logger.Instance.Write("Processing ini parameter: " + line);
                            reply = processWMCImportName(parts[1]);
                            break;
                        case "[GENERAL]":
                        case "[DIAGNOSTICS]":
                        case "[SCANLIST]":
                        case "[STATIONS]":
                        case "[OFFSETS]":
                        case "[SERVICEFILTERS]":
                        case "[REPEATEXCLUSIONS]":
                            Logger.Instance.Write("Processing ini parameter: " + line);
                            break;
                        default:
                            if (parts[0].Trim().ToUpperInvariant().StartsWith("SCANNED"))
                            {
                                Logger.Instance.Write("Processing ini parameter: " + line);
                                reply = processScannedChannel(parts[1]);
                            }
                            break;
                    }
                }
            }

            streamReader.Close();
            fileStream.Close();

            return (reply);
        }
Beispiel #11
0
        private int processTerrestrialFrequency(string[] parameters)
        {
            try
            {
                int frequency = Int32.Parse(parameters[0].Trim());
                int bandWidth = Int32.Parse(parameters[1].Trim());

                if (currentFrequency == null)
                {
                    currentFrequency = new TerrestrialFrequency();
                    currentFrequency.Provider = TerrestrialProvider.FindProvider(frequency, bandWidth);
                    if (currentFrequency.Provider == null)
                        currentFrequency.Provider = new TerrestrialProvider("Unknown");
                }

                TerrestrialFrequency terrestrialFrequency = currentFrequency as TerrestrialFrequency;
                terrestrialFrequency.Frequency = frequency;
                terrestrialFrequency.Bandwidth = bandWidth;
                int errorCode = getCollectionType(parameters[2].Trim().ToUpperInvariant(), terrestrialFrequency);
                if (errorCode != errorCodeNoError)
                    return (errorCode);

                TuningFrequency.FrequencyCollection.Add(terrestrialFrequency);
            }
            catch (FormatException)
            {
                Logger.Instance.Write("INI file format error: A Frequency line is wrong.");
                return (errorCodeFormatError);
            }
            catch (ArithmeticException)
            {
                Logger.Instance.Write("INI file format error: A Frequency line is wrong.");
                return (errorCodeFormatError);
            }

            return (errorCodeNoError);
        }
Beispiel #12
0
        private int getCollectionType(string parameter, TuningFrequency tuningFrequency)
        {
            switch (parameter)
            {
                case "N":
                case "EIT":
                    tuningFrequency.CollectionType = CollectionType.EIT;
                    break;
                case "Y":
                case "MHEG5":
                    tuningFrequency.CollectionType = CollectionType.MHEG5;
                    break;
                case "OPENTV":
                    tuningFrequency.CollectionType = CollectionType.OpenTV;
                    break;
                case "MHW1":
                case "MEDIAHIGHWAY1":
                    tuningFrequency.CollectionType = CollectionType.MediaHighway1;
                    break;
                case "MHW2":
                case "MEDIAHIGHWAY2":
                    tuningFrequency.CollectionType = CollectionType.MediaHighway2;
                    break;
                case "FREESAT":
                    tuningFrequency.CollectionType = CollectionType.FreeSat;
                    break;
                case "PSIP":
                    tuningFrequency.CollectionType = CollectionType.PSIP;
                    break;
                case "DISHNETWORK":
                    tuningFrequency.CollectionType = CollectionType.DishNetwork;
                    break;
                case "BELLTV":
                    tuningFrequency.CollectionType = CollectionType.BellTV;
                    break;
                case "SIEHFERNINFO":
                    tuningFrequency.CollectionType = CollectionType.SiehfernInfo;
                    break;
                default:
                    Logger.Instance.Write("INI file format error: The collection type on a Frequency line is wrong.");
                    return (errorCodeFormatError);
            }

            return (errorCodeNoError);
        }
Beispiel #13
0
 /// <summary>
 /// Initialize a new instance of the TuningSpec class for a DVB errestrial frequency.
 /// </summary>
 /// <param name="frequency">The terrestrial frequency to tune to.</param>
 public TuningSpec(TerrestrialFrequency frequency)
 {
     this.frequency = frequency;
      bandwidth = frequency.Bandwidth;
 }
Beispiel #14
0
        /// <summary>
        /// Check this frequency for equality with another.
        /// </summary>
        /// <param name="tuningFrequency">The other frequency.</param>
        /// <returns>True if the instances are equal; false otherwise.</returns>
        public virtual bool EqualTo(TuningFrequency tuningFrequency)
        {
            if (frequency != tuningFrequency.Frequency)
                return (false);

            if (provider != tuningFrequency.Provider)
                return (false);

            if (collectionType != tuningFrequency.CollectionType)
                return (false);

            return (true);
        }
Beispiel #15
0
        /// <summary>
        /// Start the collection process.
        /// </summary>
        /// <param name="dataProvider">A sample data provider.</param>
        /// <param name="tuningFrequency">The tuning frequency.</param>
        public void Run(ISampleDataProvider dataProvider, TuningFrequency tuningFrequency)
        {
            epgWorker = new BackgroundWorker();
            epgWorker.WorkerSupportsCancellation = true;
            epgWorker.DoWork += new DoWorkEventHandler(epgWorkerDoWork);
            epgWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(epgWorkerRunWorkerCompleted);
            epgWorker.RunWorkerAsync(new BackgroundParameters(dataProvider, tuningFrequency));

            running = true;
        }
Beispiel #16
0
        private void outputSatelliteFrequency(StreamWriter streamWriter, TuningFrequency tuningFrequency)
        {
            streamWriter.WriteLine();
            streamWriter.WriteLine("[DVBS]");

            streamWriter.WriteLine("Satellite=" + (tuningFrequency.Provider as Satellite).Longitude);

            SatelliteFrequency satelliteFrequency = tuningFrequency as SatelliteFrequency;

            if (satelliteFrequency.SatelliteDish.DiseqcSwitch != null)
                streamWriter.WriteLine("Dish=" + satelliteFrequency.SatelliteDish.LNBLowBandFrequency + "," +
                    satelliteFrequency.SatelliteDish.LNBHighBandFrequency + "," +
                    satelliteFrequency.SatelliteDish.LNBSwitchFrequency + "," +
                    satelliteFrequency.SatelliteDish.DiseqcSwitch);
            else
                streamWriter.WriteLine("Dish=" + satelliteFrequency.SatelliteDish.LNBLowBandFrequency + "," +
                    satelliteFrequency.SatelliteDish.LNBHighBandFrequency + "," +
                    satelliteFrequency.SatelliteDish.LNBSwitchFrequency);

            streamWriter.WriteLine("TuningFile=" + satelliteFrequency.Provider + ".xml");

            if (satelliteFrequency.Pilot == Pilot.NotSet && satelliteFrequency.RollOff == RollOff.NotSet)
            {
                streamWriter.WriteLine("ScanningFrequency=" + satelliteFrequency.Frequency + "," +
                    satelliteFrequency.SymbolRate + "," +
                    satelliteFrequency.FEC + "," +
                    satelliteFrequency.Polarization.PolarizationAbbreviation + "," +
                    satelliteFrequency.CollectionType);
            }
            else
            {
                streamWriter.WriteLine("ScanningFrequency=" + satelliteFrequency.Frequency + "," +
                    satelliteFrequency.SymbolRate + "," +
                    satelliteFrequency.FEC + "," +
                    satelliteFrequency.Polarization.PolarizationAbbreviation + "," +
                    satelliteFrequency.Pilot + "," +
                    satelliteFrequency.RollOff + "," +
                    satelliteFrequency.Modulation + "," +
                    satelliteFrequency.CollectionType);
            }
        }
Beispiel #17
0
 private void outputPluginFrequencyParameters(StreamWriter streamWriter, TuningFrequency tuningFrequency)
 {
     switch (tuningFrequency.TunerType)
     {
         case TunerType.Satellite:
             streamWriter.WriteLine("PluginFrequency=Satellite," + tuningFrequency.Provider.ToString().Replace(',', '+') + "," +
                 tuningFrequency.Frequency + "," + (tuningFrequency as SatelliteFrequency).Polarization.PolarizationAbbreviation + "," +
                 tuningFrequency.CollectionType);
             break;
         case TunerType.Terrestrial:
             streamWriter.WriteLine("PluginFrequency=Terrestrial," + (tuningFrequency.Provider) + "," +
                 tuningFrequency.Frequency + ",," + tuningFrequency.CollectionType);
             break;
         case TunerType.Cable:
             streamWriter.WriteLine("PluginFrequency=Cable," + (tuningFrequency.Provider) + "," +
                 tuningFrequency.Frequency + ",," + tuningFrequency.CollectionType);
             break;
         case TunerType.ATSC:
             streamWriter.WriteLine("PluginFrequency=ATSC," + (tuningFrequency.Provider) + "," +
                 tuningFrequency.Frequency + ",," + tuningFrequency.CollectionType);
             break;
         case TunerType.ClearQAM:
             streamWriter.WriteLine("PluginFrequency=ClearQAM," + (tuningFrequency.Provider) + "," +
                 tuningFrequency.Frequency + ",," + tuningFrequency.CollectionType);
             break;
         case TunerType.ISDBS:
             streamWriter.WriteLine("PluginFrequency=ISDBS," + (tuningFrequency.Provider) + "," +
                 tuningFrequency.Frequency + ",," + tuningFrequency.CollectionType);
             break;
         case TunerType.ISDBT:
             streamWriter.WriteLine("PluginFrequency=ISDBT," + (tuningFrequency.Provider) + "," +
                 tuningFrequency.Frequency + ",," + tuningFrequency.CollectionType);
             break;
         default:
             break;
     }
 }
Beispiel #18
0
        private void outputISDBSatelliteFrequency(StreamWriter streamWriter, TuningFrequency tuningFrequency)
        {
            streamWriter.WriteLine();
            streamWriter.WriteLine("[ISDBS]");

            streamWriter.WriteLine("Satellite=" + (tuningFrequency.Provider as Satellite).Longitude);

            ISDBSatelliteFrequency satelliteFrequency = tuningFrequency as ISDBSatelliteFrequency;

            if (satelliteFrequency.SatelliteDish.DiseqcSwitch != null)
                streamWriter.WriteLine("Dish=" + satelliteFrequency.SatelliteDish.LNBLowBandFrequency + "," +
                    satelliteFrequency.SatelliteDish.LNBHighBandFrequency + "," +
                    satelliteFrequency.SatelliteDish.LNBSwitchFrequency + "," +
                    satelliteFrequency.SatelliteDish.DiseqcSwitch);
            else
                streamWriter.WriteLine("Dish=" + satelliteFrequency.SatelliteDish.LNBLowBandFrequency + "," +
                    satelliteFrequency.SatelliteDish.LNBHighBandFrequency + "," +
                    satelliteFrequency.SatelliteDish.LNBSwitchFrequency);

            streamWriter.WriteLine("TuningFile=" + satelliteFrequency.Provider + ".xml");

            streamWriter.WriteLine("ScanningFrequency=" + satelliteFrequency.Frequency + "," +
                satelliteFrequency.SymbolRate + "," +
                satelliteFrequency.FEC + "," +
                satelliteFrequency.Polarization.PolarizationAbbreviation + "," +
                satelliteFrequency.CollectionType);
        }
Beispiel #19
0
 private void outputFrequencyParameters(StreamWriter streamWriter, TuningFrequency tuningFrequency)
 {
     switch (tuningFrequency.TunerType)
     {
         case TunerType.Satellite:
             outputSatelliteFrequency(streamWriter, tuningFrequency);
             break;
         case TunerType.Terrestrial:
             outputTerrestrialFrequency(streamWriter, tuningFrequency);
             break;
         case TunerType.Cable:
             outputCableFrequency(streamWriter, tuningFrequency);
             break;
         case TunerType.ATSC:
         case TunerType.ATSCCable:
             outputAtscFrequency(streamWriter, tuningFrequency);
             break;
         case TunerType.ClearQAM:
             outputClearQamFrequency(streamWriter, tuningFrequency);
             break;
         case TunerType.ISDBS:
             outputISDBSatelliteFrequency(streamWriter, tuningFrequency);
             break;
         case TunerType.ISDBT:
             outputISDBTerrestrialFrequency(streamWriter, tuningFrequency);
             break;
         default:
             break;
     }
 }
Beispiel #20
0
        private void outputClearQamFrequency(StreamWriter streamWriter, TuningFrequency tuningFrequency)
        {
            streamWriter.WriteLine();
            streamWriter.WriteLine("[CLEARQAM]");

            ClearQamFrequency clearQamFrequency = tuningFrequency as ClearQamFrequency;

            streamWriter.WriteLine("TuningFile=" + tuningFrequency.Provider + ".xml");

            streamWriter.WriteLine("ScanningFrequency=" + clearQamFrequency.Frequency + "," +
                clearQamFrequency.ChannelNumber + "," +
                clearQamFrequency.SymbolRate + "," +
                clearQamFrequency.FEC + "," +
                clearQamFrequency.Modulation + "," +
                clearQamFrequency.CollectionType);
        }
Beispiel #21
0
        private void outputCableFrequency(StreamWriter streamWriter, TuningFrequency tuningFrequency)
        {
            streamWriter.WriteLine();
            streamWriter.WriteLine("[DVBC]");

               CableFrequency cableFrequency = tuningFrequency as CableFrequency;

            streamWriter.WriteLine("TuningFile=" + tuningFrequency.Provider + ".xml");

            streamWriter.WriteLine("ScanningFrequency=" + cableFrequency.Frequency + "," +
                cableFrequency.SymbolRate + "," +
                cableFrequency.FEC + "," +
                cableFrequency.Modulation + "," +
                cableFrequency.CollectionType);
        }
Beispiel #22
0
        private void outputAtscFrequency(StreamWriter streamWriter, TuningFrequency tuningFrequency)
        {
            streamWriter.WriteLine();
            streamWriter.WriteLine("[ATSC]");

            AtscFrequency atscFrequency = tuningFrequency as AtscFrequency;

            streamWriter.WriteLine("TuningFile=" + tuningFrequency.Provider + ".xml");

            streamWriter.WriteLine("ScanningFrequency=" + atscFrequency.Frequency + "," +
                atscFrequency.ChannelNumber + "," +
                atscFrequency.SymbolRate + "," +
                atscFrequency.FEC + "," +
                atscFrequency.Modulation + "," +
                atscFrequency.CollectionType);
        }
Beispiel #23
0
 internal BackgroundParameters(ISampleDataProvider dataProvider, TuningFrequency tuningFrequency)
 {
     this.dataProvider = dataProvider;
     this.tuningFrequency = tuningFrequency;
 }
Beispiel #24
0
        private void outputTerrestrialFrequency(StreamWriter streamWriter, TuningFrequency tuningFrequency)
        {
            streamWriter.WriteLine();
            streamWriter.WriteLine("[DVBT]");

            TerrestrialFrequency terrestrialFrequency = tuningFrequency as TerrestrialFrequency;

            streamWriter.WriteLine("TuningFile=" + tuningFrequency.Provider + ".xml");

            streamWriter.WriteLine("ScanningFrequency=" + terrestrialFrequency.Frequency + "," +
                terrestrialFrequency.Bandwidth + "," +
                terrestrialFrequency.CollectionType);
        }
Beispiel #25
0
        private IEPGCollector getCollector(TuningFrequency frequency)
        {
            IEPGCollector collector;

            switch (frequency.CollectionType)
            {
                case CollectionType.EIT:
                    collector = new EITController();
                    Logger.Instance.Write("EPG delivery system is EIT on frequency " + frequency.Frequency);
                    break;
                case CollectionType.MHEG5:
                    collector = new DSMCCController();
                    Logger.Instance.Write("EPG delivery system is MHEG5 on frequency " + frequency.Frequency);
                    break;
                case CollectionType.OpenTV:
                    collector = new OpenTVController();
                    Logger.Instance.Write("EPG delivery system is OpenTV on frequency " + frequency.Frequency);
                    break;
                case CollectionType.MediaHighway1:
                    collector = new MediaHighway1Controller();
                    Logger.Instance.Write("EPG delivery system is MediaHighway1 on frequency " + frequency.Frequency);
                    break;
                case CollectionType.MediaHighway2:
                    collector = new MediaHighway2Controller();
                    Logger.Instance.Write("EPG delivery system is MediaHighway2 on frequency " + frequency.Frequency);
                    break;
                case CollectionType.FreeSat:
                    collector = new FreeSatController();
                    Logger.Instance.Write("EPG delivery system is FreeSat on frequency " + frequency.Frequency);
                    break;
                case CollectionType.PSIP:
                    collector = new AtscPsipController();
                    Logger.Instance.Write("EPG delivery system is ATSC PSIP on frequency " + frequency.Frequency);
                    break;
                case CollectionType.DishNetwork:
                    collector = new DishNetworkController();
                    Logger.Instance.Write("EPG delivery system is Dish Network on frequency " + frequency.Frequency);
                    break;
                case CollectionType.BellTV:
                    collector = new BellTVController();
                    Logger.Instance.Write("EPG delivery system is Bell TV on frequency " + frequency.Frequency);
                    break;
                case CollectionType.SiehfernInfo:
                    collector = new SiehFernInfoController();
                    Logger.Instance.Write("EPG delivery system is SiehFern Info on frequency " + frequency.Frequency);
                    break;
                default:
                    throw (new InvalidEnumArgumentException("CollectionType"));
            }

            addCollectorToList(collector);

            return (collector);
        }
Beispiel #26
0
 /// <summary>
 /// Initialize a new instance of the TuningSpec class for a DVB cable frequency.
 /// </summary>
 /// <param name="frequency">The frequency to tune to.</param>
 public TuningSpec(CableFrequency frequency)
 {
     this.frequency = frequency;
     symbolRate = frequency.SymbolRate;
     fec = frequency.FEC;
     modulation = frequency.Modulation;
 }
Beispiel #27
0
 /// <summary>
 /// Generate a copy of this frequency.
 /// </summary>
 /// <returns>A new instance with the same properties as the old instance.</returns>
 protected void Clone(TuningFrequency newFrequency)
 {
     newFrequency.Frequency = frequency;
     newFrequency.Provider = provider;
     newFrequency.CollectionType = collectionType;
     newFrequency.OpenTVCode = openTVCode;
 }
        /// <summary>
        /// Initialise a new instance of the PluginDataProvider class.
        /// </summary>
        /// <param name="tuningFrequency">The tuning frequency.</param>
        /// <param name="runReference">A unique reference for this run.</param>
        public PluginDataProvider(TuningFrequency tuningFrequency, string runReference)
        {
            this.tuningFrequency = tuningFrequency;

            resourceMutex = new Mutex(false, "DVBLogic Plugin Resource Mutex " + runReference);
        }
Beispiel #29
0
 /// <summary>
 /// Initialize a new instance of the TuningSpec class for a Clear QAM frequency.
 /// </summary>
 /// <param name="frequency">The frequency to tune to.</param>
 public TuningSpec(ClearQamFrequency frequency)
 {
     this.frequency = frequency;
     symbolRate = frequency.SymbolRate;
     fec = frequency.FEC;
     modulation = frequency.Modulation;
     channelNumber = frequency.ChannelNumber;
 }
Beispiel #30
0
        private int processSatelliteFrequency(string[] parameters)
        {
            if (parameters.Length != 5 && parameters.Length != 8)
            {
                Logger.Instance.Write("INI file format error: A Frequency line is wrong.");
                return (errorCodeFormatError);
            }

            try
            {
                int frequency = Int32.Parse(parameters[0].Trim());
                int symbolRate = Int32.Parse(parameters[1].Trim());
                FECRate fecRate = new FECRate(parameters[2]);
                SignalPolarization polarization = new SignalPolarization(parameters[3].Trim()[0]);

                Pilot pilot = Pilot.NotSet;
                RollOff rollOff = RollOff.NotSet;
                Modulation modulation = Modulation.QPSK;

                int nextParameter = 4;

                if (parameters.Length == 8)
                {
                    pilot = (Pilot)Enum.Parse(typeof(Pilot), parameters[4]);
                    rollOff = (RollOff)Enum.Parse(typeof(RollOff), parameters[5]);
                    modulation = (Modulation)Enum.Parse(typeof(Modulation), parameters[6]);
                    nextParameter = 7;
                }

                if (currentFrequency == null)
                    currentFrequency = new SatelliteFrequency();

                SatelliteFrequency satelliteFrequency = currentFrequency as SatelliteFrequency;

                satelliteFrequency.Frequency = frequency;
                satelliteFrequency.SymbolRate = symbolRate;
                satelliteFrequency.FEC = fecRate;
                satelliteFrequency.Polarization = polarization;
                satelliteFrequency.Pilot = pilot;
                satelliteFrequency.RollOff = rollOff;
                satelliteFrequency.Modulation = modulation;
                int errorCode = getCollectionType(parameters[nextParameter].Trim().ToUpperInvariant(), satelliteFrequency);
                if (errorCode != errorCodeNoError)
                    return (errorCode);

                satelliteFrequency.SatelliteDish = currentDish;

                if (currentFrequency.Provider == null)
                    currentFrequency.Provider = currentSatellite;

                TuningFrequency.FrequencyCollection.Add(satelliteFrequency);
            }
            catch (FormatException)
            {
                Logger.Instance.Write("INI file format error: A Frequency line is wrong.");
                return (errorCodeFormatError);
            }
            catch (ArithmeticException)
            {
                Logger.Instance.Write("INI file format error: A Frequency line is wrong.");
                return (errorCodeFormatError);
            }

            return (errorCodeNoError);
        }
Beispiel #31
0
        private int processCableFrequency(string[] parameters)
        {
            if (parameters.Length != 5)
            {
                Logger.Instance.Write("INI file format error: A Frequency line is wrong.");
                return (errorCodeFormatError);
            }

            try
            {
                int frequency = Int32.Parse(parameters[0].Trim());
                int symbolRate = Int32.Parse(parameters[1].Trim());
                FECRate fecRate = new FECRate(parameters[2]);
                Modulation modulation = (Modulation)Enum.Parse(typeof(Modulation), parameters[3].ToUpperInvariant(), true);

                if (currentFrequency == null)
                {
                    currentFrequency = new CableFrequency();
                    currentFrequency.Provider = CableProvider.FindProvider(frequency, symbolRate, fecRate, modulation);
                    if (currentFrequency.Provider == null)
                        currentFrequency.Provider = new CableProvider("Unknown");
                }

                CableFrequency cableFrequency = currentFrequency as CableFrequency;
                cableFrequency.Frequency = frequency;
                cableFrequency.SymbolRate = symbolRate;
                cableFrequency.FEC = fecRate;
                cableFrequency.Modulation = modulation;
                int errorCode = getCollectionType(parameters[4].Trim().ToUpperInvariant(), cableFrequency);
                if (errorCode != errorCodeNoError)
                    return (errorCode);

                TuningFrequency.FrequencyCollection.Add(cableFrequency);
            }
            catch (FormatException)
            {
                Logger.Instance.Write("INI file format error: A Frequency line is wrong.");
                return (errorCodeFormatError);
            }
            catch (ArithmeticException)
            {
                Logger.Instance.Write("INI file format error: A Frequency line is wrong.");
                return (errorCodeFormatError);
            }

            return (errorCodeNoError);
        }
Beispiel #32
0
        private void processServiceDescriptionSection(ServiceDescriptionSection serviceDescriptionSection, Collection<TVStation> tvStations, TuningFrequency frequency)
        {
            foreach (ServiceDescription serviceDescription in serviceDescriptionSection.ServiceDescriptions)
            {
                bool processStation = checkServiceInfo(serviceDescription);

                if (processStation)
                {
                    TVStation tvStation = new TVStation(serviceDescription.ServiceName);
                    tvStation.ProviderName = serviceDescription.ProviderName;
                    if (useActualFrequency)
                    {
                        tvStation.Frequency = NetworkInformationSection.GetFrequency(serviceDescriptionSection.OriginalNetworkID, serviceDescriptionSection.TransportStreamID) * 10;
                        if (tvStation.Frequency == 0)
                        {
                            tvStation.Frequency = frequency.Frequency;
                            Logger.Instance.Write("Station : " + tvStation.Name + " not found in Network Information Table");
                        }
                    }
                    else
                        tvStation.Frequency = frequency.Frequency;

                    tvStation.OriginalNetworkID = serviceDescriptionSection.OriginalNetworkID;
                    tvStation.TransportStreamID = serviceDescriptionSection.TransportStreamID;
                    tvStation.ServiceID = serviceDescription.ServiceID;
                    tvStation.Encrypted = serviceDescription.Scrambled;
                    tvStation.ServiceType = serviceDescription.ServiceType;
                    tvStation.ScheduleAvailable = serviceDescription.EITSchedule;
                    tvStation.NextFollowingAvailable = serviceDescription.EITPresentFollowing;

                    tvStation.TunerType = frequency.TunerType;
                    if (frequency.TunerType == TunerType.Satellite)
                    {
                        Satellite satellite = ((SatelliteFrequency)frequency).Provider as Satellite;
                        if (satellite != null)
                            tvStation.Satellite = satellite;
                    }

                    if (RunParameters.Instance.Options.Contains("USECHANNELID"))
                    {
                        if (serviceDescription.ChannelNumber != -1)
                            tvStation.OriginalChannelNumber = serviceDescription.ChannelNumber;
                    }

                    addStation(tvStations, tvStation);
                }
            }
        }
Beispiel #33
0
        private static bool tuneFrequency(TuningFrequency frequency)
        {
            Logger.Instance.Write("Tuning to frequency " + frequency.Frequency + " on " + frequency.TunerType);

            TuningSpec tuningSpec;
            TunerNodeType tunerNodeType;
            int frequencyRetries = 0;

            if (frequency.TunerType == TunerType.Satellite)
            {
                tuningSpec = new TuningSpec(Satellite.CurrentSatellite, (SatelliteFrequency)frequency);
                tunerNodeType = TunerNodeType.Satellite;
            }
            else if (frequency.TunerType == TunerType.Terrestrial)
            {
                tuningSpec = new TuningSpec((TerrestrialFrequency)frequency);
                tunerNodeType = TunerNodeType.Terrestrial;
            }
            else
            {
                tuningSpec = new TuningSpec((CableFrequency)frequency);
                tunerNodeType = TunerNodeType.Cable;
            }

            bool finished = false;

            while (!finished)
            {
                graph = BDAGraph.FindTuner(RunParameters.SelectedTuner, tunerNodeType, tuningSpec);
                if (graph == null)
                {
                    Logger.Instance.Write("Tuner not available");
                    return (false);
                }

                TimeSpan timeout = new TimeSpan();
                bool done = false;
                bool locked = false;

                if (RunParameters.Options.Contains("NOSIGLOCK"))
                {
                    Logger.Instance.Write("Option NOSIGLOCK: No lock check, wait 5 seconds instead");
                    locked = true;
                    Thread.Sleep(5000);
                }
                else
                {
                    while (!done)
                    {
                        if (cancelGraph)
                        {
                            graph.Dispose();
                            return (false);
                        }

                        locked = graph.SignalLocked;
                        if (!locked)
                        {
                            int signalQuality = graph.SignalQuality;
                            if (signalQuality > 0)
                            {
                                Logger.Instance.Write("Signal not locked but signal quality > 0");
                                locked = true;
                                done = true;
                            }
                            else
                            {
                                Logger.Instance.Write("Signal not locked and signal quality not > 0");
                                Thread.Sleep(1000);
                                timeout = timeout.Add(new TimeSpan(0, 0, 1));
                                done = (timeout.TotalSeconds == RunParameters.LockTimeout.TotalSeconds);
                            }
                        }
                        else
                            done = true;
                    }
                }

                if (!locked)
                {
                    Logger.Instance.Write("Failed to acquire signal");
                    graph.Dispose();

                    if (frequencyRetries == 1)
                        return (false);
                    else
                    {
                        frequencyRetries++;
                        Logger.Instance.Write("Retrying frequency");
                    }
                }
                else
                {
                    finished = true;
                    Logger.Instance.Write("Signal acquired: lock is " + graph.SignalLocked + " quality is " + graph.SignalQuality + " strength is " + graph.SignalStrength);
                }
            }

            return (true);
        }
Beispiel #34
0
        private int processISDBSatelliteFrequency(string[] parameters)
        {
            if (parameters.Length != 5)
            {
                Logger.Instance.Write("INI file format error: A Frequency line is wrong.");
                return (errorCodeFormatError);
            }

            try
            {
                int frequency = Int32.Parse(parameters[0].Trim());
                int symbolRate = Int32.Parse(parameters[1].Trim());
                FECRate fecRate = new FECRate(parameters[2]);
                SignalPolarization polarization = new SignalPolarization(parameters[3].Trim()[0]);

                if (currentFrequency == null)
                    currentFrequency = new ISDBSatelliteFrequency();

                ISDBSatelliteFrequency satelliteFrequency = currentFrequency as ISDBSatelliteFrequency;

                satelliteFrequency.Frequency = frequency;
                satelliteFrequency.SymbolRate = symbolRate;
                satelliteFrequency.FEC = fecRate;
                satelliteFrequency.Polarization = polarization;
                int errorCode = getCollectionType(parameters[4].Trim().ToUpperInvariant(), satelliteFrequency);
                if (errorCode != errorCodeNoError)
                    return (errorCode);

                satelliteFrequency.SatelliteDish = currentDish;

                if (currentFrequency.Provider == null)
                    currentFrequency.Provider = currentSatellite;

                TuningFrequency.FrequencyCollection.Add(satelliteFrequency);
            }
            catch (FormatException)
            {
                Logger.Instance.Write("INI file format error: A Frequency line is wrong.");
                return (errorCodeFormatError);
            }
            catch (ArithmeticException)
            {
                Logger.Instance.Write("INI file format error: A Frequency line is wrong.");
                return (errorCodeFormatError);
            }

            return (errorCodeNoError);
        }
        /// <summary>
        /// Check if this instance is equal to another.
        /// </summary>
        /// <param name="frequency">The other instance.</param>
        /// <returns></returns>
        public override bool EqualTo(TuningFrequency frequency)
        {
            bool reply = base.EqualTo(frequency);
            if (!reply)
                return (false);

            return (((Satellite)Provider).EqualTo(((Satellite)(frequency.Provider))));
        }
Beispiel #36
0
        private int processPluginFrequency(string parts)
        {
            string[] parameters = parts.Split(new char[] { ',' });
            if (parameters.Length != 5)
            {
                Logger.Instance.Write("INI file format error: A PluginFrequency line is wrong.");
                return (errorCodeFormatError);
            }

            switch (parameters[0])
            {
                case "Satellite":
                    pluginFrequency = new SatelliteFrequency();
                    break;
                case "Terrestrial":
                    pluginFrequency = new TerrestrialFrequency();
                    break;
                case "Cable":
                    pluginFrequency = new CableFrequency();
                    break;
                case "ATSC":
                    pluginFrequency = new AtscFrequency();
                    break;
                case "ISDBS":
                    pluginFrequency = new ISDBSatelliteFrequency();
                    break;
                case "ISDBT":
                    pluginFrequency = new ISDBTerrestrialFrequency();
                    break;
                default:
                    Logger.Instance.Write("INI file format error: A PluginFrequency line is wrong.");
                    return (errorCodeFormatError);
            }

            pluginFrequency.Provider = new Provider(parameters[1].Replace('+', ','));

            try
            {
                pluginFrequency.Frequency = Int32.Parse(parameters[2]);
                if (parameters[0] == "Satellite")
                    (pluginFrequency as SatelliteFrequency).Polarization = new SignalPolarization(parameters[3].Trim()[0]);
                return(getCollectionType(parameters[4].Trim().ToUpperInvariant(), pluginFrequency));
            }
            catch (FormatException)
            {
                Logger.Instance.Write("INI file format error: A PluginFrequency line is wrong.");
                return (errorCodeFormatError);
            }
            catch (ArithmeticException)
            {
                Logger.Instance.Write("INI file format error: A PluginFrequency line is wrong.");
                return (errorCodeFormatError);
            }
        }