PCU: introduce f_shutdown() to ensure proper tear down

Most of existing test cases are built on top of the PCU interface
abstraction components (see PCUIF_Components.ttcn). This means
that during the test case execution, additional components are
running in parallel, among with the MTC (Main Test Component).

When a test case terminates, either normally or due to an error,
it may happen that the virtual BTS component is stopped before
the associated TDMA clock generator. In this situation, sending
a clock indication towards the stopped BTS component would
lead to a dynamic test case error.

Let's take the process of tear down under control, and ensure that
the clock generator is stopped first. To achieve that, every test
case needs to call f_shutdown() in case of an error, as well as
in case of the normal termination.

Note we cannot use the existing f_shutdown() from Misc_Helpers,
because doing 'all component.stop' does not gurantee that the
clock generator is stopped first, and I experienced at least
one DTE while trying to integrate it.

Change-Id: I6a859687d9605cc08c51ff44d946c279b79bedfa
Signed-off-by: Vadim Yanitskiy <axilirator@gmail.com>
diff --git a/pcu/PCUIF_Components.ttcn b/pcu/PCUIF_Components.ttcn
index c0266fb..aa2ab42 100644
--- a/pcu/PCUIF_Components.ttcn
+++ b/pcu/PCUIF_Components.ttcn
@@ -100,6 +100,7 @@
 /* Commands are mostly used by the MTC to configure the components
  * at run-time, e.g. to enable or disable some optional features. */
 type enumerated RAW_PCU_CommandType {
+	GENERAL_CMD_SHUTDOWN,		/*!< Shut down component and all its child components */
 	TDMA_CMD_ENABLE_PTCCH_UL_FWD	/*!< Enable forwarding of TDMA_EV_PTCCH_UL_BURST to the MTC */
 };
 
@@ -417,6 +418,11 @@
 	[] as_BTS_CT_TDMASched(bts_nr);
 
 	/* Command handling */
+	[] TC.receive(tr_RAW_PCU_CMD(GENERAL_CMD_SHUTDOWN)) {
+		log("Shutting down virtual BTS #", bts_nr, "...");
+		vc_CLCK_GEN.stop;
+		break;
+		}
 	[] TC.receive(tr_RAW_PCU_CMD(TDMA_CMD_ENABLE_PTCCH_UL_FWD)) {
 		log("Enabling forwarding of PTCCH/U TDMA events to the TC");
 		cfg_ptcch_burst_fwd := true;