<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def connect(self, uuid_value, wait=None):
 """Connect to a specific device by its uuid Attempt to connect to a device that we have previously scanned using its UUID. If wait is not None, then it is used in the same was a scan(wait) to override default wait times with an explicit value. Args: uuid_value (int):
 The unique id of the device that we would like to connect to. wait (float):
 Optional amount of time to force the device adapter to wait before attempting to connect. """


        if self.connected:
            raise HardwareError("Cannot connect when we are already connected")

        if uuid_value not in self._scanned_devices:
            self.scan(wait=wait)

        with self._scan_lock:
            if uuid_value not in self._scanned_devices:
                raise HardwareError("Could not find device to connect to by UUID", uuid=uuid_value)

            connstring = self._scanned_devices[uuid_value]['connection_string']

        self.connect_direct(connstring)