OneM2M_Functions.ttcn 229 KB
Newer Older
1 2 3 4 5 6 7
/**
 *  Copyright Notification
 *  No part of this document may be reproduced, in an electronic retrieval system or otherwise, except as authorized by written permission.
 *  The copyright and the foregoing restriction extend to reproduction in all media.
 *  © 2016, oneM2M Partners Type 1 (ARIB, ATIS, CCSA, ETSI, TIA, TSDSI, TTA, TTC).
 *  All rights reserved.
 *  
8 9 10
 *  @author     ETSI
 *  @version    $URL: https://oldforge.etsi.org/svn/oneM2M/branches/Release1/ttcn/LibOneM2M/OneM2M_Functions.ttcn $
 *              $Id: OneM2M_Functions.ttcn 347 2017-08-11 08:48:20Z reinaortega $
11 12 13 14 15 16
 *  @desc       Module containing functions for oneM2M
 *
 */
module OneM2M_Functions {
	
	import from XSD all;
17
	import from LibCommon_Time all;
18
	import from OneM2M_Templates all;
19
	import from OneM2M_Types all;
20 21 22
	import from OneM2M_TypesAndValues all;
	import from OneM2M_TestSystem all;
	import from OneM2M_Pixits all;
23
	import from OneM2M_Pics all;
24
	
25
	group ConfigFunctions {
26
		
27 28 29
		/**
			@desc Ports mapping and default behaviour activation for Config 1
		*/
Yann Garcia's avatar
Yann Garcia committed
30
		function f_cf01Up(in boolean p_auxiliaryAe2Required := false) runs on AeSimu system CseSystem {
31
			
32
			// Variables
33 34
      var charstring v_binding;
      var charstring v_binding_in;
35
      var charstring v_host;
36 37
			vc_config := e_cf01;
			vc_testSystemRole := e_ae;	
38
			
39
			// Map
40 41
			map(self:mcaPort, system:mcaPort) param (PX_TS_AE1.mcaPort);
			map(self:mcaPortIn, system:mcaPortIn) param (PX_TS_AE1.mcaPortIn);
42
			map(self:acPort, system:acPort);
43
			
44
			if (ischosen(PX_TS_AE1.mcaPort.binding.httpBindingDesc)) { // FIXME Create a function to initialize vc_myInterfaces
45
				v_binding := "HTTP";
46 47
				v_host := PX_TS_AE1.mcaPort.binding.httpBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE1.mcaPort.binding.httpBindingDesc.bindingDesc.remotePort); 
			} else if (ischosen(PX_TS_AE1.mcaPort.binding.coapBindingDesc)) {
48
				v_binding := "COAP";
49 50
				v_host := PX_TS_AE1.mcaPort.binding.coapBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE1.mcaPort.binding.coapBindingDesc.bindingDesc.remotePort);
			} else if (ischosen(PX_TS_AE1.mcaPort.binding.mqttBindingDesc)) {
51
				v_binding := "MQTT";
52
				v_host := PX_TS_AE1.mcaPort.binding.mqttBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE1.mcaPort.binding.mqttBindingDesc.bindingDesc.remotePort);
53 54
			} else {
				v_binding := "WSCK";
55
				v_host := PX_TS_AE1.mcaPort.binding.wsBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE1.mcaPort.binding.wsBindingDesc.bindingDesc.remotePort);
56
			}
57
      if (ischosen(PX_TS_AE1.mcaPortIn.binding.httpBindingDesc)) {
58
        v_binding_in := "HTTP";
59
      } else if (ischosen(PX_TS_AE1.mcaPortIn.binding.coapBindingDesc)) {
60
        v_binding_in := "COAP";
61
      } else if (ischosen(PX_TS_AE1.mcaPortIn.binding.mqttBindingDesc)) {
62 63 64 65 66
        v_binding_in := "MQTT";
      } else {
        v_binding_in := "WSCK";
      }
			
67 68
			vc_myInterfaces[enum2int(InterfaceIds:e_mca_port)] := { mcaPort, v_host, v_binding, c_serializationLabel[enum2int(PX_TS_AE1.mcaPort.serialization)] };
      vc_myInterfaces[enum2int(InterfaceIds:e_mca_in_port)] := { mcaPortIn, v_host, v_binding_in, c_serializationLabel[enum2int(PX_TS_AE1.mcaPortIn.serialization)] };
69
			
70
			activate(a_default());
71
			vc_aeSimu := activate(a_cse_cf01());
72
				
73 74 75 76 77
			// Initialize AE2
			if(p_auxiliaryAe2Required) {
				vc_auxiliaryAe2Up := p_auxiliaryAe2Required;
				vc_ae2 := AeSimu.create("AE2") alive;
				vc_ae2.start(f_cf01UpAe2());
78
				vc_ae2.done;
79 80 81 82 83 84 85 86 87
			}
				
			//Initialze the IUT
							
		} // end f_cf01Up
		
		/**
			@desc Ports mapping and default behaviour activation for Config 1 on the auxiliary AE2
		*/
