OneM2M_Functions.ttcn 239 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
 *  @author     oneM2M/ETSI
9 10 11 12 13 14 15
 *  @desc       Module containing functions for oneM2M
 *
 */
module OneM2M_Functions {
	
	import from XSD all;
	import from OneM2M_Templates all;
16
	import from OneM2M_Types all;
17
    import from OneM2M_Ports all;
18 19 20
	import from OneM2M_TypesAndValues all;
	import from OneM2M_TestSystem all;
	import from OneM2M_Pixits all;
21
	import from OneM2M_Pics all;
22
	
23
	group ConfigFunctions {
24
		
25 26 27
		/**
			@desc Ports mapping and default behaviour activation for Config 1
		*/
Yann Garcia's avatar
Yann Garcia committed
28
		function f_cf01Up(in boolean p_auxiliaryAe2Required := false) runs on AeSimu system CseSystem {
29
			
30
			// Variables
31 32 33 34 35
      		var charstring v_binding;
      		var charstring v_binding_in;
      		var charstring v_host;
			
			//Initialization of component variables
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 58 59 60 61 62 63 64 65 66
     	 	
     	 	if (ischosen(PX_TS_AE1.mcaPortIn.binding.httpBindingDesc)) {
		    	v_binding_in := "HTTP";
		    } else if (ischosen(PX_TS_AE1.mcaPortIn.binding.coapBindingDesc)) {
		    	v_binding_in := "COAP";
		    } else if (ischosen(PX_TS_AE1.mcaPortIn.binding.mqttBindingDesc)) {
		    	v_binding_in := "MQTT";
		    } else {
		    	v_binding_in := "WSCK";
		    }
67
			
68
			vc_myInterfaces[enum2int(valueof(InterfaceIds:e_mca_port))] := { mcaPort, v_host, v_binding, c_serializationLabel[enum2int(PX_TS_AE1.mcaPort.serialization)] };
69
      		vc_myInterfaces[enum2int(valueof(InterfaceIds:e_mca_in_port))] := { mcaPortIn, v_host, v_binding_in, c_serializationLabel[enum2int(PX_TS_AE1.mcaPortIn.serialization)] };
70
			
71
			activate(a_default());
72
			vc_aeSimu := activate(a_cse_cf01());
73
				
74 75 76 77 78
			// Initialize AE2
			if(p_auxiliaryAe2Required) {
				vc_auxiliaryAe2Up := p_auxiliaryAe2Required;
				vc_ae2 := AeSimu.create("AE2") alive;
				vc_ae2.start(f_cf01UpAe2());
79
				vc_ae2.done;
80 81 82 83 84 85 86 87 88
			}
				
			//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
89
		function f_cf01UpAe2() runs on AeSimu system CseSystem {
90 91
			
			// Variables
92 93
			var charstring v_binding;
			var charstring v_binding_in;
94 95 96
      		var charstring v_host;
			
			//Initialization of component variables
97 98
			vc_config := e_cf01;
			vc_testSystemRole := e_ae;		
99 100
			
			// Map
101 102
			map(self:mcaPort, system:mcaPort) param (PX_TS_AE2.mcaPort);
			map(self:mcaPortIn, system:mcaPortIn) param (PX_TS_AE2.mcaPortIn);
103 104
			map(self:acPort, system:acPort);
	
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
		    if (ischosen(PX_TS_AE2.mcaPort.binding.httpBindingDesc)) {
		        v_binding := "HTTP";
		        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)) {
		        v_binding := "COAP";
		        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)) {
		        v_binding := "MQTT";
		        v_host := PX_TS_AE2.mcaPort.binding.mqttBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE2.mcaPort.binding.mqttBindingDesc.bindingDesc.remotePort);
		    } else {
		        v_binding := "WSCK";
		        v_host := PX_TS_AE2.mcaPort.binding.wsBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE2.mcaPort.binding.wsBindingDesc.bindingDesc.remotePort);
		    }
		    
		    if (ischosen(PX_TS_AE2.mcaPortIn.binding.httpBindingDesc)) {
		        v_binding_in := "HTTP";
		    } else if (ischosen(PX_TS_AE2.mcaPortIn.binding.coapBindingDesc)) {
		        v_binding_in := "COAP";
		    } else if (ischosen(PX_TS_AE2.mcaPortIn.binding.mqttBindingDesc)) {
		        v_binding_in := "MQTT";
		    } else {
		    	v_binding_in := "WSCK";
		    }
128
      
