Exemplo n.º 1
0
    def write_block(self, block, data, skip_audit=False):
        """ Writes a block.
                block is an integer
                data is a bytearray, filename, or FLP.Packets object
        """
        if isinstance(data, FLP.Packets):
            assert skip_audit == False
            return self.write_block_flp(block, data)
        if not isinstance(data, bytearray):
            data = bytearray(open(data, "rb").read())

        # Check to see that laser power is always acceptable,
        # raising an exception if the power is too high
        if self.AUDIT_LASER_POWER and not skip_audit:
            flp = FLP.fromstring(data)
            self.audit_laser_power_flp(flp)

        header = bytearray(struct.pack("<III", block, len(data), self._fletcher32(data)))
        self._command(Command.CMD_LOAD_PRINT_DATA_BLOCK, header + data, expect_success=True)
Exemplo n.º 2
0
 def read_block_flp(self, block):
     return FLP.fromstring(self.read_block(block))
Exemplo n.º 3
0
    CMD_DELETE_FILE = 0x64
    CMD_CREATE_DIRECTORY = 0x65
    CMD_READ_DIRECTORY = 0x67
    CMD_DELETE_DIRECTORY = 0x66
    CMD_GET_FILE_INFORMATION = 0x68

    STATUS_LAYER_DONE  = 0x80
    STATUS_LAYER_NON_FATAL_ERROR  = 0x81
    STATUS_BLOCK_DONE  = 0x84
    STATUS_PRINT_DONE  = 0x82

    DEBUG_STRING  = 0x90

class State(Enum):
    MACHINE_OFF = 0
    MACHINE_POWERING_UP = 1
    MACHINE_RAISING_PLATFORM = 2
    MACHINE_READY_TO_PRINT = 3
    MACHINE_PRINTING = 4
    MACHINE_PRINTING_PAUSE_PENDING = 5
    MACHINE_PRINTING_PAUSED = 6
    MACHINE_STOPPING_PRINT = 7
    MACHINE_SHUTTING_DOWN = 8
    MACHINE_ERROR = 9
    MACHINE_HARD_ERROR = 10
    MACHINE_STATE_NONE = 11


if __name__ == '__main__':
    FLP.print_not_a_script_message_and_exit()
Exemplo n.º 4
0
        if isinstance(layer[i], FLP.WaitForMovesToComplete):
            insertBefore_i = 1 + i
            break
    assert insertBefore_i is not None
    # Now we know where the motors are stopped and tilt is at its lowest.

    pauseCycle = FLP.Packets()
    zJog_usteps = int(zJog_mm * FLP.ZMove.usteps_up_per_mm)
    zJog_mmps = 10.0
    pauseCycle.append(FLP.ZCurrent(FLP.ZCurrent.moving_current))
    pauseCycle.append(FLP.ZFeedRate(zJog_mmps * abs(FLP.ZMove.usteps_up_per_mm)))
    pauseCycle.append(FLP.ZMove(zJog_usteps))
    pauseCycle.append(FLP.WaitForMovesToComplete())
    pauseCycle.append(FLP.WaitButtonPress(buttonPressMessage))
    pauseCycle.append(FLP.ZMove(-zJog_usteps))
    pauseCycle.append(FLP.WaitForMovesToComplete())
    # Restore settings:
    pauseCycle.append(FLP.ZCurrent(zCurrent))
    if zSpeed_usteps_per_s is not None:
        pauseCycle.append(FLP.ZFeedRate(zSpeed_usteps_per_s))
    newLayer = layer[:insertBefore_i] + pauseCycle + layer[insertBefore_i:]
    return newLayer


if __name__ == '__main__':
    import sys
    assert len(sys.argv) == 3, "Usage: insert_material_swaps.py input.flp output.flp."
    layer = FLP.fromfile(sys.argv[1])
    layer = insert_pause_before(layer)
    layer.tofile(sys.argv[2])
Exemplo n.º 5
0
 def read_block_flp(self, block):
     return FLP.fromstring(self.read_block_raw(block))
Exemplo n.º 6
0
    CMD_CREATE_DIRECTORY = 0x65
    CMD_READ_DIRECTORY = 0x67
    CMD_DELETE_DIRECTORY = 0x66
    CMD_GET_FILE_INFORMATION = 0x68

    STATUS_LAYER_DONE = 0x80
    STATUS_LAYER_NON_FATAL_ERROR = 0x81
    STATUS_BLOCK_DONE = 0x84
    STATUS_PRINT_DONE = 0x82

    DEBUG_STRING = 0x90


class State(Enum):
    MACHINE_OFF = 0
    MACHINE_POWERING_UP = 1
    MACHINE_RAISING_PLATFORM = 2
    MACHINE_READY_TO_PRINT = 3
    MACHINE_PRINTING = 4
    MACHINE_PRINTING_PAUSE_PENDING = 5
    MACHINE_PRINTING_PAUSED = 6
    MACHINE_STOPPING_PRINT = 7
    MACHINE_SHUTTING_DOWN = 8
    MACHINE_ERROR = 9
    MACHINE_HARD_ERROR = 10
    MACHINE_STATE_NONE = 11


if __name__ == '__main__':
    FLP.print_not_a_script_message_and_exit()
Exemplo n.º 7
0
Summary of changes:
1) First, it changes the Z feed rate in line 5
2) Next, it inserts a positive Z move of 2000 usteps (5mm)
3) Lastly, it changes the Z move in layer 9 to -1960 (-4.9mm)
Note that in this case, positive values move the build plate away from the vat, and negative values move the build plate closer to the vat.
loop continues until it gets to the last block on the printer and then it ends.
'''
print("starting loop")
while blockNum <= lastBlock:

    layer = p.read_block_flp(blockNum)
    layerStartTime = datetime.now()

    if str(layer[5]) != '0x04 ZFeedRate ' + str(267):
        try:
            layer[5] = FLP.ZFeedRate(267)
        except:
            break
    if str(layer[6]) != '0x03 ZMove ' + str(2000):
        try:
            layer.insert(6, FLP.ZMove(usteps=(2000)))
        except:
            break
    if str(layer[9]) != '0x03 ZMove ' + str(-1980):
        try:
            layer[9] = FLP.ZMove(usteps=(-1980))
        except:
            break
    writeLayer()
    print("Layer " + str(blockNum) + " finished in " +
          str(datetime.now() - layerStartTime))