OneM2M_Functions.ttcn 214 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
		*/
30 31
		function f_cf01Up(in boolean p_auxiliaryAe2Required := false) runs on AeSimu {
			
32
			// Variables
33 34
			vc_config := e_cf01;
			vc_testSystemRole := e_ae;	
35
			
36 37
			// Map
			map(self:mcaPort, system:mcaPort);
Antonio Castillo Verdugo's avatar
Fix #15  
Antonio Castillo Verdugo committed
38
			map(self:mcaPortIn, system:mcaPortIn);
39
			map(self:acPort, system:acPort);
40
			
41
			activate(a_default());
42
			vc_aeSimu := activate(a_cse_cf01());
43
				
44 45 46 47
			// Initialize AE2
			if(p_auxiliaryAe2Required) {
				vc_auxiliaryAe2Up := p_auxiliaryAe2Required;
				vc_ae2 := AeSimu.create("AE2") alive;
48 49
				vc_ae2.start(f_setProtocolBinding(PX_PROTOCOL_BINDING_AE2));
				vc_ae2.done;
50
				vc_ae2.start(f_cf01UpAe2());
51
				vc_ae2.done;
52 53 54 55 56 57 58 59 60 61 62 63
			}
				
			//Initialze the IUT
							
		} // end f_cf01Up
		
		/**
			@desc Ports mapping and default behaviour activation for Config 1 on the auxiliary AE2
		*/
		function f_cf01UpAe2() runs on AeSimu {
			
			// Variables
64 65
			vc_config := e_cf01;
			vc_testSystemRole := e_ae;		
66 67 68 69 70 71
			
			// Map
			map(self:mcaPort, system:mcaPort);
			map(self:mcaPortIn, system:mcaPortIn);
			map(self:acPort, system:acPort);
	
72
			//Initialze the IUT
73
							
74
		} // end f_cf01UpAe2
75
		
76 77 78
		/**
		 * @desc Ports mapping and default behaviour activation for Config 02
		 */
79
		function f_cf02Up(in CseTypeID p_cseType := int2) runs on AeSimu {
80
				
81
			// Variables
82
			vc_config := e_cf02;
83
			vc_testSystemRole := e_ae;	
84
			vc_cse1 := CseSimu.create("CSE1") alive;
85 86
			vc_cse1.start(f_setProtocolBinding(PX_PROTOCOL_BINDING_CSE1));
			vc_cse1.done;
87
				
88 89 90
			// Map
			map(self:mcaPort, system:mcaPort);
			map(self:acPort, system:acPort);
91 92 93
			if(PX_UT_IMPLEMENTED) {
				map(self:utPort, system:utPort);
			}
94
			activate(a_default());
95
			vc_aeSimu := activate(a_cse_cf02_ae1());
96
			vc_cse1.start(f_cf02UpCse1(p_cseType));
97
			vc_cse1.done;
98
				
99
			// Connect
100
			
101
			//Initialze the IUT
102
							
103
		} // end f_cf02Up
104 105 106 107
		
		/**
			@desc Ports mapping and default behaviour activation for Config 2 on the CSE1
		*/
108
		function f_cf02UpCse1(in CseTypeID p_cseType := int2) runs on CseSimu {
109 110
			
			// Variables
111
			var PrimitiveContent v_cSEBaseResource;
112 113
			vc_config := e_cf02;
			vc_testSystemRole := e_cse;		
114
			vc_cseType := p_cseType;
115 116 117 118 119
			
			// Map
			map(self:mccPort, system:mccPort);
			map(self:mccPortIn, system:mccPortIn);
			map(self:acPort, system:acPort);
120
						
Miguel Angel Reina Ortega's avatar
Fix #47  
Miguel Angel Reina Ortega committed
121
			v_cSEBaseResource := f_generateLocalResource(-, -1, int5);
122 123
			vc_cSEBaseIndex := f_setLocalResource(v_cSEBaseResource, int5, -1);
			
124 125 126
			//Initialze the IUT
							
		} // end f_cf02UpCse1
127 128 129 130

		/**
		 * @desc Ports mapping and default behaviour activation for Config 02
		 */
