mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-15 18:23:34 +08:00
Merged master into power_enforce
This commit is contained in:
@@ -75,7 +75,7 @@ __EXPORT extern void perf_free(perf_counter_t handle);
|
||||
/**
|
||||
* Count a performance event.
|
||||
*
|
||||
* This call only affects counters that take single events; PC_COUNT etc.
|
||||
* This call only affects counters that take single events; PC_COUNT, PC_INTERVAL etc.
|
||||
*
|
||||
* @param handle The handle returned from perf_alloc.
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (C) 2012 PX4 Development Team. All rights reserved.
|
||||
* Copyright (C) 2013-2014 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -33,8 +33,9 @@
|
||||
|
||||
/**
|
||||
* @file state_table.h
|
||||
*
|
||||
*
|
||||
* Finite-State-Machine helper class for state table
|
||||
* @author: Julian Oes <julian@oes.ch>
|
||||
*/
|
||||
|
||||
#ifndef __SYSTEMLIB_STATE_TABLE_H
|
||||
@@ -48,22 +49,28 @@ public:
|
||||
Action action;
|
||||
unsigned nextState;
|
||||
};
|
||||
|
||||
|
||||
StateTable(Tran const *table, unsigned nStates, unsigned nSignals)
|
||||
: myTable(table), myNsignals(nSignals), myNstates(nStates) {}
|
||||
|
||||
|
||||
#define NO_ACTION &StateTable::doNothing
|
||||
#define ACTION(_target) static_cast<StateTable::Action>(_target)
|
||||
#define ACTION(_target) StateTable::Action(_target)
|
||||
|
||||
virtual ~StateTable() {}
|
||||
|
||||
void dispatch(unsigned const sig) {
|
||||
register Tran const *t = myTable + myState*myNsignals + sig;
|
||||
(this->*(t->action))();
|
||||
|
||||
void dispatch(unsigned const sig) {
|
||||
/* get transition using state table */
|
||||
Tran const *t = myTable + myState*myNsignals + sig;
|
||||
|
||||
/* accept new state */
|
||||
myState = t->nextState;
|
||||
|
||||
/* */
|
||||
(this->*(t->action))();
|
||||
}
|
||||
void doNothing() {
|
||||
return;
|
||||
}
|
||||
void doNothing() {}
|
||||
protected:
|
||||
unsigned myState;
|
||||
private:
|
||||
@@ -72,4 +79,4 @@ private:
|
||||
unsigned myNstates;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user