Initial work on state-machine AP module.
This commit is contained in:
parent
0729b0806e
commit
978a2cd8c6
2 changed files with 43 additions and 7 deletions
|
@ -25,12 +25,17 @@
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "autopilot.hxx"
|
||||||
|
|
||||||
|
#include <simgear/structure/StateMachine.hxx>
|
||||||
|
#include <simgear/sg_inlines.h>
|
||||||
|
|
||||||
|
#include "component.hxx"
|
||||||
#include "functor.hxx"
|
#include "functor.hxx"
|
||||||
#include "predictor.hxx"
|
#include "predictor.hxx"
|
||||||
#include "digitalfilter.hxx"
|
#include "digitalfilter.hxx"
|
||||||
#include "pisimplecontroller.hxx"
|
#include "pisimplecontroller.hxx"
|
||||||
#include "pidcontroller.hxx"
|
#include "pidcontroller.hxx"
|
||||||
#include "autopilot.hxx"
|
|
||||||
#include "logic.hxx"
|
#include "logic.hxx"
|
||||||
#include "flipflop.hxx"
|
#include "flipflop.hxx"
|
||||||
|
|
||||||
|
@ -41,6 +46,40 @@ using std::string;
|
||||||
|
|
||||||
using namespace FGXMLAutopilot;
|
using namespace FGXMLAutopilot;
|
||||||
|
|
||||||
|
class StateMachineComponent : public Component
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
StateMachineComponent(SGPropertyNode_ptr config)
|
||||||
|
{
|
||||||
|
inner = simgear::StateMachine::createFromPlist(config, globals->get_props());
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool configure( const std::string & nodeName, SGPropertyNode_ptr config)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void update( bool firstTime, double dt )
|
||||||
|
{
|
||||||
|
SG_UNUSED(firstTime);
|
||||||
|
inner->update(dt);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
simgear::StateMachine_ptr inner;
|
||||||
|
};
|
||||||
|
|
||||||
|
class StateMachineFunctor : public FunctorBase<Component>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~StateMachineFunctor() {}
|
||||||
|
virtual Component* operator()( SGPropertyNode_ptr configNode )
|
||||||
|
{
|
||||||
|
return new StateMachineComponent(configNode);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class ComponentForge : public map<string,FunctorBase<Component> *> {
|
class ComponentForge : public map<string,FunctorBase<Component> *> {
|
||||||
public:
|
public:
|
||||||
virtual ~ ComponentForge();
|
virtual ~ ComponentForge();
|
||||||
|
@ -67,6 +106,7 @@ Autopilot::Autopilot( SGPropertyNode_ptr rootNode, SGPropertyNode_ptr configNode
|
||||||
componentForge["filter"] = new CreateAndConfigureFunctor<DigitalFilter,Component>();
|
componentForge["filter"] = new CreateAndConfigureFunctor<DigitalFilter,Component>();
|
||||||
componentForge["logic"] = new CreateAndConfigureFunctor<Logic,Component>();
|
componentForge["logic"] = new CreateAndConfigureFunctor<Logic,Component>();
|
||||||
componentForge["flipflop"] = new CreateAndConfigureFunctor<FlipFlop,Component>();
|
componentForge["flipflop"] = new CreateAndConfigureFunctor<FlipFlop,Component>();
|
||||||
|
componentForge["state-machine"] = new StateMachineFunctor();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( configNode == NULL ) configNode = rootNode;
|
if( configNode == NULL ) configNode = rootNode;
|
||||||
|
|
|
@ -23,17 +23,13 @@
|
||||||
#ifndef __AUTOPILOT_HXX
|
#ifndef __AUTOPILOT_HXX
|
||||||
#define __AUTOPILOT_HXX 1
|
#define __AUTOPILOT_HXX 1
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
# include <config.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "component.hxx"
|
|
||||||
|
|
||||||
#include <simgear/props/props.hxx>
|
#include <simgear/props/props.hxx>
|
||||||
#include <simgear/structure/subsystem_mgr.hxx>
|
#include <simgear/structure/subsystem_mgr.hxx>
|
||||||
|
|
||||||
namespace FGXMLAutopilot {
|
namespace FGXMLAutopilot {
|
||||||
|
|
||||||
|
class Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A SGSubsystemGroup implementation to serve as a collection
|
* @brief A SGSubsystemGroup implementation to serve as a collection
|
||||||
* of Components
|
* of Components
|
||||||
|
|
Loading…
Add table
Reference in a new issue