129 130
      		vc_myInterfaces[enum2int(valueof(InterfaceIds:e_mca_port))] := { mcaPort, v_host, v_binding, c_serializationLabel[enum2int(PX_TS_AE2.mcaPort.serialization)] };
      		vc_myInterfaces[enum2int(valueof(InterfaceIds:e_mca_in_port))] := { mcaPortIn, v_host, v_binding_in, c_serializationLabel[enum2int(PX_TS_AE2.mcaPortIn.serialization)] };
131

132
			//Initialze the IUT
133
							
134
		} // end f_cf01UpAe2
135
		
136 137 138
		/**
		 * @desc Ports mapping and default behaviour activation for Config 02
		 */
Yann Garcia's avatar
Yann Garcia committed
139
		function f_cf02Up(in CseTypeID p_cseType := int2) runs on AeSimu system CseSystem {
140
				
141
			// Variables
142
			var charstring v_binding;
143
			var charstring v_binding_in;
144 145 146
      		var charstring v_host;
			
			//Initialization of component variables
147
			vc_config := e_cf02;
148
			vc_testSystemRole := e_ae;	
149
			vc_cse1 := CseSimu.create("CSE1") alive;
150
				
151
			// Map
152
			map(self:mcaPort, system:mcaPort) param (PX_TS_AE1.mcaPort);
153
			map(self:mcaPortIn, system:mcaPortIn) param (PX_TS_AE1.mcaPortIn);
154
			map(self:acPort, system:acPort);
155
			if(PX_UT_IMPLEMENTED) {
156
				map(self:utPort, system:utPort) param (PX_TS_UT);
157
			}
158 159 160 161 162 163 164 165 166 167 168 169 170 171

		    if (ischosen(PX_TS_AE1.mcaPort.binding.httpBindingDesc)) {
		        v_binding := "HTTP";
		        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)) {
		        v_binding := "COAP";
		        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)) {
		        v_binding := "MQTT";
		        v_host := PX_TS_AE1.mcaPort.binding.mqttBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE1.mcaPort.binding.mqttBindingDesc.bindingDesc.remotePort);
		    } else {
		    	v_binding := "WSCK";
		        v_host := PX_TS_AE1.mcaPort.binding.wsBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE1.mcaPort.binding.wsBindingDesc.bindingDesc.remotePort);
		    }
172 173 174 175 176 177 178 179 180 181
		    
			if (ischosen(PX_TS_AE1.mcaPortIn.binding.httpBindingDesc)) {
				v_binding_in := "HTTP";
			} else if (ischosen(PX_TS_AE1.mcaPortIn.binding.coapBindingDesc)) {
				v_binding_in := "COAP";
			} else if (ischosen(PX_TS_AE1.mcaPortIn.binding.mqttBindingDesc)) {
				v_binding_in := "MQTT";
			} else {
				v_binding_in := "WSCK";
			}
182 183
		      
		    vc_myInterfaces[enum2int(valueof(InterfaceIds:e_mca_port))] := { mcaPort, v_host, v_binding, c_serializationLabel[enum2int(PX_TS_AE1.mcaPort.serialization)] };
184
			vc_myInterfaces[enum2int(valueof(InterfaceIds:e_mca_in_port))] := { mcaPortIn, v_host, v_binding_in, c_serializationLabel[enum2int(PX_TS_AE1.mcaPortIn.serialization)] };
185
			
186
			activate(a_default());
187
			vc_aeSimu := activate(a_cse_cf02_ae1());
188
			vc_cse1.start(f_cf02UpCse1(p_cseType));
189
			vc_cse1.done;
190
				
191
			// Connect
192
			
193
			//Initialze the IUT
194
							
195
		} // end f_cf02Up
196 197 198 199
		
		/**
			@desc Ports mapping and default behaviour activation for Config 2 on the CSE1
		*/