Yann Garcia's avatar
Yann Garcia committed
88
		function f_cf01UpAe2() runs on AeSimu system CseSystem {
89 90
			
			// Variables
91 92
			var charstring v_binding;
			var charstring v_binding_in;
93
      var charstring v_host;
94 95
			vc_config := e_cf01;
			vc_testSystemRole := e_ae;		
96 97
			
			// Map
98 99
			map(self:mcaPort, system:mcaPort) param (PX_TS_AE2.mcaPort);
			map(self:mcaPortIn, system:mcaPortIn) param (PX_TS_AE2.mcaPortIn);
100 101
			map(self:acPort, system:acPort);
	
102
      if (ischosen(PX_TS_AE2.mcaPort.binding.httpBindingDesc)) {
103
        v_binding := "HTTP";
104 105
        v_host := PX_TS_AE2.mcaPort.binding.httpBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE2.mcaPort.binding.httpBindingDesc.bindingDesc.remotePort);
      } else if (ischosen(PX_TS_AE2.mcaPort.binding.coapBindingDesc)) {
106
        v_binding := "COAP";
107 108
        v_host := PX_TS_AE2.mcaPort.binding.coapBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE2.mcaPort.binding.coapBindingDesc.bindingDesc.remotePort);
      } else if (ischosen(PX_TS_AE2.mcaPort.binding.mqttBindingDesc)) {
109
        v_binding := "MQTT";
110
        v_host := PX_TS_AE2.mcaPort.binding.mqttBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE2.mcaPort.binding.mqttBindingDesc.bindingDesc.remotePort);
111 112
      } else {
        v_binding := "WSCK";
113
        v_host := PX_TS_AE2.mcaPort.binding.wsBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE2.mcaPort.binding.wsBindingDesc.bindingDesc.remotePort);
114
      }
115
      if (ischosen(PX_TS_AE2.mcaPortIn.binding.httpBindingDesc)) {
116
        v_binding_in := "HTTP";
117
      } else if (ischosen(PX_TS_AE2.mcaPortIn.binding.coapBindingDesc)) {
Yann Garcia's avatar
Yann Garcia committed
118
        v_binding_in := "COAP";
119
      } else if (ischosen(PX_TS_AE2.mcaPortIn.binding.mqttBindingDesc)) {
120 121 122 123 124
        v_binding_in := "MQTT";
      } else {
        v_binding_in := "WSCK";
      }
      
125 126
      vc_myInterfaces[enum2int(InterfaceIds:e_mca_port)] := { mcaPort, v_host, v_binding, c_serializationLabel[enum2int(PX_TS_AE2.mcaPort.serialization)] };
      vc_myInterfaces[enum2int(InterfaceIds:e_mca_in_port)] := { mcaPortIn, v_host, v_binding_in, c_serializationLabel[enum2int(PX_TS_AE2.mcaPortIn.serialization)] };
127

128
			//Initialze the IUT
129
							
130
		} // end f_cf01UpAe2
131
		
132 133 134
		/**
		 * @desc Ports mapping and default behaviour activation for Config 02
		 */
Yann Garcia's avatar
Yann Garcia committed
135
		function f_cf02Up(in CseTypeID p_cseType := int2) runs on AeSimu system CseSystem {
136
				
137
			// Variables
138
			var charstring v_binding;
139
      var charstring v_host;
140
			vc_config := e_cf02;
141
			vc_testSystemRole := e_ae;	
142
			vc_cse1 := CseSimu.create("CSE1") alive;
143
				
144
			// Map
145
			map(self:mcaPort, system:mcaPort) param (PX_TS_AE1.mcaPort);
146
			map(self:acPort, system:acPort);
147
			
148
      if (ischosen(PX_TS_AE1.mcaPort.binding.httpBindingDesc)) {
149
        v_binding := "HTTP";
150 151
        v_host := PX_TS_AE1.mcaPort.binding.httpBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE1.mcaPort.binding.httpBindingDesc.bindingDesc.remotePort);
      } else if (ischosen(PX_TS_AE1.mcaPort.binding.coapBindingDesc)) {
Yann Garcia's avatar
Yann Garcia committed
152
        v_binding := "COAP";
153 154
        v_host := PX_TS_AE1.mcaPort.binding.coapBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE1.mcaPort.binding.coapBindingDesc.bindingDesc.remotePort);
      } else if (ischosen(PX_TS_AE1.mcaPort.binding.mqttBindingDesc)) {
155
        v_binding := "MQTT";
156
        v_host := PX_TS_AE1.mcaPort.binding.mqttBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE1.mcaPort.binding.mqttBindingDesc.bindingDesc.remotePort);
157 158
      } else {
        v_binding := "WSCK";
159
        v_host := PX_TS_AE1.mcaPort.binding.wsBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE1.mcaPort.binding.wsBindingDesc.bindingDesc.remotePort);
