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
 *  @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 18 19
	import from OneM2M_TypesAndValues all;
	import from OneM2M_TestSystem all;
	import from OneM2M_Pixits all;
20
	import from OneM2M_Pics all;
21
	
22
	group ConfigFunctions {
23
		
24 25 26
		/**
			@desc Ports mapping and default behaviour activation for Config 1
		*/
Yann Garcia's avatar
Yann Garcia committed
27
		function f_cf01Up(in boolean p_auxiliaryAe2Required := false) runs on AeSimu system CseSystem {
28
			
29
			// Variables
30 31
      var charstring v_binding;
      var charstring v_binding_in;
32
      var charstring v_host;
33 34
			vc_config := e_cf01;
			vc_testSystemRole := e_ae;	
35
			
36
			// Map
37 38
			map(self:mcaPort, system:mcaPort) param (PX_TS_AE1.mcaPort);
			map(self:mcaPortIn, system:mcaPortIn) param (PX_TS_AE1.mcaPortIn);
39
			map(self:acPort, system:acPort);
40
			
41
			if (ischosen(PX_TS_AE1.mcaPort.binding.httpBindingDesc)) { // FIXME Create a function to initialize vc_myInterfaces
42
				v_binding := "HTTP";
43 44
				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)) {
45
				v_binding := "COAP";
46 47
				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)) {
48
				v_binding := "MQTT";
49
				v_host := PX_TS_AE1.mcaPort.binding.mqttBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE1.mcaPort.binding.mqttBindingDesc.bindingDesc.remotePort);
50 51
			} else {
				v_binding := "WSCK";
52
				v_host := PX_TS_AE1.mcaPort.binding.wsBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE1.mcaPort.binding.wsBindingDesc.bindingDesc.remotePort);
53
			}
54
      if (ischosen(PX_TS_AE1.mcaPortIn.binding.httpBindingDesc)) {
55
        v_binding_in := "HTTP";
56
      } else if (ischosen(PX_TS_AE1.mcaPortIn.binding.coapBindingDesc)) {
57
        v_binding_in := "COAP";
58
      } else if (ischosen(PX_TS_AE1.mcaPortIn.binding.mqttBindingDesc)) {
59 60 61 62 63
        v_binding_in := "MQTT";
      } else {
        v_binding_in := "WSCK";
      }
			
64 65
			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)] };
66
			
67
			activate(a_default());
68
			vc_aeSimu := activate(a_cse_cf01());
69
				
70 71 72 73 74
			// Initialize AE2
			if(p_auxiliaryAe2Required) {
				vc_auxiliaryAe2Up := p_auxiliaryAe2Required;
				vc_ae2 := AeSimu.create("AE2") alive;
				vc_ae2.start(f_cf01UpAe2());
75
				vc_ae2.done;
76 77 78 79 80 81 82 83 84
			}
				
			//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
85
		function f_cf01UpAe2() runs on AeSimu system CseSystem {
86 87
			
			// Variables
88 89
			var charstring v_binding;
			var charstring v_binding_in;
90
      var charstring v_host;
91 92
			vc_config := e_cf01;
			vc_testSystemRole := e_ae;		
93 94
			
			// Map
95 96
			map(self:mcaPort, system:mcaPort) param (PX_TS_AE2.mcaPort);
			map(self:mcaPortIn, system:mcaPortIn) param (PX_TS_AE2.mcaPortIn);
97 98
			map(self:acPort, system:acPort);
	
99
      if (ischosen(PX_TS_AE2.mcaPort.binding.httpBindingDesc)) {
100
        v_binding := "HTTP";
101 102
        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)) {
103
        v_binding := "COAP";
104 105
        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)) {
106
        v_binding := "MQTT";
107
        v_host := PX_TS_AE2.mcaPort.binding.mqttBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE2.mcaPort.binding.mqttBindingDesc.bindingDesc.remotePort);
108 109
      } else {
        v_binding := "WSCK";
110
        v_host := PX_TS_AE2.mcaPort.binding.wsBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE2.mcaPort.binding.wsBindingDesc.bindingDesc.remotePort);
111
      }
112
      if (ischosen(PX_TS_AE2.mcaPortIn.binding.httpBindingDesc)) {
113
        v_binding_in := "HTTP";
114
      } else if (ischosen(PX_TS_AE2.mcaPortIn.binding.coapBindingDesc)) {
Yann Garcia's avatar
Yann Garcia committed
115
        v_binding_in := "COAP";
116
      } else if (ischosen(PX_TS_AE2.mcaPortIn.binding.mqttBindingDesc)) {
117 118 119 120 121
        v_binding_in := "MQTT";
      } else {
        v_binding_in := "WSCK";
      }
      
122 123
      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)] };
124

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

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

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

			// Connect
			
437
			//Initialize the IUT
438
			
439
		} // end f_cf04Up
440 441

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

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

679 680 681 682 683 684 685 686 687 688
			/**
			 * @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);
689

690 691 692 693 694
				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);
					}
695
				}
696 697 698 699 700

				p_component.done;
				f_disconnectInfoPort(p_component);
			
				return v_resourceIndex;
701
			
702
			}
703 704 705 706 707 708 709
						
			/**
			 * @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;
710

711
				f_connectInfoPort(p_component);
712

713 714 715 716 717
				p_component.start(f_sendLatestResourceIndex());
				alt {
					[]infoPort.receive(mw_resourceIndex) -> value v_resourceIndex{
					}
				}
718

719 720
				p_component.done;
				f_disconnectInfoPort(p_component);
721

722
				return v_resourceIndex;
723 724

			}
725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745

			/**
			 * @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);
746
			
747 748 749 750
				return v_resourceIndex;
			
			}
						
751 752 753 754 755 756
			/**
			 * @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;