"""
This script demonstrate the tcpip.runScript command, that allows starting a pre-configured IM script (.imsf) from python.  
IM scripts cam be generated by configuring an acquisition, and in the run tab, clicking "Create" then "Save" to save the script as a file. 

Running the script in python will prompt for a imsf script, will run it and return the directory where the images were saved.

REQUIREMENTS : 
	installing the acquifer python package
	an IM powered-on connected to the pc running the python script
	the option "Block remote connection" of the IM disabled in service settings
	the control software of the IM opened
"""

#%% Import and open tcpip communication
from acquifer import tcpip

im = tcpip.TcpIp()

#%% Prompt for imsf script
im_script = input("Paste path to a .imsf script :\n")
im_script = im_script.strip('"') # Remove leading/trailing " from copy/pasting

#%% Run script
image_dir = im.runScript(im_script)

print(f"\nImages saved in {image_dir}")