160 161
      }
      
162
      vc_myInterfaces[enum2int(InterfaceIds:e_mca_port)] := { mcaPort, v_host, v_binding, c_serializationLabel[enum2int(PX_TS_AE1.mcaPort.serialization)] };
163
			
164
			if(PX_UT_IMPLEMENTED) {
165
				map(self:utPort, system:utPort) param (PX_TS_UT);
166
			}
167
			activate(a_default());
168
			vc_aeSimu := activate(a_cse_cf02_ae1());
169
			vc_cse1.start(f_cf02UpCse1(p_cseType));
170
			vc_cse1.done;
171
				
172
			// Connect
173
			
174
			//Initialze the IUT
175
							
176
		} // end f_cf02Up
177 178 179 180
		
		/**
			@desc Ports mapping and default behaviour activation for Config 2 on the CSE1
		*/
181
		function f_cf02UpCse1(in CseTypeID p_cseType := int2) runs on CseSimu system CseSystem {
182 183
			
			// Variables
184 185
      var charstring v_binding;
      var charstring v_binding_in;
186
      var charstring v_host;
187
			var PrimitiveContent v_cSEBaseResource;
188 189
			vc_config := e_cf02;
			vc_testSystemRole := e_cse;		
190
			vc_cseType := p_cseType;
191 192
			
			// Map
193 194
			map(self:mccPort, system:mccPort) param (PX_TS_CSE1.mccPort);
			map(self:mccPortIn, system:mccPortIn) param (PX_TS_CSE1.mccPortIn);
195
			map(self:acPort, system:acPort);
196
			
197
      if (ischosen(PX_TS_CSE1.mccPort.binding.httpBindingDesc)) {
198
        v_binding := "HTTP";
199 200
        v_host := PX_TS_CSE1.mcaPort.binding.httpBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mccPort.binding.httpBindingDesc.bindingDesc.remotePort);
      } else if (ischosen(PX_TS_CSE1.mccPort.binding.coapBindingDesc)) {
201
        v_binding := "COAP";
202 203
        v_host := PX_TS_CSE1.mcaPort.binding.coapBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mccPort.binding.coapBindingDesc.bindingDesc.remotePort);
      } else if (ischosen(PX_TS_CSE1.mccPort.binding.mqttBindingDesc)) {
204
        v_binding := "MQTT";
205
        v_host := PX_TS_CSE1.mcaPort.binding.mqttBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mccPort.binding.mqttBindingDesc.bindingDesc.remotePort);
206 207
      } else {
        v_binding := "WSCK";
208
        v_host := PX_TS_CSE1.mcaPort.binding.wsBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mccPort.binding.wsBindingDesc.bindingDesc.remotePort);
209
      }
210
      if (ischosen(PX_TS_CSE1.mccPortIn.binding.httpBindingDesc)) {
211
        v_binding_in := "HTTP";
212
      } else if (ischosen(PX_TS_CSE1.mccPortIn.binding.coapBindingDesc)) {
Yann Garcia's avatar
Yann Garcia committed
213
        v_binding_in := "COAP";
214
      } else if (ischosen(PX_TS_CSE1.mccPortIn.binding.mqttBindingDesc)) {
215 216 217 218 219
        v_binding_in := "MQTT";
      } else {
        v_binding_in := "WSCK";
      }
      
220 221
      vc_myInterfaces[enum2int(InterfaceIds:e_mcc_port)] := { mccPort, v_host, v_binding, c_serializationLabel[enum2int(PX_TS_CSE1.mccPort.serialization)] };
      vc_myInterfaces[enum2int(InterfaceIds:e_mcc_in_port)] := { mccPortIn, v_host, v_binding, c_serializationLabel[enum2int(PX_TS_CSE1.mccPortIn.serialization)] };
222
      
Miguel Angel Reina Ortega's avatar
Fix #47  
Miguel Angel Reina Ortega committed
223
			v_cSEBaseResource := f_generateLocalResource(-, -1, int5);
224 225
			vc_cSEBaseIndex := f_setLocalResource(v_cSEBaseResource, int5, -1);
			
226 227 228
			//Initialze the IUT
							
		} // end f_cf02UpCse1
229 230 231 232

		/**
		 * @desc Ports mapping and default behaviour activation for Config 02
		 */
