コード例 #1
0
ファイル: hal.py プロジェクト: LuisFuentes/pyelixys
 def set_duty_cycle(self, value):
     log.debug("Set Mixer %d duty cycle -> %f" % (self.id_, value))        
     if value >= 0.0 and value <= 100.0:
         self.duty_ = value
         cmd = self.cmd_lookup['Mixers']['set_duty_cycle'][self.id_](value)
         self.comproc.run_cmd(cmd)
     else:
         # Raise Exception, value out of range!
         log.error("Mixer %d duty cycle -> %f out of range" % (self.id_, value))                
コード例 #2
0
 def set_duty_cycle(self, value):
     log.debug("Set Mixer %d duty cycle -> %f" % (self.id_, value))
     if value >= 0.0 and value <= 100.0:
         self.duty_ = value
         cmd = self.cmd_lookup['Mixers']['set_duty_cycle'][self.id_](value)
         self.comproc.run_cmd(cmd)
     else:
         # Raise Exception, value out of range!
         log.error("Mixer %d duty cycle -> %f out of range" %
                   (self.id_, value))
コード例 #3
0
ファイル: hal.py プロジェクト: mgramli1/pyelixys
    def set_analog_out(self, value):
        if not(value >= 0.0 and value <= 10.0):
            # Should raise exception in future!!!!
            log.error("SMC Analog setpoint (%f) out of range" % value)
            return
        self.comproc.run_cmd(self.cmd_lookup['SMCInterfaces']['set_analog_out'][self.id_](value))
        log.debug("Set SMC Analog out %d on -> %s"
                  % (self.id_, value))

        self.analog_out_ = value
コード例 #4
0
    def set_analog_out(self, value):
        if not (value >= 0.0 and value <= 10.0):
            # Should raise exception in future!!!!
            log.error("SMC Analog setpoint (%f) out of range" % value)
            return
        self.comproc.run_cmd(self.cmd_lookup['SMCInterfaces']['set_analog_out']
                             [self.id_](value))
        log.debug("Set SMC Analog out %d on -> %s" % (self.id_, value))

        self.analog_out_ = value
コード例 #5
0
 def lower(self):
     """ Lower actuator and unsure it gets there """
     for i in xrange(self.conf['retry_count']):
         begintime = datetime.now()
         self.lower_no_check()
         while self.timeout > datetime.now() - begintime:
             time.sleep(0.1)
             if self.is_down:
                 log.debug("Lower actuator %s success", repr(self))
                 return
         log.info("Failed to raise actuator %s before timeout, retry %d",
                     repr(self), i)
     log.error("Failed to lower actuator %s after retrys", repr(self))
コード例 #6
0
ファイル: gripper.py プロジェクト: jccbnyn/pyelixys
 def close(self):
     """ Close the gripper and make sure it closes """
     for i in xrange(self.conf['retry_count']):
         begintime = datetime.now()
         self.close_no_check()
         while self.timeout > datetime.now() - begintime:
             time.sleep(0.1)
             if self.is_closed:
                 log.debug("Close actuator %s success", repr(self))
                 return
         log.info("Failed to close actuator %s before timeout, retry %d",
                  repr(self), i)
     log.error("Failed to close actuator %s after retrys", repr(self))
コード例 #7
0
ファイル: gripper.py プロジェクト: LuisFuentes/pyelixys
 def close(self):
     """ Close the gripper and make sure it closes """
     for i in xrange(self.conf['retry_count']):
         begintime = datetime.now()
         self.close_no_check()
         while self.timeout > datetime.now() - begintime:
             time.sleep(0.1)
             if self.is_closed:
                 log.debug("Close actuator %s success", repr(self))
                 return
         log.info("Failed to close actuator %s before timeout, retry %d",
                     repr(self), i)
     log.error("Failed to close actuator %s after retrys", repr(self))
