| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- using System.Xml;
- using System.Collections.Generic;
- using System.ComponentModel;
- namespace System.Net.HomeMatic {
-
- public partial class HMChannel : HMBase {
- protected int _type;
- protected string _address;
- protected HomeMatic.Direction _direction = HomeMatic.Direction.Unknown;
- protected int _parentDevice; // link to iseId
- protected int _index;
- protected string _groupPartner;
- protected bool _aesAvailable;
- protected TransmissionMode _transmissionMode = HomeMatic.TransmissionMode.Default;
- protected bool _visible;
- protected bool _readyConfig;
- protected bool _operate;
- protected HMDevice _device;
- protected HMRoom _room;
- public HMChannel(HMApi Api, HMDevice Device) : base(Api) {
- this._device = Device;
- }
- public HMChannel(HMApi Api, HMDevice Device, XmlNode Data) :base(Api, Data) {
- this._device = Device;
- this.Init(Data);
- }
- [Browsable(true), Category("Device"), Description("")]
- public bool SystemChannel {
- get {
- if (this._device == null)
- return false;
- return this._device.SystemChannel == this._ise_id;
- }
- }
- public void Init(XmlNode Data) {
- //this._name = this.Attr_String(Data, "name");
- //this._ise_id = this.Attr_Int32(Data, "ise_id");
- this._address = this.Attr_String(Data, "address");
- this._direction = this.Attr_Direction(Data, "direction");
- this._parentDevice = this.Attr_Int32(Data, "parent_device");
- this._index = this.Attr_Int32(Data, "index");
- this._groupPartner = this.Attr_String(Data, "group_partner");
- this._aesAvailable = this.Attr_Bool(Data, "aes_available");
- this._transmissionMode = this.Attr_TransmissionMode(Data, "transmission_mode");
- this._visible = this.Attr_Bool(Data, "visible");
- this._readyConfig = this.Attr_Bool(Data, "ready_config");
- this._operate = this.Attr_Bool(Data, "operate");
- }
- [Browsable(true), Category("Channel"), Description("")]
- public int Type {
- get { return this._type; }
- }
- [Browsable(true), Category("Channel"), Description("")]
- public string Address {
- get { return this._address; }
- }
- [Browsable(true), Category("Channel"), Description("")]
- public HomeMatic.Direction Direction {
- get { return this._direction; }
- }
- [Browsable(true), Category("Device"), Description("")]
- public int ParentDevice {
- get { return this._parentDevice; }
- }
- [Browsable(true), Category("Channel"), Description("")]
- public int Index {
- get { return this._index; }
- }
- [Browsable(true), Category("Group"), Description("")]
- public string GroupPartner {
- get { return this._groupPartner; }
- }
- [Browsable(true), Category("Security"), Description("")]
- public bool AES_Available {
- get { return this._aesAvailable; }
- }
- [Browsable(true), Category("Channel"), Description("")]
- public HomeMatic.TransmissionMode TransmissionMode {
- get { return this._transmissionMode; }
- }
- [Browsable(true), Category("Channel"), Description("")]
- public bool Visible {
- get { return this._visible; }
- }
- [Browsable(true), Category("Channel"), Description("")]
- public bool ReadyConfig {
- get { return this._readyConfig; }
- }
- [Browsable(true), Category("Channel"), Description("")]
- public bool Operate {
- get { return this._operate; }
- }
- [Browsable(true), Category("Device"), Description("")]
- public HMDevice Device {
- get { return this._device; }
- }
- [Browsable(true), Category("Device"), Description("")]
- public string DeviceName {
- get {
- if (this._device != null)
- return this._device.Name;
- return "";
- }
- }
- [Browsable(true), Category("Room"), Description("")]
- public HMRoom Room {
- get { return this._room; }
- }
- public HMDataPoint GetDataPoint(string Name) {
- HMDataPoint[] dps = Api.GetDataPointList(this);
- foreach(HMDataPoint dp in dps) {
- if(dp.Channel.IseID == this._ise_id) {
- if(dp.Name == Name) {
- return dp;
- }
- }
- }
- return null;
- }
- public HMDataPoint GetDataPoint(int IseID) {
- HMDataPoint[] dps = Api.GetDataPointList(this);
- foreach (HMDataPoint dp in dps) {
- if (dp.Channel.IseID == this._ise_id) {
- if (dp.IseID == IseID) {
- return dp;
- }
- }
- }
- return null;
- }
- [Browsable(true), Category("DataPoint"), Description("")]
- public string Value {
- get {
- HMDataPoint[] dps = Api.GetDataPointList(this);
- foreach(HMDataPoint dp in dps) {
- if(dp.DataType == DataPoint_Type.State) {
- return dp.Value;
- }
- }
- return null;
- }
- set {
- HMDataPoint[] dps = Api.GetDataPointList(this);
- foreach (HMDataPoint dp in dps) {
- if (dp.DataType == DataPoint_Type.State) {
- dp.Value = value;
- }
- }
- }
- }
- public HMDataPoint GetDataPoint(DataPoint_Type _type) {
- //System.Diagnostics.Debug.WriteLine("GetDataPoint("+_type.ToString()+")");
- HMDataPoint[] dps = Api.GetDataPointList(this);
- //System.Diagnostics.Debug.WriteLine(" count: "+dps.Length.ToString());
- int counter = 0;
- foreach (HMDataPoint dp in dps) {
- counter++;
- //System.Diagnostics.Debug.WriteLine(" [" + counter.ToString()+"]");
- //System.Diagnostics.Debug.WriteLine(" ise: " + dp.IseID);
- //System.Diagnostics.Debug.WriteLine(" name: " + dp.Name);
- //System.Diagnostics.Debug.WriteLine(" type: " + dp.DataType.ToString());
- if (dp.Channel.IseID == this._ise_id) {
- if (dp.DataType == _type) {
- return dp;
- }
- }
- }
- return null;
- }
- private HMDataPoint[] _datapointList;
- private bool _initDatapointList = false;
- [Browsable(true), Category("DataPoint"), Description("")]
- public HMDataPoint[] DataPoints {
- get {
- if (this._initDatapointList == false)
- this.InitDataPointList();
- return this._datapointList;
- }
- }
- private void InitDataPointList() {
- List<HMDataPoint> res = new List<HMDataPoint>();
- foreach (HMDataPoint dp in this._api.DataPoints) {
- if (dp.Channel.IseID == this._ise_id) {
- res.Add(dp);
- }
- }
- this._datapointList = res.ToArray();
- this._initDatapointList = true;
- }
- public void UpdateDataPoints() {
- this.InitDataPointList();
- }
- [Browsable(true), Category("Device"), Description("")]
- public DeviceInfo Info {
- get { return this.Device.Info; }
- }
- protected override string GetClassName() {
- return "HMChannel";
- }
- protected override string ValuesToString() {
- return this._type.ToString() + ";" +
- this._address + ";" +
- this.GetDirection_To_String(this._direction) + ";" +
- this._index.ToString() + ";" +
- this._groupPartner + ";" +
- (this._aesAvailable ? "true" : "false") + ";" +
- this.GetTransmissionMode_To_String(this._transmissionMode) + ";" +
- (this._visible ? "true" : "false") + ";" +
- (this._readyConfig ? "true" : "false") + ";" +
- (this._operate ? "true" : "false") + ";";
- }
- }
- }
|