Beispiel #1
0
class ResetThread(QtCore.QThread):
    """Thread for resetting Vectrino"""
    def __init__(self):
        QtCore.QThread.__init__(self)
        print("Vectrino reset thread initialized")
        self.vec = PdControl()
        self.comport = "COM2"
        self.isconnected = self.vec.connected
        self.vecstatus = "Vectrino disconnected "
        self.enable = True
        print("Vectrino thread init done")

    def run(self):
        self.vec.serial_port = self.comport
        self.vec.connect()
        tstart = time.time()
        self.timeout = False
        self.vecstatus = "Connecting to Vectrino..."
        while not self.vec.connected:
            time.sleep(0.3)
            if time.time() - tstart > 10:
                print("Vectrino timed out")
                self.timeout = True
                break
        if not self.timeout:
            self.vec.stop()
            self.vecstatus = "Vectrino connected "
            while self.vec.state != "Confirmation mode":
                time.sleep(0.3)
            print("Vectrino in data confirmation mode")
            self.stop()

    def stop(self):
        self.vec.stop_disk_recording()
        self.vec.stop()
        while self.vec.state != "Command mode":
            time.sleep(0.3)
        self.vec.disconnect()
        self.vecstatus = "Vectrino disconnected "
Beispiel #2
0
class ResetThread(QtCore.QThread):
    """Thread for resetting Vectrino"""
    def __init__(self):
        QtCore.QThread.__init__(self)
        print("Vectrino reset thread initialized")
        self.vec = PdControl()
        self.comport = "COM2"
        self.isconnected = self.vec.connected
        self.vecstatus = "Vectrino disconnected "
        self.enable = True
        print("Vectrino thread init done")

    def run(self):
        self.vec.serial_port = self.comport
        self.vec.connect()
        tstart = time.time()
        self.timeout = False
        self.vecstatus = "Connecting to Vectrino..."
        while not self.vec.connected:
            time.sleep(0.3)
            if time.time() - tstart > 10:
                print("Vectrino timed out")
                self.timeout = True
                break
        if not self.timeout:
            self.vec.stop()
            self.vecstatus = "Vectrino connected "
            while self.vec.state != "Confirmation mode":
                time.sleep(0.3)
            print("Vectrino in data confirmation mode")
            self.stop()
        
    def stop(self):
        self.vec.stop_disk_recording()
        self.vec.stop()
        while self.vec.state != "Command mode":
            time.sleep(0.3)
        self.vec.disconnect()
        self.vecstatus = "Vectrino disconnected "        
