ethercat_FSM.h
Go to the documentation of this file.
00001 // $Id: ethercat_FSM.h,v 1.16 2006/02/20 15:57:33 kgad Exp $
00002 //===========================================================================
00003 //      This file is part of "EtherCAT Master Library".
00004 //      Copyright (C) 2005 FMTC vzw, Diamant Building, A. Reyerslaan 80,
00005 //      B-1030 Brussels, Belgium.
00006 //
00007 //      EtherCAT Master Library is free software; you can redistribute it
00008 //      and/or modify it under the terms of the GNU General Public License
00009 //      as published by the Free Software Foundation; either version 2 or
00010 //      (at your option) any later version.
00011 //
00012 //      EtherCAT Master Code is distributed in the hope that it will be
00013 //      useful, but WITHOUT ANY WARRANTY; without even the implied
00014 //      warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00015 //      PURPOSE. See the GNU General Public License for more details.
00016 //
00017 //      You should have received a copy of the GNU General Public License
00018 //      along with the EtherCAT Master Library; if not, write to the Free
00019 //      Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00020 //      02111-1307 USA.
00021 //
00022 //      EtherCAT, the EtherCAT trade name and logo are the intellectual
00023 //      property of, and protected by Beckhoff. You can use "EtherCAT
00024 //      Master Library" for creating and/or selling or otherwise
00025 //      distributing an EtherCAT network master under the terms of the
00026 //      EtherCAT Master License.
00027 //
00028 //      You should have received a copy of the EtherCAT Master License
00029 //      along with the EtherCAT Master Library; if not, write to Beckhoff
00030 //      Automation GmbH, Eiserstrasse 5, D-33415 Verl, Germany.
00031 //===========================================================================
00032 
00033 #ifndef __ethercat_fsm__
00034 #define __ethercat_fsm__
00035 
00036 /* Note, this class is supposed to be programmed according to the
00037  FSM design Pattern.
00038  */
00039 
00040 // forward declarations
00041 class EtherCAT_AL;
00042 class EC_Logic;
00043 class EtherCAT_SlaveHandler;
00044 class EtherCAT_DataLinkLayer;
00045 class EtherCAT_Router;
00046 class EtherCAT_PD_Buffer;
00047 
00048 // FIXME how to do forward declaration of typedef enum?, with "extern"
00049 // keyword?
00050 #include "ros_ethercat_eml/ethercat_slave_memory.h"
00051 
00053 
00054 class EC_ESM_Ops
00055 {
00056 public:
00057   void setRouter(EtherCAT_Router *_router);
00058   EC_Logic * m_logic_instance;
00059   EtherCAT_Router * m_router_instance;
00060 protected:
00062   bool start_mbx_comm();
00064   bool stop_mbx_comm();
00066   bool start_input_update();
00068   bool stop_input_update();
00070   bool start_output_update();
00072   bool stop_output_update();
00073 
00074 protected:
00076 
00078   EC_ESM_Ops(EtherCAT_SlaveHandler * a_SH,
00079              EtherCAT_DataLinkLayer *_m_dll_instance,
00080              EC_Logic *_m_logic_instance,
00081              EtherCAT_PD_Buffer *_m_pdbuf_instance);
00082 
00083   EtherCAT_DataLinkLayer * m_dll_instance;
00084   EtherCAT_SlaveHandler * m_SH;
00085 
00086   EtherCAT_PD_Buffer * m_pdbuf_instance;
00087 
00089 
00093   bool set_state(EC_State a_state);
00094 };
00095 
00096 // More forward declarations :-)
00097 class EC_ESM;
00098 class EC_ESM_InitState;
00099 class EC_ESM_PreOpState;
00100 class EC_ESM_SafeOpState;
00101 class EC_ESM_OpState;
00102 
00104 
00107 class EC_ESM_State
00108 {
00109   friend class EC_ESM;
00110 
00111 public:
00112   virtual ~EC_ESM_State()
00113   {
00114   }
00115 
00117 
00125   virtual bool to_state(EC_ESM * a_ESM, EC_State a_state) = 0;
00126   virtual EC_State get_state() const = 0;
00127 protected:
00128   static EC_ESM_InitState initState;
00129   static EC_ESM_PreOpState preopState;
00130   static EC_ESM_SafeOpState safeopState;
00131   static EC_ESM_OpState opState;
00132 };
00133 
00135 
00142 class EC_ESM : public EC_ESM_Ops
00143 {
00144   friend class EC_ESM_State;
00145   friend class EC_ESM_InitState;
00146   friend class EC_ESM_PreOpState;
00147   friend class EC_ESM_SafeOpState;
00148   friend class EC_ESM_OpState;
00149 
00150 public:
00151   EC_ESM(EtherCAT_SlaveHandler * a_SH,
00152          EtherCAT_DataLinkLayer *_m_dll_instance,
00153          EC_Logic *_m_logic_instance,
00154          EtherCAT_PD_Buffer *_m_pdbuf_instance);
00155 
00157 
00164   bool to_state(EC_State a_state)
00165   {
00166     return (m_esm_state->to_state(this, a_state));
00167   }
00168   EC_State get_state()
00169   {
00170     return m_esm_state->get_state();
00171   }
00172 
00173 protected:
00175   void setState(EC_ESM_State * a_esm_state)
00176   {
00177     m_esm_state = a_esm_state;
00178   }
00179 
00180 private:
00181   EC_ESM_State * m_esm_state;
00182 };
00183 
00184 class EC_ESM_InitState : public EC_ESM_State
00185 {
00186 public:
00187   virtual EC_State get_state() const;
00188   virtual bool to_state(EC_ESM * a_ESM, EC_State a_state);
00189 };
00190 
00191 class EC_ESM_PreOpState : public EC_ESM_State
00192 {
00193 public:
00194   virtual EC_State get_state() const;
00195   virtual bool to_state(EC_ESM * a_ESM, EC_State a_state);
00196 };
00197 
00198 class EC_ESM_SafeOpState : public EC_ESM_State
00199 {
00200 public:
00201   virtual EC_State get_state() const;
00202   virtual bool to_state(EC_ESM * a_ESM, EC_State a_state);
00203 };
00204 
00205 class EC_ESM_OpState : public EC_ESM_State
00206 {
00207 public:
00208   virtual EC_State get_state() const;
00209   virtual bool to_state(EC_ESM * a_ESM, EC_State a_state);
00210 };
00211 
00212 #endif // __ethercat_fsm__


ros_ethercat_eml
Author(s): Tom Panis, Klaas Gadeyne, Bob Koninckx, Austin Hendrix, Manos Nikolaidis
autogenerated on Thu Jul 4 2019 20:01:49