Exemplo n.º 1
0
 virtual public void SendPropertyValue(IAdapterProperty property, IAdapterValue value)
 {
     if (value.Name == "Command")
     {
         _conn.SendCmd((string)value.Data);
     }
 }
Exemplo n.º 2
0
        public uint SetPropertyValue(IAdapterProperty Property, IAdapterValue Value, out IAdapterIoRequest RequestPtr)
        {
            RequestPtr = null;

            // find corresponding attribute
            foreach (var attribute in ((AdapterProperty)Property).Attributes)
            {
                if (attribute.Value.Name == Value.Name)
                {
                    string path   = "devices/" + ((AdapterValue)attribute.Value).Path + "/state";
                    uint   status = this.SetHttpValue(path, attribute.Value.Data, attribute.Value.Name);
                    if (status == 0)
                    {
                        attribute.Value.Data = Value.Data;

                        IAdapterDevice adapterDevice = null;
                        this.devicesDict.TryGetValue(((AdapterValue)Value).Path, out adapterDevice);

                        int SignalHashCode = ((AdapterValue)attribute.Value).SignalHashCode;

                        IAdapterSignal covSignal = null;
                        ((AdapterDevice)adapterDevice).SignalsDict.TryGetValue(SignalHashCode, out covSignal);

                        this.NotifySignalListener(covSignal);
                    }

                    return(ERROR_SUCCESS);
                }
            }
            return(ERROR_INVALID_HANDLE);
        }
Exemplo n.º 3
0
 public void SendPropertyValue(IAdapterProperty Property, IAdapterValue Value)
 {
     if (Value.Name == "OnOff")
     {
         if (Convert.ToBoolean(Value.Data))
         {
             _conn.SendCommand(Onkyo.Command.Power.On());
         }
         else
         {
             _conn.SendCommand(Onkyo.Command.Power.Off());
         }
     }
     else if (Value.Name == "MasterVolume")
     {
         _conn.SendCommand(Onkyo.Command.MasterVolume.SetLevel((int)Value.Data));
     }
     else if (Value.Name == "Input")
     {
         Onkyo.EInputSelector input = Onkyo.EnumExtensions.FromDescription <Onkyo.EInputSelector>(Value.Data as string);
         _conn.SendCommand(Onkyo.Command.InputSelector.Chose(input));
     }
     else if (Value.Name == "Mute")
     {
         _conn.SendCommand(Onkyo.Command.AudioMuting.Chose((bool)Value.Data));
     }
     else if (Value.Name == "ListeningMode")
     {
         Onkyo.EListeningMode mode = Onkyo.EnumExtensions.FromDescription <Onkyo.EListeningMode>(Value.Data as string);
         _conn.SendCommand(Onkyo.Command.ListeningMode.Chose(mode));
     }
 }
Exemplo n.º 4
0
 override public void SendPropertyValue(IAdapterProperty property, IAdapterValue value)
 {
     if (value.Name == "OnOff")
     {
         _conn.Action(this.SwitchAddr, "1.001", (bool)value.Data);
     }
 }
Exemplo n.º 5
0
        public uint SetPropertyValue(IAdapterProperty Property, IAdapterValue Value, IAdapterSignal covSignal)
        {
            // find corresponding attribute
            foreach (var attribute in ((AdapterProperty)Property).Attributes)
            {
                if (attribute.Value.Name == Value.Name)
                {
                    //this.SetHttpValue(((AdapterValue)attribute.Value).Path, attribute.Value.Data, attribute.Value.Name);
                    attribute.Value.Data = Value.Data;

                    foreach (IAdapterValue param in covSignal.Params)
                    {
                        if (param.Name == Constants.COV__ATTRIBUTE_HANDLE)
                        {
                            IAdapterValue valueAttr_Value = (IAdapterValue)param.Data;
                            if (valueAttr_Value.Name == Value.Name)
                            {
                                param.Data = Value.Data;
                                NotifySignalListener(covSignal);
                            }
                        }
                    }

                    return(ERROR_SUCCESS);
                }
            }
            return(ERROR_INVALID_HANDLE);
        }