131
		function f_cf02UpCseSimuMaster(in CseTypeID p_cseType := int2) runs on CseSimu {
132 133
				
			// Variables
134 135
			var PrimitiveContent v_cSEBaseResource;
			vc_config := e_cf02CseSimuMaster;
136 137
			vc_testSystemRole := e_cse;	
			vc_cseType := p_cseType;
138
			vc_ae1 := AeSimu.create("AE1") alive;
139 140
			vc_ae1.start(f_setProtocolBinding(PX_PROTOCOL_BINDING_AE1));
			vc_ae1.done;
141 142
			
			//Initialization of local CSEBase
Miguel Angel Reina Ortega's avatar
Fix #47  
Miguel Angel Reina Ortega committed
143
			v_cSEBaseResource := f_generateLocalResource(-, -1, int5);
144
			vc_cSEBaseIndex := f_setLocalResource(v_cSEBaseResource, int5, -1);
145 146 147
				
			// Map
			map(self:mccPort, system:mccPort);
148
			map(self:mccPortIn, system:mccPortIn);
149 150
			map(self:acPort, system:acPort);
			activate(a_default());
151
			vc_cseSimu := activate(a_cse_cf02_cse1());
152 153
			vc_ae1.start(f_cf02UpAe1());
			vc_ae1.done;
154 155
				
			// Connect
156
			
157 158 159
			//Initialze the IUT
							
		} // end f_cf02UpCseSimuMaster
160
		
161 162 163
		/**
			@desc Ports mapping and default behaviour activation for Config 2 on the AE1
		*/
164
		function f_cf02UpAe1(in CseTypeID p_cseType := int2) runs on AeSimu {
165 166
			
			// Variables
167
			vc_config := e_cf02CseSimuMaster;	
168
			vc_testSystemRole := e_ae;	
169 170 171
			
			// Map
			map(self:mcaPort, system:mcaPort);
172
			map(self:mcaPortIn, system:mcaPortIn);
173 174 175 176 177 178
			map(self:acPort, system:acPort);
			
			//Initialze the IUT
							
		} // end f_cf02UpAe1
		
179 180 181
		/**
		 * @desc Ports mapping and default behaviour activation for Config 03
		 */
182
		function f_cf03Up(in CseTypeID p_cseType := int2) runs on CseSimu {
183 184
		
			// Variables
185
			var PrimitiveContent v_cSEBaseResource;
186
			vc_config := e_cf03;
187 188
			vc_testSystemRole := e_cse;	
			vc_cseType := p_cseType;	
189
			
190
			//Creation of CSEBase
Miguel Angel Reina Ortega's avatar
Fix #47  
Miguel Angel Reina Ortega committed
191
			v_cSEBaseResource := f_generateLocalResource(-, -1, int5);
192 193
			vc_cSEBaseIndex := f_setLocalResource(v_cSEBaseResource, int5, -1);
			
194
			// Map
195
			map(self:mcaPortIn, system:mcaPortIn);//TODO To be consistent, we should use mcaPortIn for AE testing
196
			map(self:acPort, system:acPort);
197 198 199
			if(PX_UT_IMPLEMENTED) {
				map(self:utPort, system:utPort);
			}
200
			activate(a_default());
201
			vc_cseSimu := activate(a_cse_cf03());
202 203 204 205 206 207
		
			// Connect
					
			//Initialze the IUT
					
		} // end f_cf03Up
208 209 210 211
		
		/**
		 * @desc Ports mapping and default behaviour activation for Config 04
		 */
212
		function f_cf04Up(in CseTypeID p_cseType := int2) runs on CseSimu {
213 214

			// Variables
215
			var PrimitiveContent v_cSEBaseResource;
216
			vc_config := e_cf04;
217
			vc_testSystemRole := e_cse;	
218
			vc_cseType := p_cseType;			
219
			//Creation of CSEBase
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
			// Map
			map(self:mccPort, system:mccPort);
225
			map(self:mccPortIn, system:mccPortIn);
226 227
			map(self:acPort, system:acPort);
			activate(a_default());
228
			vc_cseSimu := activate(a_cse_cf04());
229 230 231

			// Connect
			
232
			//Initialize the IUT
233
			
234
		} // end f_cf04Up
