@@ -362,24 +362,27 @@ private void ScannerThread()
362362 using ( HardwareManager . Open ( ) )
363363 {
364364 // Attach to the hardware itself
365- Hardware device = HardwareManager . OpenHardware ( Profile ) ;
365+ var device = HardwareManager . OpenHardware ( Profile ) ;
366+
367+ // Tell it that we only do a scan
368+ device . PrepareSourceScan ( ) ;
366369
367370 // Start loading location result list
368- foreach ( GroupLocation location in m_Locations )
371+ foreach ( var location in m_Locations )
369372 m_ScanResults . Add ( location . Clone ( ) ) ;
370373
371374 // Reset counters
372375 TotalLocations = m_Locations . Count ;
373376
374377 // Last successfull inversion
375- SpectrumInversions lastInversion = SpectrumInversions . On ;
378+ var lastInversion = SpectrumInversions . On ;
376379
377380 // Process all transponders
378381 for ( CurrentLocation = 0 ; CurrentLocation < m_Locations . Count ; )
379382 {
380383 // Get new and old
381- GroupLocation location = m_Locations [ CurrentLocation ] ;
382- GroupLocation newLocation = m_ScanResults [ CurrentLocation ] ;
384+ var location = m_Locations [ CurrentLocation ] ;
385+ var newLocation = m_ScanResults [ CurrentLocation ] ;
383386
384387 // Count
385388 ++ CurrentLocation ;
@@ -393,26 +396,27 @@ private void ScannerThread()
393396 return ;
394397
395398 // Allow NIT scan on...
396- List < SourceGroup > enableNIT = new List < SourceGroup > ( ) , foundInfo = new List < SourceGroup > ( ) ;
399+ var enableNIT = new List < SourceGroup > ( ) ;
400+ var foundInfo = new List < SourceGroup > ( ) ;
397401
398402 // Startup and load the groups from the configuration
399403 foreach ( SourceGroup group in location . Groups )
400404 enableNIT . Add ( group ) ;
401405
402406 // All we have to process
403- List < SourceGroup > process = new List < SourceGroup > ( enableNIT ) ;
407+ var process = new List < SourceGroup > ( enableNIT ) ;
404408
405409 // Allowed group type
406- Type groupType = ( process . Count > 0 ) ? process [ 0 ] . GetType ( ) : null ;
410+ var groupType = ( process . Count > 0 ) ? process [ 0 ] . GetType ( ) : null ;
407411
408412 // All we did so far
409- Dictionary < SourceGroup , bool > done = new Dictionary < SourceGroup , bool > ( ) ;
413+ var done = new HashSet < SourceGroup > ( ) ;
410414
411415 // Process all groups
412416 while ( process . Count > 0 )
413417 {
414418 // Take the first one
415- SourceGroup group = process [ 0 ] ;
419+ var group = process [ 0 ] ;
416420
417421 // Remove it
418422 process . RemoveAt ( 0 ) ;
@@ -424,18 +428,18 @@ private void ScannerThread()
424428 ++ CurrentLocationGroup ;
425429
426430 // Already done
427- if ( done . ContainsKey ( group ) )
431+ if ( done . Contains ( group ) )
428432 continue ;
429433
430434 // Found group information on equivalent group
431- if ( null != foundInfo . FirstOrDefault ( g => g . CompareTo ( group , true ) ) )
435+ if ( foundInfo . FirstOrDefault ( g => g . CompareTo ( group , true ) ) != null )
432436 continue ;
433437
434438 // Mark as done
435- done [ group ] = true ;
439+ done . Add ( group ) ;
436440
437441 // Check for external termination
438- if ( null == m_Worker )
442+ if ( m_Worker == null )
439443 return ;
440444
441445 // Not supported
@@ -449,10 +453,10 @@ private void ScannerThread()
449453 }
450454
451455 // Read the configuration
452- SourceGroupFilter filter = Profile . GetFilter ( group ) ;
456+ var filter = Profile . GetFilter ( group ) ;
453457
454458 // See if this should be skiped
455- if ( null != filter )
459+ if ( filter != null )
456460 if ( filter . ExcludeFromScan )
457461 {
458462 // Remember
@@ -467,7 +471,7 @@ private void ScannerThread()
467471 return ;
468472
469473 // See if we should process the NIT
470- bool checkNIT = enableNIT . Contains ( group ) ;
474+ var checkNIT = enableNIT . Contains ( group ) ;
471475
472476 // See if we should process
473477 if ( checkNIT || group . IsComplete )
@@ -476,16 +480,16 @@ private void ScannerThread()
476480 group = SourceGroup . FromString < SourceGroup > ( group . ToString ( ) ) ;
477481
478482 // Attach to the group
479- GroupInformation info = SelectGroup ( device , location , group , ref lastInversion ) ;
483+ var info = SelectGroup ( device , location , group , ref lastInversion ) ;
480484
481485 // Mark as done again - group may be updated for DVB-C and if unchanged this is simply a no-operation
482- done [ group ] = true ;
486+ done . Add ( group ) ;
483487
484488 // Read the configuration again - actually for DVB-C it may change
485489 filter = Profile . GetFilter ( group ) ;
486490
487491 // See if this should be skiped
488- if ( null != filter )
492+ if ( filter != null )
489493 if ( filter . ExcludeFromScan )
490494 {
491495 // Remember
@@ -496,32 +500,32 @@ private void ScannerThread()
496500 }
497501
498502 // Remember that we found a group information - transponder is not dead
499- if ( null != info )
503+ if ( info != null )
500504 foundInfo . Add ( group ) ;
501505
502506 // See if NIT update is allowed
503507 if ( checkNIT )
504- if ( null != info )
508+ if ( info != null )
505509 {
506510 // See if we are a cable group
507- CableGroup cableGroup = group as CableGroup ;
511+ var cableGroup = group as CableGroup ;
508512
509513 // Try load
510- LocationInformation nit = device . GetLocationInformation ( ) ;
511- if ( null != nit )
514+ var nit = device . GetLocationInformation ( ) ;
515+ if ( nit != null )
512516 foreach ( SourceGroup other in nit . Groups )
513517 if ( other . GetType ( ) == groupType )
514518 {
515519 // See if this is a cable group
516- CableGroup otherCable = other as CableGroup ;
520+ var otherCable = other as CableGroup ;
517521
518522 // Disable NIT scan on the group as is
519523 enableNIT . RemoveAll ( g => g . CompareTo ( other , true ) ) ;
520524 process . RemoveAll ( g => g . CompareTo ( other , true ) ) ;
521525
522526 // Set inversion
523- if ( null != otherCable )
524- if ( null != cableGroup )
527+ if ( otherCable != null )
528+ if ( cableGroup != null )
525529 {
526530 // Use same parameters
527531 otherCable . SpectrumInversion = cableGroup . SpectrumInversion ;
@@ -551,19 +555,19 @@ private void ScannerThread()
551555 newLocation . Groups . Add ( group ) ;
552556
553557 // Process this group
554- if ( null == info )
558+ if ( info == null )
555559 m_Protocol . Add ( new ProtocolRecord { Mode = ProtocolRecordMode . EmptyGroup , Location = location , Group = group } ) ;
556560 else
557- foreach ( SourceIdentifier source in info . Sources )
561+ foreach ( var source in info . Sources )
558562 {
559563 // Only stations
560- Station station = source as Station ;
561- if ( null == station )
564+ var station = source as Station ;
565+ if ( station == null )
562566 continue ;
563567
564568 // Attach to the filter
565- SourceModifier modifiers = Profile . GetFilter ( source ) ;
566- if ( null != modifiers )
569+ var modifiers = Profile . GetFilter ( source ) ;
570+ if ( modifiers != null )
567571 if ( modifiers . ExcludeFromScan )
568572 continue ;
569573 else
0 commit comments