示例#1
0
def QueryPenUp(port_name):
    if port_name is not None:
        pen_status = ebb_serial.query(port_name, 'QP\r')
        if pen_status[0] == '0':
            return False
        else:
            return True
示例#2
0
	def ServoSetupWrapper( self ):
		self.ServoSetup()
		strVersion = ebb_serial.query( self.serialPort,  'QP\r' ) #Query pen position: 1 up, 0 down (followed by OK)
		if strVersion[0] == '0':
			ebb_motion.sendPenDown(self.serialPort, 0)				
		else:
			ebb_motion.sendPenUp(self.serialPort, 0)				
示例#3
0
def queryVoltage(portName):
    # Query the EBB motor power supply input voltage.
    if (portName is not None):
        EBBversionString = ebb_serial.queryVersion(
            portName)  # Full string, human readable

        EBBversionString = EBBversionString.split("Firmware Version ", 1)

        splitLen = len(EBBversionString)
        if splitLen > 1:
            EBBversionString = EBBversionString[1]
        else:
            return True  # We haven't received a reasonable version number response.
            # Ignore voltage test and return.
        EBBversionString = EBBversionString.strip(
        )  # Stripped copy, for version # comparisons
        if (EBBversionString is not "none"):
            if (LooseVersion(EBBversionString) >= LooseVersion("2.2.3")):
                rawString = (ebb_serial.query(portName, 'QC\r'))
                splitString = rawString.split(",", 1)
                splitLen = len(splitString)
                if splitLen > 1:
                    voltagevalue = int(
                        splitString[1])  # Pick second value only
                else:
                    return True  # We haven't received a reasonable voltage string response.
                    # Ignore voltage test and return.
                # Typical reading is about 300, for 9 V input.
                if (voltagevalue < 250):
                    return False
    return True
示例#4
0
def QueryPenUp(portName):
    if (portName is not None):
        PenStatus = ebb_serial.query(portName, 'QP\r')
        if PenStatus[0] == '0':
            return False
        else:
            return True
示例#5
0
	def ServoSetupWrapper( self ):
		self.ServoSetup()
		strVersion = ebb_serial.query( self.serialPort,  'QP\r' ) #Query pen position: 1 up, 0 down (followed by OK)
		if strVersion[0] == '0':
# 			ebb_serial.command( self.serialPort,  'SP,0\r' )	
			ebb_motion.sendPenDown(self.serialPort, 0)				
		else:
# 			ebb_serial.command( self.serialPort,  'SP,1\r'  )	
			ebb_motion.sendPenUp(self.serialPort, 0)				
示例#6
0
def queryEBBLV(port_name):
    # Query the EBB "Layer" Variable, an 8-bit number we can read and write.
    # (Unrelated to our plot layers; name is an historical artifact.)
    if port_name is not None:
        value = ebb_serial.query(port_name, 'QL\r')
        try:
            ret_val = int(value)
            return value
        except:
            return None
示例#7
0
 def getReady(self):
     if (self.port is not None):
         nRetryCount = 0
         while (nRetryCount < 100):
             liststatus = ebb_serial.query(self.port,
                                           'QM\r').strip().split(",")
             if liststatus[0] == "QM" and any(
                 [int(aa) for aa in liststatus[1:]]) == False:
                 return
             else:
                 time.sleep(0.1)
                 nRetryCount += 1
         print("getReady time-out")