235 236

		/**
237
		 * @desc Ports unmapping
238
		 */
239
		function f_cf01Down() runs on AeSimu {
240
		
241
			unmap(self:mcaPort, system:mcaPort);
242
			unmap(self:acPort, system:acPort);
243 244
			if(vc_auxiliaryAe2Up) {
				vc_ae2.start(f_cf01DownAe2());
245
				vc_ae2.done;
246
			}
247
		}// end f_cf01Down
248 249 250 251 252 253 254 255 256
		
		/**
		 * @desc Ports unmapping
		 */
		function f_cf01DownAe2() runs on AeSimu {
				
			unmap(self:mcaPort, system:mcaPort);
			unmap(self:acPort, system:acPort);
			unmap(self:mcaPortIn, system:mcaPortIn);
257
		}// end f_cf01DownAe2
258
		
259 260 261
		/**
		 * @desc Ports unmapping
		 */
262
		function f_cf02Down() runs on AeSimu {
263
		
264
			unmap(self:mcaPort, system:mcaPort);
265
			unmap(self:acPort, system:acPort);
266 267 268
			if(PX_UT_IMPLEMENTED){
				unmap(self:utPort, system:utPort);
			}
269 270 271
			unmap(vc_cse1:mccPort, system:mccPort);
			unmap(vc_cse1:mccPortIn, system:mccPortIn);
			unmap(vc_cse1:acPort, system:acPort);
272 273
		}// end f_cf02Down
		
274 275 276 277 278
		/**
		 * @desc Ports unmapping
		 */
		function f_cf02DownCseSimuMaster() runs on CseSimu {
				
279
			unmap(self:mccPort, system:mccPort);
280
			unmap(self:mccPortIn, system:mccPortIn);
281
			unmap(self:acPort, system:acPort);
282 283
			unmap(vc_ae1:mcaPort, system:mcaPort);
			unmap(vc_ae1:acPort, system:acPort);
284 285
		}// end f_cf02DownCseSimuMaster
		
286 287 288
		/**
		 * @desc Ports unmapping for Config 03
		 */
289
		function f_cf03Down() runs on CseSimu {
290
			
291
			unmap(self:mcaPortIn, system:mcaPortIn);
292 293 294
			if(PX_UT_IMPLEMENTED){
				unmap(self:utPort, system:utPort);
			}
295
			unmap(self:acPort, system:acPort);
296
		}// end f_cf03Down
297
		
298 299 300
		/**
		 * @desc Ports unmapping for Config 04
		 */
301
		function f_cf04Down() runs on CseSimu {
302 303
	
			unmap(self:mccPort, system:mccPort);
304
			unmap(self:mccPortIn, system:mccPortIn);
305
			unmap(self:acPort, system:acPort);
306
		}// end f_cf04Down
307 308 309 310 311 312 313 314 315

	}//end group configFunctions
	
	group InfoPortCommunication {
	
		/**
		 * @desc Connection of InfoPort of two components
		 * @param p_tester PTC where InfoPort is to be connected
		 */
316 317 318 319 320
		function f_connectInfoPort(in Tester p_tester) runs on Tester {
			// Connect
			connect(self:infoPort, p_tester:infoPort);		
		} 
	
321 322 323 324
		/**
		 * @desc Disconnection of InfoPort of two components
		 * @param p_tester PTC where InfoPort is to be connected
		 */
325 326 327 328
		function f_disconnectInfoPort(in Tester p_tester) runs on Tester {
			// Disconnect
			disconnect(self:infoPort, p_tester:infoPort);		
		} 
329 330 331 332 333 334 335 336
		
		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;
337
				
338
				f_connectInfoPort(p_component);
339
		
340 341 342 343
				p_component.start(f_sendResponsePrimitive());
				alt {
					[]infoPort.receive(mw_responsePrimitiveforInfoPort) -> value v_response {
					}
344
				}
345 346 347 348 349 350
				
				p_component.done;
				f_disconnectInfoPort(p_component);
					
				return v_response;
					
351 352
			}
			
