示例#1
0
class ScreenAndMouseIoManager():

    ASK_AOI = Rectangle(-1, -1, -1, -1)
    PURCHASE_BUTTON = [-1, -1]
    TRADER_AOI = Rectangle(-1, -1, -1, -1)

    def get_asks(self):
        return [Ask(-1, -1, -1, -1)]

    def get_fee(self):
        return -1

    def get_trader(self):
        return Trader(-1, -1)

    def did_buy_succeed(self):
        return PurchaseResult.FAILURE

    def buy_lowest_ask(self):
        Robot.move_relative(*self.PURCHASE_BUTTON)
        Robot.click()
        Robot.type('y')
        result = PurchaseResult.UNKNOWN
        while result == PurchaseResult.UNKNOWN:
            result = self.did_buy_succeed()
            Robot.long_sleep(0.5)
        return result

    def sell_first_item(self, price):
        # TODO use Robot to sell
        pass

    def wait(self, seconds=2):
        Robot.long_sleep(seconds)
示例#2
0
    def generate(self, **kwargs):
        """Generate data using previously loaded name and parameters. Returns a list."""
        data = []
        params = self.params
        package = Package()

        body = params.l - 2*params.termlen
        package.description = "SOP-%d, %.02fmm pitch, %.2f mm body" % (
                                                    params.pincount, params.pitch, body)
    
        l = params.l # Package lead span
        # Positions and sizes of things relative to data center
        padtoe = l / 2 + params.JT
        padheel = l / 2 - params.footlen - params.JH
        padlen = padtoe - padheel
        padcenter = padtoe - padlen / 2.0
        padwidth = params.termwidth + params.JS
        pins_per_side = params.pincount // 2
        first_pad_x = - (pins_per_side - 1) * params.pitch / 2.0
        packagew = ((pins_per_side - 1) * params.pitch + 1.0) / 2.0 # About right, for small chips
        packageh = l / 2 - params.termlen
        courtyardw = packagew + params.courtyard_excess
        courtyardh = padtoe + params.courtyard_excess
        outlinew = packagew + params.silkwidth/2.0
        outlineh = packageh + params.silkwidth/2.0

        # Draw courtyard on package layer
        rect = Rectangle( (-courtyardw, -courtyardh), (courtyardw, courtyardh))
        rect.layer = "package"
        data.append(rect)

        # Draw package size on package layer
        rect = Rectangle( (-packagew, -packageh), (packagew, packageh))
        rect.layer = "package"
        data.append(rect)
        
        # Draw outline on silkscreen
        rect = Rectangle( (-outlinew, -outlineh), (outlinew, outlineh))
        rect.width = params.silkwidth
        data.append(rect)
        marksize = 0.75
        rect = Rectangle( (-outlinew, -marksize), (-outlinew + marksize, marksize))
        rect.width = params.silkwidth
        data.append(rect)
        
        # Draw orientation marker by pin 1 on silkscreen
        markx = first_pad_x - padwidth / 2.0 - params.silkwidth * 2
        line = Line( (markx, padcenter - params.silkwidth*2), (markx, padcenter))
        line.width = params.silkwidth
        data.append(line)

        # Add pads, starting with pin 1 in lower-left (negative X, positive Y) corner
        # Pads are drawn on the bottom side and rotated into place
        pinno = 1
        for side in range(0, 2):
            th = side * 180 # Coordinate system rotation for this side
    
            # Pad center coordinates
            x = first_pad_x
            y = padcenter
    
            for pin in range(0, pins_per_side):
                pad = Pad(pinno)
                pad.x = x
                pad.y = y
                pad.ysize = padlen
                pad.xsize = padwidth
                pad.rotate(th)
    
                data.append(pad)
    
                pinno += 1
                x += params.pitch

        # All done!
        package.data = data
        package.courtyard = ((-courtyardw, -courtyardh), (courtyardw, courtyardh))
    
        return package
示例#3
0
''' Positions and sizes of various objects within the screenshot '''
# Sizes for an iPhone 6S+ (1242x2208px screen)

from common import Rectangle, Point

ScreenWidth = 1242

# Height of various objects in the image
StatusBarHeight = 0
ErrorMsgHeight = 163

MeterBounds = Rectangle(118, 285, 1006, 503)
MeterBallRadius = 10 # slight underestimate

