function PrinterStoring_initialFile() { $ret_val = TRUE; $CI =& get_instance(); $array_check = array($CI->config->item('base_library'), $CI->config->item('stl_library'), $CI->config->item('gcode_library')); foreach ($array_check as $folder_check) { if (file_exists($folder_check)) { if (is_dir($folder_check)) { continue; } else { $ret_val = FALSE; $CI->load->helper('printerlog'); PrinterLog_logMessage('illegal file detected, try to unlink: ' . $folder_check, __FILE__, __LINE__); @unlink($folder_check); usleep(3); // make sure that file is deleted } } $ret_val = mkdir($folder_check); if ($ret_val == FALSE) { $CI->load->helper('printerlog'); PrinterLog_logError('library initialization create error: ' . $folder_check, __FILE__, __LINE__); break; } } return $ret_val; }
private function _get_type_array(&$array_type) { $cr = FALSE; $array_tmp = array(); $array_data = array(); $filename = $this->config->item('conf') . SETUPCARTRIDGE_JSON_FILENAME; $array_type = array(); if (file_exists($filename)) { $array_tmp = json_read($filename, TRUE); if (isset($array_tmp['error'])) { $this->load->helper('printerlog'); PrinterLog_logError('read json error', __FILE__, __LINE__); } else { $array_data = $array_tmp['json']; foreach ($array_data as $ele_type) { if (is_array($ele_type) && array_key_exists('name', $ele_type) && array_key_exists('code', $ele_type)) { $array_type[] = $ele_type; } else { $this->load->helper('printerlog'); PrinterLog_logError('json structure error', __FILE__, __LINE__); return $cr; } } if (count($array_type) == 0) { $this->load->helper('printerlog'); PrinterLog_logMessage('json file is empty', __FILE__, __LINE__); } else { $cr = TRUE; } } } else { $this->load->helper('printerlog'); PrinterLog_logMessage('json file not found', __FILE__, __LINE__); } return $cr; }
public function changecartridge_action($mode = '') { $abb_cartridge = $this->input->get('v'); if (!$abb_cartridge && !in_array($abb_cartridge, array('l', 'r'))) { $this->output->set_status_header(403); // invalid request return; } if ($mode == 'unload_r') { $mode = 'unload'; } else { if ($mode == 'load_r') { $mode = 'load'; } else { if ($mode != 'cancel_unload') { //block request when not in idle $this->load->helper('corestatus'); if (CoreStatus_checkInIdle() == FALSE) { $this->output->set_status_header(403); // bad request return; } } } } switch ($mode) { case 'unload': $ret_val = PrinterState_unloadFilament($abb_cartridge); if ($ret_val != ERROR_OK) { $this->output->set_status_header($ret_val, MyERRMSG($ret_val)); } break; case 'cancel_unload': $ret_val = 0; @unlink(PRINTERSTATE_FILE_UNLOAD_HEAT); $ret_val = CoreStatus_setInIdle(); if ($ret_val == FALSE) { $this->load->helper('printerlog'); PrinterLog_logError('can not set idle after cancelling unloading', __FILE__, __LINE__); $this->output->set_status_header(ERROR_INTERNAL); } break; case 'load': $ret_val = PrinterState_loadFilament($abb_cartridge); if ($ret_val != ERROR_OK) { $this->output->set_status_header($ret_val); } break; case 'detail': $id_model = $this->input->get('id'); $this->_display_changecartridge_cartridge_detail($abb_cartridge, $id_model); break; case 'write': $ret_val = 0; $array_data = array(); $array_old = array(); $color = $this->input->get('c'); $temper = (int) $this->input->get('t'); $material = (int) $this->input->get('m'); $length = (int) $this->input->get('l') * 1000; $abb_cartridge = $this->input->get('v'); // get cartridge type from old RFID $ret_val = PrinterState_getCartridgeAsArray($array_old, $abb_cartridge, FALSE); if ($ret_val != ERROR_OK) { $this->output->set_status_header(403); $this->load->helper('printerlog'); PrinterLog_logMessage('read rfid error: ' . $ret_val, __FILE__, __LINE__); break; } // change color from name to hex code $this->load->helper('printlist'); $ret_val = ModelList__changeColorName($color); if ($ret_val == ERROR_WRONG_PRM) { $this->output->set_status_header(404); $this->load->helper('printerlog'); PrinterLog_logMessage('unknown color name: ' . $color, __FILE__, __LINE__); break; } $color = str_replace('#', '', $color); // write RFID card $array_data = array(PRINTERSTATE_TITLE_COLOR => $color, PRINTERSTATE_TITLE_EXT_TEMPER => $temper, PRINTERSTATE_TITLE_INITIAL => $length, PRINTERSTATE_TITLE_MATERIAL => $material, PRINTERSTATE_TITLE_CARTRIDGE => $array_old[PRINTERSTATE_TITLE_CARTRIDGE]); $ret_val = PrinterState_setCartridgeAsArray($abb_cartridge, $array_data); if ($ret_val != ERROR_OK) { $this->output->set_status_header(403); $this->load->helper('printerlog'); PrinterLog_logMessage('write rfid error: ' . $ret_val, __FILE__, __LINE__); break; } break; default: $this->output->set_status_header(403); // unknown request break; } return; }
function ZimAPI_setPresetSetting($id_preset, $array_input, &$error_parameter, $name_preset = NULL, $overwrite = FALSE) { // $name_preset is NULL when creating preset from an old id $ret_val = 0; $array_setting = array(); $preset_path = NULL; $system_preset = FALSE; // $rewrite_json = FALSE; $CI =& get_instance(); if (!is_array($array_input)) { return ERROR_INTERNAL; } // check if we have same name, and define preset path if ($name_preset != NULL) { $old_path = NULL; $ret_val = ZimAPI_checkPreset(ZimAPI_codePresetHash($name_preset), $old_path, $system_preset); if ($ret_val == TRUE) { $CI->load->helper('printerlog'); if ($system_preset == TRUE) { PrinterLog_logMessage('system can not modify default preset'); return ERROR_WRONG_PRM; } else { if ($overwrite == FALSE) { PrinterLog_logMessage('system has already the same preset name: ' . $name_preset); return ERROR_FULL_PRTLST; // just use another error code } else { PrinterLog_logMessage('system detects a same preset name, and will overwrite it: ' . $name_preset); } } } $preset_path = $CI->config->item('presetlist') . ZimAPI_codePresetHash($name_preset) . '/'; } else { $ret_val = ZimAPI_checkPreset($id_preset, $preset_path, $system_preset); if ($ret_val == FALSE) { $CI->load->helper('printerlog'); PrinterLog_logError('system can not find preset: ' . $id_preset); return ERROR_WRONG_PRM; // just use another error code } if ($system_preset == TRUE) { $CI->load->helper('printerlog'); PrinterLog_logMessage('system can not modify default preset'); return ERROR_WRONG_PRM; } $preset_path .= '/' . $id_preset . '/'; } $ret_val = ZimAPI_checkPresetSetting($array_input, $error_parameter); if ($ret_val != TRUE) { $CI->load->helper('printerlog'); PrinterLog_logError('user input preset setting has wrong parameter'); return ERROR_WRONG_PRM; } $ret_val = ZimAPI_getPresetSettingAsArray($id_preset, $array_setting); if ($ret_val != ERROR_OK) { return $ret_val; } if (!ZimAPI_fixPresetSetting($array_setting)) { return ERROR_INTERNAL; } // check if 4 parameters are changed in same preset name saving (preset json is forced generated in different preset name saving) if ($name_preset == NULL) { foreach (array(ZIMAPI_TITLE_PRESET_INFILL, ZIMAPI_TITLE_PRESET_SKIRT, ZIMAPI_TITLE_PRESET_RAFT, ZIMAPI_TITLE_PRESET_SUPPORT) as $key) { if ($array_setting[$key] != $array_input[$key]) { $json_data = array(); if (ERROR_OK == ZimAPI_getPresetInfoAsArray($id_preset, $json_data)) { $name_preset = $json_data[ZIMAPI_TITLE_PRESET_NAME]; // assign preset name as the case in same name overwrite case } else { $CI->load->helper('printerlog'); PrinterLog_logError('read preset info error in reassignment of 4 parameters', __FILE__, __LINE__); return ERROR_INTERNAL; } // $rewrite_json = TRUE; } } } // assign new setting foreach ($array_input as $key => $value) { $array_setting[$key] = $value; } // save preset if (!file_exists($preset_path)) { mkdir($preset_path); } if ($name_preset != NULL) { // || $rewrite_json == TRUE $json_data = array(ZIMAPI_TITLE_PRESET_ID => ZimAPI_codePresetHash($name_preset), ZIMAPI_TITLE_PRESET_NAME => $name_preset, ZIMAPI_TITLE_PRESET_INFILL => $array_setting[ZIMAPI_TITLE_PRESET_INFILL], ZIMAPI_TITLE_PRESET_SKIRT => (int) $array_setting[ZIMAPI_TITLE_PRESET_SKIRT], ZIMAPI_TITLE_PRESET_RAFT => (int) $array_setting[ZIMAPI_TITLE_PRESET_RAFT], ZIMAPI_TITLE_PRESET_SUPPORT => (int) $array_setting[ZIMAPI_TITLE_PRESET_SUPPORT]); $CI->load->helper('json'); //write model json info try { $fp = fopen($preset_path . ZIMAPI_FILE_PRESET_JSON, 'w'); if ($fp) { fwrite($fp, json_encode_unicode($json_data)); fclose($fp); } else { return ERROR_INTERNAL; } } catch (Exception $e) { return ERROR_INTERNAL; } } //write config ini file try { $fp = fopen($preset_path . ZIMAPI_FILE_PRESET_INI, 'w'); if ($fp) { foreach ($array_setting as $key => $value) { fwrite($fp, $key . " = " . $value . "\r\n"); } fclose($fp); } else { return ERROR_INTERNAL; } } catch (Exception $e) { return ERROR_INTERNAL; } return ERROR_OK; }
function __construct() { parent::__construct(); $this->load->helper(array('form', 'url', 'json', 'errorcode', 'corestatus')); $status_current = ''; if (CoreStatus_checkInInitialization() || CoreStatus_checkInConnection() || CoreStatus_checkInUSB()) { // let no block REST web service go for setting network if (CoreStatus_checkCallNoBlockRESTInConnection()) { return; } // we haven't finished initialization or connection yet $this->_exitWithError500(ERROR_BUSY_PRINTER . ' ' . t(MyERRMSG(ERROR_BUSY_PRINTER)), ERROR_BUSY_PRINTER); } else { if (!CoreStatus_checkInIdle($status_current)) { // check if the status is changed $ret_val = 0; $this->load->helper('printerstate'); switch ($status_current) { case CORESTATUS_VALUE_SLICE: if (CoreStatus_checkCallNoBlockRESTInSlice()) { // do not block some special REST for action in slicing return; } $ret_val = PrinterState_checkBusyStatus($status_current); if ($ret_val == FALSE) { // still in slicing break; } else { if ($status_current == CORESTATUS_VALUE_IDLE) { // encounted some errors break; } else { // CORESTATUS_VALUE_PRINT $this->load->helper('printerlog'); PrinterLog_logMessage('call rest when we are in slicing, but finished really', __FILE__, __LINE__); } } // we treat canceling as printing // we treat canceling as printing case CORESTATUS_VALUE_PRINT: // do not block some special REST for action in printing if (CoreStatus_checkCallNoBlockRESTInPrint()) { return; } case CORESTATUS_VALUE_CANCEL: //TODO test here for canceling $ret_val = PrinterState_checkInPrint(); if ($ret_val == FALSE) { $ret_val = CoreStatus_setInIdle(); if ($ret_val == TRUE) { $this->load->helper('printerlog'); PrinterLog_logDebug('set idle when calling REST', __FILE__, __LINE__); return; // continue to generate if we are now in idle } $this->load->helper('printerlog'); PrinterLog_logError('can not set status in idle', __FILE__, __LINE__); } break; default: $ret_val = PrinterState_checkBusyStatus($status_current); if ($ret_val == TRUE) { $this->load->helper('printerlog'); PrinterLog_logDebug('set idle when calling REST', __FILE__, __LINE__); return; // status has changed to idle } break; } // do not block some special REST if (CoreStatus_checkCallNoBlockREST()) { return; } // return that printer is busy $this->_exitWithError500(ERROR_BUSY_PRINTER . ' ' . t(MyERRMSG(ERROR_BUSY_PRINTER)), ERROR_BUSY_PRINTER); } } }
public function __construct() { global $CFG; parent::__construct(); // $this->load->helper(array('corestatus', 'url')); $this->load->helper(array('corestatus', 'printerlog')); // set proper error handler set_error_handler(array($this, 'errorToSSO')); // add header to disable cache (IE need these headers) $this->output->set_header('Pragma: no-cache'); $this->output->set_header('Cache-Control: no-cache'); // initialisation status files if (!CoreStatus_initialFile()) { $this->load->helper('printerlog'); PrinterLog_logError('status files initialisation error when MY_Controller started', __FILE__, __LINE__); // let request failed $this->_exitWithError500('file initialisation error'); } // check tromboning autorisation if (CoreStatus_checkTromboning(FALSE)) { $this->load->helper(array('printerlog', 'errorcode')); PrinterLog_logMessage('detected and refused tromboning connection', __FILE__, __LINE__); // let request failed $this->_exitWithError500(ERROR_REMOTE_REFUSE . ' ' . MyERRMSG(ERROR_REMOTE_REFUSE), ERROR_REMOTE_REFUSE); } // Workflow management if (CoreStatus_checkCallREST()) { // we place the control for REST web service in his own class // because there are the special error codes for REST web service // and we do not need them in normal condition return; } else { $status_current = ''; $url_redirect = ''; $array_status = array(); // stats info (do not stats rest, app can initialize cookies in each request) $this->load->library('session'); if (FALSE === $this->input->cookie('stats_browserLog')) { $this->input->set_cookie('stats_browserLog', 'ok', 2592000); // 30 days for browser stats PrinterLog_statsWebAgent(); } // check initialization issue if (CoreStatus_checkInInitialization()) { if (CoreStatus_checkCallInitialization($url_redirect)) { return; // we are calling the right page } } else { if (CoreStatus_checkCallInitialization()) { $url_redirect = '/'; } else { if (CoreStatus_checkInUSB()) { if (CoreStatus_checkCallUSB($url_redirect)) { return; // we are calling the right page } } else { if (CoreStatus_checkCallUSB()) { $url_redirect = '/'; } else { if (CoreStatus_checkCallDebug()) { // we always let these interfaces go for debug return; } else { if (CoreStatus_checkInConnection()) { if (CoreStatus_checkCallNoBlockPageInConnection()) { return; // we are calling set hostname, activation or account page } if (CoreStatus_checkCallConnection($url_redirect)) { return; // we are calling the right page } } else { if (CoreStatus_checkCallConnection()) { $url_redirect = '/'; } else { if (!CoreStatus_checkInIdle($status_current, $array_status)) { switch ($status_current) { case CORESTATUS_VALUE_RECOVERY: //TODO finish and test me if (CoreStatus_checkCallRecovery($url_redirect)) { return; // we are calling the right page } break; case CORESTATUS_VALUE_PRINT: if (CoreStatus_checkCallPrinting($array_status, $url_redirect)) { return; // we are calling the right page } break; case CORESTATUS_VALUE_CANCEL: if (CoreStatus_checkCallCanceling($url_redirect)) { return; // we are calling the right page } break; case CORESTATUS_VALUE_LOAD_FILA_L: case CORESTATUS_VALUE_LOAD_FILA_R: if (CoreStatus_checkCallloading($url_redirect)) { return; // we are calling the right page } // return; // we do not block users when charging filament break; case CORESTATUS_VALUE_UNLOAD_FILA_L: case CORESTATUS_VALUE_UNLOAD_FILA_R: //FIXME finish here to block users if (CoreStatus_checkCallUnloading($url_redirect)) { return; // we are calling the right page } break; case CORESTATUS_VALUE_SLICE: if (CoreStatus_checkCallSlicing($url_redirect)) { return; } break; default: $url_redirect = '/'; // internal error, never reach here normally break; } } else { if (CoreStatus_checkCallPrintingAjax() || CoreStatus_checkCallCancelingAjax()) { // let ajax request failed when we finishing printing / canceling $protocol = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0'; header($protocol . ' 403'); header('Content-type: text/plain; charset=UTF-8'); echo 'Not in printing / canceling'; exit; } else { if (CoreStatus_checkCallPrinting() || CoreStatus_checkCallCanceling()) { $url_redirect = '/'; } else { if (CoreStatus_checkInPrinted()) { if (CoreStatus_checkCallEndPrinting($url_redirect) || CoreStatus_checkCallEndPrintingPlus()) { return; } } else { if (CoreStatus_checkCallEndPrinting()) { $url_redirect = '/'; // redirect to homepage when we have no timelapse } } } } if ($url_redirect) { header('Location: ' . $url_redirect); exit; } return; // continue to generate the current page } } } } } } } } // log error if we have no redirect url when reaching here if (is_null($url_redirect)) { $this->load->helper('printerlog'); PrinterLog_logError('no redirect place when MY_Controller finished', __FILE__, __LINE__); } header('Location: ' . $url_redirect); exit; } }
public function readnwrite_ajax() { $ret_val = 0; $array_data = array(); $array_old = array(); $color = $this->input->get('c'); $temper = (int) $this->input->get('t'); $temper_f = (int) $this->input->get('tf'); $material = (int) $this->input->get('m'); $length = (int) $this->input->get('l') * 1000; $length_use = (int) $this->input->get('lu') * 1000; $abb_cartridge = $this->input->get('v'); $type = (int) $this->input->get('ct'); // change color from name to hex code $this->load->helper('printlist'); $ret_val = ModelList__changeColorName($color); if ($ret_val == ERROR_WRONG_PRM) { $this->output->set_status_header(404); $this->load->helper('printerlog'); PrinterLog_logMessage('unknown color name: ' . $color, __FILE__, __LINE__); return; } $color = str_replace('#', '', $color); // write RFID card $array_data = array(PRINTERSTATE_TITLE_COLOR => $color, PRINTERSTATE_TITLE_EXT_TEMPER => $temper, PRINTERSTATE_TITLE_EXT_TEMP_1 => $temper_f, PRINTERSTATE_TITLE_INITIAL => $length, PRINTERSTATE_TITLE_USED => $length_use, PRINTERSTATE_TITLE_MATERIAL => $material, PRINTERSTATE_TITLE_CARTRIDGE => $type); $ret_val = PrinterState_setCartridgeAsArray($abb_cartridge, $array_data); if ($ret_val != ERROR_OK) { $this->output->set_status_header(403); $this->load->helper('printerlog'); PrinterLog_logMessage('write rfid error: ' . $ret_val, __FILE__, __LINE__); } return; }
function PrinterState_getCartridgeTemper(&$temper_cartridge, $abb_cartridge, $power_off = TRUE) { $last_output = NULL; $ret_val = 0; $ret_val = PrinterState_getCartridgeCode($last_output, $abb_cartridge, $power_off); if ($ret_val != ERROR_OK) { return $ret_val; } // check and treat output data if ($last_output) { $version_rfid = 0; $string_tmp = NULL; $hex_checksum = 0; $hex_cal = 0; $hex_tmp = 0; $offset_temp = 0; $length_temp = 0; $data_json = array(); // checksum 0 to 14 for ($i = 0; $i <= 14; $i++) { $string_tmp = substr($last_output, $i * 2, 2); $hex_tmp = hexdec($string_tmp); $hex_cal = $hex_cal ^ $hex_tmp; } $hex_checksum = hexdec(substr($last_output, 30, 2)); if ($hex_cal != $hex_checksum) { PrinterLog_logError('checksum error, $hex_cal: ' . $hex_cal . ', $hex_data: ' . $hex_checksum, __FILE__, __LINE__); return ERROR_INTERNAL; // checksum failed } // magic number $string_tmp = substr($last_output, 0, 4); switch (hexdec($string_tmp)) { case PRINTERSTATE_MAGIC_NUMBER_V1: $version_rfid = 1; break; case PRINTERSTATE_MAGIC_NUMBER_V2: $version_rfid = 2; break; case PRINTERSTATE_MAGIC_NUMBER_V3: $version_rfid = 3; break; case PRINTERSTATE_MAGIC_NUMBER_V4: $version_rfid = 4; break; default: PrinterLog_logError('magic number error', __FILE__, __LINE__); return ERROR_INTERNAL; break; } if ($version_rfid == 1) { $offset_temp = 22; $length_temp = 2; } else { if ($version_rfid == 2) { //$version_rfid == 2 $offset_temp = 24; $length_temp = 2; } else { if ($version_rfid == 3) { //$version_rfid == 3 $offset_temp = 24; $length_temp = 1; } else { //$version_rfid == 4 $offset_temp = 22; $length_temp = 2; } } } // normal extrusion temperature $string_tmp = substr($last_output, $offset_temp, $length_temp); if ($version_rfid == 3) { $temper_cartridge = hexdec($string_tmp) + PRINTERSTATE_OFFSET_TEMPER_V2; } else { $temper_cartridge = hexdec($string_tmp) + PRINTERSTATE_OFFSET_TEMPER; } } else { PrinterLog_logMessage('missing cartridge', __FILE__, __LINE__); $temp_cartridge = NULL; if ($abb_cartridge == 'l') { return ERROR_MISS_LEFT_CART; } else { return ERROR_MISS_RIGT_CART; } } return ERROR_OK; }
function Slicer__changeURLPort() { $CI =& get_instance(); $slicer_url = $CI->config->item('slicer_url'); $port_filepath = $CI->config->item('temp') . SLICER_FILE_HTTP_PORT; if (FALSE === strpos($slicer_url, '8080/')) { return; } if (file_exists($port_filepath)) { $port_slicer = @file_get_contents($port_filepath); if (strlen($port_slicer)) { $slicer_url = str_replace('8080/', '', $slicer_url); $slicer_url .= $port_slicer . '/'; } $CI->config->set_item('slicer_url', $slicer_url); // $CI->load->helper('printerlog'); // PrinterLog_logDebug('found slic3r port file, url: ' . $slicer_url, __FILE__, __LINE__); } else { $CI->load->helper('printerlog'); PrinterLog_logMessage('can not find port file of slic3r, try to use original one, 8080', __FILE__, __LINE__); } return; }
function CoreStatus_setInPause($value = TRUE) { $CI =& get_instance(); $status_file = $CI->config->item('temp') . CORESTATUS_FILENAME_PAUSE; if ($value == TRUE) { try { $fp = fopen($status_file, 'w'); if ($fp) { fwrite($fp, 'pause'); fclose($fp); } else { $CI->load->helper('printerlog'); PrinterLog_logError('open pause status file error', __FILE__, __LINE__); return FALSE; } } catch (Exception $e) { $CI->load->helper('printerlog'); PrinterLog_logError('write pause status file error', __FILE__, __LINE__); return FALSE; } } else { if (file_exists($status_file)) { @unlink($status_file); } else { $CI->load->helper('printerlog'); PrinterLog_logMessage('call get out pause when not in pause', __FILE__, __LINE__); } } return TRUE; }
public function recovery_ajax() { //TODO finish me for recovery $template_data = array(); $ret_val = 0; $status_current = NULL; $data_status = array(); $this->load->helper('corestatus'); $this->load->library('parser'); $this->lang->load('printdetail', $this->config->item('language')); $template_data = array('wait_info' => t('wait_hint_recovery')); $ret_val = CoreStatus_checkInIdle($status_current, $data_status); if ($ret_val == TRUE) { // log recovery finish $this->load->helper('printerlog'); PrinterLog_logMessage('recovery status finish', __FILE__, __LINE__); $this->output->set_status_header(202); return; } else { if ($status_current == CORESTATUS_VALUE_RECOVERY) { if ($data_status[CORESTATUS_TITLE_SUBSTATUS] == CORESTATUS_VALUE_PRINT) { $template_data['wait_info'] = t('wait_hint_recovery_printing'); } else { $template_data['wait_info'] = t('wait_hint_recovery_unknown'); $this->load->helper('printerlog'); PrinterLog_logError('unknown substatus value in recovery ' . $data_status[CORESTATUS_TITLE_SUBSTATUS], __FILE__, __LINE__); } } else { $this->output->set_status_header(403); $this->load->helper('printerlog'); PrinterLog_logError('call recovery status check when not in recovery', __FILE__, __LINE__); return; } } // parse the ajax part $this->parser->parse('printdetail/cancel_ajax', $template_data); // we can use the same view for recovery $this->output->set_content_type('text/plain; charset=UTF-8'); 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 PrinterState_resumePrinting() { global $CFG; $arcontrol_fullpath = $CFG->config['arcontrol_c']; $output = array(); $command = ''; $ret_val = 0; // check if we are in printing $ret_val = PrinterState_checkInPrint(); if ($ret_val == TRUE) { // send stop gcode $command = $arcontrol_fullpath . PRINTERSTATE_RESUME_PRINT; exec($command, $output, $ret_val); if (!PrinterState_filterOutput($output, $command)) { PrinterLog_logError('filter arduino output error', __FILE__, __LINE__); return ERROR_INTERNAL; } PrinterLog_logArduino($command, $output); if ($ret_val != ERROR_NORMAL_RC_OK) { return ERROR_INTERNAL; } } else { PrinterLog_logMessage('we are not in printing when calling resume printing', __FILE__, __LINE__); return ERROR_NO_PRINT; } return ERROR_OK; }