200
		function f_cf02UpCse1(in CseTypeID p_cseType := int2) runs on CseSimu system CseSystem {
201 202
			
			// Variables
203 204 205
      		var charstring v_binding;
      		var charstring v_binding_in;
      		var charstring v_host;
206
			var PrimitiveContent v_cSEBaseResource;
207 208
			
			//Initialization of component variables
209 210
			vc_config := e_cf02;
			vc_testSystemRole := e_cse;		
211
			vc_cseType := p_cseType;
212 213
			
			// Map
214 215
			map(self:mccPort, system:mccPort) param (PX_TS_CSE1.mccPort);
			map(self:mccPortIn, system:mccPortIn) param (PX_TS_CSE1.mccPortIn);
216
			map(self:acPort, system:acPort);
217
			
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243
		    if (ischosen(PX_TS_CSE1.mccPort.binding.httpBindingDesc)) {
		        v_binding := "HTTP";
		        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)) {
		        v_binding := "COAP";
		        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)) {
		        v_binding := "MQTT";
		        v_host := PX_TS_CSE1.mcaPort.binding.mqttBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mccPort.binding.mqttBindingDesc.bindingDesc.remotePort);
		    } else {
		        v_binding := "WSCK";
		        v_host := PX_TS_CSE1.mcaPort.binding.wsBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mccPort.binding.wsBindingDesc.bindingDesc.remotePort);
		    }
		    
		    if (ischosen(PX_TS_CSE1.mccPortIn.binding.httpBindingDesc)) {
		    	v_binding_in := "HTTP";
		    } else if (ischosen(PX_TS_CSE1.mccPortIn.binding.coapBindingDesc)) {
		        v_binding_in := "COAP";
		    } else if (ischosen(PX_TS_CSE1.mccPortIn.binding.mqttBindingDesc)) {
		        v_binding_in := "MQTT";
		    } else {
		        v_binding_in := "WSCK";
		    }
		      
		    vc_myInterfaces[enum2int(valueof(InterfaceIds:e_mcc_port))] := { mccPort, v_host, v_binding, c_serializationLabel[enum2int(PX_TS_CSE1.mccPort.serialization)] };
		    vc_myInterfaces[enum2int(valueof(InterfaceIds:e_mcc_in_port))] := { mccPortIn, v_host, v_binding, c_serializationLabel[enum2int(PX_TS_CSE1.mccPortIn.serialization)] };
244
      
Miguel Angel Reina Ortega's avatar
Fix #47  
Miguel Angel Reina Ortega committed
245
			v_cSEBaseResource := f_generateLocalResource(-, -1, int5);
246 247
			vc_cSEBaseIndex := f_setLocalResource(v_cSEBaseResource, int5, -1);
			
248 249 250
			//Initialze the IUT
							
		} // end f_cf02UpCse1
251 252 253 254

		/**
		 * @desc Ports mapping and default behaviour activation for Config 02
		 */
255
		function f_cf02UpCseSimuMaster(in CseTypeID p_cseType := int2) runs on CseSimu system CseSystem {
256 257
				
			// Variables
Miguel Angel Reina Ortega's avatar
Fix #64  
Miguel Angel Reina Ortega committed
258 259 260
      		var charstring v_binding;
      		var charstring v_binding_in;
      		var charstring v_host;
261
			var PrimitiveContent v_cSEBaseResource;
Miguel Angel Reina Ortega's avatar
Fix #64  
Miguel Angel Reina Ortega committed
262 263
			
			//Initialization of component variables
264
			vc_config := e_cf02CseSimuMaster;
265 266
			vc_testSystemRole := e_cse;	
			vc_cseType := p_cseType;
267
			vc_ae1 := AeSimu.create("AE1") alive;
268 269
			
			//Initialization of local CSEBase
Miguel Angel Reina Ortega's avatar
Fix #47  
Miguel Angel Reina Ortega committed
270
			v_cSEBaseResource := f_generateLocalResource(-, -1, int5);
271
			vc_cSEBaseIndex := f_setLocalResource(v_cSEBaseResource, int5, -1);
272 273
				
			// Map
274 275
			map(self:mccPort, system:mccPort) param (PX_TS_CSE1.mccPort);
			map(self:mccPortIn, system:mccPortIn) param (PX_TS_CSE1.mccPortIn);
276
			map(self:acPort, system:acPort);
Miguel Angel Reina Ortega's avatar
Fix #64  
Miguel Angel Reina Ortega committed
277 278 279
			if(PX_UT_IMPLEMENTED) {
				map(self:utPort, system:utPort) param (PX_TS_UT);
			}
280
			
281
			if (ischosen(PX_TS_CSE1.mccPort.binding.httpBindingDesc)) {
Miguel Angel Reina Ortega's avatar
Fix #64  
Miguel Angel Reina Ortega committed
282
				v_binding := "HTTP";
Miguel Angel Reina Ortega's avatar
Fix #66  
Miguel Angel Reina Ortega committed
283
				v_host := PX_TS_CSE1.mccPort.binding.httpBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mccPort.binding.httpBindingDesc.bindingDesc.remotePort);
284
			} else if (ischosen(PX_TS_CSE1.mccPort.binding.coapBindingDesc)) {
Miguel Angel Reina Ortega's avatar
Fix #64  
Miguel Angel Reina Ortega committed
285
				v_binding := "COAP";
Miguel Angel Reina Ortega's avatar
Fix #66  
Miguel Angel Reina Ortega committed
286
				v_host := PX_TS_CSE1.mccPort.binding.coapBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mccPort.binding.coapBindingDesc.bindingDesc.remotePort);