CPBounds = Rectangle(364, 121, 480, 126)
HPBounds = Rectangle(314, 1162, 618, 62)
DustBounds = Rectangle(686, 1756, 172, 77)

CandyNameBounds = Rectangle(580, 1616, 598, 47)
EvolveButtonPixel = Point(373, 1897)
EvolveCandyBounds = Rectangle(933, 1945, 74, 48)
TypeBounds = Rectangle(53, 1293, 390, 85)
示例#4
0
    def generate(self, **kwargs):
        """Generate data using previously loaded name and parameters. Returns a list."""
        data = []
        params = self.params
        package = Package()

        package.description = "QFP-%d, %.02fmm pitch" % (
                                                    params.pincount, params.pitch)
    
        l = params.l1 # Package length along this dimension (FIXME: non-square packages)
        # Positions of things relative to data center
        padtoe = l / 2 + params.JT
        padheel = l / 2 - params.footlen - params.JH
        padlen = padtoe - padheel
        padcenter = padtoe - padlen / 2.0
        padwidth = params.termwidth + params.JS
        pins_per_side = params.pincount // 4
        first_pad_y = (pins_per_side - 1) * params.pitch / 2.0
        courtyardsize = padtoe + params.courtyard_excess
        outlinesize = l / 2 - params.termlen + params.silkwidth/2.0

        # Draw courtyard on package layer
        rect = Rectangle( (-courtyardsize, -courtyardsize), (courtyardsize, courtyardsize))
        rect.layer = "package"
        data.append(rect)

        # Draw package size on package layer
        for side in range(0, 4):
            chamfer = 0.5
            packagesize = l / 2 - params.termlen
            th = (270 + side * 90) % 360 # Coordinate system rotation for this side
            line = Line( (-packagesize + chamfer, packagesize), (packagesize - chamfer, packagesize) )
            line.layer = "package"
            line.rotate(th)
            data.append(line)
            line = Line( (packagesize - chamfer, packagesize), (packagesize, packagesize - chamfer) )
            line.layer = "package"
            line.rotate(th)
            data.append(line)

            leadblockw = pins_per_side * params.pitch / 2.0
            leadblockh = l / 2
            
            rect = Rectangle( (-leadblockw, leadblockh), (leadblockw, leadblockh - params.footlen), 0)
            rect.layer = "package"
            rect.rotate(th)
            data.append(rect)
            rect = Rectangle( (-leadblockw, leadblockh - params.footlen), (leadblockw, packagesize), 0)
            rect.layer = "package"
            rect.rotate(th)
            data.append(rect)
    
        # Draw outline on silkscreen
        linelen = outlinesize - first_pad_y - padwidth / 2 - params.silkwidth * 1.5
        for side in range(0, 4):
            th = (270 + side * 90) % 360 # Coordinate system rotation for this side
            line = Line( (-outlinesize, outlinesize), (-outlinesize + linelen, outlinesize) )
            line.width = params.silkwidth
            line.rotate(th)
            data.append(line)
            line = Line( (-outlinesize, outlinesize), (-outlinesize, outlinesize - linelen) )
            line.width = params.silkwidth
            line.rotate(th)
            data.append(line)

        # Draw orientation mark on silkscreen
        marklen = 1.0
        line = Line( (-outlinesize, outlinesize), (-outlinesize - marklen, outlinesize + marklen) )
        line.width = params.silkwidth
        data.append(line)
    
        # Add pads, starting with pin 1 in lower-left (negative X, positive Y) corner
        # Pads are drawn on the 0-degree (right) side and rotated into place
        pinno = 1
        for side in range(0, 4):
            th = (270 + side * 90) % 360 # Coordinate system rotation for this side
    
            # Pad center coordinates
            x = padcenter
            y = first_pad_y
    
            for pin in range(0, pins_per_side):
                pad = Pad(pinno)
                pad.x = x
                pad.y = y
                pad.ysize = padwidth
                pad.xsize = padlen
                pad.rotate(th)
    
                data.append(pad)
    
                pinno += 1
                y -= params.pitch

        # All done!
        package.data = data
        package.courtyard = ((-courtyardsize, -courtyardsize), (courtyardsize, courtyardsize))
    
        return package
示例#5
0
def capture():
    return capture(Rectangle(0, 0, 1920, 1080))