Removed state machine running() methods.
This commit is contained in:
parent
3b431ec5c4
commit
daf2544626
70
master/fsm.c
70
master/fsm.c
|
|
@ -168,11 +168,15 @@ void ec_fsm_reset(ec_fsm_t *fsm /**< finite state machine */)
|
|||
|
||||
/**
|
||||
Executes the current state of the state machine.
|
||||
\return false, if state machine has terminated
|
||||
*/
|
||||
|
||||
void ec_fsm_execute(ec_fsm_t *fsm /**< finite state machine */)
|
||||
int ec_fsm_exec(ec_fsm_t *fsm /**< finite state machine */)
|
||||
{
|
||||
fsm->master_state(fsm);
|
||||
|
||||
return fsm->master_state != ec_fsm_end &&
|
||||
fsm->master_state != ec_fsm_error;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -188,19 +192,6 @@ void ec_fsm_startup(ec_fsm_t *fsm)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
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;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
Returns, if the master startup state machine terminated with success.
|
||||
\return non-zero if successful.
|
||||
|
|
@ -224,19 +215,6 @@ void ec_fsm_configuration(ec_fsm_t *fsm)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
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 @@ void ec_fsm_master_validate_vendor(ec_fsm_t *fsm /**< finite state machine */)
|
|||
{
|
||||
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 @@ void ec_fsm_master_validate_product(ec_fsm_t *fsm /**< finite state machine */)
|
|||
{
|
||||
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 @@ void ec_fsm_master_write_eeprom(ec_fsm_t *fsm /**< finite state machine */)
|
|||
{
|
||||
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 @@ void ec_fsm_slavescan_eeprom_size(ec_fsm_t *fsm /**< finite state machine */)
|
|||
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 @@ void ec_fsm_slavescan_eeprom_data(ec_fsm_t *fsm /**< finite state machine */)
|
|||
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 @@ void ec_fsm_slaveconf_init(ec_fsm_t *fsm /**< finite state machine */)
|
|||
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 @@ void ec_fsm_slaveconf_preop(ec_fsm_t *fsm /**< finite state machine */)
|
|||
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 @@ void ec_fsm_slaveconf_saveop(ec_fsm_t *fsm /**< finite state machine */)
|
|||
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 @@ void ec_fsm_slaveconf_op(ec_fsm_t *fsm /**< finite state machine */)
|
|||
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;
|
||||
|
|
|
|||
|
|
@ -89,14 +89,12 @@ struct ec_fsm
|
|||
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 *);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -97,22 +97,13 @@ void ec_fsm_change(ec_fsm_change_t *fsm, /**< finite state machine */
|
|||
|
||||
/**
|
||||
Executes the current state of the state machine.
|
||||
\return false, if the state machine has terminated
|
||||
*/
|
||||
|
||||
void ec_fsm_change_exec(ec_fsm_change_t *fsm /**< finite state machine */)
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,8 +72,7 @@ void ec_fsm_change_clear(ec_fsm_change_t *);
|
|||
|
||||
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 *);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -120,22 +120,13 @@ void ec_fsm_sii_write(ec_fsm_sii_t *fsm, /**< finite state machine */
|
|||
|
||||
/**
|
||||
Executes the SII state machine.
|
||||
\return false, if the state machine has terminated
|
||||
*/
|
||||
|
||||
void ec_fsm_sii_exec(ec_fsm_sii_t *fsm /**< finite state machine */)
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -86,8 +86,7 @@ void ec_fsm_sii_read(ec_fsm_sii_t *, ec_slave_t *,
|
|||
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 *);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -555,11 +555,9 @@ int ec_master_bus_scan(ec_master_t *master /**< EtherCAT master */)
|
|||
|
||||
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 @@ void ec_master_idle_run(void *data /**< master pointer */)
|
|||
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 @@ int ecrt_master_activate(ec_master_t *master /**< EtherCAT master */)
|
|||
|
||||
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 @@ void ecrt_master_deactivate(ec_master_t *master /**< EtherCAT master */)
|
|||
|
||||
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 @@ void ecrt_master_run(ec_master_t *master /**< EtherCAT master */)
|
|||
ec_master_output_stats(master);
|
||||
|
||||
// execute master state machine
|
||||
ec_fsm_execute(&master->fsm);
|
||||
ec_fsm_exec(&master->fsm);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
|||
Loading…
Reference in New Issue