コード例 #1
0
        /// <summary>
        /// Creates a new instance of the <see cref="Tlc59711Device"/> class.
        /// </summary>
        /// <param name="memory">Memory to work with.</param>
        /// <param name="settings">Initial settings</param>
        public Tlc59711Device(IMemory memory, ITlc59711Settings settings = null) {
            if (ReferenceEquals(memory, null))
                throw new ArgumentNullException("memory");

            if (memory.Length < COMMAND_SIZE) {
                throw new ArgumentException(
                    string.Format("Need at least {0} bytes, got {1} bytes.", COMMAND_SIZE, memory.Length), "memory");
            }

            this.memory = memory;
            initSettings = settings;
            channels = new Tlc59711Channels(memory, DATA_OFFSET);

            Reset();
        }
コード例 #2
0
        /// <summary>
        /// Creates a new instance of the <see cref="Tlc59711Cluster"/> class.
        /// </summary>
        /// <param name="memory">Memory to work with.</param>
        /// <param name="numberOfDevices">Number of <see cref="ITlc59711Device"/>s connected together.</param>
        public Tlc59711Cluster(IMemory memory, int numberOfDevices) {
            if (ReferenceEquals(memory, null))
                throw new ArgumentNullException("memory");
            if (numberOfDevices <= 0)
                throw new ArgumentOutOfRangeException("numberOfDevices", "You cannot create a cluster with less than one device.");

            var minimumRequiredMemorySize = (numberOfDevices * COMMAND_SIZE);
            if (memory.Length < minimumRequiredMemorySize) {
                var message = string.Format("For {0} device(s) you have to provide a minimum of {1} bytes of memory.", numberOfDevices, minimumRequiredMemorySize);
                throw new InsufficientMemoryException(message);
            }
            
            devices = CreateDevices(memory, numberOfDevices).ToArray();
            channels = new Tlc59711ClusterChannels(devices);
        }
コード例 #3
0
        /// <summary>
        /// Creates a new instance of the <see cref="Tlc59711Device"/> class.
        /// </summary>
        /// <param name="memory">Memory to work with.</param>
        /// <param name="settings">Initial settings</param>
        public Tlc59711Device(IMemory memory, ITlc59711Settings settings = null)
        {
            if (ReferenceEquals(memory, null))
            {
                throw new ArgumentNullException("memory");
            }

            if (memory.Length < COMMAND_SIZE)
            {
                throw new ArgumentException(
                          string.Format("Need at least {0} bytes, got {1} bytes.", COMMAND_SIZE, memory.Length), "memory");
            }

            this.memory  = memory;
            initSettings = settings;
            channels     = new Tlc59711Channels(memory, DATA_OFFSET);

            Reset();
        }
コード例 #4
0
ファイル: Tlc59711Device.cs プロジェクト: hugener/Pi
        /// <summary>
        /// Initializes a new instance of the <see cref="Tlc59711Device"/> class.
        /// </summary>
        /// <param name="memory">The memory.</param>
        /// <param name="settings">The settings.</param>
        /// <exception cref="ArgumentNullException">memory.</exception>
        /// <exception cref="ArgumentException">thrown if memory is too small.</exception>
        public Tlc59711Device(IMemory memory, ITlc59711Settings settings = null)
        {
            if (ReferenceEquals(memory, null))
            {
                throw new ArgumentNullException(nameof(memory));
            }

            if (memory.Length < CommandSize)
            {
                throw new ArgumentException(
                          string.Format("Need at least {0} bytes, got {1} bytes.", CommandSize, memory.Length), nameof(memory));
            }

            this.memory       = memory;
            this.initSettings = settings;
            this.channels     = new Tlc59711Channels(memory, DataOffset);

            this.Reset();
        }
コード例 #5
0
ファイル: Tlc59711Cluster.cs プロジェクト: tisma/IoT.Home.Pi
        /// <summary>
        /// Creates a new instance of the <see cref="Tlc59711Cluster"/> class.
        /// </summary>
        /// <param name="memory">Memory to work with.</param>
        /// <param name="numberOfDevices">Number of <see cref="ITlc59711Device"/>s connected together.</param>
        public Tlc59711Cluster(IMemory memory, int numberOfDevices)
        {
            if (ReferenceEquals(memory, null))
            {
                throw new ArgumentNullException("memory");
            }
            if (numberOfDevices <= 0)
            {
                throw new ArgumentOutOfRangeException("numberOfDevices", "You cannot create a cluster with less than one device.");
            }

            var minimumRequiredMemorySize = (numberOfDevices * COMMAND_SIZE);

            if (memory.Length < minimumRequiredMemorySize)
            {
                var message = string.Format("For {0} device(s) you have to provide a minimum of {1} bytes of memory.", numberOfDevices, minimumRequiredMemorySize);
                throw new OutOfMemoryException(message);
            }

            devices  = CreateDevices(memory, numberOfDevices).ToArray();
            channels = new Tlc59711ClusterChannels(devices);
        }
コード例 #6
0
ファイル: Tlc59711Cluster.cs プロジェクト: hugener/Pi
        /// <summary>
        /// Initializes a new instance of the <see cref="Tlc59711Cluster"/> class.
        /// </summary>
        /// <param name="memory">Memory to work with.</param>
        /// <param name="numberOfDevices">Number of <see cref="ITlc59711Device" />s connected together.</param>
        /// <exception cref="ArgumentNullException">memory.</exception>
        /// <exception cref="ArgumentOutOfRangeException">numberOfDevices - You cannot create a cluster with less than one device.</exception>
        /// <exception cref="InsufficientMemoryException">Thrown in memory is insufficient.</exception>
        public Tlc59711Cluster(IMemory memory, int numberOfDevices)
        {
            if (memory is null)
            {
                throw new ArgumentNullException("memory");
            }

            if (numberOfDevices <= 0)
            {
                throw new ArgumentOutOfRangeException("numberOfDevices", "You cannot create a cluster with less than one device.");
            }

            var minimumRequiredMemorySize = numberOfDevices * CommandSize;

            if (memory.Length < minimumRequiredMemorySize)
            {
                var message = string.Format("For {0} device(s) you have to provide a minimum of {1} bytes of memory.", numberOfDevices, minimumRequiredMemorySize);
                throw new InsufficientMemoryException(message);
            }

            this.devices  = CreateDevices(memory, numberOfDevices).ToArray();
            this.channels = new Tlc59711ClusterChannels(this.devices);
        }
コード例 #7
0
ファイル: Tlc59711Cluster.cs プロジェクト: tisma/IoT.Home.Pi
 /// <summary>
 /// Creates a new instance of the <see cref="Tlc59711Cluster"/> class.
 /// </summary>
 /// <param name="devices">The devices, that are chained together</param>
 public Tlc59711Cluster(IEnumerable <ITlc59711Device> devices)
 {
     this.devices = devices.ToArray();
     channels     = new Tlc59711ClusterChannels(this.devices);
 }
コード例 #8
0
 /// <summary>
 /// Creates a new instance of the <see cref="Tlc59711Cluster"/> class.
 /// </summary>
 /// <param name="devices">The devices, that are chained together</param>
 public Tlc59711Cluster(IEnumerable<ITlc59711Device> devices) {
     this.devices = devices.ToArray();
     channels = new Tlc59711ClusterChannels(this.devices);
 }