from SEM_API import SEM_API
import autofocus

sem = SEM_API(state="local")

from xmlrpc.server import SimpleXMLRPCServer

addr = "192.168.1.101"
port = 8123

with SimpleXMLRPCServer((addr, port)) as server:
    server.register_introspection_functions()
    
    #@server.register_function(name='autofocus')
    def _autofocus(search_step=10, wd_searh_factor=3, retry = 3, refine = True):
        res = autofocus.autofocus(sem, search_step, wd_searh_factor, retry, refine)
        return res
    server.register_function(_autofocus,name='autofocus')        

    #@server.register_function(name='autostigfocus')
    def _autostigfocus(search_step=10, iter_n=2, wd_searh_factor=3, stig_range=2, iter_range_damping = 0.8):
        res = autofocus.autofocusstig(sem, search_step, iter_n, wd_searh_factor, stig_range, iter_range_damping)
        return res
    server.register_function(_autostigfocus,name='autostigfocus')

    server.serve_forever()