Exemplo n.º 6
0
        public uint SetPropertyValue(
            IAdapterProperty Property,
            IAdapterValue Value,
            out IAdapterIoRequest RequestPtr)
        {
            RequestPtr = null;

            // sanity check
            if (Property == null)
            {
                return(ERROR_INVALID_PARAMETER);
            }

            // cast back IAdapterProperty to ZclCluster
            ZclCluster cluster = (ZclCluster)Property;

            // look for the attribute and write new data
            foreach (var item in cluster.InternalAttributeList)
            {
                var attribute = item.Value;
                if (attribute.Value.Name == Value.Name)
                {
                    if (attribute.Write(Value.Data))
                    {
                        return(ERROR_SUCCESS);
                    }
                    else
                    {
                        return((uint)ZclHelper.ZigBeeStatusToHResult(attribute.Status));
                    }
                }
            }

            return(ERROR_NOT_SUPPORTED);
        }
Exemplo n.º 7
0
        public uint GetPropertyValue(
            IAdapterProperty Property,
            string AttributeName,
            out IAdapterValue ValuePtr,
            out IAdapterIoRequest RequestPtr)
        {
            ValuePtr   = null;
            RequestPtr = null;

            // find corresponding attribute
            foreach (var attribute in Property.Attributes)
            {
                if (attribute.Value.Name == AttributeName)
                {
                    //Read from Modbus Device
                    ((ModbusSensorAttribute)attribute).ReadAsync().Wait();
                    ValuePtr = attribute.Value;

                    //Send signals if needed
                    if (AttributeName == "Temperature" && previousTempValue != (double)ValuePtr.Data)
                    {
                        if (previousTempValue != -100.0)
                        {
                            tempValueChangeEventHandler();
                        }
                        previousTempValue = (double)ValuePtr.Data;
                    }
                    return(ERROR_SUCCESS);
                }
            }

            return(ERROR_INVALID_HANDLE);
        }
Exemplo n.º 8
0
        internal void AddChangeOfValueSignal(
            IAdapterProperty Property,
            IAdapterValue Attribute)
        {
            try
            {
                AdapterSignal covSignal = new AdapterSignal(Constants.CHANGE_OF_VALUE_SIGNAL);

                // Property Handle
                AdapterValue propertyHandle = new AdapterValue(
                    Constants.COV__PROPERTY_HANDLE,
                    Property);

                // Attribute Handle
                AdapterValue attrHandle = new AdapterValue(
                    Constants.COV__ATTRIBUTE_HANDLE,
                    Attribute);

                covSignal.Params.Add(propertyHandle);
                covSignal.Params.Add(attrHandle);

                this.Signals.Add(covSignal);
            }
            catch (OutOfMemoryException ex)
            {
                throw;
            }
        }
Exemplo n.º 9
0
        override public uint SetPropertyValue(IAdapterProperty Property, IAdapterValue Value, out IAdapterIoRequest RequestPtr)
        {
            RequestPtr = null;

            ((BridgeAdapterProperty <KnxDevice>)Property).Device.SendPropertyValue(Property, Value);

            return(ERROR_SUCCESS);
        }
Exemplo n.º 10
0
 override public void SendPropertyValue(IAdapterProperty property, IAdapterValue value)
 {
     if (value.Name == "Position")
     {
         _conn.Action(this.PositionAddr, "5.001", (int)value.Data);
     }
     else if (value.Name == "Flaps")
     {
         _conn.Action(this.FlapsAddr, "5.001", (int)value.Data);
     }
 }
Exemplo n.º 11
0
 override public void SendPropertyValue(IAdapterProperty property, IAdapterValue value)
 {
     if (value.Name == "OpMode")
     {
         _conn.Action(this.OpModeAddr, "20.102", (int)value.Data);
     }
     else if (value.Name == "TargetTemperature")
     {
         _conn.Action(this.TargetTemperatureAddr, "9.001", (decimal)value.Data);
     }
 }
Exemplo n.º 12
0
        public uint SetPropertyValue(IAdapterProperty Property, IAdapterValue Value, out IAdapterIoRequest RequestPtr)
        {
            RequestPtr = null;

            foreach (var attribute in ((AdapterProperty)Property).Attributes)
            {
                if (attribute.Value.Name == Value.Name)
                {
                    attribute.Value.Data = Value.Data;
                    return(ERROR_SUCCESS);
                }
            }

            return(ERROR_INVALID_HANDLE);
        }
