Ejemplo n.º 1
0
    def correct_pos(self, stock: Stock):
        """
        Corrects the position of the cover relative to the stock container, depending on the type of cover.
        Instead of giving each cover a static position
        :param stock: Stock controlling object with type hint Stock
        :return: The position of the specific cover
        """

        # Dicts with identifiers for easier calculation of position
        curve_types = {
            'black_none': 0,
            'black_edge': 3,
            'black_curved': 6,
            'white_none': 1,
            'white_edge': 4,
            'white_curved': 7,
            'blue_none': 2,
            'blue_edge': 5,
            'blue_curved': 8
        }

        case_types = {
            'black_none': 0,
            'black_edge': 1,
            'black_curved': 2,
            'white_none': 3,
            'white_edge': 4,
            'white_curved': 5,
            'blue_none': 6,
            'blue_edge': 7,
            'blue_curved': 8
        }

        case_curve = {'curved': 0, 'edge': 1, 'none': 2}

        # Apply the offset from the bottom of the container to the first cover in the pile
        curvature = case_curve[f'{self.curve}']
        if curvature == 1:
            self.position[2, 3] = self.position[2, 3] + self._OFFSETZ_EDGE
        if curvature == 2:
            self.position[2, 3] = self.position[2, 3] + self._OFFSETZ_NONE
        if curvature == 0:
            self.position[2, 3] = self.position[2, 3] + self._OFFSETZ_CURVED

        # Apply the x-offset based on the type and the colour of the cover
        identifier = case_types[f'{self.color}_{self.curve}']
        self.position[
            0, 3] = self.position[0, 3] + identifier * self._OFFSETX_COVER_DIST

        # Depending on the remaining stock and type of curve, calculate the Z-offset to compensate for the empty space
        identifier_curve = curve_types[f'{self.color}_{self.curve}']
        if identifier_curve in range(0, 3):
            self.position[2, 3] = self.position[2, 3] + stock.get(
                f'{self.color}_none') * self._OFFSETZ_COVER_FLAT_DIST
        if identifier_curve in range(3, 6):
            self.position[2, 3] = self.position[2, 3] + stock.get(
                f'{self.color}_edge') * self._OFFSETZ_COVER_EDGE_DIST
        if identifier_curve in range(6, 9):
            self.position[2, 3] = self.position[2, 3] + stock.get(
                f'{self.color}_curved') * self._OFFSETZ_COVER_CURVED_DIST
Ejemplo n.º 2
0
# retrieval and application and then checks whether the customer selected and engraving
# If the customer has selected engraving, it will start an engraving process based
# upon the chosen type and colour of the cover and then retrieves it.

gui()
RDK = Robolink()
RDK.setSimulationSpeed(1)
stock = Stock()  # For simulating stock
time = Timer()
start = datetime.now()  # For timing simulation
#Creates a new cover object, and checks whether a cover previously used is existant, if it is it deletes it
cover = Cover(CaseConfig.colour(), CaseConfig.curve_style(), stock)
cover.new_cover_check()

# If the stock is empty tell the system
if stock.get(f'{CaseConfig.colour()}_{CaseConfig.curve_style()}') == 0:
    none_flat_str = CaseConfig.curve_style().replace('none', 'flat', -1)
    error_str = f'Stock depleted of {CaseConfig.colour()} {none_flat_str} covers'
    RDK.RunMessage(error_str)
# Else run the program
else:
    cover.give_top(time)
    if CaseConfig.engrave():
        pattern = Engrave(RDK)
        if CaseConfig.curve_style() == 'none':
            pattern.begin_flat(time)
        if CaseConfig.curve_style() == 'edge':
            pattern.begin_edge(time)
        if CaseConfig.curve_style() == 'curved':
            pattern.begin_curved(time)
        cover.retrieve()