HMProgram.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. using System.Xml;
  2. namespace System.Net.HomeMatic {
  3. public class HMProgram : HMElement {
  4. private int _id;
  5. private string _name;
  6. private bool _active;
  7. private int _timestamp;
  8. private string _description;
  9. private bool _visible;
  10. private bool _operate;
  11. public HMProgram(HMApi Api) : base(Api) {
  12. }
  13. public HMProgram(HMApi Api, XmlNode Data) : base(Api) {
  14. this.Init(Data);
  15. }
  16. private void Init(XmlNode Data) {
  17. this._id = this.Attr_Int32(Data, "id");
  18. this._name = this.Attr_String(Data, "name");
  19. this._active = this.Attr_Bool(Data, "active");
  20. this._timestamp = this.Attr_Int32(Data, "timestamp");
  21. this._description = this.Attr_String(Data, "description");
  22. this._visible = this.Attr_Bool(Data, "visible");
  23. this._operate = this.Attr_Bool(Data, "operate");
  24. }
  25. public int ID {
  26. get { return this._id; }
  27. }
  28. public string Name {
  29. get { return this._name; }
  30. }
  31. public bool Active {
  32. get { return this._active; }
  33. }
  34. public int TimeStamp {
  35. get { return this._timestamp; }
  36. }
  37. public string Description {
  38. get { return this._description; }
  39. }
  40. public bool Visible {
  41. get { return this._visible; }
  42. }
  43. public bool Operate {
  44. get { return this._operate; }
  45. }
  46. public void Run() {
  47. this._api.GetApiData(ApiMethode.RunProgram, new Collections.Generic.Dictionary<string, object>() {
  48. ["program_id"] = this._id
  49. });
  50. }
  51. /*public override bool Equals(object o) {
  52. if (o == null) return false;
  53. if (((HMProgram)o).ID == this._id)
  54. return true;
  55. else
  56. return false;
  57. }
  58. public static bool operator ==(HMProgram c1, HMProgram c2) {
  59. if (c1 == null || c2 == null) return c1 == null && c2 == null;
  60. return c1.Equals(c2);
  61. }
  62. public static bool operator !=(HMProgram c1, HMProgram c2) {
  63. if (c1 == null || c2 == null) return (c1 != null || c2 != null);
  64. return !c1.Equals(c2);
  65. }*/
  66. public override string ToString() {
  67. return "[System.Net.HomeMatic.HMProgram[" + this.ValuesToString() + "]]";
  68. }
  69. private string ValuesToString() {
  70. return this._id.ToString() + ";" +
  71. this._name + ";" +
  72. (this._active ? "true" : "false") + ";" +
  73. this._timestamp.ToString() + ";" +
  74. this._description + ";" +
  75. (this._visible ? "true" : "false") + ";" +
  76. (this._operate ? "true" : "false") + ";";
  77. }
  78. public override int GetHashCode() {
  79. return this.ToString().GetHashCode();
  80. }
  81. }
  82. }