Open yakir12 opened 9 years ago
All spectrometer methods should be blocking.
What's your specific use case for an isready
method?
I want to fetch intensities when the spec is ready and not before by using asynchronous coroutines. All of this is done in Julia (not Python) with channels, tasks, and @async. What do you mean with "All spectrometer methods should be blocking"? Maybe I can work around it?
On 18:57, Mon, 12/10/2015 Andreas Poehlmann notifications@github.com wrote:
All spectrometer methods should be blocking.
What's your specific use case for an isready method?
— Reply to this email directly or view it on GitHub https://github.com/ap--/python-seabreeze/issues/18#issuecomment-147334894 .
If you call spec.intensities() pyseabreeze sends a request command to the spectrometer and starts reading the spectrum information from the spectrometer.
By default most oceanoptics spectrometers are in a free running trigger mode. This means, that once you set the integration time, the spectrometer is constantly acquiring spectra. When a spectrum is requested via usb the spectrometer is sending the next valid acquired spectrum. This means in free running trigger mode, dependent on when the spectrum is requested, it can take from [insert really short time] up to [insert the integration time you set] until the spec.intensities() call returns.
if you call spec.intensities() in a loop, the loop delay will be the integration time you set (plus some overhead).
I'm trying to avoid changing the integration time and fetching the intensities at the same time. I think it should be possible to do that in my specific setup but thought it would be great if there was a isready() function that could tell me when the spec is ready for any kind of communication. On 12/10/2015 8:30 PM, "Andreas Poehlmann" notifications@github.com wrote:
If you call spec.intensities() pyseabreeze sends a request command to the spectrometer and starts reading the spectrum information from the spectrometer.
By default most oceanoptics spectrometers are in a free running trigger mode. This means, that once you set the integration time, the spectrometer is constantly acquiring spectra. When a spectrum is requested via usb the spectrometer is sending the next valid acquired spectrum. This means in free running trigger mode, dependent on when the spectrum is requested, it can take from [insert really short time] up to [insert the integration time you set] until the spec.intensities() call returns.
if you call spec.intensities() in a loop, the loop delay will be the integration time you set (plus some overhead).
— Reply to this email directly or view it on GitHub https://github.com/ap--/python-seabreeze/issues/18#issuecomment-147360309 .
I should check if pyseabreeze is threadsafe. In the meantime, if you want to change the integration time and read spectra from two different threads, you may need to implement the thread locking yourself.
I would recommend to use a single thread to communicate with the spectrometer and implement all asynchronous calls on this thread. In the main loop of this thread you can check if other threads want to change the integration time and do the change on demand.
Awesome advice. I'll keep tinkering. Thanks for all the work and sorry for opening all these "issues". On 12/10/2015 9:41 PM, "Andreas Poehlmann" notifications@github.com wrote:
I should check if pyseabreeze is threadsafe. In the meantime, if you want to change the integration time and read spectra from two different threads, you may need to implement the thread locking yourself.
I would recommend to use a single thread to communicate with the spectrometer and implement all asynchronous calls on this thread. In the main loop of this thread you can check if other threads want to change the integration time and do the change on demand.
— Reply to this email directly or view it on GitHub https://github.com/ap--/python-seabreeze/issues/18#issuecomment-147371751 .
It would be an awesome feature to have an
isready
functionality for testing if the spectrometer is ready for input (e.g. viaspec.integration_time_micros(12000)
) and/or output (e.g.spec.intensities()
).