summaryrefslogtreecommitdiff
path: root/cesar/ce
diff options
context:
space:
mode:
authordufour2010-04-06 11:10:28 +0000
committerdufour2010-04-06 11:10:28 +0000
commit02305a484b2ad72a97c6c027f7492cb89ba22a62 (patch)
tree15bfbf530d680a1e5efac3a232218f2b7e76d315 /cesar/ce
parent944eb5c370f2417eaf99f4cad28cd1b9990df1e3 (diff)
cesar/ce/rx/bl: clean FSM
This commit does not change the behavior of the BL FSM, just clean comments, indent and rename a few things. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@6877 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/ce')
-rw-r--r--cesar/ce/rx/bitloading/fsm/src/fsm/bl.fsm56
-rw-r--r--cesar/ce/rx/bitloading/fsm/src/tables.c8
-rw-r--r--cesar/ce/rx/bitloading/inc/transition.h39
-rw-r--r--cesar/ce/rx/bitloading/src/transition.c74
-rw-r--r--cesar/ce/rx/bitloading/test/inc/scenario_defs.h12
-rw-r--r--cesar/ce/rx/bitloading/test/src/scenario_actions.c6
-rw-r--r--cesar/ce/rx/bitloading/test/src/test_fsm.c32
-rw-r--r--cesar/ce/rx/src/rx.c2
8 files changed, 109 insertions, 120 deletions
diff --git a/cesar/ce/rx/bitloading/fsm/src/fsm/bl.fsm b/cesar/ce/rx/bitloading/fsm/src/fsm/bl.fsm
index 395e40bc45..0a5b17830f 100644
--- a/cesar/ce/rx/bitloading/fsm/src/fsm/bl.fsm
+++ b/cesar/ce/rx/bitloading/fsm/src/fsm/bl.fsm
@@ -7,49 +7,31 @@ States:
INITIAL
Gathering sound frames to build first/default tone map.
TRACKING
- Update default tone map with channel data.
+ Update default tone map with measures received from the hardware.
Events:
- channel_data_received
- Some channel data received from the PBProc/SAR (can be sound or not).
- bit_loading_auto_timer
- The timer for the bit loading auto has expired.
- channel_big_changes
- Big changes in the channel.
- no_communication_timer
- No communication with the station has been done since a long time.
+ measure_received
+ A measure has been received from the PBProc/SAR.
IDLE:
- channel_data_received: sound -> INITIAL [ce_rx_bl__IDLE__channel_data_received]
- Copy the noise NRJ to initialize the mean/sum.
- channel_data_received: sound_last -> TRACKING
- Copy the noise NRJ to initialize the mean/sum.
- Compute BER vs SNR table.
- Compute first tone map.
- channel_data_received: not_sound -> .
+ measure_received: sound_not_complete -> INITIAL [ce_rx_bl__IDLE__measure_received]
+ Copy the noise NRJ to initialize the NSR sum.
+ measure_received: sound_complete -> TRACKING
+ Copy the noise NRJ to initialize the NSR sum.
+ Compute NSR mean (required for the moment being).
+ Compute tone map.
+ measure_received: not_sound -> .
Should not happen?
INITIAL:
- channel_data_received: sound_not_last -> . [ce_rx_bl__INITIAL__channel_data_received]
- Just add it to the sum.
- channel_data_received: sound_last -> TRACKING
- Add it to the sum.
- Compute the mean.
- Compute BER vs SNR table.
- Compute first tone map.
- channel_data_received: not_sound -> .
+ measure_received: sound_not_complete -> . [ce_rx_bl__INITIAL__measure_received]
+ Add it to the NSR sum.
+ measure_received: sound_complete -> TRACKING
+ Add it to the NSR sum.
+ Compute the NSR mean.
+ Compute tone map.
+ measure_received: not_sound -> .
TRACKING:
- channel_data_received -> . [ce_rx_bl__TODO]
- Bit loading update.
- Reset communication timer.
- bit_loading_auto_timer -> . [ce_rx_bl__TODO]
- Bit loading automatic.
- Reset communication timer.
- channel_big_changes -> . [ce_rx_bl__TODO]
- Bit loading forced.
- Reset communication timer.
- no_communication_timer -> IDLE [ce_rx_bl__TODO]
- Reset everything, we will restart from scratch when new communication with
- the station will be done.
- If sound frame, reset sound frame counter to receive sound frames.
+ measure_received -> . [ce_rx_bl__TRACKING__measure_received]
+ Ignored for the moment being.
diff --git a/cesar/ce/rx/bitloading/fsm/src/tables.c b/cesar/ce/rx/bitloading/fsm/src/tables.c
index 8b1715d037..d5ed0aab18 100644
--- a/cesar/ce/rx/bitloading/fsm/src/tables.c
+++ b/cesar/ce/rx/bitloading/fsm/src/tables.c
@@ -15,14 +15,6 @@
/* Bit loading initial. */
#include "ce/rx/bitloading/inc/transition.h"
-/* TODO/FIXME: remove this. */
-ce_rx_bl_fsm_branch_t
-ce_rx_bl__TODO (ce_rx_t *ce_rx, sta_t *sta, ce_rx_bitloading_fsm_event_param_t data)
-{
- /* FIXME: this is a dirty fix to disable the tracking bit loading. */
- return ce_rx_bl_fsm_next (TRACKING, channel_data_received);
-}
-
/* Transition tables. */
#include "inc/tables.h"
diff --git a/cesar/ce/rx/bitloading/inc/transition.h b/cesar/ce/rx/bitloading/inc/transition.h
index 968c8ed8c6..06983ee666 100644
--- a/cesar/ce/rx/bitloading/inc/transition.h
+++ b/cesar/ce/rx/bitloading/inc/transition.h
@@ -21,37 +21,38 @@
BEGIN_DECLS
/**
- * Handle reception of channel_data_received in IDLE state.
+ * Handle reception of measure_received in IDLE state.
* \param ce_rx the CE RX context.
* \param sta the corresponding sta.
- * \param chan_data the data associated to the event (channel data).
+ * \param data the data associated to the event.
* \return the next state.
- *
- * It must be based on sound frames.
- *
- * Just copy the noise NRJ to initialize the mean/sum.
*/
ce_rx_bl_fsm_branch_t
-ce_rx_bl__IDLE__channel_data_received (ce_rx_t *ce_rx, sta_t *sta,
- ce_rx_bitloading_fsm_event_param_t
- chan_data);
+ce_rx_bl__IDLE__measure_received (ce_rx_t *ce_rx, sta_t *sta,
+ ce_rx_bitloading_fsm_event_param_t data);
/**
- * Handle reception of channel_data_received in INITIAL state.
+ * Handle reception of measure_received in INITIAL state.
* \param ce_rx the CE RX context.
* \param sta the corresponding sta.
- * \param chan_data the data associated to the event (channel data).
+ * \param data the data associated to the event.
+ * \return the next state.
+ */
+ce_rx_bl_fsm_branch_t
+ce_rx_bl__INITIAL__measure_received (ce_rx_t *ce_rx, sta_t *sta,
+ ce_rx_bitloading_fsm_event_param_t data);
+
+/**
+ * Handle reception of measure_received in TRACKING state.
+ * \param ce_rx the CE RX context.
+ * \param sta the corresponding sta.
+ * \param data the data associated to the event.
* \return the next state.
- *
- * It must be based on sound frames.
- *
- * If not the last one, just copy the noise NRJ to initialize the mean/sum.
- * Otherwise, compute initial tone map.
*/
ce_rx_bl_fsm_branch_t
-ce_rx_bl__INITIAL__channel_data_received (ce_rx_t *ce_rx, sta_t *sta,
- ce_rx_bitloading_fsm_event_param_t
- chan_data);
+ce_rx_bl__TRACKING__measure_received (ce_rx_t *ce_rx, sta_t *sta,
+ ce_rx_bitloading_fsm_event_param_t
+ data);
END_DECLS
diff --git a/cesar/ce/rx/bitloading/src/transition.c b/cesar/ce/rx/bitloading/src/transition.c
index 47fe4f9271..d2bbf9f792 100644
--- a/cesar/ce/rx/bitloading/src/transition.c
+++ b/cesar/ce/rx/bitloading/src/transition.c
@@ -24,72 +24,86 @@
#include "mac/pbproc/pbproc.h"
ce_rx_bl_fsm_branch_t
-ce_rx_bl__IDLE__channel_data_received (ce_rx_t *ce_rx, sta_t *sta,
- ce_rx_bitloading_fsm_event_param_t
- chan_data)
+ce_rx_bl__IDLE__measure_received (ce_rx_t *ce_rx, sta_t *sta,
+ ce_rx_bitloading_fsm_event_param_t data)
{
/* Check parameters. */
dbg_assert (sta);
- dbg_assert (chan_data.measure);
dbg_assert (ce_rx);
dbg_assert (ce_rx->mac_config);
- /* Based on sound? */
- if (chan_data.measure->rx_params.sound)
+ /* Get measure. */
+ ce_rx_measure_mbox_t *measure = data.measure;
+ dbg_assert (measure);
+
+ /* Sound? */
+ if (measure->rx_params.sound)
{
/* Initialize sum of NSR. */
- ce_rx_bl_nsr_sum_init (&sta->ce_rx_bt, chan_data.measure->chan_data,
- chan_data.measure->chan_data_count);
+ ce_rx_bl_nsr_sum_init (&sta->ce_rx_bt, measure->chan_data,
+ measure->chan_data_count);
/* Sound complete? */
- if (chan_data.measure->rx_params.sound_complete)
+ if (measure->rx_params.sound_complete)
{
/* Compute NSR mean (in fact, this is required here because we
* need to apply a margin to the input NSR). */
ce_rx_bl_nsr_compute_mean (&sta->ce_rx_bt);
- /* Start initial tone map. */
+ /* Start initial bit loading. */
ce_rx_bl_start_bl (ce_rx, sta, &ce_rx->mac_config->tonemask_info);
- return ce_rx_bl_fsm_next_branch (IDLE, channel_data_received, sound_last);
+ return ce_rx_bl_fsm_next_branch (IDLE, measure_received,
+ sound_complete);
}
else
- return ce_rx_bl_fsm_next_branch (IDLE, channel_data_received, sound);
+ return ce_rx_bl_fsm_next_branch (IDLE, measure_received,
+ sound_not_complete);
}
else
- return ce_rx_bl_fsm_next_branch (IDLE, channel_data_received,
- not_sound);
+ return ce_rx_bl_fsm_next_branch (IDLE, measure_received, not_sound);
}
ce_rx_bl_fsm_branch_t
-ce_rx_bl__INITIAL__channel_data_received (ce_rx_t *ce_rx, sta_t *sta,
- ce_rx_bitloading_fsm_event_param_t
- chan_data)
+ce_rx_bl__INITIAL__measure_received (ce_rx_t *ce_rx, sta_t *sta,
+ ce_rx_bitloading_fsm_event_param_t data)
{
/* Check parameters. */
dbg_assert (sta);
- dbg_assert (chan_data.measure);
dbg_assert (ce_rx);
dbg_assert (ce_rx->mac_config);
- /* Based on sound? */
- if (chan_data.measure->rx_params.sound)
+ /* Get measure. */
+ ce_rx_measure_mbox_t *measure = data.measure;
+ dbg_assert (measure);
+
+ /* Sound? */
+ if (measure->rx_params.sound)
{
/* Add it to the sum of NSR. */
- ce_rx_bl_nsr_sum_add (&sta->ce_rx_bt, chan_data.measure->chan_data,
- chan_data.measure->chan_data_count);
- /* Last one? */
- if (chan_data.measure->rx_params.sound_complete)
+ ce_rx_bl_nsr_sum_add (&sta->ce_rx_bt, measure->chan_data,
+ measure->chan_data_count);
+ /* Sound complete? */
+ if (measure->rx_params.sound_complete)
{
/* Compute NSR mean. */
ce_rx_bl_nsr_compute_mean (&sta->ce_rx_bt);
- /* Start initial tone map. */
+ /* Start initial bit loading. */
ce_rx_bl_start_bl (ce_rx, sta, &ce_rx->mac_config->tonemask_info);
- return ce_rx_bl_fsm_next_branch (INITIAL, channel_data_received,
- sound_last);
+ return ce_rx_bl_fsm_next_branch (INITIAL, measure_received,
+ sound_complete);
}
else
- return ce_rx_bl_fsm_next_branch (INITIAL, channel_data_received,
- sound_not_last);
+ return ce_rx_bl_fsm_next_branch (INITIAL, measure_received,
+ sound_not_complete);
}
else
- return ce_rx_bl_fsm_next_branch (INITIAL, channel_data_received,
+ return ce_rx_bl_fsm_next_branch (INITIAL, measure_received,
not_sound);
}
+
+ce_rx_bl_fsm_branch_t
+ce_rx_bl__TRACKING__measure_received (ce_rx_t *ce_rx, sta_t *sta,
+ ce_rx_bitloading_fsm_event_param_t
+ data)
+{
+ /* Do nothing for the moment being. */
+ return ce_rx_bl_fsm_next (TRACKING, measure_received);
+}
diff --git a/cesar/ce/rx/bitloading/test/inc/scenario_defs.h b/cesar/ce/rx/bitloading/test/inc/scenario_defs.h
index 37f292b4f8..ccb2594dd8 100644
--- a/cesar/ce/rx/bitloading/test/inc/scenario_defs.h
+++ b/cesar/ce/rx/bitloading/test/inc/scenario_defs.h
@@ -24,9 +24,9 @@
/* Scenario actions. */
#define SCENARIO_DEFS_ACTIONS \
- IDLE__channel_data_received, \
- INITIAL__channel_data_received, \
- TODO
+ IDLE__measure_received, \
+ INITIAL__measure_received, \
+ TRACKING__measure_received
/* Actions with default parameters. */
#define __action(action) \
@@ -42,9 +42,9 @@ scenario_action_ ## action ## _cb ( \
scenario_globals_t *globals, \
scenario_params_t *params);
-__action (IDLE__channel_data_received)
-__action (INITIAL__channel_data_received)
-__action (TODO)
+__action (IDLE__measure_received)
+__action (INITIAL__measure_received)
+__action (TRACKING__measure_received)
#undef __action
diff --git a/cesar/ce/rx/bitloading/test/src/scenario_actions.c b/cesar/ce/rx/bitloading/test/src/scenario_actions.c
index 01d03c4389..80eaaae430 100644
--- a/cesar/ce/rx/bitloading/test/src/scenario_actions.c
+++ b/cesar/ce/rx/bitloading/test/src/scenario_actions.c
@@ -29,6 +29,6 @@ scenario_action_ ## ACTION ## _cb (scenario_globals_t *globals, \
test_fail_unless (ret == params->action_ ## ACTION.branch); \
}
-__action_def (IDLE__channel_data_received);
-__action_def (INITIAL__channel_data_received);
-__action_def (TODO);
+__action_def (IDLE__measure_received);
+__action_def (INITIAL__measure_received);
+__action_def (TRACKING__measure_received);
diff --git a/cesar/ce/rx/bitloading/test/src/test_fsm.c b/cesar/ce/rx/bitloading/test/src/test_fsm.c
index 5a53ab3557..1226d4f481 100644
--- a/cesar/ce/rx/bitloading/test/src/test_fsm.c
+++ b/cesar/ce/rx/bitloading/test/src/test_fsm.c
@@ -53,11 +53,11 @@ test_ce_rx_bl_fsm_base (test_t t)
test_ce_rx_bl_measure_empty (&measure);
scenario_entry_t fsm_base[] =
{
- SCENARIO_ACTION (IDLE__channel_data_received,
+ SCENARIO_ACTION (IDLE__measure_received,
.sta = &sta,
.data = data,
.branch = ce_rx_bl_fsm_next_branch
- (IDLE, channel_data_received, not_sound)),
+ (IDLE, measure_received, not_sound)),
/* Nothing should happen. */
SCENARIO_END,
};
@@ -79,34 +79,34 @@ test_ce_rx_bl_fsm_base (test_t t)
measure_sc.rx_params.sound_complete = true;
scenario_entry_t fsm_base[] =
{
- SCENARIO_ACTION (IDLE__channel_data_received,
+ SCENARIO_ACTION (IDLE__measure_received,
.sta = &sta,
.data = data,
.branch = ce_rx_bl_fsm_next_branch
- (IDLE, channel_data_received, sound)),
+ (IDLE, measure_received, sound_not_complete)),
/* Init NSR. */
SCENARIO_EVENT (ce_rx_bl_nsr_sum_init),
- SCENARIO_ACTION (INITIAL__channel_data_received,
+ SCENARIO_ACTION (INITIAL__measure_received,
.sta = &sta,
.data = data,
.branch = ce_rx_bl_fsm_next_branch
- (INITIAL, channel_data_received,
- sound_not_last)),
+ (INITIAL, measure_received,
+ sound_not_complete)),
/* Increase NSR. */
SCENARIO_EVENT (ce_rx_bl_nsr_sum_add),
- SCENARIO_ACTION (INITIAL__channel_data_received,
+ SCENARIO_ACTION (INITIAL__measure_received,
.sta = &sta,
.data = data,
.branch = ce_rx_bl_fsm_next_branch
- (INITIAL, channel_data_received,
- sound_not_last)),
+ (INITIAL, measure_received,
+ sound_not_complete)),
/* Increase NSR. */
SCENARIO_EVENT (ce_rx_bl_nsr_sum_add),
- SCENARIO_ACTION (INITIAL__channel_data_received,
+ SCENARIO_ACTION (INITIAL__measure_received,
.sta = &sta,
.data = data_sc,
.branch = ce_rx_bl_fsm_next_branch
- (INITIAL, channel_data_received, sound_last)),
+ (INITIAL, measure_received, sound_complete)),
/* Increase NSR. */
SCENARIO_EVENT (ce_rx_bl_nsr_sum_add),
/* Compute Mean. */
@@ -127,11 +127,11 @@ test_ce_rx_bl_fsm_base (test_t t)
measure.rx_params.sound_complete = true;
scenario_entry_t fsm_base[] =
{
- SCENARIO_ACTION (IDLE__channel_data_received,
+ SCENARIO_ACTION (IDLE__measure_received,
.sta = &sta,
.data = data,
.branch = ce_rx_bl_fsm_next_branch
- (IDLE, channel_data_received, sound_last)),
+ (IDLE, measure_received, sound_complete)),
/* Init NSR. */
SCENARIO_EVENT (ce_rx_bl_nsr_sum_init),
/* Compute NSR mean (required because of NSR rescaling). */
@@ -152,11 +152,11 @@ test_ce_rx_bl_fsm_base (test_t t)
measure.rx_params.sound_complete = true;
scenario_entry_t fsm_base[] =
{
- SCENARIO_ACTION (TODO,
+ SCENARIO_ACTION (TRACKING__measure_received,
.sta = &sta,
.data = data,
.branch = ce_rx_bl_fsm_next
- (TRACKING, channel_data_received)),
+ (TRACKING, measure_received)),
/* Nothing should happen. */
SCENARIO_END,
};
diff --git a/cesar/ce/rx/src/rx.c b/cesar/ce/rx/src/rx.c
index c300384542..d6c9f4f3c2 100644
--- a/cesar/ce/rx/src/rx.c
+++ b/cesar/ce/rx/src/rx.c
@@ -208,7 +208,7 @@ ce_rx_process_work_measure (ce_rx_t *ce_rx)
/* Give measure to bit loading. */
ce_rx_bl_fsm_handle_event (ce_rx, sta,
- CE_RX_BL_FSM_EVENT_TYPE_channel_data_received,
+ CE_RX_BL_FSM_EVENT_TYPE_measure_received,
(ce_rx_bitloading_fsm_event_param_t) measure);
/* Release station. */