287
			} else if (ischosen(PX_TS_CSE1.mccPort.binding.mqttBindingDesc)) {
Miguel Angel Reina Ortega's avatar
Fix #64  
Miguel Angel Reina Ortega committed
288
				v_binding := "MQTT";
Miguel Angel Reina Ortega's avatar
Fix #66  
Miguel Angel Reina Ortega committed
289
				v_host := PX_TS_CSE1.mccPort.binding.mqttBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mccPort.binding.mqttBindingDesc.bindingDesc.remotePort);
Yann Garcia's avatar
Yann Garcia committed
290
			} else {
Miguel Angel Reina Ortega's avatar
Fix #64  
Miguel Angel Reina Ortega committed
291
				v_binding := "WSCK";
Miguel Angel Reina Ortega's avatar
Fix #66  
Miguel Angel Reina Ortega committed
292
				v_host := PX_TS_CSE1.mccPort.binding.wsBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mccPort.binding.wsBindingDesc.bindingDesc.remotePort);
Yann Garcia's avatar
Yann Garcia committed
293
			}
Miguel Angel Reina Ortega's avatar
Fix #64  
Miguel Angel Reina Ortega committed
294 295 296 297 298 299 300 301 302
		    if (ischosen(PX_TS_CSE1.mccPortIn.binding.httpBindingDesc)) {
		    	v_binding_in := "HTTP";
		    } else if (ischosen(PX_TS_CSE1.mccPortIn.binding.coapBindingDesc)) {
		        v_binding_in := "COAP";
		    } else if (ischosen(PX_TS_CSE1.mccPortIn.binding.mqttBindingDesc)) {
		    	v_binding_in := "MQTT";
		    } else {
		    	v_binding_in := "WSCK";
		    }
303
      
304 305
			vc_myInterfaces[enum2int(valueof(InterfaceIds:e_mcc_port))] := { mccPort, v_host, v_binding, c_serializationLabel[enum2int(PX_TS_CSE1.mccPort.serialization)] };
			vc_myInterfaces[enum2int(valueof(InterfaceIds:e_mcc_in_port))] := { mccPortIn, v_host, v_binding_in, c_serializationLabel[enum2int(PX_TS_CSE1.mccPortIn.serialization)] };
306
			
307
			activate(a_default());
308
			vc_cseSimu := activate(a_cse_cf02_cse1());
309 310
			vc_ae1.start(f_cf02UpAe1());
			vc_ae1.done;
311 312
				
			// Connect
313
			
314 315 316
			//Initialze the IUT
							
		} // end f_cf02UpCseSimuMaster
317
		
318 319 320
		/**
			@desc Ports mapping and default behaviour activation for Config 2 on the AE1
		*/
Yann Garcia's avatar
Yann Garcia committed
321
		function f_cf02UpAe1(in CseTypeID p_cseType := int2) runs on AeSimu system CseSystem {
322 323
			
			// Variables
Miguel Angel Reina Ortega's avatar
Fix #64  
Miguel Angel Reina Ortega committed
324 325 326
      		var charstring v_binding;
      		var charstring v_binding_in;
     		var charstring v_host;
327
			vc_config := e_cf02CseSimuMaster;	
328
			vc_testSystemRole := e_ae;	
329 330
			
			// Map
331 332
			map(self:mcaPort, system:mcaPort) param (PX_TS_AE1.mcaPort);
			map(self:mcaPortIn, system:mcaPortIn) param (PX_TS_AE1.mcaPortIn);
333 334
			map(self:acPort, system:acPort);
			
335
			if (ischosen(PX_TS_AE1.mcaPort.binding.httpBindingDesc)) {
336
			  v_binding := "HTTP";
337 338
			  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
339
			  v_binding := "COAP";
340
			  v_host := PX_TS_AE1.mcaPort.binding.coapBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE1.mcaPort.binding.coapBindingDesc.bindingDesc.remotePort);
341
			} else if (ischosen(PX_TS_AE1.mcaPort.binding.mqttBindingDesc)) {
342
			  v_binding := "MQTT";
343
			  v_host := PX_TS_AE1.mcaPort.binding.mqttBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE1.mcaPort.binding.mqttBindingDesc.bindingDesc.remotePort);
344 345
			} else {
			  v_binding := "WSCK";
346
			  v_host := PX_TS_AE1.mcaPort.binding.wsBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE1.mcaPort.binding.wsBindingDesc.bindingDesc.remotePort);
347
			}
348
			if (ischosen(PX_TS_AE1.mcaPortIn.binding.httpBindingDesc)) {
349
			  v_binding_in := "HTTP";
350
			} else if (ischosen(PX_TS_AE1.mcaPortIn.binding.coapBindingDesc)) {
351
			  v_binding_in := "COAP";
352
			} else if (ischosen(PX_TS_AE1.mcaPortIn.binding.mqttBindingDesc)) {
353 354 355 356 357
			  v_binding_in := "MQTT";
			} else {
			  v_binding_in := "WSCK";
			}
      