353 354 355 356 357 358 359 360
			/**
			 * @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);
361
	
362 363 364 365
				p_component.start(f_sendRequestPrimitive());
				alt {
					[]infoPort.receive(mw_requestPrimitiveforInfoPort) -> value v_request {
					}
366 367
				}
	
368 369 370 371 372
				p_component.done;
				f_disconnectInfoPort(p_component);
		
				return v_request;
		
373
			}
374 375 376 377 378 379 380
								
			/**
			 * @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;
381
				
382
				f_connectInfoPort(p_ae);
383
		
384 385 386 387
				p_ae.start(f_sendPrimitiveContentRetrievedResource());
				alt {
					[]infoPort.receive(mw_primitiveContent) -> value v_primitiveContent {
					}
388
				}
389 390 391 392 393 394
		
				p_ae.done;
				f_disconnectInfoPort(p_ae);
					
				return v_primitiveContent;
					
395
			}
396 397 398 399 400 401 402 403
			
			/**
			 * @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;
404
				
405
				f_connectInfoPort(p_cse);
406
		
407 408 409 410 411
				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);
					}
412
				}
413 414 415 416 417 418
		
				p_cse.done;
				f_disconnectInfoPort(p_cse);
					
				return v_resourceIndex;
					
419 420
			}
			
421 422 423 424 425
			/**
			 * @desc Getting a specific resource from an AeSimu component
			 * @param p_tester AeSimu component
			 * @param p_resourceIndex Index of resource to be retrieved
			 */
426
			function f_getResourceFromAeSimu(in AeSimu p_component, in integer p_resourceIndex := -1) runs on Tester return integer {
427 428
				var MyResource v_resource;
				var integer v_resourceIndex := -1;
429
			
430
				f_connectInfoPort(p_component);
431 432 433 434 435 436 437 438
				
				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);
					}
				}
439
	
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460
				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));
				
461 462 463 464 465
				alt {
					[]infoPort.receive(mw_resource) -> value v_resource {
						v_resourceIndex := f_setResource(v_resource.resource, v_resource.resourceType, v_resource.parentIndex, false);
					}
				}
466
	
467 468
				p_component.done;
				f_disconnectInfoPort(p_component);
469
				
470
				return v_resourceIndex;
471
				
472
			}	
473

474 475 476 477 478 479 480 481 482 483
			/**
			 * @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);
484

485 486 487 488 489
				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);
					}
490
				}
491 492 493 494 495

				p_component.done;
				f_disconnectInfoPort(p_component);
			
				return v_resourceIndex;
496
			
497
			}
498 499 500 501 502 503 504
						
			/**
			 * @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;
505

506
				f_connectInfoPort(p_component);
507

508 509 510 511 512
				p_component.start(f_sendLatestResourceIndex());
				alt {
					[]infoPort.receive(mw_resourceIndex) -> value v_resourceIndex{
					}
				}
513

514 515
				p_component.done;
				f_disconnectInfoPort(p_component);
516

517
				return v_resourceIndex;
518 519

			}
520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540

			/**
			 * @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);
541
			
542 543 544 545
				return v_resourceIndex;
			
			}
						
546 547 548 549 550 551
			/**
			 * @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;
552

553
				f_connectInfoPort(p_component);
554

555 556 557 558 559
				p_component.start(f_sendLatestLocalResourceIndex());
				alt {
					[]infoPort.receive(mw_resourceIndex) -> value v_resourceIndex{
					}
				}
560

561 562 563 564 565 566
				p_component.done;
				f_disconnectInfoPort(p_component);

				return v_resourceIndex;

			}
567
		
568 569 570 571 572 573
			/**
			 * @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;
574

575
				f_connectInfoPort(p_component);
576

577 578 579 580
				p_component.start(f_sendLatestLocalResourceAddress(p_addressingMethod, p_primitiveScope));
				alt {
					[]infoPort.receive(mw_resourceAddress) -> value v_localResourceAddress{
					}
581 582
				}

583 584
				p_component.done;
				f_disconnectInfoPort(p_component);
585

586
				return v_localResourceAddress;
587

588
			}
589
		}//end of group getFunctions
590
		
591
		group sendFunctions {	
592
	
593 594 595 596
			/**
			 * @desc Sending of last responsePrimitive (vc_response) through InfoPort
			 */	
			function f_sendResponsePrimitive() runs on Tester {
597
		
598 599 600
				infoPort.send(vc_response.primitive.responsePrimitive);
					
			} 
