-
Miguel Angel Reina Ortega authored
Signed-off-by:
reinaortega <miguelangel.reinaortega@etsi.org>
Miguel Angel Reina Ortega authoredSigned-off-by:
reinaortega <miguelangel.reinaortega@etsi.org>
OneM2M_Functions.ttcn 229.70 KiB
/**
* 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 oneM2M/ETSI
* @desc Module containing functions for oneM2M
*
*/
module OneM2M_Functions {
import from XSD all;
import from OneM2M_Templates all;
import from OneM2M_Types all;
import from OneM2M_Ports 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 system CseSystem {
// Variables
var charstring v_binding;
var charstring v_binding_in;
var charstring v_host;
//Initialization of component variables
vc_config := e_cf01;
vc_testSystemRole := e_ae;
// Map
map(self:mcaPort, system:mcaPort) param (PX_TS_AE1.mcaPort);
map(self:mcaPortIn, system:mcaPortIn) param (PX_TS_AE1.mcaPortIn);
map(self:acPort, system:acPort);
if (ischosen(PX_TS_AE1.mcaPort.binding.httpBindingDesc)) { // FIXME Create a function to initialize vc_myInterfaces
v_binding := "HTTP";
v_host := PX_TS_AE1.mcaPort.binding.httpBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE1.mcaPort.binding.httpBindingDesc.bindingDesc.remotePort);
} else if (ischosen(PX_TS_AE1.mcaPort.binding.coapBindingDesc)) {
v_binding := "COAP";
v_host := PX_TS_AE1.mcaPort.binding.coapBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE1.mcaPort.binding.coapBindingDesc.bindingDesc.remotePort);
} else if (ischosen(PX_TS_AE1.mcaPort.binding.mqttBindingDesc)) {
v_binding := "MQTT";
v_host := PX_TS_AE1.mcaPort.binding.mqttBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE1.mcaPort.binding.mqttBindingDesc.bindingDesc.remotePort);
} else {
v_binding := "WSCK";
v_host := PX_TS_AE1.mcaPort.binding.wsBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE1.mcaPort.binding.wsBindingDesc.bindingDesc.remotePort);
}
if (ischosen(PX_TS_AE1.mcaPortIn.binding.httpBindingDesc)) {
v_binding_in := "HTTP";
} else if (ischosen(PX_TS_AE1.mcaPortIn.binding.coapBindingDesc)) {
v_binding_in := "COAP";
} else if (ischosen(PX_TS_AE1.mcaPortIn.binding.mqttBindingDesc)) {
v_binding_in := "MQTT";
} else {
v_binding_in := "WSCK";
}
vc_myInterfaces[enum2int(valueof(InterfaceIds:e_mca_port))] := { mcaPort, v_host, v_binding, c_serializationLabel[enum2int(PX_TS_AE1.mcaPort.serialization)] };
vc_myInterfaces[enum2int(valueof(InterfaceIds:e_mca_in_port))] := { mcaPortIn, v_host, v_binding_in, c_serializationLabel[enum2int(PX_TS_AE1.mcaPortIn.serialization)] };
activate(a_default());
vc_aeSimu := 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 system CseSystem {
// Variables
var charstring v_binding;
var charstring v_binding_in;
var charstring v_host;
//Initialization of component variables
vc_config := e_cf01;
vc_testSystemRole := e_ae;
// Map
map(self:mcaPort, system:mcaPort) param (PX_TS_AE2.mcaPort);
map(self:mcaPortIn, system:mcaPortIn) param (PX_TS_AE2.mcaPortIn);
map(self:acPort, system:acPort);
if (ischosen(PX_TS_AE2.mcaPort.binding.httpBindingDesc)) {
v_binding := "HTTP";
v_host := PX_TS_AE2.mcaPort.binding.httpBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE2.mcaPort.binding.httpBindingDesc.bindingDesc.remotePort);
} else if (ischosen(PX_TS_AE2.mcaPort.binding.coapBindingDesc)) {
v_binding := "COAP";
v_host := PX_TS_AE2.mcaPort.binding.coapBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE2.mcaPort.binding.coapBindingDesc.bindingDesc.remotePort);
} else if (ischosen(PX_TS_AE2.mcaPort.binding.mqttBindingDesc)) {
v_binding := "MQTT";
v_host := PX_TS_AE2.mcaPort.binding.mqttBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE2.mcaPort.binding.mqttBindingDesc.bindingDesc.remotePort);
} else {
v_binding := "WSCK";
v_host := PX_TS_AE2.mcaPort.binding.wsBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE2.mcaPort.binding.wsBindingDesc.bindingDesc.remotePort);
}
if (ischosen(PX_TS_AE2.mcaPortIn.binding.httpBindingDesc)) {
v_binding_in := "HTTP";
} else if (ischosen(PX_TS_AE2.mcaPortIn.binding.coapBindingDesc)) {
v_binding_in := "COAP";
} else if (ischosen(PX_TS_AE2.mcaPortIn.binding.mqttBindingDesc)) {
v_binding_in := "MQTT";
} else {
v_binding_in := "WSCK";
}
vc_myInterfaces[enum2int(valueof(InterfaceIds:e_mca_port))] := { mcaPort, v_host, v_binding, c_serializationLabel[enum2int(PX_TS_AE2.mcaPort.serialization)] };
vc_myInterfaces[enum2int(valueof(InterfaceIds:e_mca_in_port))] := { mcaPortIn, v_host, v_binding_in, c_serializationLabel[enum2int(PX_TS_AE2.mcaPortIn.serialization)] };
//Initialze the IUT
} // end f_cf01UpAe2
/**
* @desc Ports mapping and default behaviour activation for Config 02
*/
function f_cf02Up(in CseTypeID p_cseType := int2) runs on AeSimu system CseSystem {
// Variables
var charstring v_binding;
var charstring v_host;
//Initialization of component variables
vc_config := e_cf02;
vc_testSystemRole := e_ae;
vc_cse1 := CseSimu.create("CSE1") alive;
// Map
map(self:mcaPort, system:mcaPort) param (PX_TS_AE1.mcaPort);
map(self:acPort, system:acPort);
if(PX_UT_IMPLEMENTED) {
map(self:utPort, system:utPort) param (PX_TS_UT);
}
if (ischosen(PX_TS_AE1.mcaPort.binding.httpBindingDesc)) {
v_binding := "HTTP";
v_host := PX_TS_AE1.mcaPort.binding.httpBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE1.mcaPort.binding.httpBindingDesc.bindingDesc.remotePort);
} else if (ischosen(PX_TS_AE1.mcaPort.binding.coapBindingDesc)) {
v_binding := "COAP";
v_host := PX_TS_AE1.mcaPort.binding.coapBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE1.mcaPort.binding.coapBindingDesc.bindingDesc.remotePort);
} else if (ischosen(PX_TS_AE1.mcaPort.binding.mqttBindingDesc)) {
v_binding := "MQTT";
v_host := PX_TS_AE1.mcaPort.binding.mqttBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE1.mcaPort.binding.mqttBindingDesc.bindingDesc.remotePort);
} else {
v_binding := "WSCK";
v_host := PX_TS_AE1.mcaPort.binding.wsBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE1.mcaPort.binding.wsBindingDesc.bindingDesc.remotePort);
}
vc_myInterfaces[enum2int(valueof(InterfaceIds:e_mca_port))] := { mcaPort, v_host, v_binding, c_serializationLabel[enum2int(PX_TS_AE1.mcaPort.serialization)] };
activate(a_default());
vc_aeSimu := activate(a_cse_cf02_ae1());
vc_cse1.start(f_cf02UpCse1(p_cseType));
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(in CseTypeID p_cseType := int2) runs on CseSimu system CseSystem {
// Variables
var charstring v_binding;
var charstring v_binding_in;
var charstring v_host;
var PrimitiveContent v_cSEBaseResource;
//Initialization of component variables
vc_config := e_cf02;
vc_testSystemRole := e_cse;
vc_cseType := p_cseType;
// Map
map(self:mccPort, system:mccPort) param (PX_TS_CSE1.mccPort);
map(self:mccPortIn, system:mccPortIn) param (PX_TS_CSE1.mccPortIn);
map(self:acPort, system:acPort);
if (ischosen(PX_TS_CSE1.mccPort.binding.httpBindingDesc)) {
v_binding := "HTTP";
v_host := PX_TS_CSE1.mcaPort.binding.httpBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mccPort.binding.httpBindingDesc.bindingDesc.remotePort);
} else if (ischosen(PX_TS_CSE1.mccPort.binding.coapBindingDesc)) {
v_binding := "COAP";
v_host := PX_TS_CSE1.mcaPort.binding.coapBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mccPort.binding.coapBindingDesc.bindingDesc.remotePort);
} else if (ischosen(PX_TS_CSE1.mccPort.binding.mqttBindingDesc)) {
v_binding := "MQTT";
v_host := PX_TS_CSE1.mcaPort.binding.mqttBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mccPort.binding.mqttBindingDesc.bindingDesc.remotePort);
} else {
v_binding := "WSCK";
v_host := PX_TS_CSE1.mcaPort.binding.wsBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mccPort.binding.wsBindingDesc.bindingDesc.remotePort);
}
if (ischosen(PX_TS_CSE1.mccPortIn.binding.httpBindingDesc)) {
v_binding_in := "HTTP";
} else if (ischosen(PX_TS_CSE1.mccPortIn.binding.coapBindingDesc)) {
v_binding_in := "COAP";
} else if (ischosen(PX_TS_CSE1.mccPortIn.binding.mqttBindingDesc)) {
v_binding_in := "MQTT";
} else {
v_binding_in := "WSCK";
}
vc_myInterfaces[enum2int(valueof(InterfaceIds:e_mcc_port))] := { mccPort, v_host, v_binding, c_serializationLabel[enum2int(PX_TS_CSE1.mccPort.serialization)] };
vc_myInterfaces[enum2int(valueof(InterfaceIds:e_mcc_in_port))] := { mccPortIn, v_host, v_binding, c_serializationLabel[enum2int(PX_TS_CSE1.mccPortIn.serialization)] };
v_cSEBaseResource := f_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(in CseTypeID p_cseType := int2) runs on CseSimu system CseSystem {
// Variables
var charstring v_binding;
var charstring v_binding_in;
var charstring v_host;
var PrimitiveContent v_cSEBaseResource;
//Initialization of component variables
vc_config := e_cf02CseSimuMaster;
vc_testSystemRole := e_cse;
vc_cseType := p_cseType;
vc_ae1 := AeSimu.create("AE1") alive;
//Initialization of local CSEBase
v_cSEBaseResource := f_generateLocalResource(-, -1, int5);
vc_cSEBaseIndex := f_setLocalResource(v_cSEBaseResource, int5, -1);
// Map
map(self:mccPort, system:mccPort) param (PX_TS_CSE1.mccPort);
map(self:mccPortIn, system:mccPortIn) param (PX_TS_CSE1.mccPortIn);
map(self:acPort, system:acPort);
if(PX_UT_IMPLEMENTED) {
map(self:utPort, system:utPort) param (PX_TS_UT);
}
if (ischosen(PX_TS_CSE1.mccPort.binding.httpBindingDesc)) {
v_binding := "HTTP";
v_host := PX_TS_CSE1.mccPort.binding.httpBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mccPort.binding.httpBindingDesc.bindingDesc.remotePort);
} else if (ischosen(PX_TS_CSE1.mccPort.binding.coapBindingDesc)) {
v_binding := "COAP";
v_host := PX_TS_CSE1.mccPort.binding.coapBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mccPort.binding.coapBindingDesc.bindingDesc.remotePort);
} else if (ischosen(PX_TS_CSE1.mccPort.binding.mqttBindingDesc)) {
v_binding := "MQTT";
v_host := PX_TS_CSE1.mccPort.binding.mqttBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mccPort.binding.mqttBindingDesc.bindingDesc.remotePort);
} else {
v_binding := "WSCK";
v_host := PX_TS_CSE1.mccPort.binding.wsBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mccPort.binding.wsBindingDesc.bindingDesc.remotePort);
}
if (ischosen(PX_TS_CSE1.mccPortIn.binding.httpBindingDesc)) {
v_binding_in := "HTTP";
} else if (ischosen(PX_TS_CSE1.mccPortIn.binding.coapBindingDesc)) {
v_binding_in := "COAP";
} else if (ischosen(PX_TS_CSE1.mccPortIn.binding.mqttBindingDesc)) {
v_binding_in := "MQTT";
} else {
v_binding_in := "WSCK";
}
vc_myInterfaces[enum2int(valueof(InterfaceIds:e_mcc_port))] := { mccPort, v_host, v_binding, c_serializationLabel[enum2int(PX_TS_CSE1.mccPort.serialization)] };
vc_myInterfaces[enum2int(valueof(InterfaceIds:e_mcc_in_port))] := { mccPortIn, v_host, v_binding_in, c_serializationLabel[enum2int(PX_TS_CSE1.mccPortIn.serialization)] };
activate(a_default());
vc_cseSimu := activate(a_cse_cf02_cse1());
vc_ae1.start(f_cf02UpAe1());
vc_ae1.done;
// Connect
//Initialze the IUT
} // end f_cf02UpCseSimuMaster
/**
@desc Ports mapping and default behaviour activation for Config 2 on the AE1
*/
function f_cf02UpAe1(in CseTypeID p_cseType := int2) runs on AeSimu system CseSystem {
// Variables
var charstring v_binding;
var charstring v_binding_in;
var charstring v_host;
vc_config := e_cf02CseSimuMaster;
vc_testSystemRole := e_ae;
// Map
map(self:mcaPort, system:mcaPort) param (PX_TS_AE1.mcaPort);
map(self:mcaPortIn, system:mcaPortIn) param (PX_TS_AE1.mcaPortIn);
map(self:acPort, system:acPort);
if (ischosen(PX_TS_AE1.mcaPort.binding.httpBindingDesc)) {
v_binding := "HTTP";
v_host := PX_TS_AE1.mcaPort.binding.httpBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE1.mcaPort.binding.httpBindingDesc.bindingDesc.remotePort);
} else if (ischosen(PX_TS_AE1.mcaPort.binding.coapBindingDesc)) {
v_binding := "COAP";
v_host := PX_TS_AE1.mcaPort.binding.httpBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE1.mcaPort.binding.coapBindingDesc.bindingDesc.remotePort);
} else if (ischosen(PX_TS_AE1.mcaPort.binding.mqttBindingDesc)) {
v_binding := "MQTT";
v_host := PX_TS_AE1.mcaPort.binding.httpBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE1.mcaPort.binding.mqttBindingDesc.bindingDesc.remotePort);
} else {
v_binding := "WSCK";
v_host := PX_TS_AE1.mcaPort.binding.httpBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_AE1.mcaPort.binding.wsBindingDesc.bindingDesc.remotePort);
}
if (ischosen(PX_TS_AE1.mcaPortIn.binding.httpBindingDesc)) {
v_binding_in := "HTTP";
} else if (ischosen(PX_TS_AE1.mcaPortIn.binding.coapBindingDesc)) {
v_binding_in := "COAP";
} else if (ischosen(PX_TS_AE1.mcaPortIn.binding.mqttBindingDesc)) {
v_binding_in := "MQTT";
} else {
v_binding_in := "WSCK";
}
vc_myInterfaces[enum2int(valueof(InterfaceIds:e_mca_port))] := { mcaPort, v_host, v_binding, c_serializationLabel[enum2int(PX_TS_AE1.mcaPort.serialization)] };
vc_myInterfaces[enum2int(valueof(InterfaceIds:e_mca_in_port))] := { mcaPortIn, v_host, v_binding_in, c_serializationLabel[enum2int(PX_TS_AE1.mcaPortIn.serialization)] };
//Initialze the IUT
} // end f_cf02UpAe1
/**
* @desc Ports mapping and default behaviour activation for Config 03
*/
function f_cf03Up(in CseTypeID p_cseType := int2) runs on CseSimu system AeSystem {
// Variables
var charstring v_binding;
var PrimitiveContent v_cSEBaseResource;
var charstring v_host;
//Initialization of component variables
vc_config := e_cf03;
vc_testSystemRole := e_cse;
vc_cseType := p_cseType;
//Creation of CSEBase
v_cSEBaseResource := f_generateLocalResource(-, -1, int5);
vc_cSEBaseIndex := f_setLocalResource(v_cSEBaseResource, int5, -1);
// Map
map(self:mcaPortIn, system:mcaPortIn) param (PX_TS_CSE1.mcaPortIn);//TODO To be consistent, we should use mcaPortIn for AE testing
map(self:acPort, system:acPort);
if (ischosen(PX_TS_CSE1.mcaPortIn.binding.httpBindingDesc)) {
v_binding := "HTTP";
v_host := PX_TS_CSE1.mcaPortIn.binding.httpBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mcaPortIn.binding.httpBindingDesc.bindingDesc.remotePort);
} else if (ischosen(PX_TS_CSE1.mcaPortIn.binding.coapBindingDesc)) {
v_binding := "COAP";
v_host := PX_TS_CSE1.mcaPortIn.binding.coapBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mcaPortIn.binding.coapBindingDesc.bindingDesc.remotePort);
} else if (ischosen(PX_TS_CSE1.mcaPortIn.binding.mqttBindingDesc)) {
v_binding := "MQTT";
v_host := PX_TS_CSE1.mcaPortIn.binding.mqttBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mcaPortIn.binding.mqttBindingDesc.bindingDesc.remotePort);
} else {
v_binding := "WSCK";
v_host := PX_TS_CSE1.mcaPortIn.binding.wsBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mcaPortIn.binding.wsBindingDesc.bindingDesc.remotePort);
}
vc_myInterfaces[enum2int(valueof(InterfaceIds:e_mca_in_port))] := { mcaPortIn, v_host, v_binding, c_serializationLabel[enum2int(PX_TS_CSE1.mcaPortIn.serialization)] };
if(PX_UT_IMPLEMENTED) {
map(self:utPort, system:utPort) param (PX_TS_UT);
}
activate(a_default());
vc_cseSimu := activate(a_cse_cf03());
// Connect
//Initialze the IUT
} // end f_cf03Up
/**
* @desc Ports mapping and default behaviour activation for Config 04
*/
function f_cf04Up(in CseTypeID p_cseType := int2) runs on CseSimu system CseSystem {
// Variables
var charstring v_binding;
var charstring v_binding_in;
var PrimitiveContent v_cSEBaseResource;
var charstring v_host;
//Initialization of component variables
vc_config := e_cf04;
vc_testSystemRole := e_cse;
vc_cseType := p_cseType;
////Initialization of local CSEBase
v_cSEBaseResource := f_generateLocalResource(-, -1, int5);
vc_cSEBaseIndex := f_setLocalResource(v_cSEBaseResource, int5, -1);
// Map
map(self:mccPort, system:mccPort) param (PX_TS_CSE1.mccPort);
map(self:mccPortIn, system:mccPortIn) param (PX_TS_CSE1.mccPortIn);
map(self:acPort, system:acPort);
if(PX_UT_IMPLEMENTED) {
map(self:utPort, system:utPort) param (PX_TS_UT);
}
if (ischosen(PX_TS_CSE1.mccPort.binding.httpBindingDesc)) {
v_binding := "HTTP";
v_host := PX_TS_CSE1.mccPort.binding.httpBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mccPort.binding.httpBindingDesc.bindingDesc.remotePort);
} else if (ischosen(PX_TS_CSE1.mccPort.binding.coapBindingDesc)) {
v_binding := "COAP";
v_host := PX_TS_CSE1.mccPort.binding.coapBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mccPort.binding.coapBindingDesc.bindingDesc.remotePort);
} else if (ischosen(PX_TS_CSE1.mccPort.binding.mqttBindingDesc)) {
v_binding := "MQTT";
v_host := PX_TS_CSE1.mccPort.binding.mqttBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mccPort.binding.mqttBindingDesc.bindingDesc.remotePort);
} else {
v_binding := "WSCK";
v_host := PX_TS_CSE1.mccPort.binding.wsBindingDesc.bindingDesc.sutAddress & ":" & int2str(PX_TS_CSE1.mccPort.binding.wsBindingDesc.bindingDesc.remotePort);
}
if (ischosen(PX_TS_CSE1.mccPortIn.binding.httpBindingDesc)) {
v_binding_in := "HTTP";
} else if (ischosen(PX_TS_CSE1.mccPortIn.binding.coapBindingDesc)) {
v_binding_in := "COAP";
} else if (ischosen(PX_TS_CSE1.mccPortIn.binding.mqttBindingDesc)) {
v_binding_in := "MQTT";
} else {
v_binding_in := "WSCK";
}
vc_myInterfaces[enum2int(valueof(InterfaceIds:e_mcc_port))] := { mccPort, v_host, v_binding, c_serializationLabel[enum2int(PX_TS_CSE1.mccPort.serialization)] };
vc_myInterfaces[enum2int(valueof(InterfaceIds:e_mcc_in_port))] := { mccPortIn, v_host, v_binding_in, c_serializationLabel[enum2int(PX_TS_CSE1.mccPortIn.serialization)] };
activate(a_default());
vc_cseSimu := activate(a_cse_cf04());
// Connect
//Initialize the IUT
} // end f_cf04Up
/**
* @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;
}
}// end f_cf01Down
/**
* @desc Ports unmapping
*/
function f_cf01DownAe2() runs on AeSimu {
unmap(self:mcaPort, system:mcaPort);
unmap(self:acPort, system:acPort);
unmap(self:mcaPortIn, system:mcaPortIn);
}// end f_cf01DownAe2
/**
* @desc Ports unmapping
*/
function f_cf02Down() runs on AeSimu {
unmap(self:mcaPort, system:mcaPort);
unmap(self:acPort, system:acPort);
if(PX_UT_IMPLEMENTED){
unmap(self:utPort, system:utPort);
}
unmap(vc_cse1:mccPort, system:mccPort);
unmap(vc_cse1:mccPortIn, system:mccPortIn);
unmap(vc_cse1:acPort, system:acPort);
}// end f_cf02Down
/**
* @desc Ports unmapping
*/
function f_cf02DownCseSimuMaster() runs on CseSimu {
unmap(self:mccPort, system:mccPort);
unmap(self:mccPortIn, system:mccPortIn);
unmap(self:acPort, system:acPort);
if(PX_UT_IMPLEMENTED){
unmap(self:utPort, system:utPort);
}
unmap(vc_ae1:mcaPort, system:mcaPort);
unmap(vc_ae1:acPort, system:acPort);
}// end f_cf02DownCseSimuMaster
/**
* @desc Ports unmapping for Config 03
*/
function f_cf03Down() runs on CseSimu {
unmap(self:mcaPortIn, system:mcaPortIn);
unmap(self:acPort, system:acPort);
if(PX_UT_IMPLEMENTED){
unmap(self:utPort, system:utPort);
}
}// end f_cf03Down
/**
* @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);
if(PX_UT_IMPLEMENTED){
unmap(self:utPort, system:utPort);
}
}// end f_cf04Down
}//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);
}
group getFunctions {
/**
* @desc Getting last responsePrimitive saved in a component
* @param p_tester Given component
*/
function f_getResponsePrimitive(in Tester p_component) runs on Tester return ResponsePrimitive {
var ResponsePrimitive v_response;
f_connectInfoPort(p_component);
p_component.start(f_sendResponsePrimitive());
alt {
[]infoPort.receive(mw_responsePrimitiveforInfoPort) -> value v_response {
}
}
p_component.done;
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 {
}
}
p_component.done;
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 {
}
}
p_ae.done;
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);
}
}
p_cse.done;
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_getResourceFromAeSimu(in AeSimu 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_sendResourceAeSimu(p_resourceIndex));
alt {
[]infoPort.receive(mw_resource) -> value v_resource {
v_resourceIndex := f_setResource(v_resource.resource, v_resource.resourceType, v_resource.parentIndex, false);
}
}
p_component.done;
f_disconnectInfoPort(p_component);
return v_resourceIndex;
}
/**
* @desc Getting a specific resource from an CseSimu component
* @param p_tester AeSimu component
* @param p_resourceIndex Index of resource to be retrieved
*/
function f_getResourceFromCseSimu(in CseSimu p_component, in integer p_resourceIndex := -1) runs on Tester return integer {
var MyResource v_resource;
var integer v_resourceIndex := -1;
f_connectInfoPort(p_component);
p_component.start(f_sendResourceCseSimu(p_resourceIndex));
alt {
[]infoPort.receive(mw_resource) -> value v_resource {
v_resourceIndex := f_setResource(v_resource.resource, v_resource.resourceType, v_resource.parentIndex, false);
}
}
p_component.done;
f_disconnectInfoPort(p_component);
return v_resourceIndex;
}
/**
* @desc Getting the latest resource from an AeSimu component
* @param p_tester AeSimu component
* @param p_resourceIndex Index of resource to be retrieved
*/
function f_getLatestResource(in Tester p_component) runs on Tester return integer {
var MyResource v_resource;
var integer v_resourceIndex := -1;
f_connectInfoPort(p_component);
p_component.start(f_sendLatestResource());
alt {
[]infoPort.receive(mw_resource) -> value v_resource {
v_resourceIndex := f_setResource(v_resource.resource, v_resource.resourceType, v_resource.parentIndex, false);
}
}
p_component.done;
f_disconnectInfoPort(p_component);
return v_resourceIndex;
}
/**
* @desc Getting last resourceIndex saved in the vc_resourcesList
* @param p_tester Given component
*/
function f_getLatestResourceIndex(in Tester p_component) runs on Tester return integer {
var integer v_resourceIndex;
f_connectInfoPort(p_component);
p_component.start(f_sendLatestResourceIndex());
alt {
[]infoPort.receive(mw_resourceIndex) -> value v_resourceIndex{
}
}
p_component.done;
f_disconnectInfoPort(p_component);
return v_resourceIndex;
}
/**
* @desc Getting the latest local resource from an CseSimu component
* @param p_component CseSimu component
* @param p_resourceIndex Index of resource to be retrieved
*/
function f_getLatestLocalResource(in CseSimu p_component) runs on Tester return integer {
var MyResource v_resource;
var integer v_resourceIndex := -1;
f_connectInfoPort(p_component);
p_component.start(f_sendLatestLocalResource());
alt {
[]infoPort.receive(mw_resource) -> value v_resource {
v_resourceIndex := f_setResource(v_resource.resource, v_resource.resourceType, v_resource.parentIndex, false);//TODO To set correctly parentIndex
}
}
p_component.done;
f_disconnectInfoPort(p_component);
return v_resourceIndex;
}
/**
* @desc Getting last local resourceIndex saved in the vc_localResourcesList
* @param p_tester Given component
*/
function f_getLatestLocalResourceIndex(in CseSimu p_component) runs on Tester return integer {
var integer v_resourceIndex;
f_connectInfoPort(p_component);
p_component.start(f_sendLatestLocalResourceIndex());
alt {
[]infoPort.receive(mw_resourceIndex) -> value v_resourceIndex{
}
}
p_component.done;
f_disconnectInfoPort(p_component);
return v_resourceIndex;
}
/**
* @desc Getting the address of the last local resource saved in the vc_localResourcesList
* @param p_tester Given component
*/
function f_getLatestLocalResourceAddress(in CseSimu p_component, AddressingMethod p_addressingMethod := PX_ADDRESSING_METHOD, PrimitiveScope p_primitiveScope := PX_PRIMITIVE_SCOPE) runs on Tester return XSD.ID {
var XSD.ID v_localResourceAddress;
f_connectInfoPort(p_component);
p_component.start(f_sendLatestLocalResourceAddress(p_addressingMethod, p_primitiveScope));
alt {
[]infoPort.receive(mw_resourceAddress) -> value v_localResourceAddress{
}
}
p_component.done;
f_disconnectInfoPort(p_component);
return v_localResourceAddress;
}
}//end of group getFunctions
group sendFunctions {
/**
* @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_sendResourceAeSimu(in integer p_resourceIndex) runs on AeSimu {
if(p_resourceIndex == -1) {
infoPort.send(vc_resourcesList[vc_aeAuxIndex]);
} else {
infoPort.send(vc_resourcesList[p_resourceIndex]);
}
}
/**
* @desc Sending of a specific resource through InfoPort
* @param p_resourceIndex Index of resource to be sent
*/
function f_sendResourceCseSimu(in integer p_resourceIndex) runs on CseSimu {
if(p_resourceIndex == -1) {
infoPort.send(vc_resourcesList[vc_remoteCseIndex]);
} else {
infoPort.send(vc_resourcesList[p_resourceIndex]);
}
}
/**
* @desc Sending of the latest resource through InfoPort
*/
function f_sendLatestResource() runs on Tester {
infoPort.send(vc_resourcesList[lengthof(vc_resourcesList)-1]);
}
/**
* @desc Sending of last resourceIndex saved in the vc_resourcesList
*/
function f_sendLatestResourceIndex() runs on Tester {
infoPort.send(lengthof(vc_resourcesList)-1);
}
/**
* @desc Sending of the latest local resource through InfoPort
*/
function f_sendLatestLocalResource() runs on CseSimu {
infoPort.send(vc_localResourcesList[lengthof(vc_localResourcesList)-1]);
}
/**
* @desc Sending the address of the last resource saved in the vc_resourcesList
*/
function f_sendLatestLocalResourceAddress(AddressingMethod p_addressingMethod := PX_ADDRESSING_METHOD, PrimitiveScope p_primitiveScope := PX_PRIMITIVE_SCOPE) runs on CseSimu {
infoPort.send(f_getLocalResourceAddress(lengthof(vc_localResourcesList)-1, p_addressingMethod, p_primitiveScope));
}
/**
* @desc Sending of last local resourceIndex saved in the vc_localResourcesList
*/
function f_sendLatestLocalResourceIndex() runs on CseSimu {
infoPort.send(lengthof(vc_localResourcesList)-1);
}
}//end of group sendFunctions
}// end of group 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;
//Activate defaults when running on a PTC
f_cse_activateDefaults_ae();
v_request := valueof(m_createAeAux(p_accessControlPolicyIDs, p_poaList));
v_request := f_getCreateRequestPrimitive(int2, v_request, -1);
f_send(e_mca_port, 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;
//Activate defaults when running on a PTC
f_cse_activateDefaults_ae();
if(PICS_ACP_SUPPORT){
vc_acpAuxIndex := f_cse_createAccessControlPolicyAux(p_allowedOperations := p_allowedOperations);
}
if(vc_acpAuxIndex != -1) {
vc_resourcesIndexToBeDeleted := {vc_acpAuxIndex};//TODO Not needed
v_request := valueof(m_createAe(p_appId, {f_getResourceId(vc_resourcesList[vc_acpAuxIndex].resource)}, -));
//TODO Test, to be removed
v_request.to_ := f_getResourceAddress();
f_send(e_mca_port, m_request(v_request));
//f_send(e_mca_port, m_request(m_createAeAux(p_name, {PX_URI_CSE & PX_CSE_NAME & "/" & PX_ACPAUX_NAME})));
} else {
f_send(e_mca_port, 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_TS_AE1.appId}, 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_TS_AE1.appId}, 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_createAccessControlPolicyAux("SubscriptionVerificationAcp",{"all"}, int63));
f_aeSimu_checkComponentDoneAndGetVerdict(vc_ae2);
vc_ae2.start(f_cse_createResource_withAcpAux(int2, m_createAe(PX_TS_AE2.appId, -, PX_TS_AE2.aeIdStem, c_defaultAE2Name, {f_getCompletePoA(PX_TS_AE2.mcaPortIn, "")}), -1)); // AE2 is registred
f_aeSimu_checkComponentDoneAndGetVerdict(vc_ae2);
p_ae2Index := f_getResourceFromAeSimu(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_config == e_cf02) {
if(vc_cse1.alive) {
f_cse_postamble_cse1();
}
}
if(vc_auxiliaryAe2Up) {
if (vc_ae2.alive) {
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]);
f_send(e_mca_port, 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 Calls to postamble for CseSimu component (i.e. CSE1) on AeSimu
* @verdict
*/
function f_cse_postamble_cse1() runs on AeSimu {
if(vc_cse1.running) {
vc_cse1.stop;
}
vc_cse1.start(f_cse_postamble_deleteResourcesCSE());
vc_cse1.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 integer v_resourceIndex := -1;
var URIList v_childResourceRefs;
var XSD.ID v_resourceAddress;
var RequestPrimitive v_request;
var boolean v_deregistrationPerformed := false;
var template UtTriggerPrimitive v_utRequest := m_utDelete;
var universal charstring v_action := __SCOPE__ & ": Please, perform deregistration by sending a valid DELETE Request for remoteCSE to ";
if (PX_RUN_POSTAMBLE) {
if(vc_config == e_cf02CseSimuMaster) {
if(vc_ae1.alive) {
f_cse_postamble_ae1();
}
};
for(i := lengthof(vc_resourcesIndexToBeDeleted) -1; i >=0; i := i - 1) {
v_resourceIndex := vc_resourcesIndexToBeDeleted[i];
if(ischosen(vc_resourcesList[v_resourceIndex].resource.remoteCSE)) {
v_resourceAddress := f_getResourceAddress(v_resourceIndex, e_nonHierarchical, e_spRelative);
v_deregistrationPerformed := true;
} else {
v_resourceAddress := f_getResourceAddress(v_resourceIndex);
}
v_request := valueof(m_delete(v_resourceAddress, f_getOriginator(v_resourceIndex, vc_testSystemRole)));
f_send(e_mcc_port, 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_);
}
}
}
//CSE Registration initiated by IUT - Test System to start CSE deregistration by:
//1) Started by Registrar (Test System)
//2) Started by Registree (IUT) by sending an UT message
if(not(v_deregistrationPerformed)) {
if(vc_localRemoteCseIndex != -1) {
//1) Deregistration by Registrar (Test System)
v_childResourceRefs := f_cse_retrieveChildResourceRefs_cseSimu({int16}, -, f_getOriginator(vc_remoteCseIndex));
if(v_childResourceRefs != {}) {
//v_request := valueof(m_delete(v_childResourceRefs[0], f_getOriginator(vc_remoteCseIndex)));
v_request := valueof(m_delete(v_childResourceRefs[0]));//TODO Originator super user to be replaced by CSE1_ID (line above)
f_send(e_mcc_port, 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");
v_deregistrationPerformed := true;
}
[] 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_);
}
}
}
}
if(not(v_deregistrationPerformed)) {
if(vc_localRemoteCseIndex != -1) {
//Deregistration by Registree (IUT) - Send trigger message for deregistration
v_utRequest.requestPrimitive.to_ := f_getLocalResourceAddress(vc_localRemoteCseIndex);
f_sendUtPrimitive(v_utRequest, v_action & f_getLocalResourceAddress(vc_localRemoteCseIndex));
tc_ac.start;
alt {
[] mccPortIn.receive(mw_request(mw_delete(f_getLocalResourceAddress(vc_localRemoteCseIndex)))) -> value vc_request {
tc_ac.stop;
f_processDeleteRequestPrimitive(vc_request.primitive.requestPrimitive);
f_send(e_mcc_in_port, m_response(vc_response.primitive.responsePrimitive));
log(__SCOPE__&": INFO: Deregistration performed successfully");
}
[] tc_ac.timeout {
log(__SCOPE__&": INFO: No deregistration performed");
}
}
}
}
}
}
}
}//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;
//Activate defaults when running on a PTC
f_cse_activateDefaults_ae();
v_request := f_getCreateRequestPrimitive(p_resourceType, p_requestPrimitive, p_parentIndex);
f_send(e_mca_port, 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 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_withAcpAux(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;
//Activate defaults when running on a PTC
f_cse_activateDefaults_ae();
if(vc_acpAuxIndex != -1) {
p_requestPrimitive := f_setAcpId(p_requestPrimitive, {vc_resourcesList[vc_acpAuxIndex].resource.accessControlPolicy.resourceID});
}
v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive, p_parentIndex);
return v_resourceIndex;
}
/**
* @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_acor := p_acor, p_allowedOperations := p_allowedOperations));
v_request := f_getCreateRequestPrimitive(int1, v_request, -1);
f_send(e_mca_port, 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_resourceType Resource type of the resource to be created
* @param p_requestPrimitive UPDATE request primitive to be used
* @param p_resourceIndex Internal resource index which indicates the resource to be updated
* @verdict
*/
function f_cse_updateResource(in ResourceType p_resourceType, integer p_resourceIndex, template RequestPrimitive p_request, template (omit) AttributeAux_list p_nullFields := omit) runs on AeSimu {
var RequestPrimitive v_request;
//Activate defaults when running on a PTC
f_cse_activateDefaults_ae();
v_request := f_getUpdateRequestPrimitive(p_resourceType, p_resourceIndex, p_request);
f_send(e_mca_port, m_request(valueof(v_request), p_nullFields));
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{
f_send(e_mca_port, 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");
}
[] 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);
}
f_send(e_mca_port, 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 Message exchange for any operation on a resource
* @param p_requestPrimitive Request primitive to be sent
* @return PrimitiveContent parameter of the operation response
* @verdict
*/
function f_cse_operationResource(template RequestPrimitive p_requestPrimitive) runs on AeSimu return PrimitiveContent{
f_send(e_mca_port, m_request(valueof(p_requestPrimitive)));
tc_ac.start;
alt {
[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) -> value vc_response {
tc_ac.stop;
setverdict(pass, __SCOPE__&":INFO: Success operation on resource");
}
[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) -> value vc_response {
tc_ac.stop;
setverdict(inconc, __SCOPE__&":INFO: Error on the operation on resource");
}
[] tc_ac.timeout {
setverdict(inconc, __SCOPE__&":INFO: No answer while operation on resource");
}
}
f_checkAeSimuStatus();
return vc_response.primitive.responsePrimitive.primitiveContent;
}// end f_cse_operationResource
/**
* @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_cse_isResourcePresent (integer p_resourceIndex) runs on AeSimu return boolean {
//Check to see if the resource is present or not
f_send(e_mca_port, 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 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 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
f_send(e_mca_port, 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.requestIdentifier := valueof(v_request.requestIdentifier) & f_rnd(1, 1000000);
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))};
f_send(e_mca_port, 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 Sending of a request primitive over mca port
* @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_sendCreateRequestPrimitive(in ResourceType p_resourceType, template RequestPrimitive p_requestPrimitive := m_create, integer p_parentIndex := -1) runs on AeSimu {
var RequestPrimitive v_request;
v_request := f_getCreateRequestPrimitive(p_resourceType, p_requestPrimitive, p_parentIndex);
f_send(e_mca_port, m_request(v_request));
}
/**
* @desc Sending of a request primitive over mca port
* @param p_resourceType Resource type of the resource to be created
* @param p_requestPrimitive UPDATE 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_sendUpdateRequestPrimitive(in ResourceType p_resourceType, template RequestPrimitive p_requestUpdatePrimitive := m_update, integer p_targetIndex := -1) runs on AeSimu {
var RequestPrimitive v_request;
v_request := f_getUpdateRequestPrimitive(p_resourceType, p_targetIndex, p_requestUpdatePrimitive);
f_send(e_mca_port, m_request(v_request));
}
/**
* @desc Receive response from the IUT
* @param p_requestPrimtive Received request primitive
*/
function f_cse_receiveResponse(in RequestPrimitive p_request) runs on AeSimu {
var integer v_resourceIndex := -1;
//Activate defaults when running on a PTC
f_cse_activateDefaults_ae();
tc_ac.start;
alt {
[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) -> value vc_response {
tc_ac.stop;
setverdict(pass, __SCOPE__&":INFO: Response received with positive response status code");
f_checkAttributesToBeSaved(p_request.resourceType, p_request, vc_response.primitive.responsePrimitive);
v_resourceIndex := f_setResource(vc_response.primitive.responsePrimitive.primitiveContent, p_request.resourceType);
}
[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) -> value vc_response {
tc_ac.stop;
setverdict(pass, __SCOPE__&":INFO: Response received with negative response status code");
}
[] tc_ac.timeout {
setverdict(inconc, __SCOPE__&":INFO: No response received");
}
}
}
function f_cse_generateMissingDataPoint(in integer p_timeSeriesResourceIndex) runs on AeSimu{
var RequestPrimitive v_request;
var integer v_resourceIndex := -1;
var integer i;
var XSD.NonNegativeInteger v_periodicInterval := vc_resourcesList[p_timeSeriesResourceIndex].resource.timeSeries.periodicInterval;
var XSD.NonNegativeInteger v_missingDataDetectTimer := vc_resourcesList[p_timeSeriesResourceIndex].resource.timeSeries.missingDataDetectTimer;
timer t_noAction;
//Activate defaults when running on a PTC
f_cse_activateDefaults_ae();
i := 0;
while (i < 3) {
v_request := f_getCreateRequestPrimitive(int30, m_createTimeSeriesInstanceBase, p_timeSeriesResourceIndex);
v_request.primitiveContent.timeSeriesInstance.resourceName := "MyTimeSeriesInstance" & int2str(i);
v_resourceIndex := f_cse_createResource(int30, v_request, p_timeSeriesResourceIndex);
i := i + 1;
t_noAction.start(int2float(v_periodicInterval));
}
//After missingDataTimerDetect, a missing data point should have been detected
t_noAction.start(int2float(v_missingDataDetectTimer));
}
}//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;
//Activate defaults when running on a PTC
f_cse_activateDefaults_ae();
//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) {
f_send(e_mca_in_port, m_httpResponse(v_responsePrimitive));
} else {
v_responsePrimitive.responseStatusCode := int4000;
f_send(e_mca_in_port, m_httpResponse(v_responsePrimitive));
}
//mcaPort.send(m_response(v_responsePrimitive)); // TODO have to be deleted
} //end f_subscriptionVerificationHandler
/**
* @desc Default handling message exchange for the notification procedure
* @verdict
*/
function f_cse_notifyProcedure_defaultHandler() runs on AeSimu {
// Local variables
var ResponsePrimitive v_responsePrimitive;
//Activate defaults when running on a PTC
f_cse_activateDefaults_ae();
tc_ac.start;
alt {
[] mcaPortIn.receive(mw_request(mw_notifyNotification(mw_contentNotification(?)))) -> value vc_request {
tc_ac.stop;
setverdict(pass, __SCOPE__ & ":INFO: Notification received");
//Send response in any case
v_responsePrimitive := valueof(m_responseNotification(int2000, omit));
v_responsePrimitive.requestIdentifier := vc_request.primitive.requestPrimitive.requestIdentifier;
f_send(e_mca_in_port, m_response(v_responsePrimitive));
tc_ac.start;
repeat;
}
[] mcaPortIn.receive{
tc_ac.stop;
setverdict(inconc, __SCOPE__ & ":ERROR: unexpected message received");
tc_ac.start;
repeat;
}
}
} //end f_cse_notifyProcedure_defaultHandler
/**
* @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;
//Activate defaults when running on a PTC
f_cse_activateDefaults_ae();
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(int2000, omit));
v_responsePrimitive.requestIdentifier := vc_request.primitive.requestPrimitive.requestIdentifier;
f_send(e_mca_in_port, 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
* @param p_responsePrimitive Expected responsePrimitive in the notification
* @verdict
*/
function f_cse_notifyProcedure_responsePrimitiveHandler(template ResponsePrimitive p_responsePrimitive) runs on AeSimu {
// Local variables
var ResponsePrimitive v_responsePrimitive;
//Activate defaults when running on a PTC
f_cse_activateDefaults_ae();
tc_ac.start;
alt {
[] mcaPortIn.receive(mw_request(mw_notifyResponsePrimitive(p_responsePrimitive))) -> value vc_request {
tc_ac.stop;
setverdict(pass, __SCOPE__ & ":INFO: Notification received with the expected content");
v_responsePrimitive := valueof(m_responseNotification(int2000, omit));
v_responsePrimitive.requestIdentifier := vc_request.primitive.requestPrimitive.requestIdentifier;
}
[] mcaPortIn.receive(mw_request(mw_notifyResponsePrimitive(?))) -> value vc_request {
tc_ac.stop;
setverdict(fail, __SCOPE__ & ":ERROR: Notification received but the content doesn't match");
v_responsePrimitive := valueof(m_responseNotification(int2000, omit));
v_responsePrimitive.requestIdentifier := vc_request.primitive.requestPrimitive.requestIdentifier;
}
[] tc_ac.timeout {
setverdict(fail, __SCOPE__ & ":ERROR: No notification received");
}
}
if(isvalue(v_responsePrimitive)) {
f_send(e_mca_in_port, m_response(v_responsePrimitive));
}
} //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;
//Activate defaults when running on a PTC
f_cse_activateDefaults_ae();
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(int2000, omit));
v_responsePrimitive.requestIdentifier := vc_request.primitive.requestPrimitive.requestIdentifier;
f_send(e_mca_in_port, 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(int2000, omit));
v_responsePrimitive.requestIdentifier := vc_request.primitive.requestPrimitive.requestIdentifier;
f_send(e_mca_in_port, m_response(v_responsePrimitive));
v_notificationsReceived := v_notificationsReceived + 1;
if(v_notificationsReceived < p_numberOfAggregatedNotification) {
tc_ac.start;
repeat;
}
}
[] 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;
//Activate defaults when running on a PTC
f_cse_activateDefaults_ae();
tc_ac.start;
alt {
[] mcaPortIn.receive(mw_request(mw_notifyNotification(p_notification))) -> value vc_request {
tc_ac.stop;
v_responsePrimitive := valueof(m_responseNotification(int2000, omit));
v_responsePrimitive.requestIdentifier := vc_request.primitive.requestPrimitive.requestIdentifier;
f_send(e_mca_in_port, 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
//Activate defaults when running on a PTC
f_cse_activateDefaults_ae();
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");
}
[] mcaPortIn.receive(mw_request(mw_notifyResponsePrimitive(?))) -> 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 Message exchange for notification
* @param p_requestPrimitive Notify request to be used for the notification
* @verdict
*/
function f_cse_notifyProcedure_notify(template RequestPrimitive p_requestPrimitive) runs on CseSimu {
// Local variables
var ResponsePrimitive v_responsePrimitive;
var integer v_resourceIndex := -1;
//p_requestPrimitive.from_ := PX_CSE1_ID;
p_requestPrimitive.from_ := f_getOriginator(vc_remoteCseIndex, e_cse);
f_send(e_mcc_port, m_request(valueof(p_requestPrimitive)));
tc_ac.start;
alt {
[] mccPort.receive(mw_response(mw_responseNotify(int2000))) -> value vc_response {
tc_ac.stop;
}
[] mccPort.receive(mw_response(mw_responsePrimitiveKO)) {
tc_ac.stop;
setverdict(inconc, __SCOPE__&":INFO: Error while performing notification");
}
[] mccPort.receive {
tc_ac.stop;
setverdict(inconc, __SCOPE__&":INFO: Unexpected message received");
}
[] tc_ac.timeout {
setverdict(inconc, __SCOPE__&":INFO: No answer while performing notification");
}
}
f_checkCseSimuStatus();
} //end f_cse_notifyProcedure_notify
}// end of group NotificationFunctions
group AnnouncementFunctions {
/**
* @desc Handling of announcement of resources
* @param p_requestPrimitive Expected announcement primitive
* @param p_responseStatusCode Response Status code to be sent as response
* @param p_expectedResourceIndex Expected target parent resource of the announcemnet
* @verdict
*/
function f_cse_announcementProcedure_createHandler(template RequestPrimitive p_requestprimitive := ?, in ResponseStatusCode p_responseStatusCode := int2001, template(omit) integer p_expectedResourceIndex := omit) runs on CseSimu return integer{
// Local variables
var MsgIn v_request;
var integer v_parentIndex := vc_localRemoteCseIndex;
var integer v_announcedResourceIndex;
var ResponsePrimitive v_responsePrimitive;
var PrimitiveContent v_announcedResource;
//Activate defaults when running on a PTC
f_cse_activateDefaults_cse1();
tc_ac.start;
alt {
[] mccPortIn.receive(mw_request(p_requestprimitive)) -> value v_request {
tc_ac.stop;
setverdict(pass, __SCOPE__ & ":INFO: Expected Announcement received");
v_parentIndex := f_getLocalResourceIndex(v_request.primitive.requestPrimitive.to_);
if(v_parentIndex == -1) {
log(__SCOPE__&": ERROR: Target resource not found");
v_responsePrimitive := valueof(m_responsePrimitive(int4004,v_request.primitive.requestPrimitive.requestIdentifier));
} else {
//Save resource and generate required attributes
v_announcedResource:= f_generateLocalResource(v_request.primitive.requestPrimitive.primitiveContent, v_parentIndex,v_request.primitive.requestPrimitive.resourceType);
v_announcedResourceIndex := f_setLocalResource(v_announcedResource, v_request.primitive.requestPrimitive.resourceType, v_parentIndex);
if(isvalue(p_expectedResourceIndex)){
if(valueof(p_expectedResourceIndex) == v_parentIndex){
setverdict(pass, __SCOPE__ & ":INFO: Announcement Parent Resource Address matched");
v_responsePrimitive := valueof(m_responsePrimitive(p_responseStatusCode,v_request.primitive.requestPrimitive.requestIdentifier));
v_responsePrimitive.primitiveContent := vc_localResourcesList[v_announcedResourceIndex].resource;
} else {
setverdict(fail, __SCOPE__ & ":ERROR: Announcement Parent Resource Address not matched");
v_responsePrimitive := valueof(m_responsePrimitive(int4000,v_request.primitive.requestPrimitive.requestIdentifier));
v_responsePrimitive.primitiveContent := omit;
}
} else {
v_responsePrimitive := valueof(m_responsePrimitive(p_responseStatusCode,v_request.primitive.requestPrimitive.requestIdentifier));
if(p_responseStatusCode == int2001) {
v_responsePrimitive.primitiveContent := vc_localResourcesList[v_announcedResourceIndex].resource;
} else {
v_responsePrimitive.primitiveContent := omit;
}
}
}
v_responsePrimitive.from_ := PX_TS_CSE1.cseId;
v_responsePrimitive.to_ := v_request.primitive.requestPrimitive.from_;
f_send(e_mcc_in_port, m_response(v_responsePrimitive));
}
[] mccPortIn.receive(mw_request(?)) -> value v_request {
tc_ac.stop;
setverdict(fail, __SCOPE__ & ":ERROR: Request received with unexpected parameters");
v_responsePrimitive := valueof(m_responsePrimitive(int4000,v_request.primitive.requestPrimitive.requestIdentifier));
f_send(e_mcc_in_port, m_response(v_responsePrimitive));
}
[] tc_ac.timeout {
setverdict(fail, __SCOPE__ & ":ERROR: No announcement received");
}
}
f_checkCseSimuStatus();
return v_announcedResourceIndex;
} //end f_cse_announcementProcedure_createHandler
/**
* @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_announcementProcedure_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);
f_send(e_mcc_port, 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_announcementProcedure_announceResource
/**
* @desc Handling message exchange for the AE Annc update
* @verdict
*/
//TODO TO BE FINALIZED
function f_cse_announcementProcedure_updateHandler(template RequestPrimitive p_requestprimitive := mw_update, in ResponseStatusCode p_responseStatusCode := int2004, template(omit) integer p_expectedResourceIndex := omit) runs on CseSimu {
// Local variables
var MsgIn v_request;
var integer v_parentIndex := vc_localRemoteCseIndex;
var integer v_announcedResourceIndex;
var ResponsePrimitive v_responsePrimitive;
var PrimitiveContent v_announcedResource;
//Activate defaults when running on a PTC
f_cse_activateDefaults_cse1();
tc_ac.start;
alt {
[] mccPortIn.receive(mw_request(p_requestprimitive)) -> value v_request {
tc_ac.stop;
setverdict(pass, __SCOPE__ & ":INFO: Expected UPDATE Announcement received");
f_processUpdateRequestPrimitive(v_request.primitive.requestPrimitive);
f_send(e_mcc_in_port, m_response(vc_response.primitive.responsePrimitive));
}
[] mccPortIn.receive(mw_request(?)) -> value v_request {
setverdict(fail, __SCOPE__ & ":ERROR: Request received with unexpected parameters");
v_responsePrimitive := valueof(m_responsePrimitive(int4000,v_request.primitive.requestPrimitive.requestIdentifier));
f_send(e_mcc_in_port, m_response(v_responsePrimitive));
}
[] tc_ac.timeout {
setverdict(fail, __SCOPE__ & ":ERROR: No announcement received");
}
}
f_checkCseSimuStatus();
} //end f_cse_announcementProcedure_updateHandler
/**
* @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_announcementProcedure_deleteHandler(template RequestPrimitive p_requestprimitive := mw_delete, in ResponseStatusCode p_responseStatusCode := int2002, template(omit) integer p_expectedResourceIndex := omit) runs on CseSimu {
// Local variables
var MsgIn v_request;
var integer v_parentIndex := vc_localRemoteCseIndex;
var integer v_announcedResourceIndex;
var ResponsePrimitive v_responsePrimitive;
var PrimitiveContent v_announcedResource;
//Activate defaults when running on a PTC
f_cse_activateDefaults_cse1();
tc_ac.start;
alt {
[] mccPortIn.receive(mw_request(p_requestprimitive)) -> value v_request {
tc_ac.stop;
setverdict(pass, __SCOPE__ & ":INFO: Expected DELETE Announcement received");
f_processDeleteRequestPrimitive(v_request.primitive.requestPrimitive);
f_send(e_mcc_in_port, m_response(vc_response.primitive.responsePrimitive));
}
[] mccPortIn.receive(mw_request(?)) -> value v_request {
setverdict(fail, __SCOPE__ & ":ERROR: Request received with unexpected parameters");
v_responsePrimitive := valueof(m_responsePrimitive(int4000,v_request.primitive.requestPrimitive.requestIdentifier));
f_send(e_mcc_in_port, m_response(v_responsePrimitive));
}
[] tc_ac.timeout {
setverdict(fail, __SCOPE__ & ":ERROR: No announcement received");
}
}
f_checkCseSimuStatus();
} //end f_cse_announcementProcedure_deleteHandler
}//end of group AnnouncementFunctions
/**
* @desc Message exchange for the creation of a resource
* @param p_resourceType Resource type of the resource to be created
* @param p_requestPrimitive UPDATE request primitive to be used
* @param p_resourceIndex Internal resource index which indicates the resource to be updated
* @verdict
*/
function f_cse_createResourceHandler(template RequestPrimitive p_request := mw_create) runs on CseSimu return integer{
var integer v_localResourceIndex;
//Activate defaults when running on a PTC
f_cse_activateDefaults_cse1();
tc_ac.start;
alt {
[] mccPortIn.receive(mw_request(p_request)) -> value vc_request {
tc_ac.stop;
v_localResourceIndex := f_processCreateRequestPrimitive(vc_request.primitive.requestPrimitive);
f_send(e_mcc_in_port, m_response(vc_response.primitive.responsePrimitive));
}
[] tc_ac.timeout {
setverdict(inconc, __SCOPE__&":INFO: No creation for resource received");
}
}
f_checkCseSimuStatus();
return v_localResourceIndex;
}// end f_cse_createResourceHandler
/**
* @desc Creation of a local 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_createLocalResource(template UtTriggerPrimitive p_utRequest := m_utCreate, charstring p_action) runs on CseSimu return integer {
var ResponsePrimitive v_response;
var integer v_parentResourceIndex := -1;
var integer v_localResourceIndex := -1;
var PrimitiveContent v_localResource;
//Activate defaults when running on a PTC
f_cse_activateDefaults_cse1();
f_sendUtPrimitive(p_utRequest, p_action);
tc_ac.start;
alt {
[] mccPortIn.receive(mw_request(mw_create(?,?))) -> value vc_request {
tc_ac.stop;
v_parentResourceIndex := f_getLocalResourceIndex(vc_request.primitive.requestPrimitive.to_);
if(v_parentResourceIndex == -1) {
log(__SCOPE__&": ERROR: Target resource not found");
v_response := valueof(m_responsePrimitive(int4004,vc_request.primitive.requestPrimitive.requestIdentifier));
} else {
v_localResource := f_generateLocalResource(vc_request.primitive.requestPrimitive.primitiveContent, v_parentResourceIndex, vc_request.primitive.requestPrimitive.resourceType);
v_localResourceIndex := f_setLocalResource(v_localResource, vc_request.primitive.requestPrimitive.resourceType, v_parentResourceIndex);
v_response := valueof(m_responsePrimitive(int2001,vc_request.primitive.requestPrimitive.requestIdentifier));
v_response.primitiveContent := vc_localResourcesList[v_localResourceIndex].resource;
}
v_response.from_ := PX_TS_CSE1.cseId;
v_response.to_ := vc_request.primitive.requestPrimitive.from_;
f_send(e_mcc_in_port, m_response(v_response));
}
[] tc_ac.timeout {
setverdict(inconc, __SCOPE__&":INFO: Create request not received");
}
}
f_checkCseSimuStatus();
return v_localResourceIndex;
}
/**
* @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 {
f_send(e_mcc_port, 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 Message exchange for the update of a resource
* @param p_resourceIndex Internal resource index which indicates the resource to be updated
* @param p_requestPrimitive UPDATE request primitive to be used
* @verdict
*/
function f_cse_updateResourceHandler(integer p_resourceIndex, template RequestPrimitive p_request := mw_update) runs on CseSimu {
var integer v_targetResourceIndex := -1;
//Activate defaults when running on a PTC
f_cse_activateDefaults_cse1();
tc_ac.start;
alt {
[] mccPortIn.receive(mw_request(p_request)) -> value vc_request {
tc_ac.stop;
v_targetResourceIndex := f_processUpdateRequestPrimitive(vc_request.primitive.requestPrimitive);
if(v_targetResourceIndex == p_resourceIndex) {
setverdict(pass, __SCOPE__&":INFO: Resource updated successfuly");
} else {
setverdict(inconc, __SCOPE__&":INFO: Unexpected resource update");
}
f_send(e_mcc_in_port, m_response(vc_response.primitive.responsePrimitive));
}
[] tc_ac.timeout {
setverdict(inconc, __SCOPE__&":INFO: No answer while updating resource");
}
}
f_checkCseSimuStatus();
}// end f_cse_updateResourceHandler
/**
* @desc Message exchange for the retrieve of a resource
* @param p_resourceIndex Internal resource index which indicates the expected resource to be retrieved
* @param p_requestPrimitive RETRIEVE request primitive to be used
* @verdict
*/
function f_cse_retrieveResourceHandler(integer p_resourceIndex, template RequestPrimitive p_request := mw_retrieve(?)) runs on CseSimu {
var integer v_targetResourceIndex := -1;
//Activate defaults when running on a PTC
f_cse_activateDefaults_cse1();
tc_ac.start;
alt {
[] mccPortIn.receive(mw_request(p_request)) -> value vc_request {
tc_ac.stop;
v_targetResourceIndex := f_processRetrieveRequestPrimitive(vc_request.primitive.requestPrimitive);
if(v_targetResourceIndex == p_resourceIndex) {
setverdict(pass, __SCOPE__&":INFO: Resource retrieved successfuly");
} else {
setverdict(inconc, __SCOPE__&":INFO: Unexpected resource retrieval");
}
f_send(e_mcc_in_port, m_response(vc_response.primitive.responsePrimitive));
}
[] tc_ac.timeout {
setverdict(inconc, __SCOPE__&":INFO: No answer while retrieving resource");
}
}
f_checkCseSimuStatus();
}// end f_cse_retrieveResourceHandler
/**
* @desc Message exchange for the retrieval of a child resource refs
* @param p_resourceType ResourceType of children of the resource to be retrieved
* @param p_resourceIndex Resource index of the resource to be retrieved
* @return PrimitiveContent parameter of the RETRIEVE response
* @verdict
*/
function f_cse_retrieveChildResourceRefs_cseSimu(template(omit) ResourceTypeList p_resourceTypeList := omit, integer p_targetResourceIndex := -1, XSD.ID p_originator := PX_SUPER_CSE_ID) runs on CseSimu return URIList {
var RequestPrimitive v_requestPrimitive;
var URIList v_uriList := {};
v_requestPrimitive := valueof(m_retrieveChildResourceRefs(f_getResourceAddress(p_targetResourceIndex), p_originator));
f_send(e_mcc_port, m_request(v_requestPrimitive));
tc_ac.start;
alt {
[] mccPort.receive(mw_response(mw_responsePrimitiveOK)) -> value vc_response {
tc_ac.stop;
setverdict(pass, __SCOPE__&":INFO: Resource retrieved successfuly");
v_uriList := vc_response.primitive.responsePrimitive.primitiveContent.uRIList;
}
[] mccPort.receive(mw_response(mw_responsePrimitiveKO)) {
tc_ac.stop;
setverdict(inconc, __SCOPE__&":INFO: Error while retrieving resource");
}
[] tc_ac.timeout {
setverdict(inconc, __SCOPE__&":INFO: No answer while retrieving resource");
}
}
return v_uriList;
}// end f_cse_retrieveResourceChildren
/**
* @desc Message exchange for the delete of a resource
* @param p_resourceIndex Internal resource index which indicates the expected resource to be deleted
* @param p_requestPrimitive DELETE request primitive to be used
* @verdict
*/
function f_cse_deleteResourceHandler(integer p_resourceIndex, template RequestPrimitive p_request := mw_delete) runs on CseSimu {
var integer v_targetResourceIndex := -1;
//Activate defaults when running on a PTC
f_cse_activateDefaults_cse1();
tc_ac.start;
alt {
[] mccPortIn.receive(mw_request(p_request)) -> value vc_request {
tc_ac.stop;
v_targetResourceIndex := f_processDeleteRequestPrimitive(vc_request.primitive.requestPrimitive);
if(v_targetResourceIndex == p_resourceIndex) {
setverdict(pass, __SCOPE__&":INFO: Resource deleted successfuly");
} else {
setverdict(inconc, __SCOPE__&":INFO: Unexpected resource retrieval");
}
f_send(e_mcc_in_port, m_response(vc_response.primitive.responsePrimitive));
}
[] tc_ac.timeout {
setverdict(inconc, __SCOPE__&":INFO: No answer while retrieving resource");
}
}
f_checkCseSimuStatus();
}// end f_cse_deleteResourceHandler
/**
* @desc Check that a resource is present in the IUT (resourceId is known)
* @param p_resourceIndex Resource index
* @return boolean
*/
function f_cse_isResourcePresent_cseSimu (integer p_resourceIndex) runs on CseSimu return boolean {
//Check to see if the resource is present or not
f_send(e_mcc_port, 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_cseSimu (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
f_send(e_mcc_port, 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(int2000))) {
tc_ac.stop;
setverdict(pass, testcasename() & ": Resource " & p_resourceName & " present");
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 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_localRemoteCSEResource;
//Activate defaults when running on a PTC
f_cse_activateDefaults_cse1();
v_request := f_getCreateRequestPrimitive(int16, p_requestPrimitive, -1);
f_send(e_mcc_port, 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_localRemoteCSEResource := f_generateLocalResource(valueof(m_primitiveContentRemoteCSE(m_contentLocalRemoteCSEResource(f_getCompletePoA(PX_TS_CSE1.mccPortIn, "")))), vc_cSEBaseIndex, int16); // FIXME To be review not sure we have to use CSE1
vc_localRemoteCseIndex := f_setLocalResource(v_localRemoteCSEResource, 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 (present) RequestPrimitive p_requestPrimitive := ?) runs on CseSimu return integer {
var MsgIn v_request;
var ResponsePrimitive v_response;
var PrimitiveContent v_localRemoteCSEResource;
var integer v_resourceIndex := -1;
var template UtTriggerPrimitive v_utRequest := m_utCreateRemoteCSE;
var charstring v_action := "Please, send a CSE registration request";
var ResponsePrimitive v_responsePrimitive;
var boolean v_remoteCSERegistered:=false;
//Activate defaults when running on a PTC
f_cse_activateDefaults_cse1();
//send triggering primitive to SUT
f_sendUtPrimitive(v_utRequest,v_action);
tc_ac.start;
alt {
[not v_remoteCSERegistered] mccPortIn.receive(mw_request(p_requestPrimitive)) -> value v_request {
tc_ac.stop;
setverdict(pass, __SCOPE__&":INFO: Resource type remoteCSE created successfuly");
v_localRemoteCSEResource := f_generateLocalResource(v_request.primitive.requestPrimitive.primitiveContent, vc_cSEBaseIndex, int16);//TODO Get index from v_request.primitive.requestPrimitive.to_
vc_localRemoteCseIndex := f_setLocalResource(v_localRemoteCSEResource, int16, vc_cSEBaseIndex);
v_response := valueof(m_responsePrimitive(int2001,v_request.primitive.requestPrimitive.requestIdentifier));
v_response.from_ := PX_TS_CSE1.cseId;
v_response.to_ := v_request.primitive.requestPrimitive.from_;
v_response.primitiveContent.remoteCSE := vc_localResourcesList[vc_localRemoteCseIndex].resource.remoteCSE;
f_send(e_mcc_in_port, m_response(v_response));
vc_remoteCseIndex := f_setResource(valueof(m_primitiveContentRemoteCSE(m_contentMyRemoteCSEResource(f_getCompletePoA(PX_TS_CSE1.mcaPortIn, "")))), int16, -1, false);
v_resourceIndex := vc_remoteCseIndex;
v_remoteCSERegistered:=true;
tc_ac.start(10.0);
repeat;
}
[] tc_ac.timeout {
if(not (v_remoteCSERegistered)){
setverdict(inconc, __SCOPE__&":INFO: No request received for creating resource type remoteCSE");
}
}
}
f_checkCseSimuStatus();
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_cseSimu(in template (present) RequestPrimitive p_requestPrimitive := ?) runs on CseSimu {
var ResponsePrimitive v_responsePrimitive;
//Activate defaults when running on a PTC
f_cse_activateDefaults_cse1();
tc_ac.start;
alt {
[] mccPortIn.receive(mw_request(p_requestPrimitive)) -> value vc_request {
tc_ac.stop;
setverdict(pass, __SCOPE__&":INFO: CREATE Request received successfuly");
v_responsePrimitive := f_getCreateResponsePrimitive(vc_request.primitive.requestPrimitive.resourceType, vc_request.primitive.requestPrimitive);
v_responsePrimitive.responseStatusCode := int2001;
f_send(e_mcc_in_port, m_response(v_responsePrimitive));
}
[] 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 and save 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 Index of internal created resource
*/
function f_generateAndSetLocalResource(in template(omit) PrimitiveContent p_resource := omit, in integer p_parentIndex, in ResourceType p_resourceType) runs on CseSimu return Integer {
var PrimitiveContent v_localResource;
var integer v_localResourceIndex;
v_localResource := f_generateLocalResource(p_resource, p_parentIndex, p_resourceType);
v_localResourceIndex := f_setLocalResource(v_localResource, p_resourceType, p_parentIndex);
return v_localResourceIndex;
}//End of function
/**
* @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_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 := PX_TS_CSE1.cseName;
v_myResource.cSEBase.resourceType := p_resourceType;
v_myResource.cSEBase.resourceID := f_resourceIdCleaner(PX_TS_CSE1.cseResourceId);
v_myResource.cSEBase.parentID := "";//Following TS-0001, it must be NULL. Set to a value for Codec to set it to 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_TS_CSE1.cseId;
v_myResource.cSEBase.supportedResourceType := PX_TS_CSE1.supportedResourceType;
v_myResource.cSEBase.pointOfAccess := {f_getCompletePoA(PX_TS_CSE1.mccPortIn, "")};
v_myResource.cSEBase.cseType := vc_cseType;
v_myResource.cSEBase.supportedReleaseVersions := {"2a"};
}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 := f_resourceIdCleaner(v_myResource.remoteCSE.cSE_ID);
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;
}
} else if (p_resourceType == int10002 and ispresent (p_resource)) { //AE Annc
if(ischosen(p_resource.aEAnnc)) {
v_myResource.aEAnnc := valueof(p_resource.aEAnnc);
if(not(ispresent(p_resource.aEAnnc.resourceName))) {
v_myResource.aEAnnc.resourceName := "aEAnnc" & int2str(v_resourceIndex);
}
v_myResource.aEAnnc.resourceType := p_resourceType;
v_myResource.aEAnnc.parentID := f_getResourceId(vc_localResourcesList[p_parentIndex].resource);
v_myResource.aEAnnc.creationTime := fx_generateTimestamp();
v_myResource.aEAnnc.lastModifiedTime := v_myResource.aEAnnc.creationTime;
if(v_myResource.aEAnnc.link[lengthof(v_myResource.aEAnnc.link)-1] == "S"){
v_myResource.aEAnnc.resourceID := "SaeA" & int2str(v_resourceIndex);
v_myResource.aEAnnc.aE_ID := v_myResource.aEAnnc.resourceID;
v_myResource.aEAnnc.link := substr(v_myResource.aEAnnc.link, 0, lengthof(v_myResource.aEAnnc.link)-1) & v_myResource.aEAnnc.resourceID;
} else {
v_myResource.aEAnnc.aE_ID := f_resourceIdCleaner(v_myResource.aEAnnc.link);
}
//TODO To be removed once link is fixed
v_myResource.aEAnnc.resourceID := "SaeA" & int2str(v_resourceIndex);
v_myResource.aEAnnc.link := substr(v_myResource.aEAnnc.link, 0, 11) & v_myResource.aEAnnc.resourceID;
}
} else if (p_resourceType == int10001 and ispresent (p_resource)) { //Acp Annc
if(ischosen(p_resource.accessControlPolicyAnnc)) {
v_myResource.accessControlPolicyAnnc := valueof(p_resource.accessControlPolicyAnnc);
if(not(ispresent(p_resource.accessControlPolicyAnnc.resourceName))) {
v_myResource.accessControlPolicyAnnc.resourceName := "accessControlPolicyAnnc" & int2str(v_resourceIndex);
}
v_myResource.accessControlPolicyAnnc.resourceType := p_resourceType;
v_myResource.accessControlPolicyAnnc.resourceID := "acpA" & int2str(v_resourceIndex);
v_myResource.accessControlPolicyAnnc.parentID := f_getResourceId(vc_localResourcesList[p_parentIndex].resource);
v_myResource.accessControlPolicyAnnc.creationTime := fx_generateTimestamp();
v_myResource.accessControlPolicyAnnc.lastModifiedTime := v_myResource.accessControlPolicyAnnc.creationTime;
}
} else if (p_resourceType == int10003 and ispresent (p_resource)) { //Container Annc
if(ischosen(p_resource.containerAnnc)) {
v_myResource.containerAnnc := valueof(p_resource.containerAnnc);
if(not(ispresent(p_resource.containerAnnc.resourceName))) {
v_myResource.containerAnnc.resourceName := "containerAnnc" & int2str(v_resourceIndex);
}
v_myResource.containerAnnc.resourceType := p_resourceType;
v_myResource.containerAnnc.resourceID := "cntA" & int2str(v_resourceIndex);
v_myResource.containerAnnc.parentID := f_getResourceId(vc_localResourcesList[p_parentIndex].resource);
v_myResource.containerAnnc.creationTime := fx_generateTimestamp();
v_myResource.containerAnnc.lastModifiedTime := v_myResource.containerAnnc.creationTime;
}
} else if (p_resourceType == int10009 and ispresent (p_resource)) { //Group Annc
if(ischosen(p_resource.groupAnnc)) {
v_myResource.groupAnnc := valueof(p_resource.groupAnnc);
if(not(ispresent(p_resource.groupAnnc.resourceName))) {
v_myResource.groupAnnc.resourceName := "groupAnnc" & int2str(v_resourceIndex);
}
v_myResource.groupAnnc.resourceType := p_resourceType;
v_myResource.groupAnnc.resourceID := "grpA" & int2str(v_resourceIndex);
v_myResource.groupAnnc.parentID := f_getResourceId(vc_localResourcesList[p_parentIndex].resource);
v_myResource.groupAnnc.creationTime := fx_generateTimestamp();
v_myResource.groupAnnc.lastModifiedTime := v_myResource.groupAnnc.creationTime;
}
} else if (p_resourceType == int10004 and ispresent (p_resource)) { //ContentInstance Annc
if(ischosen(p_resource.contentInstanceAnnc)) {
v_myResource.contentInstanceAnnc := valueof(p_resource.contentInstanceAnnc);
if(not(ispresent(p_resource.contentInstanceAnnc.resourceName))) {
v_myResource.contentInstanceAnnc.resourceName := "contentInstanceAnnc" & int2str(v_resourceIndex);
}
v_myResource.contentInstanceAnnc.resourceType := p_resourceType;
v_myResource.contentInstanceAnnc.resourceID := "cinA" & int2str(v_resourceIndex);
v_myResource.contentInstanceAnnc.parentID := f_getResourceId(vc_localResourcesList[p_parentIndex].resource);
v_myResource.contentInstanceAnnc.creationTime := fx_generateTimestamp();
v_myResource.contentInstanceAnnc.lastModifiedTime := v_myResource.contentInstanceAnnc.creationTime;
}
} else if (p_resourceType == int1 and ispresent (p_resource)) { //Acp Resource
if(ischosen (p_resource.accessControlPolicy)){
v_myResource.accessControlPolicy := valueof(p_resource.accessControlPolicy);
if(not(ispresent(p_resource.accessControlPolicy.resourceName))) {
v_myResource.accessControlPolicy.resourceName := "accessControlPolicy" & int2str(v_resourceIndex);
}
v_myResource.accessControlPolicy.resourceType := p_resourceType;
v_myResource.accessControlPolicy.resourceID := "acp" & int2str(v_resourceIndex);
v_myResource.accessControlPolicy.parentID := f_getResourceId(vc_localResourcesList[p_parentIndex].resource);
v_myResource.accessControlPolicy.creationTime := fx_generateTimestamp();
if(not(ispresent(p_resource.accessControlPolicy.expirationTime))) {
v_myResource.accessControlPolicy.expirationTime := "20301231T012345";
}
v_myResource.accessControlPolicy.lastModifiedTime := v_myResource.accessControlPolicy.creationTime;
v_myResource.accessControlPolicy.announceTo := omit;
v_myResource.accessControlPolicy.announcedAttribute := omit;
v_myResource.accessControlPolicy.privileges := valueof(p_resource.accessControlPolicy.privileges);
v_myResource.accessControlPolicy.selfPrivileges := valueof(p_resource.accessControlPolicy.selfPrivileges);
}
} else if(p_resourceType == int2 and ispresent(p_resource)) {//AE
if(ischosen(p_resource.aE)){
v_myResource.aE := valueof(p_resource.aE);
v_myResource.aE.resourceType := p_resourceType;
v_myResource.aE.parentID := f_getResourceId(vc_localResourcesList[p_parentIndex].resource);
v_myResource.aE.creationTime := fx_generateTimestamp();
v_myResource.aE.lastModifiedTime := v_myResource.aE.creationTime;
if(not(ispresent(p_resource.aE.expirationTime))) {
v_myResource.aE.expirationTime := "20301231T012345";
}
v_myResource.aE.resourceID := "Cae" & int2str(v_resourceIndex);
v_myResource.aE.aE_ID := v_myResource.aE.resourceID;
if(not(ispresent(p_resource.aE.resourceName))) {
v_myResource.aE.resourceName := "ae" & int2str(v_resourceIndex);
}
v_myResource.aE.app_ID := valueof(p_resource.aE.app_ID);
v_myResource.aE.requestReachability := valueof(p_resource.aE.requestReachability);
}
} else if(p_resourceType == int3 and ispresent(p_resource)) { //Container
if(ischosen(p_resource.container)){
v_myResource.container := valueof(p_resource.container);
v_myResource.container.resourceType := p_resourceType;
v_myResource.container.parentID := f_getResourceId(vc_localResourcesList[p_parentIndex].resource);
v_myResource.container.creationTime := fx_generateTimestamp();
v_myResource.container.lastModifiedTime := v_myResource.container.creationTime;
if(not(ispresent(p_resource.container.expirationTime))) {
v_myResource.container.expirationTime := "20301231T012345";
}
v_myResource.container.resourceID := "cnt" & int2str(v_resourceIndex);
if(not(ispresent(p_resource.container.resourceName))) {
v_myResource.container.resourceName := "container" & int2str(v_resourceIndex);
}
v_myResource.container.stateTag := 0;
v_myResource.container.currentNrOfInstances := 0;
v_myResource.container.currentByteSize := 0;
}
} else if(p_resourceType == int4 and ispresent(p_resource)) { //ContentInstance
if(ischosen(p_resource.contentInstance)){
v_myResource.contentInstance := valueof(p_resource.contentInstance);
v_myResource.contentInstance.resourceID := "cin" & int2str(v_resourceIndex);
if(not(ispresent(p_resource.contentInstance.resourceName))) {
v_myResource.contentInstance.resourceName := "contentInstance" & int2str(v_resourceIndex);
}
v_myResource.contentInstance.resourceType := p_resourceType;
v_myResource.contentInstance.parentID := f_getResourceId(vc_localResourcesList[p_parentIndex].resource);
v_myResource.contentInstance.creationTime := fx_generateTimestamp();
v_myResource.contentInstance.lastModifiedTime := v_myResource.contentInstance.creationTime;
if(not(ispresent(p_resource.contentInstance.expirationTime))) {
v_myResource.contentInstance.expirationTime := "20301231T012345";
}
v_myResource.contentInstance.stateTag := 0;
if(not(ispresent(p_resource.contentInstance.content))) {
v_myResource.contentInstance.contentSize := 0;
v_myResource.contentInstance.content := omit;
} else {
v_myResource.contentInstance.contentSize := lengthof(v_myResource.contentInstance.content);
v_myResource.contentInstance.content := valueof(p_resource.contentInstance.content);
}
}
} else if(p_resourceType == int23 and ispresent(p_resource)) {//Subscription
if(ischosen(p_resource.subscription)){
v_myResource.subscription := valueof(p_resource.subscription);
v_myResource.subscription.resourceID := "sub" & int2str(v_resourceIndex);
if(not(ispresent(p_resource.subscription.resourceName))) {
v_myResource.subscription.resourceName := "subscription" & int2str(v_resourceIndex);
}
v_myResource.subscription.resourceType := p_resourceType;
v_myResource.subscription.parentID := f_getResourceId(vc_localResourcesList[p_parentIndex].resource);
v_myResource.subscription.creationTime := fx_generateTimestamp();
v_myResource.subscription.lastModifiedTime := v_myResource.subscription.creationTime;
if(not(ispresent(p_resource.subscription.expirationTime))) {
v_myResource.subscription.expirationTime := "20301231T012345";
}
}
} else if(p_resourceType == int9 and ispresent(p_resource)) { //Group
if(ischosen(p_resource.group_)){
v_myResource.group_ := valueof(p_resource.group_);
v_myResource.group_.resourceID := "grp" & int2str(v_resourceIndex);
if(not(ispresent(p_resource.group_.resourceName))) {
v_myResource.group_.resourceName := "group" & int2str(v_resourceIndex);
}
v_myResource.group_.resourceType := p_resourceType;
v_myResource.group_.parentID := f_getResourceId(vc_localResourcesList[p_parentIndex].resource);
v_myResource.group_.creationTime := fx_generateTimestamp();
v_myResource.group_.lastModifiedTime := v_myResource.group_.creationTime;
if(not(ispresent(p_resource.group_.expirationTime))) {
v_myResource.group_.expirationTime := "20301231T012345";
}
if(not(ispresent(p_resource.group_.memberType))) {
v_myResource.group_.memberType := int0;
}
if(not(ispresent(p_resource.group_.consistencyStrategy))) {
v_myResource.group_.consistencyStrategy := int1;
}
if(v_myResource.group_.memberType != int0) {
v_myResource.group_.memberTypeValidated := true;//Set initially to TRUE
}
}
} else if(p_resourceType == int15 and ispresent(p_resource)) { //PollingChannel
if(ischosen(p_resource.pollingChannel)){
v_myResource.pollingChannel := valueof(p_resource.pollingChannel);
v_myResource.pollingChannel.resourceID := "pch" & int2str(v_resourceIndex);
if(not(ispresent(p_resource.pollingChannel.resourceName))) {
v_myResource.pollingChannel.resourceName := "pollingChannel" & int2str(v_resourceIndex);
}
v_myResource.pollingChannel.resourceType := p_resourceType;
v_myResource.pollingChannel.parentID := f_getResourceId(vc_localResourcesList[p_parentIndex].resource);
v_myResource.pollingChannel.creationTime := fx_generateTimestamp();
v_myResource.pollingChannel.lastModifiedTime := v_myResource.pollingChannel.creationTime;
if(not(ispresent(p_resource.pollingChannel.expirationTime))) {
v_myResource.pollingChannel.expirationTime := "20301231T012345";
}
}
}
return v_myResource;
}//End of function
/**
* @desc Update of a local resource (Test System simulating a CSE)
* @param p_localResourceIndex Resource index of resource to be updated
* @param p_resource Resource update
*/
function f_updateLocalResource(in integer p_localResourceIndex, in PrimitiveContent p_resource) runs on CseSimu {
// TODO To review the code (use of indexes, generation of value for certain attributes, etc..)
if(ischosen(vc_localResourcesList[p_localResourceIndex].resource.remoteCSE) and ischosen(p_resource.remoteCSE)) {//RemoteCSE
if(ispresent(p_resource.remoteCSE.accessControlPolicyIDs)) {
vc_localResourcesList[p_localResourceIndex].resource.remoteCSE.accessControlPolicyIDs := p_resource.remoteCSE.accessControlPolicyIDs;
}
if(ispresent(p_resource.remoteCSE.expirationTime)) {
vc_localResourcesList[p_localResourceIndex].resource.remoteCSE.expirationTime := p_resource.remoteCSE.expirationTime;
}
if(ispresent(p_resource.remoteCSE.labels)) {
vc_localResourcesList[p_localResourceIndex].resource.remoteCSE.labels := p_resource.remoteCSE.labels;
}
if(ispresent(p_resource.remoteCSE.announceTo)) {
vc_localResourcesList[p_localResourceIndex].resource.remoteCSE.announceTo := {p_resource.remoteCSE.announceTo[0] & "/" & vc_localResourcesList[vc_localRemoteCseIndex].resource.remoteCSE.resourceID & "Annc"};
}
if(ispresent(p_resource.remoteCSE.announcedAttribute)) {
vc_localResourcesList[p_localResourceIndex].resource.remoteCSE.announcedAttribute := p_resource.remoteCSE.announcedAttribute;
}
if(ispresent(p_resource.remoteCSE.dynamicAuthorizationConsultationIDs)) {
vc_localResourcesList[p_localResourceIndex].resource.remoteCSE.dynamicAuthorizationConsultationIDs := p_resource.remoteCSE.dynamicAuthorizationConsultationIDs;
}
if(ispresent(p_resource.remoteCSE.pointOfAccess)) {
vc_localResourcesList[p_localResourceIndex].resource.remoteCSE.pointOfAccess := p_resource.remoteCSE.pointOfAccess;
}
if(ispresent(p_resource.remoteCSE.m2M_Ext_ID)) {
vc_localResourcesList[p_localResourceIndex].resource.remoteCSE.m2M_Ext_ID := p_resource.remoteCSE.m2M_Ext_ID;
}
if(ispresent(p_resource.remoteCSE.trigger_Recipient_ID)) {
vc_localResourcesList[p_localResourceIndex].resource.remoteCSE.trigger_Recipient_ID := p_resource.remoteCSE.trigger_Recipient_ID;
}
if(ispresent(p_resource.remoteCSE.requestReachability)) {
vc_localResourcesList[p_localResourceIndex].resource.remoteCSE.requestReachability := p_resource.remoteCSE.requestReachability;
}
if(ispresent(p_resource.remoteCSE.nodeLink)) {
vc_localResourcesList[p_localResourceIndex].resource.remoteCSE.nodeLink := p_resource.remoteCSE.nodeLink;
}
if(ispresent(p_resource.remoteCSE.triggerReferenceNumber)) {
vc_localResourcesList[p_localResourceIndex].resource.remoteCSE.triggerReferenceNumber := p_resource.remoteCSE.triggerReferenceNumber;
}
if(ispresent(p_resource.remoteCSE.e2eSecInfo)) {
vc_localResourcesList[p_localResourceIndex].resource.remoteCSE.e2eSecInfo := p_resource.remoteCSE.e2eSecInfo;
}
if(ispresent(p_resource.remoteCSE.supportedReleaseVersions)) {
vc_localResourcesList[p_localResourceIndex].resource.remoteCSE.supportedReleaseVersions := p_resource.remoteCSE.supportedReleaseVersions;
}
} else if(ischosen(vc_localResourcesList[p_localResourceIndex].resource.container) and (ischosen(p_resource.container))) {//Container
if(ispresent(p_resource.container.expirationTime)) {
vc_localResourcesList[p_localResourceIndex].resource.container.expirationTime := p_resource.container.expirationTime;
}
if(ispresent(p_resource.container.labels)) {
vc_localResourcesList[p_localResourceIndex].resource.container.labels := p_resource.container.labels;
}
if(ispresent(p_resource.container.announceTo)) {
vc_localResourcesList[p_localResourceIndex].resource.container.announceTo := p_resource.container.announceTo;
}
if(ispresent(p_resource.container.announcedAttribute)) {
vc_localResourcesList[p_localResourceIndex].resource.container.announcedAttribute := p_resource.container.announcedAttribute;
}
if(ispresent(p_resource.container.accessControlPolicyIDs)) {
vc_localResourcesList[p_localResourceIndex].resource.container.accessControlPolicyIDs := p_resource.container.accessControlPolicyIDs;
}
if(ispresent(p_resource.container.dynamicAuthorizationConsultationIDs)) {
vc_localResourcesList[p_localResourceIndex].resource.container.dynamicAuthorizationConsultationIDs := p_resource.container.dynamicAuthorizationConsultationIDs;
}
} else if(ischosen(vc_localResourcesList[p_localResourceIndex].resource.contentInstance) and (ischosen(p_resource.contentInstance))) {//ContentInstance
if(ispresent(p_resource.contentInstance.expirationTime)) {
vc_localResourcesList[p_localResourceIndex].resource.contentInstance.expirationTime := p_resource.contentInstance.expirationTime;
}
if(ispresent(p_resource.contentInstance.labels)) {
vc_localResourcesList[p_localResourceIndex].resource.contentInstance.labels := p_resource.contentInstance.labels;
}
if(ispresent(p_resource.contentInstance.announceTo)) {
vc_localResourcesList[p_localResourceIndex].resource.contentInstance.announceTo := p_resource.contentInstance.announceTo;
}
if(ispresent(p_resource.contentInstance.announcedAttribute)) {
vc_localResourcesList[p_localResourceIndex].resource.contentInstance.announcedAttribute := p_resource.contentInstance.announcedAttribute;
}
} else if(ischosen(vc_localResourcesList[p_localResourceIndex].resource.subscription) and (ischosen(p_resource.subscription))) {//Subscription
if(ispresent(p_resource.subscription.expirationTime)) {
vc_localResourcesList[p_localResourceIndex].resource.subscription.expirationTime := p_resource.subscription.expirationTime;
}
if(ispresent(p_resource.subscription.labels)) {
vc_localResourcesList[p_localResourceIndex].resource.subscription.labels := p_resource.subscription.labels;
}
if(ispresent(p_resource.subscription.accessControlPolicyIDs)) {
vc_localResourcesList[p_localResourceIndex].resource.subscription.accessControlPolicyIDs := p_resource.subscription.accessControlPolicyIDs;
}
if(ispresent(p_resource.subscription.dynamicAuthorizationConsultationIDs)) {
vc_localResourcesList[p_localResourceIndex].resource.subscription.dynamicAuthorizationConsultationIDs := p_resource.subscription.dynamicAuthorizationConsultationIDs;
}
} else if(ischosen(vc_localResourcesList[p_localResourceIndex].resource.pollingChannel) and (ischosen(p_resource.pollingChannel))) {//pollingChannel
if(ispresent(p_resource.pollingChannel.expirationTime)) {
vc_localResourcesList[p_localResourceIndex].resource.pollingChannel.expirationTime := p_resource.pollingChannel.expirationTime;
}
if(ispresent(p_resource.pollingChannel.labels)) {
vc_localResourcesList[p_localResourceIndex].resource.pollingChannel.labels := p_resource.pollingChannel.labels;
}
} else if(ischosen(vc_localResourcesList[p_localResourceIndex].resource.aE) and (ischosen(p_resource.aE))) {//AE
if(ispresent(p_resource.aE.accessControlPolicyIDs)) {
vc_localResourcesList[p_localResourceIndex].resource.aE.accessControlPolicyIDs := p_resource.aE.accessControlPolicyIDs;
}
if(ispresent(p_resource.aE.expirationTime)) {
vc_localResourcesList[p_localResourceIndex].resource.aE.expirationTime := p_resource.aE.expirationTime;
}
if(ispresent(p_resource.aE.labels)) {
vc_localResourcesList[p_localResourceIndex].resource.aE.labels := p_resource.aE.labels;
}
if(ispresent(p_resource.aE.announceTo)) {
vc_localResourcesList[p_localResourceIndex].resource.aE.announceTo := p_resource.aE.announceTo;
}
if(ispresent(p_resource.aE.announcedAttribute)) {
vc_localResourcesList[p_localResourceIndex].resource.aE.announcedAttribute := p_resource.aE.announcedAttribute;
}
if(ispresent(p_resource.aE.dynamicAuthorizationConsultationIDs)) {
vc_localResourcesList[p_localResourceIndex].resource.aE.dynamicAuthorizationConsultationIDs := p_resource.aE.dynamicAuthorizationConsultationIDs;
}
if(ispresent(p_resource.aE.appName)) {
vc_localResourcesList[p_localResourceIndex].resource.aE.appName := p_resource.aE.appName;
}
if(ispresent(p_resource.aE.pointOfAccess)) {
vc_localResourcesList[p_localResourceIndex].resource.aE.pointOfAccess := p_resource.aE.pointOfAccess;
}
if(ispresent(p_resource.aE.ontologyRef)) {
vc_localResourcesList[p_localResourceIndex].resource.aE.ontologyRef := p_resource.aE.ontologyRef;
}
if(ispresent(p_resource.aE.nodeLink)) {
vc_localResourcesList[p_localResourceIndex].resource.aE.nodeLink := p_resource.aE.nodeLink;
}
if(ispresent(p_resource.aE.requestReachability)) {
vc_localResourcesList[p_localResourceIndex].resource.aE.requestReachability := p_resource.aE.requestReachability;
}
if(ispresent(p_resource.aE.contentSerialization)) {
vc_localResourcesList[p_localResourceIndex].resource.aE.contentSerialization := p_resource.aE.contentSerialization;
}
if(ispresent(p_resource.aE.e2eSecInfo)) {
vc_localResourcesList[p_localResourceIndex].resource.aE.e2eSecInfo := p_resource.aE.e2eSecInfo;
}
if(ispresent(p_resource.aE.supportedReleaseVersions)) {
vc_localResourcesList[p_localResourceIndex].resource.aE.supportedReleaseVersions := p_resource.aE.supportedReleaseVersions;
}
} else if(ischosen(vc_localResourcesList[p_localResourceIndex].resource.aEAnnc) and (ischosen(p_resource.aEAnnc))) {//AEAnnc
if(ispresent(p_resource.aEAnnc.accessControlPolicyIDs)) {
vc_localResourcesList[p_localResourceIndex].resource.aEAnnc.accessControlPolicyIDs := p_resource.aEAnnc.accessControlPolicyIDs;
}
if(ispresent(p_resource.aEAnnc.expirationTime)) {
vc_localResourcesList[p_localResourceIndex].resource.aEAnnc.expirationTime := p_resource.aEAnnc.expirationTime;
}
if(ispresent(p_resource.aEAnnc.labels)) {
vc_localResourcesList[p_localResourceIndex].resource.aEAnnc.labels := p_resource.aEAnnc.labels;
}
if(ispresent(p_resource.aEAnnc.link)) {
vc_localResourcesList[p_localResourceIndex].resource.aEAnnc.link := p_resource.aEAnnc.link;
}
if(ispresent(p_resource.aEAnnc.dynamicAuthorizationConsultationIDs)) {
vc_localResourcesList[p_localResourceIndex].resource.aEAnnc.dynamicAuthorizationConsultationIDs := p_resource.aEAnnc.dynamicAuthorizationConsultationIDs;
}
if(ispresent(p_resource.aEAnnc.appName)) {
vc_localResourcesList[p_localResourceIndex].resource.aEAnnc.appName := p_resource.aEAnnc.appName;
}
if(ispresent(p_resource.aEAnnc.pointOfAccess)) {
vc_localResourcesList[p_localResourceIndex].resource.aEAnnc.pointOfAccess := p_resource.aEAnnc.pointOfAccess;
}
if(ispresent(p_resource.aEAnnc.ontologyRef)) {
vc_localResourcesList[p_localResourceIndex].resource.aEAnnc.ontologyRef := p_resource.aEAnnc.ontologyRef;
}
if(ispresent(p_resource.aEAnnc.nodeLink)) {
vc_localResourcesList[p_localResourceIndex].resource.aEAnnc.nodeLink := p_resource.aEAnnc.nodeLink;
}
if(ispresent(p_resource.aEAnnc.requestReachability)) {
vc_localResourcesList[p_localResourceIndex].resource.aEAnnc.requestReachability := p_resource.aEAnnc.requestReachability;
}
if(ispresent(p_resource.aEAnnc.contentSerialization)) {
vc_localResourcesList[p_localResourceIndex].resource.aEAnnc.contentSerialization := p_resource.aEAnnc.contentSerialization;
}
if(ispresent(p_resource.aEAnnc.e2eSecInfo)) {
vc_localResourcesList[p_localResourceIndex].resource.aEAnnc.e2eSecInfo := p_resource.aEAnnc.e2eSecInfo;
}
if(ispresent(p_resource.aEAnnc.supportedReleaseVersions)) {
vc_localResourcesList[p_localResourceIndex].resource.aEAnnc.supportedReleaseVersions := p_resource.aEAnnc.supportedReleaseVersions;
}
} else if(ischosen(vc_localResourcesList[p_localResourceIndex].resource.accessControlPolicy) and (ischosen(p_resource.accessControlPolicy))) { //AccessControlPolicy
if(ispresent(p_resource.accessControlPolicy.expirationTime)) {
vc_localResourcesList[p_localResourceIndex].resource.accessControlPolicy.expirationTime := p_resource.accessControlPolicy.expirationTime;
}
if(ispresent(p_resource.accessControlPolicy.labels)) {
vc_localResourcesList[p_localResourceIndex].resource.accessControlPolicy.labels := p_resource.accessControlPolicy.labels;
}
if(ispresent(p_resource.accessControlPolicy.announceTo)) {
vc_localResourcesList[p_localResourceIndex].resource.accessControlPolicy.announceTo := p_resource.accessControlPolicy.announceTo;
}
if(ispresent(p_resource.accessControlPolicy.announcedAttribute)) {
vc_localResourcesList[p_localResourceIndex].resource.accessControlPolicy.announcedAttribute := p_resource.accessControlPolicy.announcedAttribute;
}
}
} //End of function
/**
* @desc Creation of a resource using CseSimu
* @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_cseSimu(in ResourceType p_resourceType, template RequestPrimitive p_requestPrimitive := m_create, integer p_parentIndex := -1) runs on CseSimu return integer {
var RequestPrimitive v_request;
var integer v_resourceIndex := -1;
//Activate defaults when running on a PTC
f_cse_activateDefaults_cse1();
v_request := f_getCreateRequestPrimitive(p_resourceType, p_requestPrimitive, p_parentIndex);
f_send(e_mcc_port, 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, p_resourceType, p_parentIndex);
if(p_resourceType == int16) { //remoteCSE
vc_remoteCseIndex := v_resourceIndex;
}
}
[] 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;
}
/**
* @desc Send response to the IUT (Test System simulating a CSE)
* @param p_requestPrimtive Received request primitive
*/
function f_cse_sendResponse_cseSimu(in MsgIn p_requestPrimitive) runs on CseSimu {
f_processCreateRequestPrimitive(p_requestPrimitive.primitive.requestPrimitive);
f_send(e_mcc_in_port, m_response(vc_response.primitive.responsePrimitive));
}
}//end group CseSimuFunctions
group CseAltstepFunctions {
/**
* @desc Cse altstep for config 01
*/
altstep a_cse_cf01() runs on AeSimu {
var MsgIn v_request;
var ResponsePrimitive v_responsePrimitive;
[] mcaPort.receive {
log(__SCOPE__&": WARNING: Unexpected message received");
repeat;
}
[] mcaPortIn.receive(mw_request(mw_notifyNotification(mw_contentNotification(?)))) -> value v_request {
//Send response
v_responsePrimitive := valueof(m_responseNotification(int2000, omit));
v_responsePrimitive.requestIdentifier := v_request.primitive.requestPrimitive.requestIdentifier;
f_send(e_mca_in_port, m_response(v_responsePrimitive));
log(__SCOPE__&": WARNING: Unexpected Notification message received");
repeat;
}
[] mcaPortIn.receive(mw_request(mw_notifyNotification(mw_contentNotificationVerification))) -> value v_request {
//Send response
v_responsePrimitive := valueof(m_responseNotification(int2000, omit));
v_responsePrimitive.requestIdentifier := v_request.primitive.requestPrimitive.requestIdentifier;
f_send(e_mca_in_port, m_response(v_responsePrimitive));
log(__SCOPE__&": WARNING: Unexpected Notification for Subscription Verification message received");
repeat;
}
}
/**
* @desc Cse altstep for config 02
*/
altstep a_cse_cf02_ae1() runs on AeSimu {
[] a_cse_aeSimu();
}
/**
* @desc Cse altstep for config 02
*/
altstep a_cse_cf02_cse1() runs on CseSimu {
[] a_cse_cseSimu();
}
/**
* @desc Cse altstep for config 03
*/
altstep a_cse_cf03() runs on CseSimu {
[] a_ae_cseSimu();
}
/**
* @desc Cse altstep for config 04
*/
altstep a_cse_cf04() runs on CseSimu {
[] a_cse_cseSimu();
}
/**
* @desc Altstep for CseSimu
*/
altstep a_cse_cseSimu() runs on CseSimu {
var PrimitiveContent v_localResource;
var integer v_localResourceIndex := -1;
var integer v_parentResourceIndex := -1;
var MsgIn v_request;
var ResponsePrimitive v_response;
[] mccPortIn.receive(mw_request(mw_create())) -> value v_request {
log(__SCOPE__&": WARNING: Unexpected CREATE message received");
v_localResourceIndex := f_processCreateRequestPrimitive(v_request.primitive.requestPrimitive);
f_send(e_mcc_in_port, m_response(vc_response.primitive.responsePrimitive));
repeat;
}
[] mccPortIn.receive(mw_request(mw_retrieve(?))) -> value v_request {
log(__SCOPE__&": WARNING: Unexpected RETRIEVE message received");
f_processRetrieveRequestPrimitive(v_request.primitive.requestPrimitive);
if(ischosen(vc_response.primitive.responsePrimitive.primitiveContent.cSEBase)) {
f_send(e_mcc_in_port, m_response(vc_response.primitive.responsePrimitive, {{"parentID", omit}}));
} else {
f_send(e_mcc_in_port, m_response(vc_response.primitive.responsePrimitive));
}
repeat;
}
[] mccPortIn.receive(mw_request(mw_update())) -> value v_request {
log(__SCOPE__&": WARNING: Unexpected UPDATE message received");
f_processUpdateRequestPrimitive(v_request.primitive.requestPrimitive);
f_send(e_mcc_in_port, m_response(vc_response.primitive.responsePrimitive));
repeat;
}
[] mccPortIn.receive(mw_request(mw_delete())) -> value v_request {
log(__SCOPE__&": WARNING: Unexpected DELETE message received");
f_processDeleteRequestPrimitive(v_request.primitive.requestPrimitive);
f_send(e_mcc_in_port, m_response(vc_response.primitive.responsePrimitive));
repeat;
}
[] mccPortIn.receive(mw_request(mw_notify)) -> value v_request {
log(__SCOPE__&": WARNING: Unexpected NOTIFY message received");
//Send response in any case
v_response := valueof(m_responseNotification(int2000, omit));
v_response.requestIdentifier := vc_request.primitive.requestPrimitive.requestIdentifier;
f_send(e_mcc_in_port, m_response(v_response));
repeat;
}
[] mccPortIn.receive (mw_request(?)){
log(__SCOPE__&": WARNING: Unexpected message received");
repeat;
}
[] mccPort.receive {
log(__SCOPE__&": WARNING: Unexpected message received");
repeat;
}
}
/**
* @desc Altstep for AeSimu
*/
altstep a_cse_aeSimu() runs on AeSimu {
var MsgIn v_request;
var ResponsePrimitive v_response;
[] mcaPortIn.receive(mw_request(mw_notify)) -> value v_request {
log(__SCOPE__&": WARNING: Unexpected NOTIFY message received");
//Send response in any case
v_response := valueof(m_responseNotification(int2000, omit));
v_response.requestIdentifier := vc_request.primitive.requestPrimitive.requestIdentifier;
f_send(e_mca_in_port, m_response(v_response));
repeat;
}
[] mcaPortIn.receive {
log(__SCOPE__&": WARNING: Unexpected message received");
repeat;
}
[] mcaPort.receive {
log(__SCOPE__&": WARNING: Unexpected message received");
repeat;
}
}
/**
* @desc Activation of the corresponding default altstep depending on config for CseSimu
*/
function f_cse_activateDefaults_cse1() runs on CseSimu {
deactivate;
activate(a_default());
if(vc_config == e_cf02) {
activate(a_cse_cf02_cse1());
log(__SCOPE__&": INFO: Default cf02_cse1 activated");
} else if(vc_config == e_cf02CseSimuMaster) {
activate(a_cse_cf02_cse1());
log(__SCOPE__&": INFO: Default cf02_cse1 activated");
} else if(vc_config == e_cf03) {
activate(a_cse_cf03());
log(__SCOPE__&": INFO: Default cf03 activated");
} else if(vc_config == e_cf04) {
activate(a_cse_cf04());
log(__SCOPE__&": INFO: Default cf04 activated");
}
}
/**
* @desc Activation of the corresponding default altstep depending on config for AeSimu
*/
function f_cse_activateDefaults_ae() runs on AeSimu {
deactivate;
activate(a_default());
if(vc_config == e_cf01) {
activate(a_cse_cf01());
log(__SCOPE__&": INFO: Default cf01 activated");
} else if(vc_config == e_cf02) {
activate(a_cse_cf02_ae1());
log(__SCOPE__&": INFO: Default cf02_ae1 activated");
} else if(vc_config == e_cf02CseSimuMaster) {
activate(a_cse_cf02_ae1());
log(__SCOPE__&": INFO: Default cf02_ae1 activated");
}
}
}//end group CseAltstepFunctions
}//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_utCreateAe) runs on CseSimu return integer {
var MsgIn v_request;
var integer v_localResourceIndex, v_parentIndex;
var charstring v_action := "Please, register the AE on the Tester";
p_utRequest.requestPrimitive.to_ := f_getLocalResourceAddress(-,-,-);
if(not(ispresent(p_utRequest.requestPrimitive.primitiveContent))) {
p_utRequest.requestPrimitive.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_localResourceIndex := f_processCreateRequestPrimitive(v_request.primitive.requestPrimitive);
f_send(e_mca_in_port, m_response(vc_response.primitive.responsePrimitive));
}
[] tc_ac.timeout {
setverdict(inconc, __SCOPE__&":INFO: AE registration request not received");
stop;
}
}
f_checkCseSimuStatus();
return v_localResourceIndex;
}//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_utCreateAe) 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.requestPrimitive.primitiveContent))) {
p_utRequest.requestPrimitive.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_getLocalResourceIndex(v_rp.to_);
v_modifiedResource := f_generateLocalResource(v_rp.primitiveContent, v_parentIndex, v_rp.resourceType);
v_resourceIndex := f_setLocalResource(v_modifiedResource, int2, v_parentIndex);
if(v_resourceIndex != -1) {
f_send(e_mca_in_port, m_response(m_responsePrimitive_content(int2001, v_rp.requestIdentifier, v_modifiedResource)));
setverdict(pass, __SCOPE__&":INFO: Container created successfuly");
}
else {
f_send(e_mca_in_port, 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 CseSimuFunctions {
function f_ae_createPollingChannel(template UtTriggerPrimitive p_utRequest := m_utCreateAe) 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 Polling Channel resource on the Tester";
if(not(ispresent(p_utRequest.requestPrimitive.primitiveContent))) {
p_utRequest.requestPrimitive.primitiveContent.pollingChannel := m_contentCreatePollingChannel;
}
f_sendUtPrimitive(p_utRequest, v_action);
tc_ac.start;
alt {
[] mcaPortIn.receive(mw_request(mw_createPollingChannel(?,?))) -> value v_request {
tc_ac.stop;
v_rp := v_request.primitive.requestPrimitive;
v_parentIndex := f_getLocalResourceIndex(v_rp.to_);
v_modifiedResource := f_generateLocalResource(v_rp.primitiveContent, v_parentIndex, v_rp.resourceType);
v_resourceIndex := f_setLocalResource(v_modifiedResource, int2, v_parentIndex);
if(v_resourceIndex != -1) {
f_send(e_mca_in_port, m_response(m_responsePrimitive_content(int2001, v_rp.requestIdentifier, v_modifiedResource)));
setverdict(pass, __SCOPE__&":INFO: Polling Channel created successfuly");
}
else {
f_send(e_mca_in_port, m_response(m_responsePrimitive(int5000, v_request.primitive.requestPrimitive.requestIdentifier)));
setverdict(inconc, __SCOPE__&":INFO: Polling Channel creation failed");
}
}
[] tc_ac.timeout {
setverdict(inconc, __SCOPE__&":INFO: Polling Channel create request not received");
stop;
}
}
f_checkCseSimuStatus();
return v_resourceIndex;
} //end function f_ae_createPollingChannel
} // end CseSimuFunctions
group AeAltstepFunctions {
/**
* @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 {
[] a_ae_cseSimu();
}
/**
* @desc Altstep for AeSimu
*/
altstep a_ae_cseSimu() runs on CseSimu {
var ResponsePrimitive v_response;
var MsgIn v_request;
var integer v_localResourceIndex := -1;
[] mcaPortIn.receive(mw_request(mw_notify)) -> value v_request {
tc_ac.stop;
log(__SCOPE__&": WARNING: Unexpected NOTIFY message received");
//Send response in any case
v_response := valueof(m_responseNotification(int2000, omit));
v_response.requestIdentifier := vc_request.primitive.requestPrimitive.requestIdentifier;
f_send(e_mca_in_port, m_response(v_response));
tc_ac.start(10.0);
repeat;
}
[] mcaPortIn.receive(mw_request(mw_create)) -> value v_request {
v_localResourceIndex := f_processCreateRequestPrimitive(v_request.primitive.requestPrimitive);
f_send(e_mcc_in_port, m_response(vc_response.primitive.responsePrimitive));
tc_ac.start(10.0);
repeat;
}
[] mcaPortIn.receive {
log(__SCOPE__&": WARNING: Unexpected message received");
repeat;
}
[] mcaPort.receive {
log(__SCOPE__&": WARNING: Unexpected message received");
repeat;
}
}
/**
* @desc Activation of the corresponding default altstep depending on config for CseSimu
*/
function f_ae_activateDefaults_cse1() runs on CseSimu {
if(not(self == mtc)) {
activate(a_default());
if(vc_config == e_cf03) {
activate(a_ae_cf03());
log(__SCOPE__&": INFO: Default cf03 activated");
}
}
}
}//end group AeAltstepFunctions
}//end of aeFunctions
group GetSetFunctions {
/**
* @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 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_TS_CSE1.cseId;
} else {
p_request.from_ := f_getOriginator(p_parentIndex, vc_testSystemRole);
}
}
//Only set To parameter if it has not been set yet
if(valueof(p_request.to_) == "NotInitialized") {
p_request.to_ := f_getResourceAddress(p_parentIndex);
}
if (p_resourceType == int1) {//AccessControlPolicy
} else if (p_resourceType == int2) {//AE
if(ispresent(p_request.primitiveContent.aE.pointOfAccess)) {
p_request.primitiveContent.aE.requestReachability := true;
}
} else if (p_resourceType == int16) {//remoteCSE
if(ispresent(p_request.primitiveContent.remoteCSE.pointOfAccess)) {
p_request.primitiveContent.remoteCSE.requestReachability := true;
}
} else if (p_resourceType == int9) {//group
if(match(valueof(p_request.primitiveContent.group_.memberIDs), v_defaultListOfURIs )){
if (p_parentIndex == -1){
p_request.primitiveContent.group_.memberIDs := {};
}else{
p_request.primitiveContent.group_.memberIDs := {f_getResourceId(vc_resourcesList[p_parentIndex].resource)};
}
}
} else 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)};
}
}
} else if (p_resourceType == int15) {//pollingChannel
if(ischosen(vc_resourcesList[p_parentIndex].resource.aE)) {
p_request.from_ := vc_resourcesList[p_parentIndex].resource.aE.aE_ID;
}
} else if (p_resourceType == int18) {//schedule
} else if (p_resourceType == int23) {//subscription
//notificationURI
if(match(valueof(p_request.primitiveContent.subscription.notificationURI), v_defaultListOfURIs )){
p_request.primitiveContent.subscription.notificationURI := {f_getResourceAddress(f_getResourceIndex(f_getOriginator(p_parentIndex)))};
}
//subscriberURI
if(ispresent(p_request.primitiveContent.subscription.subscriberURI)) {
if(match(valueof(p_request.primitiveContent.subscription.subscriberURI), "NotInitialized" )){
p_request.primitiveContent.subscription.subscriberURI := valueof(p_request.from_);
}
}
//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)};
}
}
} else 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);
p_request.from_ := f_getOriginator(p_resourceIndex);
if(p_resourceType != int10002) {
//Only set To parameter if it has not been set yet
if(valueof(p_request.to_) == "NotInitialized") {
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.containerAnnc)) {
return f_resourceIdCleaner(p_contentResource.containerAnnc.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 f_resourceIdCleaner(p_contentResource.m2mServiceSubscriptionProfile.resourceID);
}
if(ischosen(p_contentResource.node)) {
return f_resourceIdCleaner(p_contentResource.node.resourceID);
}
if(ischosen(p_contentResource.statsConfig)) {
return f_resourceIdCleaner(p_contentResource.statsConfig.resourceID);
}
if(ischosen(p_contentResource.statsCollect)) {
return f_resourceIdCleaner(p_contentResource.statsCollect.resourceID);
}
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;
}
if(ischosen(p_contentResource.genericInterworkingService)) {
return p_contentResource.genericInterworkingService.resourceName;
}
if(ischosen(p_contentResource.genericInterworkingService_invalid)) {
return p_contentResource.genericInterworkingService_invalid.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 TS acting as an AE or a CSE
* @return Originator for a given resource
* @verdict
*/
function f_getOriginator(integer p_targetResourceIndex := -1, TestSystemRole p_testSystemRole := e_ae) runs on Tester return XSD.AnyURI {
if(p_targetResourceIndex == -1) {
if(p_testSystemRole == e_ae) {
return PX_SUPER_AE_ID;
} else if (p_testSystemRole == e_cse) {
return PX_SUPER_CSE_ID;
}
}
if(vc_resourcesList[p_targetResourceIndex].parentIndex == -1) {
if(ischosen(vc_resourcesList[p_targetResourceIndex].resource.aE)) {
if(isvalue(vc_resourcesList[p_targetResourceIndex].resource.aE.aE_ID)) {
return vc_resourcesList[p_targetResourceIndex].resource.aE.aE_ID;
} else {
return PX_SUPER_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_getCompletePoA(in PortDesc p_portDesc := PX_TS_CSE1.mccPortIn, charstring p_announcementTargetResource := "") return charstring {
var charstring v_poa;
log(">>> f_getCompletePoA: ", p_portDesc);
if (ischosen(p_portDesc.binding.httpBindingDesc)) {
v_poa := "http://" & p_portDesc.binding.httpBindingDesc.bindingDesc.tsAddress;
if (ispresent(p_portDesc.binding.httpBindingDesc.bindingDesc.localPort)) {
v_poa := v_poa & ":" & int2str(p_portDesc.binding.httpBindingDesc.bindingDesc.localPort);
}
} else if (ischosen(p_portDesc.binding.coapBindingDesc)) {
v_poa := "coap://" & p_portDesc.binding.coapBindingDesc.bindingDesc.tsAddress;
if (ispresent(p_portDesc.binding.coapBindingDesc.bindingDesc.localPort)) {
v_poa := v_poa & ":" & int2str(p_portDesc.binding.coapBindingDesc.bindingDesc.localPort);
}
} else if (ischosen(p_portDesc.binding.mqttBindingDesc)) {
v_poa := "mqtt://" & p_portDesc.binding.mqttBindingDesc.bindingDesc.tsAddress;
if (ispresent(p_portDesc.binding.mqttBindingDesc.bindingDesc.localPort)) {
v_poa := v_poa & ":" & int2str(p_portDesc.binding.mqttBindingDesc.bindingDesc.localPort);
}
} else {
v_poa := "ws://" & p_portDesc.binding.wsBindingDesc.bindingDesc.tsAddress;
if (ispresent(p_portDesc.binding.wsBindingDesc.bindingDesc.localPort)) {
v_poa := v_poa & ":" & int2str(p_portDesc.binding.wsBindingDesc.bindingDesc.localPort);
}
}
v_poa := v_poa & "/" & p_announcementTargetResource;
return v_poa;
}
function f_getPortAddress(in PortDesc p_portDesc := PX_TS_CSE1.mcaPortIn) return charstring {
if (ischosen(p_portDesc.binding.httpBindingDesc)) {
return p_portDesc.binding.httpBindingDesc.bindingDesc.tsAddress;
} else if (ischosen(p_portDesc.binding.coapBindingDesc)) {
return p_portDesc.binding.coapBindingDesc.bindingDesc.tsAddress;
} else if (ischosen(p_portDesc.binding.mqttBindingDesc)) {
return p_portDesc.binding.mqttBindingDesc.bindingDesc.tsAddress;
} else {
return p_portDesc.binding.wsBindingDesc.bindingDesc.tsAddress;
}
}
/**
* @desc Resolution of the local 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_getLocalResourceIndex(in XSD.ID p_receivedURI) runs on CseSimu return integer {
var integer v_resourceIndex := -1;
var integer i;
var XSD.ID v_cleanedURI;
v_cleanedURI := f_resourceIdCleaner(p_receivedURI);
if (f_isHierarchical(p_receivedURI)) {
log("Hierarchical method: " & v_cleanedURI);
for(i:=0; i < lengthof(vc_localResourcesList); i := i+1){
if(v_cleanedURI == f_getResourceName(vc_localResourcesList[i].resource)){
v_resourceIndex := i;
break;
}
}
} else {
for(i:=0; i < lengthof(vc_localResourcesList); i := i+1){
if(v_cleanedURI == f_getResourceId(vc_localResourcesList[i].resource)){
v_resourceIndex := i;
log("Non Hierarchical method: " & v_cleanedURI);
break;
}
}
}
log("Resource index found: " & int2str(v_resourceIndex));
//Try CSEBase
if(v_resourceIndex == -1) {
if(v_cleanedURI == f_getResourceName(vc_localResourcesList[vc_cSEBaseIndex].resource)) {
log("Hierarchical method: " & v_cleanedURI);
v_resourceIndex := vc_cSEBaseIndex;
} else if (v_cleanedURI == f_getResourceId(vc_localResourcesList[vc_cSEBaseIndex].resource)) {
log("Non Hierarchical method: " & v_cleanedURI);
v_resourceIndex := vc_cSEBaseIndex;
}
}
log("Resource index found: " & int2str(v_resourceIndex));
return v_resourceIndex;
}
/**
* @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.ID p_receivedURI) runs on Tester return integer {
var integer v_resourceIndex := -1;
var integer i;
var XSD.ID v_cleanedURI;
v_cleanedURI := f_resourceIdCleaner(p_receivedURI);
if (f_isHierarchical(p_receivedURI)) {
log("Hierarchical method: " & v_cleanedURI);
for(i:=0; i < lengthof(vc_resourcesList); i := i+1){
if(v_cleanedURI == f_getResourceName(vc_resourcesList[i].resource)){
v_resourceIndex := i;
break;
}
}
} else {
for(i:=0; i < lengthof(vc_resourcesList); i := i+1){
if(v_cleanedURI == f_getResourceId(vc_resourcesList[i].resource)){
v_resourceIndex := i;
log("Non Hierarchical method: " & v_cleanedURI);
break;
}
}
}
log("Resource index found: " & int2str(v_resourceIndex));
return v_resourceIndex;
}
/**
* @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_addressingMethod == e_hierarchical){
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_targetResourceIndex == -1) {
return PX_CSE_RESOURCE_ID;
} else {
v_resourceAddress := f_getResourceAddress(vc_resourcesList[p_targetResourceIndex].parentIndex, e_nonHierarchical, 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_addressingMethod == e_hierarchical){
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_targetResourceIndex == -1) {
return PX_CSE_ID & "/" & PX_CSE_RESOURCE_ID;
} else {
v_resourceAddress := f_getResourceAddress(vc_resourcesList[p_targetResourceIndex].parentIndex, e_nonHierarchical, 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 & "/" & PX_CSE_RESOURCE_ID;
} else {
v_resourceAddress := PX_SP_ID & PX_CSE_ID & "/" & f_getResourceId(vc_resourcesList[p_targetResourceIndex].resource);
return v_resourceAddress;
}
} else if (p_addressingMethod == e_hierarchical){
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 {
if(p_targetResourceIndex == -1) {
return PX_SP_ID & PX_CSE_ID & "/" & PX_CSE_RESOURCE_ID;
} else {
v_resourceAddress := f_getResourceAddress(vc_resourcesList[p_targetResourceIndex].parentIndex, e_nonHierarchical, 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 := 0, 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 == 0) {
return PX_TS_CSE1.cseResourceId;
} else {
return f_getResourceId(vc_localResourcesList[p_targetResourceIndex].resource);
}
} else {
if(p_targetResourceIndex == 0) {
return PX_TS_CSE1.cseName;
} 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 == 0) {
return PX_TS_CSE1.cseId & "/" & PX_TS_CSE1.cseResourceId;
} else {
v_resourceAddress := PX_TS_CSE1.cseId & "/" & f_getResourceId(vc_localResourcesList[p_targetResourceIndex].resource);
return v_resourceAddress;
}
} else {
if(p_targetResourceIndex == 0) {
return PX_TS_CSE1.cseId & "/" & PX_TS_CSE1.cseName;
} 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 == 0) {
return PX_TS_CSE1.spId & PX_TS_CSE1.cseId & "/" & PX_TS_CSE1.cseResourceId;
} else {
v_resourceAddress := PX_TS_CSE1.spId & PX_TS_CSE1.cseId & "/" & f_getResourceId(vc_localResourcesList[p_targetResourceIndex].resource);
return v_resourceAddress;
}
} else {
if(p_targetResourceIndex == 0) {
return PX_TS_CSE1.spId & PX_TS_CSE1.cseId & "/" & PX_TS_CSE1.cseName;
} 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 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
/**
* @desc Retrieve Time from a given timestamp
* @param p_timestamp Given timestamp
* @return Time
*/
function f_getTime(charstring p_timestamp) runs on Tester return integer {
var charstring v_time := "";
var integer i;
for(i := 9; i <= 14; i := i+1){
v_time := v_time & p_timestamp[i];
}
return str2int(v_time);
} // end f_getTime
/**
* @desc Retrieve Year from a given timestamp
* @param p_timestamp Given timestamp
* @return Year
*/
function f_getYear(charstring p_timestamp) runs on Tester return integer {
var charstring v_year := "";
var integer i;
for(i := 0; i <= 3; i := i+1){
v_year := v_year & p_timestamp[i];
}
return str2int(v_year);
} // end f_getYear
/**
* @desc Retrieve Month from a given timestamp
* @param p_timestamp Given timestamp
* @return Year
*/
function f_getMonth(charstring p_timestamp) runs on Tester return integer {
var charstring v_month := "";
var integer i;
for(i := 4; i <= 5; i := i+1){
if(p_timestamp[i] != "0") {
v_month := v_month & p_timestamp[i];
}
}
return str2int(v_month);
} // end f_getYear
/**
* @desc Retrieve IP address from a given address which includes port information separated by :
* @param p_portDesc Given address
* @return IPv4 Address
*/
function f_getIpv4Address(in PortDesc p_portDesc) runs on Tester return charstring {
var charstring v_ipv4Address := "";
if (ischosen(p_portDesc.binding.httpBindingDesc)) {
v_ipv4Address := p_portDesc.binding.httpBindingDesc.bindingDesc.tsAddress;
} else if (ischosen(p_portDesc.binding.coapBindingDesc)) {
v_ipv4Address := p_portDesc.binding.coapBindingDesc.bindingDesc.tsAddress;
} else if (ischosen(p_portDesc.binding.mqttBindingDesc)) {
v_ipv4Address := p_portDesc.binding.mqttBindingDesc.bindingDesc.tsAddress;
} else {
v_ipv4Address := p_portDesc.binding.wsBindingDesc.bindingDesc.tsAddress;
}
return v_ipv4Address;
} // end f_getIpv4Address
/**
* @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(p_resourceType == int2 or p_parentIndex == -1) {//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) 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 Set parentID into the resource
* @param p_resource Resource to be modified
* @param p_parentID ParentID to be set
* @return
* @verdict
*/
function f_setParentID(PrimitiveContent p_resource, XSD.ID p_parentID) runs on Tester return PrimitiveContent {
if (ischosen(p_resource.aE)){
p_resource.aE.parentID := p_parentID;
}
else if (ischosen(p_resource.accessControlPolicy)){
p_resource.accessControlPolicy.parentID := p_parentID;
}
else if (ischosen(p_resource.accessControlPolicyAnnc)){
p_resource.accessControlPolicyAnnc.parentID := p_parentID;
}
else if (ischosen(p_resource.container)){
p_resource.container.parentID := p_parentID;
}
else if (ischosen(p_resource.containerAnnc)){
p_resource.containerAnnc.parentID := p_parentID;
}
else if (ischosen(p_resource.group_)){
p_resource.group_.parentID := p_parentID;
}
else if (ischosen(p_resource.groupAnnc)){
p_resource.groupAnnc.parentID := p_parentID;
}
else if (ischosen(p_resource.serviceSubscribedAppRule)){
p_resource.serviceSubscribedAppRule.parentID := p_parentID;
}
else if (ischosen(p_resource.subscription)){
p_resource.subscription.parentID := p_parentID;
}
else if (ischosen(p_resource.locationPolicy)){
p_resource.locationPolicy.parentID := p_parentID;
}
else if (ischosen(p_resource.delivery)){
p_resource.delivery.parentID := p_parentID;
}
else if (ischosen(p_resource.mgmtCmd)){
p_resource.mgmtCmd.parentID := p_parentID;
}
else if (ischosen(p_resource.node)){
p_resource.node.parentID := p_parentID;
}
else if (ischosen(p_resource.remoteCSE)){
p_resource.remoteCSE.parentID := p_parentID;
}
else if (ischosen(p_resource.remoteCSE)){
p_resource.remoteCSE.parentID := p_parentID;
}
else if (ischosen(p_resource.request)){
p_resource.request.parentID := p_parentID;
}
else if (ischosen(p_resource.statsCollect)){
p_resource.statsCollect.parentID := p_parentID;
}
else if (ischosen(p_resource.statsConfig)){
p_resource.statsConfig.parentID := p_parentID;
}
else if (ischosen(p_resource.timeSeries)){
p_resource.timeSeries.parentID := p_parentID;
}
else if (ischosen(p_resource.timeSeriesAnnc)){
p_resource.timeSeriesAnnc.parentID := p_parentID;
} else {
log( __SCOPE__, ":INFO: Resource not having acpi attribute. Not possible to set acpi")
}
return valueof(p_resource);
}
}//end group getSetFunctions
group CheckingFunctions {
group ComponentStatus {
/**
* @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) {
f_cf02Down();
}
kill;
} else {
log(__SCOPE__, ":INFO: AeSimu status OK");
}
}
/**
* @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();
//Tear down
if(vc_config == e_cf03) {
f_cf03Down();
} else if (vc_config ==e_cf04) {
f_cf04Down();
} else if (vc_config == e_cf02CseSimuMaster) {
f_cf02DownCseSimuMaster();
}
kill;
} else {
log(__SCOPE__, ":INFO: CseSimu status OK");
}
}
/**
* @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_aeSimu_checkComponentDoneAndGetVerdict(Tester p_component) runs on AeSimu {
var verdicttype v_verdict := none;
tc_done.start(15.0);
alt {
[] p_component.done -> value v_verdict {
tc_done.stop;
}
[] tc_done.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_cseSimu_checkComponentDoneAndGetVerdict(Tester p_component) runs on CseSimu {
var verdicttype v_verdict := none;
tc_done.start(15.0);
alt {
[] p_component.done -> value v_verdict {
tc_done.stop;
}
[] tc_done.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_checkCseSimuStatus();
}
}//end of group ComponentStatus
/**
* @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;
}
}
/**
* @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
/**
* @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(isvalue(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(isvalue(p_requestPrimitive.primitiveContent.responsePrimitive.primitiveContent.aE)) {
v_matchResult :=match(p_requestPrimitive.primitiveContent.responsePrimitive.primitiveContent.aE, p_primitiveContent.aE);
}
else if (isvalue(p_requestPrimitive.primitiveContent.aggregatedNotification.notification_list)) {
v_matchResult := true;
v_numberOfAggregatedNotification := lengthof(p_requestPrimitive.primitiveContent.aggregatedNotification.notification_list);
for(i := 0; i< v_numberOfAggregatedNotification; i := i + 1){
if(isvalue(p_requestPrimitive.primitiveContent.aggregatedNotification.notification_list[i].notificationEvent.representation.resource.aE)) {
if(not (match(p_requestPrimitive.primitiveContent.aggregatedNotification.notification_list[i].notificationEvent.representation.resource.aE, p_primitiveContent.aE))){
v_matchResult := false;
}
}
}
if (i == 0){
v_matchResult := false;
}
}
}
if (ischosen(p_primitiveContent.container)){
if(isvalue(p_requestPrimitive.primitiveContent.notification.notificationEvent.representation.resource.container)) {
v_matchResult := match(p_requestPrimitive.primitiveContent.notification.notificationEvent.representation.resource.container, p_primitiveContent.container)
}
else if(isvalue(p_requestPrimitive.primitiveContent.responsePrimitive.primitiveContent.container)) {
v_matchResult := match(p_requestPrimitive.primitiveContent.responsePrimitive.primitiveContent.container, p_primitiveContent.container)
}
}
if (ischosen(p_primitiveContent.timeSeries)){
if(isvalue(p_requestPrimitive.primitiveContent.notification.notificationEvent.representation.resource.timeSeries)) {
v_matchResult := match(p_requestPrimitive.primitiveContent.notification.notificationEvent.representation.resource.timeSeries, p_primitiveContent.timeSeries)
}
else if(isvalue(p_requestPrimitive.primitiveContent.responsePrimitive.primitiveContent.timeSeries)) {
v_matchResult := match(p_requestPrimitive.primitiveContent.responsePrimitive.primitiveContent.timeSeries, p_primitiveContent.timeSeries)
}
}
return v_matchResult;
} //end f_check_notificationContent
}//end group CheckingFunctions
group CommonFunctions {
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
group AcFunctions {
/**
* @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}});
}
}//end of group AcFunctions
group UtFunctions {
/**
* @desc Sending of an Upper Tester primitive
* @param p_utRequest Action to be performed by IUT
* @param p_action Description of the given action to be performed by the IUT
* @verdict
*/
function f_sendUtPrimitive(template UtTriggerPrimitive p_utRequest, in universal charstring p_action) runs on CseSimu {
if (PX_UT_IMPLEMENTED){
p_utRequest.requestPrimitive.requestIdentifier := "m_uttriggerPrimitive" & f_rnd(1, 1000000);
deactivate;
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!");
}
}
f_checkCseSimuStatus();
activate(a_default());
//In case UtPrimitive is used from AeSimu
/*if(vc_config == e_cf01) {
vc_aeSimu := activate(a_cse_cf01());
} else if ((vc_config == e_cf02) or (vc_config == e_cf02CseSimuMaster)) {
if(vc_testSystemRole == e_ae) {
vc_aeSimu := activate(a_cse_cf02_ae1());
} else if (vc_testSystemRole == e_cse) {
vc_cseSimu := activate(a_cse_cf02_cse1());
}
} else */
if (vc_config == e_cf03) {
vc_cseSimu := activate(a_ae_cf03());
} else if (vc_config == e_cf04) {
vc_cseSimu := activate(a_cse_cf04());
}
}else{
action(p_action);
}
}
}//end of group UtFunctions
/**
* @desc Proccessing of the CREATE request primitive
* @param p_request Request primitive to be processed
* @return Local resource index
*/
function f_processCreateRequestPrimitive(in RequestPrimitive p_request) runs on CseSimu return integer {
var integer v_parentIndex := -1;
var integer v_localResourceIndex := -1;
var PrimitiveContent v_localResource;
v_parentIndex := f_getLocalResourceIndex(p_request.to_);
if(v_parentIndex == -1) {
setverdict(inconc,__SCOPE__&": ERROR: Target resource not found");
vc_response.primitive.responsePrimitive := valueof(m_responsePrimitive(int4004,p_request.requestIdentifier));
} else {
setverdict(pass, __SCOPE__&":INFO: Resource created successfuly");
v_localResource := f_generateLocalResource(p_request.primitiveContent, v_parentIndex, p_request.resourceType);
v_localResourceIndex := f_setLocalResource(v_localResource, p_request.resourceType, v_parentIndex);
vc_response.primitive.responsePrimitive := valueof(m_responsePrimitive(int2001,p_request.requestIdentifier));
vc_response.primitive.responsePrimitive.primitiveContent := vc_localResourcesList[v_localResourceIndex].resource;
}
vc_response.primitive.responsePrimitive.from_ := PX_TS_CSE1.cseId;
vc_response.primitive.responsePrimitive.to_ := p_request.from_;
return v_localResourceIndex;
}
/**
* @desc Proccessing of the UPDATE request primitive
* @param p_request Request primitive to be processed
*/
function f_processUpdateRequestPrimitive(in RequestPrimitive p_request) runs on CseSimu return integer {
var integer v_targetLocalResourceIndex := -1;
v_targetLocalResourceIndex := f_getLocalResourceIndex(p_request.to_);
if(v_targetLocalResourceIndex == -1) {
setverdict(inconc,__SCOPE__&": ERROR: Target resource not found");
vc_response.primitive.responsePrimitive := valueof(m_responsePrimitive(int4004,p_request.requestIdentifier));
} else {
setverdict(pass, __SCOPE__&":INFO: Resource updated successfuly");
f_updateLocalResource(v_targetLocalResourceIndex, p_request.primitiveContent);
vc_response.primitive.responsePrimitive := valueof(m_responsePrimitive(int2004,p_request.requestIdentifier));
vc_response.primitive.responsePrimitive.primitiveContent := vc_localResourcesList[v_targetLocalResourceIndex].resource;
}
vc_response.primitive.responsePrimitive.from_ := PX_TS_CSE1.cseId;
vc_response.primitive.responsePrimitive.to_ := p_request.from_;
return v_targetLocalResourceIndex;
}
/**
* @desc Proccessing of the RETRIEVE request primitive
* @param p_request Request primitive to be processed
*/
function f_processRetrieveRequestPrimitive(in RequestPrimitive p_request) runs on CseSimu return integer {
var integer v_targetLocalResourceIndex := -1;
v_targetLocalResourceIndex := f_getLocalResourceIndex(p_request.to_);
if(v_targetLocalResourceIndex == -1) {
setverdict(inconc,__SCOPE__&": ERROR: Target resource not found");
vc_response.primitive.responsePrimitive := valueof(m_responsePrimitive(int4004,p_request.requestIdentifier));
} else {
setverdict(pass, __SCOPE__&":INFO: Resource retrieved successfuly");
vc_response.primitive.responsePrimitive := valueof(m_responsePrimitive(int2000,p_request.requestIdentifier));
vc_response.primitive.responsePrimitive.primitiveContent := vc_localResourcesList[v_targetLocalResourceIndex].resource;
}
vc_response.primitive.responsePrimitive.from_ := PX_TS_CSE1.cseId;
vc_response.primitive.responsePrimitive.to_ := p_request.from_;
return v_targetLocalResourceIndex;
}
/**
* @desc Proccessing of the DELETE request primitive
* @param p_request Request primitive to be processed
*/
function f_processDeleteRequestPrimitive(in RequestPrimitive p_request) runs on CseSimu return integer {
var integer v_targetLocalResourceIndex := -1;
v_targetLocalResourceIndex := f_getLocalResourceIndex(p_request.to_);
if(v_targetLocalResourceIndex == -1) {
setverdict(inconc,__SCOPE__&": ERROR: Target resource not found");
vc_response.primitive.responsePrimitive := valueof(m_responsePrimitive(int4004,p_request.requestIdentifier));
} else {
setverdict(pass, __SCOPE__&":INFO: Resource deleted successfuly");
vc_response.primitive.responsePrimitive := valueof(m_responsePrimitive(int2002,p_request.requestIdentifier));
}
vc_response.primitive.responsePrimitive.from_ := PX_TS_CSE1.cseId;
vc_response.primitive.responsePrimitive.to_ := p_request.from_;
return v_targetLocalResourceIndex;
}
/**
* @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 Replace the CSE-Name by the shortcut ("-") in a structured resource id format
* @return Cleaned-up resourceID
*/
function f_useShortcutInResourceId(in XSD.ID p_resourceID) return XSD.ID {
var integer v_length := lengthof(p_resourceID);
var integer i;
var integer v_numberOfSlashes := 0;
var XSD.ID v_modifiedResourceId:= "";
var XSD.ID v_cseName := "";
if(p_resourceID[0] == "/") {
if(p_resourceID[1] == "/") {
v_numberOfSlashes := 4;
} else {
v_numberOfSlashes := 2;
}
}
//log("p_resourceID: " & p_resourceID);
for (i := 0; i < v_length ; i := i+1){
if(v_numberOfSlashes != 0) {
if(p_resourceID[i]=="/"){
v_numberOfSlashes := v_numberOfSlashes - 1;
}
v_modifiedResourceId := v_modifiedResourceId & p_resourceID[i];
} else if (v_numberOfSlashes == 0){
if(p_resourceID[i]=="/"){
v_numberOfSlashes := v_numberOfSlashes - 1;
v_modifiedResourceId := v_modifiedResourceId & "-/";
log(__SCOPE__, "INFO: CSE Name to be removed from resource ID: " & v_cseName);
}
v_cseName := v_cseName & p_resourceID[i];
} else if (v_numberOfSlashes == -1){
v_modifiedResourceId := v_modifiedResourceId & p_resourceID[i];
}
}
return v_modifiedResourceId;
}
/**
* @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 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 ");
}
}
function f_send(
in InterfaceIds p_interfaceIds,
in template MsgOut p_msgOut
) runs on Tester {
log(">>> f_send: ", p_interfaceIds);
p_msgOut.host := vc_myInterfaces[enum2int(p_interfaceIds)].myHost;
p_msgOut.protocolBinding := vc_myInterfaces[enum2int(p_interfaceIds)].myProtocolBinding;
p_msgOut.serialization := vc_myInterfaces[enum2int(p_interfaceIds)].mySerialization;
log("f_send: protocolBinding=", p_msgOut.protocolBinding);
vc_myInterfaces[enum2int(p_interfaceIds)].myPort.send(p_msgOut);
}
}//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