358 359
			vc_myInterfaces[enum2int(valueof(InterfaceIds:e_mca_port))] := { mcaPort, v_host, v_binding, c_serializationLabel[enum2int(PX_TS_AE1.mcaPort.serialization)] };
			vc_myInterfaces[enum2int(valueof(InterfaceIds:e_mca_in_port))] := { mcaPortIn, v_host, v_binding_in, c_serializationLabel[enum2int(PX_TS_AE1.mcaPortIn.serialization)] };
360
      
361 362 363 364
			//Initialze the IUT
							
		} // end f_cf02UpAe1
		
365 366 367
		/**
		 * @desc Ports mapping and default behaviour activation for Config 03
		 */
Yann Garcia's avatar
Yann Garcia committed
368
		function f_cf03Up(in CseTypeID p_cseType := int2) runs on CseSimu system AeSystem {
369 370
		
			// Variables
371
      		var charstring v_binding;
372
			var charstring v_binding_in;
373
			var PrimitiveContent v_cSEBaseResource;
374 375 376
      		var charstring v_host;
			
			//Initialization of component variables
377
			vc_config := e_cf03;
378 379
			vc_testSystemRole := e_cse;	
			vc_cseType := p_cseType;	
380
			
381
			//Creation of CSEBase
Miguel Angel Reina Ortega's avatar
Fix #47  
Miguel Angel Reina Ortega committed
382
			v_cSEBaseResource := f_generateLocalResource(-, -1, int5);
383 384
			vc_cSEBaseIndex := f_setLocalResource(v_cSEBaseResource, int5, -1);
			
385
			// Map
386
			map(self:mcaPort, system:mcaPort) param (PX_TS_CSE1.mcaPort);//TODO To be consistent, we should use mcaPortIn for AE testing
387
			map(self:mcaPortIn, system:mcaPortIn) param (PX_TS_CSE1.mcaPortIn);//TODO To be consistent, we should use mcaPortIn for AE testing
388
			map(self:acPort, system:acPort);
389
			
390
			if (ischosen(PX_TS_CSE1.mcaPort.binding.httpBindingDesc)) {
391
				v_binding := "HTTP";
392 393
				v_host := PX_TS_CSE1.mcaPort.binding.httpBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mcaPort.binding.httpBindingDesc.bindingDesc.remotePort);
			} else if (ischosen(PX_TS_CSE1.mcaPort.binding.coapBindingDesc)) {
394
				v_binding := "COAP";
395 396
				v_host := PX_TS_CSE1.mcaPort.binding.coapBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mcaPort.binding.coapBindingDesc.bindingDesc.remotePort);
			} else if (ischosen(PX_TS_CSE1.mcaPort.binding.mqttBindingDesc)) {
397
				v_binding := "MQTT";
398
				v_host := PX_TS_CSE1.mcaPort.binding.mqttBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mcaPort.binding.mqttBindingDesc.bindingDesc.remotePort);
Yann Garcia's avatar
Yann Garcia committed
399
			} else {
400
				v_binding := "WSCK";
401
				v_host := PX_TS_CSE1.mcaPort.binding.wsBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mcaPort.binding.wsBindingDesc.bindingDesc.remotePort);
Yann Garcia's avatar
Yann Garcia committed
402
			}
403 404 405 406 407 408 409 410 411 412 413 414 415
      		
			if (ischosen(PX_TS_CSE1.mcaPortIn.binding.httpBindingDesc)) {
				v_binding_in := "HTTP";
			} else if (ischosen(PX_TS_CSE1.mcaPortIn.binding.coapBindingDesc)) {
				v_binding_in := "COAP";
			} else if (ischosen(PX_TS_CSE1.mcaPortIn.binding.mqttBindingDesc)) {
				v_binding_in := "MQTT";
			} else {
				v_binding_in := "WSCK";
			}
			
			vc_myInterfaces[enum2int(valueof(InterfaceIds:e_mca_port))] := { mcaPort, v_host, v_binding, c_serializationLabel[enum2int(PX_TS_CSE1.mcaPort.serialization)] };
			vc_myInterfaces[enum2int(valueof(InterfaceIds:e_mca_in_port))] := { mcaPortIn, v_host, v_binding_in, c_serializationLabel[enum2int(PX_TS_CSE1.mcaPortIn.serialization)] };
416
			
417
			if(PX_UT_IMPLEMENTED) {
418
				map(self:utPort, system:utPort) param (PX_TS_UT);
419
			}
420
			activate(a_default());
421
			vc_cseSimu := activate(a_cse_cf03());
