OneM2M_Functions.ttcn 130 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556
/**
 *  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.
 *  
 *  @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 $
 *  @desc       Module containing functions for oneM2M
 *
 */
module OneM2M_Functions {
	
	import from XSD all;
	import from LibCommon_Time all;
	import from OneM2M_Templates all;
	import from OneM2M_Types all;
	import from OneM2M_TypesAndValues all;
	import from OneM2M_TestSystem all;
	import from OneM2M_Pixits all;
	import from OneM2M_Pics all;
	
	group ConfigFunctions {
		
		/**
			@desc Ports mapping and default behaviour activation for Config 1
		*/
		function f_cf01Up(in boolean p_auxiliaryAe2Required := false) runs on AeSimu {
			
			// Variables
			vc_config := e_cf01;
			vc_testSystemRole := e_ae;	
			
			// Map
			map(self:mcaPort, system:mcaPort);
			map(self:acPort, system:acPort);
			
			activate(a_default());
			activate(a_cse_cf01());
				
			// Initialize AE2
			if(p_auxiliaryAe2Required) {
				vc_auxiliaryAe2Up := p_auxiliaryAe2Required;
				vc_ae2 := AeSimu.create("AE2") alive;
				vc_ae2.start(f_cf01UpAe2());
				vc_ae2.done;
			}
				
			//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
			vc_config := e_cf01;
			vc_testSystemRole := e_ae;		
			
			// Map
			map(self:mcaPort, system:mcaPort);
			map(self:mcaPortIn, system:mcaPortIn);
			map(self:acPort, system:acPort);
			
			activate(a_default());
			activate(a_cse_cf01());
			activate(a_cse_cf01_ae2()); //For mcaPortIn
	
			//Initialze the IUT
							
		} // end f_cf01Up
		
		/**
		 * @desc Ports mapping and default behaviour activation for Config 02
		 */
		function f_cf02Up() runs on AeSimu {
				
			// Variables
			vc_config := e_cf02;
			vc_testSystemRole := e_ae;	
			vc_cse1 := CseSimu.create("CSE1") alive;
				
			// Map
			map(self:mcaPort, system:mcaPort);
			map(self:acPort, system:acPort);
			activate(a_default());
			activate(a_cse_cf02_ae1());
			vc_cse1.start(f_cf02UpCse1());
			vc_cse1.done;
				
			// Connect
			
			//Initialze the IUT
							
		} // end f_cf02Up
		
		/**
			@desc Ports mapping and default behaviour activation for Config 2 on the CSE1
		*/
		function f_cf02UpCse1() runs on CseSimu {
			
			// Variables
			var PrimitiveContent v_cSEBaseResource;
			vc_config := e_cf02;
			vc_testSystemRole := e_cse;		
			
			// Map
			map(self:mccPort, system:mccPort);
			map(self:mccPortIn, system:mccPortIn);
			map(self:acPort, system:acPort);
			
			activate(a_default());
			activate(a_cse_cf02_cse1());
			
			v_cSEBaseResource := f_cse_generateLocalResource(-, -1, int5);
			vc_cSEBaseIndex := f_setLocalResource(v_cSEBaseResource, int5, -1);
			
			//Initialze the IUT
							
		} // end f_cf02UpCse1

		/**
		 * @desc Ports mapping and default behaviour activation for Config 02
		 */
		function f_cf02UpCseSimuMaster() runs on CseSimu {
				
			// Variables
			var PrimitiveContent v_cSEBaseResource;
			vc_config := e_cf02CseSimuMaster;
			vc_testSystemRole := e_cse;		
			vc_ae1 := AeSimu.create("AE1") alive;
				
			// Map
			map(self:mccPort, system:mccPort);
			map(self:mccPortIn, system:mccPortIn);
			map(self:acPort, system:acPort);
			activate(a_default());
			activate(a_cse_cf02_cse1());
			vc_ae1.start(f_cf02UpAe1());
			vc_ae1.done;
			
			v_cSEBaseResource := f_cse_generateLocalResource(-, -1, int5);
			vc_cSEBaseIndex := f_setLocalResource(v_cSEBaseResource, int5, -1);
				
			// Connect
			
			//Initialze the IUT
							
		} // end f_cf02UpCseSimuMaster
		
		/**
			@desc Ports mapping and default behaviour activation for Config 2 on the AE1
		*/
		function f_cf02UpAe1() runs on AeSimu {
			
			// Variables
			vc_config := e_cf02CseSimuMaster;	
			vc_testSystemRole := e_ae;		
			
			// Map
			map(self:mcaPort, system:mcaPort);
			map(self:mcaPortIn, system:mcaPortIn);
			map(self:acPort, system:acPort);
			
			activate(a_default());
			activate(a_cse_cf02_ae1());
			
			//Initialze the IUT
							
		} // end f_cf02UpAe1
		
		/**
		 * @desc Ports mapping and default behaviour activation for Config 03
		 */
		function f_cf03Up() runs on CseSimu {
		
			// Variables
			var PrimitiveContent v_cSEBaseResource;
			vc_config := e_cf03;
			vc_testSystemRole := e_cse;		
			
			// Map
			map(self:mcaPortIn, system:mcaPortIn);//TODO To be consistent, we should use mcaPortIn for AE testing
			map(self:acPort, system:acPort);
			if(PX_UT_IMPLEMENTED) {
				map(self:utPort, system:utPort);
			}
			activate(a_default());
			activate(a_ae_cf03());
			
			//Creation of CSEBase
			
			v_cSEBaseResource := f_cse_generateLocalResource(-, -1, int5);
			vc_cSEBaseIndex := f_setLocalResource(v_cSEBaseResource, int5, -1);
		
			// Connect
					
			//Initialze the IUT
					
		} // end f_cf03Up
		
		/**
		 * @desc Ports mapping and default behaviour activation for Config 04
		 */
		function f_cf04Up() runs on CseSimu {

			// Variables
			var PrimitiveContent v_cSEBaseResource;
			vc_config := e_cf04;
			vc_testSystemRole := e_cse;	
			
	
			// Map
			map(self:mccPort, system:mccPort);
			map(self:mccPortIn, system:mccPortIn);
			map(self:acPort, system:acPort);
			activate(a_default());
			activate(a_cse_cf04());
			
			//Creation of CSEBase
			
			v_cSEBaseResource := f_cse_generateLocalResource(-, -1, int5);
			vc_cSEBaseIndex := f_setLocalResource(v_cSEBaseResource, int5, -1);

			// Connect
			
			//Initialize the IUT
			
		} // end f_cf03Up

		/**
		 * @desc Ports unmapping
		 */
		function f_cf01Down() runs on AeSimu {
		
			unmap(self:mcaPort, system:mcaPort);
			unmap(self:acPort, system:acPort);
			if(vc_auxiliaryAe2Up) {
				vc_ae2.start(f_cf01DownAe2());
				vc_ae2.done;
			}
		}
		
		/**
		 * @desc Ports unmapping
		 */
		function f_cf01DownAe2() runs on AeSimu {
				
			unmap(self:mcaPort, system:mcaPort);
			unmap(self:acPort, system:acPort);
			unmap(self:mcaPortIn, system:mcaPortIn);
		}
		
		/**
		 * @desc Ports unmapping
		 */
		function f_cf02Down() runs on AeSimu {
		
			unmap(self:mcaPort, system:mcaPort);
			unmap(self:acPort, system:acPort);
			unmap(vc_cse1:mccPort, system:mccPort);
			unmap(vc_cse1:mccPortIn, system:mccPortIn);
			unmap(vc_cse1:acPort, system:acPort);
		}		
		/**
		 * @desc Ports unmapping
		 */
		function f_cf02DownCseSimuMaster() runs on CseSimu {
				
			unmap(self:mccPort, system:mccPort);
			unmap(self:mccPortIn, system:mccPortIn);
			unmap(self:acPort, system:acPort);
			unmap(vc_ae1:mcaPort, system:mcaPort);
			unmap(vc_ae1:acPort, system:acPort);
		}		
		/**
		 * @desc Ports unmapping for Config 03
		 */
		function f_cf03Down() runs on CseSimu {
			
			unmap(self:mcaPortIn, system:mcaPortIn);
			if(PX_UT_IMPLEMENTED){
				unmap(self:utPort, system:utPort);
			}
			unmap(self:acPort, system:acPort);
		}
		
		/**
		 * @desc Ports unmapping for Config 04
		 */
		function f_cf04Down() runs on CseSimu {
	
			unmap(self:mccPort, system:mccPort);
			unmap(self:mccPortIn, system:mccPortIn);
			unmap(self:acPort, system:acPort);
		}

	}//end group configFunctions
	
	group InfoPortCommunication {
	
		/**
		 * @desc Connection of InfoPort of two components
		 * @param p_tester PTC where InfoPort is to be connected
		 */
		function f_connectInfoPort(in Tester p_tester) runs on Tester {
			// Connect
			connect(self:infoPort, p_tester:infoPort);		
		} 
	
		/**
		 * @desc Disconnection of InfoPort of two components
		 * @param p_tester PTC where InfoPort is to be connected
		 */
		function f_disconnectInfoPort(in Tester p_tester) runs on Tester {
			// Disconnect
			disconnect(self:infoPort, p_tester:infoPort);		
		} 
	
		/**
		 * @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;
			
			f_connectInfoPort(p_component);
	
			p_component.start(f_sendResponsePrimitive());
			alt {
				[]infoPort.receive(mw_responsePrimitiveforInfoPort) -> value v_response {
				}
			}
	
			f_disconnectInfoPort(p_component);
				
			return v_response;
				
		}
		
		/**
		 * @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);

			p_component.start(f_sendRequestPrimitive());
			alt {
				[]infoPort.receive(mw_requestPrimitiveforInfoPort) -> value v_request {
				}
			}

			f_disconnectInfoPort(p_component);
	
			return v_request;
	
		}
							
		/**
		 * @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;
			
			f_connectInfoPort(p_ae);
	
			p_ae.start(f_sendPrimitiveContentRetrievedResource());
			alt {
				[]infoPort.receive(mw_primitiveContent) -> value v_primitiveContent {
				}
			}
	
			f_disconnectInfoPort(p_ae);
				
			return v_primitiveContent;
				
		}
		
		/**
		 * @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;
			
			f_connectInfoPort(p_cse);
	
			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);
				}
			}
	
			f_disconnectInfoPort(p_cse);
				
			return v_resourceIndex;
				
		}
		
		/**
		 * @desc Getting a specific resource from an AeSimu component
		 * @param p_tester AeSimu component
		 * @param p_resourceIndex Index of resource to be retrieved
		 */
		function f_getResource(in Tester 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_sendResource(p_resourceIndex));
			alt {
				[]infoPort.receive(mw_resource) -> value v_resource {
					v_resourceIndex := f_setResource(v_resource.resource, v_resource.resourceType, v_resource.parentIndex, false);
				}
			}

			f_disconnectInfoPort(p_component);
			
			return v_resourceIndex;
			
		}		

		/**
		 * @desc Sending of last responsePrimitive (vc_response) through InfoPort
		 */	
		function f_sendResponsePrimitive() runs on Tester {
	
			infoPort.send(vc_response.primitive.responsePrimitive);
				
		} 

		/**
		 * @desc Sending of last requestPrimitive (vc_request) through InfoPort
		 */			
		function f_sendRequestPrimitive() runs on Tester {
	
			infoPort.send(vc_request.primitive.requestPrimitive);
	
		} 
		
		/**
		 * @desc Sending of last primitiveContent retrieved (vc_primitiveContentRetrievedResource) through InfoPort
		 */	
		function f_sendPrimitiveContentRetrievedResource() runs on AeSimu {
	
			infoPort.send(vc_primitiveContentRetrievedResource);
				
		} 	
		
		/**
		 * @desc Sending of remoteCSE resource through InfoPort
		 */	
		function f_sendRemoteCseResource() runs on CseSimu {
	
			infoPort.send(vc_resourcesList[vc_remoteCseIndex]);
				
		} 
		
		/**
		 * @desc Sending of Ae resource through InfoPort
		 */	
		function f_sendAeResource() runs on AeSimu {
	
			infoPort.send(vc_resourcesList[vc_aeAuxIndex]);
				
		} 		
		
