Esempio n. 1
0
def sweep_scan(app, args=None, lang='en_US.UTF-8'):
    setLanguage(lang)
    try:
        safety_door = app.config.get('settings', 'safety')['door']
    except KeyError:
        safety_door = 0

    app.trace(_("Initializing Sweeping Laserscanner"))
    app.trace(_("Checking panel door status and bed inserted"))
    if (safety_door == 1):
        app.macro("M741", "TRIGGERED", 2, _("Front panel door control"))
    app.macro("M744",
              "TRIGGERED",
              2,
              _("Building plane removed!"),
              warning=True)
    app.macro("M742",
              "TRIGGERED",
              1,
              _("Spool panel is not closed!"),
              warning=True,
              verbose=False)
    app.macro("M701 S0", "ok", 2, _("Turning off lights"))
    app.macro("M702 S0", "ok", 2, _("Turning off lights"), verbose=False)
    app.macro("M703 S0", "ok", 2, _("Turning off lights"), verbose=False)
    # macro("M744","open",2,"Working plane absent/tilted",0.1)
    #~ app.macro("G28 X0 Y0",      "ok", 90,       _("Homing all axis"), 1)
    #~ app.macro("G27",            "ok", 90,       _("Homing all axis") )
    app.macro("G90", "ok", 2, _("Setting abs position"), verbose=False)
    # macro("M92 E"+str(units['a']),"ok",1,"Setting 4th axis mode",0)
    app.macro("G0 Z145 F1000",
              "ok",
              100,
              _("Lowering the plane"),
              verbose=False)
Esempio n. 2
0
def main():
    config = ConfigService()

    # SETTING EXPECTED ARGUMENTS
    parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument("-T", "--task-id",     help=_("Task ID."),      default=0)
    parser.add_argument("-F", "--file-name",   help=_("File name."),    required=True)
    parser.add_argument("--lang",              help="Output language", default='en_US.UTF-8' )
    parser.add_argument("--email",             help="Send an email on task finish", action='store_true', default=False)
    parser.add_argument("--shutdown",          help="Shutdown on task finish", action='store_true', default=False )
    
    # GET ARGUMENTS
    args = parser.parse_args()

    # INIT VARs
    gcode_file      = args.file_name     # GCODE FILE
    task_id         = args.task_id
    lang            = args.lang
    send_email      = bool(args.email)
    auto_shutdown   = bool(args.shutdown)
    
    if task_id == 0:
        standalone  = True
    else:
        standalone  = False

    app = Application(standalone)

    app.run(task_id, gcode_file)
    app.loop()
    def run(self):

        self.resetTrace()
        eeprom = self.exec_macro('read_eeprom')
        try:
            self.probe_length = abs(float(eeprom['reply']['probe_length']))
            if (self.probe_length < 38):
                self.probe_length = 38
            self.probe_length += 5
        except KeyError:
            pass

        points = [[self.x1, self.y1], [self.x1, self.y2], [self.x2, self.y2],
                  [self.x2, self.y1]]

        self.send("M402")
        self.send("M733 S0")

        if (self.skip_homing == False):
            self.trace(_("Homing all axes"))
            self.send("G27")
            self.send("G92 Z241.2")
            self.send("G90")
            self.send("G0 Z100 F1000")
            self.send("M400")

        self.trace(_("Probing points"))
        counter = 1
        for (x, y) in points:
            self.probe(x, y, counter)
            counter += 1
        self.send("M402")
        self.send("M733 S1")
        self.stop()