Exemplo n.º 13
0
        public uint NotifyDeviceRemoval(IAdapterDevice Device)
        {
            if (Device == null)
            {
                return(ERROR_INVALID_HANDLE);
            }

            IAdapterSignal deviceRemovalSignal = this.Signals[DEVICE_REMOVAL_SIGNAL_INDEX];
            IAdapterValue  signalParam         = deviceRemovalSignal.Params[DEVICE_REMOVAL_SIGNAL_PARAM_INDEX];

            signalParam.Data = Device;
            this.NotifySignalListener(deviceRemovalSignal);

            return(ERROR_SUCCESS);
        }
Exemplo n.º 14
0
        internal IAdapterValue GetInputParamByName(String name)
        {
            IAdapterValue parameter = null;

            foreach (var value in InputParams)
            {
                if (name == value.Name)
                {
                    // found parameter with matching name
                    parameter = value;
                    break;
                }
            }

            return(parameter);
        }
Exemplo n.º 15
0
        public uint SetPropertyValue(IAdapterProperty Property, IAdapterValue Value, out IAdapterIoRequest RequestPtr)
        {
            RequestPtr = null;

            var r = ((AdapterProperty)Property).Attributes.Where(x => x.Value.Name == Value.Name).First() as BridgeRT.IAdapterAttribute;

            if (r == null)
            {
                return(ERROR_INVALID_HANDLE);
            }
            else
            {
                r.Value.Data = Value.Data;

                AllJoynSet?.Invoke(this, new AllJoynData(r.Value));
                return(ERROR_SUCCESS);
            }
        }
Exemplo n.º 16
0
        internal void Send()
        {
            // set cluster Id
            m_clusterId         = m_cluster.Id;
            m_responseClusterId = m_cluster.Id;

            // add header to payload
            m_payload = new byte[m_zclHeader.Length];
            Array.Copy(m_zclHeader, m_payload, m_zclHeader.Length);

            // add command parameters to payload
            foreach (var item in m_zclInParamList)
            {
                // copy in parameter data from "BridgeRT" in parameter to
                // "internal" ZCL parameter
                IAdapterValue value = GetInputParamByName(item.Name);
                item.Data = value.Data;

                // add parameter in ZCL payload
                byte[] tempBuffer = item.ToByteBuffer();
                if (tempBuffer == null)
                {
                    // can't set current parameter => give up with sending
                    m_zigBeeStatus = ZclHelper.ZCL_ERROR_INVALID_VALUE;
                    HResult        = ZclHelper.ZigBeeStatusToHResult(m_zigBeeStatus);
                    return;
                }

                int previousLength = m_payload.Length;
                Array.Resize(ref m_payload, previousLength + tempBuffer.Length);
                Array.Copy(tempBuffer, 0, m_payload, previousLength, tempBuffer.Length);
            }

            // send command
            m_zigBeeStatus = ZclHelper.ZCL_ERROR_SUCCESS;
            if (!SendCommand(m_cluster.EndPoint.Device.Module, m_cluster.EndPoint.Device, m_cluster.EndPoint))
            {
                m_zigBeeStatus = ZclHelper.ZCL_ERROR_TIMEOUT;
            }
            HResult = ZclHelper.ZigBeeStatusToHResult(m_zigBeeStatus);

            return;
        }
Exemplo n.º 17
0
        public uint SetPropertyValue(
            IAdapterProperty Property,
            IAdapterValue Value,
            out IAdapterIoRequest RequestPtr)
        {
            RequestPtr = null;

            // find corresponding attribute
            foreach (var attribute in Property.Attributes)
            {
                if (attribute.Value.Name == Value.Name)
                {
                    //Write to Modbus Device
                    ((ModbusSensorAttribute)attribute).WriteAsync(Value.Data).Wait();
                    attribute.Value.Data = Value.Data;
                    return(ERROR_SUCCESS);
                }
            }

            return(ERROR_INVALID_HANDLE);
        }