		/**
		 * @desc Sending of a specific resource through InfoPort
		 * @param p_resourceIndex Index of resource to be sent
		 */	
		function f_sendResource(in integer p_resourceIndex) runs on Tester {
	
			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]);
			}
				
		} 	
	
	}// end of gropu InfoPortCommunication	
	
	group CseFunctions {
	
		group PreambleFunctions {

			/**
			 * @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 
			 */
			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
			
				return f_cse_createAccessControlPolicyAux(p_acpName, -, p_allowedOperations);
			
			}

	
			/**
			 * @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
			 * @return Internal AE resource index
			 * @verdict 
			 */
			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
			
				var RequestPrimitive v_request;
				var MsgIn v_response;
								
				v_request := valueof(m_createAeAux(p_accessControlPolicyIDs, p_poaList));
				
				v_request := f_getCreateRequestPrimitive(int2, v_request, -1);
				
				mcaPort.send(m_request(v_request));
				
				tc_ac.start;
				alt {
					[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) -> value v_response {
						tc_ac.stop;
						setverdict(pass,__SCOPE__&":INFO: Application registered successfuly");
						if(ischosen(v_response.primitive.responsePrimitive.primitiveContent.aE)) {
							
							f_checkAttributesToBeSaved(int2, v_request, v_response.primitive.responsePrimitive);
							
							vc_aeAuxIndex := f_setResource(v_response.primitive.responsePrimitive.primitiveContent, int2);
							
							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)));
							} else {
								f_sendAcPrimitive("AE-ID_changed", "0");
							}
						}
					}
					[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) {
						tc_ac.stop;
						setverdict(inconc, __SCOPE__&":INFO: Error while registering application");
						stop;
					}
					[] mcaPort.receive {
						tc_ac.stop;
						setverdict(inconc, __SCOPE__&":INFO: Unexpected message received");
						stop;
					};
					[] tc_ac.timeout {
						setverdict(inconc, __SCOPE__&":INFO: No answer while registering resource");
						stop;
					}
				}	
				
				f_checkAeSimuStatus();
				return vc_aeAuxIndex;
			}
			
			/**
			 * @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
			 * @param p_appId AppID of the AE resource to be created
			 * @return Internal AE resource index
			 * @verdict 
			 */
			function f_cse_preamble_registerAeWithId(XSD.ID p_appId, in template (value) AccessControlOperations p_allowedOperations := int63) runs on AeSimu return integer {//c_CRUDNDi
			
				var RequestPrimitive v_request;
				
				if(PICS_ACP_SUPPORT){
					vc_acpAuxIndex := f_cse_createAccessControlPolicyAux(p_allowedOperations := p_allowedOperations);
				}
				
				if(vc_acpAuxIndex != -1) {
					vc_resourcesIndexToBeDeleted := {vc_acpAuxIndex};
					v_request := valueof(m_createAe(p_appId, {f_getResourceId(vc_resourcesList[vc_acpAuxIndex].resource)}, -));
					
					//TODO Test, to be removed
					v_request.to_ := f_getResourceAddress();
					
					mcaPort.send(m_request(v_request));
					//mcaPort.send(m_request(m_createAeAux(p_name, {PX_URI_CSE & PX_CSE_NAME & "/" & PX_ACPAUX_NAME})));
				} else {
					mcaPort.send(m_request(m_createAe(p_appId)));
				}
				tc_ac.start;
				alt {
					[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) -> value vc_response {
						tc_ac.stop;
						setverdict(pass, __SCOPE__&": INFO: Application registered successfuly");
						if(ischosen(vc_response.primitive.responsePrimitive.primitiveContent.aE)) {
							
							vc_aeAuxIndex := f_setResource(vc_response.primitive.responsePrimitive.primitiveContent, int2);
							
							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)));
							} else {
								f_sendAcPrimitive("AE-ID_changed", "0");
							}	
						}
					}
					[] mcaPort.receive(mw_response(mw_responsePrimitiveKO))
					{
						tc_ac.stop;
						setverdict(inconc, __SCOPE__&":INFO: Error while registering application");
						stop;
					}
					[] mcaPort.receive {
						tc_ac.stop;
						setverdict(inconc, __SCOPE__&":INFO: Unexpected message received");
						stop;
					}
					[] tc_ac.timeout {
						setverdict(inconc, __SCOPE__&":INFO: No answer while registering resource");
						stop;
					}
				}	
				
				f_checkAeSimuStatus();
				return vc_aeAuxIndex;
			
			}
			
			/**
			 * @desc Creation of ServiceSubscribedAppRule resource
			 * @param p_allowedAEs Allowed AEs
			 * @return Internal resource index
			 * @verdict 
			 */
			function f_cse_preamble_createServiceSubscribedAppRule(in template ListOfM2MID p_allowedAEs := {""}) runs on AeSimu return integer {//c_CRUDNDi
			
				var integer v_serviceSubscribedAppRuleIndex := -1;
	
				v_serviceSubscribedAppRuleIndex := f_cse_createResource(int19, m_createServiceSubscribedAppRule({"None"}, {PX_APP_ID}, valueof(p_allowedAEs)));
				
				return v_serviceSubscribedAppRuleIndex;
			
			}
			
			/**
			 * @desc Creation of SubscribedProfile resource
			 * @param p_allowedAEs Allowed AEs
			 * @return Internal resource index
			 * @verdict 
			 */
			function f_cse_preamble_createServiceSubscribedProfile(in template ListOfM2MID p_allowedAEs := {""}) runs on AeSimu return integer {//c_CRUDNDi
			
				var integer v_serviceSubscribedAppRuleIndex := -1;
				var integer v_serviceSubscribedProfileIndex := -1;
				var template RequestPrimitive m_request := m_createM2mServiceSubscriptionProfileBase;
				
				//TODO Create/Update serviceSubscribedNode //m_request.primitiveContent.m2mServiceSubscriptionProfile.choice.choice_list[0].serviceSubscribedNode := m_contentServiceSubscribedNode;
				v_serviceSubscribedAppRuleIndex := f_cse_createResource(int19, m_createServiceSubscribedAppRule({"None"}, {PX_APP_ID}, valueof(p_allowedAEs)));
				m_request.primitiveContent.m2mServiceSubscriptionProfile.choice.choice_list[0].serviceSubscribedNode.ruleLinks := {f_getResourceAddress(v_serviceSubscribedAppRuleIndex)};
				v_serviceSubscribedProfileIndex := f_cse_createResource(int11, m_request);
			
				return v_serviceSubscribedProfileIndex;
	
			}
			
			/**
			 * @desc Registration of AE2 for handling of notifications and handling of subscription verification started if subscription resource is to be created
			 * @param p_ae2Index Internal AE2 resource index
			 * @param p_createRequestPrimitive CREATE Request for the resource to be created
			 * @param p_resourceType ResourceType of the resource to be created
			 * @param p_responseStatusCode Response Status Code to be sent in response to the subscription verification request
			 * @verdict 
			 */
			function f_cse_preamble_subscriptionVerification(inout integer p_ae2Index, inout template RequestPrimitive p_createRequestPrimitive,in ResourceType p_resourceType, in ResponseStatusCode p_responseStatusCode := int2000) runs on AeSimu {
				if(p_resourceType == int23){
					
					vc_ae2.start(f_cse_createResource(int2, m_createAe(PX_APP_ID, -, PX_AE2_ID_STEM, c_defaultAE2Name, {f_getAnnouncementTargetPoA("HTTP", PX_AE2_ADDRESS, "")}), -1)); // AE2 is registred
					
					f_checkComponentDoneAndGetVerdict(vc_ae2);
					
					p_ae2Index := f_getResource(vc_ae2);
					if(ischosen(p_createRequestPrimitive.primitiveContent.subscription)){		//this condition is necessary for Subscription TCs where notification URI is set in m_createSubscriptionAdvanced
						p_createRequestPrimitive.primitiveContent.subscription.notificationURI := {f_getResourceAddress(p_ae2Index)};
					}
					vc_ae2.start(f_cse_notifyProcedure_subscriptionVerificationHandler(p_responseStatusCode));
				}
			}
		
		}//end group preambleFunctions
		
		group PostambleFunctions {
	
			/**
			 * @desc Deletion of all resources created during the test case execution. It deals also with AE2 created resources if any. IUT gets clean and ready for next execution
			 * @verdict 
			 */
			function f_cse_postamble_deleteResources() runs on AeSimu {
				var integer i;
				var XSD.ID v_resourceAddress;
				var RequestPrimitive v_request;
				
				if (PX_RUN_POSTAMBLE) {
					
					if(vc_auxiliaryAe2Up) {
						f_cse_postamble_aeSimu(vc_ae2);
					}
					
					for(i := lengthof(vc_resourcesIndexToBeDeleted) -1; i >=0; i := i - 1) {
						
						v_resourceAddress := f_getResourceAddress(vc_resourcesIndexToBeDeleted[i]); 
						
						v_request := valueof(m_delete(v_resourceAddress, f_getOriginator(vc_resourcesIndexToBeDeleted[i])));
						
						v_request.from_ := f_getOriginator(vc_resourcesIndexToBeDeleted[i]);

						mcaPort.send(m_request(v_request));
						
						tc_ac.start;
						alt {
							[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) {
								tc_ac.stop;
								log(__SCOPE__&" INFO: Resource " & v_request.to_ & " deleted");
							}
							[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) {
								tc_ac.stop;
								log(__SCOPE__&" INFO: Error while deleting resource " & v_request.to_);
							}
							[] tc_ac.timeout {
								log(__SCOPE__&" INFO: No answer while deleting resource " & v_request.to_);
							}	
						}	
						
					}
				}
						
			}
			
			/**
			 * @desc Calls to postamble for AeSimu components (i.e. AE2)
			 * @verdict 
			 */
			function f_cse_postamble_aeSimu(in AeSimu p_ae) runs on AeSimu {
				if(p_ae.running) {
					p_ae.stop;
				}
				p_ae.start(f_cse_postamble_deleteResources());
				p_ae.done;
			}
			
			/**
			 * @desc Calls to postamble for AeSimu component (i.e. AE1) on CseSimu 
			 * @verdict 
			 */
			function f_cse_postamble_ae1() runs on CseSimu {
				if(vc_ae1.running) {
					vc_ae1.stop;
				}
				vc_ae1.start(f_cse_postamble_deleteResources());
				vc_ae1.done;
			}
			
			/**
			 * @desc Deletion of all resources created during the test case execution. IUT gets clean and ready for next execution
			 * @verdict 
			 */
			function f_cse_postamble_deleteResourcesCSE() runs on CseSimu {
				var integer i;
				var XSD.ID v_resourceAddress;
				var RequestPrimitive v_request;
	
				if (PX_RUN_POSTAMBLE) {
					
					if(vc_config == e_cf02CseSimuMaster) {
						f_cse_postamble_ae1();
					};
		
					for(i := lengthof(vc_resourcesIndexToBeDeleted) -1; i >=0; i := i - 1) {
			
						v_resourceAddress := f_getResourceAddress(vc_resourcesIndexToBeDeleted[i]); 
			
						v_request := valueof(m_delete(v_resourceAddress, f_getOriginator(vc_resourcesIndexToBeDeleted[i],false)));

						mccPort.send(m_request(v_request));
			
						tc_ac.start;
						alt {
							[] mccPort.receive(mw_response(mw_responsePrimitiveOK)) {
								tc_ac.stop;
								log(__SCOPE__&" INFO: Resource " & v_request.to_ & " deleted");
							}
							[] mccPort.receive(mw_response(mw_responsePrimitiveKO)) {
								tc_ac.stop;
								log(__SCOPE__&" INFO: Error while deleting resource " & v_request.to_);
							}
							[] tc_ac.timeout {
								log(__SCOPE__&" INFO: No answer while deleting resource " & v_request.to_);
							}	
						}	
			
					}
				}
			
			}			
			
		}//end group postambleFunctions
		
		group AeSimuFunctions {
			
			/**
			 * @desc Creation of a resource
			 * @param p_resourceType Resource type of the resource to be created
			 * @param p_requestPrimitive CREATE request primitive for the resource to be created
			 * @param p_parentIndex Internal resource index which indicates the parent of the resource to be created
			 * @return Internal resource index of the created resource
			 * @verdict 
			 */
			function f_cse_createResource(in ResourceType p_resourceType, template RequestPrimitive p_requestPrimitive := m_create, integer p_parentIndex := -1) runs on AeSimu return integer {
			
				var RequestPrimitive v_request;
				var integer v_resourceIndex := -1;
				
				v_request := f_getCreateRequestPrimitive(p_resourceType, p_requestPrimitive, p_parentIndex);
			
				mcaPort.send(m_request(v_request));
				tc_ac.start;
				alt {
					[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) -> value vc_response {
						tc_ac.stop;
						setverdict(pass, __SCOPE__&":INFO: Resource type " & int2str(enum2int(p_resourceType)) & " created successfuly");
						f_checkAttributesToBeSaved(p_resourceType, v_request, vc_response.primitive.responsePrimitive);
						v_resourceIndex := f_setResource(vc_response.primitive.responsePrimitive.primitiveContent, p_resourceType, p_parentIndex);
						if(p_resourceType == int2) {
							vc_aeAuxIndex := v_resourceIndex;
						}
					}
					[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) {
						tc_ac.stop;
						setverdict(inconc, __SCOPE__&":INFO: Error while creating resource type " & int2str(enum2int(p_resourceType)));
					}
					[] mcaPort.receive {
						tc_ac.stop;
						setverdict(inconc, __SCOPE__&":INFO: Unexpected message received");
					}
					[] tc_ac.timeout {
						setverdict(inconc, __SCOPE__&":INFO: No answer while creating resource type " & int2str(enum2int(p_resourceType)));
					}
				}	
				
				f_checkAeSimuStatus();
				
				return v_resourceIndex;
		
			}
			
			/**
			 * @desc Message exchange for the update of an announced resource
			 * @param p_requestPrimitive UPDATE request primitive to be used
			 * @verdict 
			 */
			function f_cse_updateAnnouncedResource(in RequestPrimitive p_requestPrimitive) runs on CseSimu {

				mccPort.send(m_request(p_requestPrimitive));
				tc_ac.start;
				alt {
					[] mccPort.receive(mw_response(mw_responsePrimitiveOK)) -> value vc_response {
						tc_ac.stop;
						setverdict(pass, __SCOPE__&":INFO: Attribute of announced resource updated successfuly");
					}
					[] mccPort.receive(mw_response(mw_responsePrimitiveKO)) -> value vc_response {
						tc_ac.stop;
						setverdict(inconc, __SCOPE__&":INFO: Error while updating announced resource");
					}
					[] mccPort.receive{
						tc_ac.stop;
						setverdict(inconc, __SCOPE__&":INFO: Unexpected message received");
					}
					[] tc_ac.timeout {
						setverdict(inconc, __SCOPE__&":INFO: No answer while updating announced resource");
					}
				}	
				
				f_checkCseSimuStatus();
				
			}// end f_cse_updateAnnouncedResource
		
			/**
			 * @desc Creation of the auxiliar ACP resource
			 * @param p_acpName ACP name
			 * @param p_allowedOperations Allowed operations
			 * @return Internal resource index of the created auxiliar ACP resource
			 * @verdict 
			 */
			function f_cse_createAccessControlPolicyAux(in template (value) XSD.String p_acpName := c_acpAuxName, in template (value) ListOfURIs p_acor := PX_ACOR, in template (value) AccessControlOperations p_allowedOperations := int63) runs on AeSimu return integer{				var RequestPrimitive v_request;
				var integer v_acpAuxIndex := -1;
				
				v_request := valueof(m_createAcpAux(p_acpName := p_acpName, p_allowedOperations := p_allowedOperations));
				
				v_request := f_getCreateRequestPrimitive(int1, v_request, -1);
								
				mcaPort.send(m_request(v_request));
				tc_ac.start;
				alt {
					[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) -> value vc_response {
						tc_ac.stop;
						setverdict(pass, __SCOPE__&":INFO: Resource type " & int2str(1) & " created successfuly");
						f_checkAttributesToBeSaved(int1, v_request, vc_response.primitive.responsePrimitive);
						v_acpAuxIndex := f_setResource(vc_response.primitive.responsePrimitive.primitiveContent, int1);
						vc_acpAuxIndex := v_acpAuxIndex;
					}
					[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) {
						tc_ac.stop;
						setverdict(inconc, __SCOPE__&":INFO: Error while creating resource type " & int2str(1));
					}
					[] mcaPort.receive {
						tc_ac.stop;
						setverdict(inconc, __SCOPE__&":INFO: Unexpected message received");
					}
					[] tc_ac.timeout {
						setverdict(inconc, __SCOPE__&":INFO: No answer while creating resource type " & int2str(1));
					}
				}	
				
				f_checkAeSimuStatus();
			
				return v_acpAuxIndex;
	
			}
							
			/**
			 * @desc Message exchange for the update of a resource
			 * @param p_requestPrimitive UPDATE request primitive to be used
			 * @verdict 
			 */
			function f_cse_updateResource(in RequestPrimitive p_requestPrimitive) runs on AeSimu {

				mcaPort.send(m_request(p_requestPrimitive));
				tc_ac.start;
				alt {
					[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) -> value vc_response {
						tc_ac.stop;
						setverdict(pass, __SCOPE__&":INFO: Attribute of resource updated successfuly");
					}
					[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) -> value vc_response {
						tc_ac.stop;
						setverdict(inconc, __SCOPE__&":INFO: Error while updating resource");
					}
					[] mcaPort.receive{
						tc_ac.stop;
						setverdict(inconc, __SCOPE__&":INFO: Unexpected message received");
					}
					[] tc_ac.timeout {
						setverdict(inconc, __SCOPE__&":INFO: No answer while updating resource");
					}
				}	
				
				f_checkAeSimuStatus();
				
			}// end f_cse_updateResource
			
			/**
			 * @desc Message exchange for the retrieval of a resource
			 * @param p_resourceIndex Resource index of the resource to be retrieved
			 * @return PrimitiveContent parameter of the RETRIEVE response
			 * @verdict 
			 */
			function f_cse_retrieveResource(integer p_resourceIndex) runs on AeSimu return PrimitiveContent{

				mcaPort.send(m_request(m_retrieve(f_getResourceAddress(p_resourceIndex), f_getOriginator(p_resourceIndex))));
				tc_ac.start;
				alt {
					[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) -> value vc_response {
						tc_ac.stop;
						setverdict(pass, __SCOPE__&":INFO: Resource retrieved successfuly");
					}
					[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) -> value vc_response {
						tc_ac.stop;
						setverdict(inconc, __SCOPE__&":INFO: Error while retrieving resource");
					}
					[] mcaPort.receive{
						tc_ac.stop;
						setverdict(inconc, __SCOPE__&":INFO: Unexpected message received");
					}
					[] tc_ac.timeout {
						setverdict(inconc, __SCOPE__&":INFO: No answer while retrieving resource");
					}
				}	
				
				f_checkAeSimuStatus();
				
				return vc_response.primitive.responsePrimitive.primitiveContent;
				
			}// end f_cse_retrieveResource
			
			/**
			 * @desc Message exchange for the deletion of a resource
			 * @param p_index Resource index of the resource to be deleted
			 * @param p_requestPrimitive DELETE request to be used. If not present default DELETE request will be used
			 * @verdict 
			 */
			function f_cse_deleteResource(in integer p_index, in template (omit) RequestPrimitive p_requestPrimitive := omit) runs on AeSimu {
				var RequestPrimitive v_request;
				
				if(not isvalue(p_requestPrimitive)) {
					v_request := valueof(m_delete(f_getResourceAddress(p_index), f_getOriginator(p_index)));
				} else {
					v_request := valueof(p_requestPrimitive);
				}
				
				mcaPort.send(m_request(v_request));
						
				tc_ac.start;
				alt {
					[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) {
						tc_ac.stop;
						setverdict(pass, __SCOPE__&"INFO: Resource " & v_request.to_ & " deleted");
						
						f_removeElementFromList(vc_resourcesIndexToBeDeleted, p_index);
					}
					[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) {
						tc_ac.stop;
						setverdict(inconc, __SCOPE__&"INFO: Error while deleting resource " & v_request.to_);
					}
					[] tc_ac.timeout {
						setverdict(inconc, __SCOPE__&"INFO: No answer while deleting resource " & v_request.to_);
					}	
				}	
				
				f_checkAeSimuStatus();
				
			}// end f_cse_deleteResource
			
			/**
			 * @desc Check that a resource is present in the IUT (resourceId is known) by using RETRIEVE operation
			 * @param p_resourceIndex Resource index of the resource to be checked
			 * @return boolean
			 */
			function f_isResourcePresent (integer p_resourceIndex) runs on AeSimu return boolean {
			
				//Check to see if the resource is present or not
				mcaPort.send(m_request(m_retrieve(f_getResourceAddress(p_resourceIndex), f_getOriginator(p_resourceIndex))));
				tc_ac.start;
				alt {
					[] mcaPort.receive(mw_response(mw_responsePrimitive(int2000))) {
						tc_ac.stop;
						setverdict(pass, testcasename() & ": Resource present: " & f_getResourceAddress(p_resourceIndex));
						return true;
					}
					[] mcaPort.receive(mw_response(mw_responsePrimitive(int4004))) {
						tc_ac.stop;
						setverdict(pass, testcasename() & ": Resource: " & f_getResourceAddress(p_resourceIndex) & " not found");
						return false;
					}
					[] mcaPort.receive(mw_response(mw_responsePrimitive(?, -))) {
						tc_ac.stop;
						setverdict(inconc, testcasename() & ": Wrong response status code in the response");
						return false;
					}
					[] tc_ac.timeout {
						setverdict(inconc, testcasename() & ": No answer while retrieving resource");
						return false;
					}
				}	
				return false;
			}
			
			/**
			 * @desc Check that a resource is present in the IUT (resourceId is known) by using RETRIEVE operation
			 * @param p_resourceIndex Resource index of the resource to be checked
			 * @return boolean
			 */
			function f_isResourcePresentCseSimu (integer p_resourceIndex) runs on CseSimu return boolean {
			
				//Check to see if the resource is present or not
				mccPort.send(m_request(m_retrieve(f_getResourceAddress(p_resourceIndex), f_getOriginator(p_resourceIndex))));
				tc_ac.start;
				alt {
					[] mccPort.receive(mw_response(mw_responsePrimitive(int2000))) {
						tc_ac.stop;
						setverdict(pass, testcasename() & ": Resource present: " & f_getResourceAddress(p_resourceIndex));
						return true;
					}
					[] mccPort.receive(mw_response(mw_responsePrimitive(?, -))) {
						tc_ac.stop;
						setverdict(inconc, testcasename() & ": Wrong response status code in the response");
						return false;
					}
					[] tc_ac.timeout {
						setverdict(inconc, testcasename() & ": No answer while retrieving resource");
						return false;
					}
				}	
				return false;
			}
			
			/**
			 * @desc Check that a resource is not present in the IUT (resourceId is NOT known)
			 * @param p_parentIndex Index of the parent resource of the resource to be checked
			 * @param p_resourceName Resource name (Hierarchical method is used) of the resource to be checked
			 * @return boolean
			 */
			function f_isResourceNotPresent (integer p_parentIndex, XSD.String p_resourceName) runs on AeSimu return boolean {
			
				log(testcasename() & ":INFO: Hierarchical addressing method is required to check the non presence of the resource");
				
				//Check to see if the resource has NOT been created
				mcaPort.send(m_request(m_retrieve(f_getResourceAddress(p_parentIndex, e_hierarchical) & "/" & p_resourceName, f_getOriginator(p_parentIndex))));
				tc_ac.start;
				alt {
					[] mcaPort.receive(mw_response(mw_responsePrimitive(int4004))) {
						tc_ac.stop;
						setverdict(pass, testcasename() & ": Resource not present");
						return true;
					}
					[] mcaPort.receive(mw_response(mw_responsePrimitive(?))) {
						tc_ac.stop;
						setverdict(inconc, testcasename() & ": Wrong response status code in the response");
						return false;
					}
					[] tc_ac.timeout {
						setverdict(inconc, testcasename() & ": No answer while retrieving resource");
						return false;
					}
				}	
				return false;
			}
			
			/**
			 * @desc Message exchange for the update of the auxiliar ACP resource
			 * @param p_allowedOperations New allowed operations
			 * @verdict 
			 */
			function f_cse_updateAcpAuxResource (in template (value) AccessControlOperations p_allowedOperations) runs on AeSimu {
				var RequestPrimitive v_request;
				
				v_request := valueof(m_updateAcpBase);
				
				v_request.to_ := f_getResourceAddress(vc_acpAuxIndex);
				v_request.from_ := f_getOriginator(vc_acpAuxIndex);
				v_request.primitiveContent.accessControlPolicy.privileges.accessControlRule_list := {valueof(m_createAcr(PX_ACOR, p_allowedOperations))};
							
				mcaPort.send(m_request(v_request));
				tc_ac.start;
				alt {
					[] mcaPort.receive(mw_response(mw_responsePrimitiveOK))  {
						tc_ac.stop;
						setverdict(pass, __SCOPE__&":INFO: " & v_request.to_ & " resource updated successfuly");
						//TODO To save new values
					}
					[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) {
						tc_ac.stop;
						setverdict(inconc, __SCOPE__&":INFO: Error while updating " & v_request.to_ & " resource");
					}
					[] tc_ac.timeout {
						setverdict(inconc, __SCOPE__&":INFO: No answer while updating " & v_request.to_ & " resource" );
					}
				}		
				
				f_checkAeSimuStatus();
			}   
			
			/**
			 * @desc Handling of announcement of resources
			 * @param p_from Expected originator of the request primitive
			 * @param p_to Expected receiver of the request primitive
			 * @verdict 
			 */
			 //TODO To finalize this function
			function f_cse_resourceAnnouncementHandler(template XSD.ID p_from := *, template XSD.ID p_to := ?) runs on CseSimu {
				// Local variables
				var MsgIn v_request;
				var ResponsePrimitive v_responsePrimitive;
				
				tc_ac.start;
				alt {
					[] mccPortIn.receive(mw_request(mw_create(p_from, p_to))) -> value v_request {
						tc_ac.stop;
						setverdict(pass, __SCOPE__ & ":INFO: Announcement received");
						//TODO Save resource and generate required attributes
						v_responsePrimitive := f_getCreateResponsePrimitive(v_request.primitive.requestPrimitive.resourceType, v_request.primitive.requestPrimitive);
						mccPortIn.send(m_response(v_responsePrimitive));
						f_checkAttributesToBeSaved(v_request.primitive.requestPrimitive.resourceType, v_request.primitive.requestPrimitive, vc_response.primitive.responsePrimitive);
						f_setResource(vc_response.primitive.responsePrimitive.primitiveContent, v_request.primitive.requestPrimitive.resourceType, vc_remoteCseIndex);					
					}
					[] mccPortIn.receive{
						tc_ac.stop;
						setverdict(fail, __SCOPE__ & ":ERROR: Unexpected message received");
					}
					[] tc_ac.timeout {
						setverdict(fail, __SCOPE__ & ":ERROR:  No announcement received");
					}
				}
				
				f_checkCseSimuStatus();
	
			} //end f_cse_resourceAnnouncementHandler
			
			/**
			 * @desc Message exchange for the announcement of resources
			 * @param p_resourceType ResourceType of the resource to be announced 
			 * @param p_requestPrimitive CREATE request to be used for the announcement
			 * @verdict 
			 */
			 //TODO To finalize this function
			function f_cse_announceResource(in ResourceType p_resourceType, template RequestPrimitive p_requestPrimitive := m_create) runs on CseSimu return integer {
				// Local variables
				var RequestPrimitive v_request;
				var ResponsePrimitive v_responsePrimitive;
				var integer v_resourceIndex := -1;
				
				v_request := f_getCreateRequestPrimitive(f_getAnnouncedResourceType(p_resourceType), p_requestPrimitive, vc_remoteCseIndex);
			
				mccPort.send(m_request(v_request));
				tc_ac.start;
				alt {
					[] mccPort.receive(mw_response(mw_responsePrimitiveOK)) -> value vc_response {
						tc_ac.stop;
						setverdict(pass, __SCOPE__&":INFO: Resource type " & int2str(enum2int(p_resourceType)) & " created successfuly");
						f_checkAttributesToBeSaved(p_resourceType, v_request, vc_response.primitive.responsePrimitive);
						v_resourceIndex := f_setResource(vc_response.primitive.responsePrimitive.primitiveContent, f_getAnnouncedResourceType(p_resourceType), vc_remoteCseIndex);
					}
					[] mccPort.receive(mw_response(mw_responsePrimitiveKO)) {
						tc_ac.stop;
						setverdict(inconc, __SCOPE__&":INFO: Error while creating resource type " & int2str(enum2int(p_resourceType)));
					}
					[] mccPort.receive {
						tc_ac.stop;
						setverdict(inconc, __SCOPE__&":INFO: Unexpected message received");
					}
					[] tc_ac.timeout {
						setverdict(inconc, __SCOPE__&":INFO: No answer while creating resource type " & int2str(enum2int(p_resourceType)));
					}
				}	
				
				f_checkCseSimuStatus();
				
				return v_resourceIndex;
	
			} //end f_cse_announceResource			
    		
			/**
			 * @desc Checking of returned important attributed (in response) in order to save properly internally
			 * @param p_resourceType ResourceType of the resource to be checked
			 * @param p_request Request primitive used for the CRU operation
			 * @param p_response Response primitive received
			 * @verdict 
			 */
			 //Note: This function will be continously extended with necessary attributes/resources
			function f_checkAttributesToBeSaved (ResourceType p_resourceType, RequestPrimitive p_request, inout ResponsePrimitive p_response) {
				select (p_resourceType) {
					case (int1) {
						if(isvalue(p_response.primitiveContent.accessControlPolicy) and
								not(ispresent(p_response.primitiveContent.accessControlPolicy.resourceName))) {
							p_response.primitiveContent.accessControlPolicy.resourceName :=  p_request.primitiveContent.accessControlPolicy.resourceName;
							log(__SCOPE__ & ":INFO: resourceName not returned. Using the one provided in the request: " & p_request.primitiveContent.accessControlPolicy.resourceName)
						}
					}
					case (int2) {
						if(isvalue(p_response.primitiveContent.aE) and
								not(ispresent(p_response.primitiveContent.aE.resourceName))) {
							p_response.primitiveContent.aE.resourceName :=  p_request.primitiveContent.aE.resourceName;
							log(__SCOPE__ & ":INFO: resourceName not returned. Using the one provided in the request: " & p_request.primitiveContent.aE.resourceName)
						}
					}
					case (int3) {
						if(isvalue(p_response.primitiveContent.container) and
								not(ispresent(p_response.primitiveContent.container.resourceName))) {
							p_response.primitiveContent.container.resourceName :=  p_request.primitiveContent.container.resourceName;
							log(__SCOPE__ & ":INFO: resourceName not returned. Using the one provided in the request: " & p_request.primitiveContent.container.resourceName)
						}
					}
					case (int4) {
						if(isvalue(p_response.primitiveContent.contentInstance) and
								not(ispresent(p_response.primitiveContent.contentInstance.resourceName))) {
							p_response.primitiveContent.contentInstance.resourceName :=  p_request.primitiveContent.contentInstance.resourceName;
							log(__SCOPE__ & ":INFO: resourceName not returned. Using the one provided in the request: " & p_request.primitiveContent.contentInstance.resourceName)
						}
					}
					case (int15) {
						if (isvalue(p_response.primitiveContent.pollingChannel) and
								not(ispresent(p_response.primitiveContent.pollingChannel.resourceName))) {
							p_response.primitiveContent.pollingChannel.resourceName :=  p_request.primitiveContent.pollingChannel.resourceName;
							log(__SCOPE__ & ":INFO: resourceName not returned. Using the one provided in the request: " & p_request.primitiveContent.pollingChannel.resourceName)
						}
					}
					case (int16) {
						if (isvalue(p_response.primitiveContent.remoteCSE) and
								not(ispresent(p_response.primitiveContent.remoteCSE.resourceName))) {
							p_response.primitiveContent.remoteCSE.resourceName :=  p_request.primitiveContent.remoteCSE.resourceName;
							log(__SCOPE__ & ":INFO: resourceName not returned. Using the one provided in the request: " & p_request.primitiveContent.remoteCSE.resourceName)
						}
					}
					case (int18) {
						if (isvalue(p_response.primitiveContent.schedule) and
								not(ispresent(p_response.primitiveContent.schedule.resourceName))) {
							p_response.primitiveContent.schedule.resourceName :=  p_request.primitiveContent.schedule.resourceName;
							log(__SCOPE__ & ":INFO: resourceName not returned. Using the one provided in the request: " & p_request.primitiveContent.schedule.resourceName)
						}
					}
					case (int23) {
						if (isvalue(p_response.primitiveContent.subscription) and
								not(ispresent(p_response.primitiveContent.subscription.resourceName))) {
							p_response.primitiveContent.subscription.resourceName :=  p_request.primitiveContent.subscription.resourceName;
							log(__SCOPE__ & ":INFO: resourceName not returned. Using the one provided in the request: " & p_request.primitiveContent.subscription.resourceName)
						}
					}
					case (int9) {
						if (isvalue(p_response.primitiveContent.group_) and
								not(ispresent(p_response.primitiveContent.group_.resourceName))) {
							p_response.primitiveContent.group_.resourceName :=  p_request.primitiveContent.group_.resourceName;
							log(__SCOPE__ & ":INFO: resourceName not returned. Using the one provided in the request: " & p_request.primitiveContent.group_.resourceName)
						}
					}
					case else {
						log(__SCOPE__&":WARNING: Resource Type "&int2str(enum2int(p_resourceType))&" not implemented");
					}
				}
    
				// TODO test that if the resource name is returned is the same resource name as used in the create message
			}
		
			/**
			 * @desc Comparison of two URIs
			 * @param p_expectedURIIndex Resource index of the resource for which its URI is to be compared
			 * @param p_receivedURI URI to be compared
			 * @param p_response Response primitive received
			 * @verdict 
			 */
			function f_compareURIs(in integer p_expectedURIIndex, in XSD.ID p_receivedURI) runs on Tester return boolean{
				// Local variables
				var boolean v_matchResult := false;
				var AddressingMethod v_addressingMethod;
				var PrimitiveScope v_primitiveScope;
    			
				if (f_isNonHierarchical(p_receivedURI)) {
					v_addressingMethod := e_nonHierarchical;
				} else if (f_isHierarchical(p_receivedURI)) {
					v_addressingMethod := e_hierarchical;
				}
				if (f_isScopeCseRelative(p_receivedURI)) {
					v_primitiveScope := e_cseRelative;
				}
				if (f_isScopeSpRelative(p_receivedURI)) {
					v_primitiveScope := e_spRelative;
				}
				if (f_isScopeAbsolute(p_receivedURI)) {
					v_primitiveScope := e_absolute;
				}
    			
				if(match(f_getResourceAddress(p_expectedURIIndex, v_addressingMethod, v_primitiveScope), p_receivedURI)) {
					v_matchResult := true;
				} else {
					v_matchResult := false;
				}
							
				return v_matchResult;
    
			} //end f_compareURIs	
			
		}//end group AeSimu
			
		group CseSimuFunctions {

			group NotificationFunctions { 
				
				/**
				 * @desc Handling message exchange for the subscription verification
				 * @param p_responseStatusCode Response Status Code to be used for the response to the verification request
				 * @verdict 
				 */
				function f_cse_notifyProcedure_subscriptionVerificationHandler(in ResponseStatusCode p_responseStatusCode := int2000) runs on AeSimu {
					// Local variables
					var ResponsePrimitive v_responsePrimitive;
					var template Notification v_notificationRequest := mw_contentNotificationVerification;
    				
					//Preparation of expected Notification verification
					//TODO To add checks for creator and subscription reference
					//v_notificationRequest.creator := p_creator; TODO To check what address format is to be expected
					//Some participants use SP relative UNSTRUCTURED
					//v_notificationRequest.subscriptionReference := "I Don't know which URI is expected"; // TODO mandatory parameter 
    			
					//Preparation of Notification response to be sent
					v_responsePrimitive := valueof(m_responseNotification(p_responseStatusCode, omit));
    	
					tc_ac.start;
					alt {
						[] mcaPortIn.receive(mw_request(mw_notifyNotification(v_notificationRequest))) -> value vc_request {
							tc_ac.stop;
							setverdict(pass, __SCOPE__ & ":INFO: Notification received");
						}
						[] mcaPortIn.receive(mw_request(mw_notifyNotification(mw_contentNotification(?)))) -> value vc_request {
							tc_ac.stop;
							setverdict(fail, __SCOPE__ & ":ERROR: Notification received but verificationRequest isn't set to TRUE");							
						}
						[] mcaPortIn.receive{
							tc_ac.stop;
							setverdict(fail, __SCOPE__ & ":ERROR: unexpected message received");
							stop;
						}
						[] tc_ac.timeout {
							setverdict(fail, __SCOPE__ & ":ERROR:  No notification received");
							stop;
						}
					}
						
					v_responsePrimitive.requestIdentifier := vc_request.primitive.requestPrimitive.requestIdentifier;
					if(getverdict == pass) {
						mcaPortIn.send(m_httpResponse(v_responsePrimitive));
					} else {
						v_responsePrimitive.responseStatusCode := int4000; 
						mcaPortIn.send(m_httpResponse(v_responsePrimitive));
					}
					
					//mcaPort.send(m_response(v_responsePrimitive));	// TODO have to be deleted
        
				} //end f_subscriptionVerificationHandler
    		
				/**
				 * @desc Handling message exchange for the notification procedure
				 * @param p_primitiveContent Expected primitiveContent in the notification
				 * @verdict 
				 */
				function f_cse_notifyProcedure_representationHandler(template PrimitiveContent p_primitiveContent) runs on AeSimu {
					// Local variables
					var ResponsePrimitive v_responsePrimitive;
					
					tc_ac.start;
					alt {
						[] mcaPortIn.receive(mw_request(mw_notifyNotification(mw_contentNotification(?)))) -> value vc_request {
							tc_ac.stop;
							if(f_check_notificationContent(vc_request.primitive.requestPrimitive, p_primitiveContent)){
								setverdict(pass, __SCOPE__ & ":INFO: Notification received");
							}
							else{
								setverdict(fail, __SCOPE__ & ":ERROR: Notification received but the content doesn't match");
							}
							//Send response in any case
							v_responsePrimitive := valueof(m_responseNotification(int2001, omit));
							v_responsePrimitive.requestIdentifier := vc_request.primitive.requestPrimitive.requestIdentifier;
							mcaPortIn.send(m_response(v_responsePrimitive));
						}
						[] mcaPortIn.receive{
							tc_ac.stop;
							setverdict(fail, __SCOPE__ & ":ERROR: unexpected message received");
						}
						[] tc_ac.timeout {
							setverdict(fail, __SCOPE__ & ":ERROR: No notification received");
						}
					}
	    		    	
				} //end f_cse_notifyProcedure_representationHandler
	    		
				/**
				 * @desc Handling message exchange for the notification procedure (aggregatedNotification)
				 * @param p_primitiveContent Expected primitiveContent in the notification
				 * @verdict 
				 */
				function f_cse_notifyProcedure_aggregatedNoficationHandler(template PrimitiveContent p_primitiveContent,in integer p_numberOfAggregatedNotification) runs on AeSimu {
					// Local variables
					var ResponsePrimitive v_responsePrimitive;
					var integer v_notificationsReceived := 0;
    
					tc_ac.start;
					alt {
						[] mcaPortIn.receive(mw_request(mw_notifyAggregatedNotification)) -> value vc_request {
							tc_ac.stop;
							if(p_numberOfAggregatedNotification == lengthof(vc_request.primitive.requestPrimitive.primitiveContent.aggregatedNotification.notification_list)){
								if(f_check_notificationContent(vc_response.primitive.requestPrimitive, p_primitiveContent)){
									setverdict(pass, __SCOPE__ & ": Notification received");
								}
								else{
									setverdict(fail, __SCOPE__ & ": Notification received but the content doesn't match");
								}
							}
							else {
								setverdict(fail, __SCOPE__ & ": Number of Notification in Aggregatednotification isn't right");
							}
							//Send response in any case
							v_responsePrimitive := valueof(m_responseNotification(int2001, omit));
							v_responsePrimitive.requestIdentifier := vc_request.primitive.requestPrimitive.requestIdentifier;
							mcaPortIn.send(m_response(v_responsePrimitive));
						}
						[] mcaPortIn.receive(mw_request(mw_notifyNotification(mw_contentNotification(?)))) -> value vc_request {
							tc_ac.stop;
							if(f_check_notificationContent(vc_request.primitive.requestPrimitive, p_primitiveContent)){
								setverdict(pass, __SCOPE__ & ":INFO: Notification received");
							}
							else{
								setverdict(fail, __SCOPE__ & ":ERROR: Notification received but the content doesn't match");
							}
							//Send response in any case
							v_responsePrimitive := valueof(m_responseNotification(int2001, omit));
							v_responsePrimitive.requestIdentifier := vc_request.primitive.requestPrimitive.requestIdentifier;
							mcaPortIn.send(m_response(v_responsePrimitive));
							v_notificationsReceived := v_notificationsReceived + 1;
							if(v_notificationsReceived < p_numberOfAggregatedNotification) {
								tc_ac.start;
								repeat;
							}
						}
						[] mcaPortIn.receive{
							tc_ac.stop;
							setverdict(fail, __SCOPE__ & ": Error, unexpected message received");
						}
						[] tc_ac.timeout {
							setverdict(fail, __SCOPE__ & ": No notification received");
						}
					}
					
				} //end f_cse_notifyProcedure_aggregatedNotificationHandler
	    		
				/**
				 * @desc Handling message exchange for the notification procedure (deletion of subscription resource)
				 * @param p_notification Expected notification
				 * @verdict 
				 */
				function f_cse_notifyProcedure_subscriptionDeletionHandler( template Notification p_notification) runs on AeSimu {
					var ResponsePrimitive v_responsePrimitive;
					tc_ac.start;
					alt {
						[] mcaPortIn.receive(mw_request(mw_notifyNotification(p_notification))) -> value vc_request {
							tc_ac.stop;
							v_responsePrimitive := valueof(m_responseNotification(int2001, omit));
							v_responsePrimitive.requestIdentifier := vc_request.primitive.requestPrimitive.requestIdentifier;
							mcaPortIn.send(m_response(v_responsePrimitive));
							if(not(match(vc_request.primitive.requestPrimitive.primitiveContent.notification.subscriptionDeletion, true))) {
								setverdict(fail, __SCOPE__ & ":ERROR: subscriptionDeletion attribute have to be set to TRUE");
							}
						}
						[] mcaPortIn.receive{
							tc_ac.stop;
							setverdict(fail, __SCOPE__ & ":ERROR: unexpected message received");
						}
						[] tc_ac.timeout {
							setverdict(fail, __SCOPE__ & ":ERROR: No notification received");
						}
					}
						
				} //end f_cse_notifyProcedure_subscriptionDeletionHandler  
				
				/**
				 * @desc Handling message exchange for the notification procedure (no notification expected)
				 * @verdict 
				 */
				function f_cse_notifyProcedure_noNotificationHandler() runs on AeSimu {
					// Local variables
		
					tc_ac.start(10.0);
					alt {
						[] mcaPortIn.receive(mw_request(mw_notifyNotification(mw_contentNotification(?)))) -> value vc_request {
							tc_ac.stop;
							setverdict(fail, __SCOPE__ & ": Error, Non expected notification received");
						}
						[] tc_ac.timeout {
							setverdict(pass, __SCOPE__ & ": No notification received");
						}
					}
		
				} //end f_cse_notifyProcedure_noNotification Handler
				
				/**
				 * @desc Checking of notification primitiveContent
				 * @param p_requestPrimitive Received Notification request
				 * @param p_primitiveContent Expected primitiveContent in the notification
				 * @verdict 
				 */
				function f_check_notificationContent(in RequestPrimitive p_requestPrimitive, template PrimitiveContent p_primitiveContent) runs on Tester return boolean{
					// Local variables
					var boolean v_matchResult := false;
					var integer i;
					var integer v_numberOfAggregatedNotification;
    	
					if (ischosen(p_primitiveContent.aE)){
						log("Representation contains AE resource representation");
						if(ischosen(p_requestPrimitive.primitiveContent.notification.notificationEvent.representation.resource.aE)) {
							v_matchResult := match(p_requestPrimitive.primitiveContent.notification.notificationEvent.representation.resource.aE, p_primitiveContent.aE);
							log("Expected primitiveContent");
						}
						else if(ischosen(p_requestPrimitive.primitiveContent.notification.notificationEvent.representation.responsePrimitive)) {
							v_matchResult :=match(p_requestPrimitive.primitiveContent.notification.notificationEvent.representation.responsePrimitive.primitiveContent.aE, p_primitiveContent.aE);
						}
						else if (ischosen(p_requestPrimitive.primitiveContent.aggregatedNotification)) {
							v_matchResult := true;
							v_numberOfAggregatedNotification := lengthof(p_requestPrimitive.primitiveContent.aggregatedNotification.notification_list);
							for(i := 0; i< v_numberOfAggregatedNotification; i := i + 1){
								if(ischosen(p_requestPrimitive.primitiveContent.aggregatedNotification.notification_list[i].notificationEvent.representation.resource)) {
									if(not (match(p_requestPrimitive.primitiveContent.aggregatedNotification.notification_list[i].notificationEvent.representation.resource.aE, p_primitiveContent.aE))){
										v_matchResult := false;
									}
								}
								else if(ischosen(p_requestPrimitive.primitiveContent.aggregatedNotification.notification_list[i].notificationEvent.representation.responsePrimitive)) {
									if(not (match(p_requestPrimitive.primitiveContent.aggregatedNotification.notification_list[i].notificationEvent.representation.responsePrimitive.primitiveContent.aE, p_primitiveContent.aE))){
										v_matchResult := false;
									}
								}						
							}
							if (i == 0){
								v_matchResult := false;
							}
						}
    
					}
    	
					if (ischosen(p_primitiveContent.container)){
						if(ischosen(p_requestPrimitive.primitiveContent.notification.notificationEvent.representation.resource.container)) {
							v_matchResult := match(p_requestPrimitive.primitiveContent.notification.notificationEvent.representation.resource.container, p_primitiveContent.container)
						}
						else if(ischosen(p_requestPrimitive.primitiveContent.notification.notificationEvent.representation.responsePrimitive)) {
							v_matchResult := match(p_requestPrimitive.primitiveContent.notification.notificationEvent.representation.responsePrimitive.primitiveContent.container, p_primitiveContent.container)
						}
					}
    	
					return v_matchResult;
    
				} //end f_check_notificationContent
				
				/**
				 * @desc Handling message exchange for the AE Annc update
				 * @verdict 
				 */
				//TODO TO BE FINALIZED
				function f_cse_notifyProcedure_updateHandler() runs on CseSimu {
					// Local variables
					var ResponsePrimitive v_responsePrimitive;
					var template Notification v_notificationRequest := mw_contentNotification_any;	 

					//Preparation of Notification response to be sent
					v_responsePrimitive := valueof(m_responseNotification(int2004, omit));

					tc_ac.start;
					alt {
						[] mccPortIn.receive(mw_request(mw_notifyNotification(v_notificationRequest))) -> value vc_request {
							tc_ac.stop;
							setverdict(pass, __SCOPE__ & ":INFO: Notification received");
						}
						[] mccPortIn.receive{
							tc_ac.stop;
							setverdict(fail, __SCOPE__ & ":ERROR: unexpected message received");
							stop;
						}
						[] tc_ac.timeout {
							setverdict(fail, __SCOPE__ & ":ERROR:  No notification received");
							stop;
						}
					}
		
					v_responsePrimitive.requestIdentifier := vc_request.primitive.requestPrimitive.requestIdentifier;
					if(getverdict == pass) {
						mccPortIn.send(m_httpResponse(v_responsePrimitive));
					} else {
						v_responsePrimitive.responseStatusCode := int4000; 
						mccPortIn.send(m_httpResponse(v_responsePrimitive));
					}

				} //end f_cse_notifyProcedure_updateHandler	
				
			}// end of group NotificationFunctions 	
			
			/**
			 * @desc Check that a resource is present in the IUT (resourceId is known)
			 * @param p_resourceIndex Resource index 
			 * @return boolean
			 */
			function f_cse_isResourcePresent (integer p_resourceIndex) runs on CseSimu return boolean {

				//Check to see if the resource is present or not
				mccPort.send(m_request(m_retrieve(f_getResourceAddress(p_resourceIndex), f_getOriginator(p_resourceIndex))));
				tc_ac.start;
				alt {
					[] mccPort.receive(mw_response(mw_responsePrimitive(int2000))) {
						tc_ac.stop;
						setverdict(pass, testcasename() & ": Resource present: " & f_getResourceAddress(p_resourceIndex));
						return true;
					}
					[] mccPort.receive(mw_response(mw_responsePrimitive(int4004))) {
						tc_ac.stop;
						setverdict(pass, testcasename() & ": Resource: " & f_getResourceAddress(p_resourceIndex) & " not found");
						return false;
					}
					[] mccPort.receive(mw_response(mw_responsePrimitive(?, -))) {
						tc_ac.stop;
						setverdict(inconc, testcasename() & ": Wrong response status code in the response");
						return false;
					}
					[] tc_ac.timeout {
						setverdict(inconc, testcasename() & ": No answer while retrieving resource");
						return false;
					}
				}	
				return false;
			}	
			
			/**
			 * @desc Check that a resource is not present in the IUT (resourceId is NOT known)
			 * @param p_parentIndex Index of the parent resource of the resource to be checked
			 * @param p_resourceName Resource name (Hierarchical method is used) of the resource to be checked
			 * @return boolean
			 */
			function f_cse_isResourceNotPresent (integer p_parentIndex, XSD.String p_resourceName) runs on CseSimu return boolean {
			
				log(testcasename() & ":INFO: Hierarchical addressing method is required to check the non presence of the resource");
				
				//Check to see if the resource has NOT been created
				mccPort.send(m_request(m_retrieve(f_getResourceAddress(p_parentIndex, e_hierarchical) & "/" & p_resourceName, f_getOriginator(p_parentIndex))));
				tc_ac.start;
				alt {
					[] mccPort.receive(mw_response(mw_responsePrimitive(int4004))) {
						tc_ac.stop;
						setverdict(pass, testcasename() & ": Resource not present");
						return true;
					}
					[] mccPort.receive(mw_response(mw_responsePrimitive(?))) {
						tc_ac.stop;
						setverdict(inconc, testcasename() & ": Wrong response status code in the response");
						return false;
					}
					[] tc_ac.timeout {
						setverdict(inconc, testcasename() & ": No answer while retrieving resource");
						return false;
					}
				}	
				return false;
			}			
	    		
			/**
			 * @desc Registration of Test System (simulating a CSE) to the CSE IUT (creation of remoteCSE)
			 * @param p_requestPrimitive Template request primitive
			 * @param p_primitiveContent Expected primitiveContent in the CREATE response primitive
			 * @return Internal resource index of the created resource
			 */
			function f_cse_registerRemoteCse(in template RequestPrimitive p_requestPrimitive, in template PrimitiveContent p_contentResponse := ?) runs on CseSimu return integer {
    			
				var MsgIn v_response;
				var RequestPrimitive v_request;
				var PrimitiveContent v_remoteCSEResource;

				v_request := f_getCreateRequestPrimitive(int16, p_requestPrimitive, -1);

				mccPort.send(m_request(v_request));
				tc_ac.start;
				alt {
					[] mccPort.receive(mw_response(mw_responsePrimitiveOK(p_contentResponse))) -> value v_response {
						tc_ac.stop;
						setverdict(pass, __SCOPE__&":INFO: Resource type remoteCSE created successfuly");
						f_checkAttributesToBeSaved(int16, v_request, v_response.primitive.responsePrimitive);
						vc_remoteCseIndex := f_setResource(v_response.primitive.responsePrimitive.primitiveContent, int16, -1);
						v_remoteCSEResource := f_cse_generateLocalResource(v_response.primitive.responsePrimitive.primitiveContent, vc_cSEBaseIndex, int16);
						vc_localRemoteCseIndex := f_setLocalResource(v_remoteCSEResource, int16, vc_cSEBaseIndex);
					}
					[] mccPort.receive(mw_response(mw_responsePrimitiveKO)) {
						tc_ac.stop;
						setverdict(inconc, __SCOPE__&":INFO: Error while creating resource type remoteCSE");
					}
					[] mccPort.receive {
						tc_ac.stop;
						setverdict(inconc, __SCOPE__&":INFO: Unexpected message received");
					}
					[] tc_ac.timeout {
						setverdict(inconc, __SCOPE__&":INFO: No answer while creating resource type remoteCSE");
					}
				}	

				f_checkCseSimuStatus();

				return vc_remoteCseIndex;
    		
			}
			
			/**
			 * @desc Registration of the CSE IUT to the Test System (simulating a CSE) 
			 * @param p_requestPrimitive Template request primitive
			 * @return Internal resource index of the created resource
			 */
			function f_cse_registrationRemoteCse(in template RequestPrimitive p_requestPrimitive := ?) runs on CseSimu return integer {
    			
				var MsgIn v_request;
				var ResponsePrimitive v_response;
				var PrimitiveContent v_remoteCSEResource;
				var integer v_resourceIndex := -1;
				var template UtTriggerPrimitive v_utRequest := m_utCreateRemoteCSE;
				var charstring v_action := "Please, send a CSE registration request";
				
				//send triggering primitive to SUT
			  	f_sendUtPrimitive(v_utRequest,v_action);

				tc_ac.start;
				alt {
					[] mccPortIn.receive(mw_request(p_requestPrimitive)) -> value v_request {
						tc_ac.stop;
						setverdict(pass, __SCOPE__&":INFO: Resource type remoteCSE created successfuly");
						v_remoteCSEResource := f_cse_generateLocalResource(v_request.primitive.requestPrimitive.primitiveContent, vc_cSEBaseIndex, int16);//TODO Get index from v_request.primitive.requestPrimitive.to_
						vc_localRemoteCseIndex := f_setLocalResource(v_remoteCSEResource, int16, vc_cSEBaseIndex);
						
						v_response := valueof(m_responsePrimitive(int2001,v_request.primitive.requestPrimitive.requestIdentifier));
						v_response.from_ := PX_CSE1_ID;
						v_response.to_ := v_request.primitive.requestPrimitive.from_;
						v_response.primitiveContent.remoteCSE := vc_localResourcesList[vc_localRemoteCseIndex].resource.remoteCSE;
						mccPortIn.send(m_response(v_response));
						
						v_resourceIndex := f_setResource(valueof(m_primitiveContentRemoteCSE(m_contentMyRemoteCSEResource)), int16, -1);
					}
					[] mccPortIn.receive {
						tc_ac.stop;
						setverdict(inconc, __SCOPE__&":INFO: Unexpected message received");
					}
					[] tc_ac.timeout {
						setverdict(inconc, __SCOPE__&":INFO: No request received for creating resource type remoteCSE");
					}
				}	

				f_checkCseSimuStatus();
				
				//In order for the IUT to perform some actions
				f_sleep(10.0);

				return v_resourceIndex;
    		
			}
						
			/**
			 * @desc Receive a request from the CSE IUT to the Test System (simulating a CSE) 
			 * @param p_requestPrimitive Expected CREATE request primitive
			 */
			function f_cse_receiveCreateRequest(in template RequestPrimitive p_requestPrimitive := ?) runs on CseSimu {
    			
				tc_ac.start;
				alt {
					[] mccPortIn.receive(mw_request(p_requestPrimitive)) -> value vc_request {
						tc_ac.stop;
						setverdict(pass, __SCOPE__&":INFO: CREATE Request received successfuly");
					}
					[] mccPortIn.receive(mw_request(?)) {
						tc_ac.stop;
						setverdict(fail, __SCOPE__&":INFO: Unexpected CREATE Request received");
					}
					[] mccPortIn.receive {
						tc_ac.stop;
						setverdict(fail, __SCOPE__&":INFO: Unexpected message received");
					}
					[] tc_ac.timeout {
						setverdict(fail, __SCOPE__&":INFO: No answer while creating resource type RemoteCSE");
					}
				}	

				f_checkCseSimuStatus();
				    		
			}
			
			/**
			 * @desc   Creation of a local resource (Test System simulating a CSE)
			 * @param  p_resource          Resource to be created
			 * @param  p_parentIndex       Parent resource index of resource to be saved
			 * @param  p_resourceType      Type of the resource to be created
			 * @return Internal created resource
			 */
			function f_cse_generateLocalResource(in template(omit) PrimitiveContent p_resource := omit, in integer p_parentIndex, in ResourceType p_resourceType) runs on CseSimu return PrimitiveContent {

				var integer v_resourceIndex := lengthof(vc_localResourcesList);
				var PrimitiveContent v_myResource;
				
				// TODO To review the code (use of indexes, generation of value for certain attributes, etc..)
				if(p_resourceType == int5) {	//CSEBase
					v_myResource.cSEBase.resourceName := "CSEBase" & int2str(v_resourceIndex);
					v_myResource.cSEBase.resourceType := p_resourceType;
					v_myResource.cSEBase.resourceID := "CSEBase" & int2str(v_resourceIndex);
					v_myResource.cSEBase.parentID := omit;		//Following TS-0001, it must be NULL
					v_myResource.cSEBase.creationTime := fx_generateTimestamp();
					v_myResource.cSEBase.creationTime := "20171231T012345";
					v_myResource.cSEBase.lastModifiedTime := v_myResource.cSEBase.creationTime;		
					v_myResource.cSEBase.cSE_ID := PX_CSE1_ID;
					v_myResource.cSEBase.supportedResourceType := PX_CSE1_SRT;
					v_myResource.cSEBase.pointOfAccess := {f_getAnnouncementTargetPoA(PX_PROTOCOL_BINDING, PX_CSE1_ADDRESS, "")};
					if (PX_MN_CSE){
						v_myResource.cSEBase.cseType := int1;	//Tester is an IN-CSE
					}else if (PX_IN_CSE){
						v_myResource.cSEBase.cseType := int2;	//Tester is a MN-CSE
					}
					    
				}else if(p_resourceType == int16 and ispresent(p_resource)) {			//RemoteCSE
					if(ischosen(p_resource.remoteCSE)){
						v_myResource.remoteCSE := valueof(p_resource.remoteCSE);
						
						if(not(ispresent(p_resource.remoteCSE.resourceName))) {
							v_myResource.remoteCSE.resourceName := "remoteCSE" & int2str(v_resourceIndex);
						}
						v_myResource.remoteCSE.resourceType := p_resourceType;
						v_myResource.remoteCSE.resourceID := "remoteCSE" & int2str(v_resourceIndex);
						v_myResource.remoteCSE.parentID := f_getResourceId(vc_localResourcesList[p_parentIndex].resource);
						v_myResource.remoteCSE.creationTime := fx_generateTimestamp();
						v_myResource.remoteCSE.creationTime := "20171231T012345";
						if(not(ispresent(p_resource.remoteCSE.expirationTime))) {
							v_myResource.remoteCSE.expirationTime := "20301231T012345";
						}
						v_myResource.remoteCSE.lastModifiedTime := v_myResource.remoteCSE. creationTime;											
						v_myResource.remoteCSE.announceTo := omit;	
						v_myResource.remoteCSE.announcedAttribute := omit;	
						
						if(not(ispresent(p_resource.remoteCSE.pointOfAccess))) {
							//TODO Create a pollingChannel resource
							v_myResource.remoteCSE.pointOfAccess := omit;
						}	
						/*if(vc_localResourcesList[v_resourceIndex].resourceType == int5) {
							v_myResource.remoteCSE.m2M_Ext_ID := omit;	
							v_myResource.remoteCSE.trigger_Recipient_ID:= omit;
						}*/
						v_myResource.remoteCSE.nodeLink := omit;
				    
					}
				}
				return v_myResource;
				
			}//End of function	
			
			
		}//end group CseSimuFunctions
		
		group CseAltstepFunctions {
			 
			/**
			  * @desc	Cse altstep for config 01
			  */
			 altstep a_cse_cf01() runs on AeSimu {
		
				[] mcaPort.receive {
					log(__SCOPE__&": WARNING: Unexpected message received");
					repeat;
				}
			 }			
			 
			 /**
			  * @desc	Cse altstep for config 01 for AE2
			  */
			 altstep a_cse_cf01_ae2() runs on AeSimu {
		
				var MsgIn v_request;
				var ResponsePrimitive v_responsePrimitive;

				[] mcaPortIn.receive(mw_request(mw_notifyNotification(mw_contentNotification(?)))) -> value v_request {
					//Send response 
					v_responsePrimitive := valueof(m_responseNotification(int2001, omit));
					v_responsePrimitive.requestIdentifier := v_request.primitive.requestPrimitive.requestIdentifier;
					mcaPortIn.send(m_response(v_responsePrimitive));
					log(__SCOPE__&": WARNING: Unexpected Notification message received");
					repeat;
				}
			 }			
			 
			/**
			  * @desc	Cse altstep for config 02 on CSE1 (AE1 as master)
			  */
			 altstep a_cse_cf02_cse1() runs on CseSimu {
				
				var MsgIn v_request;
				var ResponsePrimitive v_response;
				var PrimitiveContent v_remoteResource; //localresource
				var integer v_localResourceIndex;
				var integer v_resourceIndex;

				[] mccPortIn.receive(mw_request(mw_create)) -> value v_request {
					v_remoteResource := f_cse_generateLocalResource(v_request.primitive.requestPrimitive.primitiveContent, f_getResourceIndex(v_request.primitive.requestPrimitive.to_), v_request.primitive.requestPrimitive.resourceType);
					v_localResourceIndex := f_setLocalResource(v_remoteResource, v_request.primitive.requestPrimitive.resourceType, f_getResourceIndex(v_request.primitive.requestPrimitive.to_));
	
					v_response := valueof(m_responsePrimitive(int2001,v_request.primitive.requestPrimitive.requestIdentifier));
					v_response.from_ := PX_CSE1_ID;
					v_response.to_ := v_request.primitive.requestPrimitive.from_;
					v_response.primitiveContent := vc_localResourcesList[v_localResourceIndex].resource;
					mccPortIn.send(m_response(v_response));
				}
				[] mccPortIn.receive {
					log(__SCOPE__&": WARNING: Unexpected message received");
					repeat;
				}
				[] mccPort.receive {
					log(__SCOPE__&": WARNING: Unexpected message received");
					repeat;
				}
			 }
			 
			/**
			  * @desc	Cse altstep for config 02 on AE1 (CSE1 as master)
			  */
			 altstep a_cse_cf02_ae1() runs on AeSimu 
			 {
				[] mcaPort.receive {
					log(__SCOPE__&": WARNING: Unexpected message received");
					repeat;
				}
			 }
			 			 
			/**
			  * @desc	Cse altstep for config 04
			  */
			 altstep a_cse_cf04() runs on CseSimu {

				[] mccPort.receive {
					log(__SCOPE__&": WARNING: Unexpected message received");
					repeat;
				}
			 }		

		}//end group altstepFunctions	
		
	}//end cseFunctions
	
	group AeFunctions {
		
		group preambleFunctions {
		
			/**
			 * @desc	Waits for AE registration request and process it
			 * @param 	p_utRequest UpperTester request primitive to be sent to the IUT		
			 * @return 	Internal resource index of AE or -1 in case of failure		
			 * @verdict	inconc if no AE registration request is received 
			 */
			function f_ae_preamble_registerAe(template UtTriggerPrimitive p_utRequest := m_create) runs on CseSimu return integer {
    		
				var MsgIn v_request;
				var PrimitiveContent v_modifiedResource;
				var integer v_resourceIndex, v_parentIndex;
				var RequestPrimitive v_rp;
				var charstring v_action := "Please, register the AE on the Tester";

				if(not(ispresent(p_utRequest.primitiveContent))) {
					p_utRequest.primitiveContent.aE := m_contentCreateAe(omit, omit, omit, omit);
				}
  
				f_sendUtPrimitive(p_utRequest, v_action);
     		
				tc_ac.start;
				alt {    				
					[] mcaPortIn.receive(mw_request(mw_createAe)) -> value v_request {
						tc_ac.stop;
    					
						v_rp := v_request.primitive.requestPrimitive;		
						v_parentIndex := f_getResourceIndex(v_rp.to_);
						v_modifiedResource := f_ae_generateLocalResource(v_rp.primitiveContent, v_parentIndex, v_rp.resourceType);
						v_resourceIndex := f_setLocalResource(v_modifiedResource, int2, v_parentIndex);
						if(v_resourceIndex != -1) {
							mcaPortIn.send(m_response(m_responsePrimitive_content(int2001, v_rp.requestIdentifier, v_modifiedResource)));
							setverdict(pass, __SCOPE__&":INFO: Application registered successfuly");
						}
						else {
							mcaPortIn.send(m_response(m_responsePrimitive(int5000, v_request.primitive.requestPrimitive.requestIdentifier)));
							setverdict(inconc, __SCOPE__&":INFO: AE registration failed");
						}					
					}
    					
					[] tc_ac.timeout {
						setverdict(inconc, __SCOPE__&":INFO: AE registration request not received");
						stop;
					}	     				   	
				}    
				
				f_checkCseSimuStatus();	
    			
				return v_resourceIndex;	
			}//end function f_ae_preamble_register
			
			            
            /**
			 * @desc	Waits for Container create request and process it
			 * @param 	p_utRequest UpperTester request primitive to be sent to the IUT		
			 * @return 	Internal resource index of Container or -1 in case of failure		
			 * @verdict	inconc if no Container create request is received 
			 */
			function f_ae_preamble_createContainer(template UtTriggerPrimitive p_utRequest := m_create) runs on CseSimu return integer {
    		
				var MsgIn v_request;
				var PrimitiveContent v_modifiedResource;
				var integer v_resourceIndex, v_parentIndex;
				var RequestPrimitive v_rp;
				var charstring v_action := "Please, create a Container resource on the Tester";
				
				if(not(ispresent(p_utRequest.primitiveContent))) {
					p_utRequest.primitiveContent.container := m_contentCreateContainer;
				}
    		
				f_sendUtPrimitive(p_utRequest, v_action);
				
				tc_ac.start;
				alt {    				
					[] mcaPortIn.receive(mw_request(mw_createContainer(?,?))) -> value v_request {
						tc_ac.stop;
    					
						v_rp := v_request.primitive.requestPrimitive;		
						v_parentIndex := f_getResourceIndex(v_rp.to_);
						v_modifiedResource := f_ae_generateLocalResource(v_rp.primitiveContent, v_parentIndex, v_rp.resourceType);
						v_resourceIndex := f_setLocalResource(v_modifiedResource, int2, v_parentIndex);
						if(v_resourceIndex != -1) {
							mcaPortIn.send(m_response(m_responsePrimitive_content(int2001, v_rp.requestIdentifier, v_modifiedResource)));
							setverdict(pass, __SCOPE__&":INFO: Container created successfuly");
						}
						else {
							mcaPortIn.send(m_response(m_responsePrimitive(int5000, v_request.primitive.requestPrimitive.requestIdentifier)));
							setverdict(inconc, __SCOPE__&":INFO: Container creation failed");
						}					
					}
    					
					[] tc_ac.timeout {
						setverdict(inconc, __SCOPE__&":INFO: Container create request not received");
						stop;
					}	     				   	
				}    
				
				f_checkCseSimuStatus();	
    			
				return v_resourceIndex;	
 			} //end function f_ae_preamble_createContainer	
						
		} // end preambleFunctions
		
		group helpingFunctions {
			
			/**
			 * @desc   Creates specified resource
			 * @param  p_resource          Resource to be created
			 * @param  p_parentIndex       Parent index of resource to be saved
			 * @param  p_resourceType      Type of the resource to be created
			 * @param  p_modifiedResource  Assigned and/or modified fields
			 * @return Internal resource index of the saved resource or -1
			 */
			function f_ae_generateLocalResource(in PrimitiveContent p_resource, in integer p_parentIndex, in ResourceType p_resourceType) runs on CseSimu return PrimitiveContent {

				var integer v_resourceIndex;
				var PrimitiveContent v_primitiveContent;
				
				// AE TODO To review the code (use of indexes, generation of value for certain attributes, etc..)
				if(p_resourceType == int2 and ispresent(p_resource)) {
					if(ischosen(p_resource.aE)){
						var AE_optional v_content := p_resource.aE;
						
						v_resourceIndex := lengthof(vc_localResourcesList) - 1;
						v_content.resourceType := p_resourceType;
      					
						v_content.parentID := PX_CSE1_ID;
						v_content.creationTime := fx_generateTimestamp();
						v_content.lastModifiedTime := v_content.creationTime;											
						v_content.resourceID := "ae" & int2str(v_resourceIndex);
						v_content.aE_ID := "Cae" & int2str(v_resourceIndex);
						v_content.resourceName := "ae" & int2str(v_resourceIndex);
      					v_primitiveContent := {aE := v_content};
						return v_primitiveContent;
				    
					}
										
				}	
				
				if(p_resourceType == int3 and ispresent(p_resource)) {
					if(ischosen(p_resource.container)){
						var Container_optional v_content := p_resource.container;
						
						v_resourceIndex := lengthof(vc_localResourcesList) - 1;
						v_content.resourceType := p_resourceType;
      					
						v_content.parentID := PX_CSE1_ID;
						v_content.creationTime := fx_generateTimestamp();
						v_content.lastModifiedTime := v_content.creationTime;											
						v_content.resourceID := "cnt" & int2str(v_resourceIndex);
						v_content.resourceName := "cnt" & int2str(v_resourceIndex);
						v_primitiveContent := {container := v_content};
						return v_primitiveContent;
				    
					}
										
				}	
				
				// TODO: implement other resource types			
				
				// Error
				return p_resource;
			}
			
		} // end helpingFunctions
		
		group altstepFunctions {
    
			/**
			  * @desc	Ae altstep
			  */
			 altstep a_ae_default() runs on CseSimu {

				var MsgIn v_request; 
				
				[] mcaPort.receive(mw_request(?)) -> value v_request {
					log(__SCOPE__ & ":WARNING: Unexpected request received");
					mcaPort.send(m_response(m_responsePrimitive(int5000, v_request.primitive.requestPrimitive.requestIdentifier)));
					repeat;
				}
				    		
				[] mcaPort.receive {
					log(__SCOPE__ & ":WARNING: Unexpected message received");
					repeat;
				}
			 }		
			 
			/**
			 * @desc    Waits for CREATE request, stores resource and replies to request 
			 * @remark  This altstep includes a_ae_default
			 * @see		a_ae_default
			 */
			altstep a_ae_cf03() runs on CseSimu {
				
				var MsgIn v_request;			
				var PrimitiveContent v_modifiedResource;
				var integer v_resourceIndex, v_parentIndex;
				var RequestPrimitive v_rp;
				
				[] mcaPort.receive(mw_request(mw_create)) -> value v_request {	
					v_rp := v_request.primitive.requestPrimitive;		
					v_parentIndex := f_getResourceIndex(v_rp.to_);
					v_modifiedResource := f_ae_generateLocalResource(v_rp.primitiveContent, v_parentIndex, v_rp.resourceType);
					v_resourceIndex := f_setLocalResource(v_modifiedResource, v_rp.resourceType, v_parentIndex);
					if(v_resourceIndex != -1) {
						mcaPort.send(m_response(m_responsePrimitive_content(int2001, v_rp.requestIdentifier, v_modifiedResource)));
					}
					else {
						mcaPort.send(m_response(m_responsePrimitive(int5000, v_request.primitive.requestPrimitive.requestIdentifier)));
					}					
					repeat;	
				}
				
				[] a_ae_default();				
			}
    		 
		}//end group altstepFunctions
		
	}//end of aeFunctions


	group GetSetFunctions {
	
		/**
		 * @desc Creation of a CREATE request primitive from a template request primitive
		 * @param p_resourceType Type of resource to be created
		 * @param p_request Template request primitive 
		 * @param p_parentIndex Internal resource index which indicates the parent of the resource to be created
		 * @return Created CREATE request primitive
		 * @verdict 
		 */
		function f_getCreateRequestPrimitive(in ResourceType p_resourceType, template RequestPrimitive p_request := m_create, integer p_parentIndex) runs on Tester return RequestPrimitive {
			var template ListOfURIs v_defaultListOfURIs := {"NotInitialized"};
			var template AcpType v_defaultAcpIDs := {"NotInitialized"};

			p_request.requestIdentifier := valueof(p_request.requestIdentifier) & f_rnd(1, 1000000);
			
			if((p_resourceType != int2) and (p_resourceType != int10002)) {
				if(p_resourceType == int16) {
					p_request.from_ := PX_CSE1_ID;
				} else {	
					if(vc_testSystemRole == e_ae) {			
						p_request.from_ := f_getOriginator(p_parentIndex);
					} else {//vc_testSystemRole == e_cse
						p_request.from_ := f_getOriginator(p_parentIndex, false);
					}
				}
			}
			
			p_request.to_ := f_getResourceAddress(p_parentIndex);

			if (p_resourceType == int1) {//AccessControlPolicy
				
			} 
			
			if (p_resourceType == int9) {//group
				if(match(valueof(p_request.primitiveContent.group_.memberIDs), v_defaultListOfURIs )){
					if ((p_parentIndex == -1) and (isbound(vc_aeAuxIndex))){
						p_request.primitiveContent.group_.memberIDs := {f_getResourceId(vc_resourcesList[vc_aeAuxIndex].resource)};
					}else{
						p_request.primitiveContent.group_.memberIDs := {f_getResourceId(vc_resourcesList[p_parentIndex].resource)};
					}
				}
			}
			
			if(p_resourceType == int3){//container
				//when a container is created by hosting cse for storing location information, the container is seen as a location container
				if(PX_IS_LOC_CONTAINER){
					p_request.primitiveContent.container.locationID := f_getResourceId(vc_resourcesList[p_parentIndex].resource);//resourceID of the locationPolicy
				}	
				if(ispresent(p_request.primitiveContent.container.accessControlPolicyIDs)) {
					if((match(valueof(p_request.primitiveContent.container.accessControlPolicyIDs), v_defaultAcpIDs )) and (isbound(vc_acpAuxIndex))){
						p_request.primitiveContent.container.accessControlPolicyIDs := {f_getResourceId(vc_resourcesList[vc_acpAuxIndex].resource)};
					}	
				}  
			}
			
			if (p_resourceType == int15) {//pollingChannel
				if(ischosen(vc_resourcesList[p_parentIndex].resource.aE)) {	
					p_request.from_ := vc_resourcesList[p_parentIndex].resource.aE.aE_ID;
				}
			} 
			
			if (p_resourceType == int18) {//schedule
			} 

			if (p_resourceType == int23) {//subscription
				//notificationURI
				if(match(valueof(p_request.primitiveContent.subscription.notificationURI), v_defaultListOfURIs )){
					p_request.primitiveContent.subscription.notificationURI := {f_getResourceAddress(p_parentIndex)};
				}
				//subscriberURI
				if(ispresent(p_request.primitiveContent.subscription.subscriberURI)) {
					if(match(valueof(p_request.primitiveContent.subscription.subscriberURI), "NotInitialized" )){
						p_request.primitiveContent.subscription.subscriberURI := f_getResourceAddress(vc_aeAuxIndex);
					}
				}
				//creator attribute
				if(ispresent(p_request.primitiveContent.subscription.creator)) {
					p_request.primitiveContent.subscription.creator := f_getCreator(p_parentIndex);
				}
				//accessControlPolicyIds
				if(ispresent(p_request.primitiveContent.subscription.accessControlPolicyIDs)) {
					if(match(valueof(p_request.primitiveContent.subscription.accessControlPolicyIDs), v_defaultAcpIDs )){
						p_request.primitiveContent.subscription.accessControlPolicyIDs := {f_getResourceId(vc_resourcesList[vc_acpAuxIndex].resource)};
					}	
				}  
			}
			if (p_resourceType == int4) {//contentInstance
				//creator attribute
				if(ispresent(p_request.primitiveContent.contentInstance.creator)) {
					p_request.primitiveContent.contentInstance.creator := f_getCreator(p_parentIndex);
				}
			}

			return valueof(p_request);
		}
		
		/**
		 * @desc Creation of a CREATE response primitive from a template request primitive
		 * @param p_resourceType Type of resource to be created
		 * @param p_request Template request primitive 
		 * @return Created CREATE response primitive
		 * @verdict 
		 */
		//TODO To be completed
		function f_getCreateResponsePrimitive(in ResourceType p_resourceType, template RequestPrimitive p_request := m_create) runs on Tester return ResponsePrimitive {
			var template ResponsePrimitive v_responsePrimitive;

			if(p_resourceType != int2) {
				v_responsePrimitive.from_ := p_request.to_;
			}
			p_request.to_ := p_request.from_;

			if (p_resourceType == int1) {//AccessControlPolicy
				
			} 
			
			if (p_resourceType == int9) {//group
				
			}
			
			if(p_resourceType == int3){//container
					  
			}
			
			if (p_resourceType == int15) {//pollingChannel
				
			} 
			
			if (p_resourceType == int18) {//schedule
			} 

			if (p_resourceType == int23) {//subscription
				
				
			}

			return valueof(v_responsePrimitive);
		}

		/**
		 * @desc Creation of an UPDATE request primitive from a template request primitive
		 * @param p_resourceType Type of resource to be created
		 * @param p_resourceIndex Internal resource index which indicates the resource to be updated
		 * @param p_request Template request primitive
		 * @return Created UPDATE request primitive
		 * @verdict 
		 */
		function f_getUpdateRequestPrimitive(in ResourceType p_resourceType, integer p_resourceIndex, template RequestPrimitive p_request) runs on Tester return RequestPrimitive {
		
			p_request.requestIdentifier := valueof(p_request.requestIdentifier) & f_rnd(1, 1000000);
			
			if(p_resourceType != int10002) {
				p_request.from_ := f_getOriginator(p_resourceIndex);
		
				p_request.to_ := f_getResourceAddress(p_resourceIndex);
			} else {
				p_request.from_ := PX_CSE1_ID & "/" & f_getResourceId(vc_resourcesList[p_resourceIndex].resource); 
				
				p_request.to_ := f_getResourceAddress(p_resourceIndex, -, e_spRelative);
			}

			if (p_resourceType == int3) {//Container

			//TODO
			} 

			if (p_resourceType == int9) {//group
				//TODO	

			}

			if (p_resourceType == int18) {//schedule
				//TODO			

			} 

			if (p_resourceType == int15) {//pollingChannel
				//TODO		
			}

			if (p_resourceType == int23) {//subscription
				//TODO		
			} 

			return 	valueof(p_request);
		}

		/**
		 * @desc Extraction from a primitiveContent field the resourceID attribute
		 * @param p_contentResource primitiveContent field
		 * @return resourceID attribute
		 * @verdict 
		 */
		function f_getResourceId(PrimitiveContent p_contentResource) return XSD.ID {
					
			if(ischosen(p_contentResource.accessControlPolicy)) {
				return f_resourceIdCleaner(p_contentResource.accessControlPolicy.resourceID);
			}
			if(ischosen(p_contentResource.container)) {
				return f_resourceIdCleaner(p_contentResource.container.resourceID);
			}
			if(ischosen(p_contentResource.contentInstance)) {
				return f_resourceIdCleaner(p_contentResource.contentInstance.resourceID);
			}
			if(ischosen(p_contentResource.schedule)) {
				return f_resourceIdCleaner(p_contentResource.schedule.resourceID);
			}
			if(ischosen(p_contentResource.pollingChannel)) {
				return f_resourceIdCleaner(p_contentResource.pollingChannel.resourceID);
			}
			if(ischosen(p_contentResource.subscription)) {
				return f_resourceIdCleaner(p_contentResource.subscription.resourceID);
			}
			if(ischosen(p_contentResource.group_)) {
				return f_resourceIdCleaner(p_contentResource.group_.resourceID);
			}
			if(ischosen(p_contentResource.aE)) {
				return f_resourceIdCleaner(p_contentResource.aE.resourceID);
			}
			if(ischosen(p_contentResource.aEAnnc)) {
				return f_resourceIdCleaner(p_contentResource.aEAnnc.resourceID);
			}
			if(ischosen(p_contentResource.serviceSubscribedAppRule)) {
				return f_resourceIdCleaner(p_contentResource.serviceSubscribedAppRule.resourceID);
			}
			if(ischosen(p_contentResource.remoteCSE)) {
				return f_resourceIdCleaner(p_contentResource.remoteCSE.resourceID);
			}
			if(ischosen(p_contentResource.cSEBase)) {
				return f_resourceIdCleaner(p_contentResource.cSEBase.resourceID);
			}
			if(ischosen(p_contentResource.m2mServiceSubscriptionProfile)) {
				return p_contentResource.m2mServiceSubscriptionProfile.resourceName;
			}
			if(ischosen(p_contentResource.node)) {
				return p_contentResource.node.resourceName;
			}
			if(ischosen(p_contentResource.statsConfig)) {
				return p_contentResource.statsConfig.resourceName;
			}
			if(ischosen(p_contentResource.statsCollect)) {
				return p_contentResource.statsCollect.resourceName;
			}

			log(__SCOPE__&":WARNING: Primitive Content Kind not implemented");
			
			return "resourceIDNotFound";
			
		}
			
		/**
		 * @desc Extraction from a primitiveContent field the resourceName attribute
		 * @param p_contentResource primitiveContent field
		 * @return resourceName attribute
		 * @verdict 
		 */
		function f_getResourceName(PrimitiveContent p_contentResource) return XSD.ID {
					
			if(ischosen(p_contentResource.accessControlPolicy)) {
				return p_contentResource.accessControlPolicy.resourceName;
			}
			if(ischosen(p_contentResource.container)) {
				return p_contentResource.container.resourceName;
			}
			if(ischosen(p_contentResource.contentInstance)) {
				return p_contentResource.contentInstance.resourceName;
			}
			if(ischosen(p_contentResource.schedule)) {
				return p_contentResource.schedule.resourceName;
			}
			if(ischosen(p_contentResource.pollingChannel)) {
				return p_contentResource.pollingChannel.resourceName;
			}
			if(ischosen(p_contentResource.subscription)) {
				return p_contentResource.subscription.resourceName;
			}
			if(ischosen(p_contentResource.group_)) {
				return p_contentResource.group_.resourceName;
			}
			if(ischosen(p_contentResource.aE)) {
				return p_contentResource.aE.resourceName;
			}
			if(ischosen(p_contentResource.aEAnnc)) {
				return p_contentResource.aEAnnc.resourceName;
			}
			if(ischosen(p_contentResource.serviceSubscribedAppRule)) {
				return p_contentResource.serviceSubscribedAppRule.resourceName;
			}
			if(ischosen(p_contentResource.remoteCSE)) {
				return p_contentResource.remoteCSE.resourceName;
			}
			if(ischosen(p_contentResource.cSEBase)) {
				return p_contentResource.cSEBase.resourceName;
			}
			if(ischosen(p_contentResource.m2mServiceSubscriptionProfile)) {
				return p_contentResource.m2mServiceSubscriptionProfile.resourceName;
			}
			if(ischosen(p_contentResource.node)) {
				return p_contentResource.node.resourceName;
			}
			if(ischosen(p_contentResource.statsConfig)) {
				return p_contentResource.statsConfig.resourceName;
			}
			if(ischosen(p_contentResource.statsCollect)) {
				return p_contentResource.statsCollect.resourceName;
			}
			
			log(__SCOPE__&":WARNING: Primitive Content Kind not implemented");
			
			return "resourceNameNotFound";
			
		}
			
		/**
		 * @desc Resolution of the originator field (from) for a given resource
		 * @param p_targetResourceIndex Internal resource index of the given resource
		 * @param p_testSystemRole True if TS acting as an AE, False if TS acting as a CSE
		 * @return Originator for a given resource
		 * @verdict 
		 */
		function f_getOriginator(integer  p_targetResourceIndex := -1, boolean p_testSystemRole := true) runs on Tester return XSD.AnyURI {
				
			if(p_targetResourceIndex == -1) {
				if(p_testSystemRole) {
					return PX_SUPER_AE_ID;
				} else {
					return PX_SUPER_CSE_ID;
				}
			}	
			
			if(vc_resourcesList[p_targetResourceIndex].parentIndex == -1) {
				if(ischosen(vc_resourcesList[p_targetResourceIndex].resource.aE)) {
					return vc_resourcesList[p_targetResourceIndex].resource.aE.aE_ID;
				} else if (ischosen(vc_resourcesList[p_targetResourceIndex].resource.remoteCSE)) {
					return vc_resourcesList[p_targetResourceIndex].resource.remoteCSE.cSE_ID; 
				} else {
					return f_getOriginator(vc_resourcesList[p_targetResourceIndex].parentIndex);
				}
			} else {
				return f_getOriginator(vc_resourcesList[p_targetResourceIndex].parentIndex);
			}
		}
		
		/**
		 * @desc Resolution of the creator attribute for a given resource
		 * @param p_targetResourceIndex Internal resource index of the given resource
		 * @return AE-ID or CSE-ID of the entity creating the given resource
		 * @verdict 
		 */
		function f_getCreator(integer  p_targetResourceIndex := -1) runs on Tester return XSD.ID {
				
			if(p_targetResourceIndex == -1) {
				return PX_CSE_ID;
			}	
				
			if(ischosen(vc_resourcesList[p_targetResourceIndex].resource.aE)) {
				return vc_resourcesList[p_targetResourceIndex].resource.aE.aE_ID;
			} else {
				return f_getCreator(vc_resourcesList[p_targetResourceIndex].parentIndex);
			}
			
		}
			
		/**
		 * @desc Return of a index of a specific attribute from an attributeList by attributeName
		 * @param p_attributeList Target attributeList
		 * @param p_attributeName attributeName to be searched
		 * @return Index of the attribute in the attributeList
		 * @verdict 
		 */
		function f_getAttribute(in AttributeList p_attributeList, in XSD.NCName p_attributeName) return integer {
		var integer i;
			
		for (i:=0; i < lengthof(p_attributeList); i := i + 1){
			if(p_attributeList[i] == p_attributeName){
				return i;
			}	
		}
				
		return -1;
			
		}
		
		/**
		 * @desc Resolution of the announcement target CSE PoA
		 * @param p_protocolBinding	Protocol Binding
		 * @param p_announcementTargetAddress	Announcement Target Address
		 * @param p_announcementTargetResource Announcement Target Resource
		 * @return p_annoucementTargetPoA Announcemenet Target PoA
		 */
		function f_getAnnouncementTargetPoA(in charstring p_protocolBinding := PX_PROTOCOL_BINDING, in charstring p_announcementTargetAddress := PX_CSE1_ADDRESS, charstring p_announcementTargetResource := "" ) return charstring {
						
			if(p_protocolBinding == "HTTP") {
				return "http://" & p_announcementTargetAddress & "/" & p_announcementTargetResource;
			} else if (p_protocolBinding == "COAP") {
				return "coap://" & p_announcementTargetAddress & "/" & p_announcementTargetResource;
			} else if (p_protocolBinding == "MQTT") {
				return "mqtt://" & PX_SUT_ADDRESS & "/" & p_announcementTargetResource;//TODO
			} else {
				return "ws://" & p_announcementTargetAddress & "/" & p_announcementTargetResource;
			}
		}
			
    		
		/**
		 * @desc Resolution of the resource index for a given resource address (URI)
		 * @param p_address	Resource URI (can be structured/unstructured cseRelative/spRelative/absolute)
		 * @return Internal resource index of the given resource or -1 in case of error
		 */
		function f_getResourceIndex(in XSD.AnyURI p_address) runs on CseSimu return integer {
			return vc_cSEBaseIndex; //TODO
		}
    		
		/**
		 * @desc Resolution of the resource address field (to) for a given resource depending on addressing and hierarchical format 
		 * @param p_targetResourceIndex Internal resource index of the given resource
		 * @return Resource address for the given resource
		 * @verdict 
		 */
		function f_getResourceAddress(integer  p_targetResourceIndex := -1, AddressingMethod p_addressingMethod := PX_ADDRESSING_METHOD, PrimitiveScope p_primitiveScope := PX_PRIMITIVE_SCOPE) runs on Tester return XSD.ID {
			var XSD.ID v_resourceAddress;
			
			if(p_primitiveScope == e_cseRelative) {
					
				if(p_addressingMethod == e_nonHierarchical) {
					if(p_targetResourceIndex == -1) {
						return PX_CSE_RESOURCE_ID;
					} else {
						return f_getResourceId(vc_resourcesList[p_targetResourceIndex].resource);
					}
				} else {
					if(p_targetResourceIndex == -1) {
						return PX_CSE_NAME;
					} else {
						v_resourceAddress := f_getResourceAddress(vc_resourcesList[p_targetResourceIndex].parentIndex, p_addressingMethod, p_primitiveScope) & "/" & f_getResourceName(vc_resourcesList[p_targetResourceIndex].resource);
						return v_resourceAddress;
					}	
				}
					
			} else if (p_primitiveScope == e_spRelative) {
				if(p_addressingMethod == e_nonHierarchical) {
					if(p_targetResourceIndex == -1) {
						return PX_CSE_ID & "/" & PX_CSE_RESOURCE_ID;
					} else {
						v_resourceAddress := PX_CSE_ID & "/" & f_getResourceId(vc_resourcesList[p_targetResourceIndex].resource);
						return v_resourceAddress;
					}
				} else {
					if(p_targetResourceIndex == -1) {
						return PX_CSE_ID & "/" & PX_CSE_NAME;
					} else {
						v_resourceAddress := f_getResourceAddress(vc_resourcesList[p_targetResourceIndex].parentIndex, p_addressingMethod, p_primitiveScope) & "/" & f_getResourceName(vc_resourcesList[p_targetResourceIndex].resource);
						return v_resourceAddress;
					}
				}
			} else if (p_primitiveScope ==  e_absolute) {
				if(p_addressingMethod == e_nonHierarchical) {
					if(p_targetResourceIndex == -1) {
						return PX_SP_ID & PX_CSE_ID;
					} else {
						v_resourceAddress := f_getResourceAddress(-, p_addressingMethod, p_primitiveScope) & "/" & f_getResourceId(vc_resourcesList[p_targetResourceIndex].resource);
						return v_resourceAddress;
					}
				} else {
					if(p_targetResourceIndex == -1) {
						return PX_SP_ID & PX_CSE_ID & "/" & PX_CSE_NAME;
					} else {
						v_resourceAddress := f_getResourceAddress(vc_resourcesList[p_targetResourceIndex].parentIndex, p_addressingMethod, p_primitiveScope) & "/" & f_getResourceName(vc_resourcesList[p_targetResourceIndex].resource);
						return v_resourceAddress;
					}	
				}				
			} else {
				return "";
			}
				
		}
		
		/**
		 * @desc Resolution of the resource address field (to) for a given resource depending on addressing and hierarchical format 
		 * @param p_targetResourceIndex Internal resource index of the given resource
		 * @return Resource address for the given resource
		 * @verdict 
		 */
		function f_getLocalResourceAddress(integer  p_targetResourceIndex := -1, AddressingMethod p_addressingMethod := PX_ADDRESSING_METHOD, PrimitiveScope p_primitiveScope := PX_PRIMITIVE_SCOPE) runs on CseSimu return XSD.ID {
			var XSD.ID v_resourceAddress;
			
			if(p_primitiveScope == e_cseRelative) {
					
				if(p_addressingMethod == e_nonHierarchical) {
					if(p_targetResourceIndex == -1) {
						return PX_CSE1_RESOURCE_ID;
					} else {
						return f_getResourceId(vc_localResourcesList[p_targetResourceIndex].resource);
					}
				} else {
					if(p_targetResourceIndex == -1) {
						return PX_CSE1_NAME;
					} else {
						v_resourceAddress := f_getLocalResourceAddress(vc_localResourcesList[p_targetResourceIndex].parentIndex, p_addressingMethod, p_primitiveScope) & "/" & f_getResourceName(vc_localResourcesList[p_targetResourceIndex].resource);
						return v_resourceAddress;
					}	
				}
					
			} else if (p_primitiveScope == e_spRelative) {
				if(p_addressingMethod == e_nonHierarchical) {
					if(p_targetResourceIndex == -1) {
						return PX_CSE1_ID & "/" & PX_CSE1_RESOURCE_ID;
					} else {
						v_resourceAddress := PX_CSE_ID & "/" & f_getResourceId(vc_localResourcesList[p_targetResourceIndex].resource);
						return v_resourceAddress;
					}
				} else {
					if(p_targetResourceIndex == -1) {
						return PX_CSE1_ID & "/" & PX_CSE1_NAME;
					} else {
						v_resourceAddress := f_getLocalResourceAddress(vc_localResourcesList[p_targetResourceIndex].parentIndex, p_addressingMethod, p_primitiveScope) & "/" & f_getResourceName(vc_localResourcesList[p_targetResourceIndex].resource);
						return v_resourceAddress;
					}
				}
			} else if (p_primitiveScope ==  e_absolute) {
				if(p_addressingMethod == e_nonHierarchical) {
					if(p_targetResourceIndex == -1) {
						return PX_SP1_ID & PX_CSE1_ID;
					} else {
						v_resourceAddress := f_getLocalResourceAddress(-, p_addressingMethod, p_primitiveScope) & "/" & f_getResourceId(vc_localResourcesList[p_targetResourceIndex].resource);
						return v_resourceAddress;
					}
				} else {
					if(p_targetResourceIndex == -1) {
						return PX_SP1_ID & PX_CSE1_ID & "/" & PX_CSE1_NAME;
					} else {
						v_resourceAddress := f_getLocalResourceAddress(vc_localResourcesList[p_targetResourceIndex].parentIndex, p_addressingMethod, p_primitiveScope) & "/" & f_getResourceName(vc_localResourcesList[p_targetResourceIndex].resource);
						return v_resourceAddress;
					}	
				}				
			} else {
				return "";
			}
				
		}
		
		/**
		 * @desc Saving of a resource and its parent index in the internal resource list
		 * @param p_resource Resource to be saved
		 * @param p_parentIndex Parent index of resource to be saved
		 * @return Internal resource index of the saved resource
		 * @verdict 
		 */
		function f_setResource(PrimitiveContent p_resource, ResourceType p_resourceType, integer  p_parentIndex := -1, in boolean p_resourceToBeDeleted := true) runs on Tester return integer {
			var integer v_newIndex := -1;	
			if(isbound(vc_resourcesList)) {
				vc_resourcesList[lengthof(vc_resourcesList)] := {p_parentIndex, p_resourceType, p_resource};
			} else {
				vc_resourcesList[0] := {p_parentIndex, p_resourceType, p_resource};
			}
			
			v_newIndex := lengthof(vc_resourcesList)-1;
			if(p_resourceToBeDeleted) {
				if(match(int2, p_resourceType) or match(-1, p_parentIndex)) {//If created resource is an AE or created under CSEBase, it needs to be added to the resourceToBeDeleted list
					vc_resourcesIndexToBeDeleted := vc_resourcesIndexToBeDeleted & {v_newIndex};
				}
			}
			
			return v_newIndex;
						
		}
		
		/**
		 * @desc Saving of a local resource and its parent index in the internal resource list
		 * @param p_resource Resource to be saved
		 * @param p_parentIndex Parent index of resource to be saved
		 * @return Internal resource index of the saved resource
		 * @verdict 
		 */
		function f_setLocalResource(PrimitiveContent p_resource, ResourceType p_resourceType, integer  p_parentIndex := -1) runs on CseSimu return integer {
			var integer v_newIndex := -1;	
			if(isbound(vc_localResourcesList)) {
				vc_localResourcesList[lengthof(vc_localResourcesList)] := {p_parentIndex, p_resourceType, p_resource};
			} else {
				vc_localResourcesList[0] := {p_parentIndex, p_resourceType, p_resource};
			}
	
			v_newIndex := lengthof(vc_localResourcesList)-1;
	
			return v_newIndex;
				
		}
		
		/**
		 * @desc Set Acpid into the requestPrimitive
		 * @param p_requestPrimitive RequestPrimitive to be modified
		 * @param p_accessControlPolicyIDs AcpId to be set
		 * @return 
		 * @verdict 
		 */
		function f_setAcpId(template RequestPrimitive p_requestPrimitive, template AcpType p_accessControlPolicyIDs) runs on Tester return RequestPrimitive{
	
			if (ischosen(p_requestPrimitive.primitiveContent.aE)){
				p_requestPrimitive.primitiveContent.aE.accessControlPolicyIDs := p_accessControlPolicyIDs;
			}
			else if (ischosen(p_requestPrimitive.primitiveContent.container)){
				p_requestPrimitive.primitiveContent.container.accessControlPolicyIDs := p_accessControlPolicyIDs;
			}
			else if (ischosen(p_requestPrimitive.primitiveContent.group_)){
				p_requestPrimitive.primitiveContent.group_.accessControlPolicyIDs := p_accessControlPolicyIDs;
			}
			else if (ischosen(p_requestPrimitive.primitiveContent.serviceSubscribedAppRule)){
				p_requestPrimitive.primitiveContent.serviceSubscribedAppRule.accessControlPolicyIDs := p_accessControlPolicyIDs;
			}
			else if (ischosen(p_requestPrimitive.primitiveContent.subscription)){
				p_requestPrimitive.primitiveContent.subscription.accessControlPolicyIDs := p_accessControlPolicyIDs;
			}
			else if (ischosen(p_requestPrimitive.primitiveContent.locationPolicy)){
				p_requestPrimitive.primitiveContent.locationPolicy.accessControlPolicyIDs := p_accessControlPolicyIDs;
			}
			else if (ischosen(p_requestPrimitive.primitiveContent.delivery)){
				p_requestPrimitive.primitiveContent.delivery.accessControlPolicyIDs := p_accessControlPolicyIDs;
			}
			else if (ischosen(p_requestPrimitive.primitiveContent.mgmtCmd)){
				p_requestPrimitive.primitiveContent.mgmtCmd.accessControlPolicyIDs := p_accessControlPolicyIDs;
			}	
			else if (ischosen(p_requestPrimitive.primitiveContent.node)){
				p_requestPrimitive.primitiveContent.node.accessControlPolicyIDs := p_accessControlPolicyIDs;
			}	
			else if (ischosen(p_requestPrimitive.primitiveContent.remoteCSE)){
				p_requestPrimitive.primitiveContent.remoteCSE.accessControlPolicyIDs := p_accessControlPolicyIDs;
			}
			else if (ischosen(p_requestPrimitive.primitiveContent.request)){
				p_requestPrimitive.primitiveContent.request.accessControlPolicyIDs := p_accessControlPolicyIDs;
			}
			else if (ischosen(p_requestPrimitive.primitiveContent.statsCollect)){
				p_requestPrimitive.primitiveContent.statsCollect.accessControlPolicyIDs := p_accessControlPolicyIDs;
			}
			else if (ischosen(p_requestPrimitive.primitiveContent.statsConfig)){
				p_requestPrimitive.primitiveContent.statsConfig.accessControlPolicyIDs := p_accessControlPolicyIDs;
			} else {
				log( __SCOPE__, ":INFO: Resource not having acpi attribute. Not possible to set acpi")
			}
			return valueof(p_requestPrimitive);					
		}
		
		/**
		 * @desc Retrieve AE_ID for a given AE resource
		 * @param p_targetResourceIndex Internal resource index of the given resource
		 * @return AE_ID of the given resource
		 */
		function f_getAeId(integer  p_targetResourceIndex := -1) runs on Tester return XSD.ID {
			
			if(ischosen(vc_resourcesList[p_targetResourceIndex].resource.aE)) {
				return vc_resourcesList[p_targetResourceIndex].resource.aE.aE_ID;
			}
			
			log(__SCOPE__ & ":WARNING: p_targetResourceIndex does not refer to AE resource");
			return "";
			
		} // end f_getAeId
		
		/**
		 * @desc Retrieve Announced Resource Type from the given resource type
		 * @param p_targetResourceIndex Internal resource index of the given resource
		 * @return AE_ID of the given resource
		 */
		function f_getAnnouncedResourceType(in ResourceType p_resourceType) runs on Tester return ResourceType {
			
			if(p_resourceType == int2) {
				return int10002;
			}
			
			return p_resourceType;
			
			
		} // end f_getAnnouncedResourceType
    				
	}//end group getSetFunctions
	
	group CheckingFunctions {
	
		/**
		 * @desc It determines whether the addressing method of the given address is non-hierarchical. Not valid for CSE-Base as target
		 * @param p_resourceAddress
		 * @return boolean
		 */
		function f_isNonHierarchical(XSD.ID p_resourceAddress) runs on Tester return boolean {	
			var integer i;
			var integer v_nbOfSlashes:= 0;
    			
			for (i := 0; i < lengthof(p_resourceAddress); i:= i+1){
				if(p_resourceAddress[i] == "/"){
					v_nbOfSlashes:= v_nbOfSlashes+1;
				}
			}
				
			if(f_isScopeCseRelative(p_resourceAddress)) {
				if(v_nbOfSlashes == 0 ) {
					return true;
				} else {
					return false;
				}
    				
			} else if (f_isScopeSpRelative(p_resourceAddress)){	
				if(v_nbOfSlashes == 2 ) {
					return true;
				} else {
					return false;
				}
			} else if (f_isScopeAbsolute(p_resourceAddress)){
				if(v_nbOfSlashes == 4 ) {
					return true;
				} else {
					return false;
				}
			} else {
			   return false;
			}
		}
			
    		
		/**
		 * @desc It determines whether the addressing method of the given address is hierarchical. Not valid for CSE-Base as target
		 * @param p_resourceAddress
		 * @return boolean
		 */
		 function f_isHierarchical(XSD.ID p_resourceAddress) runs on Tester return boolean {
			if(f_isNonHierarchical(p_resourceAddress)) {
				return false;
			} else {
				return true;
			}	
		} 
			
		/**
		 * @desc It determines whether the primitive scope of the given address is CSE-Relative
		 * @param p_resourceAddress
		 * @return boolean
		 */
		function f_isScopeCseRelative(XSD.ID p_resourceAddress) runs on Tester return boolean { 
		  if (p_resourceAddress[0] != "/") {
			return true;
		  } else {
			return false;
		  }
		}
			
		/**
		 * @desc It determines whether the primitive scope of the given address is SP-Relative
		 * @param p_resourceAddress
		 * @return boolean
		 */
		function f_isScopeSpRelative(XSD.ID p_resourceAddress) runs on Tester return boolean {	
			if ((p_resourceAddress[0] == "/") and (p_resourceAddress[1] != "/")){
			  return true;
			} else {
			  return false;
			}
		}
			
		/**
		 * @desc It determines whether the primitive scope of the given address is Absolute
		 * @param p_resourceAddress
		 * @return boolean
		 */
		function f_isScopeAbsolute(XSD.ID p_resourceAddress) runs on Tester return boolean {
			if ((p_resourceAddress[0] == "/") and (p_resourceAddress[1] == "/")) {
			  return true;
			} else {
			  return false;
			}
		}
	
	
	
	}//end group CheckingFunctions
	
	group CommonFunctions {
		

		/**
		 * @desc Boolean to charstring
		 * @param p_bool
		 * @verdict 
		 */
		function f_checkAeSimuStatus() runs on AeSimu {
			
			if (getverdict != pass) {
				 f_cse_postamble_deleteResources();
				 // Tear down
				 if(vc_config == e_cf01) {
				 	f_cf01Down();
				 } else if (vc_config ==e_cf02) {
				 	vc_cse1.start(f_cse_postamble_deleteResourcesCSE());
				 	vc_cse1.done;
				 	f_cf02Down();
				 }
				 stop;
			}
		}
		
		/**
		 * @desc Sending of an Adapter Control primitive
		 * @param event Action to be performed by TA
		 * @param data Corresponding information for the correct execution of the given action
		 * @verdict 
		 */
		function f_checkComponentDoneAndGetVerdict(AeSimu p_ae) runs on AeSimu {
			
			var verdicttype v_verdict := none;

			tc_ac.start(15.0);
			alt {
				[] p_ae.done -> value v_verdict {
					tc_ac.stop;
				}
				[] tc_ac.timeout {
					setverdict(inconc, __SCOPE__ & "INFO: Component did not finish");
				}
			}			 
			
			if(v_verdict == pass) {         // Component was successfully completed and got stopped state
				setverdict(pass);
			} else {
				setverdict(inconc);            // Component was not completed successfully 
			}
			
			f_checkAeSimuStatus();
		} 
		
		/**
		 * @desc Sending of an Adapter Control primitive
		 * @param event Action to be performed by TA
		 * @param data Corresponding information for the correct execution of the given action
		 * @verdict 
		 */
		function f_checkCseSimuStatus() runs on CseSimu {
	
			if (getverdict != pass) {
				 //f_ae_postamble_deleteResources();
				 // Tear down
				 //f_cfAeTesterDown();
				f_cse_postamble_deleteResourcesCSE();
				if(vc_config == e_cf03) {
				  f_cf03Down();
				  stop;
			   	} else if (vc_config ==e_cf04) {
				  f_cf04Down();
				  stop;
				} else if (vc_config == e_cf02CseSimuMaster) {
					f_cf02DownCseSimuMaster();
					stop;
				}
			}
		}
		
		/**
		 * @desc Sending of an Adapter Control primitive
		 * @param event Action to be performed by TA
		 * @param data Corresponding information for the correct execution of the given action
		 * @verdict 
		 */
		function f_sendAcPrimitive(in charstring p_event, in charstring p_data) runs on Tester {
			

			var charstring v_data := "" & p_data; // clear encoding rules (ttwb issue ?)
			acPort.send(AcRequestPrimitive:{p_event, {charstring := v_data}});
			
		}
		
		function f_sendUtPrimitive(template UtTriggerPrimitive p_utRequest, in universal charstring p_action) runs on Tester {
			
			if (PX_UT_IMPLEMENTED){
				
				p_utRequest.from_ := "UNINITIALIZED";
				p_utRequest.requestIdentifier := "m_uttriggerPrimitive" & f_rnd(1, 1000000);

				utPort.send(valueof(p_utRequest));

				tc_wait.start;
				alt{
					[] utPort.receive(mw_utResponseOK) {
						tc_wait.stop;
						setverdict(pass, __SCOPE__, " : Triggering message is successfully received!");
					}
					[] utPort.receive(mw_utResponseKO) {
						tc_wait.stop;
						setverdict(inconc, __SCOPE__, " : Error while receiving Triggering message!");
					}
					[] tc_wait.timeout{
						setverdict(inconc, __SCOPE__, " : Timeout due to no response received from requested SUT!");
					}
				}
			
			}else{
				
				action(p_action);
			
			}
			
			

		}
 
		
		group AltstepFunctions {

			/**
			  * @desc	Default altstep
			  */
			 altstep a_default() runs on Tester {
			
				[] tc_wait.timeout {
					 setverdict(inconc, __SCOPE__&":INFO: Timeout while awaiting reaction of the IUT prior to Upper Tester action");
				}
				[] tc_ac.timeout {
					setverdict(inconc, __SCOPE__&":INFO: Timeout while awaiting the reception of a message");
				}
			 }				 

		}//end group altstepFunctions
		
		/**
		  * @desc	Get the Resource Identifier with Unstructured-CSE-relative -Resource-ID format
		  * @return	Cleaned-up resourceID
		  */
		function f_resourceIdCleaner(in XSD.ID p_resourceID) return XSD.ID {
			var integer v_length := lengthof(p_resourceID);
			var integer i;
			var XSD.ID result := "";
			
			//log("p_resourceID: " & p_resourceID);
			for (i := v_length - 1; i>=0; i := i-1){
				if(p_resourceID[i]=="/"){
					//log("result: " & result);
					return result;
				}
				else{
					result := p_resourceID[i] & result;
				}	
			}
			//log("result: " & result);
			return result;
		}
		
		/**
		 * @desc It removes the poa from a given url
		 * @param p_url URL
		 * @return Resource Identifier
		 * NOT USED FOR THE TIME BEING
		 */
		function f_removePoa(in XSD.ID p_url) return XSD.ID {
			var integer v_length := lengthof(p_url);
			var integer i;
			var integer v_numberOfColons := 0;
			var boolean v_lookForSlash := false;
			var boolean v_getURI := false;
			var XSD.ID v_uri := "";
			
			//TODO Process when FQDN is used in the URL
			for (i := 0; i<v_length; i := i + 1){
				if(v_getURI) {
					v_uri := v_uri & p_url[i];
				} else {
					if(p_url[i]==":"){
						v_numberOfColons := v_numberOfColons + 1;
					}
					if(v_numberOfColons >= 2) {
						v_lookForSlash := true;
					}
					if(v_lookForSlash) {
						if(p_url[i]=="/") {
							v_getURI := true;
						}
					}
				}
			}
			
			
			if(v_uri == "") {
				return p_url;
			} else {
				return v_uri;
			}
		}
		
		/**
		 * @desc Removal of an element from a given integer list
		 * @param p_list Given integer list
		 * @param p_valueToBeDeleted Element value to be removed
		 * @verdict 
		 */
		function f_removeElementFromList (inout IntegerList p_list, in integer p_valueToBeDeleted) {
			var IntegerList result := {};
			var integer i;
			for(i := 0; i < lengthof(p_list); i := i+1){
				if(p_list[i] != p_valueToBeDeleted){
					result := result & {p_list[i]};
				}
			}
			p_list := result;
		}
		
		/**
		 * @desc Build a reception template from the primitiveContent sent in previous request primitive
		 * @param p_primitiveContent PrimitiveContent from previous request primitive
		 * @return Built reception template
		 * @verdict 
		 */
		function f_getTemplateFromPrimitiveContent (in template PrimitiveContent p_primitiveContent) return template PrimitiveContent{
			var template PrimitiveContent v_primitiveContent := omit;
			
			if(ischosen(p_primitiveContent.container)){ // Container
				v_primitiveContent := {container := mw_contentContainerBase};
				
				if(ispresent(p_primitiveContent.container.labels)){
					v_primitiveContent.container.labels := ?;
				}
				if(ispresent(p_primitiveContent.container.accessControlPolicyIDs)){
					v_primitiveContent.container.accessControlPolicyIDs := ?;
				}
				if(ispresent(p_primitiveContent.container.announceTo)){
					v_primitiveContent.container.announceTo := ?;
				}
				if(ispresent(p_primitiveContent.container.announcedAttribute)){
					v_primitiveContent.container.announcedAttribute := ?;
				}
				if(ispresent(p_primitiveContent.container.creator)){
					v_primitiveContent.container.creator := ?;
				}
				if(ispresent(p_primitiveContent.container.maxNrOfInstances)){
					v_primitiveContent.container.maxNrOfInstances := ?;
				}
				if(ispresent(p_primitiveContent.container.maxByteSize)){
					v_primitiveContent.container.maxByteSize := ?;
				}
				if(ispresent(p_primitiveContent.container.maxInstanceAge)){
					v_primitiveContent.container.maxInstanceAge := ?;
				}
				if(ispresent(p_primitiveContent.container.locationID)){
					v_primitiveContent.container.locationID := ?;
				}
				if(ispresent(p_primitiveContent.container.ontologyRef)){
					v_primitiveContent.container.ontologyRef := ?;
				}
			}
			
			else if(ischosen(p_primitiveContent.aE)){ // AE
				v_primitiveContent := {aE := mw_contentAeBase};
				
				if(ispresent(p_primitiveContent.aE.labels)){
					v_primitiveContent.aE.labels := ?;
				}
				if(ispresent(p_primitiveContent.aE.accessControlPolicyIDs)){
					v_primitiveContent.aE.accessControlPolicyIDs := ?;
				}
				if(ispresent(p_primitiveContent.aE.announceTo)){
					v_primitiveContent.aE.announceTo := ?;
				}
				if(ispresent(p_primitiveContent.aE.announcedAttribute)){
					v_primitiveContent.aE.announcedAttribute := ?;
				}
				if(ispresent(p_primitiveContent.aE.appName)){
					v_primitiveContent.aE.appName := ?;
				}
				if(ispresent(p_primitiveContent.aE.pointOfAccess)){
					v_primitiveContent.aE.pointOfAccess := ?;
				}
				if(ispresent(p_primitiveContent.aE.ontologyRef)){
					v_primitiveContent.aE.ontologyRef := ?;
				}
				if(ispresent(p_primitiveContent.aE.nodeLink)){
					v_primitiveContent.aE.nodeLink := ?;
				}
				if(ispresent(p_primitiveContent.aE.contentSerialization)){
					v_primitiveContent.aE.contentSerialization := ?;
				}
			}
			
			else if(ischosen(p_primitiveContent.accessControlPolicy)){ // ACP
				v_primitiveContent := {accessControlPolicy := mw_contentAcpBase};
	
				if(ispresent(p_primitiveContent.accessControlPolicy.labels)){
					v_primitiveContent.accessControlPolicy.labels := ?;
				}
				if(ispresent(p_primitiveContent.accessControlPolicy.announceTo)){
					v_primitiveContent.accessControlPolicy.announceTo := ?;
				}
			}
			
			else if(ischosen(p_primitiveContent.contentInstance)){ // ContentInstance
				v_primitiveContent := {contentInstance := mw_contentContentInstanceBase};

				if(ispresent(p_primitiveContent.contentInstance.labels)){
					v_primitiveContent.contentInstance.labels := ?;
				}
				if(ispresent(p_primitiveContent.contentInstance.announceTo)){
					v_primitiveContent.contentInstance.announceTo := ?;
				}
				if(ispresent(p_primitiveContent.contentInstance.announcedAttribute)){
					v_primitiveContent.contentInstance.announcedAttribute := ?;
				}
				if(ispresent(p_primitiveContent.contentInstance.creator)){
					v_primitiveContent.contentInstance.creator := ?;
				}
				if(ispresent(p_primitiveContent.contentInstance.contentInfo)){
					v_primitiveContent.contentInstance.contentInfo := ?;
				}
				if(ispresent(p_primitiveContent.contentInstance.ontologyRef)){
					v_primitiveContent.contentInstance.ontologyRef := ?;
				}
			}
			
			else if(ischosen(p_primitiveContent.group_)){ // Group
				v_primitiveContent := {group_ := mw_contentGroupBase};

				if(ispresent(p_primitiveContent.group_.labels)){
					v_primitiveContent.group_.labels := ?;
				}
				if(ispresent(p_primitiveContent.group_.accessControlPolicyIDs)){
					v_primitiveContent.group_.accessControlPolicyIDs := ?;
				}
				if(ispresent(p_primitiveContent.group_.announceTo)){
					v_primitiveContent.group_.announceTo := ?;
				}
				if(ispresent(p_primitiveContent.group_.announcedAttribute)){
					v_primitiveContent.group_.announcedAttribute := ?;
				}
				if(ispresent(p_primitiveContent.group_.creator)){
					v_primitiveContent.group_.creator := ?;
				}
				if(ispresent(p_primitiveContent.group_.membersAccessControlPolicyIDs)){
					v_primitiveContent.group_.membersAccessControlPolicyIDs := ?;
				}
				if(ispresent(p_primitiveContent.group_.memberTypeValidated)){
					v_primitiveContent.group_.memberTypeValidated := ?;
				}
				if(ispresent(p_primitiveContent.group_.consistencyStrategy)){
					v_primitiveContent.group_.consistencyStrategy := ?;
				}
				if(ispresent(p_primitiveContent.group_.groupName)){
					v_primitiveContent.group_.groupName := ?;
				}
			}
			
			else if(ischosen(p_primitiveContent.pollingChannel)){ // PollingChannel
				v_primitiveContent := {pollingChannel := mw_contentPollingChannelBase};

				if(ispresent(p_primitiveContent.pollingChannel.labels)){
					v_primitiveContent.pollingChannel.labels := ?;
				}
			}
			
			else if(ischosen(p_primitiveContent.schedule)){ // Schedule
				v_primitiveContent := {schedule := mw_contentScheduleBase};

				if(ispresent(p_primitiveContent.schedule.labels)){
					v_primitiveContent.schedule.labels := ?;
				}
				if(ispresent(p_primitiveContent.schedule.announceTo)){
					v_primitiveContent.schedule.announceTo := ?;
				}
				if(ispresent(p_primitiveContent.schedule.announcedAttribute)){
					v_primitiveContent.schedule.announcedAttribute := ?;
				}
			}
			
			else if(ischosen(p_primitiveContent.subscription)){ // Subscription
				v_primitiveContent := {subscription := mw_contentSubscriptionBase};

				if(ispresent(p_primitiveContent.subscription.labels)){
					v_primitiveContent.subscription.labels := ?;
				}
				if(ispresent(p_primitiveContent.subscription.accessControlPolicyIDs)){
					v_primitiveContent.subscription.accessControlPolicyIDs := ?;
				}
				if(ispresent(p_primitiveContent.subscription.creator)){
					v_primitiveContent.subscription.creator := ?;
				}
				if(ispresent(p_primitiveContent.subscription.eventNotificationCriteria)){
					v_primitiveContent.subscription.eventNotificationCriteria := ?;
				}
				if(ispresent(p_primitiveContent.subscription.expirationCounter)){
					v_primitiveContent.subscription.expirationCounter := ?;
				}
				if(ispresent(p_primitiveContent.subscription.groupID)){
					v_primitiveContent.subscription.groupID := ?;
				}
				if(ispresent(p_primitiveContent.subscription.notificationForwardingURI)){
					v_primitiveContent.subscription.notificationForwardingURI := ?;
				}
				if(ispresent(p_primitiveContent.subscription.batchNotify)){
					v_primitiveContent.subscription.batchNotify := ?;
				}
				if(ispresent(p_primitiveContent.subscription.rateLimit)){
					v_primitiveContent.subscription.rateLimit := ?;
				}
				if(ispresent(p_primitiveContent.subscription.preSubscriptionNotify)){
					v_primitiveContent.subscription.preSubscriptionNotify := ?;
				}
				if(ispresent(p_primitiveContent.subscription.pendingNotification)){
					v_primitiveContent.subscription.pendingNotification := ?;
				}
				if(ispresent(p_primitiveContent.subscription.notificationStoragePriority)){
					v_primitiveContent.subscription.notificationStoragePriority := ?;
				}
				if(ispresent(p_primitiveContent.subscription.latestNotify)){
					v_primitiveContent.subscription.latestNotify := ?;
				}
				if(ispresent(p_primitiveContent.subscription.notificationContentType)){
					v_primitiveContent.subscription.notificationContentType := ?;
				}
				if(ispresent(p_primitiveContent.subscription.notificationEventCat)){
					v_primitiveContent.subscription.notificationEventCat := ?;
				}
				if(ispresent(p_primitiveContent.subscription.subscriberURI)){
					v_primitiveContent.subscription.subscriberURI := ?;
				}
			}
			else if(ischosen(p_primitiveContent.remoteCSE)){ //remoteCSE
				v_primitiveContent := {remoteCSE := mw_contentRemoteCSEBase};
				  
				if(ispresent(p_primitiveContent.remoteCSE.labels)){
					v_primitiveContent.remoteCSE.labels := ?;			    
				}
				  
				if(ispresent(p_primitiveContent.remoteCSE.accessControlPolicyIDs)){
					v_primitiveContent.remoteCSE.accessControlPolicyIDs := ?;			    
				}
				 				
				if(ispresent(p_primitiveContent.remoteCSE.announceTo)){
					v_primitiveContent.remoteCSE.announceTo := ?;			    
				}
				 
				if(ispresent(p_primitiveContent.remoteCSE.announcedAttribute)){
					v_primitiveContent.remoteCSE.announcedAttribute := ?;			    
				}
				
				if(ispresent(p_primitiveContent.remoteCSE.cseType)){
					v_primitiveContent.remoteCSE.cseType := ?;			    
				}
				  
				if(ispresent(p_primitiveContent.remoteCSE.pointOfAccess)){
					v_primitiveContent.remoteCSE.pointOfAccess := ?;			    
				}
				  
				if(ispresent(p_primitiveContent.remoteCSE.m2M_Ext_ID)){
					v_primitiveContent.remoteCSE.m2M_Ext_ID := ?;			    
				}
				  
				if(ispresent(p_primitiveContent.remoteCSE.trigger_Recipient_ID)){
					v_primitiveContent.remoteCSE.trigger_Recipient_ID := ?;			    
				}
				  
				if(ispresent(p_primitiveContent.remoteCSE.nodeLink)){
					v_primitiveContent.remoteCSE.nodeLink := ?;			    
				}
			}			
			return v_primitiveContent;
		}
		
		/**
		 * @desc Comparison of two primitiveContent parameters
		 * @param p_responsePrimitiveContent Received primitiveContent
		 * @param p_requestPrimitiveContent Sent primitiveContent
		 * @verdict 
		 */
		function f_match2PrimitiveContent (in PrimitiveContent p_responsePrimitiveContent, in template PrimitiveContent p_requestPrimitiveContent) runs on Tester {
			var template PrimitiveContent v_primitiveContent;
			var PrimitiveContent v_response;
			v_response := p_responsePrimitiveContent;
			v_primitiveContent := f_getTemplateFromPrimitiveContent(p_requestPrimitiveContent);
			if(not(match(v_response, v_primitiveContent))){
				setverdict(inconc, __SCOPE__&":INFO: Resource incomplete, some attribute missing ");
			}

		}		
		
		/**
		 * @desc Retrieve Year from a given timestamp
		 * @param p_timestamp Given timestamp
		 * @return Year
		 */
		function f_getYear(charstring p_timestamp) runs on Tester return charstring {
			
			var charstring v_year;
			var integer i;
			
			for(i := 0; i < 3; i := i+1){
				v_year := v_year & p_timestamp[i];
			}
			return v_year;
			
		} // end f_getYear
		
		/**
		 * @desc Retrieve IP address from a given address which includes port information separated by :
		 * @param p_addressPort Given address
		 * @return IPv4 Address
		 */
		function f_getIpv4Address(charstring p_addressPort) runs on Tester return charstring {
			
			var charstring v_ipv4Address;
			var integer i:= 0;
			
			while ((i < lengthof(p_addressPort)-1) and (p_addressPort[i] != ":")){
				v_ipv4Address := v_ipv4Address & p_addressPort[i];
				i := i + 1;
			}
			return v_ipv4Address;
			
		} // end f_getIpv4Address
		
	}//end of commonFunctions
	
	group externalFunctions {
		
		/**
		 * @desc Generates a oneM2M timestamp based on current time. 
		 * 		 Format shall be YYYYMMDDTHHMMSS 
		 */		
		external function fx_generateTimestamp() return charstring;

	} // end externalFunctions
	
}  // end of module