233
		function f_cf02UpCseSimuMaster(in CseTypeID p_cseType := int2) runs on CseSimu system CseSystem {
234 235
				
			// Variables
236 237
      var charstring v_binding;
      var charstring v_binding_in;
238
      var charstring v_host;
239 240
			var PrimitiveContent v_cSEBaseResource;
			vc_config := e_cf02CseSimuMaster;
241 242
			vc_testSystemRole := e_cse;	
			vc_cseType := p_cseType;
243
			vc_ae1 := AeSimu.create("AE1") alive;
244 245
			
			//Initialization of local CSEBase
Miguel Angel Reina Ortega's avatar
Fix #47  
Miguel Angel Reina Ortega committed
246
			v_cSEBaseResource := f_generateLocalResource(-, -1, int5);
247
			vc_cSEBaseIndex := f_setLocalResource(v_cSEBaseResource, int5, -1);
248 249
				
			// Map
250 251
			map(self:mccPort, system:mccPort) param (PX_TS_CSE1.mccPort);
			map(self:mccPortIn, system:mccPortIn) param (PX_TS_CSE1.mccPortIn);
252
			map(self:acPort, system:acPort);
253
			
254
			if (ischosen(PX_TS_CSE1.mccPort.binding.httpBindingDesc)) {
Yann Garcia's avatar
Yann Garcia committed
255
			  v_binding := "HTTP";
256 257
			  v_host := PX_TS_CSE1.mcaPort.binding.httpBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mccPort.binding.httpBindingDesc.bindingDesc.remotePort);
			} else if (ischosen(PX_TS_CSE1.mccPort.binding.coapBindingDesc)) {
Yann Garcia's avatar
Yann Garcia committed
258
			  v_binding := "COAP";
259 260
			  v_host := PX_TS_CSE1.mcaPort.binding.coapBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mccPort.binding.coapBindingDesc.bindingDesc.remotePort);
			} else if (ischosen(PX_TS_CSE1.mccPort.binding.mqttBindingDesc)) {
Yann Garcia's avatar
Yann Garcia committed
261
			  v_binding := "MQTT";
262
			  v_host := PX_TS_CSE1.mcaPort.binding.mqttBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mccPort.binding.mqttBindingDesc.bindingDesc.remotePort);
Yann Garcia's avatar
Yann Garcia committed
263 264
			} else {
			  v_binding := "WSCK";
265
			  v_host := PX_TS_CSE1.mcaPort.binding.wsBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mccPort.binding.wsBindingDesc.bindingDesc.remotePort);
Yann Garcia's avatar
Yann Garcia committed
266
			}
267
      if (ischosen(PX_TS_CSE1.mccPortIn.binding.httpBindingDesc)) {
268
        v_binding_in := "HTTP";
269
      } else if (ischosen(PX_TS_CSE1.mccPortIn.binding.coapBindingDesc)) {
Yann Garcia's avatar
Yann Garcia committed
270
        v_binding_in := "COAP";
271
      } else if (ischosen(PX_TS_CSE1.mccPortIn.binding.mqttBindingDesc)) {
272 273 274 275 276
        v_binding_in := "MQTT";
      } else {
        v_binding_in := "WSCK";
      }
      
277 278
			vc_myInterfaces[enum2int(InterfaceIds:e_mcc_port)] := { mccPort, v_host, v_binding, c_serializationLabel[enum2int(PX_TS_CSE1.mccPort.serialization)] };
			vc_myInterfaces[enum2int(InterfaceIds:e_mcc_in_port)] := { mccPortIn, v_host, v_binding_in, c_serializationLabel[enum2int(PX_TS_CSE1.mccPortIn.serialization)] };
279
			
280
			activate(a_default());
281
			vc_cseSimu := activate(a_cse_cf02_cse1());
282 283
			vc_ae1.start(f_cf02UpAe1());
			vc_ae1.done;
284 285
				
			// Connect
286
			
287 288 289
			//Initialze the IUT
							
		} // end f_cf02UpCseSimuMaster
290
		
291 292 293
		/**
			@desc Ports mapping and default behaviour activation for Config 2 on the AE1
		*/
Yann Garcia's avatar
Yann Garcia committed
294
		function f_cf02UpAe1(in CseTypeID p_cseType := int2) runs on AeSimu system CseSystem {
295 296
			
			// Variables
297 298
      var charstring v_binding;
      var charstring v_binding_in;
299
      var charstring v_host;
300
			vc_config := e_cf02CseSimuMaster;	
301
			vc_testSystemRole := e_ae;	
302 303
			
			// Map
304 305
			map(self:mcaPort, system:mcaPort) param (PX_TS_AE1.mcaPort);
			map(self:mcaPortIn, system:mcaPortIn) param (PX_TS_AE1.mcaPortIn);
306 307
			map(self:acPort, system:acPort);
			
308
			if (ischosen(PX_TS_AE1.mcaPort.binding.httpBindingDesc)) {
309
			  v_binding := "HTTP";
310 311
			  v_host := PX_TS_AE1.mcaPort.binding.httpBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE1.mcaPort.binding.httpBindingDesc.bindingDesc.remotePort);
			} else if (ischosen(PX_TS_AE1.mcaPort.binding.coapBindingDesc)) {
Yann Garcia's avatar
Yann Garcia committed
312
			  v_binding := "COAP";
313 314
			  v_host := PX_TS_AE1.mcaPort.binding.httpBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE1.mcaPort.binding.coapBindingDesc.bindingDesc.remotePort);
			} else if (ischosen(PX_TS_AE1.mcaPort.binding.mqttBindingDesc)) {
315
			  v_binding := "MQTT";
316
			  v_host := PX_TS_AE1.mcaPort.binding.httpBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE1.mcaPort.binding.mqttBindingDesc.bindingDesc.remotePort);
