| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- using System.Xml;
- namespace System.Net.HomeMatic {
- public class HMRSSI : HMElement {
- //device="PEQ0470160" rx="-75" tx="-67"
- private HMDevice _device;
- private string _deviceString;
- private int _rx;
- private int _tx;
- /*public override bool Equals(object o) {
- if (o == null) return false;
- if (((HMRSSI)o).Device.IseID == this._device.IseID)
- return true;
- else
- return false;
- }
- public static bool operator ==(HMRSSI c1, HMRSSI c2) {
- if (c1 == null || c2 == null) return c1 == null && c2 == null;
- return c1.Equals(c2);
- }
- public static bool operator !=(HMRSSI c1, HMRSSI c2) {
- if (c1 == null || c2 == null) return (c1 != null || c2 != null);
- return !c1.Equals(c2);
- }*/
- public override string ToString() {
- return "[System.Net.HomeMatic.HMRSSI[" + this.ValuesToString() + "]]";
- }
- private string ValuesToString() {
- return this._device.IseID + ";" +
- this._deviceString + ";" +
- this._rx.ToString() + ";" +
- this._tx.ToString() + ";";
- }
- public HMRSSI(HMApi Api, HMDevice Device):base(Api) {
- this._device = Device;
- //this._deviceString = this._device;
- //this.Update();
- }
- public HMRSSI(HMApi Api, HMDevice Device, XmlNode Data) : base(Api) {
- this._device = Device;
- this.Init(Data);
- }
- public HMRSSI(HMApi Api, HMDevice Device, string DeviceName) : base(Api) {
- this._device = Device;
- }
- public HMDevice Device {
- get { return this._device; }
- }
- public string DeviceString {
- get { return this.DeviceString; }
- }
- public int RX {
- get {
- if (this.UpdateRequired())
- this.Update();
- return this._rx;
- }
- }
- public int TX {
- get {
- if (this.UpdateRequired())
- this.Update();
- return this._tx;
- }
- }
- private void Init(XmlNode Data) {
- this._deviceString = this.Attr_String(Data, "device");
- this._rx = this.Attr_Int32(Data, "rx");
- this._tx = this.Attr_Int32(Data, "tx");
- this.lastUpdate = DateTime.Now;
- }
- private DateTime lastUpdate;
- private bool UpdateRequired() {
- return DateTime.Now.Ticks - this.lastUpdate.Ticks > 10000000;
- }
- public void Update() {
- if (this._deviceString == "")
- return;
- XmlDocument doc = this._api.GetApiData(ApiMethode.RSSIList);
- XmlNodeList childs = doc.ChildNodes[1].ChildNodes;
- int c = childs.Count;
- if (c > 0) {
- for (int i = 0; i < c; i++) {
- if (childs[i].Name == "rssi") {
- string xname = this.Attr_String(childs[i], "device");
- if (xname == this._deviceString) {
- this.Init(childs[i]);
- }
- }
- }
- }
- }
- }
- }
|