Commit f7c87549982073d01be747665969e7bd5c16856b

Authored by Alain Klotz
1 parent 4412c00f
Exists in master

update FLIPro

src/guitastro_device_flipro/component_sensor_detector_flipro.py
... ... @@ -109,7 +109,7 @@ class ComponentSensorDetectorFliproDoAcq(Thread):
109 109 class ComponentSensorDetectorFlipro(ComponentSensorDetector):
110 110 """Component for Sensor Detector Flipro
111 111  
112   - Usage : ComponentSensorDetectorFlipro("Z", name="test")
  112 + Usage : ComponentSensorDetectorFlipro("CMOS", name="test")
113 113 """
114 114  
115 115 NO_ERROR = 0
... ... @@ -174,15 +174,6 @@ class ComponentSensorDetectorFlipro(ComponentSensorDetector):
174 174  
175 175 # ------------ get
176 176  
177   - """
178   - def _get_real_motions(self):
179   - # motion_real has been updated by the thread goto
180   - motion = self.MOTION_STATE_UNKNOWN
181   - if self.real == True:
182   - motion = self.database.query("motion_real")
183   - return motion
184   - """
185   -
186 177 def _my_get_final(self, *args, **kwargs):
187 178 key = args[0]
188 179 if key == "timer":
... ... @@ -192,6 +183,14 @@ class ComponentSensorDetectorFlipro(ComponentSensorDetector):
192 183 # --- Update database
193 184 self._queue.put(param)
194 185 return timer
  186 + if key == "metadata":
  187 + metadata = self._wrapper_flipro.metadata()
  188 + param = {}
  189 + param["metadata"] = metadata
  190 + # --- Update database
  191 + self._queue.put(param)
  192 + #time.sleep(0.1)
  193 + return metadata
195 194 return None
196 195  
197 196 # ------------ protected misc methods
... ...
src/guitastro_device_flipro/device_flipro.py
... ... @@ -14,9 +14,14 @@ except:
14 14 from component_detector_shutter_flipro import ComponentDetectorShutterFlipro
15 15  
16 16 try:
17   - import wrapper_flipro
  17 + from .component_detector_timer_flipro import ComponentDetectorTimerFlipro
18 18 except:
19   - pass
  19 + from component_detector_timer_flipro import ComponentDetectorTimerFlipro
  20 +
  21 +#try:
  22 +# import wrapper_flipro
  23 +#except:
  24 +# pass
20 25  
21 26 try:
22 27 # guitastro is installed with setup.py
... ... @@ -33,6 +38,7 @@ except:
33 38 sys.path.insert(0, path)
34 39 from guitastro.device import Device
35 40 #from guitastro.ephemeris import Ephemeris
  41 +
36 42 import wrapper_flipro
37 43  
38 44 # #####################################################################
... ... @@ -102,6 +108,8 @@ class Device_Flipro(Device):
102 108 self._comp["camera"].database.query(param)
103 109 # --- init component detector camera
104 110 self._comp["shutter"] = ComponentDetectorShutterFlipro("IRIS", name=name+" shutter", model="Flipro Kepler 4040", manufacturer="Finger Lakes Instruments", description="Integrated shutter", wrapper_flipro=wrapper_flipro)
  111 + # --- init component detector camera
  112 + self._comp["timer"] = ComponentDetectorTimerFlipro("GPS", name=name+" GPS", model="Flipro Kepler 4040", manufacturer="Finger Lakes Instruments", description="Optional GPS timer", wrapper_flipro=wrapper_flipro)
105 113 # ---
106 114 time.sleep(0.1) # time to let the loop of param init
107 115  
... ... @@ -127,13 +135,14 @@ class Device_Flipro(Device):
127 135 #print(f"{key} = {val}")
128 136 self._comp["camera"].database.query(param)
129 137  
130   -
131 138 def _my_close(self):
132 139 #print("Device_Flipro _my_close")
133 140 if self._real:
134 141 wrapper_flipro.close()
135 142  
136 143 def __del__(self):
  144 + #print("Device_Flipro __del__ timer")
  145 + self._comp["timer"].__del__()
