public Nic(string name, ISettings Settings, int index, NicGroup nicGroup) : base(name, new Identifier("NIC", index.ToString(CultureInfo.InvariantCulture)), Settings) { settings = Settings; nicIndex = index; networkInterface = nicGroup.NetworkInterfaces[index]; presentBootTime = DateTime.Now.AddMilliseconds(-(double)Environment.TickCount); dataUploaded = new Sensor("Data Uploaded", 2, SensorType.Data, this, settings); ActivateSensor(dataUploaded); dataDownloaded = new Sensor("Data Downloaded", 3, SensorType.Data, this, settings); ActivateSensor(dataDownloaded); uploadSpeed = new Sensor("Upload Speed", 7, SensorType.Throughput, this, settings); ActivateSensor(uploadSpeed); downloadSpeed = new Sensor("Download Speed", 8, SensorType.Throughput, this, settings); ActivateSensor(downloadSpeed); networkUtilization = new Sensor("Network Utilization", 1, SensorType.Load, this, settings); ActivateSensor(networkUtilization); bytesUploaded = NetworkInterface.GetIPStatistics().BytesSent; bytesDownloaded = NetworkInterface.GetIPStatistics().BytesReceived; latesTime = DateTime.Now; }
public Nic(string name, ISettings Settings, int index, NicGroup nicGroup) : base(name, new Identifier("NIC", index.ToString(CultureInfo.InvariantCulture)), Settings) { settings = Settings; nicIndex = index; nic = nicGroup.NicArr[index]; totalBytesDownloaded = Convert.ToInt64(settings.GetValue("TotalDownloadedBeforeLastBoot" + nic.Name, "-1")); totalBytesUploaded = Convert.ToInt64(settings.GetValue("TotalUploadedBeforeLastBoot" + nic.Name, "-1")); if (totalBytesDownloaded == -1) { settings.SetValue("TotalDownloadedBeforeLastBoot" + nic.Name, "0"); settings.SetValue("TotalUploadedBeforeLastBoot" + nic.Name, "0"); totalBytesDownloaded = 0; totalBytesUploaded = 0; } presentBootTime = DateTime.Now.AddMilliseconds(-(double)Environment.TickCount); string lastBootTime = settings.GetValue("lastBootTime" + nic.Name, "-1"); if (lastBootTime == string.Format("{0:g}", presentBootTime)) { shouldTotalFlowUpdate = false; } connectionSpeed = new Sensor("Connection Speed", 0, SensorType.Throughput, this, settings); ActivateSensor(connectionSpeed); dataUploaded = new Sensor("Data Uploaded", 2, SensorType.Data, this, settings); ActivateSensor(dataUploaded); dataDownloaded = new Sensor("Data Downloaded", 3, SensorType.Data, this, settings); ActivateSensor(dataDownloaded); totalDataDownloaded = new Sensor("Total Data Downloaded in Static", 5, SensorType.Data, this, settings); ActivateSensor(totalDataDownloaded); totalDataUploaded = new Sensor("Total Data Uploaded in Static", 4, SensorType.Data, this, settings); ActivateSensor(totalDataUploaded); totalDataFlowed = new Sensor("Total Data Flowed in Static", 6, SensorType.Data, this, settings); ActivateSensor(totalDataFlowed); uploadSpeed = new Sensor("Upload Speed", 7, SensorType.Throughput, this, settings); ActivateSensor(uploadSpeed); downloadSpeed = new Sensor("Download Speed", 8, SensorType.Throughput, this, settings); ActivateSensor(downloadSpeed); networkUtilization = new Sensor("Network Utilization", 1, SensorType.Load, this, settings); ActivateSensor(networkUtilization); bytesUploaded = nic.GetIPStatistics().BytesSent; bytesDownloaded = nic.GetIPStatistics().BytesReceived; latesTime = DateTime.Now; }