Exemple #1
0
function PrinterState_getCartridgeCode(&$code_cartridge, $abb_cartridge, $power_off = TRUE)
{
    global $config;
    $arcontrol_fullpath = $config['arcontrol_c'];
    $command = '';
    $output = array();
    $ret_val = 0;
    switch ($abb_cartridge) {
        case 'l':
            $command = $arcontrol_fullpath . PRINTERSTATE_GET_CARTRIDGEL;
            break;
        case 'r':
            $command = $arcontrol_fullpath . PRINTERSTATE_GET_CARTRIDGER;
            break;
        default:
            return ERROR_WRONG_PRM;
            break;
    }
    exec($command, $output, $ret_val);
    if (!PrinterState_filterOutput($output)) {
        return ERROR_INTERNAL;
    }
    if ($ret_val != ERROR_NORMAL_RC_OK) {
        PrinterLog_logError('rfid read command error', __FILE__, __LINE__);
        return ERROR_INTERNAL;
    } else {
        $code_cartridge = $output ? $output[0] : NULL;
    }
    if ($power_off == TRUE) {
        $ret_val = PrinterState_setRFIDPower(FALSE);
        if ($ret_val != ERROR_OK) {
            return ERROR_INTERNAL;
        }
    }
    return ERROR_OK;
}
function PrinterState_setExtrusionMultiply($array_multiply)
{
    global $CFG;
    $output = array();
    $command = $CFG->config['arcontrol_c'] . PRINTERSTATE_SET_EXT_MULTIPLY;
    $ret_val = 0;
    foreach (array('r' => PRINTERSTATE_MULTIPLY_R_LABEL, 'l' => PRINTERSTATE_MULTIPLY_L_LABEL) as $abb_extruder => $prm_extruder) {
        if (isset($array_multiply[$abb_extruder]) && $array_multiply[$abb_extruder] < PRINTERSTATE_EXT_MULTIPLY_MAX && $array_multiply[$abb_extruder] > PRINTERSTATE_EXT_MULTIPLY_MIN) {
            $command .= $prm_extruder . $array_multiply[$abb_extruder];
        }
    }
    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;
    }
    return ERROR_OK;
}