Exemple #1
0
function workflow_execute1($sid, $mark = 0)
{
    global $db;
    if ($mark == 0) {
        $columns['status'] = 'running';
        $columns['request'] = 'waiting';
        $db->update("station", $columns, '"sid"=\'' . $sid . '\'');
    }
    #echo '..executing('.$sid.')';
    #file_put_contents('/tmp/info',"Executing (".$sid.")\n",FILE_APPEND);
    $sql = "select name from station where sid=" . $sid;
    $result = $db->fetchAll($sql);
    #file_put_contents('/tmp/info',"Found Execution Name \"".$result[0]['name']."\" (".$mark.",".$sid.")\n",FILE_APPEND);
    if ($result[0]['name'] == "New Input") {
        if ($mark == 1) {
            $sql = 'insert into inter_process ("svid", "name", "type", "value", "sid", "description", "show", "order", "timestamp", "function") values (0,\'sid\',\'integer\',\'' . $sid . '\',\'' . $sid . '\',\'Reload input ' . $sid . '\',0,0, now(),\'mark\')';
            $result1 = $db->fetchAll($sql);
        } else {
            $schema = '';
            # find module name
            $sql = "select " . $schema . "station_variables.svid as svid, " . $schema . "station_variables.name as name, " . $schema . "station_variables.value as value from " . $schema . "station_variables where " . $schema . "station_variables.sid='" . $sid . "' and (" . $schema . "station_variables.name='name' or " . $schema . "station_variables.name='value' or " . $schema . "station_variables.name='xc' or " . $schema . "station_variables.name='yc' or " . $schema . "station_variables.name='show' or " . $schema . "station_variables.name='type' or " . $schema . "station_variables.name='options' or " . $schema . "station_variables.name='taborder'  or " . $schema . "station_variables.name='moduletype')";
            $result1 = $db->fetchAll($sql);
            foreach ($result1 as $variable) {
                $value[$variable['name']] = $variable['value'];
                if ($variable['name'] == 'value') {
                    $svid = $variable['svid'];
                }
            }
            $options = json_decode($value['options'], true);
            call_user_func($value['type'] . "_rtrn_default_value", $sid, $options);
            # write value into database
            $sql = 'insert into inter_process ("svid", "name", "type", "value", "sid", "description", "show", "order", "timestamp", "function") values (0,\'sid\',\'integer\',\'' . $sid . '\',\'' . $sid . '\',\'Reload input ' . $sid . '\',0,0, now(),\'reload\')';
            $result1 = $db->fetchAll($sql);
            workflow_done($sid);
        }
    }
    #file_put_contents('/tmp/info',"Still Eaaxecuting \"".$result[0]['name']."\" (".$mark.",".$sid.")\n",FILE_APPEND);
    #echo '..narrowing begin('.$result[0]['name'].')';
    if ($result[0]['name'] == "New Processing" and $mark == 0) {
        #echo '..narrowing('.$result[0]['name'].')';
        $sql = "select * from station_variables where sid=" . $sid;
        $result1 = $db->fetchAll($sql);
        foreach ($result1 as $value) {
            $module[$value['sid']][$value['name']] = $value['value'];
        }
        #echo '..readying to run('.$module[$sid]['phpfile'].')';
        $ex = '/usr/bin/php -f modules/processors/' . $module[$sid]['phpfile'] . '.php ' . $sid . ' /dev/null &';
        #echo $ex;
        pclose(popen($ex, 'r'));
    }
    if ($result[0]['name'] == "New Visualization") {
        #file_put_contents('/tmp/info',"Requesting update for Vis (".$sid.")\n",FILE_APPEND);
        if ($mark == 1) {
            $sql = 'insert into inter_process ("svid", "name", "type", "value", "sid", "description", "show", "order", "timestamp", "function") values (0,\'sid\',\'integer\',\'' . $sid . '\',\'' . $sid . '\',\'Reload vizualization ' . $sid . '\',0,0, now(),\'mark\')';
            $result1 = $db->fetchAll($sql);
        } else {
            $sql = 'insert into inter_process ("svid", "name", "type", "value", "sid", "description", "show", "order", "timestamp", "function") values (0,\'sid\',\'integer\',\'' . $sid . '\',\'' . $sid . '\',\'Reload vizualization ' . $sid . '\',0,0, now(),\'reload\')';
            $result1 = $db->fetchAll($sql);
        }
    }
}
Exemple #2
0
//Distance to Closest Stream
    $res = pg_query ($dbconn, 'select surface_stream_flow.site_name, huc, site_type, status, total_mean*723.966 as total_mean_acreft, water_year, annual_dis*723.966 as annual_dis_acreft, distance(transform(surface_stream_flow.the_geom,32612),transform(ST_GeomFromText(\''.$data['Input Map'].'\',4326),32612))/1000 as stream_dist from surface_stream_flow order by stream_dist asc limit 1;');
        $result = pg_fetch_all($res);
        var_dump($result);

