-
Notifications
You must be signed in to change notification settings - Fork 3
/
Driver.cs
3487 lines (2885 loc) · 139 KB
/
Driver.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
//tabs=4
// --------------------------------------------------------------------------------
// TODO fill in this information for your driver, then remove this line!
//
// ASCOM Driver for Vixen Starbook
//
// Description: Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam
// nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam
// erat, sed diam voluptua. At vero eos et accusam et justo duo
// dolores et ea rebum. Stet clita kasd gubergren, no sea takimata
// sanctus est Lorem ipsum dolor sit amet.
//
// Implements: ASCOM Telescope interface version: <To be completed by driver developer>
// Author: (XXX) Your N. Here <your@email.here>
//
// Edit Log:
//
// Date Who Vers Description
// ----------- --- ----- -------------------------------------------------------
// dd-mmm-yyyy XXX 6.0.0 Initial edit, created from ASCOM driver template
// --------------------------------------------------------------------------------
//
// This is used to define code in the template that is specific to one class implementation
// unused code canbe deleted and this definition removed.
#define Telescope
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Net;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using ASCOM;
using ASCOM.Astrometry;
using ASCOM.Astrometry.AstroUtils;
using ASCOM.DeviceInterface;
using ASCOM.Utilities;
namespace ASCOM.Starbook
{
//
// Your driver's DeviceID is ASCOM.Starbook.Telescope
//
// The Guid attribute sets the CLSID for ASCOM.Starbook.Telescope
// The ClassInterface/None addribute prevents an empty interface called
// _Starbook from being created and used as the [default] interface
//
// TODO Replace the not implemented exceptions with code to implement the function or
// throw the appropriate ASCOM exception.
//
/// <summary>
/// ASCOM Telescope Driver for Starbook.
/// </summary>
[Guid("f83d3c07-d114-4a3d-a15c-09295d08d638")]
[ClassInterface(ClassInterfaceType.None)]
public partial class Telescope : ITelescopeV3
{
/// <summary>
/// ASCOM DeviceID (COM ProgID) for this driver.
/// The DeviceID is used by ASCOM applications to load the driver at runtime.
/// </summary>
internal static string driverID = "ASCOM.Starbook.Telescope";
// TODO Change the descriptive string for your driver then remove this line
/// <summary>
/// Driver description that displays in the ASCOM Chooser.
/// </summary>
private static string driverDescription = "Starbook";
internal static string ipAddressProfileName = "IPAddress"; // Constants used for Profile persistence
internal static IPAddress ipAddressDefault = new IPAddress(new byte[] { 169, 254, 1, 1 });
internal static int pollDefault = 100;
internal static string pollProfileName = "Poll";
internal static int timeoutDefault = 30000;
internal static string timeoutProfileName = "Timeout";
internal static string siteElevationProfileName = "SiteElevation";
internal static double siteElevationDefault = 0;
internal static string siteTemperatureProfileName = "SiteTemperature";
internal static double siteTemperatureDefault = 20;
internal static string slewSettleTimeProfileName = "SlewSettleTime";
internal static short slewSettleTimeDefault = 0;
internal static string guideRateProfileName = "GuideRate";
internal static int guideRateDefault = 0;
internal static string guideRatesProfileName = "GuideRates";
internal static double[] guideRatesStarbook = new double[] { 2.00, 2.00, 12, 24, 48, 96, 198, 396, 798 };
internal static double[] guideRatesStarbookS = new double[] { 0.75, 0.75, 18, 37, 75, 150, 300, 500, 1000 };
internal static double[] guideRatesStarbookTen = new double[] { 0.50, 1.00, 2, 5, 10, 30, 100, 300, 500 };
internal static double[] guideRatesDefault = guideRatesStarbookS;
internal static string predefinedGuideRatesProfileName = "PredefinedGuideRates";
internal static int predefinedGuideRatesDefault = 0;
internal static string parkAltitudeProfileName = "ParkAltitude";
internal static double parkAltitudeDefault = 0;
internal static string parkAzimuthProfileName = "ParkAzimuth";
internal static double parkAzimuthDefault = 270;
internal static string j2000ProfileName = "J2000";
internal static bool j2000Default = true;
internal static string starbookJ2000ProfileName = "StarbookJ2000";
internal static bool starbookJ2000Default = true;
internal static string autoMeridianFlipProfileName = "AutoMeridianFlip";
internal static int autoMeridianFlipDefault = 0;
internal static string extendedFeaturesProfileName = "ExtendedFeatures";
internal static string[] extendedFeaturesOff = { };
internal static string[] extendedFeaturesOn = { /*"AltAz", */"RADec", "RADecType", "MoveAxis", "Track", "Park", /*"PierSide", */"TBD" };
internal static string[] extendedFeatureDefault = extendedFeaturesOff;
internal static string traceLoggerProfileName = "TraceLogger";
internal static bool traceLoggerDefault = false;
internal static Starbook starbook = new Starbook(ipAddressDefault); // Variables to hold the currrent device configuration
internal static int poll;
internal static int timeout;
internal static short slewSettleTime;
internal static int guideRate;
internal static double[] guideRates;
internal static int predefinedGuideRates;
internal static double parkAltitude;
internal static double parkAzimuth;
internal static bool j2000;
internal static int autoMeridianFlip;
internal static HashSet<string> extendedFeatures;
/// <summary>
/// Private variable to hold the connected state
/// </summary>
private bool connectedState;
/// <summary>
/// Private variable to hold an ASCOM Utilities object
/// </summary>
private Util utilities;
/// <summary>
/// Private variable to hold an ASCOM AstroUtilities object to provide the Range method
/// </summary>
private AstroUtils astroUtilities;
/// <summary>
/// Private variable to hold an ASCOM Astrometry object to provide the Conversion method
/// </summary>
internal ASCOM.Astrometry.Transform.Transform transform;
/// <summary>
/// Variable to hold the trace logger object (creates a diagnostic log file with information that you specify)
/// </summary>
internal static TraceLogger traceLogger;
private bool parking;
private Starbook.Place placeCache;
private bool placeCached;
private double targetDeclination;
private double targetRightAscension;
private bool threadRunning;
private Thread thread;
private object status;
private object response;
private Queue<Request> requests;
private bool atHome;
private bool movingAxis;
private bool pulseGuiding;
private bool tracking;
/// <summary>
/// Initializes a new instance of the <see cref="Starbook"/> class.
/// Must be public for COM registration.
/// </summary>
public Telescope()
{
transform = new Astrometry.Transform.Transform(); // Initialise astrometry transform object
traceLogger = new TraceLogger("", "Starbook");
ReadProfile(); // Read device configuration from the ASCOM Profile store
traceLogger.LogMessage("Telescope", "Starting initialisation");
connectedState = false; // Initialise connected to false
utilities = new Util(); //Initialise util object
astroUtilities = new AstroUtils(); // Initialise astro utilities object
//TODO: Implement your additional construction here
parking = false;
placeCached = false;
targetRightAscension = double.NaN;
targetDeclination = double.NaN;
threadRunning = false;
thread = null;
status = null;
response = null;
requests = new Queue<Request>();
atHome = true;
movingAxis = false;
pulseGuiding = false;
tracking = true;
traceLogger.LogMessage("Telescope", "Completed initialisation");
}
//
// PUBLIC COM INTERFACE ITelescopeV3 IMPLEMENTATION
//
#region Common properties and methods.
/// <summary>
/// Displays the Setup Dialog form.
/// If the user clicks the OK button to dismiss the form, then
/// the new settings are saved, otherwise the old values are reloaded.
/// THIS IS THE ONLY PLACE WHERE SHOWING USER INTERFACE IS ALLOWED!
/// </summary>
public void SetupDialog()
{
// consider only showing the setup dialog if not connected
// or call a different dialog if connected
bool connected;
lock (this)
{
connected = this.connectedState;
}
if (connected)
{
System.Windows.Forms.MessageBox.Show("Already connected, just press OK");
}
using (SetupDialogForm F = new SetupDialogForm(this))
{
var result = F.ShowDialog();
if (result == System.Windows.Forms.DialogResult.OK)
{
WriteProfile(); // Persist device configuration values to the ASCOM Profile store
}
}
}
public ArrayList SupportedActions
{
get
{
ArrayList actions = new ArrayList();
foreach (string action in actions)
{
LogMessage("SupportedActions_get", action);
}
return actions;
}
}
public string Action(string actionName, string actionParameters)
{
LogMessage("Action", "{0} {1} not implemented", actionName, actionParameters);
throw new ASCOM.ActionNotImplementedException("Action " + actionName + " is not implemented by this driver");
}
public void CommandBlind(string command, bool raw)
{
CheckConnected("CommandBlind");
Telescope.starbook.Command(command);
}
public bool CommandBool(string command, bool raw)
{
CheckConnected("CommandBool");
Telescope.starbook.Command(command); return false;
}
public string CommandString(string command, bool raw)
{
CheckConnected("CommandString");
return Telescope.starbook.Command(command);
}
public void Dispose()
{
// Clean up the tracelogger and util objects
traceLogger.Enabled = false;
traceLogger.Dispose();
traceLogger = null;
utilities.Dispose();
utilities = null;
astroUtilities.Dispose();
astroUtilities = null;
transform.Dispose();
transform = null;
}
public bool Connected
{
get
{
bool connected = IsConnected;
LogMessage("Connected_get", "{0}", connected);
return connected;
}
set
{
LogMessage("Connected_set", "{0}", value);
lock (this)
{
connectedState = value; status = null; response = null;
}
if (thread != null)
{
threadRunning = false;
try
{
thread.Join();
}
catch
{
}
}
if (value)
{
threadRunning = true;
thread = new Thread(ThreadEntry);
thread.Start();
}
else
{
thread = null;
}
placeCached = false;
}
}
public string Description
{
// TODO customise this device description
get
{
LogMessage("Description_get", driverDescription);
return driverDescription;
}
}
public string DriverInfo
{
get
{
Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
// TODO customise this driver description
string driverInfo;
if (version.Build == 0)
{
driverInfo = "ASCOM Driver for Vixen Starbook v" + String.Format(CultureInfo.InvariantCulture, "{0}.{1}", version.Major, version.Minor);
}
else
{
driverInfo = "ASCOM Driver for Vixen Starbook v" + String.Format(CultureInfo.InvariantCulture, "{0}.{1}.{2}", version.Major, version.Minor, version.Build);
}
LogMessage("DriverInfo_get", driverInfo);
return driverInfo;
}
}
public string DriverVersion
{
get
{
Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
string driverVersion = String.Format(CultureInfo.InvariantCulture, "{0}.{1}", version.Major, version.Minor);
LogMessage("DriverVersion_get", driverVersion);
return driverVersion;
}
}
public short InterfaceVersion
{
// set by the driver wizard
get
{
LogMessage("InterfaceVersion_get", "3");
return Convert.ToInt16("3");
}
}
public string Name
{
get
{
string name = "Starbook";
LogMessage("Name_get", name);
return name;
}
}
#endregion
#region ITelescope Implementation
public void AbortSlew()
{
CheckConnected("AbortSlew");
if (this.parking)
{
LogMessage("AbortSlew", "InvalidOperationException: AtPark");
throw new ASCOM.InvalidOperationException("AbortSlew: AtPark, Starbook.Unpark() must be called first.");
}
Starbook.Response response = starbook.Stop();
if (response != Starbook.Response.OK)
{
LogMessage("AbortSlew", "InvalidOperationException: Starbook.Stop()={0}", response);
throw new ASCOM.InvalidOperationException("AbortSlew: Starbook.Stop() is not working.");
}
LogMessage("AbortSlew", "OK");
}
public AlignmentModes AlignmentMode
{
get
{
AlignmentModes mode = AlignmentModes.algGermanPolar;
LogMessage("AlignmentMode_get", "{0}", mode);
return mode;
}
}
public double Altitude
{
get
{
CheckConnected("Altitude_get");
double altitude;
if (extendedFeatures.Contains("AltAz"))
{
Starbook.Response response = starbook.GetAltAz(out altitude, out double azimuth);
if (response != Starbook.Response.OK)
{
LogMessage("Altitude_get", "InvalidOperationException: Starbook.GetAltAz()={0}", response);
throw new ASCOM.InvalidOperationException("Altitude_get: Starbook.GetAltAz() is not working.");
}
}
else
{
Starbook.Response response = GetStatus(out Starbook.Status status);
if (response != Starbook.Response.OK)
{
LogMessage("Altitude_get", "InvalidOperationException: Starbook.GetStatus()={0}", response);
throw new ASCOM.InvalidOperationException("Altitude_get: Starbook.GetStatus() is not working.");
}
response = GetPlace(out Starbook.Place place);
if (response != Starbook.Response.OK)
{
LogMessage("Altitude_get", "InvalidOperationException: Starbook.GetPlace()={0}", response);
throw new ASCOM.InvalidOperationException("Altitude_get: Starbook.GetPlace() is not working.");
}
response = starbook.GetTime(out DateTime time);
if (response != Starbook.Response.OK)
{
LogMessage("Altitude_get", "InvalidOperationException: Starbook.GetTime()={0}", response);
throw new ASCOM.InvalidOperationException("Altitude_get: Starbook.GetTime() is not working.");
}
Transform(place.Latitude.Value, place.Longitude.Value, time, place.Timezone,
status.RA.Value, status.Dec.Value, starbook.J2000, out altitude, out double azimuth);
}
LogMessage("Altitude_get", "{0}", altitude);
return altitude;
}
}
public double ApertureArea
{
get
{
LogMessage("ApertureArea_get", "PropertyNotImplementedException");
throw new ASCOM.PropertyNotImplementedException("ApertureArea", false);
}
}
public double ApertureDiameter
{
get
{
LogMessage("ApertureDiameter_get", "PropertyNotImplementedException");
throw new ASCOM.PropertyNotImplementedException("ApertureDiameter", false);
}
}
public bool AtHome
{
get
{
CheckConnected("AtHome");
bool atHome;
lock (this)
{
atHome = this.atHome;
}
LogMessage("AtHome_get", "{0}", atHome);
return atHome;
}
}
public bool AtPark
{
get
{
CheckConnected("AtPark_get");
bool atPark = parking;
LogMessage("AtPark_get", "{0}", atPark);
return atPark;
}
}
public IAxisRates AxisRates(TelescopeAxes Axis)
{
IAxisRates axisRates = new AxisRates(Axis);
foreach (IRate axisRate in axisRates)
{
LogMessage("AxisRates", "{0}-{1}: Axis={2}", axisRate.Minimum, axisRate.Maximum, Axis);
}
return axisRates;
}
public double Azimuth
{
get
{
CheckConnected("Azimuth_get");
double azimuth;
if (extendedFeatures.Contains("AltAz"))
{
Starbook.Response response = starbook.GetAltAz(out double altitude, out azimuth);
if (response != Starbook.Response.OK)
{
LogMessage("Azimuth_get", "InvalidOperationException: Starbook.GetAltAz()={0}", response);
throw new ASCOM.InvalidOperationException("Azimuth_get: Starbook.GetAltAz() is not working.");
}
}
else
{
Starbook.Response response = GetStatus(out Starbook.Status status);
if (response != Starbook.Response.OK)
{
LogMessage("Azimuth_get", "InvalidOperationException: Starbook.GetStatus()={0}", response);
throw new ASCOM.InvalidOperationException("Azimuth_get: Starbook.GetStatus() is not working.");
}
response = GetPlace(out Starbook.Place place);
if (response != Starbook.Response.OK)
{
LogMessage("Azimuth_get", "InvalidOperationException: Starbook.GetPlace()={0}", response);
throw new ASCOM.InvalidOperationException("Azimuth_get: Starbook.GetPlace() is not working.");
}
response = starbook.GetTime(out DateTime time);
if (response != Starbook.Response.OK)
{
LogMessage("Azimuth_get", "InvalidOperationException: Starbook.GetTime()={0}", response);
throw new ASCOM.InvalidOperationException("Azimuth_get: Starbook.GetTime() is not working.");
}
Transform(place.Latitude.Value, place.Longitude.Value, time, place.Timezone,
status.RA.Value, status.Dec.Value, starbook.J2000, out double altitude, out azimuth);
}
LogMessage("Azimuth_get", "{0}", azimuth);
return azimuth;
}
}
public bool CanFindHome
{
get
{
LogMessage("CanFindHome_get", "{0}", true);
return true;
}
}
public bool CanMoveAxis(TelescopeAxes Axis)
{
bool canMoveAxis = false;
switch (Axis)
{
case TelescopeAxes.axisPrimary:
{
canMoveAxis = true; break;
}
case TelescopeAxes.axisSecondary:
{
canMoveAxis = true; break;
}
case TelescopeAxes.axisTertiary:
{
canMoveAxis = false; break;
}
default:
{
LogMessage("CanMoveAxis", "InvalidValueException: Axis={0}", Axis);
throw new InvalidValueException("CanMoveAxis", "Axis", "Primary, Secondary, Tertiary");
}
}
LogMessage("CanMoveAxis", "{0}: Axis={1}", canMoveAxis, Axis);
return canMoveAxis;
}
public bool CanPark
{
get
{
LogMessage("CanPark_get", "{0}", true);
return true;
}
}
public bool CanPulseGuide
{
get
{
LogMessage("CanPulseGuide_get", "{0}", true);
return true;
}
}
public bool CanSetDeclinationRate
{
get
{
LogMessage("CanSetDeclinationRate_get", "{0}", false);
return false;
}
}
public bool CanSetGuideRates
{
get
{
LogMessage("CanSetGuideRates_get", "{0}", true);
return true;
}
}
public bool CanSetPark
{
get
{
LogMessage("CanSetPark_get", "{0}", true);
return true;
}
}
public bool CanSetPierSide
{
get
{
LogMessage("CanSetPierSide_get", "{0}", false);
return false;
}
}
public bool CanSetRightAscensionRate
{
get
{
LogMessage("CanSetRightAscensionRate_get", "{0}", false);
return false;
}
}
public bool CanSetTracking
{
get
{
LogMessage("CanSetTracking_get", "{0}", true);
return true;
}
}
public bool CanSlew
{
get
{
LogMessage("CanSlew_get", "{0}", true);
return true;
}
}
public bool CanSlewAltAz
{
get
{
LogMessage("CanSlewAltAz_get", "{0}", true);
return true;
}
}
public bool CanSlewAltAzAsync
{
get
{
LogMessage("CanSlewAltAzAsync_get", "{0}", true);
return true;
}
}
public bool CanSlewAsync
{
get
{
LogMessage("CanSlewAsync_get", "{0}", true);
return true;
}
}
public bool CanSync
{
get
{
LogMessage("CanSync_get", "{0}", true);
return true;
}
}
public bool CanSyncAltAz
{
get
{
LogMessage("CanSyncAltAz_get", "{0}", true);
return true;
}
}
public bool CanUnpark
{
get
{
LogMessage("CanUnpark_get", "{0}", true);
return true;
}
}
public double Declination
{
get
{
CheckConnected("Declination_get");
Starbook.Response response = GetStatus(out Starbook.Status status);
if (response != Starbook.Response.OK)
{
LogMessage("Declination_get", "InvalidOperationException: Starbook.GetStatus()={0}", response);
throw new ASCOM.InvalidOperationException("Declination_get: Starbook.GetStatus() is not working.");
}
double declination;
if (j2000 == starbook.J2000)
{
declination = status.Dec.Value;
LogMessage("Declination_get", "{0}: Status.Dec={1}", declination, status.Dec);
}
else
{
response = GetPlace(out Starbook.Place place);
if (response != Starbook.Response.OK)
{
LogMessage("Declination_get", "InvalidOperationException: Starbook.GetPlace()={0}", response);
throw new ASCOM.InvalidOperationException("Declination_get: Starbook.GetPlace() is not working.");
}
response = starbook.GetTime(out DateTime time);
if (response != Starbook.Response.OK)
{
LogMessage("Declination_get", "InvalidOperationException: Starbook.GetTime()={0}", response);
throw new ASCOM.InvalidOperationException("Declination_get: Starbook.GetTime() is not working.");
}
double statusDecValue = status.Dec.Value;
Transform(place.Latitude.Value, place.Longitude.Value, time, place.Timezone,
status.RA.Value, statusDecValue, starbook.J2000, out double rightAscension, out declination, j2000);
LogMessage("Declination_get", "{0}=>{1}: Status.Dec={2}", statusDecValue, declination, status.Dec);
}
return declination;
}
}
public double DeclinationRate
{
get
{
double declination = 0.0;
LogMessage("DeclinationRate_get", "{0}", declination);
return declination;
}
set
{
LogMessage("DeclinationRate_set", "PropertyNotImplementedException");
throw new ASCOM.PropertyNotImplementedException("DeclinationRate", true);
}
}
public PierSide DestinationSideOfPier(double RightAscension, double Declination)
{
LogMessage("DestinationSideOfPier", "MethodNotImplementedException");
throw new ASCOM.MethodNotImplementedException("DestinationSideOfPier");
}
public bool DoesRefraction
{
get
{
LogMessage("DoesRefraction_get", "PropertyNotImplementedException");
throw new ASCOM.PropertyNotImplementedException("DoesRefraction", false);
}
set
{
LogMessage("DoesRefraction_set", "PropertyNotImplementedException");
throw new ASCOM.PropertyNotImplementedException("DoesRefraction", true);
}
}
public EquatorialCoordinateType EquatorialSystem
{
get
{
CheckConnected("EquatorialSystem_get");
EquatorialCoordinateType equatorialSystem = j2000 ? EquatorialCoordinateType.equJ2000 : EquatorialCoordinateType.equTopocentric;
LogMessage("EquatorialSystem_get", "{0}", equatorialSystem);
return equatorialSystem;
}
}
public void FindHome()
{
CheckConnected("FindHome");
if (this.parking)
{
LogMessage("FindHome", "InvalidOperationException: AtPark");
throw new ASCOM.InvalidOperationException("FindHome: AtPark, Starbook.Unpark() must be called first.");
}
Starbook.Response response = Home();
if (response != Starbook.Response.OK)
{
LogMessage("FindHome", "InvalidOperationException: Starbook.Home()={0}", response);
throw new ASCOM.InvalidOperationException("FindHome: Starbook.Home() is not working.");
}
while (true)
{
response = GetStatus(out Starbook.Status status);
if (response != Starbook.Response.OK)
{
LogMessage("FindHome", "InvalidOperationException: Starbook.GetStatus()={0}", response);
throw new ASCOM.InvalidOperationException("FindHome: Starbook.GetStatus() is not working.");
}
if (!status.Goto)
{
break;
}
Thread.Sleep(poll);
}
LogMessage("FindHome", "OK");
}
public double FocalLength
{
get
{
LogMessage("FocalLength_get", "PropertyNotImplementedException");
throw new ASCOM.PropertyNotImplementedException("FocalLength", false);
}
}
public static double GuideRate(int guideRate)
{
return guideRates[guideRate] * (15.04106858 / 3600);
}
public static int GuideRate(double guideRate)
{
for (int index = 0; index <= 8; index++)
{
if (guideRate == GuideRate(index))
{
return index;
}
}
return -1;
}
public double GuideRateDeclination
{
get
{
double guideRate = GuideRate(Telescope.guideRate);
LogMessage("GuideRateDeclination_get", "{0}: GuideRate={1}", guideRate, Telescope.guideRate);
return guideRate;
}
set
{
CheckConnected("GuideRateDeclination_set");
int guideRate = GuideRate(value);
if (guideRate < 0)
{
LogMessage("GuideRateDeclination_set", "InvalidValueException: {0}", value);
throw new ASCOM.InvalidValueException("GuideRateDeclination_set", "GuideRateDeclination", "AxisRates(axisSecondary)");
}
Starbook.Response response = starbook.SetSpeed(guideRate);
if (response != Starbook.Response.OK)
{
LogMessage("GuideRateDeclination_set", "InvalidOperationException: {0}, Starbook.SetSpeed({1})={2}", value, guideRate, response);
throw new ASCOM.InvalidOperationException("GuideRateDeclination_set: Starbook.SetSpeed() is not working.");
}
LogMessage("GuideRateDeclination_set", "OK: {0}, GuideRate={1}", value, Telescope.guideRate = guideRate);
}
}
public double GuideRateRightAscension
{
get
{
double guideRate = GuideRate(Telescope.guideRate);
LogMessage("GuideRateRightAscension_get", "{0}: GuideRate={1}", guideRate, Telescope.guideRate);
return guideRate;
}
set
{
CheckConnected("GuideRateRightAscension_set");
int guideRate = GuideRate(value);
if (guideRate < 0)
{
LogMessage("GuideRateRightAscension_set", "InvalidValueException: {0}", value);
throw new ASCOM.InvalidValueException("GuideRateRightAscension_set", "GuideRateRightAscension", "AxisRates(axisPrimary)");
}