private function _display_changecartridge_cartridge_detail($abb_cartridge, $id_model) { $cr = 0; $template_data = array(); $cartridge_data = array(); $this->load->helper(array('printlist', 'printerstate')); $this->load->library('parser'); $this->lang->load('printerstate/changecartridge', $this->config->item('language')); $color_model = PRINTERSTATE_VALUE_DEFAULT_COLOR; $color_cart = PRINTERSTATE_VALUE_DEFAULT_COLOR; $model_title = t('Color of model'); $cartridge_title = t('Color of cartridge'); if ($id_model) { $model_data = array(); $cr = ModelList__getDetailAsArray($id_model, $model_data, TRUE); if ($cr != ERROR_OK || is_null($model_data)) { $this->load->helper('printerlog'); PrinterLog_logMessage('can not get model info', __FILE__, __LINE__); $id_model = NULL; $model_title = t('No model'); } else { $color_model = $abb_cartridge == 'r' ? $model_data[PRINTLIST_TITLE_COLOR_F1] : $model_data[PRINTLIST_TITLE_COLOR_F2]; } } else { $model_title = t('No model'); } $cr = PrinterState_getCartridgeAsArray($cartridge_data, $abb_cartridge); if ($cr != ERROR_OK && is_null($cartridge_data)) { $this->load->helper('printerlog'); PrinterLog_logError('can not get cartridge info', __FILE__, __LINE__); $cartridge_title = t('Error'); } else { $color_cart = $cartridge_data[PRINTERSTATE_TITLE_COLOR]; } $template_data = array('cart_title' => $cartridge_title, 'model_title' => $model_title, 'model_color' => $color_model, 'cart_color' => $color_cart); $this->parser->parse('printerstate/changecartridge_ajax/detail_cartridge', $template_data); return; }
public function youtube_form() { $array_status = array(); $model_displayname = NULL; $this->load->library('parser'); $this->lang->load('youtube_form', $this->config->item('language')); $this->lang->load('printdetail', $this->config->item('language')); // timelapse default model name $this->load->helper('corestatus'); if (CoreStatus_checkInIdle($status_current, $array_status) && array_key_exists(CORESTATUS_TITLE_PRINTMODEL, $array_status)) { $model_id = NULL; if (strpos($array_status[CORESTATUS_TITLE_PRINTMODEL], CORESTATUS_VALUE_MID_PREFIXGCODE) === 0) { // gcode library model $gcode_info = array(); $gid = (int) substr($array_status[CORESTATUS_TITLE_PRINTMODEL], strlen(CORESTATUS_VALUE_MID_PREFIXGCODE)); $model_displayname = t('timelapse_info_modelname_unknown'); $this->load->helper('printerstoring'); $gcode_info = PrinterStoring_getInfo("gcode", $gid); if (!is_null($gcode_info) && array_key_exists("name", $gcode_info)) { $model_displayname = $gcode_info["name"]; } } else { switch ($array_status[CORESTATUS_TITLE_PRINTMODEL]) { case CORESTATUS_VALUE_MID_SLICE: $preset_id = NULL; $model_filename = array(); $this->load->helper('slicer'); if (ERROR_OK == Slicer_getModelFile(0, $model_filename, TRUE)) { foreach ($model_filename as $model_basename) { if (strlen($model_displayname)) { $model_displayname .= ' + ' . $model_basename; } else { $model_displayname = $model_basename; } } } else { $model_displayname = t('timelapse_info_modelname_slice'); } break; default: // treat as pre-sliced model $model_data = array(); $model_displayname = ""; if (is_null($model_id)) { $this->load->helper('printlist'); $model_id = $array_status[CORESTATUS_TITLE_PRINTMODEL]; } if (ERROR_OK == ModelList__getDetailAsArray($model_id, $model_data, TRUE)) { $model_displayname = $model_data[PRINTLIST_TITLE_NAME]; } break; } } } if ($this->input->server('REQUEST_METHOD') == 'POST') { $this->load->library("session"); $title = isset($_POST['yt_title']) ? $_POST['yt_title'] : t('yt_title') . $model_displayname; $description = isset($_POST['yt_description']) ? $_POST['yt_description'] : t('yt_desc'); // $tags = explode(',', $_POST['yt_tags'] ? $_POST['yt_tags'] : t('yt_tags')); $tags = explode(',', t('yt_tags')); $tags = array_map('trim', $tags); $video_infos = array('yt_title' => $title, 'yt_tags' => $tags, 'yt_desc' => $description, 'yt_privacy' => $_POST["yt_privacy"]); $this->session->set_userdata($video_infos); $this->output->set_header("Location: /share/connect_google"); return; } $data = array('yt_title' => t('yt_title') . $model_displayname, 'yt_desc' => t('yt_desc'), 'yt_privacy_public' => t('yt_privacy_public'), 'yt_privacy_private' => t('yt_privacy_private'), 'yt_privacy_unlisted' => t('yt_privacy_unlisted'), 'upload_to_yt' => t('upload_to_yt'), 'title_label' => t('title_label'), 'desc_label' => t('desc_label'), 'tags_label' => t('tags_label'), 'privacy_label' => t('privacy_label'), 'back' => t('back')); $this->_parseBaseTemplate(t('youtube_title'), $this->parser->parse('share/youtube_form', $data, TRUE)); return; }
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; }
public function timelapse() { $template_data = array(); $array_info = array(); $status_current = NULL; $array_status = array(); $restart_url = NULL; $model_displayname = NULL; $show_storegcode = FALSE; $this->load->library('parser'); $this->load->helper('zimapi'); $this->lang->load('printdetail', $this->config->item('language')); if (CoreStatus_checkInIdle($status_current, $array_status) && array_key_exists(CORESTATUS_TITLE_PRINTMODEL, $array_status)) { $model_id = NULL; $abb_cartridge = NULL; $model_temper = NULL; if (strpos($array_status[CORESTATUS_TITLE_PRINTMODEL], CORESTATUS_VALUE_MID_PREFIXGCODE) === 0) { // gcode library model $gcode_info = array(); $gid = (int) substr($array_status[CORESTATUS_TITLE_PRINTMODEL], strlen(CORESTATUS_VALUE_MID_PREFIXGCODE)); $model_displayname = t('timelapse_info_modelname_unknown'); $this->load->helper('printerstoring'); $gcode_info = PrinterStoring_getInfo("gcode", $gid); if (!is_null($gcode_info) && array_key_exists("name", $gcode_info)) { $model_displayname = $gcode_info["name"]; } $array_info[] = array('title' => t('timelapse_info_modelname_title'), 'value' => $model_displayname); $restart_url = '/printdetail/printgcode?id=' . $gid; } else { switch ($array_status[CORESTATUS_TITLE_PRINTMODEL]) { case CORESTATUS_VALUE_MID_SLICE: $preset_id = NULL; $model_filename = array(); $preset_name = t('timelapse_info_presetname_unknown'); $this->load->helper('slicer'); if (ERROR_OK == Slicer_getModelFile(0, $model_filename, TRUE)) { foreach ($model_filename as $model_basename) { if (strlen($model_displayname)) { $model_displayname .= ' + ' . $model_basename; } else { $model_displayname = $model_basename; } } } else { $model_displayname = t('timelapse_info_modelname_slice'); } $array_info[] = array('title' => t('timelapse_info_modelname_title'), 'value' => $model_displayname); if (ZimAPI_getPreset($preset_id)) { $array_json = array(); if (ERROR_OK == ZimAPI_getPresetInfoAsArray($preset_id, $array_json)) { $preset_name = $array_json[ZIMAPI_TITLE_PRESET_NAME]; } } $array_info[] = array('title' => t('timelapse_info_presetname_title'), 'value' => $preset_name); $restart_url = '/printdetail/printslice'; $show_storegcode = TRUE; break; case CORESTATUS_VALUE_MID_PRIME_R: $abb_cartridge = 'r'; // treat priming in the same way // treat priming in the same way case CORESTATUS_VALUE_MID_PRIME_L: // never reach here normally (no timelapse for priming in principe, just for safety) $array_info[] = array('title' => t('timelapse_info_modelname_title'), 'value' => t('timelapse_info_modelname_prime')); if (is_null($abb_cartridge)) { $abb_cartridge = 'l'; } $restart_url = '/printdetail/printprime?r&v=' . $abb_cartridge; //TODO we lose callback info here break; case CORESTATUS_VALUE_MID_CALIBRATION: // never reach here normally (no timelapse for calibration model, just for safety) $this->load->helper('printlist'); $model_id = ModelList_codeModelHash(PRINTLIST_MODEL_CALIBRATION); $restart_url = '/printmodel/detail?id=calibration'; // treat as a normal pre-sliced model // treat as a normal pre-sliced model default: // treat as pre-sliced model $model_data = array(); $model_displayname = t('timelapse_info_modelname_unknown'); if (is_null($model_id)) { $this->load->helper('printlist'); $model_id = $array_status[CORESTATUS_TITLE_PRINTMODEL]; } if (ERROR_OK == ModelList__getDetailAsArray($model_id, $model_data, TRUE)) { $model_displayname = $model_data[PRINTLIST_TITLE_NAME]; } $array_info[] = array('title' => t('timelapse_info_modelname_title'), 'value' => $model_displayname); if (is_null($restart_url)) { $restart_url = '/printdetail/printmodel?id=' . $model_id; } break; } } if (array_key_exists(CORESTATUS_TITLE_ELAPSED_TIME, $array_status)) { $display_time = NULL; $this->load->helper('timedisplay'); $display_time = TimeDisplay__convertsecond($array_status[CORESTATUS_TITLE_ELAPSED_TIME], ''); $array_info[] = array('title' => t('timelapse_info_elapsedtime_title'), 'value' => $display_time); } if ($this->config->item('nb_extruder') < 2 && array_key_exists(CORESTATUS_TITLE_P_TEMPER_R, $array_status) && $array_status[CORESTATUS_TITLE_P_TEMPER_R] > 0) { $model_temper = t('timelapse_info_temperature_value_mono', array($array_status[CORESTATUS_TITLE_P_TEMPER_R])); } else { if (array_key_exists(CORESTATUS_TITLE_P_TEMPER_L, $array_status) && $array_status[CORESTATUS_TITLE_P_TEMPER_L] > 0 && array_key_exists(CORESTATUS_TITLE_P_TEMPER_R, $array_status) && $array_status[CORESTATUS_TITLE_P_TEMPER_R] > 0) { $model_temper = t('timelapse_info_temperature_values', array($array_status[CORESTATUS_TITLE_P_TEMPER_L], $array_status[CORESTATUS_TITLE_P_TEMPER_R])); } else { if (array_key_exists(CORESTATUS_TITLE_P_TEMPER_R, $array_status) && $array_status[CORESTATUS_TITLE_P_TEMPER_R] > 0) { $model_temper = t('timelapse_info_temperature_value_r', array($array_status[CORESTATUS_TITLE_P_TEMPER_R])); } else { if (array_key_exists(CORESTATUS_TITLE_P_TEMPER_L, $array_status) && $array_status[CORESTATUS_TITLE_P_TEMPER_L] > 0) { $model_temper = t('timelapse_info_temperature_value_l', array($array_status[CORESTATUS_TITLE_P_TEMPER_L])); } } } } if ($model_temper) { if (array_key_exists(CORESTATUS_TITLE_P_TEMPER_B, $array_status) && $array_status[CORESTATUS_TITLE_P_TEMPER_B] > 0) { $model_temper .= t('timelapse_info_extra_temperature_value_b', array($array_status[CORESTATUS_TITLE_P_TEMPER_B])); } $array_info[] = array('title' => t('timelapse_info_temperature_title'), 'value' => $model_temper); } } else { $this->load->helper('printerlog'); PrinterLog_logError('unintended status detected in timelapse page: ' . $status_current, __FILE__, __LINE__); $this->output->set_header('Location: /'); return; } // parse the main body $template_data = array('internet_ok' => @file_get_contents("https://sso.zeepro.com/login.ashx") === FALSE ? 'false' : 'true', 'loading_player' => t('timelapse_info'), 'finish_info' => t('Congratulation, your printing is complete!'), 'home_button' => t('Home'), 'home_popup_text' => t('home_popup_text'), 'yes' => t('Yes'), 'no' => t('No'), 'video_error' => t('video_error'), 'timelapse_title' => t('timelapse_title'), 'send_email_button' => t('send_email_button'), 'send_yt_button' => t('send_yt_button'), 'send_fb_button' => t('send_fb_button'), 'send_email_hint' => t('send_email_hint'), 'send_email_action' => t('send_email_action'), 'send_email_error' => t('send_email_error'), 'send_email_wrong' => t('send_email_wrong'), 'send_email_multi' => t('send_email_multi'), 'video_url' => '/tmp/' . ZIMAPI_FILENAME_TIMELAPSE . '?_=' . time(), 'timelapse_info_title' => t('timelapse_info_title'), 'timelapse_info' => $array_info, 'again_button' => t('Print again'), 'restart_url' => $restart_url ? $restart_url : '/', 'send_email_modelname' => $model_displayname, 'display_storegocde' => $show_storegcode ? 'true' : 'false', 'storegcode_checkbox' => t('storegcode_info'), 'storegcode_hint' => t('storegcode_name'), 'storegcode_err_cfm' => t('storegcode_err_cfm'), 'storegcode_title' => t('storegcode_title')); // parse all page $this->_parseBaseTemplate(t('ZeePro Personal Printer 21 - Printing details'), $this->parser->parse('printdetail/timelapse', $template_data, TRUE)); return; }
function Printer_preparePrint($model_id, $need_prime = TRUE) { $cr = 0; $timelapse_length = 0; $gcode_path = ''; $CI =& get_instance(); $CI->load->helper(array('printlist', 'corestatus')); if (!in_array($model_id, array(CORESTATUS_VALUE_MID_CALIBRATION, CORESTATUS_VALUE_MID_PRIME_L, CORESTATUS_VALUE_MID_PRIME_R, PRINTER_VALUE_MID_API_CALL))) { $CI->load->helper('zimapi'); // get printing length // if just sliced model, get value from temporary json file if ($model_id == CORESTATUS_VALUE_MID_SLICE) { $temp_json = array(); $CI->load->helper('printerstate'); if (ERROR_OK == PrinterState_getSlicedJson($temp_json)) { foreach ($temp_json as $temp_filament) { if (array_key_exists(PRINTERSTATE_TITLE_NEED_L, $temp_filament)) { $timelapse_length += $temp_filament[PRINTERSTATE_TITLE_NEED_L]; } } } } else { if (strpos($model_id, CORESTATUS_VALUE_MID_PREFIXGCODE) === 0) { $gcode_info = array(); $CI->load->helper('printerstoring'); $model_id = (int) substr($model_id, strlen(CORESTATUS_VALUE_MID_PREFIXGCODE)); $gcode_info = PrinterStoring_getInfo("gcode", $model_id); if (!is_null($gcode_info) && array_key_exists(PRINTERSTORING_TITLE_LENG_R, $gcode_info) && array_key_exists(PRINTERSTORING_TITLE_LENG_L, $gcode_info)) { $timelapse_length = $gcode_info[PRINTERSTORING_TITLE_LENG_R] + $gcode_info[PRINTERSTORING_TITLE_LENG_L]; } } else { if (strlen($model_id) == 32) { $model_info = array(); if (ERROR_OK == ModelList__getDetailAsArray($model_id, $model_info) && !is_null($model_info)) { foreach (array(PRINTLIST_TITLE_LENG_F1, PRINTLIST_TITLE_LENG_F2) as $key_length) { if (array_key_exists($key_length, $model_info)) { $timelapse_length += $model_info[$key_length]; } } } } } } if ($timelapse_length <= 0) { $timelapse_length = ZIMAPI_VALUE_DEFAULT_LENGTH; } // timelapse camera switch and prepare script, and write fps info into file if (file_exists(ZIMAPI_FILEPATH_POSTHEAT)) { $script_path = $CI->config->item('temp') . PRINTER_FN_POST_HEAT; $fps = ZIMAPI_VALUE_DEFAULT_TL_LENGTH * 10 / Printer__calculateEstimation($timelapse_length); $parameter = str_replace('{fps}', min(array(2.5, $fps * 2)), ZIMAPI_PRM_CAMERA_PRINTSTART_TIMELAPSE); $command_addon = "\n" . str_replace('sudo nice', 'nice', $CI->config->item('camera')) . $parameter . "\n"; copy(ZIMAPI_FILEPATH_POSTHEAT, $script_path); $fp = fopen($script_path, 'a'); if ($fp) { fwrite($fp, $command_addon); fclose($fp); } chmod($script_path, 0775); //TODO think if we block processing when getting an error } else { $CI->load->helper('printerlog'); PrinterLog_logError('prepare post heat script error', __FILE__, __LINE__); } // timelapse end part generation script + generation script foreach (array(PRINTER_FN_PRE_FINISH => ZIMAPI_FILEPATH_PREFINISH, PRINTER_FN_END_PRINT => ZIMAPI_FILEPATH_ENDPRINT) as $tmp_file => $bin_path) { if (file_exists($bin_path)) { $script_path = $CI->config->item('temp') . $tmp_file; copy($bin_path, $script_path); chmod($script_path, 0775); } else { $CI->load->helper('printerlog'); PrinterLog_logError('prepare script error: ' . $tmp_file, __FILE__, __LINE__); } } } else { foreach (array(PRINTER_FN_END_PRINT, PRINTER_FN_POST_HEAT, PRINTER_FN_PRE_FINISH) as $file_unlink) { @unlink($CI->config->item('temp') . $file_unlink); } } if ($need_prime == TRUE) { $cr = Printer_getFileFromModel(PRINTER_TYPE_MODELLIST, ModelList_codeModelHash(PRINTLIST_MODEL_PRINTPRIME_L), $gcode_path, PRINTER_FN_PRINTPRIME_L); if ($cr != ERROR_OK) { $CI->load->helper('printerlog'); PrinterLog_logError('prepare print prime left gcode error', __FILE__, __LINE__); return $cr; } $cr = Printer_getFileFromModel(PRINTER_TYPE_MODELLIST, ModelList_codeModelHash(PRINTLIST_MODEL_PRINTPRIME_R), $gcode_path, PRINTER_FN_PRINTPRIME_R); if ($cr != ERROR_OK) { $CI->load->helper('printerlog'); PrinterLog_logError('prepare print prime right gcode error', __FILE__, __LINE__); return $cr; } } else { @unlink($CI->config->item('temp') . PRINTER_FN_PRINTPRIME_L); @unlink($CI->config->item('temp') . PRINTER_FN_PRINTPRIME_R); } // $cr = Printer_getFileFromModel(PRINTER_TYPE_MODELLIST, ModelList_codeModelHash(PRINTLIST_MODEL_CHARGE), // $gcode_path, PRINTER_FN_CHARGE); // if ($cr != ERROR_OK) { // $CI->load->helper('printerlog'); // PrinterLog_logError('prepare charge gcode error', __FILE__, __LINE__); // return $cr; // } // $cr = Printer_getFileFromModel(PRINTER_TYPE_MODELLIST, ModelList_codeModelHash(PRINTLIST_MODEL_RETRACT), // $gcode_path, PRINTER_FN_RETRACT); // if ($cr != ERROR_OK) { // $CI->load->helper('printerlog'); // PrinterLog_logError('prepare retract gcode error', __FILE__, __LINE__); // return $cr; // } return ERROR_OK; }
function ModelList__getDuration($id_model, &$duration) { //TODO finish this function if necessary // but now, print presliced file always finish in 20s (random select between 0 and 20) $json_data = NULL; $model_cr = ModelList__getDetailAsArray($id_model, $json_data); if ($model_cr == ERROR_OK && $json_data) { $duration = $json_data[PRINTLIST_TITLE_TIME]; return ERROR_OK; } else { return $model_cr; } return; }