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;
Yann Garcia's avatar
Yann Garcia committed
35
      var integer v_port := 0;
36 37
			vc_config := e_cf01;
			vc_testSystemRole := e_ae;	
38
			
39
			// Map
40 41
			map(self:mcaPort, system:mcaPort) param (PX_TS_SETTINGS.AE1.mcaPort, PX_TS_SETTINGS.SUT.sutAddress);
			map(self:mcaPortIn, system:mcaPortIn) param (PX_TS_SETTINGS.AE1.mcaPortIn, PX_TS_SETTINGS.SUT.sutAddress);
42
			map(self:acPort, system:acPort);
43
			
Yann Garcia's avatar
Yann Garcia committed
44
			if (ischosen(PX_TS_SETTINGS.AE1.mcaPort.binding.httpBindingDesc)) { // FIXME Create a function to initialize vc_myInterfaces
45
				v_binding := "HTTP";
Yann Garcia's avatar
Yann Garcia committed
46
				v_port := PX_TS_SETTINGS.AE1.mcaPort.binding.httpBindingDesc.bindingDesc.remotePort; // FIXME Use mcxPortyy.sutAddress if present instead of PX_TS_SETTINGS.SUT.sutAddress
47 48
			} else if (ischosen(PX_TS_SETTINGS.AE1.mcaPort.binding.coapBindingDesc)) {
				v_binding := "COAP";
Yann Garcia's avatar
Yann Garcia committed
49
        v_port := PX_TS_SETTINGS.AE1.mcaPort.binding.coapBindingDesc.bindingDesc.remotePort;
50 51
			} else if (ischosen(PX_TS_SETTINGS.AE1.mcaPort.binding.mqttBindingDesc)) {
				v_binding := "MQTT";
Yann Garcia's avatar
Yann Garcia committed
52
        v_port := PX_TS_SETTINGS.AE1.mcaPort.binding.mqttBindingDesc.bindingDesc.remotePort;
53 54
			} else {
				v_binding := "WSCK";
Yann Garcia's avatar
Yann Garcia committed
55
        v_port := PX_TS_SETTINGS.AE1.mcaPort.binding.wsBindingDesc.bindingDesc.remotePort;
56 57 58 59 60 61 62 63 64 65 66
			}
      if (ischosen(PX_TS_SETTINGS.AE1.mcaPortIn.binding.httpBindingDesc)) {
        v_binding_in := "HTTP";
      } else if (ischosen(PX_TS_SETTINGS.AE1.mcaPortIn.binding.coapBindingDesc)) {
        v_binding_in := "COAP";
      } else if (ischosen(PX_TS_SETTINGS.AE1.mcaPortIn.binding.mqttBindingDesc)) {
        v_binding_in := "MQTT";
      } else {
        v_binding_in := "WSCK";
      }
			
