Ignore:
Timestamp:
Mar 1, 2015, 12:43:56 PM (10 years ago)
Author:
chronos
Message:
  • Moved trunk as mvc branch.
Location:
branches/mvc
Files:
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • branches/mvc/Application/Model/Measure.php

    r47 r59  
    4141  }
    4242
    43 
    4443  function AddValue($Value = array('Min' => 0, 'Avg' => 0, 'Max' => 0), $Level = 0, $Time = 0)
    4544  {
     
    4847    //echo(TimeToMysqlDateTime($Time).'|'.$Level."\n");
    4948
    50     $Result = $this->Database->select($this->Data['DataTable'], '*', 'Measure='.$this->Data['Id'].' AND Level='.$Level.' ORDER BY Time DESC LIMIT 2');
     49    $Result = $this->Database->select($this->Data['DataTable'], '*', '(Measure='.$this->Data['Id'].') AND '.
     50      '(Level='.$Level.') ORDER BY Time DESC LIMIT 2');
    5151    //echo($Database->LastQuery."\n");
    5252    if($Result->num_rows == 0)
    5353    {
    54        $this->Database->insert($this->Data['DataTable'], array('Min' => $Value['Min'], 'Avg' => $Value['Avg'], 'Max' => $Value['Max'], 'Level' => $Level, 'Measure' => $this->Data['Id'], 'Time' => $this->Database->TimeToMysqlDateTime($Time), 'Continuity' => 0));
     54       $this->Database->insert($this->Data['DataTable'], array('Min' => $Value['Min'],
     55         'Avg' => $Value['Avg'], 'Max' => $Value['Max'], 'Level' => $Level,
     56         'Measure' => $this->Data['Id'], 'Time' => $this->Database->TimeToMysqlDateTime($Time), 'Continuity' => 0));
    5557       //echo($Database->LastQuery."\n");
    5658    } else if($Result->num_rows == 1)
    5759    {
    58       $this->Database->insert($this->Data['DataTable'], array('Min' => $Value['Min'], 'Avg' => $Value['Avg'], 'Max' => $Value['Max'], 'Level' => $Level, 'Measure' => $this->Data['Id'], 'Time' => $this->Database->TimeToMysqlDateTime($Time), 'Continuity' => 1));
     60      $this->Database->insert($this->Data['DataTable'], array('Min' => $Value['Min'],
     61        'Avg' => $Value['Avg'], 'Max' => $Value['Max'], 'Level' => $Level,
     62        'Measure' => $this->Data['Id'], 'Time' => $this->Database->TimeToMysqlDateTime($Time), 'Continuity' => 1));
    5963      //echo($Database->LastQuery."\n");
    6064    } else
     
    7175          else $Continuity = 0;
    7276        echo('('.$LastValue['Avg'].'=='.$NextToLastValue['Avg'].') and ('.$LastValue['Avg'].' == '.$Value.') and ('.$LastValue['Continuity'].' == 1) and ('.$Continuity.' == 1))'."\n");
    73         if(($LastValue['Min'] == $NextToLastValue['Min']) and ($LastValue['Min'] == $Value['Min']) and ($LastValue['Avg'] == $NextToLastValue['Avg']) and ($LastValue['Avg'] == $Value['Avg']) and ($LastValue['Max'] == $NextToLastValue['Max']) and ($LastValue['Max'] == $Value['Max']) and ($LastValue['Continuity'] == 1) and ($Continuity == 1))
    74         {
    75           $this->Database->update($this->Data['DataTable'], '(Time="'.$LastValue['Time'].'") AND (Level='.$Level.') AND (Measure='.$this->Data['Id'].')', array('Time' => $this->Database->TimeToMysqlDateTime($Time)));
     77        if(($LastValue['Min'] == $NextToLastValue['Min']) and ($LastValue['Min'] == $Value['Min']) and
     78        ($LastValue['Avg'] == $NextToLastValue['Avg']) and ($LastValue['Avg'] == $Value['Avg']) and
     79        ($LastValue['Max'] == $NextToLastValue['Max']) and ($LastValue['Max'] == $Value['Max']) and
     80        ($LastValue['Continuity'] == 1) and ($Continuity == 1))
     81        {
     82          $this->Database->update($this->Data['DataTable'], '(Time="'.$LastValue['Time'].'") '.
     83            'AND (Level='.$Level.') AND (Measure='.$this->Data['Id'].')', array(
     84            'Time' => $this->Database->TimeToMysqlDateTime($Time)));
    7685          //echo($this->Database->LastQuery."\n");
    7786        } else
    7887        {
    79           $this->Database->insert($this->Data['DataTable'], array('Min' => $Value['Min'], 'Avg' => $Value['Avg'], 'Max' => $Value['Max'], 'Level' => $Level, 'Measure' => $this->Data['Id'], 'Time' => $this->Database->TimeToMysqlDateTime($Time), 'Continuity' => $Continuity));
     88          $this->Database->insert($this->Data['DataTable'], array('Min' => $Value['Min'],
     89            'Avg' => $Value['Avg'], 'Max' => $Value['Max'], 'Level' => $Level,
     90            'Measure' => $this->Data['Id'], 'Time' => $this->Database->TimeToMysqlDateTime($Time),
     91            'Continuity' => $Continuity));
    8092        }
    8193      }
Note: See TracChangeset for help on using the changeset viewer.