Beispiel #3
0
class TurbineTow(QtCore.QThread):
    towfinished = QtCore.pyqtSignal()

    def __init__(self,
                 acs_hcomm,
                 U,
                 tsr,
                 y_R,
                 z_H,
                 turbine_properties,
                 nidaq=True,
                 vectrino=True,
                 vecsavepath="",
                 fbg=False,
                 fbg_properties={},
                 settling=False,
                 vec_salinity=0.0):
        """Turbine tow run object."""
        QtCore.QThread.__init__(self)
        self.hc = acs_hcomm
        self.U = float(U)
        self.tsr = tsr
        self.y_R = y_R
        self.z_H = z_H
        self.R = turbine_properties["radius"]
        self.H = turbine_properties["height"]
        self.vectrino = vectrino
        self.nidaq = nidaq
        self.fbg = fbg
        self.settling = settling
        self.build_acsprg()
        self.acsdaqthread = daqtasks.AcsDaqThread(self.hc)
        self.maxvel = U * 1.3
        self.usetrigger = True
        self.vecsavepath = vecsavepath
        self.recordvno = True
        self.vecstatus = "Vectrino disconnected "
        self.autoaborted = False
        self.aborted = False
        self.vec_salinity = vec_salinity

        commit = check_output(["git", "rev-parse", "--verify", "HEAD"])[:-1]

        self.metadata = {
            "Tow speed (m/s)": float(U),
            "Tip speed ratio": tsr,
            "Time created": time.asctime(),
            "TurbineDAQ version": commit
        }

        if self.vectrino:
            self.vec = PdControl()
            self.metadata["Vectrino metadata"] = {"y/R": y_R, "z/H": z_H}

        if self.nidaq:
            self.daqthread = daqtasks.NiDaqThread(usetrigger=self.usetrigger)
            self.nidata = self.daqthread.data
            self.metadata["NI metadata"] = self.daqthread.metadata

        if self.fbg:
            self.fbgthread = daqtasks.FbgDaqThread(fbg_properties,
                                                   usetrigger=self.usetrigger)
            self.metadata["FBG metadata"] = self.fbgthread.metadata
            self.fbgdata = self.fbgthread.data

    def build_acsprg(self):
        """Create the ACSPL+ program for running the run.
        This run should send a trigger pulse."""
        if self.settling:
            endpos = 9.0
        else:
            endpos = 0.0
        self.acs_prg = acsprgs.turbine_tow_prg(self.U,
                                               self.tsr,
                                               self.R,
                                               endpos=endpos)

    def setvecconfig(self):
        self.vec.start_on_sync = self.usetrigger
        self.vec.sync_master = not self.usetrigger
        self.vec.sample_on_sync = False
        self.vec.sample_rate = 200
        self.vec.coordinate_system = "XYZ"
        self.vec.power_level = "High"
        self.vec.transmit_length = 3
        self.vec.sampling_volume = 3
        self.vec.sound_speed_mode = "measured"
        self.vec.salinity = self.vec_salinity

        if self.maxvel <= 4.0 and self.maxvel > 2.5:
            self.vec.vel_range = 0
        elif self.maxvel <= 2.5 and self.maxvel > 1.0:
            self.vec.vel_range = 1
        elif self.maxvel <= 1.0 and self.maxvel > 0.3:
            self.vec.vel_range = 2
        elif self.maxvel <= 0.3 or self.settling:
            self.vec.vel_range = 3
        self.vec.set_config()
        self.metadata["Vectrino metadata"]["Velocity range (index)"] = \
                self.vec.vel_range
        self.metadata["Vectrino metadata"]["Sample rate (Hz)"] = \
                self.vec.sample_rate
        self.metadata["Vectrino metadata"]["Coordinate system"] = \
                self.vec.coordinate_system
        self.metadata["Vectrino metadata"]["Salinity (ppt)"] = \
                self.vec.salinity
        self.metadata["Vectrino metadata"]["Transmit length"] = \
                self.vec.transmit_length
        self.metadata["Vectrino metadata"]["Sampling volume"] = \
                self.vec.sampling_volume
        print("Vectrino configuration set")

    def run(self):
        """Start the run. Comms should be open already with the controller."""
        if acsc.getOutput(self.hc, 1, 16):
            acsc.setOutput(self.hc, 1, 16, 0)
        if self.vectrino:
            acsc.enable(self.hc, 0)
            acsc.enable(self.hc, 1)
            while not acsc.getMotorState(self.hc, 0)["enabled"] or not \
                    acsc.getMotorState(self.hc, 1)["enabled"]:
                self.msleep(100)
            acsc.toPoint(self.hc, None, 0, self.y_R * self.R)
            acsc.toPoint(self.hc, None, 1, self.z_H * self.H)
            while not acsc.getMotorState(self.hc, 0)["in position"] or not \
                    acsc.getMotorState(self.hc, 1)["in position"]:
                self.msleep(300)
            print("y- and z-axes in position")
            acsc.disable(self.hc, 0)
            acsc.disable(self.hc, 1)
            self.vec.serial_port = "COM2"
            self.vec.connect()
            tstart = time.time()
            self.timeout = False
            self.vecstatus = "Connecting to Vectrino..."
            while not self.vec.connected:
                self.msleep(300)
                if time.time() - tstart > 10:
                    print("Vectrino timed out")
                    self.timeout = True
                    break
            if not self.timeout:
                self.vec.stop()
                self.setvecconfig()
                if self.recordvno:
                    self.vec.start_disk_recording(self.vecsavepath)
                self.vec.start()
                self.vecstatus = "Vectrino connected "
                while self.vec.state != "Confirmation mode":
                    self.msleep(100)
                print("Vectrino in data collection mode")
                print("Waiting 6 seconds")
                self.sleep(6)
                self.daqthread.start()
                if self.fbg:
                    self.fbgthread.start()
                self.start_motion()
        elif self.nidaq:
            self.daqthread.start()
            if self.fbg:
                self.fbgthread.start()
            self.start_motion()
        else:
            # Start motion
            self.start_motion()

    def start_motion(self):
        self.acsdaqthread.start()
        nbuf = 19
        acsc.loadBuffer(self.hc, nbuf, self.acs_prg, 2048)
        acsc.enable(self.hc, 4)
        acsc.enable(self.hc, 5)
        acsc.runBuffer(self.hc, nbuf)
        prgstate = acsc.getProgramState(self.hc, nbuf)
        while prgstate == 3:
            time.sleep(0.3)
            prgstate = acsc.getProgramState(self.hc, nbuf)
        self.acsdaqthread.stop()
        if self.nidaq:
            self.daqthread.clear()
            print("NI tasks cleared")
        if self.fbg:
            self.fbgthread.stop()
        if self.vectrino:
            if self.settling:
                # Wait 10 minutes to measure tank settling time
                print("Waiting 10 minutes")
                t0 = time.time()
                dt = 0.0
                while not self.aborted and dt < 600:
                    time.sleep(0.5)
                    dt = time.time() - t0
            if self.recordvno:
                self.vec.stop_disk_recording()
            self.vec.stop()
            self.vec.disconnect()
        print("Tow finished")
        if self.vectrino:
            if self.vec.state == "Not connected":
                self.vecstatus = "Vectrino disconnected "
            print("Resetting Vectrino")
            self.reset_vec()
        self.towfinished.emit()

    def reset_vec(self):
        self.vec.connect()
        self.vec.stop_disk_recording()
        self.vec.stop()
        self.vec.disconnect()
        self.vec.data = {}
        print("Vectrino reset")

    def abort(self):
        """This should stop everything."""
        print("Aborting turbine tow")
        self.aborted = True
        acsc.stopBuffer(self.hc, 19)
        acsc.halt(self.hc, 0)
        acsc.halt(self.hc, 1)
        acsc.halt(self.hc, 4)
        acsc.halt(self.hc, 5)

    def autoabort(self):
        """This should stop everything and return carriage and turbine back
        to zero."""
        self.autoaborted = True
        acsc.stopBuffer(self.hc, 19)
        acsc.halt(self.hc, 0)
        acsc.halt(self.hc, 1)
        acsc.halt(self.hc, 4)
        acsc.halt(self.hc, 5)
        acsc.toPoint(self.hc, None, 4, 0.0)
        acsc.setVelocity(self.hc, 5, 0.5)
        acsc.toPoint(self.hc, None, 5, 0.0)
