/// <summary> /// Sets the digital input values for the specified DI bits. /// </summary> /// <param name="bits">The DI bits.</param> /// <param name="values">The values.</param> public static void SetValues(this IEnumerable <DIBit> bits, params int[] values) { if (bits.Count() != values.Length) { throw new ArgumentException("Mismatch between the DI bits to set and the number of values specified."); } var devGroups = bits.GroupBy(b => b.Device); foreach (var devGroup in devGroups) { IIODevice dev = (IIODevice)devGroup.Key; List <DIBit> orderedBits = devGroup.OrderBy(b => b.Channel).ToList(); int[] channels = orderedBits.Select(b => b.Channel).ToArray(); dev.SetDIBits(channels, values); } }