Пример #1
0
    def informed_reconnect(self, port, baud):
        """The arguments for this function should match what is
        returned by inform_reconnect.  This causes the driver to
        disconnect from whatever device it thinks it is connected to,
        and attach to whatever ostensibly new device is described."""

        if self.serial:
            self.serial.close()
        self.serial = SerialConnection(port, baud)
        self.info = pickle.dumps(self.serial.info)  ### hack
        self.connect_events(self.__signals)
Пример #2
0
    def auto_detect(self, port):
        """Called by a hardware monitor durring a hardware connect
        event.  Return True if this driver claims the device.
        This function should also set self.uuid."""

        try:
            self.serial = SerialConnection(port)
            self.info = pickle.dumps(self.serial.info)  ### HACK
            return True
        except ConnectionException:
            return False
Пример #3
0
 def connect_serial(self, port, baudrate):
     """Connect to board via serial connection"""
     self._serial = SerialConnection(port, baudrate)
     self._board_characteristics()
     if not self.connected:
         raise BoardError(
             "Failed to establish connection to board at '{}'".format(port))
Пример #4
0
    def informed_reconnect(self, port, baud):
        """The arguments for this function should match what is
        returned by inform_reconnect.  This causes the driver to
        disconnect from whatever device it thinks it is connected to,
        and attach to whatever ostensibly new device is described."""

        if self.serial:
            self.serial.close()
        self.serial = SerialConnection(port, baud)
        self.info = pickle.dumps(self.serial.info) ### hack
        self.connect_events(self.__signals)
Пример #5
0
    def auto_detect(self, port):
        """Called by a hardware monitor durring a hardware connect
        event.  Return True if this driver claims the device.
        This function should also set self.uuid."""

        try:
            self.serial = SerialConnection(port)
            self.info = pickle.dumps(self.serial.info) ### HACK
            return True
        except ConnectionException:
            return False
Пример #6
0
class Driver(DriverBase):
    """Driver for reprap-style printers running the sprinter
    firmware."""
    def __init__(self):
        self.serial = None
        self.monitor = None
        self.__signals = None

    def get_class_info(self):
        """Returns a PrinterClassInfo object, as defined in
        capabilities.py"""

        return self.serial.info

    def connect_events(self, server):
        """Called when the driver is attached to a print server, so
        that the driver may call signals on the server object."""

        self.__signals = server
        self.monitor = SprinterMonitor(self.serial, server)

    def auto_detect(self, port):
        """Called by a hardware monitor durring a hardware connect
        event.  Return True if this driver claims the device.
        This function should also set self.uuid."""

        try:
            self.serial = SerialConnection(port)
            self.info = pickle.dumps(self.serial.info)  ### HACK
            return True
        except ConnectionException:
            return False

    def inform_reconnect(self):
        """This function is called by a worker subprocess when a
        driver is detected, but the corresponding printer object
        already exists.  In which case, this function should return a
        simple argument list which can be pushed to the already
        existing service, so that it may call the informed_reconnect
        function in it's driver instance."""
        return self.serial.connection_info()

    def informed_reconnect(self, port, baud):
        """The arguments for this function should match what is
        returned by inform_reconnect.  This causes the driver to
        disconnect from whatever device it thinks it is connected to,
        and attach to whatever ostensibly new device is described."""

        if self.serial:
            self.serial.close()
        self.serial = SerialConnection(port, baud)
        self.info = pickle.dumps(self.serial.info)  ### hack
        self.connect_events(self.__signals)

    #### printer control functions ###

    def home(self, x_axis=False, y_axis=False, z_axis=False):
        """Moves the named axises until they trigger their
        endstops."""

        cmd = ["G28"]
        if x_axis:
            cmd.append("X0")
        if y_axis:
            cmd.append("Y0")
        if z_axis:
            cmd.append("Z0")

        self.monitor.request(" ".join(cmd))

    def relative_mode(self):
        self.monitor.request("G91")

    def absolute_mode(self):
        self.monitor.request("G90")

    def move(self, x=0, y=0, z=0):
        cmd = "G0 X{0} Y{1} Z{2}".format(x, y, z)
        self.monitor.request(cmd)

    def motors_off(self):
        self.monitor.request("M84")

    def set_tool_temp(self, tool, target):
        """Requests the given tool to be set to the specified
        temperature."""
        #FIXME maybe there should be a monitor command for this so
        #that it doesn't change the active tool?
        self.monitor.request("T{0}\nM104 S{1}".format(tool, target))

    def set_bed_temp(self, target):
        """Requests the print bed be set to the specified
        temperature."""

        self.monitor.request("M140 S{0}".format(target))

    def pdq_request_print(self, path):
        self.monitor.print_file(path)
