Exemple #1
0
 public virtual void UpdateEncoderRequest(ProtocolArray requestData)
 {
     if (EncoderOffset != 0)
     {
         if (0 == encoderOffsetCache)
         {
             encoderOffsetBits = ProtocolArray.SignificantBits((uint)Math.Abs(EncoderOffset));
             encoderOffsetMask = (byte)((encoderOffsetBits << 1) + 1);
             encoderOffsetBits++;
             encoderOffsetCache = (Math.Abs(EncoderOffset) << 1) | -(Math.Sign(EncoderOffset) >> 1); //odd numbers are negative speed/backward direction
         }
         requestData.SetBits(1, 6, encoderOffsetMask);
         requestData.SetBits(1, encoderOffsetBits, (uint)encoderOffsetCache);
     }
     else
     {
         requestData.SetBits(1, 1, 0);
     }
 }
 public void DataArraySignificantBitsTest0()
 {
     Assert.AreEqual(0, ProtocolArray.SignificantBits(uint.MinValue));
 }
 public void DataArraySignificantBitsTestMaxUInt()
 {
     Assert.AreEqual(32, ProtocolArray.SignificantBits(uint.MaxValue));
 }