public void Dispose() { if (timer != null) this.timer.Stop(); this.timer = null; this.device = null; this.value = 0; this.fluctuation = 0; }
public RandomDataDevice(Client client, Objects.Device device) { if (device == null || client == null) return; this.client = client; this.device = device; Util.DeviceConfigurationAdapter adapter = Util.DeviceConfigurationAdapter.CreateAdapter(device.Configuration); try { this.value = Convert.ToDouble(adapter.Settings["value"]); this.fluctuation = Convert.ToDouble(adapter.Settings["fluctuation"]); this.interval = Convert.ToDouble(adapter.Settings["interval"]); } catch { } this.timer = new Timer(interval); this.timer.Elapsed += new ElapsedEventHandler(timer_Elapsed); this.timer.Start(); }