Пример #1
0
function CoreStatus_setInIdle($last_error = FALSE, $error_message = FALSE)
{
    $status_previous = '';
    $array_previous = array();
    $array_status = array(CORESTATUS_TITLE_STARTTIME => NULL);
    $ret_val = CoreStatus_checkInIdle($status_previous, $array_previous);
    if ($ret_val == TRUE) {
        return TRUE;
        // we are already in idle
    } else {
        if ($status_previous == CORESTATUS_VALUE_PRINT || $status_previous == CORESTATUS_VALUE_CANCEL) {
            // 		// stop camera http live streaming
            // 		$ret_val = 0;
            // 		$CI = &get_instance();
            // 		$CI->load->helper('zimapi');
            // 		$ret_val = ZimAPI_cameraOff();
            // 		if ($ret_val != TRUE) {
            // 			return FALSE;
            // 		}
            // calculate elapsed time
            $time_pass = 0;
            $CI =& get_instance();
            $CI->load->helper('printerstate');
            //TODO think if it's necessary to pass this filepath out of this heavy helper (printerstate)
            $time_pass = file_exists(PRINTERSTATE_FILE_PRINTLOG) && array_key_exists(CORESTATUS_TITLE_STARTTIME, $array_previous) ? filemtime(PRINTERSTATE_FILE_PRINTLOG) - $array_previous[CORESTATUS_TITLE_STARTTIME] : time() - $array_previous[CORESTATUS_TITLE_STARTTIME];
            $array_status[CORESTATUS_TITLE_ELAPSED_TIME] = $time_pass;
            CoreStatus_setInPause(FALSE);
            // not necessary in any case, just a safty
            // comment initialization of model id to save model info
            // 		$array_status[CORESTATUS_TITLE_PRINTMODEL] = NULL;
        }
    }
    // 	else if ($status_previous == CORESTATUS_VALUE_UNLOAD_FILA_L
    // 			|| $status_previous == CORESTATUS_VALUE_UNLOAD_FILA_R) {
    // 		$CI = &get_instance();
    // 		$CI->load->helper('printerstate');
    // 		$ret_val = PrinterState_afterUnloadFilament();
    // 		if ($ret_val != ERROR_OK) {
    // 			return FALSE;
    // 		}
    // 	}
    if ($last_error !== FALSE) {
        // add last_error for slicing
        //TODO perhaps also check $status_previous == CORESTATUS_VALUE_SLICE ?
        $array_status[CORESTATUS_TITLE_LASTERROR] = $last_error;
        $array_status[CORESTATUS_TITLE_MESSAGE] = $error_message ? $error_message : NULL;
    }
    return CoreStatus__setInStatus(CORESTATUS_VALUE_IDLE, $array_status);
}
Пример #2
0
function Printer_resumePrint()
{
    $CI =& get_instance();
    $CI->load->helper(array('corestatus', 'printerstate'));
    $cr = CoreStatus_checkInIdle($status_current);
    if ($cr == FALSE && $status_current == CORESTATUS_VALUE_PRINT) {
        if (CoreStatus_checkInPause()) {
            $cr = PrinterState_resumePrinting();
            if ($cr == ERROR_OK) {
                CoreStatus_setInPause(FALSE);
                return TRUE;
            } else {
                $CI->load->helper('printerlog');
                PrinterLog_logError('resume printing error', __FILE__, __LINE__);
            }
        } else {
            $CI->load->helper('printerlog');
            PrinterLog_logError('call resume when not in pausing', __FILE__, __LINE__);
            return TRUE;
        }
    } else {
        $CI->load->helper('printerlog');
        PrinterLog_logError('call resume when not in printing: ' . $status_current, __FILE__, __LINE__);
    }
    return FALSE;
}