File tree Expand file tree Collapse file tree 4 files changed +15
-15
lines changed Expand file tree Collapse file tree 4 files changed +15
-15
lines changed Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff 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 {
Original file line number Diff line number Diff 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 {
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments