Ejemplo n.º 1
0
        private void CheckAssignValue(SensorType sensor, byte slot)
        {
            byte size     = GetSlots(sensor);
            byte areaLeft = (byte)(8 - (slot % 8));

            if (size > areaLeft)
            {
                throw new InvalidOperationException(string.Format("{0} needs {1} slots, but only {2} slots left in this Slot area.", sensor.GetDescription(), size, areaLeft));
            }

            for (byte i = 1; i < size; i++)
            {
                if (Slots[slot + i] != SensorType.None)
                {
                    throw new InvalidOperationException(string.Format("{0} needs {1} slots, but slot {2} is already assigned with {3}.", sensor.GetDescription(), size, slot + i, Slots[slot + i].GetDescription()));
                }
            }

            Slots[slot] = sensor;
            UpdateSlotMapping();
        }