vec.sync_master = True
vec.sample_rate = 100
vec.vel_range = 2
vec.transmit_length = 3
vec.sampling_volume = 3
vec.salinity = 0.0
vec.power_level = "High"
vec.connect()

while not vec.connected:
    print "Connecting..."
    time.sleep(0.5)    
print "Connected!"

vec.set_config()
vec.stop()
vec.start_disk_recording("test/test", False)
vec.start()

while vec.state != "Confirmation mode":
    time.sleep(0.2)
print "Collecting data..."

i = 0
t0 = time.time()
t = 0

while t < 10:
    print "Signal to noise ratio (dB):", vec.get_snr(1,1)
    i += 1
    t = time.time() - t0
Beispiel #5
0
class TurbineTow(QtCore.QThread):
    towfinished = QtCore.pyqtSignal()
    def __init__(self, acs_hcomm, U, tsr, y_R, z_H, 
                 turbine_properties, nidaq=True, vectrino=True, vecsavepath="",
                 fbg=False, fbg_properties={}, settling=False, vec_salinity=0.0):
        """Turbine tow run object."""
        QtCore.QThread.__init__(self)        
        self.hc = acs_hcomm
        self.U = float(U)
        self.tsr = tsr
        self.y_R = y_R
        self.z_H = z_H
        self.R = turbine_properties["radius"]
        self.H = turbine_properties["height"]
        self.vectrino = vectrino
        self.nidaq = nidaq 
        self.fbg = fbg
        self.settling = settling
        self.build_acsprg()
        self.acsdaqthread = daqtasks.AcsDaqThread(self.hc)
        self.maxvel = U*1.3
        self.usetrigger = True
        self.vecsavepath = vecsavepath
        self.recordvno = True
        self.vecstatus = "Vectrino disconnected "
        self.autoaborted = False
        self.aborted = False
        self.vec_salinity = vec_salinity
        
        commit = check_output(["git", "rev-parse", "--verify", "HEAD"])[:-1]
        
        self.metadata = {"Tow speed (m/s)" : float(U),
                         "Tip speed ratio" : tsr, 
                         "Time created" : time.asctime(),
                         "TurbineDAQ version" : commit}
        
        if self.vectrino:
            self.vec = PdControl()
            self.metadata["Vectrino metadata"] = {"y/R": y_R, "z/H": z_H}
            
        if self.nidaq:
            self.daqthread = daqtasks.NiDaqThread(usetrigger=self.usetrigger)
            self.nidata = self.daqthread.data
            self.metadata["NI metadata"] = self.daqthread.metadata
        
        if self.fbg:
            self.fbgthread = daqtasks.FbgDaqThread(fbg_properties, 
                                                   usetrigger=self.usetrigger)
            self.metadata["FBG metadata"] = self.fbgthread.metadata
            self.fbgdata = self.fbgthread.data
        
    def build_acsprg(self):
        """Create the ACSPL+ program for running the run.
        This run should send a trigger pulse."""
        if self.settling:
            endpos = 9.0
        else:
            endpos = 0.0
        self.acs_prg = acsprgs.turbine_tow_prg(self.U, self.tsr, self.R,
                                               endpos=endpos)
                                               
    def setvecconfig(self):
        self.vec.start_on_sync = self.usetrigger
        self.vec.sync_master = not self.usetrigger
        self.vec.sample_on_sync = False
        self.vec.sample_rate = 200
        self.vec.coordinate_system = "XYZ"
        self.vec.power_level = "High"
        self.vec.transmit_length = 3
        self.vec.sampling_volume = 3
        self.vec.sound_speed_mode = "measured"
        self.vec.salinity = self.vec_salinity
        
        if self.maxvel <= 4.0 and self.maxvel > 2.5:
            self.vec.vel_range = 0
        elif self.maxvel <= 2.5 and self.maxvel > 1.0:
            self.vec.vel_range = 1
        elif self.maxvel <= 1.0 and self.maxvel > 0.3:
            self.vec.vel_range = 2
        elif self.maxvel <= 0.3 or self.settling:
            self.vec.vel_range = 3
        self.vec.set_config()
        self.metadata["Vectrino metadata"]["Velocity range (index)"] = \
                self.vec.vel_range
        self.metadata["Vectrino metadata"]["Sample rate (Hz)"] = \
                self.vec.sample_rate
        self.metadata["Vectrino metadata"]["Coordinate system"] = \
                self.vec.coordinate_system
        self.metadata["Vectrino metadata"]["Salinity (ppt)"] = \
                self.vec.salinity
        self.metadata["Vectrino metadata"]["Transmit length"] = \
                self.vec.transmit_length
        self.metadata["Vectrino metadata"]["Sampling volume"] = \
                self.vec.sampling_volume
        print("Vectrino configuration set")

    def run(self):
        """Start the run. Comms should be open already with the controller."""
        if acsc.getOutput(self.hc, 1, 16):
            acsc.setOutput(self.hc, 1, 16, 0)
        if self.vectrino:
            acsc.enable(self.hc, 0)
            acsc.enable(self.hc, 1)
            while not acsc.getMotorState(self.hc, 0)["enabled"] or not \
                    acsc.getMotorState(self.hc, 1)["enabled"]:
                self.msleep(100)
            acsc.toPoint(self.hc, None, 0, self.y_R*self.R)
            acsc.toPoint(self.hc, None, 1, self.z_H*self.H)
            while not acsc.getMotorState(self.hc, 0)["in position"] or not \
                    acsc.getMotorState(self.hc, 1)["in position"]:
                self.msleep(300)
            print("y- and z-axes in position")
            acsc.disable(self.hc, 0)
            acsc.disable(self.hc, 1)
            self.vec.serial_port = "COM2"
            self.vec.connect()
            tstart = time.time()
            self.timeout = False
            self.vecstatus = "Connecting to Vectrino..."
            while not self.vec.connected:
                self.msleep(300)
                if time.time() - tstart > 10:
                    print("Vectrino timed out")
                    self.timeout = True
                    break
            if not self.timeout:
                self.vec.stop()
                self.setvecconfig()
                if self.recordvno:
                    self.vec.start_disk_recording(self.vecsavepath)
                self.vec.start()
                self.vecstatus = "Vectrino connected "
                while self.vec.state != "Confirmation mode":
                    self.msleep(100)
                print("Vectrino in data collection mode")
                print("Waiting 6 seconds")
                self.sleep(6)
                self.daqthread.start()
                if self.fbg:
                    self.fbgthread.start()
                self.start_motion()
        elif self.nidaq:
            self.daqthread.start()
            if self.fbg:
                self.fbgthread.start()
            self.start_motion()
        else:
            # Start motion
            self.start_motion()

    def start_motion(self):
        self.acsdaqthread.start()
        nbuf = 19
        acsc.loadBuffer(self.hc, nbuf, self.acs_prg, 2048)
        acsc.enable(self.hc, 4)
        acsc.enable(self.hc, 5)
        acsc.runBuffer(self.hc, nbuf)
        prgstate = acsc.getProgramState(self.hc, nbuf)
        while prgstate == 3:
            time.sleep(0.3)
            prgstate = acsc.getProgramState(self.hc, nbuf)
        self.acsdaqthread.stop()
        if self.nidaq:
            self.daqthread.clear()
            print("NI tasks cleared")
        if self.fbg:
            self.fbgthread.stop()
        if self.vectrino:
            if self.settling:
                # Wait 10 minutes to measure tank settling time
                print("Waiting 10 minutes")
                t0 = time.time()
                dt = 0.0
                while not self.aborted and dt < 600:
                    time.sleep(0.5)
                    dt = time.time() - t0
            if self.recordvno:
                self.vec.stop_disk_recording()
            self.vec.stop()
            self.vec.disconnect()
        print("Tow finished")
        if self.vectrino:
            if self.vec.state == "Not connected":
                self.vecstatus = "Vectrino disconnected "
            print("Resetting Vectrino")
            self.reset_vec()
        self.towfinished.emit()
        
    def reset_vec(self):
        self.vec.connect()
        self.vec.stop_disk_recording()
        self.vec.stop()
        self.vec.disconnect()
        self.vec.data = {}
        print("Vectrino reset")

    def abort(self):
        """This should stop everything."""
        print("Aborting turbine tow")
        self.aborted = True
        acsc.stopBuffer(self.hc, 19)
        acsc.halt(self.hc, 0)
        acsc.halt(self.hc, 1)
        acsc.halt(self.hc, 4)
        acsc.halt(self.hc, 5)
        
    def autoabort(self):
        """This should stop everything and return carriage and turbine back
        to zero."""
        self.autoaborted = True
        acsc.stopBuffer(self.hc, 19)
        acsc.halt(self.hc, 0)
        acsc.halt(self.hc, 1)
        acsc.halt(self.hc, 4)
        acsc.halt(self.hc, 5)
        acsc.toPoint(self.hc, None, 4, 0.0)
        acsc.setVelocity(self.hc, 5, 0.5)
        acsc.toPoint(self.hc, None, 5, 0.0)