137 146 #print("Device_Flipro __del__ shutter")
138 147 self._comp["shutter"].__del__()
139 148 #print("Device_Flipro __del__ camera")
... ... @@ -243,12 +252,24 @@ if __name__ == "__main__":
243 252 # ------------------------
244 253 cam = dev.components['camera'][1]
245 254 shutter = dev.components['shutter'][1]
  255 + timer = dev.components['timer'][1]
  256 + # ------------------------
  257 + cmd = "camera GET metadata"
  258 + print("*"*20,f"\ncmd => \"{cmd}\"")
  259 + res = dev.commandstring(cmd)
  260 + for key, val in res.items():
  261 + print(f"{key} = {val}")
246 262 # ------------------------
247 263 cmd = "shutter DO OPEN"
248 264 print("*"*20,f"\ncmd => \"{cmd}\"")
249 265 dev.commandstring(cmd)
250 266 time.sleep(5)
251 267 # ------------------------
  268 + cmd = "timer GET date"
  269 + print("*"*20,f"\ncmd => \"{cmd}\"")
  270 + iso = dev.commandstring(cmd)
  271 + print(f"{iso}")
  272 + # ------------------------
252 273 cmd = "shutter DO SYNCHRO"
253 274 print("*"*20,f"\ncmd => \"{cmd}\"")
254 275 dev.commandstring(cmd)
... ...
src/wrapper_flipro/wrapper_flipro.cpp
... ... @@ -104,7 +104,16 @@ void dict_append_d(PyObject* dico, const char* key, int value, const char* comme
104 104 Py_DECREF(mylist);
105 105 }
106 106  
107   -void dict_append_s(PyObject* dico, const char* key, wchar_t *value, const char* comment) {
  107 +void dict_append_f(PyObject* dico, const char* key, double value, const char* comment) {
  108 + PyObject *mylist;
  109 + mylist = PyList_New(2);
  110 + PyList_SetItem(mylist, 0, Py_BuildValue("d", value));
  111 + PyList_SetItem(mylist, 1, Py_BuildValue("s", comment));
  112 + PyDict_SetItemString(dico, key, mylist);
  113 + Py_DECREF(mylist);
  114 +}
  115 +
  116 +void dict_append_w(PyObject* dico, const char* key, wchar_t *value, const char* comment) {
108 117 int nline = 10000;
109 118 char line[10000];
110 119 wcstombs(line, value, nline);
... ... @@ -116,6 +125,15 @@ void dict_append_s(PyObject* dico, const char* key, wchar_t *value, const char*
116 125 Py_DECREF(mylist);
117 126 }
118 127  
  128 +void dict_append_s(PyObject* dico, const char* key, char *value, const char* comment) {
  129 + PyObject *mylist;
  130 + mylist = PyList_New(2);
  131 + PyList_SetItem(mylist, 0, Py_BuildValue("s", value));
  132 + PyList_SetItem(mylist, 1, Py_BuildValue("s", comment));
  133 + PyDict_SetItemString(dico, key, mylist);
  134 + Py_DECREF(mylist);
  135 +}
  136 +
119 137 // ===================================================================================
120 138 // ===================================================================================
121 139 // === camera devices
... ... @@ -510,8 +528,8 @@ static PyObject* FingerlakesProDeviceInfo(PyObject* self, PyObject* args) {
510 528 FPRODEVICEINFO s_camDeviceInfo_selected = cam.s_camDeviceInfo_selected;
511 529 FPRODEVICEVERS device_version_info = cam.device_version_info;
512 530 PyObject* dico = PyDict_New();
513   - dict_append_s(dico, "cFriendlyName", s_camDeviceInfo_selected.cFriendlyName, "Human readable friendly name of the USB device. This string along with the cSerialNo field provide a unique name for your device suitable for a user interface");
514   - dict_append_s(dico, "cSerialNo", s_camDeviceInfo_selected.cSerialNo, "The manufacturing serial number of the device");
  531 + dict_append_w(dico, "cFriendlyName", s_camDeviceInfo_selected.cFriendlyName, "Human readable friendly name of the USB device. This string along with the cSerialNo field provide a unique name for your device suitable for a user interface");
  532 + dict_append_w(dico, "cSerialNo", s_camDeviceInfo_selected.cSerialNo, "The manufacturing serial number of the device");
515 533 dict_append_d(dico, "uiVendorId", s_camDeviceInfo_selected.conInfo.uiVendorId, "The USB vendor ID. This field is applicable only when the eCOnnType is USB");
516 534 dict_append_d(dico, "uiProdId", s_camDeviceInfo_selected.conInfo.uiProdId, "The USB Product ID. This field is applicable only when the eCOnnType is USB");
517 535 if (s_camDeviceInfo_selected.conInfo.eConnType == FPROCONNECTION::FPRO_CONNECTION_USB) {
... ... @@ -521,11 +539,11 @@ static PyObject* FingerlakesProDeviceInfo(PyObject* self, PyObject* args) {
521 539 } else {
522 540 wcscpy(value, L"UNKNOWN");
523 541 }
524   - dict_append_s(dico, "eConnType", value, "The physical connection type");
525   - dict_append_s(dico, "cFirmwareVersion", device_version_info.cFirmwareVersion, "Firmware version");
526   - dict_append_s(dico, "cFPGAVersion", device_version_info.cFPGAVersion, "FPGA version");
527   - dict_append_s(dico, "cControllerVersion", device_version_info.cControllerVersion, "Controller version");
528   - dict_append_s(dico, "cHostHardwareVersion", device_version_info.cHostHardwareVersion, "Host Hardware version");
  542 + dict_append_w(dico, "eConnType", value, "The physical connection type");
  543 + dict_append_w(dico, "cFirmwareVersion", device_version_info.cFirmwareVersion, "Firmware version");
  544 + dict_append_w(dico, "cFPGAVersion", device_version_info.cFPGAVersion, "FPGA version");
  545 + dict_append_w(dico, "cControllerVersion", device_version_info.cControllerVersion, "Controller version");
  546 + dict_append_w(dico, "cHostHardwareVersion", device_version_info.cHostHardwareVersion, "Host Hardware version");
529 547 return dico;
530 548 }
531 549 #elif LIB == 1
... ... @@ -534,27 +552,27 @@ static PyObject* FingerlakesProDeviceInfo(PyObject* self, PyObject* args) {
534 552 FPRODEVICEINFO s_camDeviceInfo_selected = cam.s_camDeviceInfo_selected;
535 553 FPRODEVICEVERS device_version_info = cam.device_version_info;
536 554 PyObject* dico = PyDict_New();
537   - dict_append_s(dico, "cFriendlyName", s_camDeviceInfo_selected.cFriendlyName, "Human readable friendly name of the USB device. This string along with the cSerialNo field provide a unique name for your device suitable for a user interface");
538   - dict_append_s(dico, "cSerialNo", s_camDeviceInfo_selected.cSerialNo, "The manufacturing serial number of the device");
  555 + dict_append_w(dico, "cFriendlyName", s_camDeviceInfo_selected.cFriendlyName, "Human readable friendly name of the USB device. This string along with the cSerialNo field provide a unique name for your device suitable for a user interface");
  556 + dict_append_w(dico, "cSerialNo", s_camDeviceInfo_selected.cSerialNo, "The manufacturing serial number of the device");
539 557 dict_append_d(dico, "uiVendorId", s_camDeviceInfo_selected.uiVendorId, "The USB vendor ID. This field is applicable only when the eCOnnType is USB");
540 558 dict_append_d(dico, "uiProdId", s_camDeviceInfo_selected.uiProdId, "The USB Product ID. This field is applicable only when the eCOnnType is USB");
541 559 if (s_camDeviceInfo_selected.eConnType == FPRO_CONNECTION_USB) {
542   - dict_append_s(dico, "eConnType", L"USB", "The physical connection type");
  560 + dict_append_w(dico, "eConnType", L"USB", "The physical connection type");
543 561 strcpy(line, "The USB connection speed of the device. This field is applicable only when the eCOnnType is FPRO_CONNECTION_USB. FLI Cameras require a FPRO_USB_SUPERSPEED USB connection in order to transfer image data reliably");
544 562 if (s_camDeviceInfo_selected.eUSBSpeed == FPRO_USB_FULLSPEED) {
545   - dict_append_s(dico, "eUSBSpeed", L"FULLSPEED", line);
  563 + dict_append_w(dico, "eUSBSpeed", L"FULLSPEED", line);
546 564 } else if (s_camDeviceInfo_selected.eUSBSpeed == FPRO_USB_HIGHSPEED) {
547   - dict_append_s(dico, "eUSBSpeed", L"HIGHSPEED", line);
  565 + dict_append_w(dico, "eUSBSpeed", L"HIGHSPEED", line);
548 566 } else if (s_camDeviceInfo_selected.eUSBSpeed == FPRO_USB_SUPERSPEED) {
549   - dict_append_s(dico, "eUSBSpeed", L"SUPERSPEED", line);
  567 + dict_append_w(dico, "eUSBSpeed", L"SUPERSPEED", line);
550 568 }
551 569 } else if (s_camDeviceInfo_selected.eConnType == FPRO_CONNECTION_FIBRE) {
552   - dict_append_s(dico, "eConnType", L"FIBRE", "The physical connection type");
  570 + dict_append_w(dico, "eConnType", L"FIBRE", "The physical connection type");
553 571 }
554   - dict_append_s(dico, "cFirmwareVersion", device_version_info.cFirmwareVersion, "Firmware version");
555   - dict_append_s(dico, "cFPGAVersion", device_version_info.cFPGAVersion, "FPGA version");
556   - dict_append_s(dico, "cControllerVersion", device_version_info.cControllerVersion, "Controller version");
557   - dict_append_s(dico, "cHostHardwareVersion", device_version_info.cHostHardwareVersion, "Host Hardware version");
  572 + dict_append_w(dico, "cFirmwareVersion", device_version_info.cFirmwareVersion, "Firmware version");
  573 + dict_append_w(dico, "cFPGAVersion", device_version_info.cFPGAVersion, "FPGA version");
  574 + dict_append_w(dico, "cControllerVersion", device_version_info.cControllerVersion, "Controller version");
  575 + dict_append_w(dico, "cHostHardwareVersion", device_version_info.cHostHardwareVersion, "Host Hardware version");
558 576 return dico;
559 577 }
560 578 #endif
... ... @@ -867,8 +885,7 @@ static PyObject* Merge(PyObject* self, PyObject* args) {
867 885  
868 886 */
869 887 const char *algo;
870   - char path[DIM_S];
871   - char method[DIM_S];
  888 + const char *method;
872 889 char ligne[DIM_S];
873 890  
874 891 // args
... ... @@ -881,8 +898,6 @@ static PyObject* Merge(PyObject* self, PyObject* args) {
881 898 PyObject* obj7=NULL;
882 899 PyObject* obj8=NULL;
883 900 PyObject* obj9=NULL;
884   -
885   - strcpy(path, ".");
886 901  
887 902 if (PyTuple_GET_SIZE(args) == 0) {
888 903 strcpy(cam.msg, "Usage : merge algo(fli|lin) ?params?");
... ... @@ -905,13 +920,14 @@ static PyObject* Merge(PyObject* self, PyObject* args) {
905 920 } else if (cam.merge_algo == MERGE_ALGO_LIN) {
906 921 // algo=lin
907 922 if (obj1 != NULL) {
908   - PyArg_ParseTuple(obj1, "s", method);
  923 + PyArg_ParseTuple(obj1, "s", &method);
909 924 if (strcmp(method, "makebias") == 0) {
910 925 cam.merge_lin_mode = MERGE_LIN_MODE_MAKEBIAS;
911 926 io_buffer_change_mode(&cam, 2);
912 927 }
913 928 else if (strcmp(method, "loadbias") == 0) {
914   - PyArg_ParseTuple(obj2, "s", path);
  929 + const char *path;
  930 + PyArg_ParseTuple(obj2, "s", &path);
915 931 char filename[DIM_S];
916 932 int naxis1, naxis2;
917 933 // --- bin1_low
... ... @@ -1127,6 +1143,59 @@ static PyObject* Library(PyObject* self, PyObject* args) {
1127 1143 return Py_BuildValue("i", LIB);
1128 1144 }
1129 1145  
  1146 +static PyObject* Metadata(PyObject* self, PyObject* args) {
  1147 + PyObject* dico = PyDict_New();
  1148 + dict_append_s(dico, "MagicNumber", cam.metadata.MagicNumber, "Magic number of the metatadata header");
  1149 + dict_append_d(dico, "MetadataLength", cam.metadata.MetadataLength, "Length of the metatadata header");
  1150 + dict_append_d(dico, "MetadataVersion", cam.metadata.MetadataVersion, "Version of the metatadata header");
  1151 + dict_append_s(dico, "CameraModel", cam.metadata.CameraModel, "Camera model");
  1152 + dict_append_s(dico, "CameraSerialNumber", cam.metadata.CameraSerialNumber, "Serial number of the camera");
  1153 + dict_append_d(dico, "FirmwareVersion", cam.metadata.FirmwareVersion, "Firmware version of the board");
  1154 + dict_append_f(dico, "TemperatureSetPoint", cam.metadata.TemperatureSetPoint, "Temperature set point (deg C)");
  1155 + dict_append_f(dico, "CoolerDutyCycle", cam.metadata.CoolerDutyCycle, "Cooler duty cycle (percent)");
  1156 + dict_append_d(dico, "HorizontalPixels", cam.metadata.HorizontalPixels, "Number of horizontal photocells");
  1157 + dict_append_d(dico, "VerticalPixels", cam.metadata.VerticalPixels, "Number of vertical photocells");
  1158 + dict_append_d(dico, "ExposureTime", cam.metadata.ExposureTime, "Exposure time (10.32e-6 s)");
  1159 + dict_append_f(dico, "SensorColdTemp", cam.metadata.SensorColdTemp, "Sensor cold finger temperature (deg C)");
  1160 + dict_append_f(dico, "SensorTemp", cam.metadata.SensorTemp, "Sensor temperature (deg C)");
  1161 + dict_append_d(dico, "GlobalGain", cam.metadata.GlobalGain, "Global gain adu)");
  1162 + dict_append_d(dico, "LowGain", cam.metadata.LowGain, "Low gain (adu)");
  1163 + dict_append_d(dico, "HighGain", cam.metadata.HighGain, "High gain (adu)");
  1164 + dict_append_d(dico, "PostRefPixelsPerRow", cam.metadata.PostRefPixelsPerRow, "Number of reference cells after the row");
  1165 + dict_append_d(dico, "PreRefPixelsPerRow", cam.metadata.PreRefPixelsPerRow, "Number of reference cells before the row");
  1166 + dict_append_d(dico, "ControlBlock", cam.metadata.ControlBlock, "Control block (0-255)");
  1167 + dict_append_d(dico, "BlackLevelAdjust", cam.metadata.BlackLevelAdjust, "Black level adjust (0-65535)");
  1168 + dict_append_d(dico, "BlackLevelSun", cam.metadata.BlackLevelSun, "Black level Sun (0-65535)");
  1169 + dict_append_d(dico, "ShutterOpenDelay", cam.metadata.ShutterOpenDelay, "Shutter open delay (0-65535)");
  1170 + dict_append_d(dico, "ShutterCloseDelay", cam.metadata.ShutterCloseDelay, "Shutter close delay (0-65535)");
  1171 + dict_append_d(dico, "IlluminStartDelay", cam.metadata.IlluminStartDelay, "Illumination start delay (0-65535)");
  1172 + dict_append_d(dico, "IlluminStopDelay", cam.metadata.IlluminStopDelay, "Illumination stop delay (0-65535)");
  1173 + dict_append_d(dico, "TrackingStartRow", cam.metadata.TrackingStartRow, "Tracking start row (0-65535)");
  1174 + dict_append_d(dico, "TrackingStartColumn", cam.metadata.TrackingStartColumn, "Tracking start column (0-65535)");
  1175 + dict_append_d(dico, "TrackingStopRow", cam.metadata.TrackingStopRow, "Image start row (0-65535)");
  1176 + dict_append_d(dico, "TrackingStopColumn", cam.metadata.TrackingStopColumn, "Image start column (0-65535)");
  1177 + dict_append_d(dico, "ImageStartRow", cam.metadata.ImageStartRow, "Image stop row (0-65535)");
  1178 + dict_append_d(dico, "ImageStartColumn", cam.metadata.ImageStartColumn, "Image start column (0-65535)");
  1179 + dict_append_d(dico, "ImageStopRow", cam.metadata.ImageStopRow, "Image stop row (0-65535)");
  1180 + dict_append_d(dico, "ImageStopColumn", cam.metadata.ImageStopColumn, "Image stop column (0-65535)");
  1181 + dict_append_d(dico, "TrackingFramesPerImageFrame", cam.metadata.TrackingFramesPerImageFrame, "Number of tracking frame per image frame");
  1182 + dict_append_d(dico, "FrameNumber", cam.metadata.FrameNumber, "Frame number");
  1183 + dict_append_d(dico, "StartingExposureRow", cam.metadata.StartingExposureRow, "Starting exposure row");
  1184 + dict_append_d(dico, "PreReferenceRows", cam.metadata.PreReferenceRows, "Pre reference rows");
  1185 + dict_append_d(dico, "PostReferenceRows", cam.metadata.PostReferenceRows, "Post reference rows");
  1186 + dict_append_d(dico, "NumberOfDataChannels", cam.metadata.NumberOfDataChannels, "Number of data channels");
  1187 + dict_append_d(dico, "ControlBlock2", cam.metadata.ControlBlock2, "Control block 2");
  1188 + dict_append_s(dico, "CaptureDateString", cam.metadata.CaptureDateString, "Capture date string");
  1189 + dict_append_f(dico, "Latitude", cam.metadata.Latitude, "Latitude (degrees)");
  1190 + dict_append_f(dico, "Longitude", cam.metadata.Longitude, "Longitude east positive (degrees)");
  1191 + dict_append_s(dico, "LibFliProVersion", cam.metadata.LibFliProVersion, "Version of the library");
  1192 + dict_append_f(dico, "HorizontalPixelSize", cam.metadata.HorizontalPixelSize, "Horizontal pixel size (m)");
  1193 + dict_append_f(dico, "VerticalPixelSize", cam.metadata.VerticalPixelSize, "Vertical pixel size (m)");
  1194 + dict_append_d(dico, "BlackLevelAdjustHigh", cam.metadata.BlackLevelAdjustHigh, "Black level adjust high (0-65535)");
  1195 + dict_append_d(dico, "BlackLevelSunHigh", cam.metadata.BlackLevelSunHigh, "Black level Sun high (0-65535)");
  1196 + return dico;
  1197 +}
  1198 +
1130 1199 // =====================================================================
1131 1200 // =====================================================================
1132 1201 // Python extension - Test functions
... ... @@ -1212,6 +1281,7 @@ static PyMethodDef functions[] = {
1212 1281 {"ledduration", LedDuration, METH_VARARGS, "Get/set the LED duration (ms)"},
1213 1282 {"preflash", Preflash, METH_VARARGS, "Get/set the preflash state (use also ledduration)"},
1214 1283 {"library", Library, METH_VARARGS, "Get the FLI library version"},
  1284 + {"metadata", Metadata, METH_VARARGS, "Get the FLI metadata of the last image taken"},
1215 1285 // --- Tests
1216 1286 {"example2", example2, METH_VARARGS, "Une fonction levant une exception"},
1217 1287 {"matrix", matrix, METH_VARARGS, "Create a matrix"},
... ...