Пример #7
0
vst = pcs.H264VideoStreamer()
if dosomestreaming:
    try:
        vst.startAndConnect()
    except Exception as e:
        print('Error starting H264 stream thread:' + e)

### Remote controller server for BotController.py ###
print('Starting up Controller Server on 0.0.0.0, port 30001')
server_address = ('0.0.0.0', 30001)
sock.bind(server_address)
sur = Surrogator(sock)

### Motors and Reels connections ###
connection = SerialConnection()
motors = SerialMotor(connection=connection)
reels = SerialReel(connection=connection)

### Sensors - Telemetry ###
sensors = TelemetryLoader(connection)


### Stop all motors when process is killed ###
def terminate():
    print('Stopping ALPIBot')
    try:
        motors.stop()
        reels.stop()
        os.remove('running.wt')
    finally:
Пример #8
0
class Driver(DriverBase):
    """Driver for reprap-style printers running the sprinter
    firmware."""

    def __init__(self):
        self.serial = None
        self.monitor = None
        self.__signals = None

    def get_class_info(self):
        """Returns a PrinterClassInfo object, as defined in
        capabilities.py"""

        return self.serial.info

    def connect_events(self, server):
        """Called when the driver is attached to a print server, so
        that the driver may call signals on the server object."""

        self.__signals = server
        self.monitor = SprinterMonitor(self.serial, server)
        
    def auto_detect(self, port):
        """Called by a hardware monitor durring a hardware connect
        event.  Return True if this driver claims the device.
        This function should also set self.uuid."""

        try:
            self.serial = SerialConnection(port)
            self.info = pickle.dumps(self.serial.info) ### HACK
            return True
        except ConnectionException:
            return False

    def inform_reconnect(self):
        """This function is called by a worker subprocess when a
        driver is detected, but the corresponding printer object
        already exists.  In which case, this function should return a
        simple argument list which can be pushed to the already
        existing service, so that it may call the informed_reconnect
        function in it's driver instance."""
        return self.serial.connection_info()

    def informed_reconnect(self, port, baud):
        """The arguments for this function should match what is
        returned by inform_reconnect.  This causes the driver to
        disconnect from whatever device it thinks it is connected to,
        and attach to whatever ostensibly new device is described."""

        if self.serial:
            self.serial.close()
        self.serial = SerialConnection(port, baud)
        self.info = pickle.dumps(self.serial.info) ### hack
        self.connect_events(self.__signals)

    #### printer control functions ###
        

    def home(self, x_axis=False, y_axis=False, z_axis=False):
        """Moves the named axises until they trigger their
        endstops."""

        cmd = ["G28"]
        if x_axis:
            cmd.append("X0")
        if y_axis:
            cmd.append("Y0")
        if z_axis:
            cmd.append("Z0")
            
        self.monitor.request(" ".join(cmd))

    
    def relative_mode(self):
        self.monitor.request("G91")


    def absolute_mode(self):
        self.monitor.request("G90")


    def move(self, x=0, y=0, z=0):
        cmd = "G0 X{0} Y{1} Z{2}".format(x, y, z)
        self.monitor.request(cmd)


    def motors_off(self):
        self.monitor.request("M84")


    def set_tool_temp(self, tool, target):
        """Requests the given tool to be set to the specified
        temperature."""
        #FIXME maybe there should be a monitor command for this so
        #that it doesn't change the active tool?
        self.monitor.request("T{0}\nM104 S{1}".format(tool, target))
        
    def set_bed_temp(self, target):
        """Requests the print bed be set to the specified
        temperature."""

        self.monitor.request("M140 S{0}".format(target))

    def pdq_request_print(self, path):
        self.monitor.print_file(path)