Ejemplo n.º 1
0
 function slice_result_ajax()
 {
     $template_data = array();
     $cr = ERROR_OK;
     $array_data = array();
     $check_filament = array();
     $change_filament = array();
     $data_json = array();
     $error = NULL;
     $bicolor_model = FALSE;
     $exchange_select_snd = FALSE;
     $bicolor_printer = $this->config->item('nb_extruder') >= 2;
     $heat_bed = $this->config->item('heat_bed');
     $enable_print = 'false';
     $enable_exchange = 'disabled="disabled"';
     // select disable
     $option_selected = 'selected="selected"';
     $this->load->helper(array('printerstate', 'slicer'));
     $this->load->library('parser');
     $this->lang->load('sliceupload/slice_status_ajax', $this->config->item('language'));
     $cr = PrinterState_getSlicedJson($data_json);
     if ($cr != ERROR_OK) {
         $display = $cr . " " . t(MyERRMSG($cr));
         $this->output->set_status_header($cr);
         $this->output->set_content_type('txt_u');
         $this->parser->parse('plaintxt', array('display' => $display));
         //optional
         return;
     } else {
         $material = NULL;
         $check_filament = array('l' => t('filament_ok'), 'r' => t('filament_ok'));
         $change_filament = array('l' => t('change_filament'), 'r' => t('change_filament'));
         foreach (array('r', 'l') as $abb_filament) {
             $data_cartridge = array();
             $data_slice = array();
             $tmp_ret = 0;
             $volume_need = 0;
             if (isset($data_json[$abb_filament])) {
                 $data_slice = $data_json[$abb_filament];
                 if (isset($data_slice[PRINTERSTATE_TITLE_NEED_L])) {
                     $volume_need = $data_slice[PRINTERSTATE_TITLE_NEED_L];
                 }
             } else {
                 $check_filament[$abb_filament] = t('filament_not_need');
             }
             // check mono extruder case (normally, it's not necessary)
             if ($bicolor_printer == FALSE && $abb_filament == 'l') {
                 $tmp_ret = ERROR_MISS_LEFT_CART;
             } else {
                 $tmp_ret = PrinterState_checkFilament($abb_filament, $volume_need, $data_cartridge);
             }
             if (in_array($tmp_ret, array(ERROR_OK, ERROR_MISS_LEFT_FILA, ERROR_MISS_RIGT_FILA, ERROR_LOW_LEFT_FILA, ERROR_LOW_RIGT_FILA))) {
                 $array_data[$abb_filament] = array(PRINTERSTATE_TITLE_COLOR => $data_cartridge[PRINTERSTATE_TITLE_COLOR], PRINTERSTATE_TITLE_EXT_TEMPER => $data_cartridge[PRINTERSTATE_TITLE_EXT_TEMPER], PRINTERSTATE_TITLE_EXT_TEMP_1 => $data_cartridge[PRINTERSTATE_TITLE_EXT_TEMP_1]);
                 // set default temperature if pla
                 if ($data_cartridge[PRINTERSTATE_TITLE_MATERIAL] == PRINTERSTATE_DESP_MATERIAL_PLA) {
                     $array_data[$abb_filament][PRINTERSTATE_TITLE_EXT_TEMPER] = PRINTERSTATE_VALUE_FILAMENT_PLA_PRINT_TEMPER;
                 }
             } else {
                 $array_data[$abb_filament] = array(PRINTERSTATE_TITLE_COLOR => PRINTERSTATE_VALUE_DEFAULT_COLOR, PRINTERSTATE_TITLE_EXT_TEMPER => SLICER_VALUE_DEFAULT_TEMPER, PRINTERSTATE_TITLE_EXT_TEMP_1 => SLICER_VALUE_DEFAULT_FIRST_TEMPER);
             }
             $array_data[$abb_filament][PRINTERSTATE_TITLE_NEED_L] = $volume_need;
             // treat error
             switch ($tmp_ret) {
                 case ERROR_OK:
                     // do nothing if no error
                     break;
                 case ERROR_LOW_RIGT_FILA:
                     $check_filament['r'] = t('filament_not_enough');
                     break;
                 case ERROR_MISS_RIGT_FILA:
                     $check_filament['r'] = t('filament_unloaded');
                     $change_filament['r'] = t('load_filament');
                     break;
                 case ERROR_MISS_RIGT_CART:
                     $check_filament['r'] = t('filament_empty');
                     $change_filament['r'] = t('load_filament');
                     break;
                 case ERROR_LOW_LEFT_FILA:
                     $check_filament['l'] = t('filament_not_enough');
                     break;
                 case ERROR_MISS_LEFT_FILA:
                     $check_filament['l'] = t('filament_unloaded');
                     $change_filament['l'] = t('load_filament');
                     break;
                 case ERROR_MISS_LEFT_CART:
                     $check_filament['l'] = t('filament_empty');
                     $change_filament['l'] = t('load_filament');
                     break;
                 default:
                     $this->load->helper('printerlog');
                     PrinterLog_logError('unexpected return when generating slicing result: ' . $tmp_ret, __FILE__, __LINE__);
                     // assign error message if necessary
                     $check_filament[$abb_filament] = t('filament_error');
                     break;
             }
             // assign $cr only when status is ok (acts like a flag of error)
             if ($cr == ERROR_OK && $volume_need > 0) {
                 $cr = $tmp_ret;
             }
             // check material difference for all used cartridges
             if (!in_array($tmp_ret, array(ERROR_INTERNAL, ERROR_MISS_LEFT_CART, ERROR_MISS_RIGT_CART)) && $volume_need > 0) {
                 if ($material == NULL) {
                     $material = $data_cartridge[PRINTERSTATE_TITLE_MATERIAL];
                 } else {
                     if ($material != $data_cartridge[PRINTERSTATE_TITLE_MATERIAL]) {
                         $error .= t('cartridge_material_diff_msg') . '<br>';
                     }
                 }
                 // 					if ($volume_need > 0) { // act as count($data_slice), but with more verification
                 // 						if ($data_slice[PRINTERSTATE_TITLE_EXT_TEMPER] != $data_cartridge[PRINTERSTATE_TITLE_EXT_TEMPER]) {
                 // 							$error .= t('temper_diff_msg',
                 // 									array(
                 // 											$data_slice[PRINTERSTATE_TITLE_EXT_TEMPER],
                 // 											$data_cartridge[PRINTERSTATE_TITLE_EXT_TEMPER],
                 // 									)
                 // 							) . '<br>';
                 // 						}
                 // 						if ($data_slice[PRINTERSTATE_TITLE_EXT_TEMP_1] != $data_cartridge[PRINTERSTATE_TITLE_EXT_TEMP_1]) {
                 // 							$error .= t('first_temper_diff_msg',
                 // 									array(
                 // 											$data_slice[PRINTERSTATE_TITLE_EXT_TEMP_1],
                 // 											$data_cartridge[PRINTERSTATE_TITLE_EXT_TEMP_1],
                 // 									)
                 // 							) . '<br>';
                 // 						}
                 // 					}
             }
         }
         if (!is_null($error)) {
             $error .= t('suggest_reslice');
         }
         // check enable print
         if ($cr == ERROR_OK) {
             $enable_print = 'true';
         }
         // check bicolor model
         if ($array_data['r'][PRINTERSTATE_TITLE_NEED_L] > 0 && $array_data['l'][PRINTERSTATE_TITLE_NEED_L] > 0) {
             $bicolor_model = TRUE;
         } else {
             if ($array_data['r'][PRINTERSTATE_TITLE_NEED_L] > 0) {
                 $exchange_select_snd = TRUE;
             }
         }
         // check exchange possiblity
         if (ERROR_OK == PrinterState_checkFilaments(array('l' => $array_data['r'][PRINTERSTATE_TITLE_NEED_L], 'r' => $array_data['l'][PRINTERSTATE_TITLE_NEED_L]))) {
             $enable_exchange = NULL;
             // enable exchange if verification is passed
         } else {
             if ($bicolor_model == FALSE) {
                 if ($array_data['l'][PRINTERSTATE_TITLE_NEED_L] == 0 && $check_filament['l'] == t('filament_not_need')) {
                     $check_filament['l'] = t('filament_not_enough_for_switch');
                 } else {
                     if ($array_data['r'][PRINTERSTATE_TITLE_NEED_L] == 0 && $check_filament['r'] == t('filament_not_need')) {
                         $check_filament['r'] = t('filament_not_enough_for_switch');
                     }
                 }
             }
         }
     }
     if ($heat_bed) {
         $bed_temper = 0;
         $cr = Slicer_getParameter('bed_temperature', $bed_temper);
         $heat_bed = (int) $bed_temper > 0;
         // disable heat bed if it is not set by user
     }
     $template_data = array('cartridge_c_l' => $array_data['l'][PRINTERSTATE_TITLE_COLOR], 'cartridge_c_r' => $array_data['r'][PRINTERSTATE_TITLE_COLOR], 'state_f_l' => $check_filament['l'], 'state_f_r' => $check_filament['r'], 'need_filament_l' => $array_data['l'][PRINTERSTATE_TITLE_NEED_L], 'need_filament_r' => $array_data['r'][PRINTERSTATE_TITLE_NEED_L], 'temper_l' => $array_data['l'][PRINTERSTATE_TITLE_EXT_TEMPER], 'temper_r' => $array_data['r'][PRINTERSTATE_TITLE_EXT_TEMPER], 'print_button' => t('print_button'), 'left_temperature' => t('left_temperature'), 'right_temperature' => t('right_temperature'), 'chg_temperature' => t('chg_temperature'), 'change_left' => $change_filament['l'], 'change_right' => $change_filament['r'], 'error_msg' => $error, 'reslice_button' => t('reslice_button'), 'exchange_extruder' => t('exchange_extruder'), 'exchange_o1_val' => $exchange_select_snd ? 1 : 0, 'exchange_o2_val' => $exchange_select_snd ? 0 : 1, 'exchange_o2_sel' => $exchange_select_snd ? $option_selected : NULL, 'exchange_o1' => t('exchange_left'), 'exchange_o2' => t('exchange_right'), 'advanced' => t('advanced'), 'gcode_link' => t('gcode_link'), '2drender_link' => t('2drender_link'), 'filament_not_need' => t('filament_not_need'), 'filament_ok' => t('filament_ok'), 'result_title' => t('result_title'), 'temper_max' => PRINTERSTATE_TEMPER_CHANGE_MAX, 'temper_min' => PRINTERSTATE_TEMPER_CHANGE_MIN, 'temper_delta' => PRINTERSTATE_TEMPER_CHANGE_VAL, 'enable_print' => $enable_print, 'enable_exchange' => $enable_exchange, 'enable_reslice' => $error ? 'true' : 'false', 'bicolor_printer' => $bicolor_printer ? 'true' : 'false', 'bicolor_model' => $bicolor_model ? 'true' : 'false', 'extrud_multiply' => t('extrud_multiply'), 'left_extrud_mult' => t('left_extrud_mult'), 'right_extrud_mult' => t('right_extrud_mult'), 'extrud_r' => PRINTERSTATE_EXT_MULTIPLY_DEFAULT, 'extrud_l' => PRINTERSTATE_EXT_MULTIPLY_DEFAULT, 'extrud_min' => PRINTERSTATE_EXT_MULTIPLY_MIN, 'extrud_max' => PRINTERSTATE_EXT_MULTIPLY_MAX, 'title_heatbed' => t('title_heatbed'), 'button_bed_off' => t('button_bed_off'), 'heat_bed' => $heat_bed ? 'true' : 'false', 'bed_temper_pla' => PRINTERSTATE_TEMPER_BED_PLA, 'bed_temper_abs' => PRINTERSTATE_TEMPER_BED_ABS, 'bed_temper_max' => PRINTERSTATE_TEMPER_MAX_H);
     $this->parser->parse('sliceupload/slice_result_ajax', $template_data);
     $this->output->set_status_header(202);
     return;
 }
