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); }
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); }
/// <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)); }
/// <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)); }