コード例 #8
0
ファイル: gripper.py プロジェクト: jccbnyn/pyelixys
    def open(self):
        """ Open the gripper and make sure it opens """
        for i in xrange(self.conf['retry_count']):
            begintime = datetime.now()
            self.open_no_check()
            while self.timeout > datetime.now() - begintime:
                time.sleep(0.1)
                if self.is_open:
                    log.debug("Open actuator %s success", repr(self))
                    return

            log.info("Failed to open actautor %s before timeout, retry %d",
                     repr(self), i)
        log.error("Failed to open actuator %s after retrys", repr(self))
コード例 #9
0
ファイル: linearaxis.py プロジェクト: mgramli1/pyelixys
    def wait(self, timeout=None):
        """ Wait for the motion to be complete """
        if timeout is None:
            timeout = self.conf['MOVETIMEOUT']

        dtimeout = timedelta(0, timeout)
        move_start_time = datetime.now()
        while datetime.now() - move_start_time < dtimeout:
            if self.isMoveComplete():
                return True
            log.info("Waiting for complete actuator %d", self.id_)

        log.error("Motion Timeout actuator %d", self.id_ )
        raise ElixysLinactError("%s unable to complete move before timeout")
コード例 #10
0
    def lift(self):
        """ Move the actuator up and ensure it gets there """
        for i in xrange(self.conf['retry_count']):
            begintime = datetime.now()
            self.lift_no_check()
            while self.timeout > datetime.now() - begintime:
                time.sleep(0.1)
                if self.is_up:
                    log.debug("Lift actuator %s success", repr(self))
                    return

            log.info("Failed to raise actautor %s before timeout, retry %d",
                        repr(self), i)
        log.error("Failed to raise actuator %s after retrys", repr(self))
コード例 #11
0
ファイル: gripper.py プロジェクト: LuisFuentes/pyelixys
    def open(self):
        """ Open the gripper and make sure it opens """
        for i in xrange(self.conf['retry_count']):
            begintime = datetime.now()
            self.open_no_check()
            while self.timeout > datetime.now() - begintime:
                time.sleep(0.1)
                if self.is_open:
                    log.debug("Open actuator %s success", repr(self))
                    return

            log.info("Failed to open actautor %s before timeout, retry %d",
                        repr(self), i)
        log.error("Failed to open actuator %s after retrys", repr(self))
コード例 #12
0
ファイル: controlbox.py プロジェクト: henryeherman/pyelixys
    def read(self, retry=2):
        """ This will replace the serial read.
        Make sure comport is avialable. If so
        read! Else try to open.  If can't open
        raise exception.
        """
        for idx in range(retry):
            try:
                resp = self.serial.readline()
                return resp
            except SerialException:
                log.error("CBox Com error, retry %d", idx)
                self.reconnect()

        raise ElixysComportError("Failed to read from CBox, %d retries" % retry)
コード例 #13
0
ファイル: controlbox.py プロジェクト: henryeherman/pyelixys
    def write(self, msg, retry=2):
        """ This will replace the serial write.
        This should make sure the comport is open
        and available.  It NOT retry to open!
        If we can't open raise exception.
        """
        for idx in range(retry):
            try:
                self.serial.write(msg)
                return
            except SerialException:
                log.error("CBox Com error, retry %d", idx)
                self.reconnect()

        raise ElixysComportError("Failed to write to CBox, %d retries" % retry)
コード例 #14
0
    def write(self, msg, retry=2):
        """ This will replace the serial write.
        This should make sure the comport is open
        and available.  It NOT retry to open!
        If we can't open raise exception.
        """
        for idx in range(retry):
            try:
                self.serial.write(msg)
                return
            except SerialException:
                log.error("CBox Com error, retry %d", idx)
                self.reconnect()

        raise ElixysComportError("Failed to write to CBox, %d retries" % retry)
コード例 #15
0
 def lower(self):
     """ Lower actuator and ensure it gets there """
     self.prepare_air()
     for i in xrange(self.conf['retry_count']):
         begintime = datetime.now()
         self.lower_no_check()
         while self.timeout > datetime.now() - begintime:
             time.sleep(0.1)
             if self.is_down:
                 log.debug("Lower actuator %s success", repr(self))
                 return
         log.info("Failed to raise actuator %s before timeout, retry %d",
                     repr(self), i)
     log.error("Failed to lower actuator %s after retrys", repr(self))
     raise ElixysPneumaticError("Failed to lower %s"
             " check digital sensors and pressure source"% repr(self))