317 318
			} else {
			  v_binding := "WSCK";
319
			  v_host := PX_TS_AE1.mcaPort.binding.httpBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE1.mcaPort.binding.wsBindingDesc.bindingDesc.remotePort);
320
			}
321
			if (ischosen(PX_TS_AE1.mcaPortIn.binding.httpBindingDesc)) {
322
			  v_binding_in := "HTTP";
323
			} else if (ischosen(PX_TS_AE1.mcaPortIn.binding.coapBindingDesc)) {
324
			  v_binding_in := "COAP";
325
			} else if (ischosen(PX_TS_AE1.mcaPortIn.binding.mqttBindingDesc)) {
326 327 328 329 330
			  v_binding_in := "MQTT";
			} else {
			  v_binding_in := "WSCK";
			}
      
331 332
			vc_myInterfaces[enum2int(InterfaceIds:e_mca_port)] := { mcaPort, v_host, v_binding, c_serializationLabel[enum2int(PX_TS_AE1.mcaPort.serialization)] };
			vc_myInterfaces[enum2int(InterfaceIds:e_mca_in_port)] := { mcaPortIn, v_host, v_binding_in, c_serializationLabel[enum2int(PX_TS_AE1.mcaPortIn.serialization)] };
333
      
334 335 336 337
			//Initialze the IUT
							
		} // end f_cf02UpAe1
		
338 339 340
		/**
		 * @desc Ports mapping and default behaviour activation for Config 03
		 */
Yann Garcia's avatar
Yann Garcia committed
341
		function f_cf03Up(in CseTypeID p_cseType := int2) runs on CseSimu system AeSystem {
342 343
		
			// Variables
344
      var charstring v_binding;
345
			var PrimitiveContent v_cSEBaseResource;
346
      var charstring v_host;
347
			vc_config := e_cf03;
348 349
			vc_testSystemRole := e_cse;	
			vc_cseType := p_cseType;	
350
			
351
			//Creation of CSEBase
Miguel Angel Reina Ortega's avatar
Fix #47  
Miguel Angel Reina Ortega committed
352
			v_cSEBaseResource := f_generateLocalResource(-, -1, int5);
353 354
			vc_cSEBaseIndex := f_setLocalResource(v_cSEBaseResource, int5, -1);
			
355
			// Map
356
			map(self:mcaPortIn, system:mcaPortIn) param (PX_TS_AE1.mcaPort);//TODO To be consistent, we should use mcaPortIn for AE testing
357
			map(self:acPort, system:acPort);
358
			
359
			if (ischosen(PX_TS_AE2.mcaPort.binding.httpBindingDesc)) {
Yann Garcia's avatar
Yann Garcia committed
360
			  v_binding := "HTTP";
361 362
			  v_host := PX_TS_AE2.mcaPort.binding.httpBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE2.mcaPort.binding.httpBindingDesc.bindingDesc.remotePort);
			} else if (ischosen(PX_TS_AE2.mcaPort.binding.coapBindingDesc)) {
Yann Garcia's avatar
Yann Garcia committed
363
			  v_binding := "COAP";
364 365
			  v_host := PX_TS_AE2.mcaPort.binding.coapBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE2.mcaPort.binding.coapBindingDesc.bindingDesc.remotePort);
			} else if (ischosen(PX_TS_AE2.mcaPort.binding.mqttBindingDesc)) {
Yann Garcia's avatar
Yann Garcia committed
366
			  v_binding := "MQTT";
367
			  v_host := PX_TS_AE2.mcaPort.binding.mqttBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE2.mcaPort.binding.mqttBindingDesc.bindingDesc.remotePort);
Yann Garcia's avatar
Yann Garcia committed
368 369
			} else {
			  v_binding := "WSCK";
370
			  v_host := PX_TS_AE2.mcaPort.binding.wsBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE2.mcaPort.binding.wsBindingDesc.bindingDesc.remotePort);
Yann Garcia's avatar
Yann Garcia committed
371
			}
372
      
373
			vc_myInterfaces[enum2int(InterfaceIds:e_mca_in_port)] := { mcaPortIn, v_host, v_binding, c_serializationLabel[enum2int(PX_TS_AE2.mcaPortIn.serialization)] };
374
			
375
			if(PX_UT_IMPLEMENTED) {
376
				map(self:utPort, system:utPort) param (PX_TS_UT);
377
			}
378
			activate(a_default());
379
			vc_cseSimu := activate(a_cse_cf03());
380 381 382 383 384 385
		
			// Connect
					
			//Initialze the IUT
					
		} // end f_cf03Up
