import wlmData import time import csv from datetime import datetime #time buffer btw measurements buffer = 1e-3 #s #stops automatically after T seconds T = 10 #s #change the path to the local wlmData.dll location # Load the DLL # DLL_PATH = "/home/fabio/Programs/HighFinesse/Wavelength Meter WS6 4572/Projects/DataDemo/Python/lib/libwlmData.so" # linux DLL_PATH = "C:\Windows\SysWOW64\wlmData.dll" # windows # DLL_PATH = "C:\Program Files (x86)\HighFinesse\Wavelength Meter WS6 4572\Projects\NetworkAccess\NetworkAccess_0007\Client_Windows\x64/wlmData.dll" # NetAccessFolder wlmData.LoadDLL(DLL_PATH) # File to store the data current_time = datetime.now().strftime("%Y%m%d_%H%M") output_file = f"data/wavelength_data_{current_time}_buf{buffer}s_{T}s.csv" # Open the file for writing with open(output_file, mode='w', newline='') as file: writer = csv.writer(file) writer.writerow([f'buffer btw datapoints {buffer} s', '']) writer.writerow(["timestamp", "Wavelength (nm)"]) # Header print(f"Reading wavelength data for {T} seconds. Wait or Press Ctrl+C to stop.") start_time = time.time() try: while True: # Get the current timestamp elapsed_time = time.time() - start_time if elapsed_time > T: print("Measurement completed!") break # Get the wavelength wavelength = wlmData.dll.GetWavelengthNum(4,0.0) # Log the data writer.writerow([elapsed_time, wavelength]) print(f"Time: {elapsed_time}, Wavelength: {wavelength} nm") # Wait for a short interval before the next reading time.sleep(buffer) except KeyboardInterrupt: print("Measurement stopped.")