From 63102172fc7b6bc80921467b4fcb3c08bf43e50e Mon Sep 17 00:00:00 2001 From: Romain Bazile Date: Sun, 29 Nov 2020 14:28:31 +0100 Subject: [PATCH] add sleep_before, closes #48 --- flows/main.json | 213 +++++++++++++++++++-------------- scripts/planktoscope/imager.py | 6 +- 2 files changed, 124 insertions(+), 95 deletions(-) diff --git a/flows/main.json b/flows/main.json index b933e74..641b080 100644 --- a/flows/main.json +++ b/flows/main.json @@ -734,60 +734,6 @@ "width": 4, "height": 1 }, - { - "id": "9698828d.faacb8", - "type": "ui_spacer", - "name": "spacer", - "group": "4322c187.e73e5", - "order": 6, - "width": 10, - "height": 1 - }, - { - "id": "52335429.3ccffc", - "type": "ui_spacer", - "name": "spacer", - "group": "4322c187.e73e5", - "order": 9, - "width": 10, - "height": 1 - }, - { - "id": "14361a81.e5f03d", - "type": "ui_spacer", - "name": "spacer", - "group": "b5d61bc7.54fe48", - "order": 2, - "width": 6, - "height": 1 - }, - { - "id": "d54e2186.0e6d2", - "type": "ui_spacer", - "name": "spacer", - "group": "b5d61bc7.54fe48", - "order": 3, - "width": 1, - "height": 1 - }, - { - "id": "ff5055f4.d3636", - "type": "ui_spacer", - "name": "spacer", - "group": "b5d61bc7.54fe48", - "order": 5, - "width": 1, - "height": 1 - }, - { - "id": "67ccad31.7b2c5c", - "type": "ui_spacer", - "name": "spacer", - "group": "b7919ae2.c01788", - "order": 2, - "width": 5, - "height": 1 - }, { "id": "b001a150.faa548", "type": "ui_spacer", @@ -815,6 +761,51 @@ "width": 10, "height": 1 }, + { + "id": "de621043.b31528", + "type": "ui_spacer", + "name": "spacer", + "group": "4322c187.e73e5", + "order": 7, + "width": 10, + "height": 1 + }, + { + "id": "b0a2c4ff.ce75b", + "type": "ui_spacer", + "name": "spacer", + "group": "b5d61bc7.54fe48", + "order": 2, + "width": 6, + "height": 1 + }, + { + "id": "f1326cca.4ab1f", + "type": "ui_spacer", + "name": "spacer", + "group": "b5d61bc7.54fe48", + "order": 3, + "width": 1, + "height": 1 + }, + { + "id": "a27ea76d.b9989", + "type": "ui_spacer", + "name": "spacer", + "group": "b5d61bc7.54fe48", + "order": 5, + "width": 1, + "height": 1 + }, + { + "id": "17a79a42.2912ce", + "type": "ui_spacer", + "name": "spacer", + "group": "b7919ae2.c01788", + "order": 2, + "width": 5, + "height": 1 + }, { "id": "4e78af2d.90be7", "type": "ui_ui_control", @@ -1653,7 +1644,7 @@ "delay": 300, "topic": "acq_id", "x": 650, - "y": 240, + "y": 280, "wires": [ [ "fb887036.12429", @@ -2090,6 +2081,11 @@ "value": 200, "type": "num" }, + { + "label": "300 µm capillary", + "value": 300, + "type": "num" + }, { "label": "400 μm µ-Slide I Luer", "value": 400, @@ -2109,7 +2105,7 @@ "payload": "", "topic": "acq_celltype", "x": 630, - "y": 80, + "y": 240, "wires": [ [ "fb887036.12429", @@ -2170,7 +2166,7 @@ "type": "function", "z": "b771c342.49603", "name": "Check form", - "func": "var sample_project= global.get(\"sample_project\");\nvar sample_ship= global.get(\"sample_ship\");\nvar sample_id= global.get(\"sample_id\");\nvar sample_operator= global.get(\"sample_operator\");\nvar sample_sampling_gear= global.get(\"sample_sampling_gear\");\nvar object_lat= global.get(\"object_lat\");\nvar object_lon= global.get(\"object_lon\");\nvar object_date= global.get(\"object_date\");\nvar object_time= global.get(\"object_time\");\n\nif (sample_project === undefined || sample_project === \"\") {\n msg.topic = \"Missing entry :\"\n msg.payload = \"Sample project\"\n}\n\nelse if (sample_ship === undefined || sample_ship === \"\") {\n msg.topic = \"Missing entry :\"\n msg.payload = \"Sample ship\"\n}\n\nelse if (sample_id === undefined || sample_id === \"\") {\n msg.topic = \"Missing entry :\"\n msg.payload = \"Sample ID\"\n}\n\nelse if (sample_operator === undefined || sample_operator === \"\") {\n msg.topic = \"Missing entry :\"\n msg.payload = \"Sample operator\"\n}\n\nelse if (sample_sampling_gear === undefined || sample_sampling_gear === \"\") {\n msg.topic = \"Missing entry :\"\n msg.payload = \"Sample sampling gear\"\n}\n\nelse if (object_lat === undefined || object_lat === null) {\n msg.topic = \"Missing entry :\"\n msg.payload = \"Latitude of throw\"\n}\n\nelse if (object_lon === undefined || object_lon === null) {\n msg.topic = \"Missing entry :\"\n msg.payload = \"Longitude of throw\"\n}\n\nelse if (object_date === undefined || object_date === \"\") {\n msg.topic = \"Missing entry :\"\n msg.payload = \"Date of throw\"\n}\n\nelse if (object_time === undefined || object_time === \"\") {\n msg.topic = \"Missing entry :\"\n msg.payload = \"Time of throw\"\n}\nelse if (sample_sampling_gear == \"net\"){\n var object_lat_end= global.get(\"object_lat_end\");\n var object_lon_end= global.get(\"object_lon_end\");\n var object_date_end= global.get(\"object_date_end\");\n var object_time_end= global.get(\"object_time_end\");\n\n if (object_lat_end === undefined || object_lat_end === null) {\n msg.topic = \"Missing entry :\"\n msg.payload = \"Latitude of retrieval\"\n }\n \n else if (object_lon_end === undefined || object_lon_end === null) {\n msg.topic = \"Missing entry :\"\n msg.payload = \"Longitude of retrieval\"\n }\n \n else if (object_date_end === undefined || object_date_end === \"\") {\n msg.topic = \"Missing entry :\"\n msg.payload = \"Date of retrieval\"\n }\n \n else if (object_time_end === undefined || object_time_end === \"\") {\n msg.topic = \"Missing entry :\"\n msg.payload = \"Time of retrieval\"\n }\n}\nelse {\n msg.topic = \"Change Tab\"\n msg.payload={\"tab\":\"Optic Configuration\"};\n}\nreturn msg;\n", + "func": "var sample_project= global.get(\"sample_project\");\nvar sample_ship= global.get(\"sample_ship\");\nvar sample_id= global.get(\"sample_id\");\nvar sample_operator= global.get(\"sample_operator\");\nvar sample_sampling_gear= global.get(\"sample_sampling_gear\");\nvar object_lat= global.get(\"object_lat\");\nvar object_lon= global.get(\"object_lon\");\nvar object_date= global.get(\"object_date\");\nvar object_time= global.get(\"object_time\");\n\nif (sample_project === undefined || sample_project === \"\") {\n msg.topic = \"Missing entry :\"\n msg.payload = \"Sample project\"\n}\n\nelse if (sample_ship === undefined || sample_ship === \"\") {\n msg.topic = \"Missing entry :\"\n msg.payload = \"Sample ship\"\n}\n\nelse if (sample_id === undefined || sample_id === \"\") {\n msg.topic = \"Missing entry :\"\n msg.payload = \"Sample ID\"\n}\n\nelse if (sample_operator === undefined || sample_operator === \"\") {\n msg.topic = \"Missing entry :\"\n msg.payload = \"Sample operator\"\n}\n\nelse if (sample_sampling_gear === undefined || sample_sampling_gear === \"\") {\n msg.topic = \"Missing entry :\"\n msg.payload = \"Sample sampling gear\"\n}\n\nelse if (object_lat === undefined || object_lat === null) {\n msg.topic = \"Missing entry :\"\n msg.payload = \"Latitude of throw\"\n}\n\nelse if (object_lon === undefined || object_lon === null) {\n msg.topic = \"Missing entry :\"\n msg.payload = \"Longitude of throw\"\n}\n\nelse if (object_date === undefined || object_date === \"\") {\n msg.topic = \"Missing entry :\"\n msg.payload = \"Date of throw\"\n}\n\nelse if (object_time === undefined || object_time === \"\") {\n msg.topic = \"Missing entry :\"\n msg.payload = \"Time of throw\"\n}\nelse if (sample_sampling_gear == \"net\"){\n var object_lat_end= global.get(\"object_lat_end\");\n var object_lon_end= global.get(\"object_lon_end\");\n var object_date_end= global.get(\"object_date_end\");\n var object_time_end= global.get(\"object_time_end\");\n\n if (object_lat_end === undefined || object_lat_end === null) {\n msg.topic = \"Missing entry :\"\n msg.payload = \"Latitude of retrieval\"\n }\n \n else if (object_lon_end === undefined || object_lon_end === null) {\n msg.topic = \"Missing entry :\"\n msg.payload = \"Longitude of retrieval\"\n }\n \n else if (object_date_end === undefined || object_date_end === \"\") {\n msg.topic = \"Missing entry :\"\n msg.payload = \"Date of retrieval\"\n }\n \n else if (object_time_end === undefined || object_time_end === \"\") {\n msg.topic = \"Missing entry :\"\n msg.payload = \"Time of retrieval\"\n }\n else {\n msg.topic = \"Change Tab\"\n msg.payload={\"tab\":\"Optic Configuration\"};\n }\n}\nelse {\n msg.topic = \"Change Tab\"\n msg.payload={\"tab\":\"Optic Configuration\"};\n}\nreturn msg;\n", "outputs": 1, "noerr": 0, "initialize": "", @@ -2927,35 +2923,17 @@ "order": 6, "width": 0, "height": 0, - "format": "
\n Sample Project:
\n Sample Ship:
\n sample operator:
\n sample id:
\n sample sampling_gear:
\n\n acq id:
\n acq instrument:
\n acq instrument_id:
\n acq camera:
\n acq celltype:
\n acq minimum_mesh:
\n acq maximum_mesh:
\n acq min_esd:
\n acq max_esd:
\n acq volume:
\n acq magnification:
\n acq fnumber_objective:
\n acq software:
\n acq flowrate:
\n\n object lat:
\n object lon:
\n object lat end:
\n object lon end:
\n object date:
\n object time:
\n object date end:
\n object time end:
\n object depth min:
\n object depth max:
\n\n process pixel:
\n process id: \n
\n", + "format": "
\n Sample Project:
\n Sample Ship:
\n sample operator:
\n sample id:
\n sample sampling_gear:
\n\n acq id:
\n acq instrument:
\n acq instrument_id:
\n acq camera:
\n acq celltype:
\n acq minimum_mesh:
\n acq maximum_mesh:
\n acq min_esd:
\n acq max_esd:
\n acq volume:
\n acq magnification:
\n acq fnumber_objective:
\n acq software:
\n acq flowrate:
\n\n object lat:
\n object lon:
\n object lat end:
\n object lon end:
\n object date:
\n object time:
\n object date end:
\n object time end:
\n object depth min:
\n object depth max:
\n\n process pixel:
\n process id: \n
\n", "storeOutMessages": true, "fwdInMessages": true, "resendOnRefresh": false, "templateScope": "local", - "x": 950, + "x": 1250, "y": 500, "wires": [ [] ] }, - { - "id": "e2919164.70927", - "type": "function", - "z": "baa1e3d9.cb29d", - "name": "get global", - "func": "msg.payload = {\n \"sample_project\":global.get(\"sample_project\"),\n \"sample_ship\":global.get(\"sample_ship\"),\n \"sample_operator\":global.get(\"sample_operator\"),\n \"sample_id\":global.get(\"sample_id\"),\n \"sample_sampling_gear\":global.get(\"sample_sampling_gear\"),\n \n \"acq_id\":global.get(\"acq_id\"),\n \"acq_instrument\":global.get(\"acq_instrument\"),\n \"acq_instrument_id\":global.get(\"acq_instrument_id\"),\n \"acq_camera\":global.get(\"acq_camera\"),\n \"acq_celltype\":global.get(\"acq_celltype\"),\n \"acq_minimum_mesh\":global.get(\"acq_minimum_mesh\"),\n \"acq_maximum_mesh\":global.get(\"acq_maximum_mesh\"),\n \"acq_min_esd\":global.get(\"acq_min_esd\"),\n \"acq_max_esd\":global.get(\"acq_max_esd\"),\n \"acq_volume\":global.get(\"acq_volume\"),\n \"acq_magnification\":global.get(\"acq_magnification\"),\n \"acq_fnumber_objective\":global.get(\"acq_fnumber_objective\"),\n \"acq_software\":global.get(\"acq_software\"),\n \"acq_flowrate\":global.get(\"sug_flowrate\"),\n \n \"object_lat\":global.get(\"object_lat\"),\n \"object_lon\":global.get(\"object_lon\"),\n \"object_lat_end\":global.get(\"object_lat_end\"),\n \"object_lon_end\":global.get(\"object_lon_end\"),\n \"object_date\":global.get(\"object_date\"),\n \"object_time\":global.get(\"object_time\"),\n \"object_date_end\":global.get(\"object_date_end\"),\n \"object_time_end\":global.get(\"object_time_end\"),\n \"object_depth_min\":global.get(\"object_depth_min\"),\n \"object_depth_max\":global.get(\"object_depth_max\"),\n \n \"process_pixel\":global.get(\"process_pixel\"),\n \"process_id\":global.get(\"process_id\")\n \n}\n\nreturn msg;", - "outputs": 1, - "noerr": 0, - "initialize": "", - "finalize": "", - "x": 780, - "y": 500, - "wires": [ - [ - "29be525e.0c87fe" - ] - ] - }, { "id": "cbb8afed.0a026", "type": "rpi-gpio out", @@ -3948,7 +3926,7 @@ "type": "function", "z": "baa1e3d9.cb29d", "name": "Image control", - "func": "state = global.get(\"state\");\nglobal.set('img_counter',0);\nglobal.set('obj_counter',0);\nif (state === null){state=\"free\"}\n\nvar nb_frame= global.get(\"nb_frame\");\nvar acq_celltype= global.get(\"acq_celltype\");\nvar acq_minimum_mesh= global.get(\"acq_minimum_mesh\");\nvar acq_maximum_mesh= global.get(\"acq_maximum_mesh\");\nvar acq_id= global.get(\"acq_id\");\nvar pump_direction= global.get(\"pump_direction\");\nvar imaging_pump_volume= global.get(\"imaging_pump_volume\");\n\nif (acq_celltype === undefined || acq_celltype === \"\") {\n msg.topic = \"Missing entry :\"\n msg.payload = \"Type of the flowcell\"\n}else if (acq_minimum_mesh === undefined || acq_minimum_mesh === \"\") {\n msg.topic = \"Missing entry :\"\n msg.payload = \"Lower fraction size\"\n}else if (acq_maximum_mesh === undefined || acq_maximum_mesh === \"\") {\n msg.topic = \"Missing entry :\"\n msg.payload = \"Upper fraction size\"\n}else if (imaging_pump_volume === undefined || imaging_pump_volume === \"\" || imaging_pump_volume === null) {\n msg.topic = \"Missing entry :\"\n msg.payload = \"Volume inbetween images\"\n}else if (acq_id === undefined || acq_id === \"\") {\n msg.topic = \"Missing entry :\"\n msg.payload = \"Acquisition ID\"\n}else if (nb_frame === undefined || nb_frame === \"\" || nb_frame === null) {\n msg.topic = \"Missing entry :\";\n msg.payload = \"Number of image to save\";\n \n}else if (pump_direction === undefined || pump_direction === \"\" || pump_direction === null) {\n msg.topic = \"Missing entry :\";\n msg.payload = \"Pump direction\";\n \n}else {\n msg.payload={\"action\":\"image\", \n \"sleep\":1,\n \"pump_direction\": pump_direction,\n \"volume\":imaging_pump_volume,\n \"nb_frame\":nb_frame,\n }\n}\n\nreturn msg;", + "func": "state = global.get(\"state\");\nglobal.set('img_counter', 0);\nglobal.set('obj_counter', 0);\nif (state === null) {\n state = \"free\"\n}\n\nvar nb_frame = global.get(\"nb_frame\");\nvar acq_celltype = global.get(\"acq_celltype\");\nvar acq_minimum_mesh = global.get(\"acq_minimum_mesh\");\nvar acq_maximum_mesh = global.get(\"acq_maximum_mesh\");\nvar acq_id = global.get(\"acq_id\");\nvar pump_direction = global.get(\"pump_direction\");\nvar imaging_pump_volume = global.get(\"imaging_pump_volume\");\nvar sleep_before = global.get(\"sleep_before\");\n\nif (acq_celltype === undefined || acq_celltype === \"\") {\n msg.topic = \"Missing entry :\"\n msg.payload = \"Type of the flowcell\"\n} else if (acq_minimum_mesh === undefined || acq_minimum_mesh === \"\") {\n msg.topic = \"Missing entry :\"\n msg.payload = \"Lower fraction size\"\n} else if (acq_maximum_mesh === undefined || acq_maximum_mesh === \"\") {\n msg.topic = \"Missing entry :\"\n msg.payload = \"Upper fraction size\"\n} else if (imaging_pump_volume === undefined || imaging_pump_volume === \"\" || imaging_pump_volume === null) {\n msg.topic = \"Missing entry :\"\n msg.payload = \"Volume inbetween images\"\n} else if (acq_id === undefined || acq_id === \"\") {\n msg.topic = \"Missing entry :\"\n msg.payload = \"Acquisition ID\"\n} else if (nb_frame === undefined || nb_frame === \"\" || nb_frame === null) {\n msg.topic = \"Missing entry :\";\n msg.payload = \"Number of image to save\";\n} else if (pump_direction === undefined || pump_direction === \"\" || pump_direction === null) {\n msg.topic = \"Missing entry :\";\n msg.payload = \"Pump direction\";\n} else if (sleep_before === undefined || sleep_before === \"\" || pump_direction === null) {\n msg.topic = \"Missing entry :\";\n msg.payload = \"Delay before image\";\n} else {\n msg.payload = {\n \"action\": \"image\",\n \"sleep\": sleep_before,\n \"pump_direction\": pump_direction,\n \"volume\": imaging_pump_volume,\n \"nb_frame\": nb_frame,\n }\n}\n\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", @@ -4076,7 +4054,7 @@ "label": "Pump direction", "tooltip": "BACKWARD / FORWARD", "group": "4322c187.e73e5", - "order": 7, + "order": 8, "width": 5, "height": 1, "passthru": true, @@ -4113,7 +4091,8 @@ "y": 540, "wires": [ [ - "c3e50240.82aa58" + "c3e50240.82aa58", + "29be525e.0c87fe" ] ] }, @@ -4146,7 +4125,7 @@ "z": "baa1e3d9.cb29d", "name": "", "group": "4322c187.e73e5", - "order": 8, + "order": 9, "width": 5, "height": 1, "passthru": false, @@ -4163,7 +4142,6 @@ "wires": [ [ "52ea7d01.711034", - "e2919164.70927", "a4abb1ae.2ae418" ] ] @@ -4681,7 +4659,7 @@ "z": "baa1e3d9.cb29d", "name": "", "x": 90, - "y": 160, + "y": 200, "wires": [ [ "f3658d30.b8448", @@ -4702,8 +4680,8 @@ "noerr": 0, "initialize": "", "finalize": "", - "x": 310, - "y": 240, + "x": 300, + "y": 280, "wires": [ [ "6b34c456.83178c" @@ -4719,7 +4697,7 @@ "outputs": 1, "noerr": 0, "x": 320, - "y": 80, + "y": 240, "wires": [ [ "cc0ca68b.4263a8" @@ -4936,7 +4914,7 @@ "payload": "10", "payloadType": "num", "x": 310, - "y": 280, + "y": 320, "wires": [ [ "51b4d0df.d70a88" @@ -5070,8 +5048,8 @@ "z": "baa1e3d9.cb29d", "name": "", "env": [], - "x": 770, - "y": 460, + "x": 930, + "y": 500, "wires": [ [] ] @@ -5092,7 +5070,7 @@ "delay": 300, "topic": "nb_frame", "x": 640, - "y": 280, + "y": 320, "wires": [ [ "fb887036.12429", @@ -6023,7 +6001,7 @@ "type": "ui_text", "z": "baa1e3d9.cb29d", "group": "4322c187.e73e5", - "order": 5, + "order": 6, "width": 5, "height": 1, "name": "Pump volume", @@ -6039,7 +6017,7 @@ "type": "function", "z": "baa1e3d9.cb29d", "name": "pump volume calc", - "func": "var acq_volume = global.get(\"acq_volume\");\nvar nb_frame = global.get(\"nb_frame\");\n\nvar pump_volume = Math.max((Number(acq_volume) / Number(nb_frame)), 0.01).toFixed(4)\n\nglobal.set(\"imaging_pump_volume\", pump_volume)\n\nmsg.payload = pump_volume + \" mL per frame\"\nreturn msg;", + "func": "var acq_volume = global.get(\"acq_volume\");\nvar nb_frame = global.get(\"nb_frame\");\n\nvar pump_volume = Math.max((Number(acq_volume) / Number(nb_frame)), 0.01).toFixed(3)\n\nglobal.set(\"imaging_pump_volume\", pump_volume)\n\nmsg.payload = pump_volume + \" mL/frame\"\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", @@ -6740,5 +6718,56 @@ "wires": [ [] ] + }, + { + "id": "a8bf2334.279c", + "type": "inject", + "z": "baa1e3d9.cb29d", + "name": "Default: 0.5", + "props": [ + { + "p": "payload" + } + ], + "repeat": "", + "crontab": "", + "once": true, + "onceDelay": 0.1, + "topic": "", + "payload": "0.5", + "payloadType": "num", + "x": 310, + "y": 80, + "wires": [ + [ + "49ea1123.ee1768" + ] + ] + }, + { + "id": "49ea1123.ee1768", + "type": "ui_numeric", + "z": "baa1e3d9.cb29d", + "name": "sleep_before", + "label": "Delay to stabilize image (s)", + "tooltip": "Happens before every capture", + "group": "4322c187.e73e5", + "order": 5, + "width": 5, + "height": 2, + "wrap": false, + "passthru": true, + "topic": "sleep_before", + "format": "{{value}}", + "min": "0.1", + "max": "5", + "step": "0.1", + "x": 630, + "y": 80, + "wires": [ + [ + "fb887036.12429" + ] + ] } ] \ No newline at end of file diff --git a/scripts/planktoscope/imager.py b/scripts/planktoscope/imager.py index f8877d5..06e67ab 100644 --- a/scripts/planktoscope/imager.py +++ b/scripts/planktoscope/imager.py @@ -595,9 +595,6 @@ class ImagerProcess(multiprocessing.Process): f"The integrity file already exists in this export path {self.__export_path}" ) - # Sleep a duration before to start acquisition - time.sleep(self.__sleep_before) - # Set the LEDs as Blue planktoscope.light.setRGB(0, 0, 255) @@ -624,6 +621,9 @@ class ImagerProcess(multiprocessing.Process): f"Capturing image {self.__img_done + 1}/{self.__img_goal} to {filename_path}" ) + # Sleep a duration before to start acquisition + time.sleep(self.__sleep_before) + # Capture an image with the proper filename try: self.__camera.capture(filename_path)