Skip to content

Commit bac7586

Browse files
committed
Updated all uses of DateTime.Now to DateTime.UtcNow
1 parent b864b5c commit bac7586

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

RICADO.Omron/Channels/EthernetChannel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ internal async Task<ProcessRequestResult> ProcessRequestAsync(FINSRequest reques
7171
int packetsSent = 0;
7272
int bytesReceived = 0;
7373
int packetsReceived = 0;
74-
DateTime startTimestamp = DateTime.Now;
74+
DateTime startTimestamp = DateTime.UtcNow;
7575

7676
while (attempts <= retries)
7777
{
@@ -126,7 +126,7 @@ internal async Task<ProcessRequestResult> ProcessRequestAsync(FINSRequest reques
126126
PacketsSent = packetsSent,
127127
BytesReceived = bytesReceived,
128128
PacketsReceived = packetsReceived,
129-
Duration = DateTime.Now.Subtract(startTimestamp).TotalMilliseconds,
129+
Duration = DateTime.UtcNow.Subtract(startTimestamp).TotalMilliseconds,
130130
Response = FINSResponse.CreateNew(responseMessage, request),
131131
};
132132
}

RICADO.Omron/Channels/EthernetTCPChannel.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,12 @@ private async Task<ReceiveMessageResult> receiveMessageAsync(enTCPCommandCode co
216216
try
217217
{
218218
List<byte> receivedData = new List<byte>();
219-
DateTime startTimestamp = DateTime.Now;
219+
DateTime startTimestamp = DateTime.UtcNow;
220220

221-
while (DateTime.Now.Subtract(startTimestamp).TotalMilliseconds < timeout && receivedData.Count < TCP_HEADER_LENGTH)
221+
while (DateTime.UtcNow.Subtract(startTimestamp).TotalMilliseconds < timeout && receivedData.Count < TCP_HEADER_LENGTH)
222222
{
223223
Memory<byte> buffer = new byte[4096];
224-
TimeSpan receiveTimeout = TimeSpan.FromMilliseconds(timeout).Subtract(DateTime.Now.Subtract(startTimestamp));
224+
TimeSpan receiveTimeout = TimeSpan.FromMilliseconds(timeout).Subtract(DateTime.UtcNow.Subtract(startTimestamp));
225225

226226
if (receiveTimeout.TotalMilliseconds >= 50)
227227
{
@@ -311,12 +311,12 @@ private async Task<ReceiveMessageResult> receiveMessageAsync(enTCPCommandCode co
311311

312312
if (receivedData.Count < tcpMessageDataLength)
313313
{
314-
startTimestamp = DateTime.Now;
314+
startTimestamp = DateTime.UtcNow;
315315

316-
while (DateTime.Now.Subtract(startTimestamp).TotalMilliseconds < timeout && receivedData.Count < tcpMessageDataLength)
316+
while (DateTime.UtcNow.Subtract(startTimestamp).TotalMilliseconds < timeout && receivedData.Count < tcpMessageDataLength)
317317
{
318318
Memory<byte> buffer = new byte[4096];
319-
TimeSpan receiveTimeout = TimeSpan.FromMilliseconds(timeout).Subtract(DateTime.Now.Subtract(startTimestamp));
319+
TimeSpan receiveTimeout = TimeSpan.FromMilliseconds(timeout).Subtract(DateTime.UtcNow.Subtract(startTimestamp));
320320

321321
if (receiveTimeout.TotalMilliseconds >= 50)
322322
{

RICADO.Omron/Channels/EthernetUDPChannel.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,12 @@ protected override async Task<ReceiveMessageResult> ReceiveMessageAsync(int time
123123
try
124124
{
125125
List<byte> receivedData = new List<byte>();
126-
DateTime startTimestamp = DateTime.Now;
126+
DateTime startTimestamp = DateTime.UtcNow;
127127

128-
while(DateTime.Now.Subtract(startTimestamp).TotalMilliseconds < timeout && receivedData.Count < FINSResponse.HEADER_LENGTH + FINSResponse.COMMAND_LENGTH + FINSResponse.RESPONSE_CODE_LENGTH)
128+
while(DateTime.UtcNow.Subtract(startTimestamp).TotalMilliseconds < timeout && receivedData.Count < FINSResponse.HEADER_LENGTH + FINSResponse.COMMAND_LENGTH + FINSResponse.RESPONSE_CODE_LENGTH)
129129
{
130130
Memory<byte> buffer = new byte[4096];
131-
TimeSpan receiveTimeout = TimeSpan.FromMilliseconds(timeout).Subtract(DateTime.Now.Subtract(startTimestamp));
131+
TimeSpan receiveTimeout = TimeSpan.FromMilliseconds(timeout).Subtract(DateTime.UtcNow.Subtract(startTimestamp));
132132

133133
if (receiveTimeout.TotalMilliseconds >= 50)
134134
{

RICADO.Omron/OmronPLC.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ public class OmronPLC : IDisposable
4040

4141
internal EthernetChannel Channel => _channel;
4242

43-
internal int MaximumReadWordLength => _plcType == enPLCType.CP1 ? 499 : 999;
44-
45-
internal int MaximumWriteWordLength => _plcType == enPLCType.CP1 ? 496 : 996;
46-
4743
internal bool IsNSeries => _plcType switch
4844
{
4945
enPLCType.NJ101 => true,
@@ -113,6 +109,10 @@ public int Retries
113109

114110
public string ControllerVersion => _controllerVersion;
115111

112+
public int MaximumReadWordLength => _plcType == enPLCType.CP1 ? 499 : 999;
113+
114+
public int MaximumWriteWordLength => _plcType == enPLCType.CP1 ? 496 : 996;
115+
116116
#endregion
117117

118118

0 commit comments

Comments
 (0)