386 387 388 389
		
		/**
		 * @desc Ports mapping and default behaviour activation for Config 04
		 */
390
		function f_cf04Up(in CseTypeID p_cseType := int2) runs on CseSimu system CseSystem {
391 392

			// Variables
393 394
			var charstring v_binding;
			var charstring v_binding_in;
395
			var PrimitiveContent v_cSEBaseResource;
396
      var charstring v_host;
397
			vc_config := e_cf04;
398
			vc_testSystemRole := e_cse;	
399
			vc_cseType := p_cseType;			
400
			//Creation of CSEBase
Miguel Angel Reina Ortega's avatar
Fix #47  
Miguel Angel Reina Ortega committed
401
			v_cSEBaseResource := f_generateLocalResource(-, -1, int5);
402 403
			vc_cSEBaseIndex := f_setLocalResource(v_cSEBaseResource, int5, -1);
			
404
			// Map
405 406
			map(self:mccPort, system:mccPort) param (PX_TS_CSE1.mccPort);
			map(self:mccPortIn, system:mccPortIn) param (PX_TS_CSE1.mccPortIn);
407
			map(self:acPort, system:acPort);
408
			
409
			if (ischosen(PX_TS_CSE1.mccPort.binding.httpBindingDesc)) {
Yann Garcia's avatar
Yann Garcia committed
410
			  v_binding := "HTTP";
411 412
			  v_host := PX_TS_CSE1.mcaPort.binding.httpBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mccPort.binding.httpBindingDesc.bindingDesc.remotePort);
			} else if (ischosen(PX_TS_CSE1.mccPort.binding.coapBindingDesc)) {
Yann Garcia's avatar
Yann Garcia committed
413
			  v_binding := "COAP";
414 415
			  v_host := PX_TS_CSE1.mcaPort.binding.coapBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mccPort.binding.coapBindingDesc.bindingDesc.remotePort);
			} else if (ischosen(PX_TS_CSE1.mccPort.binding.mqttBindingDesc)) {
Yann Garcia's avatar
Yann Garcia committed
416
			  v_binding := "MQTT";
417
			  v_host := PX_TS_CSE1.mcaPort.binding.mqttBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mccPort.binding.mqttBindingDesc.bindingDesc.remotePort);
Yann Garcia's avatar
Yann Garcia committed
418 419
			} else {
			  v_binding := "WSCK";
420
			  v_host := PX_TS_CSE1.mcaPort.binding.wsBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mccPort.binding.wsBindingDesc.bindingDesc.remotePort);
Yann Garcia's avatar
Yann Garcia committed
421
			}
422
      if (ischosen(PX_TS_CSE1.mccPortIn.binding.httpBindingDesc)) {
423
        v_binding_in := "HTTP";
424
      } else if (ischosen(PX_TS_CSE1.mccPortIn.binding.coapBindingDesc)) {
Yann Garcia's avatar
Yann Garcia committed
425
        v_binding_in := "COAP";
426
      } else if (ischosen(PX_TS_CSE1.mccPortIn.binding.mqttBindingDesc)) {
427 428 429 430 431
        v_binding_in := "MQTT";
      } else {
        v_binding_in := "WSCK";
      }
      
432 433
      vc_myInterfaces[enum2int(InterfaceIds:e_mcc_port)] := { mccPort, v_host, v_binding, c_serializationLabel[enum2int(PX_TS_CSE1.mccPort.serialization)] };
      vc_myInterfaces[enum2int(InterfaceIds:e_mcc_in_port)] := { mccPortIn, v_host, v_binding_in, c_serializationLabel[enum2int(PX_TS_CSE1.mccPortIn.serialization)] };
434
      
435
			activate(a_default());
436
			vc_cseSimu := activate(a_cse_cf04());
437 438 439

			// Connect
			
440
			//Initialize the IUT
441
			
442
		} // end f_cf04Up
443 444

		/**
445
		 * @desc Ports unmapping
446
		 */
447
		function f_cf01Down() runs on AeSimu {
448
		
449
			unmap(self:mcaPort, system:mcaPort);
450
			unmap(self:acPort, system:acPort);
451 452
			if(vc_auxiliaryAe2Up) {
				vc_ae2.start(f_cf01DownAe2());
453
				vc_ae2.done;
454
			}
455
		}// end f_cf01Down
456 457 458 459 460 461 462 463 464
		
		/**
		 * @desc Ports unmapping
		 */
		function f_cf01DownAe2() runs on AeSimu {
				
			unmap(self:mcaPort, system:mcaPort);
			unmap(self:acPort, system:acPort);
			unmap(self:mcaPortIn, system:mcaPortIn);
465
		}// end f_cf01DownAe2
466
		
467 468 469
		/**
		 * @desc Ports unmapping
		 */