422 423 424 425 426 427
		
			// Connect
					
			//Initialze the IUT
					
		} // end f_cf03Up
428 429 430 431
		
		/**
		 * @desc Ports mapping and default behaviour activation for Config 04
		 */
432
		function f_cf04Up(in CseTypeID p_cseType := int2) runs on CseSimu system CseSystem {
433 434

			// Variables
435 436
			var charstring v_binding;
			var charstring v_binding_in;
437
			var PrimitiveContent v_cSEBaseResource;
Miguel Angel Reina Ortega's avatar
Fix #63  
Miguel Angel Reina Ortega committed
438 439 440
	  		var charstring v_host;
			
			//Initialization of component variables
441
			vc_config := e_cf04;
442
			vc_testSystemRole := e_cse;	
443
			vc_cseType := p_cseType;			
Miguel Angel Reina Ortega's avatar
Fix #63  
Miguel Angel Reina Ortega committed
444 445
			
			////Initialization of local CSEBase
Miguel Angel Reina Ortega's avatar
Fix #47  
Miguel Angel Reina Ortega committed
446
			v_cSEBaseResource := f_generateLocalResource(-, -1, int5);
447 448
			vc_cSEBaseIndex := f_setLocalResource(v_cSEBaseResource, int5, -1);
			
449
			// Map
450 451
			map(self:mccPort, system:mccPort) param (PX_TS_CSE1.mccPort);
			map(self:mccPortIn, system:mccPortIn) param (PX_TS_CSE1.mccPortIn);
452
			map(self:acPort, system:acPort);
Miguel Angel Reina Ortega's avatar
Fix #63  
Miguel Angel Reina Ortega committed
453 454 455
			if(PX_UT_IMPLEMENTED) {
				map(self:utPort, system:utPort) param (PX_TS_UT);
			}
456
			
457
			if (ischosen(PX_TS_CSE1.mccPort.binding.httpBindingDesc)) {
Yann Garcia's avatar
Yann Garcia committed
458
			  v_binding := "HTTP";
Miguel Angel Reina Ortega's avatar
Fix #65  
Miguel Angel Reina Ortega committed
459
			  v_host := PX_TS_CSE1.mccPort.binding.httpBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mccPort.binding.httpBindingDesc.bindingDesc.remotePort);
460
			} else if (ischosen(PX_TS_CSE1.mccPort.binding.coapBindingDesc)) {
Yann Garcia's avatar
Yann Garcia committed
461
			  v_binding := "COAP";
Miguel Angel Reina Ortega's avatar
Fix #65  
Miguel Angel Reina Ortega committed
462
			  v_host := PX_TS_CSE1.mccPort.binding.coapBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mccPort.binding.coapBindingDesc.bindingDesc.remotePort);
463
			} else if (ischosen(PX_TS_CSE1.mccPort.binding.mqttBindingDesc)) {
Yann Garcia's avatar
Yann Garcia committed
464
			  v_binding := "MQTT";
Miguel Angel Reina Ortega's avatar
Fix #65  
Miguel Angel Reina Ortega committed
465
			  v_host := PX_TS_CSE1.mccPort.binding.mqttBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mccPort.binding.mqttBindingDesc.bindingDesc.remotePort);
Yann Garcia's avatar
Yann Garcia committed
466 467
			} else {
			  v_binding := "WSCK";
Miguel Angel Reina Ortega's avatar
Fix #65  
Miguel Angel Reina Ortega committed
468
			  v_host := PX_TS_CSE1.mccPort.binding.wsBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mccPort.binding.wsBindingDesc.bindingDesc.remotePort);
Yann Garcia's avatar
Yann Garcia committed
469
			}
Miguel Angel Reina Ortega's avatar
Fix #63  
Miguel Angel Reina Ortega committed
470 471 472 473 474 475 476 477 478
		   	if (ischosen(PX_TS_CSE1.mccPortIn.binding.httpBindingDesc)) {
		    	v_binding_in := "HTTP";
		    } else if (ischosen(PX_TS_CSE1.mccPortIn.binding.coapBindingDesc)) {
		    	v_binding_in := "COAP";
		    } else if (ischosen(PX_TS_CSE1.mccPortIn.binding.mqttBindingDesc)) {
		    	v_binding_in := "MQTT";
		    } else {
		    	v_binding_in := "WSCK";
		    }
479
      
Miguel Angel Reina Ortega's avatar
Fix #63  
Miguel Angel Reina Ortega committed
480 481
      		vc_myInterfaces[enum2int(valueof(InterfaceIds:e_mcc_port))] := { mccPort, v_host, v_binding, c_serializationLabel[enum2int(PX_TS_CSE1.mccPort.serialization)] };
      		vc_myInterfaces[enum2int(valueof(InterfaceIds:e_mcc_in_port))] := { mccPortIn, v_host, v_binding_in, c_serializationLabel[enum2int(PX_TS_CSE1.mccPortIn.serialization)] };