# writing the data into the table

        $res = pg_query ($dbconn, 'update result_simple_variables set value=(\''.$result[0]['site_name'].' ('.round ($result[0]['stream_dist'],2).'km)\' ) where id=12;');
        pg_fetch_all($res);

# writing the data into the table

        $res = pg_query ($dbconn,'update result_simple_variables set value=(\''.$result[0]['huc'].', '.$result[0] ['site_type'].', '.$result[0]['status'].'\') where id=13;');
        pg_fetch_all($res);

# writing the data into the table

        $res = pg_query ($dbconn,'update result_simple_variables set value=(\''.round ($result[0]['total_mean_acreft'],2).', '.$result[0] ['water_year'].'\') where id=14;');
        pg_fetch_all($res);

# writing the data into the table

        $res = pg_query ($dbconn,'update result_simple_variables set value=(\''.round ($result[0]['annual_dis_acreft'],2).'\') where id=15;');
        pg_fetch_all($res);


# Make sure to write the data into a table 
#---------- end of userdefined content ------------------

workflow_done($sid);
}
Exemple #3
0
function place_input($dashboard, $sid)
{
    array_push($movableObjects, $sid);
    global $db;
    global $setup;
    $schema = '';
    $sql = "select " . $schema . "station_variables.svid as svid, " . $schema . "station_variables.name as name, " . $schema . "station_variables.value as value from " . $schema . "station_variables where " . $schema . "station_variables.sid='" . $sid . "' and (" . $schema . "station_variables.name='name' or " . $schema . "station_variables.name='value' or " . $schema . "station_variables.name='xc' or " . $schema . "station_variables.name='yc' or " . $schema . "station_variables.name='show' or " . $schema . "station_variables.name='type' or " . $schema . "station_variables.name='options' or " . $schema . "station_variables.name='taborder'  or " . $schema . "station_variables.name='moduletype')";
    $result = $db->fetchAll($sql);
    foreach ($result as $variable) {
        $value[$variable['name']] = $variable['value'];
        if ($variable['name'] == 'options') {
            $svid = $variable['svid'];
        }
        if ($variable['name'] == 'value') {
            $svid_value = $variable['svid'];
        }
    }
    $options = json_decode($value['options'], true);
    foreach ($options as $key1 => $value1) {
        if (is_integer($key1)) {
            if ($key1 == $dashboard) {
                $options['dashboard_options'] = $options[$dashboard];
            }
            unset($options[$key1]);
        }
    }
    if ($setup == 1) {
        $setup_location['enabled'] = true;
    } else {
        $setup_location['enabled'] = false;
    }
    $setup_location['dashboard'] = $dashboard;
    $setup_location['svid'] = $svid;
    $setup_location['value_svid'] = $svid_value;
    $content = call_user_func("reload_input_" . $value['type'], $sid, $value['value'], $options, $setup_location);
    workflow_done($sid);
    return $content;
}