save conf
This commit is contained in:
@@ -3,5 +3,5 @@
|
||||
"Amplitude_mm": 10,
|
||||
"Time_in_beam_s": 5,
|
||||
"Time_out_of_beam_s": 10,
|
||||
"Exposure_time": 0.005
|
||||
"Exposure_time": 0.002
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -39,7 +39,9 @@ class AD(camera.Camera):
|
||||
self.pv_cam_exposure = PV('{}AcquireTime'.format(self.prefix))
|
||||
self.pv_im_array = PV('{}ArrayData'.format("X02DA-PG-USB:image1:"))
|
||||
self.pv_im_height = PV('{}ArraySize1_RBV'.format("X02DA-PG-USB:image1:"))
|
||||
self.pv_im_width = PV('{}ArraySize0_RBV'.format("X02DA-PG-USB:image1:"))
|
||||
self.pv_im_width = PV('{}ArraySize0_RBV'.format("X02DA-PG-USB:image1:"))
|
||||
def __del__(self):
|
||||
print("Camera deleted")
|
||||
|
||||
def start(self, wait=True):
|
||||
"""
|
||||
|
||||
@@ -23,6 +23,10 @@ check_path(config_path)
|
||||
def init_nr_of_cycles():
|
||||
config = myu.load_object(config_path)
|
||||
return config.get("Number_of_cycles", 1)
|
||||
def init_exposure_time():
|
||||
config = myu.load_object(config_path)
|
||||
|
||||
return config.get("Exposure_time")
|
||||
library_path = r"C:\Users\berti_r\Python_Projects\templates\motion_libs"
|
||||
check_path(library_path)
|
||||
sys.path.append(library_path)
|
||||
@@ -122,6 +126,8 @@ def run_repeatability_series(
|
||||
#-----------------------------------------cleanup-----------------------------------------
|
||||
|
||||
axis1.disableAxis()
|
||||
camera.stop()
|
||||
del camera
|
||||
|
||||
def analyze_repeatability(input_file, pixel_size, units='um'):
|
||||
"""
|
||||
@@ -259,7 +265,7 @@ def image_test(motor_on_off=0):
|
||||
|
||||
|
||||
# Coordinates (float, in pixels)
|
||||
x, y = image_center_of_mass(th2, plot=False, verbose=False)
|
||||
x, y = image_center_of_mass(im, plot=False, verbose=False)
|
||||
# Create a new figure and axis
|
||||
fig, ax = plt.subplots()
|
||||
ax.imshow(im)
|
||||
@@ -267,6 +273,8 @@ def image_test(motor_on_off=0):
|
||||
ax.scatter([x], [y], c='red', s=50)
|
||||
ax.axis('off')
|
||||
plt.show()
|
||||
camera.stop()
|
||||
del camera
|
||||
|
||||
def camera_thread_function( img_queue):
|
||||
if os.getenv("EPICS_CA_ADDR_LIST") is not None:
|
||||
@@ -283,6 +291,8 @@ def camera_thread_function( img_queue):
|
||||
stop_time = time.time()
|
||||
elapsed_time = stop_time - start_time
|
||||
print(f"Elapsed time: {elapsed_time:.2f}")
|
||||
camera.stop()
|
||||
del camera
|
||||
|
||||
|
||||
def static_test(motor_on_off=0):
|
||||
@@ -314,14 +324,38 @@ def static_test(motor_on_off=0):
|
||||
fh.close()
|
||||
camera_thread.join()
|
||||
|
||||
if os.getenv("EPICS_CA_ADDR_LIST") is not None:
|
||||
def my_set_ev():
|
||||
print("trying to set ev")
|
||||
if os.getenv("EPICS_CA_ADDR_LIST") is not None:
|
||||
pass
|
||||
else:
|
||||
os.environ["EPICS_CA_ADDR_LIST"] = "129.129.181.64"
|
||||
|
||||
camera_seting = ad.AD()
|
||||
|
||||
while (camera_seting.get_exposure_time() != init_exposure_time()):
|
||||
camera_seting.set_ev_time(init_exposure_time())
|
||||
sleep(1.2)
|
||||
|
||||
# print(init_exposure_time())
|
||||
|
||||
|
||||
if camera_seting.get_exposure_time() != init_exposure_time():
|
||||
print("failed setting exposure time")
|
||||
if camera_seting.get_exposure_time() == init_exposure_time():
|
||||
print("success setting exposure time")
|
||||
del camera_seting
|
||||
|
||||
|
||||
"""if os.getenv("EPICS_CA_ADDR_LIST") is not None:
|
||||
pass
|
||||
else:
|
||||
os.environ["EPICS_CA_ADDR_LIST"] = "129.129.181.64"
|
||||
|
||||
camera = ad.AD()
|
||||
camera.set_ev_time(0.004)
|
||||
print("EV:", camera.get_exposure_time())
|
||||
camera_seting = ad.AD()
|
||||
camera_seting.set_ev_time(init_exposure_time())
|
||||
|
||||
print(camera_seting.get_exposure_time())"""
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -81,8 +81,8 @@
|
||||
"source_hidden": true
|
||||
},
|
||||
"ExecuteTime": {
|
||||
"end_time": "2025-07-17T07:20:15.136806Z",
|
||||
"start_time": "2025-07-17T07:20:14.832048Z"
|
||||
"end_time": "2025-07-17T08:24:45.640478Z",
|
||||
"start_time": "2025-07-17T08:24:45.332300Z"
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
@@ -122,6 +122,7 @@
|
||||
"meas_scripts_dir_local = r\"C:\\Users\\berti_r\\Python_Projects\\StagePerformaceDocu\\Scripts\"\n",
|
||||
"config_path = r\"C:\\Users\\berti_r\\Python_Projects\\StagePerformaceDocu\\Config\\config.json\"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"#check_path(meas_scripts_dir)\n",
|
||||
"check_path(meas_scripts_dir_local)\n",
|
||||
"check_path(config_path)\n",
|
||||
@@ -133,6 +134,9 @@
|
||||
"import metrology_functions as mf\n",
|
||||
"import myutility as myu\n",
|
||||
"from matplotlib.widgets import Cursor\n",
|
||||
"import ad\n",
|
||||
"import sys\n",
|
||||
"import os\n",
|
||||
"\"\"\"\n",
|
||||
"# Load config from JSON file\n",
|
||||
"def load_object(path):\n",
|
||||
@@ -151,15 +155,15 @@
|
||||
"# Get exposure time from config\n",
|
||||
"def init_exposure_time():\n",
|
||||
" config = myu.load_object(config_path)\n",
|
||||
" print(config)\n",
|
||||
"\n",
|
||||
" return config.get(\"Exposure_time\", 0)\n",
|
||||
" return config.get(\"Exposure_time\")\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"# --------------------------------------------------GUI Objects-----------------------------------------------\n",
|
||||
"start_button = widgets.Button(description=\"Start Measurement\")\n",
|
||||
"ev_button = widgets.Button(description=\"Set exposure time\")\n",
|
||||
"\n",
|
||||
"nr_of_cycles = widgets.BoundedIntText(\n",
|
||||
" value=init_nr_of_cycles(),\n",
|
||||
@@ -172,8 +176,7 @@
|
||||
"\n",
|
||||
"# Dropdown menu to choose measurement function\n",
|
||||
"measurement_options = {\n",
|
||||
" \"Repeatability Test\": mf.run_repeatability_series,\n",
|
||||
" \"Image Test\": mf.image_test, # Example function, make sure it exists in metrology_functions.py\n",
|
||||
" \"Image Test\": mf.image_test,\"Repeatability Test\": mf.run_repeatability_series,\n",
|
||||
" \"Static Test\": mf.static_test\n",
|
||||
"}\n",
|
||||
"\n",
|
||||
@@ -190,6 +193,7 @@
|
||||
"output2 = widgets.Output()\n",
|
||||
"output3 = widgets.Output()\n",
|
||||
"output4 = widgets.Output()\n",
|
||||
"output5 = widgets.Output()\n",
|
||||
"\n",
|
||||
"# --------------------------------------------------IRQs-----------------------------------------------\n",
|
||||
"def start_measurement(b):\n",
|
||||
@@ -217,33 +221,38 @@
|
||||
" print(f'Number of cycles set to: {new_cycles}')\n",
|
||||
"\n",
|
||||
"# Set exposure time and save to config\n",
|
||||
"def set_exposure_time(change):\n",
|
||||
"def set_exposure_time(change_exp):\n",
|
||||
"\n",
|
||||
" try:\n",
|
||||
" new_exposure = float(change['new'])\n",
|
||||
" config = myu.load_object(config_path)\n",
|
||||
" config['Exposure_time'] = new_exposure\n",
|
||||
" myu.save_config(config_path, config)\n",
|
||||
" new_exposure = float(change_exp['new'])\n",
|
||||
" config_exp = myu.load_object(config_path)\n",
|
||||
" config_exp['Exposure_time'] = new_exposure\n",
|
||||
" myu.save_config(config_path, config_exp)\n",
|
||||
"\n",
|
||||
" with output4:\n",
|
||||
" clear_output()\n",
|
||||
" print(f'Exposure time set to: {new_exposure:.2f} s')\n",
|
||||
" print(f'Exposure time set to: {new_exposure:.5f} s')\n",
|
||||
" except ValueError:\n",
|
||||
" with output4:\n",
|
||||
" clear_output()\n",
|
||||
" print(\"Invalid input. Please enter a number.\")\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def load_ev_time_to_cam():\n",
|
||||
" with output5:\n",
|
||||
" clear_output()\n",
|
||||
" mf.my_set_ev()\n",
|
||||
"# --------------------------------------------------Unmask IRQs-----------------------------------------------\n",
|
||||
"nr_of_cycles.observe(set_nr_of_cycles, names='value')\n",
|
||||
"start_button.on_click(start_measurement)\n",
|
||||
"\n",
|
||||
"ev_button.on_click(load_ev_time_to_cam,output5)\n",
|
||||
"exposure_input.observe(set_exposure_time, names='value')\n",
|
||||
"\n",
|
||||
"# --------------------------------------------------Display-----------------------------------------------\n",
|
||||
"display(dropdown,output3)\n",
|
||||
"display(nr_of_cycles, output2)\n",
|
||||
"display(start_button, output1)\n",
|
||||
"display(exposure_input, output4)\n",
|
||||
"display(ev_button,output5)\n",
|
||||
"display(start_button, output1)\n",
|
||||
"\n",
|
||||
"\n"
|
||||
],
|
||||
"outputs": [
|
||||
@@ -260,22 +269,21 @@
|
||||
"Connect to PLC\n",
|
||||
"is_open()=True\n",
|
||||
"get_local_address()=None\n",
|
||||
"read_device_info()=('Plc30 App', <pyads.structs.AdsVersion object at 0x000001656C161400>)\n",
|
||||
"read_device_info()=('Plc30 App', <pyads.structs.AdsVersion object at 0x00000270F2F7D2B0>)\n",
|
||||
"GVL_APP.nAXIS_NUM=3\n",
|
||||
"Constructor for axis\n",
|
||||
"EV: 0.004\n",
|
||||
"{'Number_of_cycles': 200, 'Amplitude_mm': 10, 'Time_in_beam_s': 5, 'Time_out_of_beam_s': 10}\n"
|
||||
"0.006\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"Dropdown(description='Test Type:', options=('Repeatability Test', 'Image Test', 'Static Test'), value='Repeata…"
|
||||
"Dropdown(description='Test Type:', index=1, options=('Image Test', 'Repeatability Test', 'Static Test'), value…"
|
||||
],
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"version_major": 2,
|
||||
"version_minor": 0,
|
||||
"model_id": "37a89768f67b4f0f8f7a32c07598c8b0"
|
||||
"model_id": "9a684efad38f4a87b5e2e46ba7086576"
|
||||
}
|
||||
},
|
||||
"metadata": {},
|
||||
@@ -289,7 +297,7 @@
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"version_major": 2,
|
||||
"version_minor": 0,
|
||||
"model_id": "37d77ded9fda48219ad17fd39bb5ce47"
|
||||
"model_id": "24d9b5ab4e344644bd87b584e9ef061f"
|
||||
}
|
||||
},
|
||||
"metadata": {},
|
||||
@@ -303,7 +311,7 @@
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"version_major": 2,
|
||||
"version_minor": 0,
|
||||
"model_id": "8908afd5ce6e49519ff8513aaee7f941"
|
||||
"model_id": "71befd61b3d24c2cb6d179ad4e529429"
|
||||
}
|
||||
},
|
||||
"metadata": {},
|
||||
@@ -317,7 +325,63 @@
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"version_major": 2,
|
||||
"version_minor": 0,
|
||||
"model_id": "c5827195cc6e4cf595aa94e706596f25"
|
||||
"model_id": "37eaf9aa950e40a49668bb642f6710b0"
|
||||
}
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"Text(value='0.002', description='Exposure [s]:')"
|
||||
],
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"version_major": 2,
|
||||
"version_minor": 0,
|
||||
"model_id": "140a8daecf834fa89e7e545a9470a4c6"
|
||||
}
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"Output()"
|
||||
],
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"version_major": 2,
|
||||
"version_minor": 0,
|
||||
"model_id": "0a7bac91ac9f4ac5bf97a894ea2a29f3"
|
||||
}
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"Button(description='Set exposure time', style=ButtonStyle())"
|
||||
],
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"version_major": 2,
|
||||
"version_minor": 0,
|
||||
"model_id": "e47f92cd2d224606b7ef0133b89f14ce"
|
||||
}
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"Output()"
|
||||
],
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"version_major": 2,
|
||||
"version_minor": 0,
|
||||
"model_id": "7d0fb4a326734eab9d39719ce5d2d5cc"
|
||||
}
|
||||
},
|
||||
"metadata": {},
|
||||
@@ -331,7 +395,7 @@
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"version_major": 2,
|
||||
"version_minor": 0,
|
||||
"model_id": "5c599052a9be4824ad0c2bf7da9e7fc0"
|
||||
"model_id": "86d9ae24158146158b01ba359d080dbd"
|
||||
}
|
||||
},
|
||||
"metadata": {},
|
||||
@@ -345,35 +409,7 @@
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"version_major": 2,
|
||||
"version_minor": 0,
|
||||
"model_id": "bd2a964315144939a0d917c6c91aa2c6"
|
||||
}
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"Text(value='0', description='Exposure [s]:')"
|
||||
],
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"version_major": 2,
|
||||
"version_minor": 0,
|
||||
"model_id": "ae695ca082ab4f18a1676f247f3df6cb"
|
||||
}
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"Output()"
|
||||
],
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"version_major": 2,
|
||||
"version_minor": 0,
|
||||
"model_id": "a6df34e1ec7748e8a11c369e8599fb26"
|
||||
"model_id": "f148b73a58f14c8ba69795dc48434d5e"
|
||||
}
|
||||
},
|
||||
"metadata": {},
|
||||
|
||||
Reference in New Issue
Block a user