Пример #1
0
/**
 * REmove previous log.txt, omr_result[*].txt
 * Enter description here ...
 * @param record $scan @see table blended_scans
 * @throws OMRError
 */
function omrprocess($scan)
{
    global $CFG;
    global $scansfoldername;
    mtrace("Entering OMR phase.");
    $scan->status = JOB_STATE_BUSY;
    set_field('blended_scans', 'status', $scan->status, 'id', $scan->id);
    $scan->timestatus = time();
    set_field('blended_scans', 'timestatus', $scan->timestatus, 'id', $scan->id);
    //update_record('blended_scans', $scan);
    $strresultlink = get_string('resultlink', 'blended');
    $rutaorigen = blended_getOMRSourcePath($scan);
    $rutafieldset = blended_getOMRFieldsetDir($scan);
    $rutadestino = blended_getOMRTargetPath($scan);
    $logfile = blended_getOMRInputLogFilePath($scan);
    mtrace("Processing Scan: {$scan->scan_name}");
    mtrace("     located at: {$rutaorigen}");
    mtrace("    fieldset at: {$rutafieldset}");
    mtrace("      target at: {$rutadestino} \n");
    try {
        /**
         * Clean previous results in case of a previous error and a relaunch
         */
        blended_delete_log_file($scan);
        blended_delete_scan_results($scan);
        /**
         * Execute the recognition process
         */
        list($status, $output) = blended_execute_omr_recognition($rutaorigen, $rutadestino, $rutafieldset);
        mtrace("Command executed. Status Code =");
        print_r($status);
        if ($status != 'OK') {
            $error = new OMRError($status, OMRError::OMRPROCESS_FAILED);
            throw $error;
        } else {
            $statusMsg = "Command executed. Status Code = 0";
            print_object($output);
            register_status($scan->id, $statusMsg, $output, JOB_STATE_FINISHED);
            //register_scannedjob($rutascandir,$jobid,$scan->course);
            $scan->status = JOB_STATE_FINISHED;
            register_scannedjob($scan);
        }
    } catch (OMRError $e) {
        mtrace("Fatal OMR Error: " . $e->getMessage());
        register_exception($e, $scan->id);
    } catch (ResultsError $e) {
        mtrace("ResultsError: " . $e->getMessage());
        register_exception($e, $scan->id);
    }
    return;
}
<?php

require_once "../../../config.php";
require_once '../processinglib.php';
register_scannedjob('C:/temp/sys/testBlended', 0);
die;