Esempio n. 4
0
def measure_nozzle_offset(app, args=None, lang='en_US.UTF-8'):
    setLanguage(lang)

    app.macro("M104 S0", "ok", 2, _("Extruder heating off"))
    app.macro("M140 S0", "ok", 2, _("Bed heating off"))

    app.trace(_("Measuring nozzle offset"))
    zpos = getPosition(app, lang)

    # Paper width is 0.08mm
    nozzle = float(zpos['z']) - 0.08

    app.macro("G90", "ok", 2, _("Setting rel position"), verbose=False)
    app.macro("G0 Z+40",
              "ok",
              100,
              _("Moving the bed 40mm away from measured height"),
              verbose=False)

    # Store offset to head config
    head_file = os.path.join(
        app.config.get('hardware', 'heads'),
        app.config.get('settings', 'hardware.head') + '.json')
    with open(head_file) as json_f:
        head_info = json.load(json_f)

    #head_info['nozzle_offset'] = str(round(nozzle,2))
    head_info['nozzle_offset'] = nozzle

    with open(head_file, 'w') as outfile:
        json.dump(head_info, outfile, sort_keys=True, indent=4)

    return {'nozzle_z_offset': nozzle}
Esempio n. 5
0
def set_lights(app, args=None, lang='en_US.UTF-8'):
    setLanguage(lang)

    if (len(args) < 3):
        try:
            colors = app.config.get('settings', 'color')
            red = colors['r']
            green = colors['g']
            blue = colors['b']
        except:
            red = 255
            green = 255
            blue = 255
    else:
        red = args[0]
        green = args[1]
        blue = args[2]

    app.macro("M701 S{0}".format(red),
              "ok",
              1,
              _("Setting red color"),
              verbose=False)
    app.macro("M702 S{0}".format(green),
              "ok",
              1,
              _("Setting green color"),
              verbose=False)
    app.macro("M703 S{0}".format(blue),
              "ok",
              1,
              _("Setting blue color"),
              verbose=False)
Esempio n. 6
0
def check_measure_probe(app, args=None, lang='en_US.UTF-8'):
    setLanguage(lang)
    try:
        safety_door = app.config.get('settings', 'safety')['door']
    except KeyError:
        safety_door = 0

    try:
        bed_enabled = app.config.get('settings', 'hardware')['bed']['enable']
    except KeyError:
        bed_enabled = True

    app.trace(_("Checking safety measures"))
    if safety_door == 1:
        app.macro("M741",
                  "TRIGGERED",
                  2,
                  _("Front panel door opened"),
                  verbose=False)

    app.trace(_("Checking building plate"))
    if bed_enabled == True:
        app.macro("M744",
                  "TRIGGERED",
                  1,
                  _("Build plate needs to be flipped to the printing side"),
                  verbose=False)

    app.macro("M742",
              "TRIGGERED",
              1,
              _("Spool panel control"),
              verbose=False,
              warning=True)
Esempio n. 7
0
def auto_bed_leveling(app, args=None, lang='en_US.UTF-8'):
    setLanguage(lang)

    app.trace(_("Auto Bed leveling Initialized"))
    app.macro("G28", "ok", 120, _("Homing Z axis"))
    app.macro("G28 X Y", "ok", 90, _("Homing X/Y axis"))
    app.macro("G29", "ok", 150, _("Probing the bed"))
Esempio n. 8
0
def end_additive_aborted(app, args=None, lang='en_US.UTF-8'):
    setLanguage(lang)
    #app.macro("G91",                        "ok", 2,    _("Setting rel position") )
    #app.macro("G0 Z5 F10000",   "ok", 100,  _("Moving to safe zone") )
    app.macro("G27 Z0", "ok", 100, _("Moving to safe zone"))
    app.macro("G28 XY", "ok", 100, _("Zeroing Z axis"), verbose=False)
    app.macro("M400", "ok", 200, _("Waiting for all moves to finish"))
    app.macro("M18", "ok", 2, _("Motors off"), verbose=False)
Esempio n. 9
0
 def state_change_callback(self, state):
     if state == 'paused':
         self.trace( _("Engraving PAUSED") )
         self.trace( _("Please wait until the buffered moves in totumduino are finished") )
     if state == 'resumed':
         self.trace( _("Engraving RESUMED") )
     if state == 'aborted':
         self.trace( _("Engraving ABORTED") )
