-
Notifications
You must be signed in to change notification settings - Fork 2
/
eqmod_int.pas
1291 lines (1195 loc) · 38 KB
/
eqmod_int.pas
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
unit eqmod_int;
{$mode objfpc}{$H+}
{
Copyright (C) 2015 Patrick Chevalley
http://www.ap-i.net
pch@ap-i.net
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
}
interface
uses indibaseclient, indibasedevice, indiapi, indicom,
ExtCtrls, Forms, Classes, SysUtils;
type
TNotifyMsg = procedure(msg:string) of object;
TNotifyNum = procedure(d: double) of object;
TTrackMode =(trStop, trSidereal, trLunar, trSolar, trCustom);
TNumRange = record
min,max,step: double;
end;
const
TrackModeName :array [0..4] of string = ('TRACK_STOP','TRACK_SIDEREAL','TRACK_LUNAR','TRACK_SOLAR','TRACK_CUSTOM');
UnitRange:TNumRange = (min:1;max:1;step:1);
NullRange:TNumRange = (min:0;max:0;step:0);
NullCoord=-9999;
type
T_indieqmod = class(TIndiBaseClient)
private
InitTimer: TTimer;
MountDevice: Basedevice;
Mountport: ITextVectorProperty;
coord_prop: INumberVectorProperty;
coord_ra: INumber;
coord_dec: INumber;
horz_prop: INumberVectorProperty;
horz_az: INumber;
horz_alt: INumber;
TelescopeInfo: INumberVectorProperty;
TelescopeAperture, TelescopeFocale: INumber;
Mlst: INumberVectorProperty;
PierSide: ISwitchVectorProperty;
Sim: ISwitchVectorProperty;
AbortMotion: ISwitchVectorProperty;
MotionNS: ISwitchVectorProperty;
MotionN: ISwitch;
MotionS: ISwitch;
MotionWE: ISwitchVectorProperty;
MotionW: ISwitch;
MotionE: ISwitch;
RevDec: ISwitchVectorProperty;
SlewMode: ISwitchVectorProperty;
SlewSpeed: INumberVectorProperty;
RAslew, DEslew: INumber;
TrackM: ISwitchVectorProperty;
TrackSidereal,TrackLunar,TrackSolar,TrackCustom: ISwitch;
TrackSt: ISwitchVectorProperty;
TrackOn, TrackOff: ISwitch;
TrackR: INumberVectorProperty;
TrackRra, TrackRde: INumber;
CoordSet: ISwitchVectorProperty;
CoordSetTrack,CoordSetSlew,CoordSetSync: ISwitch;
Park_opt: ISwitchVectorProperty;
geo_coord: INumberVectorProperty;
geo_lat: INumber;
geo_lon: INumber;
geo_ele: INumber;
guide_rate: INumberVectorProperty;
guide_rateNS: INumber;
guide_rateWE: INumber;
AlignCount: INumberVectorProperty;
AlignCountPoint,AlignCountTriangle: INumber;
StandardSync: INumberVectorProperty;
SyncDeltaRA, SyncDeltaDE: INumber;
AlignMode: ISwitchVectorProperty;
AlignList: ISwitchVectorProperty;
AlignListAdd, AlignListClear, AlignListWrite, AlignListLoad: ISwitch;
AlignSyncMode: ISwitchVectorProperty;
AlignDataFile: ITextVectorProperty;
SyncManage: ISwitchVectorProperty;
SyncClearDelta: ISwitch;
configprop: ISwitchVectorProperty;
configload,configsave,configdefault: ISwitch;
eod_coord: boolean;
Fready,Fconnected,FAutoloadConfig: boolean;
Findiserver, Findiserverport, Findidevice, Findideviceport: string;
FSimulation: Boolean;
FSlewPreset: TStringList;
FStatus: TDeviceStatus;
FonDestroy: TNotifyEvent;
FonMsg: TNotifyMsg;
FonStatusChange: TNotifyEvent;
FonCoordChange: TNotifyEvent;
FonAltAZChange: TNotifyEvent;
FonLSTChange: TNotifyEvent;
FonPierSideChange: TNotifyEvent;
FonSlewSpeedChange: TNotifyEvent;
FonSlewModeChange: TNotifyEvent;
FonRevDecChange: TNotifyEvent;
FonSync: TNotifyEvent;
FonTrackModeChange: TNotifyEvent;
FonTrackRateChange:TNotifyEvent;
FonParkChange:TNotifyEvent;
FonGuideRateChange:TNotifyEvent;
FonGeoCoordChange:TNotifyEvent;
FonAlignCountChange: TNotifyEvent;
FonSyncDeltaChange: TNotifyEvent;
FonAlignmentModeChange: TNotifyEvent;
FonSyncModeChange: TNotifyEvent;
FonAbortMotion: TNotifyEvent;
FAlignmentMode: TStringList;
FSyncMode: TStringList;
procedure InitTimerTimer(Sender: TObject);
procedure ClearStatus;
procedure CheckStatus;
procedure NewDevice(dp: Basedevice);
procedure NewMessage(mp: IMessage);
procedure NewProperty(indiProp: IndiProperty);
procedure NewNumber(nvp: INumberVectorProperty);
procedure NewText(tvp: ITextVectorProperty);
procedure NewSwitch(svp: ISwitchVectorProperty);
procedure NewLight(lvp: ILightVectorProperty);
procedure DeleteDevice(dp: Basedevice);
procedure DeleteProperty(indiProp: IndiProperty);
procedure ServerConnected(Sender: TObject);
procedure ServerDisconnected(Sender: TObject);
function GetRA:double;
function GetDec:double;
function GetAZ:double;
function GetALT:double;
function GetLST:double;
function GetEquinox: double;
function GetAperture:double;
function GetPierSideLbl: string;
function GetFocaleLength:double;
function GetRevDec: boolean;
procedure SetRevDec(value: boolean);
function GetRASlewSpeed:integer;
procedure SetRASlewSpeed(value:integer);
function GetDESlewSpeed:integer;
procedure SetDESlewSpeed(value:integer);
function GetActiveSlewPreset: integer;
procedure SetActiveSlewPreset(value: integer);
function GetRASlewSpeedRange: TNumRange;
function GetDESlewSpeedRange: TNumRange;
function GetTrackmode: TTrackMode;
procedure SetTrackmode(value: TTrackMode);
procedure msg(txt: string);
function GetRATrackRate: double;
function GetDETrackRate: double;
function GetPark: boolean;
procedure SetPark(value:boolean);
function GetLatitude: double;
function GetLongitude: double;
function GetElevation: double;
function GetRAGuideRate:double;
procedure SetRAGuideRate(value:double);
function GetDEGuideRate:double;
procedure SetDEGuideRate(value:double);
function GetPointCount: integer;
function GetTriangleCount: integer;
function GetDeltaRa: double;
function GetDeltaDe: double;
function GetActiveAlignmentMode: integer;
procedure SetActiveAlignmentMode(value: integer);
function GetActiveSyncMode: integer;
procedure SetActiveSyncMode(value: integer);
function GetStatusError: string;
public
constructor Create;
destructor Destroy; override;
Procedure Connect;
Procedure Disconnect;
procedure MotionNorth;
procedure MotionSouth;
procedure MotionWest;
procedure MotionEast;
procedure MotionNorthStop;
procedure MotionSouthStop;
procedure MotionWestStop;
procedure MotionEastStop;
procedure MotionStop;
procedure SetTrackRate(tra,tde: double);
procedure SetSite(ObsLat,ObsLon,ObsElev: double);
procedure ClearAlignment;
procedure SaveAlignment(fn: string);
procedure LoadAlignment(fn: string);
procedure SaveConfig;
procedure LoadConfig;
procedure ClearSyncDelta;
property indiserver: string read Findiserver write Findiserver;
property indiserverport: string read Findiserverport write Findiserverport;
property indidevice: string read Findidevice write Findidevice;
property indideviceport: string read Findideviceport write Findideviceport;
property AutoloadConfig: boolean read FAutoloadConfig write FAutoloadConfig;
property Status: TDeviceStatus read FStatus;
property Simulation: Boolean read FSimulation write FSimulation;
property RA: double read GetRA;
property Dec: double read GetDec;
property AZ: double read GetAZ;
property ALT: double read GetALT;
property LST: double read GetLST;
property PierSideLbl: string read GetPierSideLbl;
property Equinox: double read GetEquinox;
property Aperture: double read GetAperture;
property FocaleLength: double read GetFocaleLength;
property ReverseDec: Boolean read GetRevDec write SetRevDec;
property SlewPreset: TStringList read FSlewPreset;
property ActiveSlewPreset: integer read GetActiveSlewPreset write SetActiveSlewPreset;
property RASlewSpeedRange: TNumRange read GetRASlewSpeedRange;
property DESlewSpeedRange: TNumRange read GetDESlewSpeedRange;
property RASlewSpeed: integer read GetRASlewSpeed write SetRASlewSpeed;
property DESlewSpeed: integer read GetDESlewSpeed write SetDESlewSpeed;
property TrackMode: TTrackMode read GetTrackmode write SetTrackmode;
property RATrackRate: double read GetRATrackRate;
property DETrackRate: double read GetDETrackRate;
property Park: boolean read GetPark write SetPark;
property Latitude: double read GetLatitude;
property Longitude: double read GetLongitude;
property Elevation: double read GetElevation;
property RAGuideRate: double read GetRAGuideRate write SetRAGuideRate;
property DEGuideRate: double read GetDEGuideRate write SetDEGuideRate;
property PointCount: integer read GetPointCount;
property TriangleCount: integer read GetTriangleCount;
property DeltaRa: double read GetDeltaRa;
property DeltaDe: double read GetDeltaDe;
property AlignmentMode: TStringList read FAlignmentMode;
property ActiveAlignmentMode: integer read GetActiveAlignmentMode write SetActiveAlignmentMode;
property SyncMode: TStringList read FSyncMode;
property ActiveSyncMode: integer read GetActiveSyncMode write SetActiveSyncMode;
property StatusError: string read GetStatusError;
property onDestroy: TNotifyEvent read FonDestroy write FonDestroy;
property onMsg: TNotifyMsg read FonMsg write FonMsg;
property onStatusChange: TNotifyEvent read FonStatusChange write FonStatusChange;
property onCoordChange: TNotifyEvent read FonCoordChange write FonCoordChange;
property onAltAZChange: TNotifyEvent read FonAltAZChange write FonAltAZChange;
property onLSTChange: TNotifyEvent read FonLSTChange write FonLSTChange;
property onPierSideChange: TNotifyEvent read FonPierSideChange write FonPierSideChange;
property onRevDecChange: TNotifyEvent read FonRevDecChange write FonRevDecChange;
property onSync: TNotifyEvent read FonSync write FonSync;
property onSlewSpeedChange: TNotifyEvent read FonSlewSpeedChange write FonSlewSpeedChange;
property onSlewModeChange: TNotifyEvent read FonSlewModeChange write FonSlewModeChange;
property onTrackModeChange: TNotifyEvent read FonTrackModeChange write FonTrackModeChange;
property onTrackRateChange: TNotifyEvent read FonTrackRateChange write FonTrackRateChange;
property onParkChange: TNotifyEvent read FonParkChange write FonParkChange;
property onGeoCoordChange:TNotifyEvent read FonGeoCoordChange write FonGeoCoordChange;
property onGuideRateChange:TNotifyEvent read FonGuideRateChange write FonGuideRateChange;
property onAlignCountChange:TNotifyEvent read FonAlignCountChange write FonAlignCountChange;
property onSyncDeltaChange: TNotifyEvent read FonSyncDeltaChange write FonSyncDeltaChange;
property onAlignmentModeChange: TNotifyEvent read FonAlignmentModeChange write FonAlignmentModeChange;
property onSyncModeChange: TNotifyEvent read FonSyncModeChange write FonSyncModeChange;
property onAbortMotion: TNotifyEvent read FonAbortMotion write FonAbortMotion;
end;
implementation
constructor T_indieqmod.Create;
begin
inherited Create;
FSlewPreset:=TStringList.Create;
FAlignmentMode:=TStringList.Create;
FSyncMode:=TStringList.Create;
ClearStatus;
Findiserver:='localhost';
Findiserverport:='7624';
Findidevice:='';
Findideviceport:='';
InitTimer:=TTimer.Create(nil);
InitTimer.Enabled:=false;
InitTimer.Interval:=30000;
InitTimer.OnTimer:=@InitTimerTimer;
onNewDevice:=@NewDevice;
onNewMessage:=@NewMessage;
onNewProperty:=@NewProperty;
onNewNumber:=@NewNumber;
onNewText:=@NewText;
onNewSwitch:=@NewSwitch;
onNewLight:=@NewLight;
onDeleteDevice:=@DeleteDevice;
onDeleteProperty:=@DeleteProperty;
onServerConnected:=@ServerConnected;
onServerDisconnected:=@ServerDisconnected;
end;
destructor T_indieqmod.Destroy;
begin
if assigned(FonDestroy) then FonDestroy(self);
onNewDevice:=nil;
onNewMessage:=nil;
onNewProperty:=nil;
onNewNumber:=nil;
onNewText:=nil;
onNewSwitch:=nil;
onNewLight:=nil;
onNewBlob:=nil;
onServerConnected:=nil;
onServerDisconnected:=nil;
if InitTimer<>nil then FreeAndNil(InitTimer);
Terminate;
FSlewPreset.Free;
FAlignmentMode.Free;
FSyncMode.Free;
inherited Destroy;
end;
procedure T_indieqmod.ClearStatus;
begin
MountDevice:=nil;
Mountport:=nil;
TelescopeInfo:=nil;
coord_prop:=nil;
horz_prop:=nil;
PierSide:=nil;
Sim:=nil;
Mlst:=nil;
AbortMotion:=nil;
MotionNS:=nil;
MotionWE:=nil;
RevDec:=nil;
SlewMode:=nil;
SlewSpeed:=nil;
TrackM:=nil;
TrackR:=nil;
TrackSt:=nil;
CoordSet:=nil;
Park_opt:=nil;
geo_coord:=nil;
guide_rate:=nil;
AlignCount:=nil;
StandardSync:=nil;
AlignMode:=nil;
AlignList:=nil;
AlignDataFile:=nil;
AlignSyncMode:=nil;
SyncManage:=nil;
configprop:=nil;
Fready:=false;
Fconnected := false;
FStatus := devDisconnected;
FSlewPreset.Clear;
FAlignmentMode.Clear;
FSyncMode.Clear;
if Assigned(FonStatusChange) then FonStatusChange(self);
end;
procedure T_indieqmod.CheckStatus;
begin
if Fconnected and
(not Fready) and
(coord_prop<>nil) and
(horz_prop<>nil) and
(Mlst<>nil) and
(PierSide<>nil) and
(Sim<>nil) and
(AbortMotion<>nil) and
(MotionNS<>nil) and
(MotionWE<>nil) and
(RevDec<>nil) and
(TrackM<>nil) and
(TrackR<>nil) and
(TrackSt<>nil) and
(CoordSet<>nil) and
(SlewMode<>nil) and
(SlewSpeed<>nil) and
(Park_opt<>nil) and
(guide_rate<>nil) and
(geo_coord<>nil) and
(AlignCount<>nil) and
(StandardSync<>nil) and
(AlignMode<>nil) and
(AlignList<>nil) and
(AlignSyncMode<>nil) and
(AlignDataFile<>nil) and
(configprop<>nil) and
(SyncManage<>nil)
then begin
FStatus := devConnected;
if (not Fready) and Assigned(FonStatusChange) then FonStatusChange(self);
Fready:=true;
if FAutoloadConfig then begin
LoadConfig;
end;
end;
end;
function T_indieqmod.GetStatusError: string;
begin
if Fconnected then begin
Result:='Missing properties: ';
if (coord_prop=nil) then Result:=Result+'EQUATORIAL_(EOD)_COORD, ';
if (horz_prop=nil) then Result:=Result+'HORIZONTAL_COORD, ';
if (Mlst=nil) then Result:=Result+'TIME_LST, ';
if (PierSide=nil) then Result:=Result+'TELESCOPE_PIER_SIDE, ';
if (Sim=nil) then Result:=Result+'SIMULATION, ';
if (AbortMotion=nil) then Result:=Result+'TELESCOPE_ABORT_MOTION, ';
if (MotionNS=nil) then Result:=Result+'TELESCOPE_MOTION_NS, ';
if (MotionWE=nil) then Result:=Result+'TELESCOPE_MOTION_WE, ';
if (RevDec=nil) then Result:=Result+'REVERSEDEC, ';
if (TrackSt=nil) then Result:=Result+'TELESCOPE_TRACK_STATE, ';
if (TrackM=nil) then Result:=Result+'TELESCOPE_TRACK_RATE, ';
if (TrackR=nil) then Result:=Result+'TRACKRATES, ';
if (CoordSet=nil) then Result:=Result+'ON_COORD_SET, ';
if (SlewMode=nil) then Result:=Result+'TELESCOPE_SLEW_RATE, ';
if (SlewSpeed=nil) then Result:=Result+'SLEWSPEEDS, ';
if (Park_opt=nil) then Result:=Result+'TELESCOPE_PARK, ';
if (geo_coord=nil) then Result:=Result+'GEOGRAPHIC_COORD, ';
if (guide_rate=nil) then Result:=Result+'GUIDE_RATE, ';
if (AlignCount=nil) then Result:=Result+'ALIGNCOUNT, ';
if (StandardSync=nil) then Result:=Result+'STANDARDSYNC, ';
if (AlignMode=nil) then Result:=Result+'ALIGNMODE, ';
if (AlignList=nil) then Result:=Result+'ALIGNLIST, ';
if (AlignSyncMode=nil) then Result:=Result+'ALIGNSYNCMODE, ';
if (AlignDataFile=nil) then Result:=Result+'ALIGNDATAFILE, ';
if (configprop=nil) then Result:=Result+'CONFIG_PROCESS, ';
if (SyncManage=nil) then Result:=Result+'SYNCMANAGE, ';
end else
Result:='Not connected';
end;
procedure T_indieqmod.msg(txt: string);
begin
if Assigned(FonMsg) then FonMsg(txt);
end;
Procedure T_indieqmod.Connect;
begin
if not Connected then begin
FStatus := devDisconnected;
if Assigned(FonStatusChange) then FonStatusChange(self);
SetServer(indiserver,indiserverport);
watchDevice(indidevice);
ConnectServer;
FStatus := devConnecting;
if Assigned(FonStatusChange) then FonStatusChange(self);
InitTimer.Enabled:=true;
end
else msg('Already connected');
end;
procedure T_indieqmod.InitTimerTimer(Sender: TObject);
begin
InitTimer.Enabled:=false;
if (MountDevice=nil)or(not Fready) then begin
msg('Initialisation failed.');
msg(GetStatusError);
Disconnect;
end;
end;
Procedure T_indieqmod.Disconnect;
begin
Terminate;
ClearStatus;
end;
procedure T_indieqmod.ServerConnected(Sender: TObject);
begin
if (Mountport<>nil)and(Findideviceport<>'') then begin
Mountport.tp[0].text:=Findideviceport;
sendNewText(Mountport);
WaitBusy(Mountport,5000,1000);
end;
if (Sim<>nil) and FSimulation then begin
IUResetSwitch(Sim);
Sim.sp[0].s:=ISS_ON;
sendNewSwitch(Sim);
end;
connectDevice(Findidevice);
end;
procedure T_indieqmod.ServerDisconnected(Sender: TObject);
begin
FStatus := devDisconnected;
if Assigned(FonStatusChange) then FonStatusChange(self);
msg('Mount server disconnected');
end;
procedure T_indieqmod.NewDevice(dp: Basedevice);
begin
//writeln('Newdev: '+dp.getDeviceName);
if dp.getDeviceName=Findidevice then begin
Fconnected:=true;
MountDevice:=dp;
end;
end;
procedure T_indieqmod.DeleteDevice(dp: Basedevice);
begin
if dp.getDeviceName=Findidevice then begin
Disconnect;
end;
end;
procedure T_indieqmod.DeleteProperty(indiProp: IndiProperty);
begin
{ TODO : check if a vital property is removed ? }
end;
procedure T_indieqmod.NewMessage(mp: IMessage);
begin
msg(mp.msg);
mp.Free;
end;
procedure T_indieqmod.NewProperty(indiProp: IndiProperty);
var propname: string;
proptype: INDI_TYPE;
i: integer;
begin
propname:=indiProp.getName;
proptype:=indiProp.getType;
if (proptype=INDI_TEXT)and(propname='DEVICE_PORT') then begin
Mountport:=indiProp.getText;
end
else if (proptype=INDI_NUMBER)and(propname='EQUATORIAL_EOD_COORD') then begin
coord_prop:=indiProp.getNumber;
coord_ra:=IUFindNumber(coord_prop,'RA');
coord_dec:=IUFindNumber(coord_prop,'DEC');
eod_coord:=true;
if (coord_ra=nil)or(coord_dec=nil) then coord_prop:=nil;
end
else if (proptype=INDI_NUMBER)and(coord_prop=nil)and(propname='EQUATORIAL_COORD') then begin
coord_prop:=indiProp.getNumber;
coord_ra:=IUFindNumber(coord_prop,'RA');
coord_dec:=IUFindNumber(coord_prop,'DEC');
eod_coord:=false;
if (coord_ra=nil)or(coord_dec=nil) then coord_prop:=nil;
end
else if (proptype=INDI_NUMBER)and(propname='HORIZONTAL_COORD') then begin
horz_prop:=indiProp.getNumber;
horz_az:=IUFindNumber(horz_prop,'AZ');
horz_alt:=IUFindNumber(horz_prop,'ALT');
if (horz_az=nil)or(horz_alt=nil) then horz_prop:=nil;
end
else if (proptype=INDI_NUMBER)and(propname='TELESCOPE_INFO') then begin
TelescopeInfo:=indiProp.getNumber;
TelescopeAperture:=IUFindNumber(TelescopeInfo,'TELESCOPE_APERTURE');
TelescopeFocale:=IUFindNumber(TelescopeInfo,'TELESCOPE_FOCAL_LENGTH');
if (TelescopeAperture=nil)or(TelescopeFocale=nil) then TelescopeInfo:=nil;
end
else if (proptype=INDI_NUMBER)and(propname='TIME_LST') then begin
Mlst:=indiProp.getNumber;
end
else if (proptype=INDI_SWITCH)and(propname='TELESCOPE_PIER_SIDE') then begin
PierSide:=indiProp.getSwitch;
end
else if (proptype=INDI_SWITCH)and(propname='SIMULATION') then begin
Sim:=indiProp.getSwitch;
end
else if (proptype=INDI_SWITCH)and(propname='TELESCOPE_ABORT_MOTION') then begin
AbortMotion:=indiProp.getSwitch;
end
else if (proptype=INDI_SWITCH)and(propname='TELESCOPE_MOTION_NS') then begin
MotionNS:=indiProp.getSwitch;
MotionN:=IUFindSwitch(MotionNS,'MOTION_NORTH');
MotionS:=IUFindSwitch(MotionNS,'MOTION_SOUTH');
if (MotionN=nil)or(MotionS=nil) then MotionNS:=nil;
end
else if (proptype=INDI_SWITCH)and(propname='TELESCOPE_MOTION_WE') then begin
MotionWE:=indiProp.getSwitch;
MotionW:=IUFindSwitch(MotionWE,'MOTION_WEST');
MotionE:=IUFindSwitch(MotionWE,'MOTION_EAST');
if (MotionW=nil)or(MotionE=nil) then MotionWE:=nil;
end
else if (proptype=INDI_SWITCH)and(propname='REVERSEDEC') then begin
RevDec:=indiProp.getSwitch;
end
else if (proptype=INDI_SWITCH)and((propname='TELESCOPE_SLEW_RATE')or(propname='SLEWMODE')) then begin
SlewMode:=indiProp.getSwitch;
for i:=0 to SlewMode.nsp-1 do begin
FSlewPreset.Add(SlewMode.sp[i].lbl);
end;
end
else if (proptype=INDI_NUMBER)and(propname='SLEWSPEEDS') then begin
SlewSpeed:=indiProp.getNumber;
RAslew:=IUFindNumber(SlewSpeed,'RASLEW');
DEslew:=IUFindNumber(SlewSpeed,'DESLEW');
if (RAslew=nil)or(DEslew=nil) then SlewSpeed:=nil;
end
else if (proptype=INDI_NUMBER)and((propname='TELESCOPE_TRACK_RATE')or(propname='TRACKRATES')) then begin
TrackR:=indiProp.getNumber;
TrackRra:=IUFindNumber(TrackR,'TRACK_RATE_RA');
if TrackRra=nil then TrackRra:=IUFindNumber(TrackR,'RATRACKRATE');
TrackRde:=IUFindNumber(TrackR,'TRACK_RATE_DE');
if TrackRde=nil then TrackRde:=IUFindNumber(TrackR,'DETRACKRATE');
if (TrackRra=nil)or(TrackRde=nil) then TrackR:=nil;
end
else if (proptype=INDI_SWITCH)and((propname='TELESCOPE_TRACK_MODE')or(propname='TELESCOPE_TRACK_RATE')or(propname='TRACKMODE')) then begin
TrackM:=indiProp.getSwitch;
TrackSidereal:=IUFindSwitch(TrackM,'TRACK_SIDEREAL');
if TrackSidereal=nil then TrackSidereal:=IUFindSwitch(TrackM,'SIDEREAL');
TrackLunar:=IUFindSwitch(TrackM,'TRACK_LUNAR');
if TrackLunar=nil then TrackLunar:=IUFindSwitch(TrackM,'LUNAR');
TrackSolar:=IUFindSwitch(TrackM,'TRACK_SOLAR');
if TrackSolar=nil then TrackSolar:=IUFindSwitch(TrackM,'SOLAR');
TrackCustom:=IUFindSwitch(TrackM,'TRACK_CUSTOM');
if TrackCustom=nil then TrackCustom:=IUFindSwitch(TrackM,'CUSTOM');
if (TrackSidereal=nil)or(TrackLunar=nil)or(TrackSolar=nil)or(TrackCustom=nil) then TrackM:=nil;
end
else if (proptype=INDI_SWITCH)and(propname='TELESCOPE_TRACK_STATE') then begin
TrackSt:=indiProp.getSwitch;
TrackOn:=IUFindSwitch(TrackSt,'TRACK_ON');
TrackOff:=IUFindSwitch(TrackSt,'TRACK_OFF');
if (TrackOn=nil)or(TrackOff=nil) then TrackSt:=nil;
end
else if (proptype=INDI_SWITCH)and(propname='ON_COORD_SET') then begin
CoordSet:=indiProp.getSwitch;
CoordSetTrack:=IUFindSwitch(CoordSet,'TRACK');
CoordSetSlew:=IUFindSwitch(CoordSet,'SLEW');
CoordSetSync:=IUFindSwitch(CoordSet,'SYNC');
if (CoordSetTrack=nil)or(CoordSetSlew=nil)or(CoordSetSync=nil) then CoordSet:=nil;
end
else if (proptype=INDI_SWITCH)and(propname='TELESCOPE_PARK') then begin
Park_opt:=indiProp.getSwitch;
end
else if (proptype=INDI_NUMBER)and(propname='GEOGRAPHIC_COORD') then begin
geo_coord:=indiProp.getNumber;
geo_lat:=IUFindNumber(geo_coord,'LAT');
geo_lon:=IUFindNumber(geo_coord,'LONG');
geo_ele:=IUFindNumber(geo_coord,'ELEV');
if (geo_lat=nil)or(geo_lon=nil)or(geo_ele=nil) then geo_coord:=nil;
end
else if (proptype=INDI_NUMBER)and(propname='GUIDE_RATE') then begin
guide_rate:=indiProp.getNumber;
guide_rateNS:=IUFindNumber(guide_rate,'GUIDE_RATE_NS');
guide_rateWE:=IUFindNumber(guide_rate,'GUIDE_RATE_WE');
if (guide_rateNS=nil)or(guide_rateWE=nil) then guide_rate:=nil;
if Assigned(FonGuideRateChange) then FonGuideRateChange(self);
end
else if (proptype=INDI_SWITCH)and(propname='ALIGNMODE') then begin
AlignMode:=indiProp.getSwitch;
for i:=0 to AlignMode.nsp-1 do begin
FAlignmentMode.Add(AlignMode.sp[i].lbl);
end;
end
else if (proptype=INDI_NUMBER)and(propname='ALIGNCOUNT') then begin
AlignCount:=indiProp.getNumber;
AlignCountPoint:=IUFindNumber(AlignCount,'ALIGNCOUNT_POINTS');
AlignCountTriangle:=IUFindNumber(AlignCount,'ALIGNCOUNT_TRIANGLES');
if (AlignCountPoint=nil)or(AlignCountTriangle=nil) then AlignCount:=nil;
end
else if (proptype=INDI_SWITCH)and(propname='ALIGNLIST') then begin
AlignList:=indiProp.getSwitch;
AlignListAdd:=IUFindSwitch(AlignList,'ALIGNLISTADD');
AlignListClear:=IUFindSwitch(AlignList,'ALIGNLISTCLEAR');
AlignListWrite:=IUFindSwitch(AlignList,'ALIGNWRITEFILE');
AlignListLoad:=IUFindSwitch(AlignList,'ALIGNLOADFILE');
if (AlignListAdd=nil)or(AlignListClear=nil)or(AlignListWrite=nil)or(AlignListLoad=nil) then AlignList:=nil;
end
else if (proptype=INDI_TEXT)and(propname='ALIGNDATAFILE') then begin
AlignDataFile:=indiProp.getText;
end
else if (proptype=INDI_SWITCH)and(propname='ALIGNSYNCMODE') then begin
AlignSyncMode:=indiProp.getSwitch;
for i:=0 to AlignSyncMode.nsp-1 do begin
FSyncMode.Add(AlignSyncMode.sp[i].lbl);
end;
end
else if (proptype=INDI_SWITCH)and(propname='SYNCMANAGE') then begin
SyncManage:=indiProp.getSwitch;
SyncClearDelta:=IUFindSwitch(SyncManage,'SYNCCLEARDELTA');
if (SyncClearDelta=nil) then SyncManage:=nil;
end
else if (proptype=INDI_NUMBER)and(propname='STANDARDSYNC') then begin
StandardSync:=indiProp.getNumber;
SyncDeltaRA:=IUFindNumber(StandardSync,'STANDARDSYNC_RA');
SyncDeltaDE:=IUFindNumber(StandardSync,'STANDARDSYNC_DE');
if (SyncDeltaRA=nil)or(SyncDeltaDE=nil) then StandardSync:=nil;
end
else if (proptype=INDI_SWITCH)and(propname='CONFIG_PROCESS') then begin
configprop:=indiProp.getSwitch;
configload:=IUFindSwitch(configprop,'CONFIG_LOAD');
configsave:=IUFindSwitch(configprop,'CONFIG_SAVE');
configdefault:=IUFindSwitch(configprop,'CONFIG_DEFAULT');
if (configload=nil)or(configsave=nil)or(configdefault=nil) then configprop:=nil;
end
;
CheckStatus;
end;
procedure T_indieqmod.NewNumber(nvp: INumberVectorProperty);
begin
if nvp=coord_prop then begin
if Assigned(FonCoordChange) then FonCoordChange(self);
end else if nvp=horz_prop then begin
if Assigned(FonAltAZChange) then FonAltAZChange(self);
end else if nvp=Mlst then begin
if Assigned(FonLSTChange) then FonLSTChange(self);
end else if nvp=SlewSpeed then begin
if Assigned(FonSlewSpeedChange) then FonSlewSpeedChange(self);
end else if nvp=TrackR then begin
if Assigned(FonTrackRateChange) then FonTrackRateChange(self);
end else if nvp=geo_coord then begin
if Assigned(FonGeoCoordChange) then FonGeoCoordChange(self);
end else if nvp=guide_rate then begin
if Assigned(FonGuideRateChange) then FonGuideRateChange(self);
end else if nvp=AlignCount then begin
if Assigned(FonAlignCountChange) then FonAlignCountChange(self);
end else if nvp=StandardSync then begin
if Assigned(FonSyncDeltaChange) then FonSyncDeltaChange(self);
end;
end;
procedure T_indieqmod.NewText(tvp: ITextVectorProperty);
begin
// writeln('NewText: '+tvp.name+' '+tvp.tp[0].text);
end;
procedure T_indieqmod.NewSwitch(svp: ISwitchVectorProperty);
begin
if svp=PierSide then begin
if Assigned(FonPierSideChange) then FonPierSideChange(self);
end else if svp=SlewMode then begin
if Assigned(FonSlewModeChange) then FonSlewModeChange(self);
end else if svp=RevDec then begin
if Assigned(FonRevDecChange) then FonRevDecChange(self);
end else if svp=CoordSet then begin
if (CoordSetSync.s=ISS_ON) and Assigned(FonSync) then FonSync(self);
end else if svp=TrackM then begin
if Assigned(FonTrackModeChange) then FonTrackModeChange(self);
end else if svp=TrackSt then begin
if Assigned(FonTrackModeChange) then FonTrackModeChange(self);
end else if svp=Park_opt then begin
if Assigned(FonParkChange) then FonParkChange(self);
end else if svp=AlignMode then begin
if Assigned(FonAlignmentModeChange) then FonAlignmentModeChange(self);
end else if svp=AlignSyncMode then begin
if Assigned(FonSyncModeChange) then FonSyncModeChange(self);
end else if svp=AbortMotion then begin
if Assigned(FonAbortMotion) then FonAbortMotion(self);
end;
end;
procedure T_indieqmod.NewLight(lvp: ILightVectorProperty);
begin
// writeln('NewLight: '+lvp.name);
end;
function T_indieqmod.GetRA:double;
begin
if coord_prop<>nil then begin;
result:=coord_ra.value;
end
else result:=NullCoord;
end;
function T_indieqmod.GetDec:double;
begin
if coord_prop<>nil then begin;
result:=coord_dec.value;
end
else result:=NullCoord;
end;
function T_indieqmod.GetAZ:double;
begin
if horz_prop<>nil then begin;
result:=horz_az.value;
end
else result:=NullCoord;
end;
function T_indieqmod.GetALT:double;
begin
if horz_prop<>nil then begin;
result:=horz_alt.value;
end
else result:=NullCoord;
end;
function T_indieqmod.GetLST:double;
begin
if Mlst<>nil then begin;
result:=Mlst.np[0].value;
end
else result:=0;
end;
function T_indieqmod.GetEquinox: double;
begin
if eod_coord then result:=0
else result:=2000;
end;
function T_indieqmod.GetAperture:double;
begin
if TelescopeInfo<>nil then begin;
result:=TelescopeAperture.value;
end
else result:=-1;
end;
function T_indieqmod.GetFocaleLength:double;
begin
if TelescopeInfo<>nil then begin;
result:=TelescopeFocale.value;
end
else result:=-1;
end;
function T_indieqmod.GetPierSideLbl: string;
var sw:ISwitch;
begin
if PierSide<>nil then begin
sw:=IUFindOnSwitch(PierSide);
if sw<>nil then
result:=sw.lbl
else
result:='?';
end
else result:='?';
end;
function T_indieqmod.GetRevDec: boolean;
begin
if RevDec<>nil then begin
result:=RevDec.sp[0].s=ISS_ON;
end;
end;
procedure T_indieqmod.SetRevDec(value: boolean);
begin
if RevDec<>nil then begin
IUResetSwitch(RevDec);
if value then
RevDec.sp[0].s:=ISS_ON
else
RevDec.sp[1].s:=ISS_ON;
sendNewSwitch(RevDec);
end;
end;
procedure T_indieqmod.MotionNorth;
begin
if MotionNS<>nil then begin;
IUResetSwitch(MotionNS);
MotionN.s:=ISS_ON;
sendNewSwitch(MotionNS);
end;
end;
procedure T_indieqmod.MotionSouth;
begin
if MotionNS<>nil then begin;
IUResetSwitch(MotionNS);
MotionS.s:=ISS_ON;
sendNewSwitch(MotionNS);
end;
end;
procedure T_indieqmod.MotionWest;
begin
if MotionWE<>nil then begin;
IUResetSwitch(MotionWE);
MotionW.s:=ISS_ON;
sendNewSwitch(MotionWE);
end;
end;
procedure T_indieqmod.MotionEast;
begin
if MotionWE<>nil then begin;
IUResetSwitch(MotionWE);
MotionE.s:=ISS_ON;
sendNewSwitch(MotionWE);
end;
end;
procedure T_indieqmod.MotionNorthStop;
begin
if MotionNS<>nil then begin;
IUResetSwitch(MotionNS);
sendNewSwitch(MotionNS);
end;
end;
procedure T_indieqmod.MotionSouthStop;
begin
if MotionNS<>nil then begin;
IUResetSwitch(MotionNS);
sendNewSwitch(MotionNS);
end;
end;
procedure T_indieqmod.MotionWestStop;
begin
if MotionWE<>nil then begin;
IUResetSwitch(MotionWE);
sendNewSwitch(MotionWE);
end;
end;
procedure T_indieqmod.MotionEastStop;
begin
if MotionWE<>nil then begin;
IUResetSwitch(MotionWE);
sendNewSwitch(MotionWE);
end;
end;
procedure T_indieqmod.MotionStop;
begin
if (MotionNS<>nil)and(MotionWE<>nil) then begin;
IUResetSwitch(MotionNS);
sendNewSwitch(MotionNS);
IUResetSwitch(MotionWE);
sendNewSwitch(MotionWE);
end;
end;
function T_indieqmod.GetRASlewSpeed:integer;
begin
if SlewSpeed<>nil then begin
result:=trunc(RAslew.value);
if result=0 then result:=1;
end;
end;
procedure T_indieqmod.SetRASlewSpeed(value:integer);
begin
if SlewSpeed<>nil then begin
RAslew.value:=value;
sendNewNumber(SlewSpeed);
end;
end;
function T_indieqmod.GetDESlewSpeed:integer;
begin
if SlewSpeed<>nil then begin
result:=trunc(DEslew.value);
if result=0 then result:=1;
end;
end;
procedure T_indieqmod.SetDESlewSpeed(value:integer);
begin
if SlewSpeed<>nil then begin
DEslew.value:=value;
sendNewNumber(SlewSpeed);
end;
end;
function T_indieqmod.GetRASlewSpeedRange: TNumRange;
begin
if SlewSpeed<>nil then begin
result.min:=RAslew.min;
result.max:=RAslew.max;
result.step:=RAslew.step;
end;
end;
function T_indieqmod.GetDESlewSpeedRange: TNumRange;
begin
if SlewSpeed<>nil then begin
result.min:=DEslew.min;
result.max:=DEslew.max;
result.step:=DEslew.step;
end;
end;
function T_indieqmod.GetActiveSlewPreset: integer;
var i: integer;
begin
if SlewMode<>nil then begin
for i := 0 to SlewMode.nsp-1 do
if SlewMode.sp[i].s = ISS_ON then
exit(i);
end;
end;
procedure T_indieqmod.SetActiveSlewPreset(value: integer);
begin
if SlewMode<>nil then begin
IUResetSwitch(SlewMode);
SlewMode.sp[value].s := ISS_ON;
sendNewSwitch(SlewMode);
end;
end;