UniNE-CHYN / thorpy

Python library implementing Thorlabs APT communication protocol
43 stars 22 forks source link

K10CR1 disconnect ? and conflict with Thorlabs spectrometer in discover_stage() #15

Open LeoMonn opened 5 years ago

LeoMonn commented 5 years ago

Hello,

Thank you for your code. I'm currently using it to make a UI. It appears there is an when using discover_stages() if the stages have already been "discovered", preventing me to use them. Also, when I import and find another Thorlabs instrument such as a spectrometer, a conflict appears again preventing to discover the stages. My fix for now was to write:

try: 
    from thorpy.comm.discovery import discover_stages
    try: #Checking if the 2 stages have already been discovered 
        if len(stages)==2:
            print(stages)
        else:
            raise("error stages")
    except:
        stages = list(discover_stages())
        print(stages)
except:
    print('failed to import thorpy.comm.discovery or load the stages')
    pass

basically the idea was just to go around both problems, allowing my code to not work sometimes and forcing me to kill the current kernel and start a new one (using spyder 3). For my first problem, I fell like a fix could be to disconnect the stages. Is this possible ? Is there another fix that could do the job properly ? For the second problem, it seems like I can fix this by forcing to load the stages before the thorlabs spectrometer, which in my case is not very convenient. Is this a known issue ?

Thank you Best regards,

Léo