function ZimAPI_cameraOff() { $CI =& get_instance(); $output = NULL; $ret_val = 0; $command = $CI->config->item('camera') . ZIMAPI_PRM_CAMERA_STOP; $data_json = array(); $fp = 0; $mode_current = ''; if (!ZimAPI_checkCamera($mode_current)) { return FALSE; } else { if ($mode_current == ZIMAPI_VALUE_MODE_OFF) { return TRUE; } else { if (ZimAPI_checkCameraInBlock()) { return TRUE; } } } exec($command, $output, $ret_val); if ($ret_val != ERROR_NORMAL_RC_OK) { $CI =& get_instance(); $CI->load->helper('printerlog'); PrinterLog_logError('camera stop command error', __FILE__, __LINE__); return FALSE; } $data_json = array(ZIMAPI_TITLE_MODE => ZIMAPI_VALUE_MODE_OFF, ZIMAPI_TITLE_COMMAND => NULL); // write json file $fp = fopen($CI->config->item('temp') . ZIMAPI_FILENAME_CAMERA, 'w'); if ($fp) { fwrite($fp, json_encode($data_json)); fclose($fp); } else { $CI =& get_instance(); $CI->load->helper('printerlog'); PrinterLog_logError('write camera status error', __FILE__, __LINE__); return FALSE; } return TRUE; }
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; }