27
27
@ ExtendWith (MockitoExtension .class )
28
28
class HmiServiceTest {
29
29
30
+ private static final String DQC_REPORT_TYPE = "DQC" ;
31
+ private static final String CYC_REPORT_TYPE = "CYC" ;
30
32
@ InjectMocks
31
33
HmiService hmiService ;
32
34
@@ -42,7 +44,7 @@ void setUp() {
42
44
void createAllIhmReportControlBlocks_with_fc_ST_should_create_dataset_and_controlblock () {
43
45
// Given
44
46
SCL scd = SclTestMarshaller .getSCLFromFile ("/scd-hmi-create-report-cb/scd_create_dataset_and_controlblocks_for_hmi.xml" );
45
- TFCDAFilter tfcdaFilter = createFCDAFilter ("LdInst11" , "ANCR" , "1" , null , "DoName1" , Tfc .ST );
47
+ TFCDAFilter tfcdaFilter = createFCDAFilter ("LdInst11" , "ANCR" , "1" , null , "DoName1" , Tfc .ST , DQC_REPORT_TYPE );
46
48
po .getFCDAs ().getFCDA ().add (tfcdaFilter );
47
49
// When
48
50
hmiService .createAllHmiReportControlBlocks (scd , po );
@@ -69,7 +71,7 @@ void createAllIhmReportControlBlocks_with_fc_ST_should_create_dataset_and_contro
69
71
void createAllIhmReportControlBlocks_with_fc_MX_should_create_dataset_and_controlblock () {
70
72
// Given
71
73
SCL scd = SclTestMarshaller .getSCLFromFile ("/scd-hmi-create-report-cb/scd_create_dataset_and_controlblocks_for_hmi.xml" );
72
- TFCDAFilter tfcdaFilter = createFCDAFilter ("LdInst11" , "PVOC" , "1" , null , "DoName2" , Tfc .MX );
74
+ TFCDAFilter tfcdaFilter = createFCDAFilter ("LdInst11" , "PVOC" , "1" , null , "DoName2" , Tfc .MX , CYC_REPORT_TYPE );
73
75
po .getFCDAs ().getFCDA ().add (tfcdaFilter );
74
76
// When
75
77
hmiService .createAllHmiReportControlBlocks (scd , po );
@@ -93,11 +95,39 @@ void createAllIhmReportControlBlocks_with_fc_MX_should_create_dataset_and_contro
93
95
assertThat (reportControl .getRptEnabled ().isSetClientLN ()).isFalse ();
94
96
}
95
97
98
+ @ Test
99
+ void createAllIhmReportControlBlocks_with_fc_MX_and_DQC_REPORT_TYPE_should_create_dataset_and_controlblock_with_suffix_DQPO () {
100
+ // Given
101
+ SCL scd = SclTestMarshaller .getSCLFromFile ("/scd-hmi-create-report-cb/scd_create_dataset_and_controlblocks_for_hmi.xml" );
102
+ TFCDAFilter tfcdaFilter = createFCDAFilter ("LdInst11" , "PVOC" , "1" , null , "DoName2" , Tfc .MX , DQC_REPORT_TYPE );
103
+ po .getFCDAs ().getFCDA ().add (tfcdaFilter );
104
+ // When
105
+ hmiService .createAllHmiReportControlBlocks (scd , po );
106
+ // Then
107
+ // Check DataSet is created
108
+ DataSetAdapter dataSet = findDataSet (scd , "IedName1" , "LdInst11" , "DS_LDINST11_DQPO" );
109
+ assertThat (dataSet .getCurrentElem ().getFCDA ()).hasSize (1 ).first ()
110
+ .usingRecursiveComparison ().isEqualTo (toFCDA (tfcdaFilter ));
111
+ // Check ControlBlock is created
112
+ LN0Adapter ln0 = findLn0 (scd , "IedName1" , "LdInst11" );
113
+ assertThat (ln0 .getTControlsByType (TReportControl .class )).hasSize (1 );
114
+
115
+ TReportControl reportControl = findControlBlock (scd , "IedName1" , "LdInst11" , "CB_LDINST11_DQPO" , TReportControl .class );
116
+ assertThat (reportControl ).extracting (TReportControl ::getRptID , TControl ::getDatSet , TReportControl ::getConfRev , TReportControl ::isBuffered , TReportControl ::getBufTime , TReportControl ::isIndexed ,
117
+ TControlWithTriggerOpt ::getIntgPd )
118
+ .containsExactly ("IedName1LdInst11/LLN0.CB_LDINST11_DQPO" , "DS_LDINST11_DQPO" , 1L , true , 0L , true , 60000L );
119
+ assertThat (reportControl .getTrgOps ())
120
+ .extracting (TTrgOps ::isDchg , TTrgOps ::isQchg , TTrgOps ::isDupd , TTrgOps ::isPeriod , TTrgOps ::isGi )
121
+ .containsExactly (true , true , false , true , true );
122
+ assertThat (reportControl .getRptEnabled ().getMax ()).isEqualTo (1 );
123
+ assertThat (reportControl .getRptEnabled ().isSetClientLN ()).isFalse ();
124
+ }
125
+
96
126
@ Test
97
127
void createAllIhmReportControlBlocks_with_FCDA_on_ln0_should_create_dataset_and_controlblock () {
98
128
// Given
99
129
SCL scd = SclTestMarshaller .getSCLFromFile ("/scd-hmi-create-report-cb/scd_create_dataset_and_controlblocks_for_hmi.xml" );
100
- TFCDAFilter tfcdaFilter = createFCDAFilter ("LdInst11" , "LLN0" , null , null , "DoName0" , Tfc .ST );
130
+ TFCDAFilter tfcdaFilter = createFCDAFilter ("LdInst11" , "LLN0" , null , null , "DoName0" , Tfc .ST , DQC_REPORT_TYPE );
101
131
po .getFCDAs ().getFCDA ().add (tfcdaFilter );
102
132
// When
103
133
hmiService .createAllHmiReportControlBlocks (scd , po );
@@ -126,7 +156,7 @@ void createAllIhmReportControlBlocks_when_lDevice_ON_but_LN_Mod_StVal_missing_sh
126
156
SCL scd = SclTestMarshaller .getSCLFromFile ("/scd-hmi-create-report-cb/scd_create_dataset_and_controlblocks_for_hmi.xml" );
127
157
LNAdapter ln = findLn (scd , "IedName1" , "LdInst11" , "ANCR" , "1" , null );
128
158
ln .getCurrentElem ().unsetDOI ();
129
- TFCDAFilter tfcdaFilter = createFCDAFilter ("LdInst11" , "ANCR" , "1" , null , "DoName1" , Tfc .ST );
159
+ TFCDAFilter tfcdaFilter = createFCDAFilter ("LdInst11" , "ANCR" , "1" , null , "DoName1" , Tfc .ST , DQC_REPORT_TYPE );
130
160
po .getFCDAs ().getFCDA ().add (tfcdaFilter );
131
161
// When
132
162
hmiService .createAllHmiReportControlBlocks (scd , po );
@@ -151,7 +181,7 @@ void createAllIhmReportControlBlocks_when_lDevice_ON_but_LN_Mod_StVal_OFF_should
151
181
LNAdapter ln = findLn (scd , "IedName1" , "LdInst11" , "ANCR" , "1" , null );
152
182
ln .getDOIAdapterByName (CommonConstants .MOD_DO_NAME ).getDataAdapterByName (CommonConstants .STVAL_DA_NAME ).setVal ("off" );
153
183
assertThat (ln .getDaiModStValValue ()).hasValue ("off" );
154
- TFCDAFilter tfcdaFilter = createFCDAFilter ("LdInst11" , "ANCR" , "1" , null , "DoName1" , Tfc .ST );
184
+ TFCDAFilter tfcdaFilter = createFCDAFilter ("LdInst11" , "ANCR" , "1" , null , "DoName1" , Tfc .ST , DQC_REPORT_TYPE );
155
185
po .getFCDAs ().getFCDA ().add (tfcdaFilter );
156
186
// When
157
187
hmiService .createAllHmiReportControlBlocks (scd , po );
@@ -167,7 +197,7 @@ void createAllIhmReportControlBlocks_when_lDevice_OFF_should_not_create_dataset(
167
197
LN0Adapter ln0 = findLn0 (scd , "IedName1" , "LdInst11" );
168
198
ln0 .getDOIAdapterByName (CommonConstants .MOD_DO_NAME ).getDataAdapterByName (CommonConstants .STVAL_DA_NAME ).setVal ("off" );
169
199
assertThat (findLDevice (scd , "IedName1" , "LdInst11" ).getLDeviceStatus ()).hasValue (ActiveStatus .OFF .getValue ());
170
- TFCDAFilter tfcdaFilter = createFCDAFilter ("LdInst11" , "ANCR" , "1" , null , "DoName1" , Tfc .ST );
200
+ TFCDAFilter tfcdaFilter = createFCDAFilter ("LdInst11" , "ANCR" , "1" , null , "DoName1" , Tfc .ST , DQC_REPORT_TYPE );
171
201
po .getFCDAs ().getFCDA ().add (tfcdaFilter );
172
202
// When
173
203
hmiService .createAllHmiReportControlBlocks (scd , po );
@@ -183,7 +213,7 @@ void createAllIhmReportControlBlocks_when_LDevice_has_no_status_should_not_creat
183
213
LN0Adapter ln0 = findLn0 (scd , "IedName1" , "LdInst11" );
184
214
ln0 .getDOIAdapterByName (CommonConstants .MOD_DO_NAME ).getDataAdapterByName (CommonConstants .STVAL_DA_NAME ).getCurrentElem ().unsetVal ();
185
215
assertThat (findLDevice (scd , "IedName1" , "LdInst11" ).getLDeviceStatus ()).isEmpty ();
186
- TFCDAFilter tfcdaFilter = createFCDAFilter ("LdInst11" , "ANCR" , "1" , null , "DoName1" , Tfc .ST );
216
+ TFCDAFilter tfcdaFilter = createFCDAFilter ("LdInst11" , "ANCR" , "1" , null , "DoName1" , Tfc .ST , DQC_REPORT_TYPE );
187
217
po .getFCDAs ().getFCDA ().add (tfcdaFilter );
188
218
// When
189
219
hmiService .createAllHmiReportControlBlocks (scd , po );
@@ -192,14 +222,15 @@ void createAllIhmReportControlBlocks_when_LDevice_has_no_status_should_not_creat
192
222
assertThat (streamAllControlBlocks (scd , TReportControl .class )).isEmpty ();
193
223
}
194
224
195
- private static TFCDAFilter createFCDAFilter (String ldInst , String lnClass , String lnInst , String prefix , String doName , Tfc tfc ) {
225
+ private static TFCDAFilter createFCDAFilter (String ldInst , String lnClass , String lnInst , String prefix , String doName , Tfc tfc , String reportType ) {
196
226
TFCDAFilter tfcdaFilter = new TFCDAFilter ();
197
- tfcdaFilter .setLdInst ("LdInst11" );
227
+ tfcdaFilter .setLdInst (ldInst );
198
228
tfcdaFilter .setLnClass (lnClass );
199
- tfcdaFilter .setPrefix (null );
229
+ tfcdaFilter .setPrefix (prefix );
200
230
tfcdaFilter .setDoName (doName );
201
231
tfcdaFilter .setLnInst (lnInst );
202
232
tfcdaFilter .setFc (tfc );
233
+ tfcdaFilter .setReportType (reportType );
203
234
return tfcdaFilter ;
204
235
}
205
236
0 commit comments