Exemple #1
0
        public void FromSingle_TimestampedValue_PayloadHasValue()
        {
            float value     = (float)Math.E;
            var   timestamp = GetTimestamp();
            var   message   = HarpMessage.FromSingle(DefaultAddress, timestamp, MessageType.Write, value);

            AssertIsValid(message);
            var(payload, actualTimestamp) = message.GetTimestampedPayloadSingle();
            AssertTimestamp(timestamp, actualTimestamp);
            Assert.AreEqual(value, payload);
        }
Exemple #2
0
        public void FromSingle_TimestampedArray_PayloadHasValue()
        {
            var value     = new float[] { (float)Math.PI, 1 / 3f };
            var timestamp = GetTimestamp();
            var message   = HarpMessage.FromSingle(DefaultAddress, timestamp, MessageType.Write, value);

            AssertIsValid(message);
            var(payload, actualTimestamp) = message.GetTimestampedPayloadArray <float>();
            AssertTimestamp(timestamp, actualTimestamp);
            AssertArrayEqual(value, payload);
            Assert.AreEqual(value[1], message.GetTimestampedPayloadSingle(1).Value);
        }
Exemple #3
0
 /// <summary>
 /// Returns a <see cref="HarpMessage"/> write command with the specified address, and an
 /// array payload of single-precision floating point numbers.
 /// </summary>
 /// <param name="address">The address of the register to which the Harp message refers to.</param>
 /// <param name="values">The values to be stored in the payload.</param>
 /// <returns>
 /// A valid <see cref="HarpMessage"/> write command with the specified address and payload.
 /// </returns>
 public static HarpMessage WriteSingle(int address, params float[] values)
 {
     return(HarpMessage.FromSingle(address, MessageType.Write, values));
 }
Exemple #4
0
 /// <summary>
 /// Returns a <see cref="HarpMessage"/> read command for a single-precision floating point
 /// register with the specified address.
 /// </summary>
 /// <param name="address">The address of the register to read.</param>
 /// <returns>
 /// A valid <see cref="HarpMessage"/> read command for a single-precision floating point
 /// register with the specified address.
 /// </returns>
 public static HarpMessage ReadSingle(int address)
 {
     return(HarpMessage.FromSingle(address, MessageType.Read));
 }