Esempio n. 10
0
def set_ambient_color(app, args=None, lang='en_US.UTF-8'):
    _ = setLanguage(lang)
    red = args[0]
    green = args[1]
    blue = args[2]

    app.macro("M701 S{0}".format(red), "ok", 1, _("Setting red color"))
    app.macro("M702 S{0}".format(green), "ok", 1, _("Setting green color"))
    app.macro("M703 S{0}".format(blue), "ok", 1, _("Setting blue color"))
Esempio n. 11
0
def pause_prism(app, args=None, lang='en_US.UTF-8'):

    setLanguage(lang)

    try:

        max_height = args[0]

    except:

        max_height = 40.00

    try:

        z_offset = args[1]

    except:

        z_offset = 100.00

    app.macro("M300", "ok", 3, _("Play beep"), verbose=False)

    app.macro("M732 S0", "ok", 2, _("Disabling door safety"), verbose=False)

    # turn lights to red
    set_lights(app, [25, 2, 0])

    # get position
    position = getPosition(app, lang)

    current_z = float(position['z'])

    # raise platform only if object's height is < max_height

    if current_z < max_height:

        # store position
        with open('/var/lib/fabui/settings/stored_task.json', 'w') as f:

            f.write(json.dumps({'position': position}))

        safe_z = current_z + z_offset

        app.macro("G91", "ok", 1, _("Relative mode"), verbose=False)

        app.macro("G0 Z-{0} F300".format(safe_z),
                  "ok",
                  100,
                  _("Raising platform"),
                  verbose=False)

        app.macro("M400",
                  "ok",
                  120,
                  _("Wait for all movements"),
                  verbose=False)
Esempio n. 12
0
def start_subtractive(app, args = None, lang='en_US.UTF-8'):
    _ = setLanguage(lang)
    
    feeder = app.config.get_feeder_info('built_in_feeder')
    units_a = feeder['steps_per_angle']
    
    configure_head(app, app.config.get('settings', 'hardware.head'))
    
    app.macro("G92 X0 Y0 Z0 E0", "ok", 1,       _("Setting Origin Point"), verbose=False)
    app.macro("M92 E"+str(units_a), "ok", 1,    _("Setting 4th Axis mode"), verbose=False)
Esempio n. 13
0
def prepare_additive(app, args=None, lang='en_US.UTF-8'):
    _ = setLanguage(lang)
    
    ext_temp = args[0];
    bed_temp = args[1];

    app.macro("M104 S"+str(ext_temp),   "ok", 3,    _("Pre Heating Nozzle ({0}&deg;) (fast)").format(str(ext_temp)))
    app.macro("M140 S"+str(bed_temp),   "ok", 3,    _("Pre Heating Bed ({0}&deg;) (fast)").format(str(bed_temp)))
    
    app.macro("M402", "ok", 2,    _("Retract Probe"), verbose=False)
Esempio n. 14
0
    def run_update(self, task_id, plugins):
        """
        Plugin update procedure
        """
        #~ task_id = -1
        print "task started"

        self.factory = UpdateFactory(config=self.config,
                                     gcs=self.gcs,
                                     notify_update=self.update_monitor)

        self.prepare_task(task_id,
                          task_type='plugin',
                          task_controller='update')
        self.set_task_status(GCodePusher.TASK_RUNNING)

        print "getting online repo"
        repo_plugins = self.factory.getPlugins()

        for slug in plugins:
            print "check", slug
            if slug in repo_plugins:
                repo_plugin = repo_plugins[slug]
                latest = repo_plugin['latest']
                print "Name:", repo_plugin['name']
                print "Latest:", latest
                print "Rels:", repo_plugin['releases']

                task = PluginTask(slug, repo_plugin)
                self.factory.addTask(task)

        print "downloading"

        self.factory.setStatus('downloading')
        for task in self.factory.getTasks():
            self.factory.setCurrentTask(task.getName())
            self.factory.update()
            self.trace(_("Downloading plugin {0}...").format(task.getName()))
            task.download()

        active_plugins = Plugin(self.db).get_active_plugins()
        installed_plugins = get_installed_plugins()

        print "installing"
        self.factory.setStatus('installing')
        for task in self.factory.getTasks():
            self.factory.setCurrentTask(task.getName())
            self.factory.update()
            self.trace(_("Installing plugin {0}...").format(task.getName()))
            task.install()
            self.trace(_("Installed plugin {0}").format(task.getName()))

        self.trace(_("Finishing task"))
        print "finishing task"
        self.finalize_task()