482
      
483
			activate(a_default());
484
			vc_cseSimu := activate(a_cse_cf04());
485 486 487

			// Connect
			
488
			//Initialize the IUT
489
			
490
		} // end f_cf04Up
491 492

		/**
493
		 * @desc Ports unmapping
494
		 */
495
		function f_cf01Down() runs on AeSimu {
496
		
497
			unmap(self:mcaPort, system:mcaPort);
498
			unmap(self:acPort, system:acPort);
499
			if(vc_auxiliaryAe2Up) {
500 501 502 503
				if(vc_ae2.alive) {
					vc_ae2.start(f_cf01DownAe2());
					vc_ae2.done;
				}
504
			}
Miguel Angel Reina Ortega's avatar
Fix #64  
Miguel Angel Reina Ortega committed
505
		
506
		}// end f_cf01Down
507 508 509 510 511 512 513 514 515
		
		/**
		 * @desc Ports unmapping
		 */
		function f_cf01DownAe2() runs on AeSimu {
				
			unmap(self:mcaPort, system:mcaPort);
			unmap(self:acPort, system:acPort);
			unmap(self:mcaPortIn, system:mcaPortIn);
Miguel Angel Reina Ortega's avatar
Fix #64  
Miguel Angel Reina Ortega committed
516
		
517
		}// end f_cf01DownAe2
518
		
519 520 521
		/**
		 * @desc Ports unmapping
		 */
522
		function f_cf02Down() runs on AeSimu {
523
		
524
			unmap(self:mcaPort, system:mcaPort);
525
			unmap(self:acPort, system:acPort);
526 527 528
			if(PX_UT_IMPLEMENTED){
				unmap(self:utPort, system:utPort);
			}
529 530 531
			unmap(vc_cse1:mccPort, system:mccPort);
			unmap(vc_cse1:mccPortIn, system:mccPortIn);
			unmap(vc_cse1:acPort, system:acPort);
Miguel Angel Reina Ortega's avatar
Fix #64  
Miguel Angel Reina Ortega committed
532
		
533 534
		}// end f_cf02Down
		
535 536 537 538 539
		/**
		 * @desc Ports unmapping
		 */
		function f_cf02DownCseSimuMaster() runs on CseSimu {
				
540
			unmap(self:mccPort, system:mccPort);
541
			unmap(self:mccPortIn, system:mccPortIn);
542
			unmap(self:acPort, system:acPort);
Miguel Angel Reina Ortega's avatar
Fix #64  
Miguel Angel Reina Ortega committed
543 544 545
			if(PX_UT_IMPLEMENTED){
				unmap(self:utPort, system:utPort);
			}
546 547
			unmap(vc_ae1:mcaPort, system:mcaPort);
			unmap(vc_ae1:acPort, system:acPort);
Miguel Angel Reina Ortega's avatar
Fix #64  
Miguel Angel Reina Ortega committed
548
		
549 550
		}// end f_cf02DownCseSimuMaster
		
551 552 553
		/**
		 * @desc Ports unmapping for Config 03
		 */
554
		function f_cf03Down() runs on CseSimu {
555
			
556
			unmap(self:mcaPortIn, system:mcaPortIn);
Miguel Angel Reina Ortega's avatar
Fix #64  
Miguel Angel Reina Ortega committed
557
			unmap(self:acPort, system:acPort);
558 559 560
			if(PX_UT_IMPLEMENTED){
				unmap(self:utPort, system:utPort);
			}
Miguel Angel Reina Ortega's avatar
Fix #64  
Miguel Angel Reina Ortega committed
561
			
562
		}// end f_cf03Down
563
		
564 565 566
		/**
		 * @desc Ports unmapping for Config 04
		 */
567
		function f_cf04Down() runs on CseSimu {
568 569
	
			unmap(self:mccPort, system:mccPort);
570
			unmap(self:mccPortIn, system:mccPortIn);
571
			unmap(self:acPort, system:acPort);
Miguel Angel Reina Ortega's avatar
Fix #63  
Miguel Angel Reina Ortega committed
572 573 574
			if(PX_UT_IMPLEMENTED){
				unmap(self:utPort, system:utPort);
			}
Miguel Angel Reina Ortega's avatar
Fix #64  
Miguel Angel Reina Ortega committed
575
		
576
		}// end f_cf04Down
