49 lines
1.3 KiB
C#
49 lines
1.3 KiB
C#
///
|
|
/// Copyright (c) 2017 Sensus Metering Systems
|
|
///
|
|
using System.Net;
|
|
using log4net;
|
|
|
|
namespace TBF.BenchControl.Network.Adapter
|
|
{
|
|
public class Netadapter : ComponentBase, GenericDevices.INetworkAdapter
|
|
{
|
|
private static readonly ILog log = LogManager.GetLogger(typeof(Netadapter));
|
|
public override string ToString()
|
|
{
|
|
return string.Format("Component={0} IPAddress={1} NetMask={2} Description={3}", Cfg.Name, IPAddress, NetMask, (Cfg as NetadapterCfg).Description);
|
|
}
|
|
|
|
public bool Running { get { return running; } }
|
|
bool running;
|
|
|
|
readonly NetadapterCfg netadapterCfg;
|
|
readonly IPAddress ipAddress;
|
|
readonly IPAddress netMask;
|
|
readonly IPAddress broadcastAddress;
|
|
|
|
public IPAddress IPAddress { get { return ipAddress; } }
|
|
public IPAddress NetMask { get { return netMask; } }
|
|
public IPAddress BroadcastAddress { get { return broadcastAddress; } }
|
|
|
|
public Netadapter()
|
|
{
|
|
}
|
|
|
|
public Netadapter(Generic.IComponentCfg cfg)
|
|
: base(cfg)
|
|
{
|
|
netadapterCfg = cfg as NetadapterCfg;
|
|
AdapterInfo.RefreshNetAdaptersInfo();
|
|
AdapterInfo netadapter = AdapterInfo.GetNetAdapter(netadapterCfg.Description);
|
|
ipAddress = netadapter.IPAddress;
|
|
netMask = netadapter.NetMask;
|
|
broadcastAddress = netadapter.GetBroadcastAddress();
|
|
|
|
running = false;
|
|
|
|
log.Debug(this.ToString());
|
|
}
|
|
}
|
|
}
|