470
		function f_cf02Down() runs on AeSimu {
471
		
472
			unmap(self:mcaPort, system:mcaPort);
473
			unmap(self:acPort, system:acPort);
474 475 476
			if(PX_UT_IMPLEMENTED){
				unmap(self:utPort, system:utPort);
			}
477 478 479
			unmap(vc_cse1:mccPort, system:mccPort);
			unmap(vc_cse1:mccPortIn, system:mccPortIn);
			unmap(vc_cse1:acPort, system:acPort);
480 481
		}// end f_cf02Down
		
482 483 484 485 486
		/**
		 * @desc Ports unmapping
		 */
		function f_cf02DownCseSimuMaster() runs on CseSimu {
				
487
			unmap(self:mccPort, system:mccPort);
488
			unmap(self:mccPortIn, system:mccPortIn);
489
			unmap(self:acPort, system:acPort);
490 491
			unmap(vc_ae1:mcaPort, system:mcaPort);
			unmap(vc_ae1:acPort, system:acPort);
492 493
		}// end f_cf02DownCseSimuMaster
		
494 495 496
		/**
		 * @desc Ports unmapping for Config 03
		 */
497
		function f_cf03Down() runs on CseSimu {
498
			
499
			unmap(self:mcaPortIn, system:mcaPortIn);
500 501 502
			if(PX_UT_IMPLEMENTED){
				unmap(self:utPort, system:utPort);
			}
503
			unmap(self:acPort, system:acPort);
504
		}// end f_cf03Down
505
		
506 507 508
		/**
		 * @desc Ports unmapping for Config 04
		 */
509
		function f_cf04Down() runs on CseSimu {
510 511
	
			unmap(self:mccPort, system:mccPort);
512
			unmap(self:mccPortIn, system:mccPortIn);
513
			unmap(self:acPort, system:acPort);
514
		}// end f_cf04Down