示例#8
0
 def getStepPosition(self, getnow=True):
     if getnow == False:
         self.getReady()
     if (self.port is not None):
         nRetryCount = 0
         while (nRetryCount < 100):
             try:
                 liststatus = ebb_serial.query(self.port, "QS\r").split(",")
                 liststatus = [int(aa) for aa in liststatus]
                 if len(liststatus) == 2:
                     return [(liststatus[0] + liststatus[1]) // 2,
                             (liststatus[0] - liststatus[1]) // 2]
             except:
                 pass
             nRetryCount += 1
示例#9
0
def queryVoltage(portName):
    # Query the EBB motor power supply input voltage.
    if (portName is not None):
        EBBversionString = ebb_serial.queryVersion(
            portName)  # Full string, human readable
        EBBversionString = EBBversionString.split(
            "Version ", 1)[1]  # Stripped copy, for version # comparisons
        EBBversionString = EBBversionString.strip()
        if (EBBversionString is not "none"):
            if (LooseVersion(EBBversionString) >= LooseVersion("2.2.3")):
                rawString = (ebb_serial.query(portName, 'QC\r'))
                voltagevalue = int(rawString.split(
                    ",", 1)[1])  # Pick second value only
                # Typical reading is about 300, for 9 V input.
                if (voltagevalue < 250):
                    return False
    return True
示例#10
0
def queryVoltage(port_name):
    # Query the EBB motor power supply input voltage.
    if port_name is not None:
        version_status = ebb_serial.min_version(port_name,"2.2.3")
        if not version_status:
            return True # Unable to read version, or version is below 2.2.3.
                        # In these cases, issue no voltage warning.
        else:
            raw_string = (ebb_serial.query(port_name, 'QC\r'))
            split_string = raw_string.split(",", 1)
            split_len = len(split_string)
            if split_len > 1:
                voltage_value = int(split_string[1])  # Pick second value only
            else:
                return True  # We haven't received a reasonable voltage string response.
                # Ignore voltage test and return.
            # Typical reading is about 300, for 9 V input.
            if voltage_value < 250:
                return False
    return True
示例#11
0
def QueryPRGButton(port_name):
    if port_name is not None:
        return ebb_serial.query(port_name, 'QB\r')
示例#12
0
 def getEBBVersion(self):
     return ebb_serial.query(self.port, "V\r")
示例#13
0
 def QueryPRGButton(self):
     self.getReady()
     if (self.port is not None):
         return ebb_serial.query(self.port, 'QB\r')
示例#14
0
	def manualCommand( self ):
		"""Execute commands from the "manual" tab"""

		if self.options.manualType == "none":
			return
			
		if self.serialPort is None:
			return
			
		if self.options.manualType == "raise-pen":
			self.ServoSetupWrapper()
			self.penUp()

		elif self.options.manualType == "lower-pen":
			self.ServoSetupWrapper()
			self.penDown()

		elif self.options.manualType == "enable-motors":
			ebb_motion.sendEnableMotors(self.serialPort, 1) # 16X microstepping

		elif self.options.manualType == "disable-motors":
			self.sendDisableMotors()

		elif self.options.manualType == "version-check":
			strVersion = ebb_serial.query( self.serialPort, 'v\r' )
			inkex.errormsg( 'I asked the EBB for its version info, and it replied:\n ' + strVersion )

		elif self.options.manualType == "enable-engraver":
			if ( not self.options.engraving ):
				inkex.errormsg( gettext.gettext( "The engraver option is disabled. " + \
				" Please enable it first from the \"Options\" tab." ) )
			else:
				self.engraverOn()

		elif self.options.manualType == 'disable-engraver':
			self.engraverOffManual() #Force engraver off, even if it is not enabled.

		else:  # self.options.manualType is "walk-egg-motor" or "walk-pen-motor":
			if self.options.manualType == "walk-egg-motor":
				nDeltaX = self.options.WalkDistance
				nDeltaY = 0
			elif self.options.manualType == "walk-pen-motor":
				nDeltaY = self.options.WalkDistance
				nDeltaX = 0
			else:
				return
				
			ebb_motion.sendEnableMotors(self.serialPort, 1) # 16X microstepping
			
			#Query pen position: 1 up, 0 down (followed by OK)
			strVersion = ebb_serial.query( self.serialPort, 'QP\r' )
			
			if strVersion[0] == '0':
				self.fSpeed = self.options.penDownSpeed
			if strVersion[0] == '1':
				self.fSpeed = self.options.penUpSpeed

			if ( self.options.revPenMotor ):
				nDeltaY = -1 * nDeltaY
			if ( self.options.revEggMotor ):
				nDeltaX = -1 * nDeltaX
			
			nTime = 10000.00 / self.fSpeed * plot_utils.distance( nDeltaX, nDeltaY )
			nTime = int( math.ceil(nTime / 10.0))
			
			strOutput = ','.join( ['SM', str( nTime ), str( nDeltaY ), str( nDeltaX )] ) + '\r'
			#inkex.errormsg( 'strOutput:  ' + strOutput )

			ebb_serial.command( self.serialPort, strOutput )
示例#15
0
def queryEBBLV(portName):
    # Query the EBB "Layer" Variable, an 8-bit number we can read and write.
    # (Unrelated to our plot layers; name is an historical artifact.)
    if (portName is not None):
        return (int(ebb_serial.query(portName, 'QL\r')))
示例#16
0
	def manualCommand( self ):
		"""Execute commands from the "manual" tab"""

		if self.options.manualType == "none":
			return
			
		if self.serialPort is None:
			return
			
		if self.options.manualType == "raise-pen":
			self.ServoSetupWrapper()
			self.penUp()

		elif self.options.manualType == "lower-pen":
			self.ServoSetupWrapper()
			self.penDown()

		elif self.options.manualType == "enable-motors":
			ebb_motion.sendEnableMotors(self.serialPort, 1) # 16X microstepping

		elif self.options.manualType == "disable-motors":
			self.sendDisableMotors()

		elif self.options.manualType == "version-check":
			strVersion = ebb_serial.query( self.serialPort, 'v\r' )
			inkex.errormsg( 'I asked the EBB for its version info, and it replied:\n ' + strVersion )

		elif self.options.manualType == "enable-engraver":
			if ( not self.options.engraving ):
				inkex.errormsg( gettext.gettext( "The engraver option is disabled. " + \
				" Please enable it first from the \"Options\" tab." ) )
			else:
				self.engraverOn()

		elif self.options.manualType == 'disable-engraver':
			self.engraverOffManual() #Force engraver off, even if it is not enabled.

		else:  # self.options.manualType is "walk-egg-motor" or "walk-pen-motor":
			if self.options.manualType == "walk-egg-motor":
				nDeltaX = self.options.WalkDistance
				nDeltaY = 0
			elif self.options.manualType == "walk-pen-motor":
				nDeltaY = self.options.WalkDistance
				nDeltaX = 0
			else:
				return
				
			ebb_motion.sendEnableMotors(self.serialPort, 1) # 16X microstepping
			
			#Query pen position: 1 up, 0 down (followed by OK)
			strVersion = ebb_serial.query( self.serialPort, 'QP\r' )
			
			if strVersion[0] == '0':
				self.fSpeed = self.options.penDownSpeed
			if strVersion[0] == '1':
				self.fSpeed = self.options.penUpSpeed

			if ( self.options.revPenMotor ):
				nDeltaY = -1 * nDeltaY
			if ( self.options.revEggMotor ):
				nDeltaX = -1 * nDeltaX
			
			nTime = 10000.00 / self.fSpeed * plot_utils.distance( nDeltaX, nDeltaY )
			nTime = int( math.ceil(nTime / 10.0))
			
			strOutput = ','.join( ['SM', str( nTime ), str( nDeltaY ), str( nDeltaX )] ) + '\r'
			#inkex.errormsg( 'strOutput:  ' + strOutput )

			ebb_serial.command( self.serialPort, strOutput )
示例#17
0
def QueryPRGButton( portName ):
	if (portName is not None):
		return ebb_serial.query( portName, 'QB\r' )