Removed state machine running() methods.
--- a/master/fsm.c Mon Oct 23 13:45:09 2006 +0000
+++ b/master/fsm.c Mon Oct 23 14:00:58 2006 +0000
@@ -168,33 +168,13 @@
/**
Executes the current state of the state machine.
-*/
-
-void ec_fsm_execute(ec_fsm_t *fsm /**< finite state machine */)
+ \return false, if state machine has terminated
+*/
+
+int ec_fsm_exec(ec_fsm_t *fsm /**< finite state machine */)
{
fsm->master_state(fsm);
-}
-
-/*****************************************************************************/
-
-/**
- Initializes the master startup state machine.
-*/
-
-void ec_fsm_startup(ec_fsm_t *fsm)
-{
- fsm->master_state = ec_fsm_startup_start;
-}
-
-/*****************************************************************************/
-
-/**
- Returns the running state of the master startup state machine.
- \return non-zero if not terminated yet.
-*/
-
-int ec_fsm_startup_running(ec_fsm_t *fsm /**< Finite state machine */)
-{
+
return fsm->master_state != ec_fsm_end &&
fsm->master_state != ec_fsm_error;
}
@@ -202,6 +182,17 @@
/*****************************************************************************/
/**
+ Initializes the master startup state machine.
+*/
+
+void ec_fsm_startup(ec_fsm_t *fsm)
+{
+ fsm->master_state = ec_fsm_startup_start;
+}
+
+/*****************************************************************************/
+
+/**
Returns, if the master startup state machine terminated with success.
\return non-zero if successful.
*/
@@ -225,19 +216,6 @@
/*****************************************************************************/
/**
- Returns the running state of the master configuration state machine.
- \return non-zero if not terminated yet.
-*/
-
-int ec_fsm_configuration_running(ec_fsm_t *fsm /**< Finite state machine */)
-{
- return fsm->master_state != ec_fsm_end &&
- fsm->master_state != ec_fsm_error;
-}
-
-/*****************************************************************************/
-
-/**
Returns, if the master confuguration state machine terminated with success.
\return non-zero if successful.
*/
@@ -796,9 +774,7 @@
{
ec_slave_t *slave = fsm->slave;
- ec_fsm_sii_exec(&fsm->fsm_sii); // execute SII state machine
-
- if (ec_fsm_sii_running(&fsm->fsm_sii)) return;
+ if (ec_fsm_sii_exec(&fsm->fsm_sii)) return;
if (!ec_fsm_sii_success(&fsm->fsm_sii)) {
fsm->slave->error_flag = 1;
@@ -864,9 +840,7 @@
{
ec_slave_t *slave = fsm->slave;
- ec_fsm_sii_exec(&fsm->fsm_sii); // execute SII state machine
-
- if (ec_fsm_sii_running(&fsm->fsm_sii)) return;
+ if (ec_fsm_sii_exec(&fsm->fsm_sii)) return;
if (!ec_fsm_sii_success(&fsm->fsm_sii)) {
fsm->slave->error_flag = 1;
@@ -1001,9 +975,7 @@
{
ec_slave_t *slave = fsm->slave;
- ec_fsm_sii_exec(&fsm->fsm_sii); // execute SII state machine
-
- if (ec_fsm_sii_running(&fsm->fsm_sii)) return;
+ if (ec_fsm_sii_exec(&fsm->fsm_sii)) return;
if (!ec_fsm_sii_success(&fsm->fsm_sii)) {
fsm->slave->error_flag = 1;
@@ -1266,10 +1238,7 @@
ec_slave_t *slave = fsm->slave;
uint16_t cat_type, cat_size;
- // execute SII state machine
- ec_fsm_sii_exec(&fsm->fsm_sii);
-
- if (ec_fsm_sii_running(&fsm->fsm_sii)) return;
+ if (ec_fsm_sii_exec(&fsm->fsm_sii)) return;
if (!ec_fsm_sii_success(&fsm->fsm_sii)) {
fsm->slave->error_flag = 1;
@@ -1326,10 +1295,7 @@
ec_slave_t *slave = fsm->slave;
uint16_t *cat_word, cat_type, cat_size;
- // execute SII state machine
- ec_fsm_sii_exec(&fsm->fsm_sii);
-
- if (ec_fsm_sii_running(&fsm->fsm_sii)) return;
+ if (ec_fsm_sii_exec(&fsm->fsm_sii)) return;
if (!ec_fsm_sii_success(&fsm->fsm_sii)) {
fsm->slave->error_flag = 1;
@@ -1446,9 +1412,7 @@
const ec_sii_sync_t *sync;
ec_sii_sync_t mbox_sync;
- ec_fsm_change_exec(&fsm->fsm_change); // execute state change state machine
-
- if (ec_fsm_change_running(&fsm->fsm_change)) return;
+ if (ec_fsm_change_exec(&fsm->fsm_change)) return;
if (!ec_fsm_change_success(&fsm->fsm_change)) {
slave->error_flag = 1;
@@ -1571,9 +1535,7 @@
ec_datagram_t *datagram = &fsm->datagram;
unsigned int j;
- ec_fsm_change_exec(&fsm->fsm_change); // execute state change state machine
-
- if (ec_fsm_change_running(&fsm->fsm_change)) return;
+ if (ec_fsm_change_exec(&fsm->fsm_change)) return;
if (!ec_fsm_change_success(&fsm->fsm_change)) {
slave->error_flag = 1;
@@ -1708,9 +1670,7 @@
ec_master_t *master = fsm->master;
ec_slave_t *slave = fsm->slave;
- ec_fsm_change_exec(&fsm->fsm_change); // execute state change state machine
-
- if (ec_fsm_change_running(&fsm->fsm_change)) return;
+ if (ec_fsm_change_exec(&fsm->fsm_change)) return;
if (!ec_fsm_change_success(&fsm->fsm_change)) {
fsm->slave->error_flag = 1;
@@ -1750,9 +1710,7 @@
ec_master_t *master = fsm->master;
ec_slave_t *slave = fsm->slave;
- ec_fsm_change_exec(&fsm->fsm_change); // execute state change state machine
-
- if (ec_fsm_change_running(&fsm->fsm_change)) return;
+ if (ec_fsm_change_exec(&fsm->fsm_change)) return;
if (!ec_fsm_change_success(&fsm->fsm_change)) {
slave->error_flag = 1;
--- a/master/fsm.h Mon Oct 23 13:45:09 2006 +0000
+++ b/master/fsm.h Mon Oct 23 14:00:58 2006 +0000
@@ -89,14 +89,12 @@
int ec_fsm_init(ec_fsm_t *, ec_master_t *);
void ec_fsm_clear(ec_fsm_t *);
void ec_fsm_reset(ec_fsm_t *);
-void ec_fsm_execute(ec_fsm_t *);
+int ec_fsm_exec(ec_fsm_t *);
void ec_fsm_startup(ec_fsm_t *);
-int ec_fsm_startup_running(ec_fsm_t *);
int ec_fsm_startup_success(ec_fsm_t *);
void ec_fsm_configuration(ec_fsm_t *);
-int ec_fsm_configuration_running(ec_fsm_t *);
int ec_fsm_configuration_success(ec_fsm_t *);
/*****************************************************************************/
--- a/master/fsm_change.c Mon Oct 23 13:45:09 2006 +0000
+++ b/master/fsm_change.c Mon Oct 23 14:00:58 2006 +0000
@@ -97,22 +97,13 @@
/**
Executes the current state of the state machine.
-*/
-
-void ec_fsm_change_exec(ec_fsm_change_t *fsm /**< finite state machine */)
+ \return false, if the state machine has terminated
+*/
+
+int ec_fsm_change_exec(ec_fsm_change_t *fsm /**< finite state machine */)
{
fsm->state(fsm);
-}
-
-/*****************************************************************************/
-
-/**
- Returns the running state of the state machine.
- \return non-zero if not terminated yet.
-*/
-
-int ec_fsm_change_running(ec_fsm_change_t *fsm /**< Finite state machine */)
-{
+
return fsm->state != ec_fsm_change_end
&& fsm->state != ec_fsm_change_error;
}
--- a/master/fsm_change.h Mon Oct 23 13:45:09 2006 +0000
+++ b/master/fsm_change.h Mon Oct 23 14:00:58 2006 +0000
@@ -72,8 +72,7 @@
void ec_fsm_change(ec_fsm_change_t *, ec_slave_t *, ec_slave_state_t);
-void ec_fsm_change_exec(ec_fsm_change_t *);
-int ec_fsm_change_running(ec_fsm_change_t *);
+int ec_fsm_change_exec(ec_fsm_change_t *);
int ec_fsm_change_success(ec_fsm_change_t *);
/*****************************************************************************/
--- a/master/fsm_sii.c Mon Oct 23 13:45:09 2006 +0000
+++ b/master/fsm_sii.c Mon Oct 23 14:00:58 2006 +0000
@@ -120,22 +120,13 @@
/**
Executes the SII state machine.
-*/
-
-void ec_fsm_sii_exec(ec_fsm_sii_t *fsm /**< finite state machine */)
+ \return false, if the state machine has terminated
+*/
+
+int ec_fsm_sii_exec(ec_fsm_sii_t *fsm /**< finite state machine */)
{
fsm->state(fsm);
-}
-
-/*****************************************************************************/
-
-/**
- Returns the running state of the master startup state machine.
- \return non-zero if not terminated yet.
-*/
-
-int ec_fsm_sii_running(ec_fsm_sii_t *fsm /**< Finite state machine */)
-{
+
return fsm->state != ec_fsm_sii_end && fsm->state != ec_fsm_sii_error;
}
--- a/master/fsm_sii.h Mon Oct 23 13:45:09 2006 +0000
+++ b/master/fsm_sii.h Mon Oct 23 14:00:58 2006 +0000
@@ -86,8 +86,7 @@
void ec_fsm_sii_write(ec_fsm_sii_t *, ec_slave_t *, uint16_t, uint16_t *,
ec_fsm_sii_addressing_t);
-void ec_fsm_sii_exec(ec_fsm_sii_t *);
-int ec_fsm_sii_running(ec_fsm_sii_t *);
+int ec_fsm_sii_exec(ec_fsm_sii_t *);
int ec_fsm_sii_success(ec_fsm_sii_t *);
/*****************************************************************************/
--- a/master/master.c Mon Oct 23 13:45:09 2006 +0000
+++ b/master/master.c Mon Oct 23 14:00:58 2006 +0000
@@ -555,11 +555,9 @@
ec_fsm_startup(fsm); // init startup state machine
- do {
- ec_fsm_execute(fsm);
+ while (ec_fsm_exec(fsm)) {
ec_master_sync_io(master);
}
- while (ec_fsm_startup_running(fsm));
if (!ec_fsm_startup_success(fsm)) {
ec_master_clear_slaves(master);
@@ -669,7 +667,7 @@
ecrt_master_receive(master);
// execute master state machine
- ec_fsm_execute(&master->fsm);
+ ec_fsm_exec(&master->fsm);
ecrt_master_send(master);
cycles_end = get_cycles();
@@ -1246,11 +1244,9 @@
ec_fsm_configuration(fsm); // init configuration state machine
- do {
- ec_fsm_execute(fsm);
+ while (ec_fsm_exec(fsm)) {
ec_master_sync_io(master);
}
- while (ec_fsm_configuration_running(fsm));
if (!ec_fsm_configuration_success(fsm)) {
return -1;
@@ -1279,11 +1275,9 @@
ec_fsm_configuration(fsm); // init configuration state machine
- do {
- ec_fsm_execute(fsm);
+ while (ec_fsm_exec(fsm)) {
ec_master_sync_io(master);
}
- while (ec_fsm_configuration_running(fsm));
}
/*****************************************************************************/
@@ -1429,7 +1423,7 @@
ec_master_output_stats(master);
// execute master state machine
- ec_fsm_execute(&master->fsm);
+ ec_fsm_exec(&master->fsm);
}
/*****************************************************************************/