67 68
			vc_myInterfaces[enum2int(InterfaceIds:e_mca_port)] := { mcaPort, PX_TS_SETTINGS.SUT.sutAddress & ":" & int2str(v_port), v_binding, c_serializationLabel[enum2int(PX_TS_SETTINGS.AE1.mcaPort.serialization)] };
      vc_myInterfaces[enum2int(InterfaceIds:e_mca_in_port)] := { mcaPortIn, PX_TS_SETTINGS.SUT.sutAddress & ":" & int2str(v_port), v_binding_in, c_serializationLabel[enum2int(PX_TS_SETTINGS.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;
Yann Garcia's avatar
Yann Garcia committed
93
      var integer v_port := 0;
94 95
			vc_config := e_cf01;
			vc_testSystemRole := e_ae;		
96 97
			
			// Map
98 99
			map(self:mcaPort, system:mcaPort) param (PX_TS_SETTINGS.AE2.mcaPort, PX_TS_SETTINGS.SUT.sutAddress);
			map(self:mcaPortIn, system:mcaPortIn) param (PX_TS_SETTINGS.AE2.mcaPortIn, PX_TS_SETTINGS.SUT.sutAddress);
100 101
			map(self:acPort, system:acPort);
	
102 103
      if (ischosen(PX_TS_SETTINGS.AE2.mcaPort.binding.httpBindingDesc)) {
        v_binding := "HTTP";
Yann Garcia's avatar
Yann Garcia committed
104
        v_port := PX_TS_SETTINGS.AE2.mcaPort.binding.httpBindingDesc.bindingDesc.remotePort;
105 106
      } else if (ischosen(PX_TS_SETTINGS.AE2.mcaPort.binding.coapBindingDesc)) {
        v_binding := "COAP";
Yann Garcia's avatar
Yann Garcia committed
107
        v_port := PX_TS_SETTINGS.AE2.mcaPort.binding.coapBindingDesc.bindingDesc.remotePort;
108 109
      } else if (ischosen(PX_TS_SETTINGS.AE2.mcaPort.binding.mqttBindingDesc)) {
        v_binding := "MQTT";
Yann Garcia's avatar
Yann Garcia committed
110
        v_port := PX_TS_SETTINGS.AE2.mcaPort.binding.mqttBindingDesc.bindingDesc.remotePort;
111 112
      } else {
        v_binding := "WSCK";
Yann Garcia's avatar
Yann Garcia committed
113
        v_port := PX_TS_SETTINGS.AE2.mcaPort.binding.wsBindingDesc.bindingDesc.remotePort;
114 115 116 117
      }
      if (ischosen(PX_TS_SETTINGS.AE2.mcaPortIn.binding.httpBindingDesc)) {
        v_binding_in := "HTTP";
      } else if (ischosen(PX_TS_SETTINGS.AE2.mcaPortIn.binding.coapBindingDesc)) {
Yann Garcia's avatar
Yann Garcia committed
118
        v_binding_in := "COAP";
119 120 121 122 123 124
      } else if (ischosen(PX_TS_SETTINGS.AE2.mcaPortIn.binding.mqttBindingDesc)) {
        v_binding_in := "MQTT";
      } else {
        v_binding_in := "WSCK";
      }
      
125 126
      vc_myInterfaces[enum2int(InterfaceIds:e_mca_port)] := { mcaPort, PX_TS_SETTINGS.SUT.sutAddress & ":" & int2str(v_port), v_binding, c_serializationLabel[enum2int(PX_TS_SETTINGS.AE2.mcaPort.serialization)] };
      vc_myInterfaces[enum2int(InterfaceIds:e_mca_in_port)] := { mcaPortIn, PX_TS_SETTINGS.SUT.sutAddress & ":" & int2str(v_port), v_binding_in, c_serializationLabel[enum2int(PX_TS_SETTINGS.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;
Yann Garcia's avatar
Yann Garcia committed
139
      var integer v_port := 0;
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_SETTINGS.AE1.mcaPort, PX_TS_SETTINGS.SUT.sutAddress);
146
			map(self:acPort, system:acPort);
147 148 149
			
      if (ischosen(PX_TS_SETTINGS.AE1.mcaPort.binding.httpBindingDesc)) {
        v_binding := "HTTP";
Yann Garcia's avatar
Yann Garcia committed
150
        v_port := PX_TS_SETTINGS.AE1.mcaPort.binding.httpBindingDesc.bindingDesc.remotePort;
151
      } else if (ischosen(PX_TS_SETTINGS.AE1.mcaPort.binding.coapBindingDesc)) {
Yann Garcia's avatar
Yann Garcia committed
152
        v_binding := "COAP";
Yann Garcia's avatar
Yann Garcia committed
153
        v_port := PX_TS_SETTINGS.AE1.mcaPort.binding.coapBindingDesc.bindingDesc.remotePort;
154 155
      } else if (ischosen(PX_TS_SETTINGS.AE1.mcaPort.binding.mqttBindingDesc)) {
        v_binding := "MQTT";
Yann Garcia's avatar
Yann Garcia committed
156
        v_port := PX_TS_SETTINGS.AE1.mcaPort.binding.mqttBindingDesc.bindingDesc.remotePort;
157 158
      } else {
        v_binding := "WSCK";
Yann Garcia's avatar
Yann Garcia committed
159
        v_port := PX_TS_SETTINGS.AE1.mcaPort.binding.wsBindingDesc.bindingDesc.remotePort;
160 161
      }
      
162
      vc_myInterfaces[enum2int(InterfaceIds:e_mca_port)] := { mcaPort, PX_TS_SETTINGS.SUT.sutAddress & ":" & int2str(v_port), v_binding, c_serializationLabel[enum2int(PX_TS_SETTINGS.AE1.mcaPort.serialization)] };
163
			
164
			if(PX_UT_IMPLEMENTED) {
165
				map(self:utPort, system:utPort) param (PX_TS_SETTINGS.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;
Yann Garcia's avatar
Yann Garcia committed
186
      var integer v_port := 0;
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_SETTINGS.CSE1.mccPort, PX_TS_SETTINGS.SUT.sutAddress);
			map(self:mccPortIn, system:mccPortIn) param (PX_TS_SETTINGS.CSE1.mccPortIn, PX_TS_SETTINGS.SUT.sutAddress);
195
			map(self:acPort, system:acPort);
196 197 198
			
      if (ischosen(PX_TS_SETTINGS.CSE1.mccPort.binding.httpBindingDesc)) {
        v_binding := "HTTP";
Yann Garcia's avatar
Yann Garcia committed
199
        v_port := PX_TS_SETTINGS.CSE1.mccPort.binding.httpBindingDesc.bindingDesc.remotePort;
200 201
      } else if (ischosen(PX_TS_SETTINGS.CSE1.mccPort.binding.coapBindingDesc)) {
        v_binding := "COAP";
Yann Garcia's avatar
Yann Garcia committed
202
        v_port := PX_TS_SETTINGS.CSE1.mccPort.binding.coapBindingDesc.bindingDesc.remotePort;
203
      } else if (ischosen(PX_TS_SETTINGS.CSE1.mccPort.binding.mqttBindingDesc)) {
Yann Garcia's avatar
Yann Garcia committed
204
        v_port := PX_TS_SETTINGS.CSE1.mccPort.binding.mqttBindingDesc.bindingDesc.remotePort;
205 206
        v_binding := "MQTT";
      } else {
Yann Garcia's avatar
Yann Garcia committed
207
        v_port := PX_TS_SETTINGS.CSE1.mccPort.binding.wsBindingDesc.bindingDesc.remotePort;
208 209 210 211 212
        v_binding := "WSCK";
      }
      if (ischosen(PX_TS_SETTINGS.CSE1.mccPortIn.binding.httpBindingDesc)) {
        v_binding_in := "HTTP";
      } else if (ischosen(PX_TS_SETTINGS.CSE1.mccPortIn.binding.coapBindingDesc)) {
Yann Garcia's avatar
Yann Garcia committed
213
        v_binding_in := "COAP";
214 215 216 217 218 219
      } else if (ischosen(PX_TS_SETTINGS.CSE1.mccPortIn.binding.mqttBindingDesc)) {
        v_binding_in := "MQTT";
      } else {
        v_binding_in := "WSCK";
      }
      
220 221
      vc_myInterfaces[enum2int(InterfaceIds:e_mcc_port)] := { mccPort, PX_TS_SETTINGS.SUT.sutAddress & ":" & int2str(v_port), v_binding, c_serializationLabel[enum2int(PX_TS_SETTINGS.CSE1.mccPort.serialization)] };
      vc_myInterfaces[enum2int(InterfaceIds:e_mcc_in_port)] := { mccPortIn, v_binding_in, PX_TS_SETTINGS.SUT.sutAddress & ":" & int2str(v_port), c_serializationLabel[enum2int(PX_TS_SETTINGS.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;
Yann Garcia's avatar
Yann Garcia committed
238
      var integer v_port := 0;
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_SETTINGS.CSE1.mccPort, PX_TS_SETTINGS.SUT.sutAddress);
			map(self:mccPortIn, system:mccPortIn) param (PX_TS_SETTINGS.CSE1.mccPortIn, PX_TS_SETTINGS.SUT.sutAddress);
252
			map(self:acPort, system:acPort);
253
			
Yann Garcia's avatar
Yann Garcia committed
254 255 256 257 258 259 260 261 262 263 264 265 266
			if (ischosen(PX_TS_SETTINGS.CSE1.mccPort.binding.httpBindingDesc)) {
			  v_binding := "HTTP";
			  v_port := PX_TS_SETTINGS.CSE1.mccPort.binding.httpBindingDesc.bindingDesc.remotePort;
			} else if (ischosen(PX_TS_SETTINGS.CSE1.mccPort.binding.coapBindingDesc)) {
			  v_binding := "COAP";
			  v_port := PX_TS_SETTINGS.CSE1.mccPort.binding.coapBindingDesc.bindingDesc.remotePort;
			} else if (ischosen(PX_TS_SETTINGS.CSE1.mccPort.binding.mqttBindingDesc)) {
			  v_port := PX_TS_SETTINGS.CSE1.mccPort.binding.mqttBindingDesc.bindingDesc.remotePort;
			  v_binding := "MQTT";
			} else {
			  v_port := PX_TS_SETTINGS.CSE1.mccPort.binding.wsBindingDesc.bindingDesc.remotePort;
			  v_binding := "WSCK";
			}
267 268 269
      if (ischosen(PX_TS_SETTINGS.CSE1.mccPortIn.binding.httpBindingDesc)) {
        v_binding_in := "HTTP";
      } else if (ischosen(PX_TS_SETTINGS.CSE1.mccPortIn.binding.coapBindingDesc)) {
Yann Garcia's avatar
Yann Garcia committed
270
        v_binding_in := "COAP";
271 272 273 274 275 276
      } else if (ischosen(PX_TS_SETTINGS.CSE1.mccPortIn.binding.mqttBindingDesc)) {
        v_binding_in := "MQTT";
      } else {
        v_binding_in := "WSCK";
      }
      
277 278
			vc_myInterfaces[enum2int(InterfaceIds:e_mcc_port)] := { mccPort, PX_TS_SETTINGS.SUT.sutAddress & ":" & int2str(v_port), v_binding, c_serializationLabel[enum2int(PX_TS_SETTINGS.CSE1.mccPort.serialization)] };
			vc_myInterfaces[enum2int(InterfaceIds:e_mcc_in_port)] := { mccPortIn, PX_TS_SETTINGS.SUT.sutAddress & ":" & int2str(v_port), v_binding_in, c_serializationLabel[enum2int(PX_TS_SETTINGS.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;
Yann Garcia's avatar
Yann Garcia committed
299
      var integer v_port := 0;
300
			vc_config := e_cf02CseSimuMaster;	
301
			vc_testSystemRole := e_ae;	
302 303
			
			// Map
304 305
			map(self:mcaPort, system:mcaPort) param (PX_TS_SETTINGS.AE1.mcaPort, PX_TS_SETTINGS.SUT.sutAddress);
			map(self:mcaPortIn, system:mcaPortIn) param (PX_TS_SETTINGS.AE1.mcaPortIn, PX_TS_SETTINGS.SUT.sutAddress);
306 307
			map(self:acPort, system:acPort);
			
308 309
			if (ischosen(PX_TS_SETTINGS.AE1.mcaPort.binding.httpBindingDesc)) {
			  v_binding := "HTTP";
Yann Garcia's avatar
Yann Garcia committed
310
			  v_port := PX_TS_SETTINGS.AE1.mcaPort.binding.httpBindingDesc.bindingDesc.remotePort;
311
			} else if (ischosen(PX_TS_SETTINGS.AE1.mcaPort.binding.coapBindingDesc)) {
Yann Garcia's avatar
Yann Garcia committed
312
			  v_binding := "COAP";
Yann Garcia's avatar
Yann Garcia committed
313
			  v_port := PX_TS_SETTINGS.AE1.mcaPort.binding.coapBindingDesc.bindingDesc.remotePort;
314 315
			} else if (ischosen(PX_TS_SETTINGS.AE1.mcaPort.binding.mqttBindingDesc)) {
			  v_binding := "MQTT";
Yann Garcia's avatar
Yann Garcia committed
316
			  v_port := PX_TS_SETTINGS.AE1.mcaPort.binding.mqttBindingDesc.bindingDesc.remotePort;
317 318
			} else {
			  v_binding := "WSCK";
Yann Garcia's avatar
Yann Garcia committed
319
			  v_port := PX_TS_SETTINGS.AE1.mcaPort.binding.wsBindingDesc.bindingDesc.remotePort;
320 321 322 323 324 325 326 327 328 329 330
			}
			if (ischosen(PX_TS_SETTINGS.AE1.mcaPortIn.binding.httpBindingDesc)) {
			  v_binding_in := "HTTP";
			} else if (ischosen(PX_TS_SETTINGS.AE1.mcaPortIn.binding.coapBindingDesc)) {
			  v_binding_in := "COAP";
			} else if (ischosen(PX_TS_SETTINGS.AE1.mcaPortIn.binding.mqttBindingDesc)) {
			  v_binding_in := "MQTT";
			} else {
			  v_binding_in := "WSCK";
			}
      
331 332
			vc_myInterfaces[enum2int(InterfaceIds:e_mca_port)] := { mcaPort, PX_TS_SETTINGS.SUT.sutAddress & ":" & int2str(v_port), v_binding, c_serializationLabel[enum2int(PX_TS_SETTINGS.AE1.mcaPort.serialization)] };
			vc_myInterfaces[enum2int(InterfaceIds:e_mca_in_port)] := { mcaPortIn, PX_TS_SETTINGS.SUT.sutAddress & ":" & int2str(v_port), v_binding_in, c_serializationLabel[enum2int(PX_TS_SETTINGS.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;
Yann Garcia's avatar
Yann Garcia committed
346
      var integer v_port := 0;
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_SETTINGS.AE1.mcaPort, PX_TS_SETTINGS.SUT.sutAddress);//TODO To be consistent, we should use mcaPortIn for AE testing
357
			map(self:acPort, system:acPort);
358
			
Yann Garcia's avatar
Yann Garcia committed
359 360 361 362
			if (ischosen(PX_TS_SETTINGS.AE2.mcaPort.binding.httpBindingDesc)) {
			  v_binding := "HTTP";
			  v_port := PX_TS_SETTINGS.AE2.mcaPort.binding.httpBindingDesc.bindingDesc.remotePort;
			} else if (ischosen(PX_TS_SETTINGS.AE2.mcaPort.binding.coapBindingDesc)) {
Yann Garcia's avatar
Yann Garcia committed
363
			  v_binding := "COAP";
Yann Garcia's avatar
Yann Garcia committed
364 365 366 367 368 369 370 371
			  v_port := PX_TS_SETTINGS.AE2.mcaPort.binding.coapBindingDesc.bindingDesc.remotePort;
			} else if (ischosen(PX_TS_SETTINGS.AE2.mcaPort.binding.mqttBindingDesc)) {
			  v_binding := "MQTT";
			  v_port := PX_TS_SETTINGS.AE2.mcaPort.binding.mqttBindingDesc.bindingDesc.remotePort;
			} else {
			  v_binding := "WSCK";
			  v_port := PX_TS_SETTINGS.AE2.mcaPort.binding.wsBindingDesc.bindingDesc.remotePort;
			}
372
      
373 374
			vc_myInterfaces[enum2int(InterfaceIds:e_mca_in_port)] := { mcaPortIn, PX_TS_SETTINGS.SUT.sutAddress & ":" & int2str(v_port), v_binding, c_serializationLabel[enum2int(PX_TS_SETTINGS.AE2.mcaPortIn.serialization)] };
			vc_myInterfaces[enum2int(InterfaceIds:e_mca_in_port)] := { mcaPortIn, PX_TS_SETTINGS.SUT.sutAddress & ":" & int2str(v_port), v_binding, c_serializationLabel[enum2int(PX_TS_SETTINGS.AE2.mcaPortIn.serialization)] };
375
			
376
			if(PX_UT_IMPLEMENTED) {
377
				map(self:utPort, system:utPort) param (PX_TS_SETTINGS.UT);
378
			}
379
			activate(a_default());
380
			vc_cseSimu := activate(a_cse_cf03());
381 382 383 384 385 386
		
			// Connect
					
			//Initialze the IUT
					
		} // end f_cf03Up
387 388 389 390
		
		/**
		 * @desc Ports mapping and default behaviour activation for Config 04
		 */
391
		function f_cf04Up(in CseTypeID p_cseType := int2) runs on CseSimu system CseSystem {
392 393

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

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

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

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

683 684 685 686 687 688 689 690 691 692
			/**
			 * @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);
693

694 695 696 697 698
				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);
					}
699
				}
700 701 702 703 704

				p_component.done;
				f_disconnectInfoPort(p_component);
			
				return v_resourceIndex;
705
			
706
			}
707 708 709 710 711 712 713
						
			/**
			 * @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;
714

715
				f_connectInfoPort(p_component);
716

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

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

726
				return v_resourceIndex;
727 728

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

			/**
			 * @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);
750
			
751 752 753 754
				return v_resourceIndex;
			
			}
						
755 756 757 758 759 760
			/**
			 * @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;
761

762
				f_connectInfoPort(p_component);
763

764 765 766 767 768
				p_component.start(f_sendLatestLocalResourceIndex());
				alt {
					[]infoPort.receive(mw_resourceIndex) -> value v_resourceIndex{
					}
				}
769

770 771 772 773 774 775
				p_component.done;
				f_disconnectInfoPort(p_component);

				return v_resourceIndex;

			}
776
		
777 778 779 780 781 782
			/**
			 * @desc Getting the address of the last local resource saved in the vc_localResourcesList
			 * @param p_tester Given component
			 */
			function f_getLatestLocalResourceAddress(in CseSimu p_component, AddressingMethod p_addressingMethod := PX_ADDRESSING_METHOD, PrimitiveScope p_primitiveScope := PX_PRIMITIVE_SCOPE) runs on Tester return XSD.ID {
				var XSD.ID v_localResourceAddress;
783

784
				f_connectInfoPort(p_component);
785

786 787 788 789
				p_component.start(f_sendLatestLocalResourceAddress(p_addressingMethod, p_primitiveScope));
				alt {
					[]infoPort.receive(mw_resourceAddress) -> value v_localResourceAddress{
					}
790 791
				}

792 793
				p_component.done;
				f_disconnectInfoPort(p_component);
794

795
				return v_localResourceAddress;
796

797
			}
798
		}//end of group getFunctions
799
		
800
		group sendFunctions {	
801
	
802 803 804 805
			/**
			 * @desc Sending of last responsePrimitive (vc_response) through InfoPort
			 */	
			function f_sendResponsePrimitive() runs on Tester {
806
		
807 808 809
				infoPort.send(vc_response.primitive.responsePrimitive);
					
			} 
810
	
811 812 813 814
			/**
			 * @desc Sending of last requestPrimitive (vc_request) through InfoPort
			 */			
			function f_sendRequestPrimitive() runs on Tester {
815
		
816
				infoPort.send(vc_request.primitive.requestPrimitive);
817
		
818
			} 
819
			
820 821 822 823 824 825 826