Hi,
thanks for using the forum!
I checked your driver and as you already describe, there are two problems:
- How to retrieve information from the device to configure it before the measurement
- speeding up the measurement
Regarding the 1.)
I have to say that SweepMe! is missing a Driver API function that allows to communicate with the device in order to refresh the GUI parameters. This is something that we have on our development list, but still looking for a robust way to implement it to handle the timeout errors when the wrong device is selected.
If you are working with a single device that has a fixed amount of sensors, my recommendation would be to create a hard-coded list of variables and units. If you have multiple devices with each having a fixed amount of sensors, you could create some kind of in-driver lookup dictionary and select your device in the GUI. If you have devices where the sensors constantly change, a workaround would be to create a GUI where the user can select the number of connected sensors and then manually select the sensors to be read out.
Here, use of dynamic GUI parameters as explained in the Wiki
https://wiki.sweep-me.net/wiki/Driver_Programming#Dynamic_GUI_parameters
might be helpful to populate the UI with as many Sensor selection fields as needed.
I will discuss this topic also once again with my colleagues. Optimal solution would be if a user could access the port during set_GUIparameter or update_gui_parameters.
Regarding 2.)
In general, it should be possible to use SweepMe!'s port manager during the measurement in semantic phase functions and still create own ports to something special before the measurement. This would not make your driver faster, but your could make use of the many convenience functions for the port handling like reading until the separator or the encoding.
Although the code looks a bit lengthy, I don’t think it is the reason for being slow. The use of the functions request_result, read_result, and process_data is correct.
You already retrieve the data with a single call using “S1” command so there is no chance to further parallelize the date readout. However, often there is the problem that terminator character is not correctly used. Then, the code always waits until the timeout. To check this, you can increase the timeout to larger values and see whether the measurement gets even slower.
I further wonder about the command “readall” that you use for the pyserial Port object. I was able to verify that the command exists, but did not find any official documentation about it. So, I would check whether the command is correctly used and how it handles the terminator of the incoming message.
Maybe you can write how long a single readout takes or how many values you can readout right now per second. More than 100 values will be difficult with a serial communication. If possible, one could also increase the baudrate of the COM port if the ALMEMO device allows to configure this.
In process_data you are redefining self.plottype and self.savetype which however has no influence anymore at this position. Variables, units, plottypes and savetypes must be defined latest during get_GUIparmeter or apply_gui_parameter. So you can safely remove them there.
Printing a lot of information at each process step, e.g. as you do during ‘call’ function might also slow down SweepMe!, so you could remove this as well or close the Debug widget during the measurement.
Hope these steps help you to proceed with a faster measurement. Let us know what you can figure out.
Thanks and best
Axel