Пример #1
0
            public void UpdateValue(LedWizOutput LedWizOutput)
            {
                byte V = ByteToLedWizValue[LedWizOutput.Value];
                bool S = (V != 0);

                int ZeroBasedOutputNumber = LedWizOutput.LedWizOutputNumber - 1;

                int ByteNr = ZeroBasedOutputNumber >> 3;
                int BitNr  = ZeroBasedOutputNumber & 7;

                byte Mask = (byte)(1 << BitNr);

                lock (ValueChangeLocker)
                {
                    if (S != ((NewAfterValueSwitches[ByteNr] & Mask) != 0))
                    {
                        //Neeed to adjust switches
                        if (S == false)
                        {
                            //Output will be turned off
                            Mask = (byte)~Mask;
                            NewAfterValueSwitches[ByteNr]           &= Mask;
                            NewBeforeValueSwitches[ByteNr]          &= Mask;
                            NewSwitchUpdateBeforeValueUpdateRequired = true;
                            UpdateRequired = true;
                        }
                        else
                        {
                            //Output will be turned on
                            if (V != NewOutputValues[ZeroBasedOutputNumber])
                            {
                                //Need to change value before turing on
                                NewOutputValues[ZeroBasedOutputNumber] = V;
                                NewAfterValueSwitches[ByteNr]         |= Mask;
                                NewValueUpdateRequired = true;
                                NewSwitchUpdateAfterValueUpdateRequired = true;
                                UpdateRequired = true;
                            }
                            else
                            {
                                //Value is correct, only need to turn on switch
                                NewAfterValueSwitches[ByteNr]           |= Mask;
                                NewBeforeValueSwitches[ByteNr]          |= Mask;
                                NewSwitchUpdateBeforeValueUpdateRequired = true;
                                UpdateRequired = true;
                            }
                        }
                    }
                    else
                    {
                        if (S == true && V != NewOutputValues[ZeroBasedOutputNumber])
                        {
                            //Only need to adjust value
                            NewOutputValues[ZeroBasedOutputNumber] = V;
                            NewValueUpdateRequired = true;
                            UpdateRequired         = true;
                        }
                    }
                }
            }
Пример #2
0
        /// <summary>
        /// This method is called whenever the value of a output in the Outputs property changes its value.<br />
        /// Updates the internal arrays holding the states of the LedWiz outputs.
        /// </summary>
        /// <param name="Output">The output which has changed.</param>
        /// <exception cref="System.Exception">
        /// The OutputValueChanged event handler for LedWiz {0:00} has been called by a sender which is not a LedWizOutput.<br/>
        /// or<br/>
        /// LedWiz output numbers must be in the range of 1-32. The supplied output number {0} is out of range.
        /// </exception>
        protected override void OnOutputValueChanged(IOutput Output)
        {
            if (!(Output is LedWizOutput))
            {
                throw new Exception("The OutputValueChanged event handler for LedWiz {0:00} has been called by a sender which is not a LedWizOutput.".Build(Number));
            }
            LedWizOutput LWO = (LedWizOutput)Output;

            if (!LWO.LedWizOutputNumber.IsBetween(1, 32))
            {
                throw new Exception("LedWiz output numbers must be in the range of 1-32. The supplied output number {0} is out of range.".Build(LWO.LedWizOutputNumber));
            }

            LedWizUnit S = LedWizUnits[this.Number];

            S.UpdateValue(LWO);
        }
Пример #3
0
        /// <summary>
        /// This method is called whenever the value of a output in the Outputs property changes its value.<br />
        /// Updates the internal arrays holding the states of the LedWiz outputs.
        /// </summary>
        /// <param name="Output">The output which has changed.</param>
        /// <exception cref="System.Exception">
        /// The OutputValueChanged event handler for LedWiz {0:00} has been called by a sender which is not a LedWizOutput.<br/>
        /// or<br/>
        /// LedWiz output numbers must be in the range of 1-32. The supplied output number {0} is out of range.
        /// </exception>
        protected override void OnOutputValueChanged(IOutput Output)
        {
            if (!(Output is LedWizOutput))
            {
                throw new Exception("The OutputValueChanged event handler for LedWiz {0:00} has been called by a sender which is not a LedWizOutput.".Build(Number));
            }
            LedWizOutput LWO = (LedWizOutput)Output;

            if (!LWO.LedWizOutputNumber.IsBetween(1, 32))
            {
                throw new Exception("LedWiz output numbers must be in the range of 1-32. The supplied output number {0} is out of range.".Build(LWO.LedWizOutputNumber));
            }

            LedWizUnit S = LedWizUnits[this.Number];
            //S.UpdateValue(LWO);

            //uses ledwizoutput instead of standard output, need to mirror ledwizoutputnumber
            //note, compensate for id [1-16] not being zero-based
            IOutput recalculatedOutput = ScheduledSettings.Instance.getnewrecalculatedOutput(Output, 1, Number - 1);

            LWO.Value = recalculatedOutput.Value;

            S.UpdateValue(LWO);
        }
Пример #4
0
            public void UpdateValue(LedWizOutput LedWizOutput)
            {
                byte V = ByteToLedWizValue[LedWizOutput.Value];
                bool S = (V != 0);

                int ZeroBasedOutputNumber = LedWizOutput.LedWizOutputNumber - 1;

                int ByteNr = ZeroBasedOutputNumber >> 3;
                int BitNr = ZeroBasedOutputNumber & 7;

                byte Mask = (byte)(1 << BitNr);

                lock (ValueChangeLocker)
                {
                    if (S != ((NewAfterValueSwitches[ByteNr] & Mask) != 0))
                    {
                        //Neeed to adjust switches
                        if (S == false)
                        {
                            //Output will be turned off
                            Mask = (byte)~Mask;
                            NewAfterValueSwitches[ByteNr] &= Mask;
                            NewBeforeValueSwitches[ByteNr] &= Mask;
                            NewSwitchUpdateBeforeValueUpdateRequired = true;
                            UpdateRequired = true;
                        }
                        else
                        {
                            //Output will be turned on
                            if (V != NewOutputValues[ZeroBasedOutputNumber])
                            {
                                //Need to change value before turing on
                                NewOutputValues[ZeroBasedOutputNumber] = V;
                                NewAfterValueSwitches[ByteNr] |= Mask;
                                NewValueUpdateRequired = true;
                                NewSwitchUpdateAfterValueUpdateRequired = true;
                                UpdateRequired = true;
                            }
                            else
                            {
                                //Value is correct, only need to turn on switch
                                NewAfterValueSwitches[ByteNr] |= Mask;
                                NewBeforeValueSwitches[ByteNr] |= Mask;
                                NewSwitchUpdateBeforeValueUpdateRequired = true;
                                UpdateRequired = true;
                            }
                        }
                    }
                    else
                    {
                        if (S == true && V != NewOutputValues[ZeroBasedOutputNumber])
                        {
                            //Only need to adjust value
                            NewOutputValues[ZeroBasedOutputNumber] = V;
                            NewValueUpdateRequired = true;
                            UpdateRequired = true;
                        }

                    }
                }
            }