Ejemplo n.º 2
0
 public function detail()
 {
     $model_data = array();
     $template_data = array();
     $cr = 0;
     $check_filament = array();
     $change_filament = array();
     $array_data = array();
     $time_estimation = NULL;
     $body_page = NULL;
     $mono_model = FALSE;
     $bicolor = $this->config->item('nb_extruder') >= 2;
     $heat_bed = $this->config->item('heat_bed');
     $enable_print = 'true';
     $enable_exchange = 'disabled="disabled"';
     // select disable
     $calibration = FALSE;
     $this->load->helper(array('printlist', 'printerstate', 'slicer', 'timedisplay'));
     $this->load->library('parser');
     $this->lang->load('printlist', $this->config->item('language'));
     $this->lang->load('timedisplay', $this->config->item('language'));
     $mid = $this->input->get('id');
     // check model id, resend user to if not valid
     if ($mid) {
         if ($mid == 'calibration') {
             $mid = ModelList_codeModelHash(PRINTLIST_MODEL_CALIBRATION);
             $calibration = TRUE;
         }
         $cr = ModelList__getDetailAsArray($mid, $model_data, TRUE);
         if ($cr != ERROR_OK || is_null($model_data)) {
             $this->output->set_header('Location: /printmodel/listmodel');
             return;
         }
     } else {
         $this->output->set_header('Location: /printmodel/listmodel');
         return;
     }
     // check the model is mono-color or 2 colors
     if (isset($model_data[PRINTLIST_TITLE_LENG_F2]) && $model_data[PRINTLIST_TITLE_LENG_F2] > 0) {
         $mono_model = FALSE;
     } else {
         $mono_model = TRUE;
     }
     // initialize variables
     $check_filament = array('l' => t('ok'), 'r' => t('ok'));
     $change_filament = array('l' => t('Change'), 'r' => t('Change'));
     // check quantity of filament and get cartridge information (color)
     // color1 => right, color2 => left
     foreach (array('r', 'l') as $abb_filament) {
         $data_cartridge = array();
         $key_length = $abb_filament == 'l' ? PRINTLIST_TITLE_LENG_F2 : PRINTLIST_TITLE_LENG_F1;
         $key_color = $abb_filament == 'l' ? PRINTLIST_TITLE_COLOR_F2 : PRINTLIST_TITLE_COLOR_F1;
         if ($model_data[$key_length] <= 0) {
             $check_filament[$abb_filament] = t('filament_not_need');
         }
         // check mono extruder case (normally, it's not necessary)
         if ($bicolor == FALSE && $abb_filament == 'l') {
             $cr = ERROR_MISS_LEFT_CART;
         } else {
             $cr = PrinterState_checkFilament($abb_filament, $model_data[$key_length], $data_cartridge);
         }
         if (in_array($cr, array(ERROR_OK, ERROR_MISS_LEFT_FILA, ERROR_MISS_RIGT_FILA, ERROR_LOW_LEFT_FILA, ERROR_LOW_RIGT_FILA))) {
             $array_data[$abb_filament] = array(PRINTERSTATE_TITLE_COLOR => $data_cartridge[PRINTERSTATE_TITLE_COLOR], PRINTERSTATE_TITLE_EXT_TEMPER => $data_cartridge[PRINTERSTATE_TITLE_EXT_TEMPER]);
             // set default temperature if pla
             if ($data_cartridge[PRINTERSTATE_TITLE_MATERIAL] == PRINTERSTATE_DESP_MATERIAL_PLA) {
                 $array_data[$abb_filament][PRINTERSTATE_TITLE_EXT_TEMPER] = PRINTERSTATE_VALUE_FILAMENT_PLA_PRINT_TEMPER;
             }
         } else {
             $array_data[$abb_filament] = array(PRINTERSTATE_TITLE_COLOR => PRINTERSTATE_VALUE_DEFAULT_COLOR, PRINTERSTATE_TITLE_EXT_TEMPER => SLICER_VALUE_DEFAULT_TEMPER);
         }
         $array_data[$abb_filament][PRINTERSTATE_TITLE_NEED_L] = $model_data[$key_length];
         // treat error
         switch ($cr) {
             case ERROR_OK:
                 // do nothing if no error
                 break;
             case ERROR_LOW_RIGT_FILA:
                 $check_filament['r'] = t('not enough');
                 break;
             case ERROR_MISS_RIGT_FILA:
                 $check_filament['r'] = t('unloaded');
                 $change_filament['r'] = t('Load');
                 break;
             case ERROR_MISS_RIGT_CART:
                 $check_filament['r'] = t('empty');
                 $change_filament['r'] = t('Load');
                 break;
             case ERROR_LOW_LEFT_FILA:
                 $check_filament['l'] = t('not enough');
                 break;
             case ERROR_MISS_LEFT_FILA:
                 $check_filament['l'] = t('unloaded');
                 $change_filament['l'] = t('Load');
                 break;
             case ERROR_MISS_LEFT_CART:
                 $check_filament['l'] = t('empty');
                 $change_filament['l'] = t('Load');
                 break;
             default:
                 $this->load->helper('printerlog');
                 PrinterLog_logError('not previewed return code for checking filament ' . $abb_filament, __FILE__, __LINE__);
                 // assign error message if necessary
                 $check_filament[$abb_filament] = t('error');
                 break;
         }
         if ($cr != ERROR_OK && $model_data[$key_length] > 0) {
             $enable_print = 'false';
         }
     }
     // get a more legible time of estimation
     $time_estimation = TimeDisplay__convertsecond($model_data[PRINTLIST_TITLE_TIME], t('Time estimation: '), t('unknown'));
     // check if we can inverse filament / exchange extruder or not
     $cr = PrinterState_checkFilaments(array('l' => $array_data['r'][PRINTERSTATE_TITLE_NEED_L], 'r' => $array_data['l'][PRINTERSTATE_TITLE_NEED_L]));
     if ($cr == ERROR_OK && $calibration == FALSE) {
         $enable_exchange = NULL;
     } else {
         if ($mono_model == TRUE) {
             if ($array_data['l'][PRINTERSTATE_TITLE_NEED_L] == 0) {
                 $check_filament['l'] = t('filament_not_enough_for_switch');
             } else {
                 // ($array_data['r'][PRINTERSTATE_TITLE_NEED_L] == 0)
                 $check_filament['r'] = t('filament_not_enough_for_switch');
             }
         }
     }
     // show detail page if valid, parse the body of page
     $template_data = array('home' => t('Home'), 'title' => $model_data[PRINTLIST_TITLE_NAME], 'image' => $model_data[PRINTLIST_TITLE_PIC][0], 'model_c_r' => $model_data[PRINTLIST_TITLE_COLOR_F1], 'model_c_l' => $model_data[PRINTLIST_TITLE_COLOR_F2], 'time' => $time_estimation, 'desp' => $model_data[PRINTLIST_TITLE_DESP], 'state_c_l' => $array_data['l'][PRINTERSTATE_TITLE_COLOR], 'state_c_r' => $array_data['r'][PRINTERSTATE_TITLE_COLOR], 'state_f_l' => $check_filament['l'], 'state_f_r' => $check_filament['r'], 'model_id' => $mid, 'title_current' => t('Filament'), 'change_filament_l' => $change_filament['l'], 'change_filament_r' => $change_filament['r'], 'need_filament_l' => $model_data[PRINTLIST_TITLE_LENG_F2], 'need_filament_r' => $model_data[PRINTLIST_TITLE_LENG_F1], 'temper_filament_l' => $array_data['l'][PRINTERSTATE_TITLE_EXT_TEMPER], 'temper_filament_r' => $array_data['r'][PRINTERSTATE_TITLE_EXT_TEMPER], 'print_model' => t('Print'), 'back' => t('back'), 'preview_title' => t('Preview'), 'desp_title' => t('Description'), 'color_suggestion' => t('color_suggestion'), 'temp_adjustments_l' => t('temp_adjustments_l'), 'temp_adjustments_r' => t('temp_adjustments_r'), 'chg_temperature' => t('chg_temperature'), 'error' => t('error'), 'filament_not_need' => t('filament_not_need'), 'filament_ok' => t('ok'), 'temper_max' => PRINTERSTATE_TEMPER_CHANGE_MAX, 'temper_min' => PRINTERSTATE_TEMPER_CHANGE_MIN, 'temper_delta' => PRINTERSTATE_TEMPER_CHANGE_VAL, 'exchange_on' => t('exchange_left'), 'exchange_off' => t('exchange_right'), 'exchange_extruder' => t('exchange_extruder'), 'random_prefix' => $mid . '_' . rand() . '_', 'enable_exchange' => $enable_exchange, 'enable_print' => $enable_print, 'bicolor_model' => $mono_model ? 'false' : 'true', 'bicolor_printer' => $bicolor ? 'true' : 'false', 'advanced' => t('advanced'), 'extrud_multiply' => t('extrud_multiply'), 'left_extrud_mult' => t('left_extrud_mult'), 'right_extrud_mult' => t('right_extrud_mult'), 'extrud_r' => PRINTERSTATE_EXT_MULTIPLY_DEFAULT, 'extrud_l' => PRINTERSTATE_EXT_MULTIPLY_DEFAULT, 'extrud_min' => PRINTERSTATE_EXT_MULTIPLY_MIN, 'extrud_max' => PRINTERSTATE_EXT_MULTIPLY_MAX, 'title_heatbed' => t('title_heatbed'), 'button_bed_off' => t('button_bed_off'), 'heat_bed' => $heat_bed ? 'true' : 'false', 'bed_temper_pla' => PRINTERSTATE_TEMPER_BED_PLA, 'bed_temper_abs' => PRINTERSTATE_TEMPER_BED_ABS, 'bed_temper_max' => PRINTERSTATE_TEMPER_MAX_H);
     $this->_parseBaseTemplate(t('ZeePro Personal Printer 21 - Printing details'), $this->parser->parse('printlist/detail', $template_data, TRUE));
     return;
 }
