HMChannelList.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using System.Collections.Generic;
  2. using System.Xml;
  3. namespace System.Net.HomeMatic {
  4. public abstract class HMChannelList : HMBase {
  5. private List<int> _channels_ise = new List<int>();
  6. public HMChannelList(HMApi Api):base(Api) {
  7. }
  8. public int ChannelCount {
  9. get { return this._channels_ise.Count; }
  10. }
  11. public HMChannelList(HMApi Api, XmlNode Data) : base(Api, Data) {
  12. if(Data.HasChildNodes) {
  13. int c = Data.ChildNodes.Count;
  14. for(int i=0;i< c;i++) {
  15. if(Data.ChildNodes[i].Name == "channel") {
  16. int ise = this.Attr_Int32(Data.ChildNodes[i], "ise_id");
  17. if (ise > 0)
  18. this._channels_ise.Add(ise);
  19. }
  20. }
  21. }
  22. }
  23. public HMChannel[] Channels {
  24. get {
  25. List<HMChannel> res = new List<HMChannel>();
  26. foreach (int id in this._channels_ise) {
  27. if (id > 0) {
  28. HMChannel ch = Api.GetChannel(id);
  29. if (ch != null)
  30. res.Add(ch);
  31. }
  32. }
  33. return res.ToArray();
  34. }
  35. }
  36. public HMDataPoint[] DataPoints {
  37. get {
  38. List<HMDataPoint> res = new List<HMDataPoint>();
  39. foreach (int id in this._channels_ise) {
  40. if (id > 0) {
  41. HMChannel ch = Api.GetChannel(id);
  42. if (ch != null) {
  43. HMDataPoint[] itms = Api.GetDataPointList(ch);
  44. if (itms.Length > 0)
  45. res.AddRange(itms);
  46. }
  47. }
  48. }
  49. return res.ToArray();
  50. }
  51. }
  52. public HMDevice[] Devices {
  53. get {
  54. List<HMDevice> res = new List<HMDevice>();
  55. foreach (int id in this._channels_ise) {
  56. if (id > 0) {
  57. HMChannel ch = Api.GetChannel(id);
  58. if (ch != null) {
  59. if (ch.Device != null && !res.Contains(ch.Device))
  60. res.Add(ch.Device);
  61. }
  62. }
  63. }
  64. return res.ToArray();
  65. }
  66. }
  67. }
  68. }