Esempio n. 1
0
 private void ProcessSceneGroupWrite(UInt16 SceneID)
 {
     foreach (var Chan in Channels)
     {
         if (Chan != null && Chan.Properties[2] != null)
         {
             //Might be more dynamic than always channel 2
             if (Chan.Properties[2].channelType == ChannelType.chanInputActorGroupMessage)
             {
                 //Might be more dynamic than always property 5
                 foreach (var data in Chan.Properties[5].PropertyData)
                 {
                     if (data != null)
                     {
                         byte Scene = data.data[1];
                         byte Value = data.data[2];
                         if (Scene < 0x40) //over 64 seems to be unsupported
                         {
                             if (Scene == SceneID)
                             {
                                 //Console.WriteLine("Scene Execute: " + Scene + " value: " + Value);
                                 OnGroupWriteEvent?.Invoke(this, Chan.Properties[3].ChannelAdresses[1].GroupValueAddress.ElementAt(0).GetAsReversed(), new byte[] { Value });
                                 OnActorChange?.Invoke(this, Chan.Properties[2].ActorSensorIndex, Value);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 2
0
        public void ProccessGroupWrite(KNXAddress GroupValue, byte[] data)
        {
            try
            {
                if (GroupValue == FaHSceneGroupValueAddress.GetAsReversed())
                {
                    ProcessSceneGroupWrite(data[0]);
                    return;
                }
                else
                {
                    //Console.WriteLine(GroupValue);
                    int ChannelID  = -1;
                    int PropertyID = -1;

                    //check if it is GroupValueWrite we have to act upon
                    if (GetGroupValueEntry(GroupValue, ref ChannelID, ref PropertyID, ChannelType.chanInputActorGroupMessage))
                    {
                        if (Channels[ChannelID].Properties[PropertyID].PropertyData[1].data.Length == 2)
                        {
                            Channels[ChannelID].Properties[PropertyID].PropertyData[1].data[1] = data[0];
                            this.AutoSave();
                        }
                        var OutChan = Channels[ChannelID].Properties[PropertyID + 1];
                        if (OutChan != null)
                        {
                            if (OutChan.channelType == FaHDeviceProperties.ChannelType.chanOutputActorChangedValue)
                            {
                                //WritePropertyValue(ChannelID, PropertyID, 1, data);
                                OnGroupWriteEvent?.Invoke(this, OutChan.ChannelAdresses[1].GroupValueAddress.ElementAt(0).GetAsReversed(), data);
                                OnActorChange?.Invoke(this, OutChan.ActorSensorIndex, data[0]);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Cannot parse: " + e);
            }
        }
Esempio n. 3
0
        public bool WritePropertyValue(int ChannelIndex, int propIndex, int FieldID, byte[] propertyData)
        {
            EnsureChannelExist(ChannelIndex);
            EnsurePropertyExist(ChannelIndex, propIndex);
            EnsurePropertyFieldExist(ChannelIndex, propIndex, FieldID);
            Channels[ChannelIndex].Properties[propIndex].PropertyData[FieldID].data = propertyData;

            //Check if device (on\off\dim) value is set via Application\Web
            if (FieldID == 1 && Channels[ChannelIndex].Properties[propIndex].channelType == ChannelType.chanInputActorGroupMessage)
            {
                var OutChan = Channels[ChannelIndex].Properties[propIndex + 1];
                if (OutChan != null)
                {
                    if (OutChan.channelType == FaHDeviceProperties.ChannelType.chanOutputActorChangedValue)
                    {
                        if (propertyData.Length != 2)
                        {
                            Console.WriteLine("Not Implemented!");
                        }
                        else
                        {
                            //Console.WriteLine("SendGroupValueWritePropVal:" + OutChan.ChannelAdresses[1].GroupValueAddress.ElementAt(0).GetAsReversed().ToString());
                            OnGroupWriteEvent?.Invoke(this, OutChan.ChannelAdresses[1].GroupValueAddress.ElementAt(0).GetAsReversed(), new byte[] { propertyData[1] });
                            OnActorChange?.Invoke(this, OutChan.ActorSensorIndex, propertyData[1]);
                            this.AutoSave();
                        }
                    }
                }
            }

            if (Channels[ChannelIndex].Properties[propIndex].PropertyData.Length == FieldID - 1)
            {
                return(false);
            }
            return(true);
        }