577 578 579 580 581 582 583 584 585

	}//end group configFunctions
	
	group InfoPortCommunication {
	
		/**
		 * @desc Connection of InfoPort of two components
		 * @param p_tester PTC where InfoPort is to be connected
		 */
586 587 588 589 590
		function f_connectInfoPort(in Tester p_tester) runs on Tester {
			// Connect
			connect(self:infoPort, p_tester:infoPort);		
		} 
	
591 592 593 594
		/**
		 * @desc Disconnection of InfoPort of two components
		 * @param p_tester PTC where InfoPort is to be connected
		 */
595 596 597 598
		function f_disconnectInfoPort(in Tester p_tester) runs on Tester {
			// Disconnect
			disconnect(self:infoPort, p_tester:infoPort);		
		} 
599 600 601 602 603 604 605 606
		
		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;
607
				
608
				f_connectInfoPort(p_component);
609
		
610 611 612 613
				p_component.start(f_sendResponsePrimitive());
				alt {
					[]infoPort.receive(mw_responsePrimitiveforInfoPort) -> value v_response {
					}
614
				}
615 616 617 618 619 620
				
				p_component.done;
				f_disconnectInfoPort(p_component);
					
				return v_response;
					
621 622
			}
			
623 624 625 626 627 628 629 630
			/**
			 * @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);
631
	
632 633 634 635
				p_component.start(f_sendRequestPrimitive());
				alt {
					[]infoPort.receive(mw_requestPrimitiveforInfoPort) -> value v_request {
					}
636 637
				}
	
638 639 640 641 642
				p_component.done;
				f_disconnectInfoPort(p_component);
		
				return v_request;
		
643
			}
644 645 646 647 648 649 650
								
			/**
			 * @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;
651
				
652
				f_connectInfoPort(p_ae);
653
		
654 655 656 657
				p_ae.start(f_sendPrimitiveContentRetrievedResource());
				alt {
					[]infoPort.receive(mw_primitiveContent) -> value v_primitiveContent {
					}
658
				}
659 660 661 662 663 664
		
				p_ae.done;
				f_disconnectInfoPort(p_ae);
					
				return v_primitiveContent;
					
665
			}
666 667 668 669 670 671 672 673
			
			/**
			 * @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;
674
				
675
				f_connectInfoPort(p_cse);
676
		
677 678 679 680 681
				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);
					}
682
				}
683 684 685 686 687 688
		
				p_cse.done;
				f_disconnectInfoPort(p_cse);
					
				return v_resourceIndex;
					
689 690
			}
			
691 692 693 694 695
			/**
			 * @desc Getting a specific resource from an AeSimu component
			 * @param p_tester AeSimu component
			 * @param p_resourceIndex Index of resource to be retrieved
			 */
696
			function f_getResourceFromAeSimu(in AeSimu p_component, in integer p_resourceIndex := -1) runs on Tester return integer {
697 698
				var MyResource v_resource;
				var integer v_resourceIndex := -1;
699
			
700
				f_connectInfoPort(p_component);
701 702 703 704 705 706 707 708
				
				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);
					}
				}
709
	
710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730
				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));
				
731 732 733 734 735
				alt {
					[]infoPort.receive(mw_resource) -> value v_resource {
						v_resourceIndex := f_setResource(v_resource.resource, v_resource.resourceType, v_resource.parentIndex, false);
					}
				}
736
	
737 738
				p_component.done;
				f_disconnectInfoPort(p_component);
739
				
740
				return v_resourceIndex;
741
				
742
			}	
743

744 745 746 747 748 749 750 751 752 753
			/**
			 * @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);
754

755 756 757 758 759
				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);
					}
760
				}
761 762 763 764 765

				p_component.done;
				f_disconnectInfoPort(p_component);
			
				return v_resourceIndex;
766
			
767
			}
768 769 770 771 772 773 774
						
			/**
			 * @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;
775

776
				f_connectInfoPort(p_component);
777

778 779 780 781 782
				p_component.start(f_sendLatestResourceIndex());
				alt {
					[]infoPort.receive(mw_resourceIndex) -> value v_resourceIndex{
					}
				}
783

784 785
				p_component.done;
				f_disconnectInfoPort(p_component);
786

787
				return v_resourceIndex;
788 789

			}
790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810

			/**
			 * @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);
811
			
812 813 814 815
				return v_resourceIndex;
			
			}
						
816 817 818 819 820 821
			/**
			 * @desc Getting last local resourceIndex saved in the vc_localResourcesList
			 * @param p_tester Given component
			 */
			function f_getLatestLocalResourceIndex(in CseSimu p_component) runs on Tester return integer {
				var integer v_resourceIndex;
822

823
				f_connectInfoPort(p_component);
824

825 826 827 828 829
				p_component.start(f_sendLatestLocalResourceIndex());
				alt {
					[]infoPort.receive(mw_resourceIndex) -> value <