コード例 #16
0
    def read(self, retry=2):
        """ This will replace the serial read.
        Make sure comport is avialable. If so
        read! Else try to open.  If can't open
        raise exception.
        """
        for idx in range(retry):
            try:
                resp = self.serial.readline()
                return resp
            except SerialException:
                log.error("CBox Com error, retry %d", idx)
                self.reconnect()

        raise ElixysComportError("Failed to read from CBox, %d retries" %
                                 retry)
コード例 #17
0
ファイル: linearaxis.py プロジェクト: mgramli1/pyelixys
    def move_and_wait(self, posmm, timeout=None):
        """ Move, and wait for it to complete
        make sure to do this within and alotted timeout.
        """
        if timeout is None:
            timeout = self.conf['MOVETIMEOUT']

        dtimeout = timedelta(0, timeout)
        move_start_time = datetime.now()
        self.move(posmm)
        while datetime.now() - move_start_time < dtimeout:
            if self.isMoveComplete():
                return True
            log.info("Waiting for complete actuator %d", self.id_)

        log.error("Motion Timeout actuator %d", self.id_ )
        raise ElixysLinactError("%s unable to complete move before timeout")
コード例 #18
0
ファイル: controlbox.py プロジェクト: henryeherman/pyelixys
    def __init__(self):
        super(ControlBoxSystem, self).__init__()
        self.conf = self.sysconf['ControlBox']
        if os.name == 'nt':
            self._port = self.conf['win_port']
        elif os.name == 'posix':
            self._port = self.conf['posix_port']
        else:
            raise ElixysComportError("Could not "
                    "determine platform for port")
        self._baud = self.conf['baud']

        if self.sysconf['Simulator']['controlbox']:
            log.debug("Loading the control box simulator")
            from pyelixys.hal.tests.testcontrolbox import CBoxSim
            self.serial = CBoxSim()
            return

        try:
            self.serial = serial.Serial(port=self._port,
                                    baudrate=self._baud,
                                    timeout=0.2)
	    if os.name == 'posix':
		self.serial.close()
		self.serial.baudrate = 115200
                self.serial.baudrate = self._baud
		self.serial.open()
		self.serial.baudrate = 115200
		self.serial.baudrate = self._baud
        except SerialException:
            log.error("Failed to open comport %s", self._port)
            raise ElixysComportError("Serial COM port not available at %s."
                                    "Ensure CBox Board is connected and "
                                    "user has permission to"
                                    "access device" % self._port)

        self._leds = 0
コード例 #19
0
    def __init__(self):
        super(ControlBoxSystem, self).__init__()
        self.conf = self.sysconf['ControlBox']
        if os.name == 'nt':
            self._port = self.conf['win_port']
        elif os.name == 'posix':
            self._port = self.conf['posix_port']
        else:
            raise ElixysComportError("Could not "
                                     "determine platform for port")
        self._baud = self.conf['baud']

        if self.sysconf['Simulator']['controlbox']:
            log.debug("Loading the control box simulator")
            from pyelixys.hal.tests.testcontrolbox import CBoxSim
            self.serial = CBoxSim()
            return

        try:
            self.serial = serial.Serial(port=self._port,
                                        baudrate=self._baud,
                                        timeout=0.2)
            if os.name == 'posix':
                self.serial.close()
                self.serial.baudrate = 115200
                self.serial.baudrate = self._baud
                self.serial.open()
                self.serial.baudrate = 115200
                self.serial.baudrate = self._baud
        except SerialException:
            log.error("Failed to open comport %s", self._port)
            raise ElixysComportError("Serial COM port not available at %s."
                                     "Ensure CBox Board is connected and "
                                     "user has permission to"
                                     "access device" % self._port)

        self._leds = 0