Exemplo n.º 18
0
        internal void AddChangeOfValueSignal(IAdapterProperty Property, IAdapterValue Attribute)
        {
            try
            {
                AdapterSignal covSignal = new AdapterSignal(Constants.CHANGE_OF_VALUE_SIGNAL);

                AdapterValue propertyHandle = new AdapterValue(Constants.COV__PROPERTY_HANDLE, Property);

                AdapterValue attrHandle = new AdapterValue(Constants.COV__ATTRIBUTE_HANDLE, Attribute);

                covSignal.Params.Add(propertyHandle);
                covSignal.Params.Add(attrHandle);

                this.Signals.Add(covSignal);
            }
            catch (OutOfMemoryException ex)
            {
                Debug.WriteLine("Out of memory while trying to change the value of the signal." + ex.Message);
                throw;
            }
        }
Exemplo n.º 19
0
        public uint GetPropertyValue(
            IAdapterProperty Property,
            string AttributeName,
            out IAdapterValue ValuePtr,
            out IAdapterIoRequest RequestPtr)
        {
            ValuePtr   = null;
            RequestPtr = null;

            // find corresponding attribute
            foreach (var attribute in ((AdapterProperty)Property).Attributes)
            {
                if (attribute.Value.Name == AttributeName)
                {
                    ValuePtr = attribute.Value;
                    return(ERROR_SUCCESS);
                }
            }

            return(ERROR_INVALID_HANDLE);
        }
Exemplo n.º 20
0
        internal void AddChangeOfValueSignal(
            IAdapterProperty Property,
            IAdapterValue Attribute)
        {
            try
            {
                AdapterSignal covSignal = new AdapterSignal(Constants.CHANGE_OF_VALUE_SIGNAL);

                // Property Handle
                AdapterValue propertyHandle = new AdapterValue(
                    Constants.COV__PROPERTY_HANDLE,
                    Property);

                // Attribute Handle
                AdapterValue attrHandle = new AdapterValue(
                    Constants.COV__ATTRIBUTE_HANDLE,
                    Attribute);

                covSignal.Params.Add(propertyHandle);
                covSignal.Params.Add(attrHandle);

                this.Signals.Add(covSignal);

                try
                {
                    ((AdapterValue)Attribute).SignalHashCode = covSignal.GetHashCode();
                    this.SignalsDict.Add(covSignal.GetHashCode(), covSignal);
                    //this.SignalsDict.Add(Attribute.GetHashCode().ToString(), covSignal);
                }
                catch (ArgumentException ex)
                {
                    //ex.Message
                    System.Diagnostics.Debug.WriteLine("ex.Message.............." + ex.Message);
                }
            }
            catch (OutOfMemoryException ex)
            {
                throw;
            }
        }
Exemplo n.º 21
0
        public uint GetPropertyValue(
            IAdapterProperty Property,
            string AttributeName,
            out IAdapterValue ValuePtr,
            out IAdapterIoRequest RequestPtr)
        {
            ValuePtr   = null;
            RequestPtr = null;

            // sanity check
            if (Property == null)
            {
                return(ERROR_INVALID_PARAMETER);
            }

            // cast back IAdapterProperty to ZclCluster
            ZclCluster cluster = (ZclCluster)Property;

            // look for the attribute
            foreach (var item in cluster.InternalAttributeList)
            {
                var attribute = item.Value;
                if (attribute.Value.Name == AttributeName)
                {
                    object value;
                    if (attribute.Read(out value))
                    {
                        ValuePtr = attribute.Value;
                        return(ERROR_SUCCESS);
                    }
                    else
                    {
                        return((uint)ZclHelper.ZigBeeStatusToHResult(attribute.Status));
                    }
                }
            }

            return(ERROR_NOT_SUPPORTED);
        }
Exemplo n.º 22
0
 public uint GetPropertyValue(IAdapterProperty Property, string AttributeName, out IAdapterValue ValuePtr, out IAdapterIoRequest RequestPtr)
 {
     return(_adapter.GetPropertyValue(Property, AttributeName, out ValuePtr, out RequestPtr));
 }
Exemplo n.º 23
0
 public uint SetPropertyValue(IAdapterProperty Property, IAdapterValue Value, out IAdapterIoRequest RequestPtr)
 {
     return(_adapter.SetPropertyValue(Property, Value, out RequestPtr));
 }
