コード例 #1
0
ファイル: stick.py プロジェクト: wkcwells/mmeowlink
    def power_control(self, minutes=None):
        """ Control Pumping """  # Bad comment
        log.warning('BEGIN POWER CONTROL %s' % self.serial)

        current_time = time.time()
        if current_time < self.last_command_time + (60 *
                                                    self.MAX_SESSION_DURATION):
            log.warning("Power control: Expecting that pump is still awake.")
            return self.model

        model = self.get_model()
        if model is not None:
            log.warning("Pump is already awake.  Model = " + model)
            return model

        self.command = commands.PowerControl(**dict(
            minutes=minutes, serial=self.serial
        ))  # Don't know that we need to setup the dict this way - just legacy
        repeater = Repeater(self.link)

        status = repeater(self.command, repetitions=500, ack_wait_seconds=20)

        if status:
            model = self.get_model()
            if model is not None:
                return model
            # Else what?
        else:
            raise CommsException(
                "No acknowledgement from pump on wakeup. Is it out of range or is the battery too low?"
            )
コード例 #2
0
ファイル: stick.py プロジェクト: ninastykowska/mmeowlink
  def power_control (self, minutes=None):
    """ Control Pumping """
    log.info('BEGIN POWER CONTROL %s' % self.serial)
    self.command = commands.PowerControl(**dict(minutes=minutes, serial=self.serial))
    repeater = Repeater(self.link)

    repeater(self.command, repetitions=500, ack_wait_seconds=15, retry_count=2)
コード例 #3
0
ファイル: stick.py プロジェクト: alexaps1/myopenaos
    def power_control(self, minutes=None):
        """ Control Pumping """

        # See if the pump is on and responding to messages. If it isn't, then
        # we need to send a wakeup to the pump
        if self.check_pump_awake():
            log.info(
                'Pump %s is already responding. Not sending wakeup messages' %
                self.serial)
            return True
        else:
            log.info('BEGIN POWER CONTROL %s' % self.serial)
            self.command = commands.PowerControl(
                **dict(minutes=minutes, serial=self.serial))
            repeater = Repeater(self.link)

            status = repeater(self.command,
                              repetitions=500,
                              ack_wait_seconds=12)

            if status:
                return True
            else:
                raise CommsException(
                    "No acknowledgement from pump on wakeup. Is it out of range or is the battery too low?"
                )
コード例 #4
0
ファイル: stick.py プロジェクト: sniperlucian/mmblelink
 def power_control (self, minutes=None):
   log.info('BEGIN POWER CONTROL %s' % self.serial)
   # print "PowerControl SERIAL", self.serial
   command = commands.PowerControl(**dict(minutes=minutes, serial=self.serial))
   transfer = Repeater(self.link)
   response = transfer(command)
   # response = self.query(commands.PowerControl, minutes=minutes)
   power = response
   log.info('manually download PowerControl serial %s' % self.serial)
   data = dict(raw=str(power.data).encode('hex'), ok=power.done( ), minutes=minutes)
   return data
コード例 #5
0
ファイル: stick.py プロジェクト: jbwittmer/mmeowlink
  def power_control (self, minutes=None):
    """ Control Pumping """
    log.info('BEGIN POWER CONTROL %s' % self.serial)
    self.command = commands.PowerControl(**dict(minutes=minutes, serial=self.serial))
    repeater = Repeater(self.link)

    status = repeater(self.command, repetitions=500, ack_wait_seconds=20)

    return True
    if status:
      return True
    else:
      raise CommsException("No acknowledgement from pump on wakeup. Is it out of range or is the battery too low?")