Skip to content

Commit

Permalink
- added error handling on CP56Time2A.GetDateTime function
Browse files Browse the repository at this point in the history
- fixed wrong return type for parameter qualifier in pParameter information objects
  • Loading branch information
mzillgith committed Nov 13, 2018
1 parent d83d26d commit 8b0ee79
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
23 changes: 21 additions & 2 deletions lib60870/CP56Time2a.cs
Expand Up @@ -65,8 +65,27 @@ public DateTime GetDateTime(int startYear)
if (this.Year < (startYear % 100))
baseYear += 100;

DateTime value = new DateTime (baseYear + this.Year, this.Month, this.DayOfMonth, this.Hour, this.Minute, this.Second, this.Millisecond);

int month = this.Month;

if (month == 0)
month = 1;

int dayOfMonth = this.DayOfMonth;

if (dayOfMonth == 0)
dayOfMonth = 1;

DateTime value;

try
{
value = new DateTime(baseYear + this.Year, month, dayOfMonth, this.Hour, this.Minute, this.Second, this.Millisecond);
}
catch (ArgumentOutOfRangeException)
{
value = new DateTime(0);
}

return value;
}

Expand Down
4 changes: 2 additions & 2 deletions lib60870/CS101/ParameterMeasuredValues.cs
Expand Up @@ -154,7 +154,7 @@ public class ParameterScaledValue : InformationObject

private byte qpm;

public float QPM {
public byte QPM {
get {
return qpm;
}
Expand Down Expand Up @@ -220,7 +220,7 @@ public class ParameterFloatValue : InformationObject

private byte qpm;

public float QPM {
public byte QPM {
get {
return qpm;
}
Expand Down
2 changes: 1 addition & 1 deletion lib60870/CS104/Connection.cs
Expand Up @@ -1676,7 +1676,7 @@ private void HandleConnection()
}

if (suspendThread)
Thread.Sleep(10);
Thread.Sleep(1);

}
catch (SocketException)
Expand Down

0 comments on commit 8b0ee79

Please sign in to comment.