Beispiel #6
0
class VectrinoThread(QtCore.QThread):
    """Thread for running Vectrino"""
    collecting = QtCore.pyqtSignal()
    connectsignal = QtCore.pyqtSignal(bool)

    def __init__(self,
                 maxvel=2.5,
                 usetrigger=True,
                 record=False,
                 salinity=0.0):
        QtCore.QThread.__init__(self)
        print("Vectrino thread initialized")
        self.vec = PdControl()
        self.vecdata = self.vec.data
        self.usetrigger = usetrigger
        self.maxvel = maxvel
        self.comport = "COM2"
        self.record = record
        self.isconnected = self.vec.connected
        self.savepath = ""
        self.vecstatus = "Vectrino disconnected "
        self.enable = True
        self.salinity = salinity
        print("Vectrino thread init done")

    def setconfig(self):
        self.vec.start_on_sync = self.usetrigger
        self.vec.sync_master = not self.usetrigger
        self.vec.sample_on_sync = False
        self.vec.sample_rate = 200
        self.vec.transmit_length = 3
        self.vec.sampling_volume = 3
        self.vec.sound_speed_mode = "measured"
        self.vec.salinity = self.salinity
        self.vec.power_level = "High"
        if self.maxvel <= 4.0 and self.maxvel > 2.5:
            self.vec.vel_range = 0
        elif self.maxvel <= 2.5 and self.maxvel > 1.0:
            self.vec.vel_range = 1
        elif self.maxvel <= 1.0 and self.maxvel > 0.3:
            self.vec.vel_range = 2
        self.vec.set_config()
        print("Vectrino configuration set")

    def run(self):
        self.vec.serial_port = self.comport
        self.vec.connect()
        tstart = time.time()
        self.timeout = False
        self.vecstatus = "Connecting to Vectrino..."
        while not self.vec.connected:
            time.sleep(0.5)
            if time.time() - tstart > 10:
                print("Vectrino timed out")
                self.timeout = True
                self.connectsignal.emit(False)
                break
        if not self.timeout:
            self.connectsignal.emit(True)
            self.vec.stop()
            self.setconfig()
            if self.record:
                self.vec.start_disk_recording(self.savepath)
            self.vec.start()
            self.vecstatus = "Vectrino connected "
            while self.vec.state != "Confirmation mode":
                time.sleep(0.1)
            print("Vectrino in data collection mode")
            time.sleep(6)
            self.collecting.emit()
            print("Vectrino collecting")

    def getstatus(self):
        return self.vec.state

    def stop(self):
        self.enable = False
        if self.record:
            self.vec.stop_disk_recording()
        self.vec.stop()
        self.vec.disconnect()
        self.vecstatus = "Vectrino disconnected "
Beispiel #7
0
vec.sync_master = True
vec.sample_rate = 100
vec.vel_range = 2
vec.transmit_length = 3
vec.sampling_volume = 3
vec.salinity = 0.0
vec.power_level = "High"
vec.connect()

while not vec.connected:
    print "Connecting..."
    time.sleep(0.5)
print "Connected!"

vec.set_config()
vec.stop()
vec.start_disk_recording("test/test", False)
vec.start()

while vec.state != "Confirmation mode":
    time.sleep(0.2)
print "Collecting data..."

i = 0
t0 = time.time()
t = 0

while t < 10:
    print "Signal to noise ratio (dB):", vec.get_snr(1, 1)
    i += 1
    t = time.time() - t0
Beispiel #8
0
class VectrinoThread(QtCore.QThread):
    """Thread for running Vectrino"""
    collecting = QtCore.pyqtSignal()
    connectsignal = QtCore.pyqtSignal(bool)
    def __init__(self, maxvel=2.5, usetrigger=True, record=False, salinity=0.0):
        QtCore.QThread.__init__(self)
        print("Vectrino thread initialized")
        self.vec = PdControl()
        self.vecdata = self.vec.data
        self.usetrigger = usetrigger
        self.maxvel = maxvel
        self.comport = "COM2"
        self.record = record
        self.isconnected = self.vec.connected
        self.savepath = ""
        self.vecstatus = "Vectrino disconnected "
        self.enable = True
        self.salinity = salinity
        print("Vectrino thread init done")
        
    def setconfig(self):
        self.vec.start_on_sync = self.usetrigger
        self.vec.sync_master = not self.usetrigger
        self.vec.sample_on_sync = False
        self.vec.sample_rate = 200 
        self.vec.transmit_length = 3
        self.vec.sampling_volume = 3
        self.vec.sound_speed_mode = "measured"
        self.vec.salinity = self.salinity
        self.vec.power_level = "High"
        if self.maxvel <= 4.0 and self.maxvel > 2.5:
            self.vec.vel_range = 0
        elif self.maxvel <= 2.5 and self.maxvel > 1.0:
            self.vec.vel_range = 1
        elif self.maxvel <= 1.0 and self.maxvel > 0.3:
            self.vec.vel_range = 2
        self.vec.set_config()
        print("Vectrino configuration set")

    def run(self):
        self.vec.serial_port = self.comport
        self.vec.connect()
        tstart = time.time()
        self.timeout = False
        self.vecstatus = "Connecting to Vectrino..."
        while not self.vec.connected:
            time.sleep(0.5)
            if time.time() - tstart > 10:
                print("Vectrino timed out")
                self.timeout = True
                self.connectsignal.emit(False)
                break
        if not self.timeout:
            self.connectsignal.emit(True)
            self.vec.stop()
            self.setconfig()
            if self.record:
                self.vec.start_disk_recording(self.savepath)
            self.vec.start()
            self.vecstatus = "Vectrino connected "
            while self.vec.state != "Confirmation mode":
                time.sleep(0.1)
            print("Vectrino in data collection mode")
            time.sleep(6)
            self.collecting.emit()
            print("Vectrino collecting")

    def getstatus(self):
        return self.vec.state
        
    def stop(self):
        self.enable = False
        if self.record:
            self.vec.stop_disk_recording()
        self.vec.stop()
        self.vec.disconnect()
        self.vecstatus = "Vectrino disconnected "