601
	
602 603 604 605
			/**
			 * @desc Sending of last requestPrimitive (vc_request) through InfoPort
			 */			
			function f_sendRequestPrimitive() runs on Tester {
606
		
607
				infoPort.send(vc_request.primitive.requestPrimitive);
608
		
609
			} 
610
			
611 612 613 614 615 616 617 618
			/**
			 * @desc Sending of last primitiveContent retrieved (vc_primitiveContentRetrievedResource) through InfoPort
			 */	
			function f_sendPrimitiveContentRetrievedResource() runs on AeSimu {
		
				infoPort.send(vc_primitiveContentRetrievedResource);
					
			} 	
619
			
620 621 622 623
			/**
			 * @desc Sending of remoteCSE resource through InfoPort
			 */	
			function f_sendRemoteCseResource() runs on CseSimu {
624
		
625 626 627 628 629 630 631 632
				infoPort.send(vc_resourcesList[vc_remoteCseIndex]);
					
			} 
			
			/**
			 * @desc Sending of Ae resource through InfoPort
			 */	
			function f_sendAeResource() runs on AeSimu {
633
		
634 635 636
				infoPort.send(vc_resourcesList[vc_aeAuxIndex]);
					
			} 		
637
			
638 639 640 641
			/**
			 * @desc Sending of a specific resource through InfoPort
			 * @param p_resourceIndex Index of resource to be sent
			 */	
642
			function f_sendResourceAeSimu(in integer p_resourceIndex) runs on AeSimu {
643 644 645 646 647 648 649 650
		
				if(p_resourceIndex == -1) {
					infoPort.send(vc_resourcesList[vc_aeAuxIndex]);  //TODO To send Ae or RemoteCSE depending on the component type
				} else {
					infoPort.send(vc_resourcesList[p_resourceIndex]);
				}
					
			} 	
651
			
652 653 654 655 656 657 658 659 660 661 662 663 664 665
			/**
			 * @desc Sending of a specific resource through InfoPort
			 * @param p_resourceIndex Index of resource to be sent
			 */	
			function f_sendResourceCseSimu(in integer p_resourceIndex) runs on CseSimu {
		
				if(p_resourceIndex == -1) {
					infoPort.send(vc_resourcesList[vc_remoteCseIndex]);  //TODO To send Ae or RemoteCSE depending on the component type
				} else {
					infoPort.send(vc_resourcesList[p_resourceIndex]);
				}
					
			}
			
666 667 668 669
			/**
			 * @desc Sending of the latest resource through InfoPort
			 */	
			function f_sendLatestResource() runs on Tester {
670

671
				infoPort.send(vc_resourcesList[lengthof(vc_resourcesList)-1]);
672
				
673 674 675 676 677 678
			} 	
			
			/**
			 * @desc Sending of last resourceIndex saved in the vc_resourcesList
			 */	
			function f_sendLatestResourceIndex() runs on Tester {
679

680
				infoPort.send(lengthof(vc_resourcesList)-1);
681
		
682
			} 
683 684 685 686 687 688 689 690 691 692 693

			
			/**
			 * @desc Sending of the latest local resource through InfoPort
			 */	
			function f_sendLatestLocalResource() runs on CseSimu {

				infoPort.send(vc_localResourcesList[lengthof(vc_localResourcesList)-1]);
				
			} 	
					
694 695 696 697
			/**
			 * @desc Sending the address of the last resource saved in the vc_resourcesList
			 */	
			function f_sendLatestLocalResourceAddress(AddressingMethod p_addressingMethod := PX_ADDRESSING_METHOD, PrimitiveScope p_primitiveScope := PX_PRIMITIVE_SCOPE) runs on CseSimu {
698

699
				infoPort.send(f_getLocalResourceAddress(lengthof(vc_localResourcesList)-1, p_addressingMethod, p_primitiveScope));
700
		
701
			} 
