Пример #1
0
function Slicer_checkPlatformColor(&$array_cartridge = array(), &$custom_change = FALSE)
{
    $cr = 0;
    $multi_part = FALSE;
    $array_platform = array();
    $array_color = array();
    Slicer_listModel($array_model);
    $array_platform = json_decode($array_model, TRUE);
    $custom_change = FALSE;
    if (is_null($array_platform)) {
        $cr = ERROR_EMPTY_PLATFORM;
    } else {
        $CI =& get_instance();
        $CI->load->helper('printerstate');
        $cr = ERROR_OK;
        // get the extruder which we need
        foreach ($array_platform as $model) {
            $colors = $model[SLICER_TITLE_COLOR];
            foreach ($colors as $color) {
                $array_color[] = (int) $color + SLICER_OFFSET_VALUE_COLOR2EXTRUDER;
            }
        }
        // check if it's multipart model
        if (count($array_color) > 1) {
            $multi_part = TRUE;
        }
        $array_color = array_unique($array_color);
        foreach ($array_color as $number_color) {
            $abb_cartridge = PrinterState_cartridgeNumber2Abbreviate($number_color);
            if ($abb_cartridge == 'error') {
                $cr = ERROR_WRONG_PRM;
                break;
            }
            $array_cartridge[] = $abb_cartridge;
            // we do not check filament status when starting slicing 20140807
            // 			if (PrinterState_getFilamentStatus($abb_cartridge)) {
            // 				continue;
            // 			}
            // 			else if ($abb_cartridge == 'l') {
            // 				$cr = ERROR_MISS_LEFT_FILA;
            // 				break;
            // 			}
            // 			else {
            // 				$cr = ERROR_MISS_RIGT_FILA;
            // 				break;
            // 			}
        }
        // check if we have done some custom changes to force local slicing or not
        if ($multi_part == TRUE) {
            foreach ($array_platform as $model) {
                if ($model[SLICER_PRM_XROT] != 0 || $model[SLICER_PRM_YROT] != 0 || $model[SLICER_PRM_SCALE] != 100) {
                    $custom_change = TRUE;
                    break;
                }
            }
        }
    }
    return $cr;
}
Пример #2
0
function PrinterState_getConsumption(&$array_filament)
{
    global $CFG;
    $output = array();
    $command = $CFG->config['arcontrol_c'] . PRINTERSTATE_GET_CONSUMPTION;
    $ret_val = 0;
    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;
    }
    // treat return of arduino
    if (count($output) > 1) {
        $status = NULL;
        foreach ($output as $line) {
            if (strpos($line, ':') === FALSE) {
                continue;
            }
            $tmp_array = explode(':', $line);
            $consumption = (double) trim($tmp_array[1]);
            if ($consumption > 0) {
                $endstop_line = PrinterState_cartridgeNumber2Abbreviate((int) str_replace('E', '', trim($tmp_array[0])));
                if ($endstop_line != 'error') {
                    $array_filament[$endstop_line] = $consumption;
                }
            }
        }
        return ERROR_OK;
    } else {
        // no usful return
        PrinterLog_logError('no arduino return', __FILE__, __LINE__);
    }
    return ERROR_INTERNAL;
}