Ignore:
Timestamp:
Jan 5, 2026, 6:38:18 PM (41 hours ago)
Author:
chronos
Message:
  • Modfied: Allow to add measurements with different min, avg and max values.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Measure/Measure.php

    r95 r96  
    6464  function __construct(Database $Database)
    6565  {
    66     $this->Id = 0;
    6766    $this->ValueTypes = array('Min', 'Avg', 'Max');
    6867    $this->Database = &$Database;
     
    103102  }
    104103
    105   function AddValue(float $Value, int $Time): void
     104  function AddValue(int $Time, float $Min, float $Avg, float $Max): void
    106105  {
    107106    $Result = $this->Database->select($this->Data['DataTable'], '*', '(`Measure`='.$this->Data['Id'].') AND '.
     
    110109      // No measure value found. Simply insert new first value.
    111110      $this->Database->insert($this->Data['DataTable'],
    112         array('Min' => $Value, 'Avg' => $Value, 'Max' => $Value, 'Level' => 0,
     111        array('Min' => $Min, 'Avg' => $Avg, 'Max' => $Max, 'Level' => 0,
    113112        'Measure' => $this->Data['Id'], 'Time' => TimeToMysqlDateTime($Time),
    114113        'Continuity' => 0));
     
    116115      // One value exists. Add second value.
    117116      $this->Database->insert($this->Data['DataTable'],
    118       array('Min' => $Value, 'Avg' => $Value, 'Max' => $Value, 'Level' => 0,
     117      array('Min' => $Min, 'Avg' => $Avg, 'Max' => $Max, 'Level' => 0,
    119118      'Measure' => $this->Data['Id'], 'Time' => TimeToMysqlDateTime($Time),
    120119      'Continuity' => 1));
     
    138137          $Continuity = 0;
    139138        }
    140         if (($LastValue['Avg'] == $NextToLastValue['Avg']) and ($LastValue['Avg'] == $Value) and
     139        if (($LastValue['Min'] == $NextToLastValue['Min']) and ($LastValue['Min'] == $Min) and
     140          ($LastValue['Avg'] == $NextToLastValue['Avg']) and ($LastValue['Avg'] == $Avg) and
     141          ($LastValue['Max'] == $NextToLastValue['Max']) and ($LastValue['Max'] == $Max) and
    141142          ($LastValue['Continuity'] == 1) and ($Continuity == 1))
    142143        {
     
    148149        {
    149150          // Last value is different or not with continuity flag. Need to add new value.
    150           $this->Database->insert($this->Data['DataTable'], array('Min' => $Value,
    151             'Avg' => $Value, 'max' => $Value, 'Level' => 0, 'Measure' => $this->Data['Id'],
     151          $this->Database->insert($this->Data['DataTable'], array('Min' => $Min,
     152            'Avg' => $Avg, 'Max' => $Max, 'Level' => 0, 'Measure' => $this->Data['Id'],
    152153            'Time' => TimeToMysqlDateTime($Time),
    153154            'Continuity' => $Continuity));
     
    561562    $this->Database->query('DROP TABLE `'.$Measure->GetDataTable().'`');
    562563  }
    563 
    564564}
Note: See TracChangeset for help on using the changeset viewer.