Exemplo n.º 24
0
        public uint GetPropertyValue(IAdapterProperty Property, string AttributeName, out IAdapterValue ValuePtr, out IAdapterIoRequest RequestPtr)
        {
            ValuePtr   = null;
            RequestPtr = null;

            var r = ((AdapterProperty)Property).Attributes.Where(x => x.Value.Name == AttributeName).First() as BridgeRT.IAdapterAttribute;

            if (r == null)
            {
                return(ERROR_INVALID_HANDLE);
            }
            else
            {
                ValuePtr = r.Value;
                return(ERROR_SUCCESS);
            }
        }
Exemplo n.º 25
0
 public AllJoynData(IAdapterValue Value)
 {
     this.Value = Value;
 }
Exemplo n.º 26
0
        public uint SetPropertyValue(
            IAdapterProperty Property,
            IAdapterValue Value,
            out IAdapterIoRequest RequestPtr)
        {
            RequestPtr = null;

            // find corresponding attribute
            foreach (var attribute in ((AdapterProperty)Property).Attributes)
            {
                if (attribute.Value.Name == Value.Name)
                {
                    attribute.Value.Data = Value.Data;
                    return ERROR_SUCCESS;
                }
            }

            return ERROR_INVALID_HANDLE;
        }
Exemplo n.º 27
0
        virtual public uint GetPropertyValue(IAdapterProperty Property, string AttributeName, out IAdapterValue ValuePtr, out IAdapterIoRequest RequestPtr)
        {
            ValuePtr   = null;
            RequestPtr = null;

            return(ERROR_SUCCESS);
        }
Exemplo n.º 28
0
        public uint SetPropertyValue(IAdapterProperty Property, IAdapterValue Value, out IAdapterIoRequest RequestPtr)
        {
            RequestPtr = null;

            var r = ((AdapterProperty)Property).Attributes.Where(x => x.Value.Name == Value.Name).First() as BridgeRT.IAdapterAttribute;

            if (r == null) { return ERROR_INVALID_HANDLE; }
            else
            {
                r.Value.Data = Value.Data;

                AllJoynSet?.Invoke(this, new AllJoynData(r.Value));
                return ERROR_SUCCESS;
            }
        }
        internal void AddChangeOfValueSignal(
            IAdapterProperty Property,
            IAdapterValue Attribute)
        {
            try
            {
                AdapterSignal covSignal = new AdapterSignal(Constants.CHANGE_OF_VALUE_SIGNAL);

                // Property Handle
                AdapterValue propertyHandle = new AdapterValue(
                                                    Constants.COV__PROPERTY_HANDLE,
                                                    Property);

                // Attribute Handle
                AdapterValue attrHandle = new AdapterValue(
                                                    Constants.COV__ATTRIBUTE_HANDLE,
                                                    Attribute);

                covSignal.Params.Add(propertyHandle);
                covSignal.Params.Add(attrHandle);

                this.Signals.Add(covSignal);
            }
            catch (OutOfMemoryException ex)
            {
                throw;
            }
        }
Exemplo n.º 30
0
        public uint SetPropertyValue(
            IAdapterProperty Property,
            IAdapterValue Value,
            out IAdapterIoRequest RequestPtr)
        {
            RequestPtr = null;

            return ERROR_SUCCESS;
        }
Exemplo n.º 31
0
        public uint GetPropertyValue(
            IAdapterProperty Property,
            string AttributeName,
            out IAdapterValue ValuePtr,
            out IAdapterIoRequest RequestPtr)
        {
            RequestPtr = null;
            IAdapterValue attribute = Property.Attributes.ElementAt<IAdapterValue>(0);
            if (Property.Name == "Pin-5")
            {
                pinValueData5 = (int)pin5.Read();

                attribute.Data = pinValueData5;
            }
            else if (Property.Name == "Pin-6")
            {
                pinValueData6 = (int)pin6.Read();

                attribute.Data = pinValueData6;
            }
            else if (Property.Name == "Pin-12")
            {
                pinValueData12 = (int)pin12.Read();

                attribute.Data = pinValueData12;
            }
            else if (Property.Name == "Pin-16")
            {
                pinValueData16 = (int)pin16.Read();

                attribute.Data = pinValueData16;
            }

            ValuePtr = attribute;

            return ERROR_SUCCESS;
        }
