/// <summary>
        /// Generates the BICCP command for the current action.
        /// </summary>
        /// <param name="biccp">BICCP Manager used to send the command.</param>
        /// <param name="answer">BICCPData object to retrieve the answer from the module.</param>
        /// <returns>Success of the call to the module. True if command was successful, false otherwise.</returns>
        public override bool ToBICCP(IBICCPManager biccp, IBICCPData answer)
        {
            bool b = false;

            string desc = (string)Data[0];

            byte[] data = new byte[ICCConstants.DESCSIZE];
            for (int i = 0; i < ICCConstants.DESCSIZE; i++)
            {
                if (i < desc.Length)
                {
                    data[i] = (byte)desc[i];
                }
                else
                {
                    data[i] = 0;
                }
            }

            if (biccp.RequestToModule(Address, answer, Group, Command, data[0], data[1], data[2], data[3], data[4], data[5],
                                      data[6], data[7], data[8], data[9], data[10], data[11], data[12], data[13]))
            {
                b = (answer.Data[0] == BICCPConstants.BICCP_SUCCESS);
            }

            Log?.LogMessageText(b, "Set description", Address, (string)Data[0]);

            return(b);
        }
        /// <summary>
        /// Generates the BICCP command for the current action.
        /// </summary>
        /// <param name="biccp">BICCP Manager used to send the command.</param>
        /// <param name="answer">BICCPData object to retrieve the answer from the module.</param>
        /// <returns>Success of the call to the module. True if command was successful, false otherwise.</returns>
        public override bool ToBICCP(IBICCPManager biccp, IBICCPData answer)
        {
            bool b = false;

            if (biccp.RequestToModule(Address, answer, Group, Command))
            {
                b = (answer.Data[0] == BICCPConstants.BICCP_SUCCESS);
            }

            Log?.LogMessage(b, "HardReset", Address);

            return(b);
        }
        /// <summary>
        /// Generates the BICCP command for the current action.
        /// </summary>
        /// <param name="biccp">BICCP Manager used to send the command.</param>
        /// <param name="answer">BICCPData object to retrieve the answer from the module.</param>
        /// <returns>Success of the call to the module. True if command was successful, false otherwise.</returns>
        public override bool ToBICCP(IBICCPManager biccp, IBICCPData answer)
        {
            bool b = false;

            if (biccp.RequestToModule(Address, answer, Group, Command, (byte)Data[0]))
            {
                b = (answer.Data[0] == BICCPConstants.BICCP_SUCCESS);
            }

            Log?.LogMessageToDec(b, "Set type", Address, (byte)Data[0]);

            return(b);
        }
Пример #4
0
        /// <summary>
        /// Generates the BICCP command for the current action.
        /// </summary>
        /// <param name="biccp">BICCP Manager used to send the command.</param>
        /// <param name="answer">BICCPData object to retrieve the answer from the module.</param>
        /// <returns>Success of the call to the module. True if command was successful, false otherwise.</returns>
        public override bool ToBICCP(IBICCPManager biccp, IBICCPData answer)
        {
            bool b = false;

            if (biccp.RequestToModule(Address, answer, Group, Command, (byte)Data[0]))
            {
                b = (answer.Data[0] == BICCPConstants.BICCP_SUCCESS);
            }

            Log?.LogMessage(b, string.Format("LightingModule: Stop scenario(s) for pin {0}", (byte)Data[0]), Address);

            return(b);
        }
Пример #5
0
        /// <summary>
        /// Generates the BICCP command for the current action.
        /// </summary>
        /// <param name="biccp">BICCP Manager used to send the command.</param>
        /// <param name="answer">BICCPData object to retrieve the answer from the module.</param>
        /// <returns>Success of the call to the module. True if command was successful, false otherwise.</returns>
        public override bool ToBICCP(IBICCPManager biccp, IBICCPData answer)
        {
            bool b = false;

            if (biccp.RequestToModule(Address, answer, Group, (byte)(Command + (byte)Data[0]), (byte)Data[1]))
            {
                b = (answer.Data[0] == BICCPConstants.BICCP_SUCCESS);
            }

            Log?.LogMessage(b, string.Format("LightingModule: Set dimmable output {0:X} to {1}", (byte)Data[0], (byte)Data[1]), Address);

            return(b);
        }
