function ZimAPI_checkCameraInBlock() { $data_json = array(); $CI =& get_instance(); $CI->load->helper(array('corestatus', 'printerstate')); // check we are in printing, and not in heating $data_json = PrinterState_checkStatusAsArray(FALSE); if (is_array($data_json) && $data_json[PRINTERSTATE_TITLE_STATUS] == CORESTATUS_VALUE_PRINT && isset($data_json[PRINTERSTATE_TITLE_EXTEND_PRM][PRINTERSTATE_TITLE_EXT_OPER]) && $data_json[PRINTERSTATE_TITLE_EXTEND_PRM][PRINTERSTATE_TITLE_EXT_OPER] != PRINTERSTATE_VALUE_PRINT_OPERATION_HEAT) { // $status_current = NULL; // check we are in printing of normal model which has timelapse //TODO union two verification of timelapse into 1 (preparePrint function in printer helper and this function) // CoreStatus_checkInIdle($status_current, $data_json); CoreStatus_getStatusArray($data_json); if (isset($data_json[CORESTATUS_TITLE_PRINTMODEL]) && in_array($data_json[CORESTATUS_TITLE_PRINTMODEL], array(CORESTATUS_VALUE_MID_PRIME_R, CORESTATUS_VALUE_MID_PRIME_L, CORESTATUS_VALUE_MID_CALIBRATION))) { return FALSE; } else { $CI->load->helper('printerlog'); PrinterLog_logMessage('ignore all camera requests in printing non-heating phase'); } return TRUE; } return FALSE; }
public function status() { $time_remain = NULL; $pagetitle = NULL; $template_data = array(); $data_status = array(); $temper_status = array(); $print_slice = FALSE; $print_calibration = FALSE; $status_strip = FALSE; $status_head = FALSE; $ret_val = 0; $option_selected = 'selected="selected"'; $status_current = NULL; $this->load->library('parser'); $this->lang->load('printdetail', $this->config->item('language')); $this->lang->load('printerstate/index', $this->config->item('language')); $this->load->helper(array('zimapi', 'printerstate', 'corestatus')); $id = $this->input->get('id'); $callback = $this->input->get('cb'); $abb_cartridge = $this->input->get('v'); $array_status = array(); $model_displayname = t('timelapse_info_modelname_unknown'); // check if we are in printing or not to continue, do redirection if not $data_status = PrinterState_checkStatusAsArray(FALSE); if ($data_status[PRINTERSTATE_TITLE_STATUS] != CORESTATUS_VALUE_PRINT) { if (in_array($data_status[PRINTERSTATE_TITLE_STATUS], array(CORESTATUS_VALUE_IDLE, CORESTATUS_VALUE_SLICED)) && file_exists(ZIMAPI_FILEPATH_TIMELAPSE)) { $this->output->set_header('Location: /printdetail/timelapse'); } else { $this->output->set_header('Location: /'); } return; } if (!ZimAPI_checkCameraInBlock()) { // only launch camera video for heating parse (camera is in use for other parses) if (!ZimAPI_cameraOn(ZIMAPI_PRM_CAMERA_PRINTSTART)) { $this->load->helper('printerlog'); PrinterLog_logError('can not set camera', __FILE__, __LINE__); } } // pass the real value of LED later $this->get_led($status_strip, $status_head); if ($id == CORESTATUS_VALUE_MID_SLICE) { $print_slice = TRUE; } else { if ($id == CORESTATUS_VALUE_MID_CALIBRATION) { $print_calibration = TRUE; } } // get model name CoreStatus_getStatusArray($array_status); 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)); $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 { $model_id = NULL; 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)) { $model_displayname = NULL; 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; case CORESTATUS_VALUE_MID_PRIME_R: case CORESTATUS_VALUE_MID_PRIME_L: $model_displayname = t('timelapse_info_modelname_prime'); break; case CORESTATUS_VALUE_MID_CALIBRATION: $this->load->helper('printlist'); $model_id = ModelList_codeModelHash(PRINTLIST_MODEL_CALIBRATION); // treat as a normal pre-sliced model // treat as a normal pre-sliced model default: // treat as pre-sliced model $model_data = array(); 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; } } // parse the main body $template_data = array('title' => t('Control your printing'), 'print_detail' => t('Printing details'), 'print_stop' => t('Cancel'), 'cancel_confirm' => t('cancel_confirm'), 'wait_info' => t('Waiting for starting...'), 'finish_info' => t('Congratulation, your printing is complete!'), 'return_button' => t('Home'), 'return_url' => '/', 'restart_url' => '/printdetail/printmodel?id=' . $id, 'var_prime' => 'false', 'var_slice' => 'false', 'var_calibration' => $print_calibration ? 'true' : 'false', 'again_button' => t('Print again'), 'video_url' => $this->config->item('video_url'), 'strip_led' => t('strip_led'), 'head_led' => t('head_led'), 'led_on' => t('led_on'), 'led_off' => t('led_off'), 'lighting' => t('lighting'), 'initial_strip' => $status_strip == TRUE ? $option_selected : NULL, 'initial_head' => $status_head == TRUE ? $option_selected : NULL, 'video_error' => t('video_error'), 'loading_player' => t('loading_player'), 'model_name_title' => t('timelapse_info_modelname_title'), 'model_name_value' => $model_displayname); if ($print_slice == TRUE) { $template_data['restart_url'] = '/printdetail/printslice'; $template_data['var_slice'] = 'true'; // $template_data['return_url'] = '/sliceupload/slice?callback'; } else { if ($print_calibration == TRUE) { // $template_data['restart_url'] = '/printdetail/printcalibration'; $template_data['restart_url'] = '/printmodel/detail?id=calibration'; $template_data['return_url'] = '/printerstate/offset_setting'; $template_data['return_button'] = t('button_set_offset'); } else { if ($abb_cartridge) { $template_data['finish_info'] = t('Restart?'); // $template_data['return_url'] = '/printmodel/detail?id=' . $callback; $template_data['restart_url'] = '/printdetail/printprime?r&v=' . $abb_cartridge . '&cb=' . $callback; $template_data['return_button'] = t('No'); $template_data['var_prime'] = 'true'; $template_data['again_button'] = t('Yes'); // change wording $template_data['title'] = t('title_prime'); $template_data['print_detail'] = t('print_detail_prime'); $template_data['cancel_confirm'] = t('cancel_confirm_prime'); // $template_data['finish_info'] = t('finish_info_prime'); $template_data['wait_info'] = t('wait_info_prime'); if ($callback) { if ($callback == 'slice') { $template_data['return_url'] = '/sliceupload/slice?callback'; } else { $template_data['return_url'] = '/printmodel/detail?id=' . $callback; } } } } } // parse all page $pagetitle = $abb_cartridge ? t('pagetitle_prime') : t('ZeePro Personal Printer 21 - Printing details'); $this->_parseBaseTemplate($pagetitle, $this->parser->parse('printdetail/status', $template_data, TRUE)); return; }
function Printer_checkCancelStatus() { $data_status = array(); $temper_status = array(); $CI =& get_instance(); $CI->load->helper(array('printerstate', 'corestatus')); // check status if we are not in canceling $data_status = PrinterState_checkStatusAsArray(FALSE); if ($data_status[PRINTERSTATE_TITLE_STATUS] != CORESTATUS_VALUE_CANCEL) { $CI->load->helper('printerlog'); PrinterLog_logMessage('not in canceling when checking cancel status', __FILE__, __LINE__); return FALSE; } return TRUE; }
function gcode_ajax() { $cr = 0; $display = NULL; $status_array = array(); $this->load->helper(array('printerstate', 'slicer')); $status_array = PrinterState_checkStatusAsArray(); if ($status_array[PRINTERSTATE_TITLE_STATUS] == CORESTATUS_VALUE_SLICED) { $gcode_path = $this->config->item('temp') . SLICER_FILE_MODEL; 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('slice.gcode', @file_get_contents($gcode_path)); $this->_sendFileContent($gcode_path, 'slice.gcode'); return; } else { $cr = ERROR_INTERNAL; } } else { $cr = ERROR_EMPTY_PLATFORM; } $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; }
function PrinterState_checkStatus() { $data_json = PrinterState_checkStatusAsArray(); return json_encode($data_json); }