Expose BIND and CONNECT states for use with dynamic configuration

introduce FairMQ interface version
This commit is contained in:
Alexey Rybalchenko
2015-01-28 14:24:14 +01:00
parent 6d65c4313a
commit 8a82afe184
22 changed files with 255 additions and 54 deletions

View File

@@ -1,8 +1,8 @@
/********************************************************************************
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
* *
* This software is distributed under the terms of the *
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
* This software is distributed under the terms of the *
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
* copied verbatim in the file "LICENSE" *
********************************************************************************/
/**
@@ -15,6 +15,10 @@
#ifndef FAIRMQSTATEMACHINE_H_
#define FAIRMQSTATEMACHINE_H_
#define FAIRMQ_INTERFACE_VERSION 1
#include <string>
#include <boost/thread.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition_variable.hpp>
@@ -39,6 +43,8 @@ namespace FairMQFSM
struct INIT {};
struct SETOUTPUT {};
struct SETINPUT {};
struct BIND {};
struct CONNECT {};
struct PAUSE {};
struct RUN {};
struct STOP {};
@@ -48,9 +54,9 @@ namespace FairMQFSM
struct FairMQFSM_ : public msm::front::state_machine_def<FairMQFSM_>
{
FairMQFSM_()
: fState()
, fRunningStateThread()
{}
: fState()
, fRunningStateThread()
{}
// Destructor
virtual ~FairMQFSM_() {};
@@ -71,6 +77,8 @@ namespace FairMQFSM
struct INITIALIZING_FSM : public msm::front::state<> {};
struct SETTINGOUTPUT_FSM : public msm::front::state<> {};
struct SETTINGINPUT_FSM : public msm::front::state<> {};
struct BINDING_FSM : public msm::front::state<> {};
struct CONNECTING_FSM : public msm::front::state<> {};
struct WAITING_FSM : public msm::front::state<> {};
struct RUNNING_FSM : public msm::front::state<> {};
// Define initial state
@@ -111,6 +119,24 @@ namespace FairMQFSM
fsm.InitInput();
}
};
struct BindFct
{
template <class EVT, class FSM, class SourceState, class TargetState>
void operator()(EVT const&, FSM& fsm, SourceState&, TargetState&)
{
fsm.fState = BINDING;
fsm.Bind();
}
};
struct ConnectFct
{
template <class EVT, class FSM, class SourceState, class TargetState>
void operator()(EVT const&, FSM& fsm, SourceState&, TargetState&)
{
fsm.fState = CONNECTING;
fsm.Connect();
}
};
struct RunFct
{
template <class EVT, class FSM, class SourceState, class TargetState>
@@ -147,6 +173,8 @@ namespace FairMQFSM
virtual void Shutdown() {}
virtual void InitOutput() {}
virtual void InitInput() {}
virtual void Bind() {}
virtual void Connect() {}
virtual void Terminate() {} // Termination method called during StopFct action.
// Transition table for FairMQFMS
struct transition_table : mpl::vector<
@@ -156,8 +184,10 @@ namespace FairMQFSM
msmf::Row<IDLE_FSM, END, msmf::none, TestFct, msmf::none>, // this is an invalid transition...
msmf::Row<INITIALIZING_FSM, SETOUTPUT, SETTINGOUTPUT_FSM, SetOutputFct, msmf::none>,
msmf::Row<SETTINGOUTPUT_FSM, SETINPUT, SETTINGINPUT_FSM, SetInputFct, msmf::none>,
msmf::Row<SETTINGINPUT_FSM, PAUSE, WAITING_FSM, PauseFct, msmf::none>,
msmf::Row<SETTINGINPUT_FSM, RUN, RUNNING_FSM, RunFct, msmf::none>,
msmf::Row<SETTINGINPUT_FSM, BIND, BINDING_FSM, BindFct, msmf::none>,
msmf::Row<BINDING_FSM, CONNECT, CONNECTING_FSM, ConnectFct, msmf::none>,
msmf::Row<CONNECTING_FSM, PAUSE, WAITING_FSM, PauseFct, msmf::none>,
msmf::Row<CONNECTING_FSM, RUN, RUNNING_FSM, RunFct, msmf::none>,
msmf::Row<WAITING_FSM, RUN, RUNNING_FSM, RunFct, msmf::none>,
msmf::Row<WAITING_FSM, STOP, IDLE_FSM, StopFct, msmf::none>,
msmf::Row<RUNNING_FSM, PAUSE, WAITING_FSM, PauseFct, msmf::none>,
@@ -179,6 +209,8 @@ namespace FairMQFSM
INITIALIZING,
SETTINGOUTPUT,
SETTINGINPUT,
BINDING,
CONNECTING,
WAITING,
RUNNING
};
@@ -195,6 +227,8 @@ class FairMQStateMachine : public FairMQFSM::FairMQFSM
INIT,
SETOUTPUT,
SETINPUT,
BIND,
CONNECT,
PAUSE,
RUN,
STOP,
@@ -202,7 +236,11 @@ class FairMQStateMachine : public FairMQFSM::FairMQFSM
};
FairMQStateMachine();
virtual ~FairMQStateMachine();
void ChangeState(int event);
int GetInterfaceVersion();
bool ChangeState(int event);
bool ChangeState(std::string event);
// condition variable to notify parent thread about end of running state.
boost::condition_variable fRunningCondition;