Ejemplo n.º 3
0
function Printer_printFromFile($gcode_path, $model_id, $time_estimation, $need_prime = TRUE, $exchange_extruder = FALSE, $array_filament = array(), $array_temper = array())
{
    global $CFG;
    $command = '';
    $output = array();
    $temper_json = array();
    $ret_val = 0;
    $stats_info = array();
    $CI =& get_instance();
    $CI->load->helper(array('printerstate', 'errorcode', 'corestatus', 'printerlog', 'detectos'));
    // check if we have no file
    if (!file_exists($gcode_path)) {
        return ERROR_INTERNAL;
    }
    // only check if we are in printing when we are not called stopping printing
    // 	if ($stop_printing == FALSE) {
    // check if in printing
    $ret_val = PrinterState_checkInPrint();
    if ($ret_val == TRUE) {
        // 			return ERROR_IN_PRINT;
        PrinterLog_logMessage('already in printing', __FILE__, __LINE__);
        return ERROR_BUSY_PRINTER;
    }
    // 	}
    // check extruder number
    if ($CI->config->item('nb_extruder') < 2) {
        $tmp_array = array();
        $command = $CFG->config['gcanalyser'] . $gcode_path;
        exec($command, $output, $ret_val);
        if ($ret_val != ERROR_NORMAL_RC_OK) {
            PrinterLog_logError('gcanalyser error', __FILE__, __LINE__);
            return ERROR_INTERNAL;
        }
        $tmp_array = json_decode($output[0], TRUE);
        if ($tmp_array['N'] > $CI->config->item('nb_extruder')) {
            PrinterLog_logMessage('no enough extruder', __FILE__, __LINE__);
            return ERROR_INTERNAL;
        }
    }
    // check if having enough filament
    $ret_val = PrinterState_checkFilaments($array_filament);
    if ($ret_val != ERROR_OK) {
        return $ret_val;
    }
    if ($time_estimation == 0) {
        $ret_val = Printer__getEstimation($array_filament, $time_estimation);
        if ($ret_val != TRUE) {
            PrinterLog_logError('system can not get estimation time');
            return ERROR_INTERNAL;
        }
    }
    // prepare subprinting gcode files and scripts
    $ret_val = Printer_preparePrint($model_id, $need_prime);
    if ($ret_val != ERROR_OK) {
        return $ret_val;
    }
    // 	if ($stop_printing == FALSE) {
    if ($CFG->config['simulator']) {
        // just set temperature for simulation
        PrinterState_setExtruder('r');
        PrinterState_setTemperature(210);
        PrinterState_setExtruder('l');
        PrinterState_setTemperature(200);
        PrinterState_setExtruder('r');
    }
    // change status json file
    foreach ($array_temper as $abb_filament => $tmp_temper) {
        if ($abb_filament != 'b' && (!array_key_exists($abb_filament, $array_filament) || $array_filament[$abb_filament] <= 0)) {
            $temper_json[$abb_filament] = NULL;
        } else {
            $temper_json[$abb_filament] = $array_temper[$abb_filament];
        }
    }
    $ret_val = CoreStatus_setInPrinting($model_id, $time_estimation, $exchange_extruder, $temper_json);
    // 	}
    // 	else {
    // 		$ret_val = CoreStatus_setInCanceling();
    // 	}
    if ($ret_val == FALSE) {
        return ERROR_INTERNAL;
    }
    // stats info
    $stats_info[PRINTERLOG_STATS_MODEL] = $model_id;
    foreach ($temper_json as $abb_filament => $tmp_temper) {
        if (isset($tmp_temper)) {
            $json_cartridge = array();
            $arrkey_type = PRINTERLOG_STATS_FILA_TYPE_R;
            $arrkey_color = PRINTERLOG_STATS_FILA_COLOR_R;
            if ($abb_filament == 'l') {
                $arrkey_type = PRINTERLOG_STATS_FILA_TYPE_L;
                $arrkey_color = PRINTERLOG_STATS_FILA_COLOR_L;
            }
            if (ERROR_OK == PrinterState_getCartridgeAsArray($json_cartridge, $abb_filament)) {
                $stats_info[$arrkey_type] = $json_cartridge[PRINTERSTATE_TITLE_MATERIAL];
                $stats_info[$arrkey_color] = $json_cartridge[PRINTERSTATE_TITLE_COLOR];
            }
        }
    }
    PrinterLog_statsPrint(PRINTERLOG_STATS_ACTION_START, $stats_info);
    // pass gcode to printer
    //	if (!PrinterState_beforeFileCommand()) {
    //		return ERROR_INTERNAL;
    //	}
    // use different command for priming
    if ($need_prime == FALSE) {
        $command = PrinterState_getPrintCommand($array_filament, TRUE, TRUE) . $gcode_path;
    } else {
        $command = PrinterState_getPrintCommand($array_filament) . $gcode_path;
    }
    // 		exec($command, $output, $ret_val);
    // 		if ($ret_val != ERROR_NORMAL_RC_OK) {
    // 			return ERROR_INTERNAL;
    // 		}
    if ($CFG->config['simulator'] && DectectOS_checkWindows()) {
        pclose(popen($command, 'r'));
        // only for windows arcontrol client
        PrinterLog_logArduino($command);
    } else {
        // 		exec($command, $output, $ret_val);
        pclose(popen($command . ' > ' . PRINTERSTATE_FILE_PRINTLOG . ' &', 'r'));
        // 		if (!PrinterState_filterOutput($output)) {
        // 			PrinterLog_logError('filter arduino output error', __FILE__, __LINE__);
        // 			return ERROR_INTERNAL;
        // 		}
        // 		if ($ret_val != ERROR_NORMAL_RC_OK) {
        // 			return $ret_val;
        // 		}
        // 		PrinterLog_logArduino($command, $output);
        PrinterLog_logArduino($command);
    }
    //	if (!PrinterState_afterFileCommand()) {
    //		return ERROR_INTERNAL;
    //	}
    return ERROR_OK;
}