Exemplo n.º 32
0
        public uint SetPropertyValue(
            IAdapterProperty Property,
            IAdapterValue Value,
            out IAdapterIoRequest RequestPtr)
        {
            RequestPtr = null;

            IAdapterValue attribute = Property.Attributes.ElementAt<IAdapterValue>(0);
            if (Property.Name == "Pin-5")
            {
                if (Convert.ToInt32(Value.Data) == 1)
                {
                    pinValueData5 = 1;
                    pin5.Write(GpioPinValue.High);
                }
                else
                {
                    pinValueData5 = 0;
                    pin5.Write(GpioPinValue.Low);
                }
            }
            else if (Property.Name == "Pin-6")
            {
                if (Convert.ToInt32(Value.Data) == 1)
                {
                    pinValueData6 = 1;
                    pin6.Write(GpioPinValue.High);
                }
                else
                {
                    pinValueData6 = 0;
                    pin6.Write(GpioPinValue.Low);
                }
            }
            else if (Property.Name == "Pin-12")
            {
                if (Convert.ToInt32(Value.Data) == 1)
                {
                    pinValueData12 = 1;
                    pin12.Write(GpioPinValue.High);
                }
                else
                {
                    pinValueData12 = 0;
                    pin12.Write(GpioPinValue.Low);
                }
            }
            else if (Property.Name == "Pin-16")
            {
                if (Convert.ToInt32(Value.Data) == 1)
                {
                    pinValueData16 = 1;
                    pin16.Write(GpioPinValue.High);
                }
                else
                {
                    pinValueData16 = 0;
                    pin16.Write(GpioPinValue.Low);
                }
            }

            attribute.Data = Value.Data;

            return ERROR_SUCCESS;
        }
Exemplo n.º 33
0
        virtual public uint SetPropertyValue(IAdapterProperty Property, IAdapterValue Value, out IAdapterIoRequest RequestPtr)
        {
            RequestPtr = null;

            return(ERROR_SUCCESS);
        }
Exemplo n.º 34
0
 virtual public void SendPropertyValue(IAdapterProperty Property, IAdapterValue Value)
 {
 }
Exemplo n.º 35
0
        public uint GetPropertyValue(
            IAdapterProperty Property,
            string AttributeName,
            out IAdapterValue ValuePtr,
            out IAdapterIoRequest RequestPtr)
        {
            ValuePtr = null;
            RequestPtr = null;

            return ERROR_SUCCESS;
        }
Exemplo n.º 36
0
        public uint GetPropertyValue(IAdapterProperty Property, string AttributeName, out IAdapterValue ValuePtr, out IAdapterIoRequest RequestPtr)
        {
            ValuePtr = null;
            RequestPtr = null;

            var r = ((AdapterProperty)Property).Attributes.Where(x => x.Value.Name == AttributeName).First() as BridgeRT.IAdapterAttribute;

            if (r == null) { return ERROR_INVALID_HANDLE; }
            else
            {
                ValuePtr = r.Value;
                return ERROR_SUCCESS;
            }
        }
Exemplo n.º 37
0
        public uint GetPropertyValue(
            IAdapterProperty Property,
            string AttributeName,
            out IAdapterValue ValuePtr,
            out IAdapterIoRequest RequestPtr)
        {
            ValuePtr = null;
            RequestPtr = null;

            // find corresponding attribute
            foreach (var attribute in ((AdapterProperty)Property).Attributes)
            {
                if (attribute.Value.Name == AttributeName)
                {
                    ValuePtr = attribute.Value;
                    return ERROR_SUCCESS;
                }
            }

            return ERROR_INVALID_HANDLE;
        }
Exemplo n.º 38
0
 public AllJoynData(IAdapterValue Value)
 {
     this.Value = Value;
 }
Exemplo n.º 39
0
        override public uint GetPropertyValue(IAdapterProperty Property, string AttributeName, out IAdapterValue ValuePtr, out IAdapterIoRequest RequestPtr)
        {
            ValuePtr   = null;
            RequestPtr = null;

            ValuePtr = ((BridgeAdapterProperty <KnxDevice>)Property).Device.GetPropertyValue(Property, AttributeName);

            return(ERROR_SUCCESS);
        }