Пример #6
0
        /// <summary>
        /// Generates the BICCP command for the current action.
        /// </summary>
        /// <param name="biccp">BICCP Manager used to send the command.</param>
        /// <param name="answer">BICCPData object to retrieve the answer from the module.</param>
        /// <returns>Success of the call to the module. True if command was successful, false otherwise.</returns>
        public override bool ToBICCP(IBICCPManager biccp, IBICCPData answer)
        {
            bool b        = false;
            byte outValue = (byte)((bool)Data[1] ? 0xFF : 0x00);

            if (biccp.RequestToModule(Address, answer, Group, (byte)(Command + (byte)Data[0]), outValue))
            {
                b = (answer.Data[0] == BICCPConstants.BICCP_SUCCESS);
            }

            Log?.LogMessage(b, string.Format("GenPurpModule: Set output {0:X} to {1:X2}", (byte)Data[0], outValue), Address);

            return(b);
        }
        /// <summary>
        /// Generates the BICCP command for the current action.
        /// </summary>
        /// <param name="biccp">BICCP Manager used to send the command.</param>
        /// <param name="answer">BICCPData object to retrieve the answer from the module.</param>
        /// <returns>Success of the call to the module. True if command was successful, false otherwise.</returns>
        public override bool ToBICCP(IBICCPManager biccp, IBICCPData answer)
        {
            bool b = false;

            lock (Conf)
            {
                if (Conf != null)
                {
                    if (Conf.ScanBus() != 0)
                    {
                        b = true;
                    }
                }
            }

            Log?.LogMessage(b, "ScanBus", Address);

            return(b);
        }
Пример #8
0
        /// <summary>
        /// Sends a request to a module and gets the response.
        /// </summary>
        /// <param name="addr">Address of the module.</param>
        /// <param name="data">Data to send.</param>
        /// <param name="group">Group of command to send.</param>
        /// <param name="command">Command to send.</param>
        /// <param name="datas">Response data.</param>
        /// <returns>Status of response. True if response acknowledges correctly group and command, false otherwise.</returns>
        public virtual bool RequestToModule(int addr, IBICCPData data, byte group, byte command, params byte[] datas)
        {
            var m = new I2CManager();

            int fd = GetFDFromAddress(addr);

            byte[] buffer = new byte[ICCConstants.PACKETSIZE];
            buffer[0] = group;
            buffer[1] = command;
            for (int i = 2; i < ICCConstants.PACKETSIZE; i++)
            {
                buffer[i] = 0;
            }

            for (int i = 0; i < datas.Length; i++)
            {
                if (i < ICCConstants.DATASIZE)
                {
                    buffer[i + 2] = datas[i];
                }
            }

            bool b = RequestToModuleFromBuffer(addr, ref buffer);

            if (!b)
            {
                return(false);
            }
            else if (buffer[0] != group || buffer[1] != command)
            {
                return(false);
            }
            else
            {
                for (int i = 0; i < ICCConstants.DATASIZE; i++)
                {
                    data.Data[i] = buffer[i + 2];
                }
                return(true);
            }
        }
        /// <summary>
        /// Generates the BICCP command for the current action.
        /// </summary>
        /// <param name="biccp">BICCP Manager used to send the command.</param>
        /// <param name="answer">BICCPData object to retrieve the answer from the module.</param>
        /// <returns>Success of the call to the module. True if command was successful, false otherwise.</returns>
        public override bool ToBICCP(IBICCPManager biccp, IBICCPData answer)
        {
            bool b = false;

            int[] p = (int[])Data[1];

            if (p.Length != 1)
            {
                LogArgumentsError(1);
            }
            else
            {
                if (biccp.RequestToModule(Address, answer, Group, Command, (byte)Data[0], (byte)p[0]))
                {
                    b = (answer.Data[0] == BICCPConstants.BICCP_SUCCESS);
                }
            }

            LogStart(b, p);

            return(b);
        }
Пример #10
0
 /// <summary>
 /// Generates the BICCP command for the current action.
 /// </summary>
 /// <param name="biccp">BICCP Manager used to send the command.</param>
 /// <param name="answer">BICCPData object to retrieve the answer from the module.</param>
 /// <returns>Success of the call to the module. True if command was successful, false otherwise.</returns>
 public virtual bool ToBICCP(IBICCPManager biccp, IBICCPData answer)
 {
     throw new NotImplementedException();
 }