Changeset 921 for trunk/Modules/Network
- Timestamp:
- Feb 25, 2022, 9:30:55 AM (3 years ago)
- Location:
- trunk/Modules/Network
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Network/Network.php
r917 r921 120 120 NetworkDomain::GetClassName(), NetworkDomainServer::GetClassName(), NetworkDomainView::GetClassName(), 121 121 NetworkDomainItemFilter::GetClassName(), DeviceAPIType::GetClassName(), NetworkInterfaceWireless::GetClassName(), 122 NetworkInterfaceUpDown::GetClassName(), NetworkPortUpDown::GetClassName() );122 NetworkInterfaceUpDown::GetClassName(), NetworkPortUpDown::GetClassName(), NetworkMac::GetClassName()); 123 123 124 124 // TODO: Make notify time configurable … … 380 380 'Items' => array( 381 381 'Time' => array('Type' => 'DateTime', 'Caption' => 'Čas', 'Default' => ''), 382 'MAC' => array('Type' => ' MacAddress', 'Caption' => 'Fyzická adresa (MAC)', 'Default' => ''),382 'MAC' => array('Type' => 'TNetworkMac', 'Caption' => 'Fyzická adresa (MAC)', 'Default' => ''), 383 383 'Interface' => array('Type' => 'TNetworkInterface', 'Caption' => 'Rozhraní', 'Default' => '', 'Null' => true), 384 384 'Value' => array('Type' => 'Integer', 'Caption' => 'Signál', 'Default' => '0', 'Suffix' => 'dBm'), … … 608 608 'Duration' => array('Type' => 'TimeDiff', 'Caption' => 'Trvání', 'Default' => '', 'ReadOnly' => true), 609 609 ), 610 )); 611 $this->System->FormManager->RegisterClass('NetworkMac', array( 612 'Title' => 'Fyzická síťová adresa', 613 'Table' => 'NetworkMac', 614 'Items' => array( 615 'MAC' => array('Type' => 'String', 'Caption' => 'Fyzická adresa', 'Default' => ''), 616 'Signal' => array('Type' => 'TNetworkSignalListMac', 'Caption' => 'Signál rozhraní', 'Default' => ''), 617 ), 618 )); 619 $this->System->FormManager->RegisterFormType('TNetworkMac', array( 620 'Type' => 'Reference', 621 'Table' => 'NetworkMac', 622 'Id' => 'Id', 623 'Name' => 'MAC', 624 'Filter' => '1', 625 )); 626 $this->System->FormManager->RegisterFormType('TNetworkSignalListMac', array( 627 'Type' => 'ManyToOne', 628 'Table' => 'NetworkSignal', 629 'Id' => 'Id', 630 'Ref' => 'Mac', 631 'Filter' => '1', 610 632 )); 611 633 $this->System->FormManager->RegisterFormType('TNetworkProtocol', array( -
trunk/Modules/Network/NetworkModels.php
r911 r921 192 192 $Desc = new ModelDesc(self::GetClassName()); 193 193 $Desc->AddDateTime('Time'); 194 $Desc->Add String('MAC');194 $Desc->AddReference('MAC', NetworkMac::GetClassName()); 195 195 $Desc->AddReference('Interface', NetworkInterface::GetClassName()); 196 196 $Desc->AddInteger('Value'); … … 342 342 } 343 343 } 344 345 class NetworkMac extends Model 346 { 347 static function GetModelDesc(): ModelDesc 348 { 349 $Desc = new ModelDesc(self::GetClassName()); 350 $Desc->AddString('MAC'); // size=17 351 return $Desc; 352 } 353 354 function GetIndex(string $MAC) 355 { 356 $DbResult = $this->Database->select('NetworkMac', 'Id', 'MAC="'.$MAC.'"'); 357 if ($DbResult->num_rows > 0) 358 { 359 $DbRow = $DbResult->fetch_assoc(); 360 return $DbRow['Id']; 361 } else 362 { 363 return $this->Database->insert('NetworkMac', array('MAC' => $MAC)); 364 } 365 } 366 }
Note:
See TracChangeset
for help on using the changeset viewer.