Changeset 656


Ignore:
Timestamp:
May 16, 2014, 10:44:07 PM (10 years ago)
Author:
chronos
Message:
  • Opraveno: Zobrazení tabulky seznamu měření.
  • Opraveno: Přidávání nových hodnot přes web.
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/Version.php

    r653 r656  
    11<?php
    22
    3 $Revision = 653; // Subversion revision
    4 $DatabaseRevision = 647; // SQL structure revision
    5 $ReleaseTime = strtotime('2014-05-04');
     3$Revision = 656; // Subversion revision
     4$DatabaseRevision = 656; // SQL structure revision
     5$ReleaseTime = strtotime('2014-05-16');
  • trunk/Common/Setup/Updates.php

    r649 r656  
    22
    33function UpdateTo493($Manager)
    4 {     
     4{
    55  $Manager->Execute("ALTER TABLE `UserOnline` CHANGE `User` `User` INT( 11 ) NULL DEFAULT NULL COMMENT 'User.Id'");
    66}
    77
    88function UpdateTo494($Manager)
    9 {     
     9{
    1010  $Manager->Execute("ALTER TABLE `FinanceOperation` DROP FOREIGN KEY `FinanceOperation_ibfk_2` ;\n".
    1111    "ALTER TABLE `FinanceOperation` CHANGE `Bill` `File` INT( 11 ) NULL DEFAULT NULL;\n".
     
    183183  `Message` varchar(255) NOT NULL DEFAULT '',
    184184  PRIMARY KEY (`Id`)
    185 ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;"); 
     185) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
    186186}
    187187
     
    201201  $Manager->Execute("INSERT INTO `ServiceCategory` (
    202202`Id` ,`Name`) VALUES (NULL , 'Pevný nájem');");
    203   $ServiceCategoryHire = $Manager->Database->insert_id; 
     203  $ServiceCategoryHire = $Manager->Database->insert_id;
    204204  $DbResult = $Manager->Execute("SELECT * FROM Member WHERE Hire>0");
    205205  while($Member = $DbResult->fetch_assoc())
     
    211211NULL , 'Nájem', '".$ServiceCategoryHire."', '-".$Member['Hire']."', '2', '', NULL , NULL , '', '', '', '', '', '', '', ''
    212212);");
    213     $ServiceHire = $Manager->Database->insert_id; 
    214     $Manager->Execute("INSERT INTO `ServiceCustomerRel` (`Service`, `Customer`) VALUES ". 
     213    $ServiceHire = $Manager->Database->insert_id;
     214    $Manager->Execute("INSERT INTO `ServiceCustomerRel` (`Service`, `Customer`) VALUES ".
    215215      "(".$ServiceHire.",".$Member['Id'].")");
    216216  }
     
    226226  $Manager->Execute("ALTER TABLE `NetworkSubnet` ADD FOREIGN KEY ( `Service` ) REFERENCES `ServiceCustomerRel` (
    227227`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;");
    228   $Manager->Execute("UPDATE `NetworkSubnet` SET `Service` = (SELECT `Id` FROM `ServiceCustomerRel` WHERE `ServiceCustomerRel`.`Customer` = `NetworkSubnet`.`Member` LIMIT 1)"); 
     228  $Manager->Execute("UPDATE `NetworkSubnet` SET `Service` = (SELECT `Id` FROM `ServiceCustomerRel` WHERE `ServiceCustomerRel`.`Customer` = `NetworkSubnet`.`Member` LIMIT 1)");
    229229}
    230230
     
    252252      PRIMARY KEY (`Id`)
    253253  ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
    254  
     254
    255255  INSERT INTO `ActionType` (`Id`, `Name`) VALUES
    256256  (1, 'Odkaz'),
     
    301301  $ActionId = $Manager->Database->insert_id;
    302302  $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
    303     "VALUES (NULL , 'Nabídky', '23', '".$ActionId."', '1');"); 
     303    "VALUES (NULL , 'Nabídky', '23', '".$ActionId."', '1');");
    304304}
    305305
     
    310310  while($DbRow = $DbResult->fetch_row())
    311311  {
    312     $Manager->Execute("ALTER TABLE `".$DbRow[0]."` CONVERT TO CHARACTER SET utf8"); 
    313   } 
     312    $Manager->Execute("ALTER TABLE `".$DbRow[0]."` CONVERT TO CHARACTER SET utf8");
     313  }
    314314}
    315315
     
    323323
    324324function UpdateTo550($Manager)
    325 { 
     325{
    326326  $Manager->Execute('ALTER TABLE `FinanceBankAccount` ADD `LastImportId` VARCHAR( 255 ) NOT NULL ;');
    327327  $Manager->Execute('ALTER TABLE `FinanceBankAccount` ADD `LastImportDate` DATE NULL ;');
     
    330330
    331331function UpdateTo551($Manager)
    332 { 
     332{
    333333  $Manager->Execute('ALTER TABLE `FinanceOperation` ADD `DocumentLine` INT NULL AFTER `Value` ,
    334334ADD INDEX ( `DocumentLine` ) ;');
     
    344344
    345345function UpdateTo565($Manager)
    346 { 
     346{
    347347  $Manager->Execute('CREATE TABLE IF NOT EXISTS `WikiPage` (
    348348    `Id` int(11) NOT NULL AUTO_INCREMENT,
     
    370370
    371371function UpdateTo571($Manager)
    372 { 
     372{
    373373  $Manager->Execute('ALTER TABLE `NetworkDevice` ADD `LoginName` VARCHAR( 255 ) NOT NULL ,
    374374ADD `LoginPassword` VARCHAR( 255 ) NOT NULL ;');
     
    391391      PRIMARY KEY (`Id`)
    392392  ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=33 ;");
    393  
     393
    394394  $Manager->Execute("INSERT INTO `Module` (`Id`, `Name`, `Title`) VALUES
    395395  (1, 'Customer', 'Zákazník'),
     
    647647}
    648648
     649function UpdateTo656($Manager)
     650{
     651        $Manager->Execute('CREATE TABLE IF NOT EXISTS `Measure` (
     652  `Id` int(11) NOT NULL AUTO_INCREMENT,
     653  `Name` varchar(255) NOT NULL,
     654  `Method` int(11) NOT NULL,
     655  `Continuity` int(11) NOT NULL,
     656  `Period` int(11) NOT NULL,
     657  `Enabled` int(11) NOT NULL,
     658  `Description` text NOT NULL,
     659  `DataType` varchar(255) NOT NULL,
     660  `DataTable` varchar(255) NOT NULL,
     661  `Group` int(11) DEFAULT NULL,
     662  `Cumulative` int(11) NOT NULL DEFAULT "0",
     663  PRIMARY KEY (`Id`),
     664  KEY `Group` (`Group`),
     665  KEY `Method` (`Method`)
     666) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
     667
     668  $Manager->Execute('CREATE TABLE IF NOT EXISTS `MeasureData` (
     669  `Id` int(11) NOT NULL AUTO_INCREMENT,
     670  `Time` datetime NOT NULL,
     671  `Level` int(11) NOT NULL,
     672  `Measure` int(11) NOT NULL,
     673  `Continuity` int(11) NOT NULL,
     674  `Min` int(11) NOT NULL,
     675  `Avg` int(11) NOT NULL,
     676  `Max` int(11) NOT NULL,
     677  PRIMARY KEY (`Id`),
     678  KEY `Time` (`Time`),
     679  KEY `Measure` (`Measure`)
     680) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
     681
     682  $Manager->Execute('CREATE TABLE IF NOT EXISTS `MeasureGroup` (
     683  `Id` int(11) NOT NULL AUTO_INCREMENT,
     684  `Name` varchar(255) NOT NULL,
     685  `Parent` int(11) DEFAULT NULL,
     686  PRIMARY KEY (`Id`),
     687  KEY `Parent` (`Parent`)
     688) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
     689
     690  $Manager->Execute('CREATE TABLE IF NOT EXISTS `MeasureMethod` (
     691  `Id` int(11) NOT NULL AUTO_INCREMENT,
     692  `Name` varchar(255) NOT NULL,
     693  `Unit` varchar(255) NOT NULL,
     694  PRIMARY KEY (`Id`)
     695) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
     696
     697  $Manager->Execute('ALTER TABLE `Measure`
     698  ADD CONSTRAINT `Measure_ibfk_1` FOREIGN KEY (`Group`) REFERENCES `MeasureGroup` (`Id`),
     699  ADD CONSTRAINT `Measure_ibfk_2` FOREIGN KEY (`Method`) REFERENCES `MeasureMethod` (`Id`);');
     700
     701  $Manager->Execute('ALTER TABLE `MeasureData`
     702  ADD CONSTRAINT `MeasureData_ibfk_1` FOREIGN KEY (`Measure`) REFERENCES `Measure` (`Id`);');
     703
     704  $Manager->Execute('ALTER TABLE `MeasureGroup`
     705  ADD CONSTRAINT `MeasureGroup_ibfk_1` FOREIGN KEY (`Parent`) REFERENCES `MeasureGroup` (`Id`);');
     706}
    649707
    650708class Updates
  • trunk/Modules/NetworkConfigRouterOS/Routerboard.php

    r548 r656  
    5555      if($this->Debug) echo($Command);
    5656      $Output = array();
    57       exec($Command, $Output);
     57      //exec($Command, $Output);
    5858    } else $Output = '';
    5959    if($this->Debug) print_r($Output);
  • trunk/Modules/TimeMeasure/Graph.php

    r655 r656  
    106106        $PointsMax[] = $Index * $Width / $Measure->DivisionCount;
    107107        $PointsMax[] = $Height - 1 - ($Points[$Index]['Max'] - $MinValue) / ($MaxValue - $MinValue) * $Height * $this->ValueToImageHeigthCoefficient;
    108         //echo($Index.' - '.$Item.' '.$Points[$Index].'<br>');
    109108      }
    110109    }
     
    127126    //$Points[] = $Width - 1;
    128127    //$Points[] = $Height - 1;
    129 
    130     //print_r($PointsMax);
    131128
    132129    // Generate image
  • trunk/Modules/TimeMeasure/Main.php

    r655 r656  
    33class PageMeasure extends Page
    44{
    5   var $Months;
    65  var $GraphTimeRanges;
    76  var $DefaultVariables;
     
    2322      'Differential' => 0,
    2423    );
    25     $this->Months = array('', 'Leden', 'Únor', 'Březen', 'Duben', 'Květen',
    26       'Červen', 'Červenec', 'Srpen', 'Září', 'Říjen', 'Listopad', 'Prosinec');
    2724    $this->GraphTimeRanges = array
    2825  (
     
    5653  function EditTime($Time)
    5754  {
     55    global $MonthNames;
     56
    5857    $Output = '<form style="display: inline;" action="?Operation=SetTime&amp;Time='.$Time.'" method="post">';
    5958
     
    7271    // Month selection
    7372    $Output .= '<select name="Month">';
    74     foreach($this->Months as $Index => $Month)
     73    foreach($MonthNames as $Index => $Month)
    7574    {
    7675      if($Index == $TimeParts['mon']) $Selected = ' selected="1"'; else $Selected = '';
     
    133132    }
    134133
    135     $Output = '';
     134    $Output = '<div style="text-align: center;">';
    136135
    137136    if(!array_key_exists('Operation', $_GET)) $_GET['Operation'] = '';
     
    171170      $Output .= '<a href="?TimeSpecify=1">Přesnější nastavení...</a><br>';
    172171    } else {
    173       $Output .= '<table cellspacing="0" cellpadding="2" border="0">';
     172      $Output .= '<table style="margin: 10px auto; " cellspacing="0" cellpadding="2" border="0">';
    174173      $Output .= '<tr><td>Počátek:</td><td>'.$this->EditTime('TimeStart').'</td></tr>';
    175174      $Output .= '<tr><td>Konec:</td><td>'.$this->EditTime('TimeEnd').'</td></tr>';
     
    198197  {
    199198    $PrefixMultiplier = new PrefixMultiplier();
    200     $Output = '<table border="1" cellspacing="0" cellpadding="2" style="font-size: small;">';
    201     $Output .= '<tr><th>Měřená veličina</th><th>Poslední hodnota</th><th>Čas posledního měření</th><th>Interpolace</th><th>Poznámky</th>';
    202     if(array_key_exists('Debug', $_GET)) $Output .= '<th>Počet položek</th><th>Čas vykonání</th>';
    203     $Output .= '</tr>';
    204     $Result = $this->Database->select('Measure', '*', 'Enabled=1 ORDER BY Description');
     199
     200    $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Measure` WHERE `Enabled`=1');
     201    $DbRow = $DbResult->fetch_row();
     202    $PageList = GetPageList($DbRow[0]);
     203
     204    $Output = $PageList['Output'];
     205    $Output .= '<table class="WideTable" style="font-size: small;">';
     206
     207    $TableColumns = array(
     208      array('Name' => 'Name', 'Title' => 'Měřená veličina'),
     209      array('Name' => 'LastValue', 'Title' => 'Poslední hodnota'),
     210      array('Name' => 'LastValueTime', 'Title' => 'Čas posledního měření'),
     211      array('Name' => 'Continuous', 'Title' => 'Interpolace'),
     212      array('Name' => 'Description', 'Title' => 'Popis'),
     213    );
     214    if(array_key_exists('Debug', $_GET))
     215    {
     216      $TableColumns[] = array('Name' => 'ItemCount', 'Title' => 'Počet položek');
     217      $TableColumns[] = array('Name' => 'MeasureDuration', 'Title' => 'Čas vykonání');
     218    }
     219    $Order = GetOrderTableHeader($TableColumns, 'Name', 0);
     220    $Output .= $Order['Output'];
     221
     222    $Result = $this->Database->select('Measure', '*', '`Enabled`=1 '.$Order['SQL'].$PageList['SQLLimit']);
    205223    while($Measure = $Result->fetch_array())
    206224    {
    207       $DbResult2 = $this->Database->select('MeasureMethod', '*', 'Id='.$Measure['Method']);
     225      $DbResult2 = $this->Database->select('MeasureMethod', '*', '`Id`='.$Measure['Method']);
    208226      $MeasureMethod = $DbResult2->fetch_assoc();
    209227      $StopWatchStart = GetMicrotime();
     
    234252    }
    235253    $Output .= '</table>';
     254    $Output .= $PageList['Output'];
    236255    //echo(time());
    237256    //print_r(gd_info());
     
    240259    //ShowPage($Output);
    241260    //echo($PrefixMultiplier->Add('-0.000000071112345', 'B'));
     261    $Output .= '</div>';
    242262    return($Output);
    243263  }
    244264}
     265
     266class PageMeasureAddValue extends Page
     267{
     268  function Show()
     269  {
     270    $this->ClearPage = true;
     271
     272    $Output = '';
     273    if(!array_key_exists('MeasureId', $_GET)) return('Nebylo zadáno Id měření.');
     274    if(!array_key_exists('Value', $_GET)) return('Nebyla zadána hodnota.');
     275    $Measure = new Measure($this->System);
     276    $Measure->Load($_GET['MeasureId']);
     277    if(!isset($Measure->Data['Id'])) return('Měření s Id '.$_GET['MeasureId'].' nenalezeno.');
     278    $Measure->AddValue(array('Min' => $_GET['Value'], 'Avg' => $_GET['Value'], 'Max' => $_GET['Value']));
     279    return($Output);
     280  }
     281}
  • trunk/Modules/TimeMeasure/Measure.php

    r655 r656  
    3939  }
    4040
    41 
    4241  function AddValue($Value = array('Min' => 0, 'Avg' => 0, 'Max' => 0), $Level = 0, $Time = 0)
    4342  {
    4443    if($Time == 0) $Time = time();
    45     //$Value = round($Measure['divider'] * $Value);
    46     //echo(TimeToMysqlDateTime($Time).'|'.$Level."\n");
    47 
    48     $Result = $this->Database->select($this->Data['DataTable'], '*', 'Measure='.$this->Data['Id'].' AND Level='.$Level.' ORDER BY Time DESC LIMIT 2');
    49     //echo($Database->LastQuery."\n");
     44
     45    $Result = $this->Database->select($this->Data['DataTable'], '*', 'Measure='.
     46      $this->Data['Id'].' AND Level='.$Level.' ORDER BY Time DESC LIMIT 2');
    5047    if($Result->num_rows == 0)
    5148    {
    52        $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));
    53        //echo($Database->LastQuery."\n");
     49       $this->Database->insert($this->Data['DataTable'], array('Min' => $Value['Min'],
     50         'Avg' => $Value['Avg'], 'Max' => $Value['Max'], 'Level' => $Level,
     51         'Measure' => $this->Data['Id'], 'Time' => TimeToMysqlDateTime($Time), 'Continuity' => 0));
    5452    } else if($Result->num_rows == 1)
    5553    {
    56       $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));
    57       //echo($Database->LastQuery."\n");
     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' => TimeToMysqlDateTime($Time), 'Continuity' => 1));
    5857    } else
    5958    {
    6059      $LastValue = $Result->fetch_assoc();
    6160      $NextToLastValue = $Result->fetch_assoc();
    62       //echo($Level.': '.$Time.' - '.MysqlDateTimeToTime($LastValue['Time']).' '.($Time - MysqlDateTimeToTime($LastValue['Time'])).' = '.$Measure['Period']."\n");
    6361      if((($Time - MysqlDateTimeToTime($LastValue['Time'])) < 0.75 * $this->Data['Period']) and ($Level == 0))
    6462      {
    65         echo('Too short period\n');
     63        echo('Too short period. Minimal period is '.(0.75 * $this->Data['Period'])." seconds\n");
    6664      } else
    6765      {
    6866        if(($Time - MysqlDateTimeToTime($LastValue['Time'])) < 1.25 * $this->Data['Period']) $Continuity = 1;
    6967          else $Continuity = 0;
    70         echo('('.$LastValue['Avg'].'=='.$NextToLastValue['Avg'].') and ('.$LastValue['Avg'].' == '.$Value.') and ('.$LastValue['Continuity'].' == 1) and ('.$Continuity.' == 1))'."\n");
    71         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))
    72         {
    73           $this->Database->update($this->Data['DataTable'], '(Time="'.$LastValue['Time'].'") AND (Level='.$Level.') AND (Measure='.$this->Data['Id'].')', array('Time' => $this->Database->TimeToMysqlDateTime($Time)));
    74           //echo($this->Database->LastQuery."\n");
     68        if(($LastValue['Min'] == $NextToLastValue['Min']) and ($LastValue['Min'] ==
     69          $Value['Min']) and ($LastValue['Avg'] == $NextToLastValue['Avg']) and
     70          ($LastValue['Avg'] == $Value['Avg']) and ($LastValue['Max'] == $NextToLastValue['Max'])
     71          and ($LastValue['Max'] == $Value['Max']) and ($LastValue['Continuity'] == 1) and ($Continuity == 1))
     72        {
     73          $this->Database->update($this->Data['DataTable'], '(Time="'.$LastValue['Time'].
     74            '") AND (Level='.$Level.') AND (Measure='.$this->Data['Id'].')', array('Time' => TimeToMysqlDateTime($Time)));
    7575        } else
    7676        {
    77           $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));
     77          $this->Database->insert($this->Data['DataTable'], array('Min' => $Value['Min'],
     78            'Avg' => $Value['Avg'], 'Max' => $Value['Max'], 'Level' => $Level,
     79            'Measure' => $this->Data['Id'], 'Time' => TimeToMysqlDateTime($Time), 'Continuity' => $Continuity));
    7880        }
    7981      }
     
    8385      {
    8486        $Level = $Level + 1;
    85         //echo('Level '.$Level."<br>\n");
    8687        $TimeSegment = $this->TimeSegment($this->Data['Period'], 1);
    8788        $EndTime = $this->AlignTime($Time, $TimeSegment);
     
    8990        $StartTime = $EndTime - $TimeSegment;
    9091
    91         //echo(" ".$TimeSegment." ".$StartTime.'-'.$EndTime."<br>\n");
    92         //flush();
    93 
    9492        // Load values in time range
    9593        $Values = array();
    9694        //.'" AND Time < "'.TimeToMysqlDateTime($EndTime).'" AND Measure='.$Measure['Id'].' AND Level='.($Level - 1).' ORDER BY Time');
    97         $Result = $this->Database->select($this->Data['DataTable'], '*', '(Time > "'.TimeToMysqlDateTime($StartTime).'") AND (Time < "'.$this->Database->TimeToMysqlDateTime($EndTime).'") AND (Measure='.$this->Data['Id'].') AND (Level='.($Level - 1).') ORDER BY Time');
     95        $Result = $this->Database->select($this->Data['DataTable'], '*', '(Time > "'.
     96          TimeToMysqlDateTime($StartTime).'") AND (Time < "'.TimeToMysqlDateTime($EndTime).
     97            '") AND (Measure='.$this->Data['Id'].') AND (Level='.($Level - 1).') ORDER BY Time');
    9898        while($Row = $Result->fetch_assoc())
    9999        {
     
    103103        //if(count($Values) > 2)
    104104        {
    105           //print_r($Values);
    106105          //array_pop($Values);
    107106
    108107          // Load subsidary values
    109           print_r($Values);
    110           $Values = array_merge($this->LoadLeftSideValue($Level - 1, $this->Data,
     108          $Values = array_merge($this->LoadLeftSideValue($Level - 1,
    111109            $StartTime), $Values, $this->LoadRightSideValue($Level - 1, $EndTime));
    112           print_r($Values);
    113110
    114111          $Point = $this->ComputeOneValue($StartTime, $EndTime, $Values, $Level);
    115         //print_r($Point);
    116112
    117113          $this->Database->delete($this->Data['DataTable'], '(Time > "'.TimeToMysqlDateTime($StartTime).
     
    128124  {
    129125    $Y = ($Y2 - $Y1) / ($X2 - $X1) * ($X - $X1) + $Y1;
    130     //echo($Y1.'-'.$Y.'-'.$Y2.' '.$X1.'-'.$X.'-'.$X2.'<br>');
    131126    return($Y);
    132127  }
     
    186181        else if($ValueType == 'Min')
    187182        {
    188           //echo($Values[$I+1]['continuity'].'=='.$Measure['ContinuityEnabled'].'<br>');
    189183          if($Values[$I + 1]['Continuity'] == $this->Data['ContinuityEnabled'])
    190184          {
     
    210204    }
    211205    return($NewValue);
    212     //echo($NewValue['avg'].'<br>');
    213     //return(array('min' => rand(0,1), 'avg' => $NewValue['avg'], 'max' => rand(0,1)));
    214206  }
    215207
     
    217209  {
    218210    // Get first and last time
    219     //echo($Measure['Id'].','.$Level.','.StatTableName($Level)."\n");
    220211    $Result = $this->Database->select($this->Data['DataTable'], '*', 'Measure='.$this->Data['Id'].' AND Level='.$Level.' ORDER BY Time LIMIT 1');
    221212    if($Result->num_rows > 0)
     
    269260  {
    270261    $Result = array();
    271     //echo('SELECT * FROM '.StatTableName($Level). ' WHERE '. 'Time < "'.TimeToMysqlDateTime($Time).'" AND measure='.$Measure['Id'].' AND level='.$Level.' ORDER BY Time DESC LIMIT 1'."<br>\n");
    272     $DbResult = $this->Database->select($this->Data['DataTable'], '*', 'Time < "'.TimeToMysqlDateTime($Time).'" AND Measure='.$this->Data['Id'].' AND Level='.$Level.' ORDER BY Time DESC LIMIT 1');
     262    $DbResult = $this->Database->select($this->Data['DataTable'], '*', '(Time < "'.
     263      TimeToMysqlDateTime($Time).'") AND (Measure='.$this->Data['Id'].') AND (Level='.$Level.') ORDER BY Time DESC LIMIT 1');
    273264    if($DbResult->num_rows > 0)
    274265    {
     
    289280        array_push($Result, array('Time' => (MysqlDateTimeToTime($Row['Time']) - 10), 'Min' => 0, 'Avg' => 0, 'Max' => 0, 'Continuity' => 0));
    290281      }
    291 //    if($Debug) print_r($Result);
    292282      return($Result);
    293283    }
     
    330320    {
    331321      $Values = array_merge($this->LoadLeftSideValue($Level, $TimeFrom), $Values, $this->LoadRightSideValue($Level, $TimeTo));
    332       //echo(count($Values).'<br>');
    333       //echo($TimeFrom.','.$TimeTo.'<br>');
    334       //echo($Values[0]['Time'].'<br>');
    335322      $StartIndex = 0;
    336323      $Points = array();
    337       //echo($DivisionCount.'<br>');
    338324      if($this->Debug) print_r($Values);
    339       //die();
    340325      for($I = 0; $I < $this->DivisionCount; $I++)
    341326      {
    342327        $TimeStart = $TimeFrom + (($TimeTo - $TimeFrom) / $this->DivisionCount) * $I;
    343         //if($Debug) echo('TimeStart '.$I.': '.$TimeStart.'('.TimeToMysqlDateTime($TimeStart).')<br>');
    344328        $TimeEnd = $TimeFrom + (($TimeTo - $TimeFrom) / $this->DivisionCount) * ($I + 1);
    345         if($this->Debug) echo('TimeEnd '.$I.': '.$TimeEnd.'('.$this->Database->TimeToMysqlDateTime($TimeEnd).')<br>');
    346         //echo($TimeStart.','.$TimeEnd.'<br>');
     329        if($this->Debug) echo('TimeEnd '.$I.': '.$TimeEnd.'('.TimeToMysqlDateTime($TimeEnd).')<br>');
    347330
    348331        $EndIndex = $StartIndex;
     
    350333        //while(($Values[$EndIndex]['Time'] < $TimeEnd)) $EndIndex = $EndIndex + 1;
    351334        $SubValues = array_slice($Values, $StartIndex, $EndIndex - $StartIndex + 1);
    352         //echo($StartIndex.','.$EndIndex.' '.count($SubValues).'<br>');
    353         //print_r($SubValues);
    354335        $Points[] = $this->ComputeOneValue($TimeStart, $TimeEnd, $SubValues, $Level);
    355336        $StartIndex = $EndIndex - 1;
     
    362343  function RebuildMeasureCache()
    363344  {
    364     echo('Velicina '.$this->Data['Name']."<br>\n");
     345    echo('Veličina '.$this->Data['Name']."<br>\n");
    365346    if($this->Data['Continuity'] == 0) $this->Data['ContinuityEnabled'] = 0;  // non continuous
    366347      else $this->Data['ContinuityEnabled'] = 2;    // continuous graph
     
    377358      echo('Uroven '.$Level."<br>\n");
    378359      $TimeRange = $this->GetTimeRange($Level - 1);
    379       //echo($Measure['Id'].','.($Level-1)."\n");
    380       //echo(TimeToMysqlDateTime($TimeRange['left']).'-'.TimeToMysqlDateTime($TimeRange['right'])."\n");
    381360      $TimeSegment = $this->TimeSegment($this->Data['Period'], $Level);
    382361      $StartTime = $this->AlignTime($TimeRange['Left'], $TimeSegment) - $TimeSegment;
     
    390369        $EndTime2 = $StartTime + ($I + 1) * $BurstCount * $TimeSegment;
    391370        $Values = array();
    392         $DbResult = $this->Database->select($this->Data['DataTable'], '*', 'Time > "'.$this->Database->TimeToMysqlDateTime($StartTime2).'" AND Time < "'.$this->Database->TimeToMysqlDateTime($EndTime2).'" AND Measure='.$Measure['Id'].' AND Level='.($Level - 1).' ORDER BY Time');
     371        $DbResult = $this->Database->select($this->Data['DataTable'], '*', 'Time > "'.
     372          TimeToMysqlDateTime($StartTime2).'" AND Time < "'.TimeToMysqlDateTime($EndTime2).'" AND Measure='.$this->Data['Id'].' AND Level='.($Level - 1).' ORDER BY Time');
    393373        while($Row = $DbResult->fetch_assoc())
    394374        {
     
    399379        if(count($Values) > 0)
    400380        {
    401           $Values = array_merge($this->LoadLeftSideValue($Level - 1, $StartTime2), $Values, $this->LoadRightSideValue($Level - 1, $Measure, $EndTime2));
     381          $Values = array_merge($this->LoadLeftSideValue($Level - 1, $StartTime2),
     382          $Values, $this->LoadRightSideValue($Level - 1, $this->Data, $EndTime2));
    402383
    403384          $StartIndex = 0;
     
    411392            while($Values[$EndIndex]['Time'] < $EndTime3) $EndIndex = $EndIndex + 1;
    412393            $SubValues = array_slice($Values, $StartIndex, $EndIndex - $StartIndex + 1);
    413             //echo($StartIndex.','.$EndIndex.' '.count($SubValues).'<br>');
    414             //print_r($SubValues);
    415394            if(count($SubValues) > 2)
    416395            {
    417396              $Point = $this->ComputeOneValue($StartTime3, $EndTime3, $SubValues, $Level);
    418397              $Continuity = $SubValues[1]['Continuity'];
    419               $this->Database->insert($this->Data['DataTable'], array('Level' => $Level, 'Measure' => $this->Data['Id'], 'Min' => $Point['Min'], 'Avg' => $Point['avg'], 'max' => $Point['Max'], 'Continuity' => $Continuity, 'Time' => $this->Database->TimeToMysqlDateTime($StartTime3 + ($EndTime3 - $StartTime3) / 2)));
     398              $this->Database->insert($this->Data['DataTable'], array('Level' => $Level,
     399                'Measure' => $this->Data['Id'], 'Min' => $Point['Min'], 'Avg' => $Point['avg'],
     400                'max' => $Point['Max'], 'Continuity' => $Continuity, 'Time' =>
     401                TimeToMysqlDateTime($StartTime3 + ($EndTime3 - $StartTime3) / 2)));
    420402            }
    421403            $StartIndex = $EndIndex - 1;
  • trunk/Modules/TimeMeasure/TimeMeasure.php

    r655 r656  
    3030    $this->System->RegisterPage('grafy', 'PageMeasure');
    3131    $this->System->RegisterPage(array('grafy', 'graf.png'), 'PageGraph');
     32    $this->System->RegisterPage(array('grafy', 'add.php'), 'PageMeasureAddValue');
    3233    $this->System->FormManager->RegisterClass('Measure', array(
    3334      'Title' => 'Měření',
Note: See TracChangeset for help on using the changeset viewer.