702
		
703 704 705 706
			/**
			 * @desc Sending of last local resourceIndex saved in the vc_localResourcesList
			 */	
			function f_sendLatestLocalResourceIndex() runs on CseSimu {
707

708
				infoPort.send(lengthof(vc_localResourcesList)-1);
709
		
710 711
			} 
			
712
		}//end of group sendFunctions
713
			
714
	}// end of group InfoPortCommunication	
715
	
716
	group CseFunctions {
717
	
718
		group PreambleFunctions {
719

720 721 722 723 724 725
			/**
			 * @desc Creation of auxiliar resources ACP for correct execution of the test case
			 * @param p_allowedOperations Allowed operations for the auxiliar AE resource
			 * @return Internal ACP resource index
			 * @verdict 
			 */
726
			function f_cse_preamble_createAcpAux(in template (value) XSD.String p_acpName := c_acpAuxName, in template (value) AccessControlOperations p_allowedOperations := int63) runs on AeSimu return integer {//c_CRUDNDi
727
			
728
				return f_cse_createAccessControlPolicyAux(p_acpName, -, p_allowedOperations);
729 730
			
			}
731

732 733
	
			/**
734 735 736
			 * @desc Creation of auxiliar resource AE for correct execution of the test case
			 * @param p_accessControlPolicyIDs AccessControlPolicyIDs for the auxiliar AE resource
			 * @param p_poaList Point of contact of the auxiliar AE resource
737 738 739
			 * @return Internal AE resource index
			 * @verdict 
			 */
740
			function f_cse_preamble_registerAe(template (omit) AcpType p_accessControlPolicyIDs := omit, in template (omit) PoaList p_poaList := omit) runs on AeSimu return integer {//c_CRUDNDi
741 742 743
			
				var RequestPrimitive v_request;
				var MsgIn v_response;
744 745 746 747

				//Activate defaults when running on a PTC
				f_cse_activateDefaults_ae();		
												
748
				v_request := valueof(m_createAeAux(p_accessControlPolicyIDs, p_poaList));
749 750
				
				v_request := f_getCreateRequestPrimitive(int2, v_request, -1);
751
				
752
				mcaPort.send(f_getMsgOutPrimitive(m_request(v_request)));
753 754 755 756 757
				
				tc_ac.start;
				alt {
					[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) -> value v_response {
						tc_ac.stop;
758
						setverdict(pass,__SCOPE__&":INFO: Application registered successfuly");
759
						if(ischosen(v_response.primitive.responsePrimitive.primitiveContent.aE)) {
760
							
761 762
							f_checkAttributesToBeSaved(int2, v_request, v_response.primitive.responsePrimitive);
							
763
							vc_aeAuxIndex := f_setResource(v_response.primitive.responsePrimitive.primitiveContent, int2);
764
							
765 766
							if(ispresent(v_response.primitive.responsePrimitive.primitiveContent.aE.aE_ID)){
								f_sendAcPrimitive("AE-ID_changed", oct2char(unichar2oct(v_response.primitive.responsePrimitive.primitiveContent.aE.aE_ID)));
767 768 769 770 771 772 773
							} else {
								f_sendAcPrimitive("AE-ID_changed", "0");
							}
						}
					}
					[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) {
						tc_ac.stop;
774
						setverdict(inconc, __SCOPE__&":INFO: Error while registering application");
775 776 777 778
						stop;
					}
					[] mcaPort.receive {
						tc_ac.stop;
779
						setverdict(inconc, __SCOPE__&":INFO: Unexpected message received");
780 781 782
						stop;
					};
					[] tc_ac.timeout {
783
						setverdict(inconc, __SCOPE__&":INFO: No answer while registering resource");
784 785 786 787
						stop;
					}
				}	
				
788
				f_checkAeSimuStatus();
789
				return vc_aeAuxIndex;
790 791 792 793 794
			}
			
			/**
			 * @desc Creation of auxiliar resources ACP and AE for correct execution of the test case
			 * @param p_allowedOperations Allowed operations for the auxiliar AE resource
795
			 * @param p_appId AppID of the AE resource to be created
796 797 798
			 * @return Internal AE resource index
			 * @verdict 
			 */
799
			function f_cse_preamble_registerAeWithId(XSD.ID p_appId, in template (value) AccessControlOperations p_allowedOperations := int63) runs on AeSimu return integer {//c_CRUDNDi
800 801
			
				var RequestPrimitive v_request;
802
				
803 804 805
				//Activate defaults when running on a PTC
				f_cse_activateDefaults_ae();		
				
806
				if(PICS_ACP_SUPPORT){
807
					vc_acpAuxIndex := f_cse_createAccessControlPolicyAux(p_allowedOperations := p_allowedOperations);
808 809
				}
				
810
				if(vc_acpAuxIndex != -1) {
811
					vc_resourcesIndexToBeDeleted := {vc_acpAuxIndex};//TODO Not needed
812
					v_request := valueof(m_createAe(p_appId, {f_getResourceId(vc_resourcesList[vc_acpAuxIndex].resource)}, -));
813 814 815 816
					
					//TODO Test, to be removed
					v_request.to_ := f_getResourceAddress();
					
817 818
					mcaPort.send(f_getMsgOutPrimitive(m_request(v_request)));
					//mcaPort.send(f_getMsgOutPrimitive(m_request(m_createAeAux(p_name, {PX_URI_CSE & PX_CSE_NAME & "/" & PX_ACPAUX_NAME}))));
819
				} else {
820
					mcaPort.send(f_getMsgOutPrimitive(m_request(m_createAe(p_appId))));
821 822 823
				}
				tc_ac.start;
				alt {
824
					[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) -> value vc_response {
825
						tc_ac.stop;
826
						setverdict(pass, __SCOPE__&": INFO: Application registered successfuly");
827
						if(ischosen(vc_response.primitive.responsePrimitive.primitiveContent.aE)) {
828
							
829
							vc_aeAuxIndex := f_setResource(vc_response.primitive.responsePrimitive.primitiveContent, int2);
830
							
831 832
							if(ispresent(vc_response.primitive.responsePrimitive.primitiveContent.aE.aE_ID)){
								f_sendAcPrimitive("AE-ID_changed", oct2char(unichar2oct(vc_response.primitive.responsePrimitive.primitiveContent.aE.aE_ID)));
833 834 835 836 837 838 839 840
							} else {
								f_sendAcPrimitive("AE-ID_changed", "0");
							}	
						}
					}
					[] mcaPort.receive(mw_response(mw_responsePrimitiveKO))
					{
						tc_ac.stop;
841
						setverdict(inconc, __SCOPE__&":INFO: Error while registering application");
842 843 844 845
						stop;
					}
					[] mcaPort.receive {
						tc_ac.stop;
846
						setverdict(inconc, __SCOPE__&":INFO: Unexpected message received");
847 848 849
						stop;
					}
					[] tc_ac.timeout {
850
						setverdict(inconc, __SCOPE__&":INFO: No answer while registering resource");
851 852 853 854
						stop;
					}
				}	
				
855
				f_checkAeSimuStatus();
856
				return vc_aeAuxIndex;
857 858 859
			
			}
			
860 861 862 863 864 865
			/**
			 * @desc Creation of ServiceSubscribedAppRule resource
			 * @param p_allowedAEs Allowed AEs
			 * @return Internal resource index
			 * @verdict 
			 */
866
			function f_cse_preamble_createServiceSubscribedAppRule(in template ListOfM2MID p_allowedAEs := {""}) runs on AeSimu return integer {//c_CRUDNDi
867 868 869 870 871 872 873 874 875
			
				var integer v_serviceSubscribedAppRuleIndex := -1;
	
				v_serviceSubscribedAppRuleIndex := f_cse_createResource(int19, m_createServiceSubscribedAppRule({"None"}, {PX_APP_ID}, valueof(p_allowedAEs)));
				
				return v_serviceSubscribedAppRuleIndex;
			
			}
			
876 877 878 879 880 881
			/**
			 * @desc Creation of SubscribedProfile resource
			 * @param p_allowedAEs Allowed AEs
			 * @return I