Esempio n. 15
0
 def run_deactivate(self, plugins):
     """
     Deactivate plugins by removing their links to the system
     """
     for plugin in plugins:
         self.trace(
             _("Decoupling plugin <strong>{0}</strong> from system...").
             format(plugin))
         deactivate_plugin(plugin, self.config)
         self.trace(_("Done"))
         print "ok"
Esempio n. 16
0
 def run_activate(self, plugins):
     """
     Activate plugins by creating links in the system to plugin resources
     """
     for plugin in plugins:
         self.trace(
             _("Integrating plugin <strong>{0}</strong> into system...").
             format(plugin))
         activate_plugin(plugin, self.config)
         self.trace(_("Done"))
         print "ok"
Esempio n. 17
0
    def state_change_callback(self, state):
        if state == 'paused':
            self.trace(_("PAUSED"))

        if state == 'resuming':
            self.trace(_("RESUMING"))

        if state == 'resumed':
            self.trace(_("RESUMED"))
        if state == 'aborted':
            self.trace(_("ABORTED"))
Esempio n. 18
0
    def __send_task_email(self):

        if not self.task_stats["send_email"]:
            return

        import shlex, subprocess
        cmd = 'sudo -u www-data php /usr/share/fabui/index.php Std sendTaskEmail/{0}'.format(
            self.task_stats['id'])
        try:
            output = subprocess.check_output(shlex.split(cmd))
            self.trace(_("Email sent"))
        except subprocess.CalledProcessError as e:
            self.trace(_("Email sending failed"))
Esempio n. 19
0
def heats(app, args=None, lang='en_US.UTF-8'):
    _ = setLanguage(lang)

    what = args[0]
    temperature = float(args[1])

    CODES = {"nozzle": "M109", "bed": "M190"}

    app.macro(
        "{0} S{1}".format(CODES[what], temperature), "*", 400,
        _("Waiting for {0} to reach temperature (<span class='top-bar-{1}-actual'>-</span> / {2}&deg;)"
          .format(what, what, temperature)))  #heating and waiting.
    app.trace(_("Please wait..."))
Esempio n. 20
0
def start_engraving(app, args=None, lang='en_US.UTF-8'):
    _ = setLanguage(lang)

    feeder = app.config.get_feeder_info('built_in_feeder')
    units_a = feeder['steps_per_angle']
    LASER_FOCUS_OFFSET = 2
    configure_head(app, app.config.get('settings', 'hardware.head'))

    go_to_focus = int(args[0])

    if (go_to_focus == 1):
        app.macro("G91", "ok", 2, _("Set relative mode"), verbose=False)
        app.macro("G0 Z{0} F1000".format(LASER_FOCUS_OFFSET),
                  "ok",
                  2,
                  _("Going to focus point"),
                  verbose=True)

    app.macro("G92 X0 Y0 Z0 E0",
              "ok",
              1,
              _("Setting Origin Point"),
              verbose=False)
    app.macro("M92 E" + str(units_a),
              "ok",
              1,
              _("Setting 4th Axis mode"),
              verbose=False)
    app.macro("M106 S255", "ok", 1, _("Turning fan on"), verbose=False)
    app.macro("M701 S0", "ok", 2, _("Turning off lights"), verbose=False)
    app.macro("M702 S0", "ok", 2, _("Turning off lights"), verbose=False)
    app.macro("M703 S0", "ok", 2, _("Turning off lights"), verbose=False)