515 516 517 518 519 520 521 522 523

	}//end group configFunctions
	
	group InfoPortCommunication {
	
		/**
		 * @desc Connection of InfoPort of two components
		 * @param p_tester PTC where InfoPort is to be connected
		 */
524 525 526 527 528
		function f_connectInfoPort(in Tester p_tester) runs on Tester {
			// Connect
			connect(self:infoPort, p_tester:infoPort);		
		} 
	
529 530 531 532
		/**
		 * @desc Disconnection of InfoPort of two components
		 * @param p_tester PTC where InfoPort is to be connected
		 */
533 534 535 536
		function f_disconnectInfoPort(in Tester p_tester) runs on Tester {
			// Disconnect
			disconnect(self:infoPort, p_tester:infoPort);		
		} 
537 538 539 540 541 542 543 544
		
		group getFunctions {
			/**
			 * @desc Getting last responsePrimitive saved in a component
			 * @param p_tester Given component
			 */
			function f_getResponsePrimitive(in Tester p_component) runs on Tester return ResponsePrimitive {
				var ResponsePrimitive v_response;
545
				
546
				f_connectInfoPort(p_component);
547
		
548 549 550 551
				p_component.start(f_sendResponsePrimitive());
				alt {
					[]infoPort.receive(mw_responsePrimitiveforInfoPort) -> value v_response {
					}
552
				}
553 554 555 556 557 558
				
				p_component.done;
				f_disconnectInfoPort(p_component);
					
				return v_response;
					
559 560
			}
			
561 562 563 564 565 566 567 568
			/**
			 * @desc Getting last requestPrimitive saved in an AeSimu component
			 * @param p_tester Given component
			 */
			function f_getRequestPrimitive(in Tester p_component) runs on Tester return RequestPrimitive {
				var RequestPrimitive v_request;
	
				f_connectInfoPort(p_component);
569
	
570 571 572 573
				p_component.start(f_sendRequestPrimitive());
				alt {
					[]infoPort.receive(mw_requestPrimitiveforInfoPort) -> value v_request {
					}
574 575
				}
	
576 577 578 579 580
				p_component.done;
				f_disconnectInfoPort(p_component);
		
				return v_request;
		
581
			}
582 583 584 585 586 587 588
								
			/**
			 * @desc Getting primitiveContent retrieved in an AeSimu component
			 * @param p_tester AeSimu component
			 */
			function f_getPrimitiveContentRetrievedResource(in AeSimu p_ae) runs on Tester return PrimitiveContent {
				var PrimitiveContent v_primitiveContent;
589
				
590
				f_connectInfoPort(p_ae);
591
		
592 593 594 595
				p_ae.start(f_sendPrimitiveContentRetrievedResource());
				alt {
					[]infoPort.receive(mw_primitiveContent) -> value v_primitiveContent {
					}
596
				}
597 598 599 600 601 602
		
				p_ae.done;
				f_disconnectInfoPort(p_ae);
					
				return v_primitiveContent;
					
603
			}
604 605 606 607 608 609 610 611
			
			/**
			 * @desc Getting remoteCSE resource from a CseSimu component
			 * @param p_tester CseSimu component
			 */
			function f_getRemoteCseResource(in CseSimu p_cse) runs on Tester return integer {
				var MyResource v_resource;
				var integer v_resourceIndex := -1;
612
				
613
				f_connectInfoPort(p_cse);
614
		
615 616 617 618 619
				p_cse.start(f_sendRemoteCseResource());
				alt {
					[]infoPort.receive(mw_resource) -> value v_resource {
						v_resourceIndex := f_setResource(v_resource.resource, v_resource.resourceType, v_resource.parentIndex, false);
					}
620
				}
621 622 623 624 625 626
		
				p_cse.done;
				f_disconnectInfoPort(p_cse);
					
				return v_resourceIndex;
					
627 628
			}
			
629 630 631 632 633
			/**
			 * @desc Getting a specific resource from an AeSimu component
			 * @param p_tester AeSimu component
			 * @param p_resourceIndex Index of resource to be retrieved
			 */
634
			function f_getResourceFromAeSimu(in AeSimu p_component, in integer p_resourceIndex := -1) runs on Tester return integer {
635 636
				var MyResource v_resource;
				var integer v_resourceIndex := -1;
637
			
638
				f_connectInfoPort(p_component);
639 640 641 642 643 644 645 646
				
				p_component.start(f_sendResourceAeSimu(p_resourceIndex));
				
				alt {
					[]infoPort.receive(mw_resource) -> value v_resource {
						v_resourceIndex := f_setResource(v_resource.resource, v_resource.resourceType, v_resource.parentIndex, false);
					}
				}
647
	
648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668
				p_component.done;
				f_disconnectInfoPort(p_component);
				
				return v_resourceIndex;
				
			}	

			
			/**
			 * @desc Getting a specific resource from an CseSimu component
			 * @param p_tester AeSimu component
			 * @param p_resourceIndex Index of resource to be retrieved
			 */
			function f_getResourceFromCseSimu(in CseSimu p_component, in integer p_resourceIndex := -1) runs on Tester return integer {
				var MyResource v_resource;
				var integer v_resourceIndex := -1;
			
				f_connectInfoPort(p_component);
				
				p_component.start(f_sendResourceCseSimu(p_resourceIndex));
				
669 670 671 672 673
				alt {
					[]infoPort.receive(mw_resource) -> value v_resource {
						v_resourceIndex := f_setResource(v_resource.resource, v_resource.resourceType, v_resource.parentIndex, false);
					}
				}
674
	
675 676
				p_component.done;
				f_disconnectInfoPort(p_component);
677
				
678
				return v_resourceIndex;
679
				
680
			}	
681

682 683 684 685 686 687 688 689 690 691
			/**
			 * @desc Getting the latest resource from an AeSimu component
			 * @param p_tester AeSimu component
			 * @param p_resourceIndex Index of resource to be retrieved
			 */
			function f_getLatestResource(in Tester p_component) runs on Tester return integer {
				var MyResource v_resource;
				var integer v_resourceIndex := -1;
		
				f_connectInfoPort(p_component);
692

693 694 695 696 697
				p_component.start(f_sendLatestResource());
				alt {
					[]infoPort.receive(mw_resource) -> value v_resource {
						v_resourceIndex := f_setResource(v_resource.resource, v_resource.resourceType, v_resource.parentIndex, false);
					}
698
				}
699 700 701 702 703

				p_component.done;
				f_disconnectInfoPort(p_component);
			
				return v_resourceIndex;
704
			
705
			}
706 707 708 709 710 711 712
						
			/**
			 * @desc Getting last resourceIndex saved in the vc_resourcesList
			 * @param p_tester Given component
			 */
			function f_getLatestResourceIndex(in Tester p_component) runs on Tester return integer {
				var integer v_resourceIndex;
713

714
				f_connectInfoPort(p_component);
715

716 717 718 719 720
				p_component.start(f_sendLatestResourceIndex());
				alt {
					[]infoPort.receive(mw_resourceIndex) -> value v_resourceIndex{
					}
				}
721

722 723
				p_component.done;
				f_disconnectInfoPort(p_component);
724

725
				return v_resourceIndex;
726 727

			}
728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748

			/**
			 * @desc Getting the latest local resource from an CseSimu component
			 * @param p_component CseSimu component
			 * @param p_resourceIndex Index of resource to be retrieved
			 */
			function f_getLatestLocalResource(in CseSimu p_component) runs on Tester return integer {
				var MyResource v_resource;
				var integer v_resourceIndex := -1;
		
				f_connectInfoPort(p_component);

				p_component.start(f_sendLatestLocalResource());
				alt {
					[]infoPort.receive(mw_resource) -> value v_resource {
						v_resourceIndex := f_setResource(v_resource.resource, v_resource.resourceType, v_resource.parentIndex, false);//TODO To set correctly parentIndex
					}
				}

				p_component.done;
				f_disconnectInfoPort(p_component);
749
			
750 751 752 753
				return v_resourceIndex;
			
			}
						
754 755