labscript-suite / labscript-devices

A modular and extensible plugin architecture to control experiment hardware using the 𝘭𝘒𝘣𝘴𝘀𝘳π˜ͺ𝘱𝘡 𝘴𝘢π˜ͺ𝘡𝘦.
http://labscriptsuite.org
Other
5 stars 58 forks source link

Tekscope with multiple devices #66

Open ARFritsch opened 4 years ago

ARFritsch commented 4 years ago

Blacs complains when try to save the data from the scope if multiple scopes are connected. Line 57 (transition_to_buffer) in labscript-devices/labscript_devices/TekScope/blacs_workers.py creates a group in the .h5 file to save the scope data. However, when the group is already created by the first connected scope, the second scope gets an error because the group already exists. `

        with h5py.File(self.h5file, 'r+') as hdf_file:
            grp = hdf_file.create_group('/data/traces')
            print('Saving traces...')
            dset = grp.create_dataset(self.device_name, data=data)
            dset.attrs.update(wfmp[ch]) 

I could fix this by checking if the group exists before creating it. `

        with h5py.File(self.h5file, 'r+') as hdf_file:
            check_grp = '/data/traces' in hdf_file
            if check_grp == False:
                 grp = hdf_file.create_group('/data/traces')
                 dset = grp.create_dataset(self.device_name, data=data)
            else:
                 dset = hdf_file.create_dataset('/data/traces/' + self.device_name, data=data)
            print('Saving traces...')
            dset.attrs.update(wfmp[ch]) `

I tested it with two scopes connected and is working.