@@ -69,22 +69,26 @@ public class ReptParam
69
69
public ReportControlBlock rcb ;
70
70
}
71
71
72
- static Boolean MMSTestDoubleStateFailed ( MmsValue mv )
72
+ static bool MMSTestDoubleStateFailed ( MmsValue mv )
73
73
{ // test for double state inconsistent (bitstring of 2 with same values)
74
74
return ( mv . GetType ( ) == MmsType . MMS_BIT_STRING && mv . Size ( ) == 2 && mv . GetBit ( 0 ) == mv . GetBit ( 1 ) ) ;
75
75
}
76
+ static bool MMSTestDoubleStateTransient ( MmsValue mv )
77
+ { // test for double state inconsistent (bitstring of 2 with same values)
78
+ return ( mv . GetType ( ) == MmsType . MMS_BIT_STRING && mv . Size ( ) == 2 && mv . GetBit ( 0 ) == false && mv . GetBit ( 1 ) == false ) ;
79
+ }
76
80
77
- static Boolean MMSGetQualityFailed ( MmsValue mv )
81
+ static bool MMSGetQualityFailed ( MmsValue mv )
78
82
{ // tries to find a qualifier of iec61850 (bitstring) in a mms structure
79
- Boolean f = false ;
80
- Boolean found = false ;
83
+ bool f = false ;
84
+ bool found = false ;
81
85
switch ( mv . GetType ( ) )
82
86
{
83
87
case MmsType . MMS_STRUCTURE :
84
88
for ( int i = 0 ; i < mv . Size ( ) ; i ++ )
85
- if ( mv . GetElement ( i ) . GetType ( ) == MmsType . MMS_BIT_STRING )
89
+ if ( mv . GetElement ( i ) . GetType ( ) == MmsType . MMS_BIT_STRING && mv . GetElement ( i ) . Size ( ) > 2 )
86
90
{
87
- f = ! ( mv . GetElement ( i ) . BitStringToUInt32BigEndian ( ) == 0 ) ;
91
+ f = new Quality ( ( int ) mv . GetElement ( i ) . BitStringToUInt32 ( ) ) . GetValidity ( ) != Validity . GOOD ;
88
92
found = true ;
89
93
break ;
90
94
}
@@ -100,11 +104,35 @@ static Boolean MMSGetQualityFailed(MmsValue mv)
100
104
}
101
105
return f ;
102
106
}
107
+ static bool MMSGetQualityTransient ( MmsValue mv )
108
+ { // tries to find a qualifier of iec61850 (bitstring) in a mms structure
109
+ bool t = false ;
110
+ bool found = false ;
111
+ switch ( mv . GetType ( ) )
112
+ {
113
+ case MmsType . MMS_STRUCTURE :
114
+ for ( int i = 0 ; i < mv . Size ( ) ; i ++ )
115
+ if ( mv . Size ( ) == 2 && mv . GetElement ( i ) . GetType ( ) == MmsType . MMS_BIT_STRING )
116
+ {
117
+ t = mv . GetBit ( 0 ) == false && mv . GetBit ( 1 ) == false ;
118
+ found = true ;
119
+ break ;
120
+ }
121
+ if ( ! found )
122
+ t = MMSGetQualityFailed ( mv . GetElement ( 0 ) ) ;
123
+ break ;
124
+ case MmsType . MMS_BIT_STRING :
125
+ if ( MMSTestDoubleStateTransient ( mv ) )
126
+ t = true ;
127
+ break ;
128
+ }
129
+ return t ;
130
+ }
103
131
104
132
static ulong MMSGetTimestamp ( MmsValue mv )
105
133
{ // tries to find a timestamp of iec61850 (utc time) in a mms structure, return number of ms UTC
106
134
ulong t = 0 ;
107
- Boolean found = false ;
135
+ bool found = false ;
108
136
switch ( mv . GetType ( ) )
109
137
{
110
138
case MmsType . MMS_STRUCTURE :
@@ -125,10 +153,10 @@ static ulong MMSGetTimestamp(MmsValue mv)
125
153
return t ;
126
154
}
127
155
128
- static Double MMSGetNumericVal ( MmsValue mv , out Boolean isBinary )
156
+ static Double MMSGetNumericVal ( MmsValue mv , out bool isBinary )
129
157
{ // tries to find a numeric value of iec61850 (flot, integer, unsigned) in a mms structure
130
158
Double v = 0 ;
131
- Boolean found = false ;
159
+ bool found = false ;
132
160
isBinary = false ;
133
161
switch ( mv . GetType ( ) )
134
162
{
@@ -193,7 +221,7 @@ static Double MMSGetNumericVal(MmsValue mv, out Boolean isBinary)
193
221
return v ;
194
222
}
195
223
196
- static Double MMSGetDoubleVal ( MmsValue mv , out Boolean isBinary )
224
+ static Double MMSGetDoubleVal ( MmsValue mv , out bool isBinary )
197
225
{ // tries to convert any mms value into a double
198
226
Double v = 0 ;
199
227
isBinary = false ;
@@ -412,10 +440,11 @@ private static void reportHandler(Report report, object parameter)
412
440
log += " Included for reason " + report . GetReasonForInclusion ( k ) . ToString ( ) + " \n " ;
413
441
string tag = entry . js_tag ;
414
442
var value = values . GetElement ( k ) ;
415
- double v ;
416
- bool failed ;
417
- ulong timestamp ;
418
- Boolean isBinary = false ;
443
+ double v = 0 ;
444
+ bool failed = false ;
445
+ ulong timestamp = 0 ;
446
+ bool isBinary = false ;
447
+ bool transient = false ;
419
448
420
449
if ( value . GetType ( ) == MmsType . MMS_STRUCTURE )
421
450
{
@@ -430,6 +459,7 @@ private static void reportHandler(Report report, object parameter)
430
459
}
431
460
v = MMSGetNumericVal ( value , out isBinary ) ;
432
461
failed = MMSGetQualityFailed ( value ) ;
462
+ transient = MMSGetQualityTransient ( value ) ;
433
463
timestamp = MMSGetTimestamp ( value ) ;
434
464
435
465
for ( int i = 0 ; i < value . Size ( ) ; i ++ )
@@ -450,6 +480,7 @@ private static void reportHandler(Report report, object parameter)
450
480
}
451
481
}
452
482
failed = MMSGetQualityFailed ( value . GetElement ( i ) ) ;
483
+ transient = MMSGetQualityTransient ( value . GetElement ( i ) ) ;
453
484
timestamp = MMSGetTimestamp ( value . GetElement ( i ) ) ;
454
485
if ( value . GetElement ( i ) . GetType ( ) == MmsType . MMS_BIT_STRING )
455
486
{
@@ -460,7 +491,7 @@ private static void reportHandler(Report report, object parameter)
460
491
if ( value . GetElement ( i ) . GetType ( ) == MmsType . MMS_UTC_TIME )
461
492
{
462
493
if ( LogLevel > LogLevelNoLog )
463
- log += " -> " + value . GetElement ( i ) . GetUtcTimeAsDateTimeOffset ( ) + "\n " ;
494
+ log += " -> " + value . GetElement ( i ) . GetUtcTimeAsDateTimeOffset ( ) . ToString ( "o" ) + "\n " ;
464
495
}
465
496
else
466
497
{
@@ -478,6 +509,7 @@ private static void reportHandler(Report report, object parameter)
478
509
var iv = new IECValue
479
510
{
480
511
isDigital = isBinary ,
512
+ isTransient = transient ,
481
513
value = v ,
482
514
valueString = vstr ,
483
515
valueJson = MMSGetStringValue ( value ) ,
@@ -509,7 +541,8 @@ private static void reportHandler(Report report, object parameter)
509
541
log += " Value is of simple type " + value . GetType ( ) + " " + v ;
510
542
}
511
543
failed = false ;
512
- if ( MMSTestDoubleStateFailed ( value ) ) failed = true ; // double state inconsistent status
544
+ failed = MMSTestDoubleStateFailed ( value ) ; // double state inconsistent status
545
+ transient = MMSTestDoubleStateTransient ( value ) ; // double state inconsistent status
513
546
string vstr ;
514
547
if ( isBinary )
515
548
vstr = v != 0 ? "true" : "false" ;
@@ -519,6 +552,7 @@ private static void reportHandler(Report report, object parameter)
519
552
var iv = new IECValue
520
553
{
521
554
isDigital = isBinary ,
555
+ isTransient = transient ,
522
556
value = v ,
523
557
valueString = vstr ,
524
558
valueJson = MMSGetStringValue ( value ) ,
@@ -848,6 +882,7 @@ static void Process(Iec61850Connection srv)
848
882
var tp = value . GetType ( ) ;
849
883
double v = 0 ;
850
884
bool failed = false ;
885
+ bool transient = false ;
851
886
ulong timestamp = 0 ;
852
887
bool isBinary = false ;
853
888
@@ -857,6 +892,7 @@ static void Process(Iec61850Connection srv)
857
892
if ( LogLevel >= LogLevelDetailed ) log += "\n Value is of complex type \n " ;
858
893
v = MMSGetNumericVal ( value , out isBinary ) ;
859
894
failed = MMSGetQualityFailed ( value ) ;
895
+ transient = MMSGetQualityTransient ( value ) ;
860
896
timestamp = MMSGetTimestamp ( value ) ;
861
897
862
898
for ( int i = 0 ; i < value . Size ( ) ; i ++ )
@@ -874,6 +910,7 @@ static void Process(Iec61850Connection srv)
874
910
}
875
911
}
876
912
failed = MMSGetQualityFailed ( value . GetElement ( i ) ) ;
913
+ transient = MMSGetQualityTransient ( value . GetElement ( i ) ) ;
877
914
timestamp = MMSGetTimestamp ( value . GetElement ( i ) ) ;
878
915
if ( value . GetElement ( i ) . GetType ( ) == MmsType . MMS_BIT_STRING )
879
916
{
@@ -882,7 +919,7 @@ static void Process(Iec61850Connection srv)
882
919
else
883
920
if ( value . GetElement ( i ) . GetType ( ) == MmsType . MMS_UTC_TIME )
884
921
{
885
- if ( LogLevel >= LogLevelDetailed ) log += " -> " + value . GetElement ( i ) . GetUtcTimeAsDateTimeOffset ( ) + "\n " ;
922
+ if ( LogLevel >= LogLevelDetailed ) log += " -> " + value . GetElement ( i ) . GetUtcTimeAsDateTimeOffset ( ) . ToString ( "o" ) + "\n " ;
886
923
}
887
924
else
888
925
{
@@ -899,6 +936,7 @@ static void Process(Iec61850Connection srv)
899
936
var iv = new IECValue
900
937
{
901
938
isDigital = isBinary ,
939
+ isTransient = transient ,
902
940
value = v ,
903
941
valueString = vstr ,
904
942
valueJson = MMSGetStringValue ( value ) ,
@@ -922,7 +960,8 @@ static void Process(Iec61850Connection srv)
922
960
else
923
961
{
924
962
v = MMSGetDoubleVal ( value , out isBinary ) ;
925
- if ( MMSTestDoubleStateFailed ( value ) ) failed = true ; // double state inconsistent status
963
+ failed = MMSTestDoubleStateFailed ( value ) ; // double state inconsistent status
964
+ transient = MMSTestDoubleStateTransient ( value ) ; // double state inconsistent status
926
965
string vstr ;
927
966
if ( isBinary )
928
967
vstr = v != 0 ? "true" : "false" ;
@@ -932,6 +971,7 @@ static void Process(Iec61850Connection srv)
932
971
var iv = new IECValue
933
972
{
934
973
isDigital = isBinary ,
974
+ isTransient = transient ,
935
975
value = v ,
936
976
valueString = vstr ,
937
977
valueJson = MMSGetStringValue ( value ) ,
0 commit comments