-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCanFdMessage.cs
More file actions
83 lines (74 loc) · 3.45 KB
/
CanFdMessage.cs
File metadata and controls
83 lines (74 loc) · 3.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// -------------------------------------------------------------------------
// Copyright (c) Mecalc (Pty) Limited. All rights reserved.
// -------------------------------------------------------------------------
using QProtocol.GenericDefines;
using QProtocol.JsonProperties;
using System;
using System.Collections.Generic;
using System.Linq;
namespace QProtocol
{
/// <summary>
/// This class can be used with the /canfd/message/list/ endpoint to deserialize the response received and serialize the body sent.
/// </summary>
[Serializable]
public class CanFdTransmitMessage
{
/// <summary>
/// Gets or sets the settings applicable to the current message.
/// </summary>
public List<Setting> Settings { get; set; }
/// <summary>
/// Gets or sets the data packet of the message.
/// </summary>
public Setting MessageData { get; set; }
/// <summary>
/// Creates a new instance of the <see cref="CanFdTransmitMessage"/> class.
/// </summary>
public CanFdTransmitMessage()
{
}
/// <summary>
/// Creates a new instance of the <see cref="CanFdTransmitMessage"/> class from the QProtocol defined <see cref="CanFdChannel.TransmitMessage"/> class.
/// </summary>
/// <param name="transmitMessage">An instance of the <see cref="CanFdChannel.TransmitMessage"/> class.</param>
public CanFdTransmitMessage(CanFdChannel.TransmitMessage transmitMessage)
{
UpdateFromSettings(transmitMessage.Settings);
UpdateFromMessageData(transmitMessage.MessageData);
}
/// <summary>
/// This method can be used to convert the <see cref="Settings"/> property to <see cref="CanFdChannel.MessageSettings"/> class.
/// </summary>
/// <typeparam name="T">Type of the QProtocol defined settings class.</typeparam>
/// <returns>An instance of the <see cref="CanFdChannel.MessageSettings"/> class.</returns>
public CanFdChannel.MessageSettings ConvertToSettings()
{
return Setting.ConvertTo<CanFdChannel.MessageSettings>(this.Settings);
}
/// <summary>
/// This method will update the <see cref="Settings"/> property from an instance of <see cref="CanFdChannel.MessageSettings"/> class.
/// </summary>
/// <param name="definedSettings">An instance of the <see cref="CanFdChannel.MessageSettings"/> class.</param>
public void UpdateFromSettings(CanFdChannel.MessageSettings definedSettings)
{
this.Settings = Setting.ConvertFrom(definedSettings);
}
/// <summary>
/// This method can be used to convert the <see cref="Data"/> property to an instance of <see cref="Data"/>.
/// </summary>
/// <returns>An instance of <see cref="Data"/>.</returns>
public CanFdChannel.MessageData ConvertToMessageData()
{
return Setting.ConvertTo<CanFdChannel.MessageData>(new List<Setting> { this.MessageData });
}
/// <summary>
/// This method can be used to update the <see cref="Data"/> property from an instance of <see cref="Data"/>.
/// </summary>
/// <param name="definedSettings">An instance of <see cref="Data"/>.</param>
public void UpdateFromMessageData(CanFdChannel.MessageData definedSettings)
{
this.MessageData = Setting.ConvertFrom(definedSettings).First();
}
}
}