예제 #1
0
파일: manage.php 프로젝트: Jaesin/zim-web
 public function index()
 {
     $template_data = array();
     $ret_val = 0;
     $this->load->library('parser');
     $this->lang->load('manage', $this->config->item('language'));
     $this->lang->load('printerstate/index', $this->config->item('language'));
     $this->load->helper(array('zimapi', 'printerstate'));
     if (!ZimAPI_cameraOn(ZIMAPI_PRM_CAMERA_PRINTSTART)) {
         $this->load->helper('printerlog');
         PrinterLog_logError('can not set camera', __FILE__, __LINE__);
     }
     $ret_val = PrinterState_getStripLedStatus($status_strip);
     if ($ret_val != ERROR_OK) {
         $status_strip = FALSE;
     }
     $ret_val = PrinterState_getTopLedStatus($status_head);
     if ($ret_val != ERROR_OK) {
         $status_head = FALSE;
     }
     //parse the main body
     $template_data = array('back' => t('back'), 'what' => t('what'), 'loading_player' => t('loading_player'), 'platform_view_title' => t('platform_view_title'), 'reset' => t('reset_title'), 'home_text' => t('home_text'), 'head' => t('head_title'), 'head_text' => t('head_text'), 'platform' => t('platform_title'), 'platform_text' => t('platform_text'), 'filament' => t('filament_title'), 'filament_text' => t('filament_text'), 'manage_left' => t('manage_left'), 'manage_right' => t('manage_right'), 'bed_title' => t('bed_title'), 'bed_text' => t('bed_text'), 'video_error' => t('video_error'), 'video_url' => $this->config->item('video_url'), 'reboot' => t('reboot'), 'shutdown' => t('shutdown'), 'lighting_title' => t('lighting_title'), 'strip_led' => t('strip_led'), 'head_led' => t('head_led'), 'led_on' => t('led_on'), 'led_off' => t('led_off'), 'left' => t('left'), 'right' => t('right'), 'strip_led_on' => $status_strip == TRUE ? "selected=selected" : NULL, 'head_led_on' => $status_head == TRUE ? "selected=selected" : NULL, 'bicolor' => $this->config->item('nb_extruder') >= 2 ? 'true' : 'false');
     // parse all page
     $this->_parseBaseTemplate(t('manage_index_pagetitle'), $this->parser->parse('manage/index', $template_data, TRUE), '<link rel="stylesheet" href="/assets/jquery-mobile-fluid960.min.css">');
     return;
 }
예제 #2
0
 private function get_led(&$status_strip, &$status_head)
 {
     $this->load->library(array('parser', 'session'));
     $status_strip = $this->session->flashdata('led_strip');
     if ($status_strip === FALSE) {
         $ret_val = PrinterState_getStripLedStatus($status_strip);
         if ($ret_val != ERROR_OK) {
             $status_strip = FALSE;
         }
     }
     $status_head = $this->session->flashdata('led_head');
     if ($status_head === FALSE) {
         $ret_val = PrinterState_getTopLedStatus($status_head);
         if ($ret_val != ERROR_OK) {
             $status_head = FALSE;
         }
     }
     return;
 }
