public static ReadingDescriptor CreateCellVoltageDescriptor(int cellIndex) { return(new ReadingDescriptor( new ReadingDescription( String.Format("Cell {0} voltage", cellIndex + 1), String.Format("A voltage of the cell {0}.", cellIndex + 1) ), new Dictionary <Func <BatteryElement, BatteryElement>, EntryKey> { { b => ((BatteryPack)b)[cellIndex], BatteryActualsWrapper.VoltageKey } }, new ReadingValueAccessor( b => ReadingDescriptors.GetValue <float>(((BatteryPack)b)[cellIndex], BatteryActualsWrapper.VoltageKey), "{0:N3} V" ))); }
public static ReadingDescriptor CreateChainCellVoltageDescriptor(int chipIndex, int cellIndex) { return(new ReadingDescriptor( new ReadingDescription( String.Format("Cell {0}.{1} voltage", chipIndex + 1, cellIndex + 1), String.Format("A voltage of the cell {0} on chip {1}.", cellIndex + 1, chipIndex + 1) ), new Dictionary <Func <BatteryElement, BatteryElement>, EntryKey> { { b => ((Pack)b).SubElements .OfType <ChipPack>() .Single(x => x.ChainIndex == chipIndex)[cellIndex], BatteryActualsWrapper.VoltageKey } }, new ReadingValueAccessor( b => ReadingDescriptors.GetValue <float>( ((Pack)b).SubElements .OfType <ChipPack>() .Single(x => x.ChainIndex == chipIndex)[cellIndex], BatteryActualsWrapper.VoltageKey), "{0:N3} V" ))); }