Esempio n. 21
0
def door_safety(app, args=None, lang='en_US.UTF-8'):
    setLanguage(lang)
    try:
        safety_door = app.config.get('settings', 'safety')['door']
    except KeyError:
        safety_door = 0

    app.trace(_("Checking safety measures"))
    if safety_door == 1:
        app.macro("M741",
                  "TRIGGERED",
                  2,
                  _("Front panel door opened"),
                  verbose=False)
Esempio n. 22
0
def probe_scan(app, args=None, lang='en_US.UTF-8'):
    setLanguage(lang)
    feeder = app.config.get_feeder_info('built_in_feeder')
    units_a = feeder['steps_per_angle']
    try:
        safety_door = app.config.get('settings', 'safety')['door']
    except KeyError:
        safety_door = 0

    app.trace(_("Initializing Probing procedure"))
    if (safety_door == 1):
        app.macro("M741",
                  "TRIGGERED",
                  2,
                  _("Front panel door control"),
                  warning=True)
    app.macro("M402", "ok", 2, _("Retracting Probe"))
    app.macro("M744",
              "TRIGGERED",
              2,
              _("Building plane is absent"),
              warning=True)
    app.macro("M742", "TRIGGERED", 2, _("Spool panel"), warning=False)
    app.macro("G90", "ok", 2, _("Setting abs position"), verbose=True)
    app.macro("M302 S0",
              "ok",
              2,
              _("Disabling cold extrusion prevention"),
              verbose=True)
    app.macro("M92 E" + str(units_a),
              "ok",
              2,
              _("Setting 4th axis mode"),
              verbose=True)
Esempio n. 23
0
    def run_remove(self, plugins):
        """
        Remove plugins from the system
        """
        self.run_deactivate(plugins)
        plugins_path = self.config.get('general', 'plugins_path')

        for plugin in plugins:
            self.trace(
                _("Deleting plugin <strong>{0}</strong> files...").format(
                    plugin))
            remove_plugin(plugin, self.config)
            self.trace(_("Done"))
            print "ok"
Esempio n. 24
0
 def error_callback(self, error_no):
     """ 
     Triggered when an error occures.
     :param error_no: Error number
     """
     message = _("Warning: print paused due to error {0}".format(error_no))
     if (self.is_paused() == False):
         if (error_no == ERROR_WIRE_END):
             message = _("Warning: filament is about to end")
         elif (error_no == ERROR_EXTRUDE_MINTEMP):
             message = _(
                 "Warning: cannot extrude filament: the nozzle temperature is too low"
             )
         elif (error_no == ERROR_AMBIENT_TEMP):
             message = _(
                 "Warning: ambient temperature is less then 15&deg;C. Cannot continue"
             )
         elif (error_no == ERROR_LONG_EXTRUSION):
             message = _("Warning: cannot extrude so much filament!")
         elif (error_no == ERROR_MAX_TEMP):
             message = _(
                 "Warning: extruder Temperature critical, shutting down")
         elif (error_no == ERROR_IDLE_SAFETY):
             message = _(
                 "The FABtotum has been idling for more than 10 minutes. Temperatures and Motors have been turned off"
             )
         elif (error_no == ERROR_X_MIN_ENDSTOP):
             message = _(
                 "X min Endstop hit: Move the carriage to the center or check Settings > Hardware > Custom Settings >Invert X Endstop Logic"
             )
         self.trace(message)
         self.task_stats['message'] = message
         self.pause()
Esempio n. 25
0
def end_prism(app, args=None, lang='en_US.UTF-8'):

    setLanguage(lang)

    set_lights(app, [0, 0, 0])

    app.macro("G91", "ok", 1, _("Relative mode"), verbose=False)

    app.macro("G0 Z-200 F300",
              "ok",
              60,
              _("Raising the platform"),
              verbose=True)

    app.macro("M400", "ok", 120, _("Wait for all movements"), verbose=False)
