Beispiel #1
0
 function gcode_ajax()
 {
     $cr = 0;
     $display = NULL;
     $gcode_path = NULL;
     $id_model = $this->input->get('id');
     $this->load->helper('printer');
     $cr = Printer_getFileFromModel(PRINTER_TYPE_GCODELIB, $id_model, $gcode_path);
     if ($cr == ERROR_OK) {
         if (file_exists($gcode_path)) {
             // 				$this->load->helper('file');
             // 				$this->output->set_content_type(get_mime_by_extension($gcode_path))->set_output(@file_get_contents($gcode_path));
             // 				$this->load->helper('download');
             // 				force_download('library.gcode', @file_get_contents($gcode_path));
             $this->_sendFileContent($gcode_path, 'library.gcode');
             return;
         } else {
             $cr = ERROR_INTERNAL;
         }
     }
     $display = $cr . " " . t(MyERRMSG($cr));
     $this->output->set_status_header($cr, $display);
     // 		http_response_code($cr);
     $this->output->set_content_type('text/plain; charset=UTF-8');
     $this->load->library('parser');
     $this->parser->parse('plaintxt', array('display' => $display));
     //optional
     return;
 }
Beispiel #2
0
function Printer_printFromLibrary($id_gcode, $exchange_extruder = FALSE, $array_temper = array())
{
    $ret_val = 0;
    $array_info = NULL;
    $array_filament = array();
    $CI =& get_instance();
    $ret_val = Printer_getFileFromModel(PRINTER_TYPE_GCODELIB, $id_gcode, $gcode_path, NULL, $array_info);
    if ($ret_val == ERROR_OK && $gcode_path) {
        $array_filament = array();
        if (Printer__getLengthFromJson(PRINTER_TYPE_GCODELIB, $array_info, $array_filament)) {
            if ($exchange_extruder) {
                Printer__inverseFilament($array_filament);
            }
        } else {
            return ERROR_INTERNAL;
            // $ret_val = ERROR_INTERNAL;
        }
        // modify the temperature of gcode file according to cartridge info
        $ret_val = Printer__changeGcode($gcode_path, $array_filament, $exchange_extruder, $array_temper);
        if ($ret_val != ERROR_OK) {
            return $ret_val;
        }
        $CI->load->helper('corestatus');
        $ret_val = Printer_printFromFile($gcode_path, CORESTATUS_VALUE_MID_PREFIXGCODE . $id_gcode, 0, TRUE, $exchange_extruder, $array_filament, $array_temper);
        // stats info
        $CI->load->helper('printerlog');
        PrinterLog_statsLibraryGcode(PRINTERLOG_STATS_LABEL_PRINT, count($array_filament));
    }
    return $ret_val;
}