12
12
from astropy .io import fits
13
13
import astropy .coordinates
14
14
import astropy .units
15
+ import astropy .utils .iers
15
16
16
17
from picamera2 import Picamera2
17
18
from libcamera import controls , Rectangle
18
19
19
20
20
21
from .indidevice import *
21
22
22
- # From time to time astropy downloads the latest IERS-A table from internet.
23
- # If offline this will raise an error. Here we disable the auto update.
24
- from astropy .utils .iers import conf
25
- conf .auto_max_age = None
26
23
27
24
class CameraSettings :
28
25
"""exposure settings
@@ -217,8 +214,14 @@ class CameraControl:
217
214
def __init__ (self , parent , config ):
218
215
self .parent = parent
219
216
self .config = config
220
- self .do_CameraAdjustments = config .getboolean ("driver" , "CameraAdjustments" , fallback = True )
221
- self .IgnoreRawModes = config .getboolean ("driver" , "IgnoreRawModes" , fallback = False )
217
+ # From time to time astropy downloads the latest IERS-A table from internet.
218
+ # If offline this will raise an error. Here we disable the auto update.
219
+ if self .config .getboolean ("driver" , "enable_IERS_autoupdate" , fallback = True ):
220
+ astropy .utils .iers .conf .auto_max_age = None
221
+ astropy .utils .iers .conf .iers_degraded_accuracy = "ignore"
222
+ #
223
+ self .do_CameraAdjustments = self .config .getboolean ("driver" , "CameraAdjustments" , fallback = True )
224
+ self .IgnoreRawModes = self .config .getboolean ("driver" , "IgnoreRawModes" , fallback = False )
222
225
# reset states
223
226
self .picam2 = None
224
227
self .present_CameraSettings = CameraSettings ()
@@ -737,6 +740,7 @@ def __ExposureLoop(self):
737
740
self .Sig_ActionExpose .clear ()
738
741
if self .Sig_ActionExit .is_set ():
739
742
# exit exposure loop
743
+ #logger.error(f'DBG vor stop (line 744): {self.picam2.started=}') # FIXME
740
744
self .picam2 .stop_ ()
741
745
self .parent .setVector ("CCD_EXPOSURE" , "CCD_EXPOSURE_VALUE" , value = 0 , state = IVectorState .OK )
742
746
return
@@ -763,6 +767,7 @@ def __ExposureLoop(self):
763
767
if self .present_CameraSettings .is_ReconfigurationNeeded (NewCameraSettings ) or self .needs_Restarts :
764
768
logger .info (f'reconfiguring camera' )
765
769
# need a new camera configuration
770
+ #logger.error(f'DBG vor create_still_configuration: {self.picam2.started=}') # FIXME
766
771
config = self .picam2 .create_still_configuration (
767
772
queue = NewCameraSettings .DoFastExposure ,
768
773
buffer_count = 2 # 2 if NewCameraSettings.DoFastExposure else 1 # need at least 2 buffer for queueing
@@ -783,22 +788,27 @@ def __ExposureLoop(self):
783
788
#self.parent.setVector("CCD_FRAME", "HEIGHT", value=NewCameraSettings.ProcSize[1])
784
789
# optimize (align) configuration: small changes to some main stream configurations
785
790
# (for instance: size) will fit better to hardware
791
+ #logger.error(f'DBG vor align_configuration: {self.picam2.started=}') # FIXME
786
792
self .picam2 .align_configuration (config )
787
793
# set still configuration
794
+ #logger.error(f'DBG vor configure: {self.picam2.started=}') # FIXME
788
795
self .picam2 .configure (config )
789
796
# changing exposure time or analogue gain needs a restart
790
797
if IsRestartNeeded :
791
798
# change camera controls
799
+ #logger.error(f'DBG vor set_controls: {self.picam2.started=}') # FIXME
792
800
self .picam2 .set_controls (NewCameraSettings .get_controls ())
793
801
# start camera if not already running in Fast Exposure mode
794
802
if not self .picam2 .started :
803
+ #logger.error(f'DBG vor start (line 802): {self.picam2.started=}') # FIXME
795
804
self .picam2 .start ()
796
805
logger .debug (f'camera started' )
797
806
# camera runs now with new parameter
798
807
self .present_CameraSettings = NewCameraSettings
799
808
# last chance to exit or abort before doing exposure
800
809
if self .Sig_ActionExit .is_set ():
801
810
# exit exposure loop
811
+ #logger.error(f'DBG vor stop (line 811): {self.picam2.started=}') # FIXME
802
812
self .picam2 .stop_ ()
803
813
self .parent .setVector ("CCD_EXPOSURE" , "CCD_EXPOSURE_VALUE" , value = 0 , state = IVectorState .OK )
804
814
return
@@ -808,6 +818,7 @@ def __ExposureLoop(self):
808
818
# get (non-blocking!) frame and meta data
809
819
self .Sig_CaptureDone .clear ()
810
820
ExpectedEndOfExposure = time .time () + self .present_CameraSettings .ExposureTime
821
+ #logger.error(f'DBG vor capture_arrays: {self.picam2.started=}') # FIXME
811
822
job = self .picam2 .capture_arrays (
812
823
["raw" if self .present_CameraSettings .DoRaw else "main" ],
813
824
wait = False , signal_function = self .on_CaptureFinished ,
@@ -824,12 +835,15 @@ def __ExposureLoop(self):
824
835
# allow to close camera
825
836
if self .Sig_ActionExit .is_set ():
826
837
# exit exposure loop
838
+ #logger.error(f'DBG vor stop (line 838): {self.picam2.started=}') # FIXME
827
839
self .picam2 .stop_ ()
828
840
self .parent .setVector ("CCD_EXPOSURE" , "CCD_EXPOSURE_VALUE" , value = 0 , state = IVectorState .OK )
829
841
return
830
842
# allow to abort exposure
831
843
Abort = self .Sig_ActionAbort .is_set ()
832
844
if Abort :
845
+ #logger.error(f'DBG vor stop (line 846): {self.picam2.started=}') # FIXME
846
+ self .picam2 .stop_ () # stop exposure immediately
833
847
self .Sig_ActionAbort .clear ()
834
848
break
835
849
# allow exposure to finish earlier than expected (for instance when in fast exposure mode)
@@ -838,6 +852,7 @@ def __ExposureLoop(self):
838
852
time .sleep (PollingPeriod_s )
839
853
# get frame and its metadata
840
854
if not Abort :
855
+ #logger.error(f'DBG vor wait: {self.picam2.started=}') # FIXME
841
856
(array , ), metadata = self .picam2 .wait (job )
842
857
logger .info ('got exposed frame' )
843
858
# at least HQ camera reports CCD temperature in meta data
@@ -848,6 +863,7 @@ def __ExposureLoop(self):
848
863
# last chance to exit or abort before sending blob
849
864
if self .Sig_ActionExit .is_set ():
850
865
# exit exposure loop
866
+ #logger.error(f'DBG vor stop (line 864): {self.picam2.started=}') # FIXME
851
867
self .picam2 .stop_ ()
852
868
self .parent .setVector ("CCD_EXPOSURE" , "CCD_EXPOSURE_VALUE" , value = 0 , state = IVectorState .OK )
853
869
return
@@ -859,7 +875,8 @@ def __ExposureLoop(self):
859
875
FastCount_Frames = self .parent .knownVectors ["CCD_FAST_COUNT" ]["FRAMES" ].value
860
876
if not DoFastExposure :
861
877
# in normal exposure mode the camera needs to be started with exposure command
862
- self .picam2 .stop_ ()
878
+ #logger.error(f'DBG vor stop (line 876): {self.picam2.started=}') # FIXME
879
+ self .picam2 .stop ()
863
880
if not Abort :
864
881
if DoFastExposure :
865
882
FastCount_Frames -= 1
0 commit comments