Changeset 674


Ignore:
Timestamp:
Jul 21, 2014, 11:09:35 PM (10 years ago)
Author:
chronos
Message:
  • Přidáno: Zprovozněno měření signálu přes RouterOS API.
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/FormClasses.php

    r673 r674  
    772772    'Filter' => '1',
    773773  ),
     774  'TNetworkSignalListInterface' => array(
     775    'Type' => 'ManyToOne',
     776    'Table' => 'NetworkSignal',
     777    'Id' => 'Id',
     778    'Ref' => 'Interface',
     779    'Filter' => '1',
     780  ),
    774781        'TFinanceInvoiceItemListInvoice' => array(
    775782    'Type' => 'ManyToOne',
  • trunk/Application/Version.php

    r673 r674  
    11<?php
    22
    3 $Revision = 673; // Subversion revision
    4 $DatabaseRevision = 671; // SQL structure revision
    5 $ReleaseTime = strtotime('2014-07-19');
     3$Revision = 674; // Subversion revision
     4$DatabaseRevision = 674; // SQL structure revision
     5$ReleaseTime = strtotime('2014-07-22');
  • trunk/Common/Setup/Updates.php

    r671 r674  
    832832  $Manager->Execute('ALTER TABLE `NetworkDevice` ADD FOREIGN KEY ( `API` ) REFERENCES `DeviceAPIType` (
    833833`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT ;');
    834 
     834}
     835
     836function UpdateTo674($Manager)
     837{
     838  $Manager->Execute('ALTER TABLE `NetworkSignal` ADD `RateRx` INT NOT NULL ;');
     839  $Manager->Execute('ALTER TABLE `NetworkSignal` ADD `RateTx` INT NOT NULL ;');
    835840}
    836841
     
    879884      662 => array('Revision' => 668, 'Function' => 'UpdateTo668'),
    880885      668 => array('Revision' => 671, 'Function' => 'UpdateTo671'),
     886      671 => array('Revision' => 674, 'Function' => 'UpdateTo674'),
    881887    ));
    882888  }
  • trunk/Modules/Network/Network.php

    r671 r674  
    188188        'Links2' => array('Type' => 'TNetworkLinkListInterface2', 'Caption' => 'Propojení 2', 'Default' => ''),
    189189        'UpDown' => array('Type' => 'TNetworkInterfaceUpDown', 'Caption' => 'Změny stavu', 'Default' => ''),
     190        'Signal' => array('Type' => 'TNetworkSignalListInterface', 'Caption' => 'Signál', 'Default' => ''),
    190191      ),
    191192    ));
     
    237238        'MAC' => array('Type' => 'MacAddress', 'Caption' => 'Fyzická adresa (MAC)', 'Default' => ''),
    238239        'Interface' => array('Type' => 'TNetworkInterface', 'Caption' => 'Rozhraní', 'Default' => '', 'Null' => true),
    239         'Value' => array('Type' => 'Integer', 'Caption' => 'Signál', 'Default' => '0'),
     240        'Value' => array('Type' => 'Integer', 'Caption' => 'Signál', 'Default' => '0', 'Suffix' => 'dBm'),
     241        'RateRx' => array('Type' => 'Integer', 'Caption' => 'Rychlost', 'Default' => '0', 'Suffix' => 'MHz'),
     242        'RateTx' => array('Type' => 'Integer', 'Caption' => 'Rychlost', 'Default' => '0', 'Suffix' => 'MHz'),
    240243      ),
    241244    ));
  • trunk/Modules/NetworkConfigRouterOS/Generators/Signal.php

    r671 r674  
    1919    echo('Waiting '.$Delay.' seconds...'."\n");
    2020    sleep($Delay);
    21   }      print_r($Properties);
    22 
     21  }
    2322}
    2423
     
    3736  {
    3837    echo($Device['LocalIP']."\n");
    39     $Routerboard = new Routerboard();
    40     $Routerboard->UserName = $Config['MainRouter']['UserName'];
    41     $Routerboard->Timeout = $Config['MainRouter']['ConnectTimeout'];
    42     $Routerboard->HostName = $Device['LocalIP'];
    43     $Routerboard->Debug = true;
    44     $List = $Routerboard->ListGetPrint($Path, array('mac-address', 'signal-strength'), array(), 'stats');
    45     foreach($List as $Properties)
     38    $Routerboard = new RouterosAPI();
     39    $Routerboard->Connect($Device['LocalIP'], $Config['API']['UserName'], $Config['API']['Password']);
     40    $Routerboard->Write('/interface/wireless/registration-table/getall', false);
     41    $Routerboard->Write('=.proplist=signal-strength,mac-address,rx-rate,tx-rate', false);
     42    $Routerboard->Write('=stats=');
     43    $Read = $Routerboard->Read(false);
     44    $Array = $Routerboard->ParseResponse($Read);
     45    foreach($Array as $Properties)
    4646    {
    47       print_r($Properties);
    4847      $DbResult = $System->Database->select('NetworkInterface', 'Id', 'MAC="'.$Properties['mac-address'].'"');
    4948      if($DbResult->num_rows > 0)
     
    5251        $Interface = $DbRow['Id'];
    5352      } else $Interface = null;
     53
     54      $Parts = explode('@', $Properties['signal-strength']);
     55      $Strength = substr($Parts[0], 0, -3); // without dBm
     56      $RateRx = substr($Properties['rx-rate'], 0, -3); // without MHz
     57      $RateTx = substr($Properties['tx-rate'], 0, -3); // without MHz
    5458      $System->Database->insert('NetworkSignal', array('MAC' => $Properties['mac-address'],
    55         'Value' => $Properties['signal-strength'], 'Time' => $Time, 'Interface' => $Interface));
     59        'Value' => $Strength, 'RateRx' => $RateRx, 'RateTx' => $RateTx,
     60        'Time' => TimeToMysqlDateTime($Time), 'Interface' => $Interface));
    5661      /*
    5762      $DbResult = $System->Database->select('Measure', 'Id', '`Name` = "'.$Properties['mac-address'].'"');
     
    7277}
    7378
    74 RepeatFunction(60, 'ReadWirelessRegistration');
     79RepeatFunction(60 * 60, 'ReadWirelessRegistration');
  • trunk/Modules/NetworkConfigRouterOS/NetworkConfigRouterOS.php

    r673 r674  
    22
    33include_once(dirname(__FILE__).'/Routerboard.php');
     4include_once(dirname(__FILE__).'/RouterboardAPI.php');
    45include_once(dirname(__FILE__).'/Generators/Common.php');
    56
  • trunk/Modules/NetworkConfigRouterOS/RouterboardAPI.php

    r671 r674  
    1111  var $Timeout;        // Connection attempt timeout and data read timeout
    1212  var $Socket;             // Variable for storing socket resource
     13  var $Debug;
    1314
    1415  function __construct()
     
    1920    $this->Port = 8728;
    2021    $this->Timeout = 3;
     22    $this->Debug = false;
    2123  }
    2224
     
    182184        $Response[] = $Line;
    183185      }
    184       echo($Line."\n");
     186      if($this->Debug) echo($Line);
    185187      // If we get a !done, make a note of it.
    186188      if ($Line == "!done") $ReceivedDone = true;
Note: See TracChangeset for help on using the changeset viewer.