-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
126 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/OpenProtocolInterpreter/IApplicationDataMessageRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace OpenProtocolInterpreter | ||
{ | ||
public interface IApplicationDataMessageRequest | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Security.Cryptography; | ||
using System.Text; | ||
|
||
namespace OpenProtocolInterpreter.Tightening | ||
{ | ||
/// <summary> | ||
/// This message contains a list of tightening results stored in the controller. The result list is sorted ascendingly on result index, and contains a brief summary of each result. | ||
/// <para><see cref="Communication.Mid0006"/> Application Data Message Request shall be used for fetching this message</para> | ||
/// <para>For full results data, request upload of <see cref="Mid1201"/></para> | ||
/// </summary> | ||
public class Mid0067 : Mid, ITightening, IController, IApplicationDataMessageRequest | ||
{ | ||
public const int MID = 67; | ||
|
||
public int NumberOfResults | ||
{ | ||
get => GetField(1, DataFields.NumberOfResults).GetValue(OpenProtocolConvert.ToInt32); | ||
private set => GetField(1, DataFields.NumberOfResults).SetValue(OpenProtocolConvert.ToString, value); | ||
} | ||
|
||
public List<TighteningSummary> ResultData { get; set; } | ||
|
||
public Mid0067() : this(new Header() | ||
{ | ||
Mid = MID, | ||
Revision = DEFAULT_REVISION | ||
}) | ||
{ | ||
} | ||
|
||
public Mid0067(Header header) : base(header) | ||
{ | ||
} | ||
|
||
protected override Dictionary<int, List<DataField>> RegisterDatafields() | ||
{ | ||
return new Dictionary<int, List<DataField>>() | ||
{ | ||
{ | ||
1, new List<DataField>() | ||
{ | ||
DataField.Number(DataFields.NumberOfResults, 20, 3, false), | ||
DataField.Volatile(DataFields.ResultData, 23, false) | ||
} | ||
} | ||
}; | ||
} | ||
|
||
protected enum DataFields | ||
{ | ||
NumberOfResults, | ||
ResultData | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/OpenProtocolInterpreter/Tightening/TighteningSummary.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace OpenProtocolInterpreter.Tightening | ||
{ | ||
public class TighteningSummary | ||
{ | ||
public long Index { get; set; } | ||
public DateTime StartTime { get; set; } | ||
public bool Status { get; set; } | ||
|
||
public string Pack() | ||
{ | ||
return OpenProtocolConvert.ToString('0', 10, PaddingOrientation.LeftPadded, Index) + | ||
OpenProtocolConvert.ToString(StartTime) + | ||
OpenProtocolConvert.ToString(Status); | ||
} | ||
|
||
public static TighteningSummary Parse(string value) | ||
{ | ||
return new TighteningSummary() | ||
{ | ||
Index = OpenProtocolConvert.ToInt64(value.Substring(0, 10)), | ||
StartTime = OpenProtocolConvert.ToDateTime(value.Substring(10, 19)), | ||
Status = OpenProtocolConvert.ToBoolean(value.Substring(29, 1)) | ||
}; | ||
} | ||
|
||
public static IEnumerable<TighteningSummary> ParseAll(string value) | ||
{ | ||
const int sectionSize = 30; | ||
for (int i = 0; i < value.Length; i += sectionSize) | ||
{ | ||
var section = value.Substring(i, sectionSize); | ||
yield return Parse(section); | ||
} | ||
} | ||
} | ||
} |