-
Notifications
You must be signed in to change notification settings - Fork 9
/
Satellite.cs
1066 lines (973 loc) · 36.9 KB
/
Satellite.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Collections.Generic;
using System.Globalization;
#if !PocketPC || DesignTime
using System.ComponentModel;
#endif
namespace GeoFramework.Gps
{
/// <summary>Represents information about a GPS satellite in orbit above Earth.</summary>
/// <remarks>
/// <para>GPS devices are able to isolate information about GPS satellites in orbit. Each
/// satellite's <see cref="Satellite.PseudorandomNumber">unique identifier</see>,
/// <see cref="Satellite.SignalToNoiseRatio">radio signal strength</see>,
/// <see cref="Satellite.Azimuth">azimuth</see> and
/// <see cref="Satellite.Elevation">elevation</see> are available once its
/// radio signal is detected.</para>
/// <para>Properties in this class are updated automatically as new information is
/// received from the GPS device.</para>
/// <para><img src="Satellite.jpg"/></para>
/// </remarks>
/// <seealso cref="SatelliteCollection">SatelliteCollection Class</seealso>
#if !PocketPC || DesignTime
[TypeConverter(typeof(ExpandableObjectConverter))]
#endif
public struct Satellite : IFormattable, IEquatable<Satellite>, IComparable<Satellite>
{
private int _PseudorandomNumber;
private Azimuth _Azimuth;
private Elevation _Elevation;
private SignalToNoiseRatio _SignalToNoiseRatio;
private bool _IsFixed;
private DateTime _LastSignalReceived;
#region Constructors
/// <summary>
/// Creates a new instance using the specified unique identifier.
/// </summary>
/// <param name="pseudorandomNumber"></param>
public Satellite(int pseudorandomNumber)
: this(pseudorandomNumber, Azimuth.Empty, Elevation.Empty, SignalToNoiseRatio.Empty, false)
{ }
/// <summary>
/// Creates a new instance using the specified unique identifier, location around the horizon, and elevation up from the horizon.
/// </summary>
/// <param name="pseudorandomNumber"></param>
/// <param name="azimuth"></param>
/// <param name="elevation"></param>
public Satellite(int pseudorandomNumber, Azimuth azimuth, Elevation elevation)
: this(pseudorandomNumber, azimuth, elevation, SignalToNoiseRatio.Empty, false)
{ }
/// <summary>
/// Creates a new instance using the specified unique identifier, location around the horizon, and elevation up from the horizon.
/// </summary>
/// <param name="pseudorandomNumber"></param>
/// <param name="azimuth"></param>
/// <param name="elevation"></param>
/// <param name="signalToNoiseRatio"></param>
public Satellite(int pseudorandomNumber, Azimuth azimuth, Elevation elevation, SignalToNoiseRatio signalToNoiseRatio)
: this(pseudorandomNumber, azimuth, elevation, signalToNoiseRatio, false)
{ }
/// <summary>
/// Creates a new instance using the specified unique identifier, location around the horizon, and elevation up from the horizon.
/// </summary>
/// <param name="pseudorandomNumber"></param>
/// <param name="azimuth"></param>
/// <param name="elevation"></param>
/// <param name="signalToNoiseRatio"></param>
/// <param name="isFixed"></param>
public Satellite(int pseudorandomNumber, Azimuth azimuth, Elevation elevation, SignalToNoiseRatio signalToNoiseRatio, bool isFixed)
{
_PseudorandomNumber = pseudorandomNumber;
_Azimuth = azimuth;
_Elevation = elevation;
_SignalToNoiseRatio = signalToNoiseRatio;
_IsFixed = isFixed;
_LastSignalReceived = DateTime.MinValue;
}
#endregion
#region Public Properties
/// <summary>Returns the unique identifier of the satellite.</summary>
#if !PocketPC
[Category("Data")]
[Description("Returns the unique identifier of the satellite.")]
[Browsable(true)]
[ParenthesizePropertyName(true)]
#endif
public int PseudorandomNumber
{
get
{
return _PseudorandomNumber;
}
}
/// <summary>
/// Returns the horizontal direction towards the satellite from the current location.
/// </summary>
#if !PocketPC
[Category("Location")]
[Description("Returns the horizontal direction towards the satellite from the current location.")]
[Browsable(true)]
#endif
public Azimuth Azimuth
{
get
{
return _Azimuth;
}
set
{
if (_Azimuth.Equals(value))
return;
_Azimuth = value;
}
}
/// <summary>
/// Returns the vertical direction towards the satellite from the current
/// location.
/// </summary>
#if !PocketPC
[Category("Location")]
[Description("Returns the vertical direction towards the satellite from the current location.")]
[Browsable(true)]
#endif
public Elevation Elevation
{
get
{
return _Elevation;
}
set
{
if (_Elevation.Equals(value))
return;
_Elevation = value;
}
}
/// <summary>
/// Returns the strength of the satellite's radio signal as it is being
/// received.
/// </summary>
#if !PocketPC
[Category("Radio Signal")]
[Description("Returns the strength of the satellite's radio signal as it is being received.")]
[Browsable(true)]
#endif
public SignalToNoiseRatio SignalToNoiseRatio
{
get
{
return _SignalToNoiseRatio;
}
set
{
if (_SignalToNoiseRatio.Equals(value))
return;
_SignalToNoiseRatio = value;
}
}
/// <summary>Returns the date and time that the satellite's signal was detected.</summary>
#if !PocketPC
[Category("Statistics")]
[Description("Returns the date and time that the satellite's signal was detected.")]
[Browsable(true)]
#endif
public DateTime LastSignalReceived
{
get
{
return _LastSignalReceived;
}
set
{
if (_LastSignalReceived.Equals(value))
return;
_LastSignalReceived = value;
}
}
/// <summary>
/// Returns whether the satellite's signal is being used to calculate the current
/// location.
/// </summary>
#if !PocketPC
[Category("Statistics")]
[Description("Returns whether the satellite's signal is being used to calculate the current location.")]
[Browsable(true)]
#endif
public bool IsFixed
{
get
{
return _IsFixed;
}
set
{
if (_IsFixed.Equals(value))
return;
_IsFixed = value;
}
}
/// <summary>Returns whether the satellite's signal is currently being detected.</summary>
#if !PocketPC
[Category("Statistics")]
[Description("Returns whether the satellite's signal is currently being detected.")]
[Browsable(true)]
#endif
public bool IsTracked
{
get
{
return !_SignalToNoiseRatio.IsEmpty;
}
}
/// <summary>Returns the amount of time elapsed since the signal was last received.</summary>
#if !PocketPC
[Category("Statistics")]
[Description("Returns whether the satellite's signal is currently being detected.")]
[Browsable(true)]
#endif
public TimeSpan SignalAge
{
get
{
return DateTime.Now.Subtract(_LastSignalReceived);
}
}
/// <summary>Returns whether the satellite's signal has recently been received.</summary>
#if !PocketPC
[Category("Statistics")]
[Description("Returns whether the satellite's signal has recently been received.")]
[Browsable(true)]
#endif
public bool IsActive
{
get
{
return _IsFixed || SignalAge.TotalSeconds < 10.0;
}
}
/// <summary>
/// Indicates whether the satellite is providing additional corrective
/// signals to increase precision.
/// </summary>
/// <remarks>This property will return a value of <strong>True</strong>
/// if the GPS satellite has been identified as a WAAS, EGNOS or MSAS satellite.
/// These satellites are geostationary (unlike typical NAVSTAR GPS satellites)
/// and re-broadcast correction signals from ground stations. When this property
/// is true, the GPS device has improved precision.</remarks>
#if !PocketPC
[Category("Behavior")]
[Description("Indicates whether the satellite is providing additional corrective signals to increase precision.")]
[Browsable(true)]
#endif
public bool IsDifferentialGpsSatellite
{
get
{
SatelliteClass satelliteClass = this.Class;
return satelliteClass.Equals(SatelliteClass.Waas)
|| satelliteClass.Equals(SatelliteClass.Egnos)
|| satelliteClass.Equals(SatelliteClass.Msas);
}
}
/// <summary>Returns the government project responsible for launching the satellite.</summary>
#if !PocketPC
[Category("Statistics")]
[Description("Returns the government project responsible for launching the satellite.")]
[Browsable(true)]
#endif
public SatelliteClass Class
{
get
{
switch (_PseudorandomNumber)
{
case 122:
case 134:
case 125:
case 135:
case 138:
case 35:
case 47:
case 48:
case 51:
return SatelliteClass.Waas;
case 120:
case 124:
case 126:
case 131:
case 33:
case 37:
case 39:
case 44:
return SatelliteClass.Egnos;
case 129:
case 137:
case 42:
case 50:
return SatelliteClass.Msas;
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
case 13:
case 14:
case 15:
case 16:
case 18:
case 19:
case 20:
case 21:
case 22:
case 23:
case 24:
case 25:
case 26:
case 27:
case 28:
case 29:
case 30:
case 31:
return SatelliteClass.Navstar;
default:
return SatelliteClass.Unknown;
}
}
}
/// <summary>Returns the atomic clock currently in service.</summary>
#if !PocketPC
[Category("Statistics")]
[Description("Returns the atomic clock currently in service.")]
[Browsable(true)]
#endif
public SatelliteAtomicClockType AtomicClockType
{
get
{
switch (_PseudorandomNumber)
{
/* Data was compiled from Wikipedia:
* http://en.wikipedia.org/wiki/List_of_GPS_satellite_launches
*/
case 24:
case 27:
case 09:
case 03:
case 10:
case 30:
case 08:
return SatelliteAtomicClockType.Cesium;
case 32:
case 25:
case 26:
case 05:
case 04:
case 06:
case 13:
case 11:
case 20:
case 28:
case 14:
case 18:
case 16:
case 21:
case 22:
case 19:
case 23:
case 02:
case 17:
case 31:
case 12:
case 15:
case 29:
case 07:
return SatelliteAtomicClockType.Rubidium;
default:
return SatelliteAtomicClockType.Unknown;
}
}
}
/// <summary>Returns the launch block of the satellite.</summary>
#if !PocketPC
[Category("Statistics")]
[Description("Returns the launch block of the satellite.")]
[Browsable(true)]
#endif
public SatelliteBlock Block
{
get
{
switch (_PseudorandomNumber)
{
/* Compiled via the US Military
* ftp://tycho.usno.navy.mil/pub/gps/gpsb1.txt
*/
case 32:
case 24:
case 25:
case 26:
case 27:
case 9:
case 5:
case 4:
case 6:
case 3:
case 10:
case 30:
case 08:
return SatelliteBlock.IIA;
case 13:
case 11:
case 20:
case 28:
case 14:
case 18:
case 16:
case 21:
case 22:
case 19:
case 23:
case 2:
case 17:
case 31:
case 12:
case 15:
case 29:
case 7:
return SatelliteBlock.IIR;
default:
return SatelliteBlock.Unknown;
}
}
}
/// <summary>Returns the date the satellite was placed into orbit.</summary>
#if !PocketPC
[Category("Statistics")]
[Description("Returns the date the satellite was placed into orbit.")]
[Browsable(true)]
#endif
public DateTime DateLaunched
{
get
{
/* Data was compiled from Wikipedia:
* http://en.wikipedia.org/wiki/List_of_GPS_satellite_launches
*/
switch (_PseudorandomNumber)
{
case 32:
return new DateTime(1990, 11, 26);
case 24:
return new DateTime(1991, 07, 04);
case 25:
return new DateTime(1992, 02, 23);
case 26:
return new DateTime(1992, 07, 07);
case 27:
return new DateTime(1992, 09, 09);
case 01:
return new DateTime(1992, 05, 13);
case 09:
return new DateTime(1993, 06, 26);
case 05:
return new DateTime(1993, 08, 30);
case 04:
return new DateTime(1993, 10, 28);
case 06:
return new DateTime(1994, 03, 10);
case 03:
return new DateTime(1996, 03, 28);
case 10:
return new DateTime(1996, 07, 16);
case 30:
return new DateTime(1996, 09, 12);
case 13:
return new DateTime(1997, 07, 23);
case 11:
return new DateTime(1999, 10, 07);
case 20:
return new DateTime(2000, 05, 11);
case 28:
return new DateTime(2000, 07, 16);
case 14:
return new DateTime(2000, 11, 10);
case 18:
return new DateTime(2001, 01, 30);
case 16:
return new DateTime(2003, 01, 29);
case 21:
return new DateTime(2003, 03, 31);
case 22:
return new DateTime(2003, 12, 21);
case 19:
return new DateTime(2004, 03, 20);
case 23:
return new DateTime(2004, 06, 23);
case 02:
return new DateTime(2004, 11, 06);
case 17:
return new DateTime(2005, 09, 26);
case 31:
return new DateTime(2006, 09, 25);
case 12:
return new DateTime(2006, 11, 17);
case 15:
return new DateTime(2007, 10, 17);
case 29:
return new DateTime(2007, 12, 20);
case 07:
return new DateTime(2008, 03, 15);
default:
return DateTime.MinValue;
}
}
}
/// <summary>Returns the date the satellite was placed into service.</summary>
#if !PocketPC
[Category("Statistics")]
[Description("Returns the date the satellite was placed into service.")]
[Browsable(true)]
#endif
public DateTime DateCommissioned
{
get
{
switch (_PseudorandomNumber)
{
/* Data was compiled from the US Military:
* ftp://tycho.usno.navy.mil/pub/gps/gpsb2.txt
*/
#region Temporarily offline or decommissioned
//case 17:
// return new DateTime(1990, 1, 6); DECOMMISSIONED
//case 18:
// return new DateTime(1990, 2, 14); DECOMMISSIONED
//case 19:
// return new DateTime(1989, 11, 23); DECOMMISSIONED
//case 20:
// return new DateTime(1990, 4, 18); DECOMMISSIONED
//case 21:
// return new DateTime(1990, 8, 22); DECOMMISSIONED
//case 22:
// return new DateTime(1993, 4, 4); DECOMMISSIONED
//case 23:
// return new DateTime(1990, 12, 10); DECOMMISSIONED
case 32:
return new DateTime(2008, 2, 26);
case 24:
return new DateTime(1991, 8, 30);
case 25:
return new DateTime(1992, 3, 24);
case 26:
return new DateTime(1992, 7, 23);
case 27:
return new DateTime(1992, 9, 30);
//case 28:
// return new DateTime(1992, 4, 25); DECOMMISSIONED
//case 29:
// return new DateTime(1993, 1, 5); DECOMMISSIONED
case 30:
return new DateTime(1996, 10, 1);
//case 31:
// return new DateTime(1993, 4, 13); DECOMMISSIONED
case 01:
return new DateTime(1992, 12, 11);
case 03:
return new DateTime(1996, 4, 9);
case 04:
return new DateTime(1993, 11, 22);
case 05:
return new DateTime(1993, 9, 28);
case 06:
return new DateTime(1994, 3, 28);
//case 07:
// return new DateTime(1993, 6, 12); DECOMMISSIONED
case 08:
return new DateTime(1997, 12, 18);
case 09:
return new DateTime(1993, 7, 21);
case 10:
return new DateTime(1996, 8, 15);
#endregion
#region Currently operational
case 14:
return new DateTime(2000, 12, 10);
case 13:
return new DateTime(1998, 1, 31);
case 28:
return new DateTime(2000, 8, 17);
case 21:
return new DateTime(2003, 4, 12);
case 11:
return new DateTime(2000, 1, 3);
case 22:
return new DateTime(2004, 1, 12);
case 07:
return new DateTime(2008, 3, 24);
case 20:
return new DateTime(2000, 1, 1);
case 31:
return new DateTime(2006, 10, 12);
case 17:
return new DateTime(2005, 12, 16);
case 18:
return new DateTime(2001, 2, 15);
case 15:
return new DateTime(2007, 10, 31);
case 16:
return new DateTime(2003, 2, 19);
case 29:
return new DateTime(2008, 1, 2);
case 12:
return new DateTime(2006, 12, 13);
case 19:
return new DateTime(2004, 4, 5);
case 23:
return new DateTime(2004, 7, 9);
case 02:
return new DateTime(2004, 11, 22);
#endregion
default:
return DateTime.MinValue;
}
}
}
/// <summary>Returns the date the satellite was removed from service.</summary>
#if !PocketPC
[Category("Statistics")]
[Description("Returns the date the satellite was removed from service.")]
[Browsable(true)]
#endif
public DateTime DateDecommissioned
{
get
{
switch (_PseudorandomNumber)
{
case 2:
return new DateTime(2004, 5, 12);
case 14:
return new DateTime(2000, 4, 14);
default:
return new DateTime(0);
}
}
}
/// <summary>Returns the friendly name of the satellite.</summary>
#if !PocketPC
[Category("Statistics")]
[Description("Returns the friendly name of the satellite.")]
[Browsable(true)]
[ParenthesizePropertyName(true)]
#endif
public string Name
{
get
{
/* Information was obtained from WikiPedia:
* http://en.wikipedia.org/wiki/List_of_GPS_satellite_launches
*/
switch (_PseudorandomNumber)
{
#region Standard NAVSTAR satellites
case 32:
return "Navstar 2A-01";
case 24:
return "Navstar 2A-02";
case 25:
return "Navstar 2A-03";
case 26:
return "Navstar 2A-05";
case 27:
return "Navstar 2A-06";
case 1:
return "Navstar 2A-11";
case 9:
return "Navstar 2A-12";
case 5:
return "Navstar 2A-13";
case 4:
return "Navstar 2A-14";
case 6:
return "Navstar 2A-15";
case 3:
return "Navstar 2A-16";
case 10:
return "Navstar 2A-17";
case 30:
return "Navstar 2A-18";
case 13:
return "Navstar 43";
case 11:
return "Navstar 46";
case 20:
return "Navstar 47";
case 28:
return "Navstar 48";
case 14:
return "Navstar 49";
case 18:
return "Navstar 50";
case 16:
return "Navstar 51";
case 21:
return "Navstar 52";
case 22:
return "Navstar 53";
case 19:
return "Navstar 54";
case 23:
return "Navstar 55";
case 2:
return "Navstar 56";
case 17:
return "Navstar 57";
case 31:
return "GPS 2R-15";
case 12:
return "Navstar 59";
case 15:
return "GPS 2R-17";
case 29:
return "GPS 2R-18";
case 7:
return "Navstar 62";
#endregion
#region Wide Area Augmentation System (WAAS)
/* http://en.wikipedia.org/wiki/WAAS */
case 35:
return "Atlantic Ocean Region-West (WAAS)";
case 51:
return "Anik F1R (WAAS)";
case 47:
return "Pacific Ocean Region (WAAS)";
case 48:
return "Galaxy 15 (WAAS)";
#endregion
#region EGNOS (European)
case 33:
return "Atlantic Ocean Region-East (EGNOS)";
case 37:
return "ARTEMIS (EGNOS)";
case 39:
return "Indian Ocean Region-West (EGNOS)";
case 44:
return "Indian Ocean Region-East (EGNOS)";
#endregion
#region MSAS (Japan)
case 42:
return "MTSAT-1";
case 50:
return "MTSAT-2";
#endregion
case 0:
// A placeholder for the SatellitSignalBar control that
// is displaying no satellites. Otherwise the control is
// not visible.
return "Unknown";
default:
return "New Satellite";
}
}
}
#endregion
#region Public Methods
public string ToString(string format)
{
return ToString(format, CultureInfo.CurrentCulture);
}
#endregion
#region Overrides
public override bool Equals(object obj)
{
if (obj is Satellite)
return Equals((Satellite)obj);
return false;
}
public override int GetHashCode()
{
return _PseudorandomNumber;
}
public override string ToString()
{
return ToString("g", CultureInfo.CurrentCulture);
}
#endregion
#region Static methods
/// <summary>
/// Returns the satellites in the specified in the list which are marked as fixed.
/// </summary>
/// <param name="satellites"></param>
/// <returns></returns>
public static List<Satellite> GetFixedSatellites(List<Satellite> satellites)
{
List<Satellite> results = new List<Satellite>();
for (int index = 0; index < satellites.Count; index++)
{
Satellite satellite = satellites[index];
if (satellite.IsFixed)
results.Add(satellite);
}
return results;
}
#endregion
#region IEquatable<Satellite> Members
public bool Equals(Satellite other)
{
return _PseudorandomNumber.Equals(other.PseudorandomNumber);
}
#endregion
#region IFormattable Members
public string ToString(string format, IFormatProvider formatProvider)
{
CultureInfo culture = (CultureInfo)formatProvider;
if (culture == null)
culture = CultureInfo.CurrentCulture;
if (format == null || format.Length == 0)
format = "G";
return Name + " (" + _PseudorandomNumber.ToString(format, formatProvider) + "): "
+ _Azimuth.ToString(format, formatProvider) + culture.TextInfo.ListSeparator + " "
+ _Elevation.ToString(format, formatProvider) + culture.TextInfo.ListSeparator + " "
+ _SignalToNoiseRatio.ToString(format, formatProvider);
}
#endregion
#region IComparable<Satellite> Members
public int CompareTo(Satellite other)
{
// Fixed satellites come first, then non-fixed satellites.
// Second, satellites are sorted by signal, strongest signal first.
if (_IsFixed && !other.IsFixed)
return 1;
if (!_IsFixed && other.IsFixed)
return -1;
return other.SignalToNoiseRatio.CompareTo(_SignalToNoiseRatio);
}
#endregion
}
/// <summary>
/// Represents information about a satellite when a satellite-related event is raised.
/// </summary>
/// <remarks>This object is used primarily by the <see cref="Satellite">Satellite</see>
/// class to provide notification when information such as <see cref="Satellite.Azimuth">azimuth</see>,
/// <see cref="Satellite.Elevation">elevation</see>, or <see cref="Satellite.SignalToNoiseRatio">radio signal strength</see>
/// has changed.</remarks>
/// <example>This example demonstrates how to use this class when raising an event.
/// <code lang="VB">
/// ' Start a new receiver
/// Dim MyReceiver As New Receiver()
/// ' Declare a new event
/// Dim MySatelliteEvent As EventHandler
/// ' Get a handle on the first satellite in the receiver's collection
/// Dim MySatellite As Satellite = MyReceiver.Satellites(0)
///
/// Sub Main()
/// ' Raise our custom event
/// RaiseEvent MySatelliteEvent(Me, New SatelliteEventArgs(MySatellite))
/// End Sub
/// </code>
/// <code lang="C#">
/// // Start a new receiver
/// Receiver MyReceiver = new Receiver();
/// // Declare a new event
/// EventHandler MySatelliteEvent;
/// // Create an Satellite of 90°
/// Satellite MySatellite = new Satellite(90);
///
/// void Main()
/// {
/// // Raise our custom event
/// MySatelliteEvent(this, New SatelliteEventArgs(MySatellite));
/// }
/// </code>
/// </example>
/// <seealso cref="Satellite">SatelliteCollection Class</seealso>
/// <seealso cref="Satellite.Azimuth">Azimuth Property (Satellite Class)</seealso>
/// <seealso cref="Satellite.Elevation">Elevation Property (Satellite Class)</seealso>
/// <seealso cref="Satellite.SignalToNoiseRatio">SignalToNoiseRatio Property (Satellite Class)</seealso>
public sealed class SatelliteEventArgs : EventArgs
{
private Satellite _Satellite;
/// <summary>
/// Creates a new instance.
/// </summary>
/// <param name="Satellite"></param>
public SatelliteEventArgs(Satellite satellite)
{
_Satellite = satellite;
}
/// <summary>
/// Indicates which satellite is the target of the event.
/// </summary>
/// <value>A <strong>Satellite</strong> object containing modified information.</value>
public Satellite Satellite
{
get
{
return _Satellite;
}
}
}
public sealed class SatelliteListEventArgs : EventArgs
{
private IList<Satellite> _satellites;
/// <summary>
/// Creates a new instance.
/// </summary>