示例#1
0
        /// <summary>
        /// Instantiates a new BICCPCommunicator.
        /// </summary>
        /// <param name="biccp">BICCP Manager.</param>
        /// <param name="conf">Configuration Manager.</param>
        /// <param name="log">Logger.</param>
        public BICCPCommunicator(IBICCPManager biccp, IConfManager conf, ILogger log)
        {
            if (biccp == null)
            {
                throw new ArgumentException("ConfManager : argument biccp cannot be null.");
            }
            else
            {
                Biccp = biccp;
            }

            if (conf == null)
            {
                throw new ArgumentException("ConfManager : argument conf cannot be null.");
            }
            else
            {
                Conf = conf;
            }

            if (log == null)
            {
                throw new ArgumentException("ConfManager : argument log cannot be null.");
            }
            else
            {
                Log = log;
            }

            Actions = new BlockingCollection <IICCAction>();
        }
        /// <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);
        }
示例#3
0
        /// <summary>
        /// Instantiates a new ConfManager.
        /// </summary>
        /// <param name="biccp">BICCP Manager.</param>
        /// <param name="log">Logger.</param>
        public ConfManager(IBICCPManager biccp, ILogger log)
        {
            if (biccp == null)
            {
                throw new ArgumentException("ConfManager : argument biccp cannot be null.");
            }
            else
            {
                Biccp = biccp;
            }

            if (log == null)
            {
                throw new ArgumentException("ConfManager : argument log cannot be null.");
            }
            else
            {
                Log = log;
            }

            Modules   = new Dictionary <byte, IModule>();
            Positions = new Dictionary <int, ConfPosition>();
            Relays    = new Dictionary <int, ConfRelay>();
            Sections  = new Dictionary <int, ConfSection>();
            Sensors   = new Dictionary <int, ConfSensor>();
            Switchs   = new Dictionary <int, ConfSwitch>();
        }
        /// <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);
        }
示例#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;

            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);
        }
示例#7
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);
        }
示例#8
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);
        }
示例#10
0
        /// <summary>
        /// Instantiates a new instance of the Daemon Manager.
        /// </summary>
        /// <param name="biccp">BICCP Manager reference.</param>
        /// <param name="conf">Configuration Manager reference.</param>
        /// <param name="log">Log Manager reference.</param>
        public DaemonManager(IBICCPManager biccp, IConfManager conf, ILogger log)
        {
            if (biccp == null)
            {
                throw new ArgumentException("DaemonManager : argument biccp cannot be null.");
            }
            else
            {
                Biccp = biccp;
            }

            if (conf == null)
            {
                throw new ArgumentException("DaemonManager : argument conf cannot be null.");
            }
            else
            {
                Conf = conf;
            }

            if (log == null)
            {
                throw new ArgumentException("DaemonManager : argument log cannot be null.");
            }
            else
            {
                Log = log;
            }

            // Instantiates a new communicator to handle I2C communications
            Communicator = new BICCPCommunicator(Biccp, Conf, Log);
            Communicator.Start();

            // Register to the Configuration Manager's BusRescanned event to get notification of every new bus scan,
            // so we can take appropriate actions on new modules instances
            Conf.BusRescanned += Conf_BusRescanned;
            // Call to RegisterModules() to get notification of each change to a module, so the corresponding
            // action can be stacked to the actions list
            RegisterModules();
        }
        /// <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);
        }
示例#12
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();
 }