File tree Expand file tree Collapse file tree 9 files changed +3109
-46
lines changed
Daqifi.Core.Tests/Communication/Producers Expand file tree Collapse file tree 9 files changed +3109
-46
lines changed Original file line number Diff line number Diff line change @@ -289,7 +289,7 @@ public void ForceBootloader_ReturnsCorrectMessage()
289289 Assert . Equal ( "SYSTem:FORceBoot" , message . Data ) ;
290290 }
291291
292- private static void AssertMessageFormat ( IMessage message )
292+ private static void AssertMessageFormat ( IOutboundMessage < string > message )
293293 {
294294 var bytes = message . GetBytes ( ) ;
295295 var expectedBytes = Encoding . ASCII . GetBytes ( $ "{ message . Data } \r \n ") ;
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change 1+ namespace Daqifi . Core . Communication . Messages ;
2+
3+ /// <summary>
4+ /// Represents a message containing data received from the DAQiFi device (Inbound).
5+ /// </summary>
6+ /// <typeparam name="T">The type of the data payload.</typeparam>
7+ public interface IInboundMessage < out T > // Using 'out' for covariance
8+ {
9+ /// <summary>
10+ /// Gets the payload data received from the device.
11+ /// </summary>
12+ T Data { get ; }
13+ }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ namespace Daqifi . Core . Communication . Messages ;
2+
3+ /// <summary>
4+ /// Represents a message to be sent to the DAQiFi device (Outbound).
5+ /// Defines the contract for serializing the message data into bytes.
6+ /// </summary>
7+ /// <typeparam name="T">The type of the data payload.</typeparam>
8+ public interface IOutboundMessage < T >
9+ {
10+ /// <summary>
11+ /// Gets or sets the payload data to be sent.
12+ /// </summary>
13+ T Data { get ; set ; }
14+
15+ /// <summary>
16+ /// Converts the message data into a byte array suitable for transmission.
17+ /// </summary>
18+ /// <returns>A byte array representing the message.</returns>
19+ byte [ ] GetBytes ( ) ;
20+ }
Original file line number Diff line number Diff line change 1+ namespace Daqifi . Core . Communication . Messages ;
2+
3+ /// <summary>
4+ /// Represents a message containing incoming data from the DAQiFi device,
5+ /// formatted using Google Protocol Buffers (Protobuf).
6+ /// The name DaqifiOutMessage signifies data coming "out" from the device.
7+ /// Implements IInboundMessage.
8+ /// </summary>
9+ public class ProtobufMessage : IInboundMessage < DaqifiOutMessage >
10+ {
11+ /// <summary>
12+ /// Gets the data associated with the message, which is a DaqifiOutMessage
13+ /// received from the device.
14+ /// </summary>
15+ public DaqifiOutMessage Data { get ; }
16+
17+ /// <summary>
18+ /// Initializes a new instance of the <see cref="ProtobufMessage"/> class
19+ /// to wrap incoming device data.
20+ /// </summary>
21+ /// <param name="message">The DaqifiOutMessage received from the device.</param>
22+ public ProtobufMessage ( DaqifiOutMessage message )
23+ {
24+ Data = message ;
25+ }
26+ }
Original file line number Diff line number Diff line change 22
33namespace Daqifi . Core . Communication . Messages ;
44
5- public class ScpiMessage ( string command ) : IMessage
5+ /// <summary>
6+ /// Represents a Standard Commands for Programmable Instruments (SCPI) message
7+ /// to be sent to the device (Outbound).
8+ /// Implements IOutboundMessage.
9+ /// </summary>
10+ /// <param name="command">The SCPI command string.</param>
11+ public class ScpiMessage ( string command ) : IOutboundMessage < string >
612{
7- public object Data { get ; set ; } = command ;
13+ /// <summary>
14+ /// Gets or sets the data associated with the message, which is the SCPI command string.
15+ /// </summary>
16+ public string Data { get ; set ; } = command ;
817
18+ /// <summary>
19+ /// Converts the SCPI command string to a byte array suitable for transmission,
20+ /// appending the required carriage return and newline characters.
21+ /// </summary>
22+ /// <returns>A byte array representing the SCPI message.</returns>
923 public byte [ ] GetBytes ( )
1024 {
11- return Encoding . ASCII . GetBytes ( ( string ) Data + "\r \n " ) ;
25+ return Encoding . ASCII . GetBytes ( Data + "\r \n " ) ;
1226 }
1327}
You can’t perform that action at this time.
0 commit comments