Esempio n. 26
0
def prepare_prism(app, args=None, lang='en_US.UTF-8'):

    setLanguage(lang)

    app.trace(_("Turning off lights"))

    set_lights(app, [0, 0, 0])

    app.macro("M564 S0",
              "ok",
              3,
              _("Disbale restricted movements"),
              verbose=False)

    app.macro("G92 Z0", "ok", 3, _("Set Z 0"), verbose=False)
Esempio n. 27
0
def zProbe(app, lang='en_US.UTF-8'):
    setLanguage(lang)
    app.macro("M401", "ok", 5, _("Open probe"), verbose=False)
    reply = app.macro("G30", "ok", 120, _("Probe position"), verbose=False)
    probe = parseG30(reply)

    app.macro("G91", "ok", 2, _("Setting rel position"), verbose=False)
    app.macro("G0 Z5 F1000",
              "ok",
              20,
              _("Moving bed away from the probe"),
              verbose=False)
    app.macro("M402", "ok", 5, _("Retract probe"), verbose=False)

    return probe
Esempio n. 28
0
def get_versions(app, lang='en_US.UTF-8'):
    setLanguage(lang)

    ### controller serail ID
    retr = app.macro("M760", "ok", 1, _("Controller serial ID"), verbose=False)
    controller_serial_id = retr[0]
    ### controller control code
    retr = app.macro("M761",
                     "ok",
                     1,
                     _("Controller control code"),
                     verbose=False)
    controller_control_code = retr[0]
    ### board version
    retr = app.macro("M762", "ok", 1, _("Board version"), verbose=False)
    board_version = retr[0]
    ### Production batch (hardware version)
    retr = app.macro("M763", "ok", 1, _("Production batch"), verbose=False)
    production_batch = retr[0]
    ### Production batch control code
    retr = app.macro("M764",
                     "ok",
                     1,
                     _("Production batch control code"),
                     verbose=False)
    production_batch_control_code = retr[0]
    ### firmware version
    retr = app.macro("M765", "ok", 1, _("Firmware version"), verbose=False)
    firmware_version = retr[0]
    try:
        firmware_version = firmware_version.split()[1]
    except:
        pass
    ### Firmware build date
    retr = app.macro("M766", "ok", 1, _("Firmware build date"), verbose=False)
    firmware_build_date = retr[0]
    ### firmware author
    retr = app.macro("M767", "ok", 1, _("Firmware author"), verbose=False)
    firmware_author = retr[0]

    return {
        'firmware': {
            'version': firmware_version,
            'build_date': firmware_build_date,
            'author': firmware_author
        },
        'production': {
            'batch': production_batch,
            'control_code': production_batch_control_code
        },
        'controller': {
            'serial_id': controller_serial_id,
            'control_code': controller_control_code
        },
        'board': {
            'version': board_version
        }
    }
Esempio n. 29
0
    def state_change_callback(self, state):
        if state == 'paused':
            self.trace(_("Milling PAUSED"))
            self.trace(
                _("Please wait until the buffered moves in totumduino are finished"
                  ))
            self.exec_macro("pause_subtractive")

        if state == 'resuming':
            self.trace(_("RESUMING Print"))
            self.exec_macro("resume_subtractive")
        if state == 'resumed':
            self.trace(_("Milling RESUMED"))
        if state == 'aborted':
            self.resetTrace()
            self.trace(_("Milling ABORTED"))
Esempio n. 30
0
    def first_move_callback(self):
        self.trace(_("Milling STARTED"))

        with self.monitor_lock:
            #~ self.pusher_stats['first_move'] = True
            self.set_task_status(GCodePusher.TASK_RUNNING)
            self.update_monitor_file()