Skip to content

Commit 8b0ee79

Browse files
committed
- added error handling on CP56Time2A.GetDateTime function
- fixed wrong return type for parameter qualifier in pParameter information objects
1 parent d83d26d commit 8b0ee79

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

lib60870/CP56Time2a.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,27 @@ public DateTime GetDateTime(int startYear)
6565
if (this.Year < (startYear % 100))
6666
baseYear += 100;
6767

68-
DateTime value = new DateTime (baseYear + this.Year, this.Month, this.DayOfMonth, this.Hour, this.Minute, this.Second, this.Millisecond);
69-
68+
int month = this.Month;
69+
70+
if (month == 0)
71+
month = 1;
72+
73+
int dayOfMonth = this.DayOfMonth;
74+
75+
if (dayOfMonth == 0)
76+
dayOfMonth = 1;
77+
78+
DateTime value;
79+
80+
try
81+
{
82+
value = new DateTime(baseYear + this.Year, month, dayOfMonth, this.Hour, this.Minute, this.Second, this.Millisecond);
83+
}
84+
catch (ArgumentOutOfRangeException)
85+
{
86+
value = new DateTime(0);
87+
}
88+
7089
return value;
7190
}
7291

lib60870/CS101/ParameterMeasuredValues.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public ScaledValue ScaledValue {
154154

155155
private byte qpm;
156156

157-
public float QPM {
157+
public byte QPM {
158158
get {
159159
return qpm;
160160
}
@@ -220,7 +220,7 @@ public float Value {
220220

221221
private byte qpm;
222222

223-
public float QPM {
223+
public byte QPM {
224224
get {
225225
return qpm;
226226
}

lib60870/CS104/Connection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1676,7 +1676,7 @@ private void HandleConnection()
16761676
}
16771677

16781678
if (suspendThread)
1679-
Thread.Sleep(10);
1679+
Thread.Sleep(1);
16801680

16811681
}
16821682
catch (SocketException)

0 commit comments

Comments
 (0)