예제 #3
0
파일: rest.php 프로젝트: Jaesin/zim-web
 public function get()
 {
     $parameter = NULL;
     $cr = 0;
     $display = NULL;
     $api_prm = NULL;
     $this->load->helper(array('printerstate', 'zimapi'));
     $parameter = $this->input->get('p');
     //return false if missing
     if ($parameter) {
         switch ($parameter) {
             case PRINTERSTATE_PRM_EXTRUDER:
                 $cr = PrinterState_getExtruder($display);
                 //$abb_extruder
                 break;
             case PRINTERSTATE_PRM_TEMPER:
                 // check which temperature we want
                 $has_e = $this->input->get('e');
                 $has_h = $this->input->get('h');
                 $has_v = $this->input->get('v');
                 if ($has_e === FALSE && $has_h === FALSE) {
                     $cr = ERROR_MISS_PRM;
                 } else {
                     if (!($has_e === FALSE) && !($has_h === FALSE)) {
                         $cr = ERROR_WRONG_PRM;
                     } else {
                         if (!($has_e === FALSE) && !($has_v === FALSE)) {
                             // refuse getting data not existed for mono extruder
                             if ($has_v == 'l' && $this->config->item('nb_extruder') == 1) {
                                 $cr = ERROR_WRONG_PRM;
                             } else {
                                 if (in_array($has_v, array('l', 'r'))) {
                                     // 							$tmp_array = PrinterState_getExtruderTemperaturesAsArray();
                                     // 							$cr = ERROR_OK;
                                     // 							$display = ($has_v == 'l')
                                     // 									? $tmp_array[PRINTERSTATE_LEFT_EXTRUD]
                                     // 									: $tmp_array[PRINTERSTATE_RIGHT_EXTRUD];
                                     $cr = PrinterState_getTemperature($display, 'e', $has_v);
                                 } else {
                                     $cr = ERROR_WRONG_PRM;
                                 }
                             }
                         } else {
                             $api_prm = $has_e === FALSE ? 'h' : 'e';
                             $cr = PrinterState_getTemperature($display, $api_prm);
                         }
                     }
                 }
                 break;
             case PRINTERSTATE_PRM_CARTRIDGE:
                 $api_prm = $this->input->get('v');
                 // refuse getting data not existed for mono extruder
                 if ($api_prm == 'l' && $this->config->item('nb_extruder') == 1) {
                     $cr = ERROR_WRONG_PRM;
                 } else {
                     $cr = PrinterState_getCartridge($display, $api_prm);
                 }
                 break;
             case PRINTERSTATE_PRM_INFO:
                 //TODO need add SSO account
                 $cr = ERROR_OK;
                 $display = PrinterState_getInfo();
                 break;
             case 'render':
                 $this->_return_under_construction();
                 return;
                 break;
             case PRINTERSTATE_PRM_ACCELERATION:
                 $cr = PrinterState_getAcceleration($display);
                 break;
             case PRINTERSTATE_PRM_SPEED_MOVE:
             case PRINTERSTATE_PRM_SPEED_EXTRUDE:
                 $cr = PrinterState_getSpeed($display);
                 break;
             case PRINTERSTATE_PRM_COLDEXTRUSION:
                 $value = NULL;
                 $cr = PrinterState_getColdExtrusion($value);
                 if ($cr == ERROR_OK) {
                     if ($value == TRUE) {
                         $display = 'on';
                     } else {
                         $display = 'off';
                     }
                 }
                 break;
             case PRINTERSTATE_PRM_FILAMENT:
                 $value = NULL;
                 $api_prm = $this->input->get('v');
                 // refuse getting data not existed for mono extruder
                 if ($api_prm == 'l' && $this->config->item('nb_extruder') == 1) {
                     $cr = ERROR_WRONG_PRM;
                 } else {
                     if ($api_prm) {
                         $cr = ERROR_OK;
                         $value = PrinterState_getFilamentStatus($api_prm);
                         if ($value == TRUE) {
                             $display = 'true';
                         } else {
                             $display = 'false';
                         }
                     } else {
                         $cr = ERROR_MISS_PRM;
                     }
                 }
                 break;
             case PRINTERSTATE_PRM_ENDSTOP:
                 $status = NULL;
                 $abb_endstop = $this->input->get('axis');
                 $cr = PrinterState_getEndstop($abb_endstop, $status);
                 if ($cr == ERROR_OK) {
                     $display = $status ? 'on' : 'off';
                 }
                 break;
             case PRINTERSTATE_PRM_STRIPLED:
                 $value = NULL;
                 $cr = PrinterState_getStripLedStatus($value);
                 if ($cr == ERROR_OK) {
                     if ($value == TRUE) {
                         $display = 'on';
                     } else {
                         $display = 'off';
                     }
                 }
                 break;
             case PRINTERSTATE_PRM_HEADLED:
                 $value = NULL;
                 $cr = PrinterState_getTopLedStatus($value);
                 if ($cr == ERROR_OK) {
                     if ($value == TRUE) {
                         $display = 'on';
                     } else {
                         $display = 'off';
                     }
                 }
                 break;
             case PRINTERSTATE_PRM_OFFSET:
                 $value = NULL;
                 $axis = $this->input->get('axis');
                 if ($axis) {
                     $cr = PrinterState_getOffset($axis, $value);
                     if ($cr == ERROR_OK) {
                         $display = $value;
                     }
                 } else {
                     $cr = ERROR_MISS_PRM;
                 }
                 break;
             case PRINTERSTATE_PRM_POSITION:
                 $cr = PrinterState_getPosition($display);
                 break;
             case ZIMAPI_PRM_CAPTURE:
                 $path_capture = '';
                 $password = $this->input->get('password');
                 if (!ZimAPI_checkCameraPassword($password)) {
                     $cr = ERROR_WRONG_PWD;
                     break;
                 }
                 $this->load->helper('file');
                 if (ZimAPI_cameraCapture($path_capture)) {
                     $this->output->set_content_type(get_mime_by_extension($path_capture))->set_output(@file_get_contents($path_capture));
                     return;
                 } else {
                     $cr = ERROR_INTERNAL;
                 }
                 break;
             case ZIMAPI_PRM_VIDEO_MODE:
                 if (ZimAPI_checkCamera($display)) {
                     $cr = ERROR_OK;
                 } else {
                     $cr = ERROR_INTERNAL;
                 }
                 break;
             case ZIMAPI_PRM_PRESET:
                 if (ZimAPI_getPreset($display)) {
                     $cr = ERROR_OK;
                 } else {
                     $cr = ERROR_INTERNAL;
                 }
                 break;
             case ZIMAPI_PRM_UPGRADE:
                 if (ZimAPI_getUpgradeMode($display)) {
                     $cr = ERROR_OK;
                 } else {
                     $cr = ERROR_INTERNAL;
                 }
                 if ($display != 'off') {
                     $display = 'on';
                 }
                 break;
             case ZIMAPI_PRM_PROXY:
                 if (ZimAPI_getTromboning()) {
                     $display = 'on';
                 } else {
                     $display = 'off';
                 }
                 $cr = ERROR_OK;
                 break;
             case ZIMAPI_PRM_SSH:
                 $status_current = NULL;
                 if (ZimAPI_getSSH($status_current)) {
                     $cr = ERROR_OK;
                     if ($status_current) {
                         $display = 'on';
                     } else {
                         $display = 'off';
                     }
                 } else {
                     $cr = ERROR_INTERNAL;
                 }
                 break;
             case ZIMAPI_PRM_STATS:
                 if (ZimAPI_getStatistic()) {
                     $display = 'on';
                 } else {
                     $display = 'off';
                 }
                 $cr = ERROR_OK;
                 break;
             default:
                 $cr = ERROR_WRONG_PRM;
                 break;
         }
     } else {
         $cr = ERROR_MISS_PRM;
     }
     if ($cr != ERROR_OK) {
         $display = $cr . " " . t(MyERRMSG($cr));
     }
     $this->output->set_status_header($cr, $display);
     // 		http_response_code($cr);
     $this->output->set_content_type(RETURN_CONTENT_TYPE);
     // 		echo $display;
     $this->load->library('parser');
     $this->parser->parse('plaintxt', array('display' => $display));
     return;
 }