public void ShouldConfigureDacPrecision(
     [Values(DacPrecision.FourteenBit, DacPrecision.SixteenBit)] DacPrecision dacPrecision)
 {
     GivenDeviceConfig(WithDacPrecision(dacPrecision));
     WhenCreate();
     ThenDacPrecisionShouldBe(dacPrecision);
 }
 public void ShouldSetAndGetDacPrecision
 (
     DacPrecision originalDacPrecision,
     DacPrecision newDacPrecision
 )
 {
     GivenDacPrecision(originalDacPrecision);
     WhenSetAndGetDacPrecision(newDacPrecision);
     ThenDacPrecisionShouldBe(newDacPrecision);
 }
예제 #3
0
 public void ShouldSendSPI(
     [Values(DacPrecision.SixteenBit, DacPrecision.FourteenBit)] DacPrecision dacPrecision,
     [Range((int)ChannelAddress.Dac0, (int)ChannelAddress.Dac39)] ChannelAddress channelAddress,
     [Values(ushort.MinValue, 1, 1 << 1, 1 << 2, 1 << 3, 1 << 4, 1 << 5, 1 << 6, 1 << 7, 1 << 8, 1 << 9, 1 << 10,
             1 << 11, 1 << 12, 1 << 13, 1 << 14, 1 << 15, ushort.MaxValue)] int dacChannelDataValueA)
 {
     GivenDACPrecision(dacPrecision);
     WhenSetDacChannelDataValueA(channelAddress, (ushort)dacChannelDataValueA);
     ThenSPICommandIsSent(DataForSPI(dacPrecision, channelAddress, (ushort)dacChannelDataValueA));
 }
 private static uint DataForSPI(DacPrecision dacPrecision, ChannelAddress channelAddress, ushort dacChannelGain)
 {
     return
         ((uint)SerialInterfaceModeBits.WriteToDACGainRegisterM
          | (uint)(((byte)channelAddress & (byte)BasicMasks.SixBits) << 16)
          | (dacChannelGain &
             (dacPrecision == DacPrecision.SixteenBit
                ? (uint)BasicMasks.SixteenBits
                : (uint)BasicMasks.HighFourteenBits)));
 }
예제 #5
0
 public void ShouldOnlyReturnReadableBitsPortionOfMRegisterValue(
     [Range((int)ChannelAddress.Dac0, (int)ChannelAddress.Dac39)] int channelAddress,
     [Values(ushort.MinValue, (ushort)BasicMasks.FourteenBits, (ushort)BasicMasks.SixteenBits)]
     ushort mRegisterBits,
     [Values(DacPrecision.FourteenBit, DacPrecision.SixteenBit)] DacPrecision dacPrecision
     )
 {
     GivenMRegisterValueInDeviceMemory(mRegisterBits);
     GivenDacPrecision(dacPrecision);
     WhenReadbackMRegister((ChannelAddress)channelAddress);
     ThenTheValueShouldBeTheReadableBitsPartOfTheValueOnTheDevice();
 }
 public void ShouldSetAndGetDacChannelOffset(
     [Values(DacPrecision.FourteenBit, DacPrecision.SixteenBit)] DacPrecision dacPrecision,
     [Range((int)ChannelAddress.Dac0, (int)ChannelAddress.Dac39)] int channelAddress,
     [Values(0, 1, 1 << 1, 1 << 2, 1 << 3, 1 << 4, 1 << 5, 1 << 6, 1 << 7, 1 << 8, 1 << 9, 1 << 10, 1 << 11,
             1 << 12, 1 << 13, 1 << 14, 1 << 15, (2 ^ 16) - 1)] int newValue)
 {
     GivenDacPrecision(dacPrecision);
     GivenDacChannelOffset((ChannelAddress)channelAddress, (ushort)~newValue);
     WhenSetAndGetDacChannelOffset((ChannelAddress)channelAddress, (ushort)newValue);
     ThenDacChannelOffsetShouldBe((ushort)(newValue & (ushort)(dacPrecision == DacPrecision.FourteenBit
                                                ? BasicMasks.HighFourteenBits
                                                : BasicMasks.SixteenBits)));
 }
예제 #7
0
 public void ShouldGetCorrectDacChannelOffset(
     [Values(DacPrecision.SixteenBit, DacPrecision.FourteenBit)] DacPrecision dacPrecision,
     [Range((int)ChannelAddress.Dac0, (int)ChannelAddress.Dac39)] int channelAddress,
     [Values(0, 1, 1 << 1, 1 << 2, 1 << 3, 1 << 4, 1 << 5, 1 << 6, 1 << 7, 1 << 8, 1 << 9, 1 << 10, 1 << 11,
             1 << 12, 1 << 13, 1 << 14, 1 << 15, (2 ^ 16) - 1)] int cRegisterValue)
 {
     GivenDacPrecision(dacPrecision);
     GivenCRegisterBits((ChannelAddress)channelAddress, (ushort)cRegisterValue);
     WhenGetDacChannelOffset((ChannelAddress)channelAddress);
     ThenValueReturnedShouldBe((ushort)(cRegisterValue &
                                        (dacPrecision == DacPrecision.SixteenBit
                                             ? (ushort)BasicMasks.SixteenBits
                                             : (ushort)BasicMasks.HighFourteenBits)));
 }
예제 #8
0
 public void ShouldCacheX1ARegisterValues(
     [Values(DacPrecision.SixteenBit, DacPrecision.FourteenBit)] DacPrecision dacPrecision,
     [Range((int)ChannelAddress.Dac0, (int)ChannelAddress.Dac39)] ChannelAddress channelAddress,
     [Values(ushort.MinValue, 1, 1 << 1, 1 << 2, 1 << 3, 1 << 4, 1 << 5, 1 << 6, 1 << 7, 1 << 8, 1 << 9, 1 << 10,
             1 << 11, 1 << 12, 1 << 13, 1 << 14, 1 << 15, ushort.MaxValue)] int dacChannelDataValueA)
 {
     GivenDACPrecision(dacPrecision);
     WhenSetDacChannelDataValueA(channelAddress, (ushort)dacChannelDataValueA);
     ThenX1ARegisterValueInDeviceStateCacheIsSetTo(
         (int)channelAddress - 8,
         (ushort)(dacChannelDataValueA &
                  (dacPrecision == DacPrecision.SixteenBit
                       ? (ushort)BasicMasks.SixteenBits
                       : (ushort)BasicMasks.HighFourteenBits))
         );
 }
예제 #9
0
 private void GivenDacPrecision(DacPrecision dacPrecision)
 {
     _deviceState.Precision = dacPrecision;
 }
 private void ThenDacPrecisionShouldBe(DacPrecision expected)
 {
     _dacPrecisionReturned.Should().Be(expected);
 }
 private void WhenSetAndGetDacPrecision(DacPrecision dacPrecision)
 {
     _evalBoard.DacPrecision = dacPrecision;
     _dacPrecisionReturned   = _evalBoard.DacPrecision;
 }
 private void GivenDacPrecision(DacPrecision dacPrecision)
 {
     _evalBoard.DacPrecision = dacPrecision;
 }
 private void ThenDacPrecisionShouldBe(DacPrecision expectedDacPrecision)
 {
     Mock.Get(_fakeEvalBoard)
     .VerifySet(x => x.DacPrecision = expectedDacPrecision);
 }
 private static DeviceConfig WithDacPrecision(DacPrecision dacPrecision)
 {
     return(new DeviceConfig {
         DACPrecision = dacPrecision
     });
 }