HARPgroup / om

Object-oriented Meta-model
0 stars 1 forks source link

CBP Runoff Widget Upgrade #35

Open rburghol opened 5 years ago

rburghol commented 5 years ago

See also: https://github.com/HARPgroup/vahydro/issues/7

  1. Support csv inputs instead of XML
  2. operate with shared runtime database table
  3. use persistent runtime database table (no need to refresh if we pull the whole thing)
    • cache expiration per session data tables
  4. Support setting of runoff file dynamically at wake(), load from matrix sub-comps
  5. Eliminate redundant querying from shared table by storing in global or broadcast object
  6. Support local munging of timestep?
    • Or, Could pass entire hourly simulation to model, and use: var $intmethod = 6; // 6 - period sum, 3 - period mean inflow; but may be time-consuming // period sum is what is returned for precip and suro/ifwo/agwo or any other ivld by remote/rss_cbp_land_data.php

Options

ToDo:

Support CSV

global $cbp_seg_data; 
// for landseg suro, ifwo and agwo
// current values at simulation timestep\
// Ex:
//   $cbp_landseg_data['A51011'] = array(
//     'thistime' => 0, // set on update
//     'for_suro' => 0.011,
//     'for_ifwo' => 0.005,
//   ...
//   );

function step() {
  $status = $this->checkSharedData($this->id2);
  if (! ($status == 'error') ) {
    if (!status) {
      $this->putSharedData($this->id2, $this->state);
  }
}

function checkSharedData($id) {
  global $cbp_seg_data;
  // check global variable
  if (!isset($cbp_seg_data[$id])) {
    return 'error'; // something is mis-configured that should have happened in init()
  }
  if ($cbp_seg_data[$this->id2]['thistime'] == $this->timer->thistime) {
    // it is already updated, so return
    return TRUE;
  }
  return FALSE;

  function putSharedData($id, $data) {
    global $cbp_seg_data, $global_hub;
    // or a broadcast hub
   // $global_hub->broadCast($dataClass, $dataName, $sourceID, $dataValue)
   $global_hub->broadCast('cbp_landseg', $this->id2, 'for_suro', 0.001);
  }
}
rburghol commented 5 years ago

Fixed Routine is hanging up during XML serialize operation. I feel like I've seen this effect before, often related to a nested object? See test basic.php