1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
|
// Comment(s) to the function f_MyFunction
function f_<FunctionName>(
in template <TypeId> pl_<formalParName1>,
out <TypeId> pl_<formalParName2>,
inout <TypeId> pl_<formalParName3>,
timer pl_<timerFormalParName>,
<PortTypeName>_PT pl_<portFormalParName>)
{
//function body
}
// Comment(s) to the function f_MyPTCFunction1
function f_<FunctionName2>(
in <TypeId> pl_<formalParName>)
runs on <componentTypeName>_CT
return <TypeId>
{
//local definitions
const integer cl_<constantName> := 0;
var boolean <variableName> := true;
var <TypeId> vl_<localVariableName>;
var <componentTypeName>_CT vl_<CompReference>;
var default vl_<defaultReference1>, vl_<defaultReference2>, vl_<defaultReference3>;
timer Tl_<localTimer> := 5.0;
vl_<defaultReference1> := activate(as_<altStepName1>());
vl_<defaultReference2> := activate(as_<altStepName2>(Tl_<localTimer>));
vl_<defaultReference3> := activate(as_<altStepName3>(<parameterName>));
Tl_<localTimer>.start;
//example alt statement
alt
{
[] // Entire heading fit into one line
<PortName>.receive(<TypeId>:?) from v_<addressVariableName> -> value vl_<localVariableName>
{
// 1st statement body
}
[] <PortName>.trigger(t_<templateName>)
-> value v_<ComponentTypeNameType> sender v_<CompReference>
{
// 2nd statement body
}
[<booleanCondition>] // More complicated alternative
<PortName>.receive(tr_<templateName>(
tr_<templateName>(
?,
tr_<templateName>("baab")),
c_<constantName>))
from v_<addressVariableName>
-> value v_<TypeId>
{
// 3rd statement body
}
[] <PortName>.receive(charstring:?)
-> value v_<TypeId> sender vl_<CompReference>
{
// 4th statement body
}
} // alt
//simple if example
if (Tl_<TimerName>.running){ Tl_<TimerName>.stop};
// if-else and do-while example
do
{
<PortName>.send (t_<templateName>) to v_<variableName>;
<PortName>.receive(<TypeId>:?) -> value vl_<variableName>;
if (match(vl_<variableName>,t_<templateName>))
{
// statements
setverdict(pass);
<variableName> := false;
}
else
{
log ("MyFunc(W):IUT is not transparent")
}
} while (<variableName>)
//for loop example
for(var integer <i> := 0; <i> < 8; <i> := <i> + 1)
{
<PortName>.send(t_<templateName>);
<PortName>.receive(t_<templateName>);
};
// label-goto example
<PortName>.receive(charstring:"START");
label <labelId>;
<PortName>.send (t_<TypeId>);
<PortName>.receive (t_<TypeId>);
goto <labelId>;
} // function f_MyPTCFunction1
// Comment to the function f_MyPTCFunction2
function f_<FunctionName3>()
runs on <componentTypeName>_CT
{
//local definitions
var <TypeId> vl_<variableName>;
var <TypeId> vl_<variableName>;
var <TypeId> vl_<variableName>;
var <TypeId> vl_<variableName>;
//infinite loop example
while(true)
{
//procedure based communication example
//handling outgoing blocking call
<PortName>.call(t_<templateName>, tspx_<testSuiteParameterName>) to v_<AddressVariable>
{
[] <PortName>.getreply(tr_<procedureTemplateName>)
from v_<AddressVariable>
-> value vl_<variableName> param(vl_<paramName>,vl_<paramName>)
sender v_<AddressVariable>
{
// statements
}
[] <PortName>.catch(S_<ProcedureSignatureName>, <ExceptionTypeId>:?)
{
// statements
}
[] <PortName>.catch(timeout)
{
// statements
}
} // call
//handling incoming blocking call
<PortName>.getcall(tr_<MyProcedure>)
from v_<AddressVariable>
-> param(vl_<paramName>, vl_<paramName>) sender v_<AddressVariable>;
if (<booleanCondition>)
{
<PortName>.reply(t_<ProcedureReply> value vl_<variableName>) to v_<AddressVar>;
}
else
{
<PortName>.raise(S_<ProcedureSignature>, <ExceptionType1>:cg_<errorCodeOne>)
to v_<AddressVar>;
}
} // while
} // function f_MyPTCFunction2
|