[OSADL-svn-commits] r88 - in fapia-trunk/FAPIAIPCSynchronize: interface make make/MPC source test test/one_process test/one_process/make test/one_process/make/MPC test/one_process/source

OSADL repository commits osadl-svn-commits at lists.osadl.org
Tue Oct 2 11:46:56 CEST 2007


Author: tb10rts
Date: Thu Jul 19 07:20:10 2007
New Revision: 88

Log:


Added:
   fapia-trunk/FAPIAIPCSynchronize/interface/
   fapia-trunk/FAPIAIPCSynchronize/interface/FAPIAIPCISynchronize.h
   fapia-trunk/FAPIAIPCSynchronize/interface/FAPIAIPCSynchronize.h
   fapia-trunk/FAPIAIPCSynchronize/interface/FAPIAIPCSynchronizeError.h
   fapia-trunk/FAPIAIPCSynchronize/interface/FAPIAIPCSynchronizeError.i
   fapia-trunk/FAPIAIPCSynchronize/interface/FAPIAIPCSynchronizeInit.h
   fapia-trunk/FAPIAIPCSynchronize/interface/FAPIAIPCSynchronizeInit.i
   fapia-trunk/FAPIAIPCSynchronize/make/
   fapia-trunk/FAPIAIPCSynchronize/make/MPC/
   fapia-trunk/FAPIAIPCSynchronize/make/MPC/FAPIAIPCSynchronize.mpc
   fapia-trunk/FAPIAIPCSynchronize/make/MPC/FAPIAIPCSynchronize.mwc
   fapia-trunk/FAPIAIPCSynchronize/make/makeall.bat
   fapia-trunk/FAPIAIPCSynchronize/make/makefile
   fapia-trunk/FAPIAIPCSynchronize/source/
   fapia-trunk/FAPIAIPCSynchronize/source/FAPIAIPCSynchronize.cpp
   fapia-trunk/FAPIAIPCSynchronize/source/FAPIAIPCSynchronizeError.cpp
   fapia-trunk/FAPIAIPCSynchronize/source/FAPIAIPCSynchronizeInit.cpp
   fapia-trunk/FAPIAIPCSynchronize/source/FAPIAIPCSynchronizeSharedMemoryStruct.h
   fapia-trunk/FAPIAIPCSynchronize/source/FAPIAIPCSynchronizeWatchdog.cpp
   fapia-trunk/FAPIAIPCSynchronize/source/FAPIAIPCSynchronizeWatchdog.h
   fapia-trunk/FAPIAIPCSynchronize/test/
   fapia-trunk/FAPIAIPCSynchronize/test/one_process/
   fapia-trunk/FAPIAIPCSynchronize/test/one_process/make/
   fapia-trunk/FAPIAIPCSynchronize/test/one_process/make/MPC/
   fapia-trunk/FAPIAIPCSynchronize/test/one_process/make/MPC/one_process.mpc
   fapia-trunk/FAPIAIPCSynchronize/test/one_process/make/MPC/one_process.mwc
   fapia-trunk/FAPIAIPCSynchronize/test/one_process/make/makefile
   fapia-trunk/FAPIAIPCSynchronize/test/one_process/makeall.bat
   fapia-trunk/FAPIAIPCSynchronize/test/one_process/makefile
   fapia-trunk/FAPIAIPCSynchronize/test/one_process/source/
   fapia-trunk/FAPIAIPCSynchronize/test/one_process/source/main.cpp
   fapia-trunk/FAPIAIPCSynchronize/test/one_process/source/test_fapia_synchronize_one_process.cpp
   fapia-trunk/FAPIAIPCSynchronize/test/one_process/source/test_fapia_synchronize_one_process.h

Added: fapia-trunk/FAPIAIPCSynchronize/interface/FAPIAIPCISynchronize.h
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCSynchronize/interface/FAPIAIPCISynchronize.h	Thu Jul 19 07:20:10 2007
@@ -0,0 +1,89 @@
+/* -*- C++ -*- */
+
+//=============================================================================
+/**
+ *  @file    FAPIAIPCISynchronize.h
+ *
+ *  $Id$
+ *
+ *  @author Thomas Rothfuss <thomas.rothfuss at homag.de>
+ */
+//=============================================================================
+
+#ifndef _FAPI_ACYCLIC_IPC_ISYNCHRONIZE_H_
+#define _FAPI_ACYCLIC_IPC_ISYNCHRONIZE_H_
+
+#include /**/ <ace/ace.h>
+#include "FAPIAIPCSynchronizeInit.h"
+#include "FAPIAIPCSynchronizeError.h"
+
+namespace FAPI
+  {
+    namespace Acyclic
+      {
+        namespace IPC
+          {
+            /**
+             * @interface ISynchronize
+             *
+             * @brief The ISynchronize is the interface for the IPC::Synchronize
+             * module.
+             *
+             */
+            class ISynchronize
+              {
+
+              public:
+                /**
+                 * @brief Initializes the IPC::Synchronize module.
+                 *
+                 * If it returns -1 there was an error. Look at the error object.
+                 *
+                 */
+                virtual int init
+                  (
+                    const FAPI::Acyclic::IPC::Synchronize::Init& init,
+                    FAPI::Acyclic::IPC::Synchronize::Error& error
+                  ) = 0;
+
+                /**
+                 * @brief Deinitializes the IPC::Synchronize module.
+                 *
+                 * If it returns -1 an error occured.
+                 *
+                 */
+                virtual int deinit (void) = 0;
+
+                /**
+                 * @brief Retrieves the address for a given physical object.
+                 *
+                 * If it returns -1 an error occured. Then look at the error
+                 * object.
+                 *
+                 */
+                virtual int retrieve_physical_object_address
+                  (
+                    const ACE_CString& physical_object_name,
+                    ACE_CString& physical_object_address,
+                    FAPI::Acyclic::IPC::Synchronize::Error& error
+                  ) = 0;
+
+                /**
+                 * @brief Disables the physical object.
+                 *
+                 * If it returns -1 an error occured.
+                 *
+                 */
+                virtual int disable_physical_object
+                  (
+                    const ACE_CString& physical_object_address,
+                    FAPI::Acyclic::IPC::Synchronize::Error& error
+                  ) = 0;
+
+              }; /* class ISynchronize */
+
+          } /* namespace IPC */
+      } /* namespace Acyclic */
+  } /* namespace FAPI */
+
+#endif /* _FAPI_ACYCLIC_IPC_ISYNCHRONIZE_H_ */

Added: fapia-trunk/FAPIAIPCSynchronize/interface/FAPIAIPCSynchronize.h
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCSynchronize/interface/FAPIAIPCSynchronize.h	Thu Jul 19 07:20:10 2007
@@ -0,0 +1,176 @@
+/* -*- C++ -*- */
+
+//=============================================================================
+/**
+ *  @file    FAPIAIPCSynchronize.h
+ *
+ *  $Id$
+ *
+ *  @author Thomas Rothfuss <thomas.rothfuss at homag.de>
+ */
+//=============================================================================
+
+#ifndef _FAPI_ACYCLIC_IPC_SYNCHRONIZE_SYNCHRONIZE_H_
+#define _FAPI_ACYCLIC_IPC_SYNCHRONIZE_SYNCHRONIZE_H_
+
+#include "../interface/FAPIAIPCISynchronize.h"
+#include "../source/FAPIAIPCSynchronizeSharedMemoryStruct.h"
+#include <ace/Process_Mutex.h>
+#include <ace/Memory_Pool.h>
+#include <ace/Mem_Map.h>
+
+namespace FAPI
+  {
+    namespace Acyclic
+      {
+        namespace IPC
+          {
+            namespace Synchronize
+              {
+
+                class Watchdog;
+
+                /**
+                 * @class Synchronize
+                 *
+                 * @brief This is the implementation of IPC::ISynchronize
+                 * interface.
+                 *
+                 */
+                class Synchronize : public FAPI::Acyclic::IPC::ISynchronize
+                  {
+                  public:
+                    friend class Watchdog;
+
+                    /**
+                     * @brief Constructor.
+                     *
+                     */
+                    Synchronize (void);
+
+                    /**
+                     * @brief Destructor.
+                     *
+                     */
+                    virtual ~Synchronize (void);
+
+                    /**
+                     * @brief Initializes the IPC::Synchronize module.
+                     *
+                     * If it returns -1 there was an error. Look at the error object.
+                     *
+                     */
+                    virtual int init
+                      (
+                        const FAPI::Acyclic::IPC::Synchronize::Init& init,
+                        FAPI::Acyclic::IPC::Synchronize::Error& error
+                      );
+
+                    /**
+                     * @brief Deinitializes the IPC::Synchronize module.
+                     *
+                     * If it returns -1 an error occured.
+                     *
+                     */
+                    virtual int deinit (void);
+
+                    /**
+                     * @brief Retrieves the address for a given physical object.
+                     *
+                     * If it returns -1 an error occured. Then look at the error
+                     * object.
+                     *
+                     */
+                    virtual int retrieve_physical_object_address
+                      (
+                        const ACE_CString& physical_object_name,
+                        ACE_CString& physical_object_address,
+                        FAPI::Acyclic::IPC::Synchronize::Error& error
+                      );
+
+                    /**
+                     * @brief Disables the physical object.
+                     *
+                     * If it returns -1 an error occured.
+                     *
+                     */
+                    virtual int disable_physical_object
+                      (
+                        const ACE_CString& physical_object_address,
+                        FAPI::Acyclic::IPC::Synchronize::Error& error
+                      );
+
+                  protected:
+
+                    /**
+                     * @enum State
+                     *
+                     * @brief State of the ipc synchronize module.
+                     *
+                     */
+                    enum State
+                      {
+                        INITIAL     = 1,
+                        RUNNING     = 2
+                      };
+
+                    /// State of the controller module.
+                    State                       state_;
+
+                    /// Name of the shared memory to synchronize the fapia
+                    /// subscribers.
+                    ACE_CString           fapia_synchronize_shared_memory_name_;
+
+                    /// Name of the process mutex to synchronize the fapia
+                    /// shared memory.
+                    ACE_CString           fapia_synchronize_process_mutex_name_;
+
+                    /// Process mutex to synchronize the access to the shared
+                    /// memory.
+                    ACE_Process_Mutex     fapia_synchronize_mutex_;
+
+                    /// Shared memory for syncronize the fapia subsrcibers.
+                    ACE_Mem_Map           fapia_shared_memory_;
+
+                    /// Own position within shared memory.
+                    unsigned long         own_shared_memory_pos_;
+
+                    /// Pointer to watchdog thread.
+                    FAPI::Acyclic::IPC::Synchronize::Watchdog* synchronize_watchdog_;
+
+                    /**
+                     * @brief Creates or read the shared memory.
+                     *
+                     * If it returns -1 an error occured.
+                     *
+                     */
+                    int create_or_read_shared_memory (void);
+
+                    /**
+                     * @brief Creates a directory recursively.
+                     *
+                     * If it returns -1 an error occured.
+                     *
+                     */
+                    int mkdir_recursive (const char * const directory);
+
+                  private:
+
+                    /**
+                     * Copy Constructor is private, so this object cannot be copied.
+                     */
+                    Synchronize (const Synchronize&);
+
+                    /**
+                     * Assignment operator is private, so this object cannot be copied.
+                     */
+                    const Synchronize& operator= (const Synchronize&);
+
+                  }; /* class Synchronize */
+
+              } /* namespace Synchronize */
+          } /* namespace IPC */
+      } /* namespace Acyclic */
+  } /* namespace FAPI */
+
+#endif /* _FAPI_ACYCLIC_IPC_SYNCHRONIZE_SYNCHRONIZE_H_ */

Added: fapia-trunk/FAPIAIPCSynchronize/interface/FAPIAIPCSynchronizeError.h
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCSynchronize/interface/FAPIAIPCSynchronizeError.h	Thu Jul 19 07:20:10 2007
@@ -0,0 +1,107 @@
+/* -*- C++ -*- */
+
+//=============================================================================
+/**
+ *  @file    FAPIAIPCSynchronizeError.h
+ *
+ *  $Id$
+ *
+ *  @author Thomas Rothfuss <thomas.rothfuss at homag.de>
+ */
+//=============================================================================
+
+#ifndef _FAPI_ACYCLIC_IPC_SYNCHRONIZE_ERROR_H_
+#define _FAPI_ACYCLIC_IPC_SYNCHRONIZE_ERROR_H_
+
+#include /**/ <ace/Vector_T.h>
+#include /**/ <ace/SString.h>
+#include "../../interface/FAPIA.h"
+
+namespace FAPI
+  {
+    namespace Acyclic
+      {
+        namespace IPC
+          {
+            namespace Synchronize
+              {
+                /**
+                 * @class Error
+                 *
+                 * @brief The Error struct contains error information.
+                 *
+                 */
+                class  Error
+                  {
+
+                  public:
+                    /**
+                     * @brief Constructor of Error.
+                     *
+                     */
+                    Error (void);
+
+                    /**
+                     * @brief Copy Constructor.
+                     *
+                     */
+                    Error (const Error&);
+
+                    /**
+                     * @brief Assignment operator.
+                     *
+                     */
+                    const Error& operator= (const Error&);
+
+                    /**
+                     * @brief Destructor of Error.
+                     *
+                     */
+                    virtual ~Error (void);
+
+                  // The member variables are public. Therefore there is no need
+                  // to implement get and set methods. This class is used as a
+                  // structure with constructor, destructor, copy constructor and
+                  // assignement operator.
+                  public:
+                    /// Error code. Maybe ok.
+                    FAPIAErrorCode                       error_code_;
+
+                    /// Reason of failure. If error_ is ok the reason_ is an
+                    /// empty string.
+                    ACE_CString                          reason_;
+
+                  private:
+                    /**
+                     * @brief Initialize the values.
+                     *
+                     */
+                    void open (void);
+
+                    /**
+                     * @brief Copying the values.
+                     *
+                     */
+                    void copy (const Error&);
+
+                    /**
+                     * @brief Deinitialize the values.
+                     *
+                     */
+                    void close (void);
+
+                  }; /* class Error */
+
+                  /// This typedef is a container for Errors.
+                typedef  ACE_Vector<FAPI::Acyclic::IPC::Synchronize::Error> Errors;
+
+              } /* namespace Synchronize */
+          } /* namespace IPC */
+      } /* namespace Acyclic */
+  } /* namespace FAPI */
+
+#if defined (__ACE_INLINE__)
+#include "../interface/FAPIAIPCSynchronizeError.i"
+#endif /* __ACE_INLINE__ */
+
+#endif /* _FAPI_ACYCLIC_IPC_SYNCHRONIZE_ERROR_H_ */

Added: fapia-trunk/FAPIAIPCSynchronize/interface/FAPIAIPCSynchronizeError.i
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCSynchronize/interface/FAPIAIPCSynchronizeError.i	Thu Jul 19 07:20:10 2007
@@ -0,0 +1,42 @@
+// $Id$
+
+
+namespace FAPI
+  {
+    namespace Acyclic
+      {
+        namespace IPC
+          {
+            namespace Synchronize
+              {
+                ACE_INLINE const Error& Error::operator= (const Error& init)
+                  {
+                    if (this != &init)
+                      {
+                        this->copy(init);
+                      }
+                    return *this;
+                  }
+                
+                ACE_INLINE void Error::open (void)
+                  {
+                    error_code_ = FAPIA_ERROR_OK;
+                    reason_     = "";
+                  }
+                
+                ACE_INLINE void Error::close (void)
+                  {
+                    error_code_ = FAPIA_ERROR_OK;
+                    reason_     = "";
+                  }
+                  
+                ACE_INLINE void Error::copy (const Error& init)  
+                  {
+                    this->error_code_   = init.error_code_;
+                    this->reason_       = init.reason_;
+                  }
+
+              }/* namespace Synchronize */
+          }/* namespace IPC */
+      } /* namespace Acyclic */
+  } /* namespace FAPI */

Added: fapia-trunk/FAPIAIPCSynchronize/interface/FAPIAIPCSynchronizeInit.h
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCSynchronize/interface/FAPIAIPCSynchronizeInit.h	Thu Jul 19 07:20:10 2007
@@ -0,0 +1,109 @@
+/* -*- C++ -*- */
+
+//=============================================================================
+/**
+ *  @file    FAPIAIPCSynchronizeInit.h
+ *
+ *  $Id$
+ *
+ *  @author Thomas Rothfuss <thomas.rothfuss at homag.de>
+ */
+//=============================================================================
+
+#ifndef _FAPI_ACYCLIC_IPC_SYNCHRONIZE_INIT_H_
+#define _FAPI_ACYCLIC_IPC_SYNCHRONIZE_INIT_H_
+
+#include /**/ <ace/ace.h>
+#include <ace/SString.h>
+
+
+namespace FAPI
+  {
+    namespace Acyclic
+      {
+        namespace IPC
+          {
+            namespace Synchronize
+              {
+                /**
+                 * @class Init
+                 *
+                 * @brief The Init structure is used to initialize the
+                 * IPC::Synchronize module.
+                 *
+                 */
+                class  Init
+                  {
+
+                  public:
+                    /**
+                     * @brief Constructor of Init.
+                     *
+                     */
+                    Init (void);
+
+                    /**
+                     * @brief Copy Constructor.
+                     *
+                     */
+                    Init (const Init&);
+
+                    /**
+                     * @brief Assignment operator.
+                     *
+                     */
+                    const Init& operator= (const Init&);
+
+                    /**
+                     * @brief Destructor of Init.
+                     *
+                     */
+                    virtual ~Init (void);
+
+                  // The member variables are public. Therefore there is no need
+                  // to implement get and set methods. This class is used as a
+                  // structure with constructor, destructor, copy constructor and
+                  // assignement operator.
+                  public:
+                    /// Name of the file for the shared memory.
+                    ACE_CString                                         fapia_shared_memory_name_;
+
+                    /// Name of this physical object.
+                    ACE_CString                                         physical_object_name_;
+
+                    /// Address of this physical object.
+                    ACE_CString                                         physical_object_address_;
+
+
+                  private:
+                    /**
+                     * @brief Initialize the values.
+                     *
+                     */
+                    void open (void);
+
+                    /**
+                     * @brief Copying the values.
+                     *
+                     */
+                    void copy (const Init&);
+
+                    /**
+                     * @brief Deinitialize the values.
+                     *
+                     */
+                    void close (void);
+
+                  }; /* class Init */
+
+              } /* namespace Synchronize */
+          } /* namespace IPC */
+      } /* namespace Acyclic */
+  } /* namespace FAPI */
+
+
+#if defined (__ACE_INLINE__)
+#include "FAPIAIPCSynchronizeInit.i"
+#endif /* __ACE_INLINE__ */
+
+#endif /* _FAPI_ACYCLIC_IPC_SYNCHRONIZE_INIT_H_ */

Added: fapia-trunk/FAPIAIPCSynchronize/interface/FAPIAIPCSynchronizeInit.i
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCSynchronize/interface/FAPIAIPCSynchronizeInit.i	Thu Jul 19 07:20:10 2007
@@ -0,0 +1,45 @@
+// $Id$
+
+
+namespace FAPI
+  {
+    namespace Acyclic
+      {
+        namespace IPC
+          {
+            namespace Synchronize
+              {
+                ACE_INLINE const Init& Init::operator= (const Init& init)
+                  {
+                    if (this != &init)
+                      {
+                        this->copy(init);
+                      }
+                    return *this;
+                  }
+                
+                ACE_INLINE void Init::open (void)
+                  {
+                    fapia_shared_memory_name_   = "";
+                    physical_object_name_       = "";
+                    physical_object_address_    = "";
+                  }
+                
+                ACE_INLINE void Init::close (void)
+                  {
+                    fapia_shared_memory_name_   = "";
+                    physical_object_name_       = "";
+                    physical_object_address_    = "";
+                  }
+                  
+                ACE_INLINE void Init::copy (const Init& init)  
+                  {
+                    this->fapia_shared_memory_name_   = init.fapia_shared_memory_name_;
+                    this->physical_object_name_       = init.physical_object_name_;
+                    this->physical_object_address_    = init.physical_object_address_;
+                  }
+
+              }/* namespace Synchronize */
+          }/* namespace IPC */
+      } /* namespace Acyclic */
+  } /* namespace FAPI */

Added: fapia-trunk/FAPIAIPCSynchronize/make/MPC/FAPIAIPCSynchronize.mpc
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCSynchronize/make/MPC/FAPIAIPCSynchronize.mpc	Thu Jul 19 07:20:10 2007
@@ -0,0 +1,3 @@
+
+project : FAPIAIPCSynchronizesource {
+}
\ No newline at end of file

Added: fapia-trunk/FAPIAIPCSynchronize/make/MPC/FAPIAIPCSynchronize.mwc
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCSynchronize/make/MPC/FAPIAIPCSynchronize.mwc	Thu Jul 19 07:20:10 2007
@@ -0,0 +1,3 @@
+workspace {
+  FAPIAIPCSynchronize.mpc
+}
\ No newline at end of file

Added: fapia-trunk/FAPIAIPCSynchronize/make/makeall.bat
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCSynchronize/make/makeall.bat	Thu Jul 19 07:20:10 2007
@@ -0,0 +1,2 @@
+set ARP_Tools=%cd%\..\..\..\..\DevTools_vob\ARP-Tools
+ccperl %arp_tools%\mk.pl %*
\ No newline at end of file

Added: fapia-trunk/FAPIAIPCSynchronize/make/makefile
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCSynchronize/make/makefile	Thu Jul 19 07:20:10 2007
@@ -0,0 +1,26 @@
+MODULE=FAPIAIPCSynchronize
+
+TYPES:= VC8_STATIC Automake
+
+NMAKE_STATIC_CFG="Static_Multi_Unicode_Debug_StaticRTL" "Static_Multi_Unicode_Release_StaticRTL"
+NMAKE_DLL_CFG=
+
+MPC_DIRS := $(VIEW_ROOT)/IOFramework_vob/FAPIA/make/MPC/config $(VIEW_ROOT)/ACE_Wrappers_vob/ACE_wrappers/make/MPC/config
+
+ALL:  MPC BUILD
+
+BUILD: BUILD_ALL 
+
+CLEAN:  CLEAN_BUILD CLEAN_MPC
+
+REALCLEAN: REALCLEAN_BUILD CLEAN_MPC
+
+EXPORT: EXPORT_ALL
+
+%include <.homag_make_rules>
+%include <.homag_mpc_make_rules>
+%include <.homag_build_make_rules>
+%include <.homag_export_make_rules>
+
+MAKE_RUNDIR:= os9/run
+AUTOMAKE_RUNDIR:= i686_linux32

Added: fapia-trunk/FAPIAIPCSynchronize/source/FAPIAIPCSynchronize.cpp
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCSynchronize/source/FAPIAIPCSynchronize.cpp	Thu Jul 19 07:20:10 2007
@@ -0,0 +1,779 @@
+// $Id$
+
+
+#include "../interface/FAPIAIPCSynchronize.h"
+#include "../../interface/FAPIATrace.h"
+#include "FAPIAIPCSynchronizeWatchdog.h"
+#include <ace/synch_t.h>
+
+
+namespace FAPI
+  {
+    namespace Acyclic
+      {
+        namespace IPC
+          {
+            namespace Synchronize
+              {
+
+/* ---------------------------------------------------------------------------*/
+
+                Synchronize::Synchronize (void) :
+                    fapia_synchronize_process_mutex_name_ (
+                        "FAPI_ACYCLIC_IPC_SYNCHRONIZE_PROCESS_MUTEX"),
+                    fapia_synchronize_mutex_ (
+                        fapia_synchronize_process_mutex_name_.c_str ())
+                  {
+                    FAPIA_TRACE;
+
+                    state_ = FAPI::Acyclic::IPC::Synchronize::Synchronize::INITIAL;
+                    fapia_synchronize_shared_memory_name_ = "";
+
+                    own_shared_memory_pos_ = FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_MAX_COUNT;
+                    synchronize_watchdog_ = 0;
+                  }
+
+/* ---------------------------------------------------------------------------*/
+
+                Synchronize::~Synchronize (void)
+                  {
+                    FAPIA_TRACE;
+
+                    if (synchronize_watchdog_)
+                      {
+                        synchronize_watchdog_->shutdown ();
+                        delete synchronize_watchdog_;
+                        synchronize_watchdog_ = 0;
+                      }
+
+                    fapia_shared_memory_.close ();
+                    state_ = FAPI::Acyclic::IPC::Synchronize::Synchronize::INITIAL;
+
+                  }
+
+/* ---------------------------------------------------------------------------*/
+
+                int Synchronize::init (
+                    const FAPI::Acyclic::IPC::Synchronize::Init& init,
+                    FAPI::Acyclic::IPC::Synchronize::Error& error)
+                  {
+                    FAPIA_TRACE;
+
+                    error.error_code_ = FAPIA_ERROR_OK;
+                    error.reason_ = "";
+
+                    // Check for valid state.
+                    if (state_ != FAPI::Acyclic::IPC::Synchronize::Synchronize::INITIAL)
+                      {
+                        FAPIA_DEBUG (
+                            LM_ERROR,
+                            "State is not INITIAL. Call deinit first\n");
+
+                        error.error_code_ =
+                            FAPIA_ERROR_SYNCHRONIZE_COULD_NOT_BE_INITIALIZED;
+                        error.reason_ = "State is not INITIAL. Call deinit first";
+                        return -1;
+                      }
+
+
+                    // Check for valid parameters.
+                    if (init.physical_object_address_.length () >
+                            FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_ADDRESS_MAX_SIZE -1 ||
+                        init.physical_object_address_.length () == 0)
+
+                      {
+                        FAPIA_DEBUG (
+                            LM_ERROR,
+                            "Maximum length of physical_object_address_ is %u.\n",
+                            FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_ADDRESS_MAX_SIZE - 1);
+
+                        error.error_code_ =
+                            FAPIA_ERROR_SYNCHRONIZE_COULD_NOT_BE_INITIALIZED;
+
+                        char tmp_error[1024];
+                        ACE_OS::sprintf(
+                            tmp_error,
+                            "Maximum length of physical_object_address_ is %ld.",
+                            FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_ADDRESS_MAX_SIZE - 1);
+
+                        error.reason_ = tmp_error;
+                        return -1;
+                      }
+
+                    if (init.physical_object_name_.length () >
+                            FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_NAME_MAX_SIZE -1 ||
+                        init.physical_object_name_.length () == 0)
+                      {
+                        FAPIA_DEBUG (
+                            LM_ERROR,
+                            "Maximum length of physical_object_name is %u.\n",
+                            FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_NAME_MAX_SIZE - 1);
+
+                        error.error_code_ =
+                            FAPIA_ERROR_SYNCHRONIZE_COULD_NOT_BE_INITIALIZED;
+
+                        char tmp_error[1024];
+                        ACE_OS::sprintf(
+                            tmp_error,
+                            "Maximum length of physical_object_name is %ld.",
+                            FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_NAME_MAX_SIZE - 1);
+
+                        error.reason_ = tmp_error;
+                        return -1;
+                      }
+
+                    if (init.fapia_shared_memory_name_.length () == 0)
+                      {
+                        FAPIA_DEBUG (
+                            LM_ERROR,
+                            "Length of fapia_shared_memory_name_ is zero.\n");
+
+                        error.error_code_ =
+                            FAPIA_ERROR_SYNCHRONIZE_COULD_NOT_BE_INITIALIZED;
+
+                        error.reason_ =
+                            "Length of fapia_shared_memory_name_ is zero.";
+                        return -1;
+                      }
+
+
+
+
+
+
+                    // Set the name of the shared memory
+                    this->fapia_synchronize_shared_memory_name_ =
+                        init.fapia_shared_memory_name_;
+
+                      {
+                        ACE_Write_Guard <ACE_Process_Mutex> lock (
+                            fapia_synchronize_mutex_);
+
+
+                        // Read the shared memory.
+                        if (this->create_or_read_shared_memory () == -1)
+                          {
+                            FAPIA_DEBUG (
+                                LM_ERROR,
+                                "Shared memory %C could not be read.\n",
+                                this->fapia_synchronize_shared_memory_name_.c_str ());
+
+                            error.error_code_ =
+                                FAPIA_ERROR_SYNCHRONIZE_COULD_NOT_BE_INITIALIZED;
+
+                            char tmp_error[1024];
+                            if (this->fapia_synchronize_shared_memory_name_.length () <
+                                sizeof (tmp_error) - 50)
+                              {
+                                ACE_OS::sprintf(
+                                    tmp_error,
+                                    "Shared memory %s could not be read.",
+                                    this->fapia_synchronize_shared_memory_name_.c_str ());
+                              }
+                            else
+                              {
+                                ACE_OS::sprintf(
+                                    tmp_error,
+                                    "Shared memory could not be opened.");
+                              }
+
+                            error.reason_ = tmp_error;
+                            return -1;
+                          }
+
+
+
+
+                        // Search the free place for initializing.
+                        unsigned long i = 0;
+                        unsigned long free_pos = FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_MAX_COUNT;
+                        SharedMemoryStruct*    shared_memory_structs =
+                            ACE_static_cast (SharedMemoryStruct*,
+                               (void *)((char*)fapia_shared_memory_.addr () + FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION_LEN));
+
+                        for (i = 0; i < FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_MAX_COUNT; ++i)
+                          {
+                            if (free_pos == FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_MAX_COUNT)
+                              {
+                                if (shared_memory_structs[i].physical_object_name[0] == '\0')
+                                  {
+                                    free_pos = i;
+                                  }
+                              }
+
+                            // If this physical object already exists take this entry.
+                            if (ACE_OS::strcmp (
+                                    shared_memory_structs[i].physical_object_name,
+                                    init.physical_object_name_.c_str ()) == 0)
+                              {
+                                free_pos = i;
+                                break;
+                              }
+                          }
+
+                        if (free_pos == FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_MAX_COUNT)
+                          {
+                            FAPIA_DEBUG (
+                                LM_ERROR,
+                                "There are too much communication subscribers. The maximum is %u\n",
+                                FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_MAX_COUNT);
+
+                            error.error_code_ =
+                                FAPIA_ERROR_SYNCHRONIZE_COULD_NOT_BE_INITIALIZED;
+
+                            char tmp_error[1024];
+                            ACE_OS::sprintf(
+                                tmp_error,
+                                "There are too much communication subscribers. The maximum is %ld\n",
+                                FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_MAX_COUNT);
+
+                            error.reason_ = tmp_error;
+                            fapia_shared_memory_.close ();
+                            return -1;
+                          }
+
+
+
+
+                        // Put own values into shared memory.
+                        ACE_OS::strcpy (
+                            shared_memory_structs[free_pos].physical_object_name,
+                            init.physical_object_name_.c_str ());
+                        ACE_OS::strcpy (
+                            shared_memory_structs[free_pos].physical_object_address,
+                            init.physical_object_address_.c_str ());
+                        shared_memory_structs[free_pos].physical_object_active = 1;
+                        own_shared_memory_pos_ = free_pos;
+                      }
+
+                    ACE_NEW_NORETURN (
+                        synchronize_watchdog_,
+                        FAPI::Acyclic::IPC::Synchronize::Watchdog (this));
+                    if (synchronize_watchdog_ == 0)
+                      {
+                        FAPIA_DEBUG (
+                            LM_ALERT,
+                            "Error allocating FAPI::Acyclic::IPC::Synchronize::Watchdog.\n");
+
+                        error.error_code_ =
+                            FAPIA_ERROR_SYNCHRONIZE_COULD_NOT_BE_INITIALIZED;
+
+                        error.reason_ = "Error allocating FAPI::Acyclic::IPC::Synchronize::Watchdog.";
+                        fapia_shared_memory_.unmap ();
+                        fapia_shared_memory_.close ();
+                        return -1;
+                      }
+
+                    // Start up the created thread;
+                    if (synchronize_watchdog_->activate () == -1)
+                      {
+                        FAPIA_DEBUG (
+                            LM_ALERT,
+                            "Error activating watchdog.\n");
+
+                        error.error_code_ =
+                            FAPIA_ERROR_SYNCHRONIZE_COULD_NOT_BE_INITIALIZED;
+
+                        error.reason_ = "Error activating watchdog.";
+                        fapia_shared_memory_.unmap ();
+                        fapia_shared_memory_.close ();
+                        delete synchronize_watchdog_;
+                        synchronize_watchdog_ = 0;
+                        return -1;
+                      }
+
+                    ACE_Thread::yield ();
+                    ACE_OS::sleep(1);
+
+                    state_ = FAPI::Acyclic::IPC::Synchronize::Synchronize::RUNNING;
+
+                    return 0;
+                  }
+
+/* ---------------------------------------------------------------------------*/
+
+                int Synchronize::deinit (void)
+                  {
+                    FAPIA_TRACE;
+
+                    // Check for valid state.
+                    if (state_ != FAPI::Acyclic::IPC::Synchronize::Synchronize::RUNNING)
+                      {
+                        FAPIA_DEBUG (
+                            LM_ERROR,
+                            "State is not RUNNING. Call init first\n");
+                        return -1;
+                      }
+
+                    if (synchronize_watchdog_)
+                      {
+                        synchronize_watchdog_->shutdown ();
+                        delete synchronize_watchdog_;
+                        synchronize_watchdog_ = 0;
+                      }
+
+                      {
+                        ACE_Write_Guard <ACE_Process_Mutex> lock (
+                            fapia_synchronize_mutex_);
+
+                        SharedMemoryStruct*    shared_memory_structs =
+                            ACE_static_cast (SharedMemoryStruct*,
+                                (void *)((char*)fapia_shared_memory_.addr () + FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION_LEN));
+
+                        // Deactivate own physical object.
+                        if (this->own_shared_memory_pos_ <
+                                FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_MAX_COUNT)
+                          {
+                            shared_memory_structs[own_shared_memory_pos_].physical_object_active = 0;
+                          }
+
+                        // Test if any physical object is still active.
+                        bool any_physical_object_is_active = false;
+                        unsigned long i = 0;
+                        for (i = 0; i < FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_MAX_COUNT; ++i)
+                          {
+                            if (shared_memory_structs[i].physical_object_active != 0)
+                              {
+                                any_physical_object_is_active = true;
+                                break;
+                              }
+                          }
+
+                        // Close shared memory.
+                        fapia_shared_memory_.close ();
+
+                        // If no object is active any more delete shared memory file.
+                        if (!any_physical_object_is_active)
+                          {
+                            ACE_OS::unlink (fapia_synchronize_shared_memory_name_.c_str ());
+                          }
+                      }
+
+                    state_ = FAPI::Acyclic::IPC::Synchronize::Synchronize::INITIAL;
+
+                    return 0;
+                  }
+
+/* ---------------------------------------------------------------------------*/
+
+                int Synchronize::retrieve_physical_object_address (
+                    const ACE_CString& physical_object_name,
+                    ACE_CString& physical_object_address,
+                    FAPI::Acyclic::IPC::Synchronize::Error& error)
+                  {
+                    FAPIA_TRACE;
+
+                    error.error_code_ = FAPIA_ERROR_OK;
+                    error.reason_ = "";
+
+                    // Check for valid state.
+                    if (state_ != FAPI::Acyclic::IPC::Synchronize::Synchronize::RUNNING)
+                      {
+                        FAPIA_DEBUG (
+                            LM_ERROR,
+                            "State is not RUNNING. Call init first\n");
+
+                        error.error_code_ =
+                            FAPIA_ERROR_SYNCHRONIZE_COULD_NOT_BE_INITIALIZED;
+                        error.reason_ = "State is not RUNNING. Call init first";
+                        return -1;
+                      }
+
+                    // Search the free place for initializing.
+                    bool physical_object_name_found = false;
+
+                      {
+                        ACE_Read_Guard <ACE_Process_Mutex> lock (
+                            fapia_synchronize_mutex_);
+
+                        SharedMemoryStruct*    shared_memory_structs =
+                            ACE_static_cast (SharedMemoryStruct*,
+                                (void *)((char*)fapia_shared_memory_.addr () + FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION_LEN));
+
+
+                        unsigned long i = 0;
+                        for (i = 0; i < FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_MAX_COUNT; ++i)
+                          {
+                            // If this physical object already exists take this entry.
+                            if (ACE_OS::strcmp (
+                                    shared_memory_structs[i].physical_object_name,
+                                    physical_object_name.c_str ()) == 0)
+                              {
+                                if (shared_memory_structs[i].physical_object_active)
+                                  {
+                                    physical_object_address =
+                                        shared_memory_structs[i].physical_object_address;
+                                    physical_object_name_found = true;
+                                  }
+                                break;
+                              }
+                          }
+                      }
+
+                    if (!physical_object_name_found)
+                      {
+                        FAPIA_DEBUG (
+                            LM_ERROR,
+                            "The physical object %C could not be found.\n",
+                            physical_object_name.c_str ());
+
+                        error.error_code_ = FAPIA_ERROR_OBJECT_NOT_FOUND;
+
+                        char tmp_error[1024];
+                        if (this->fapia_synchronize_shared_memory_name_.length () <
+                            sizeof (tmp_error) - 50)
+                          {
+                            ACE_OS::sprintf(
+                                tmp_error,
+                                "The physical object %s could not be found.",
+                                physical_object_name.c_str ());
+                          }
+                        else
+                          {
+                            ACE_OS::sprintf(
+                                tmp_error,
+                                "The physical object could not be found.");
+                          }
+
+                        error.reason_ = tmp_error;
+                        return -1;
+                      }
+
+                    return 0;
+                  }
+
+/* ---------------------------------------------------------------------------*/
+
+                int Synchronize::disable_physical_object (
+                    const ACE_CString& physical_object_address,
+                    FAPI::Acyclic::IPC::Synchronize::Error& error)
+
+                  {
+                    FAPIA_TRACE;
+
+                    error.error_code_   = FAPIA_ERROR_OK;
+                    error.reason_       = "";
+
+                    // Check for valid state.
+                    if (state_ != FAPI::Acyclic::IPC::Synchronize::Synchronize::RUNNING)
+                      {
+                        FAPIA_DEBUG (
+                            LM_ERROR,
+                            "State is not RUNNING. Call init first\n");
+
+                        error.error_code_ =
+                            FAPIA_ERROR_SYNCHRONIZE_COULD_NOT_BE_INITIALIZED;
+                        error.reason_ = "State is not RUNNING. Call init first";
+                        return -1;
+                      }
+
+                    bool physical_object_address_found = false;
+
+                      {
+                        ACE_Write_Guard <ACE_Process_Mutex> lock (
+                            fapia_synchronize_mutex_);
+                        // Search the free place for initializing.
+
+                        SharedMemoryStruct*    shared_memory_structs =
+                            ACE_static_cast (SharedMemoryStruct*,
+                                (void *)((char*)fapia_shared_memory_.addr () + FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION_LEN));
+
+                        unsigned long i = 0;
+                        for (i = 0; i < FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_MAX_COUNT; ++i)
+                          {
+                            // If this physical object already exists take this entry.
+                            if (ACE_OS::strcmp (
+                                    shared_memory_structs[i].physical_object_address,
+                                    physical_object_address.c_str ()) == 0)
+                              {
+                                if (shared_memory_structs[i].physical_object_active)
+                                  {
+                                    shared_memory_structs[i].physical_object_active = 0;
+                                  }
+                                physical_object_address_found = true;
+                                break;
+                              }
+                          }
+                      }
+
+                    if (!physical_object_address_found)
+                      {
+                        FAPIA_DEBUG (
+                            LM_DEBUG,
+                            "The physical object address %C could not be found.\n",
+                            physical_object_address.c_str ());
+
+                        error.error_code_ = FAPIA_ERROR_OBJECT_NOT_FOUND;
+
+                        char tmp_error[1024];
+                        if (this->fapia_synchronize_shared_memory_name_.length () <
+                            sizeof (tmp_error) - 50)
+                          {
+                            ACE_OS::sprintf(
+                                tmp_error,
+                                "The physical object address %s could not be found.",
+                                physical_object_address.c_str ());
+                          }
+                        else
+                          {
+                            ACE_OS::sprintf(
+                                tmp_error,
+                                "The physical object address could not be found.");
+                          }
+
+                        error.reason_ = tmp_error;
+                        return -1;
+                      }
+
+                    return 0;
+                  }
+
+/* ---------------------------------------------------------------------------*/
+
+                  int Synchronize::create_or_read_shared_memory (void)
+                  {
+                    // Initialize shared memory.
+                    unsigned long len =
+                        FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION_LEN +
+                        FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_MAX_COUNT *
+                            sizeof (FAPI::Acyclic::IPC::Synchronize::SharedMemoryStruct);
+
+                    int rc = 0;
+                    if (fapia_shared_memory_.handle () == ACE_INVALID_HANDLE)
+                      {
+                        // Test if it exists.
+                        if (fapia_shared_memory_.open (
+                              this->fapia_synchronize_shared_memory_name_.c_str (),
+                              O_RDWR) == -1)
+                          {
+
+                            if (mkdir_recursive (fapia_synchronize_shared_memory_name_.c_str ()) == -1)
+                              {
+                                FAPIA_DEBUG (
+                                    LM_ERROR,
+                                    "Directory %s could not be generated.\n",
+                                    fapia_synchronize_shared_memory_name_.c_str ());
+                                return -1;
+                              }
+
+                            // Create a new file.
+                            rc = fapia_shared_memory_.map (
+                                    this->fapia_synchronize_shared_memory_name_.c_str (),
+                                    len,
+                                    O_RDWR | O_CREAT,
+                                    ACE_DEFAULT_FILE_PERMS,
+                                    PROT_RDWR,
+                                    MAP_SHARED,
+                                    0,
+                                    0,
+                                    0);
+                            // Initialize shared memory and write it to file.
+                            if (rc == 0)
+                              {
+                                char* shared_memory_version =
+                                    ACE_static_cast (char*,
+                                      fapia_shared_memory_.addr ());
+
+                                SharedMemoryStruct*    shared_memory_structs =
+                                    ACE_static_cast (SharedMemoryStruct*,
+                                      (void *)((char*)fapia_shared_memory_.addr () + FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION_LEN));
+
+                                ACE_OS::sprintf (shared_memory_version, "%010lu", FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION);
+                                ACE_OS::memset (shared_memory_structs, 0, len - FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION_LEN);
+                                fapia_shared_memory_.close ();
+                                rc = fapia_shared_memory_.map (
+                                        this->fapia_synchronize_shared_memory_name_.c_str (),
+                                        len,
+                                        O_RDWR,
+                                        ACE_DEFAULT_FILE_PERMS,
+                                        PROT_RDWR,
+                                        MAP_SHARED,
+                                        0,
+                                        0,
+                                        0);
+                              }
+                          }
+                        else
+                          {
+                            // Read the existing file
+                            rc = fapia_shared_memory_.map (
+                                    fapia_shared_memory_.handle (),
+                                    len,
+                                    PROT_RDWR,
+                                    MAP_SHARED,
+                                    0,
+                                    0,
+                                    0);
+                          }
+                        if (rc == -1)
+                          {
+                            FAPIA_DEBUG (
+                                LM_ERROR,
+                                "Shared memory %C could not be read or created.\n",
+                                this->fapia_synchronize_shared_memory_name_.c_str ());
+                            return -1;
+                          }
+
+                        // Get version number of shared memory and compare it.
+                        if (len >= FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION_LEN)
+                          {
+                            char tmp [FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION_LEN + 1];
+
+                            char* shared_memory_version =
+                                ACE_static_cast (char*,
+                                  fapia_shared_memory_.addr ());
+                            ACE_OS::memcpy (tmp, shared_memory_version, FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION_LEN);
+                            tmp[FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION_LEN] = '\0';
+
+                            int shared_memory_version_number = ACE_OS::atoi (tmp);
+
+                            if (shared_memory_version_number != FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION)
+                              {
+                                FAPIA_DEBUG (
+                                    LM_ERROR,
+                                    "Shared memory version number should be %u but it is %u.\n",
+                                    FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION,
+                                    shared_memory_version_number);
+                                fapia_shared_memory_.close ();
+                                return -1;
+                              }
+                          }
+
+                        if (len != fapia_shared_memory_.size ())
+                          {
+                            FAPIA_DEBUG (
+                                LM_ERROR,
+                                "Size of shared memory should be %u but it is %u.\n",
+                                len,
+                                fapia_shared_memory_.size ());
+                            fapia_shared_memory_.close ();
+                            return -1;
+                          }
+
+                      }
+
+                    return 0;
+                  }
+
+/* ---------------------------------------------------------------------------*/
+
+                  int Synchronize::mkdir_recursive (const char * const directory)
+                    {
+
+                      // If length of directory is empty just return.
+                      unsigned long directory_len = ACE_OS::strlen (directory);
+                      if (directory_len == 0)
+                        {
+                          return 0;
+                        }
+
+                      // Search first slash.
+                      unsigned long i = 0;
+                      bool slash_found = false;
+                      for (i = 0; !slash_found && i < directory_len; ++i)
+                        {
+                          switch (directory[i])
+                            {
+                              case '\\':
+                              case '/':
+                                slash_found = true;
+                                --i; // Correct loop counter because after the
+                                     //loop it is increased.
+                                break;
+                              default:
+                                break;
+                            }
+                        }
+
+                      // No slash inside. This means no directory must be created.
+                      if (!slash_found)
+                        {
+                          return 0;
+                        }
+
+                      // If a root slash is there look for the next slash.
+                      if (i == 0 || (i == 2 && directory[1] == ':'))
+                        {
+                          ++i;
+                          slash_found = false;
+                          for (; !slash_found && i < directory_len; ++i)
+                            {
+                              switch (directory[i])
+                                {
+                                  case '\\':
+                                  case '/':
+                                    slash_found = true;
+                                    break;
+                                  default:
+                                    break;
+                                }
+                            }
+
+                          // No further slash inside. This means no directory
+                          // must be created.
+                          if (!slash_found)
+                            {
+                              return 0;
+                            }
+                        }
+
+
+                      char* tmp_directory = 0;
+                      ACE_NEW_NORETURN (tmp_directory, char[directory_len + 1]);
+                      if (tmp_directory == 0)
+                        {
+                          FAPIA_DEBUG (
+                              LM_ERROR,
+                              "Memory with len %u for tmp_directory could not be allocated.\n",
+                              directory_len + 1);
+                          return -1;
+                        }
+
+                      // Make direcories recursively.
+                      while (slash_found)
+                        {
+                          slash_found = false;
+                          ACE_OS::memcpy (tmp_directory, directory, i - 1);
+                          tmp_directory[i - 1] = '\0';
+
+                          // If directory does not exist create it.
+                          ACE_stat ace_stat;
+                          if (ACE_OS::stat (tmp_directory, &ace_stat) == -1)
+                            {
+                              if (ACE_OS::mkdir (tmp_directory) == -1)
+                                {
+                                  FAPIA_DEBUG (
+                                      LM_ERROR,
+                                      "Directory %C could not be created.\n",
+                                      tmp_directory);
+                                  delete tmp_directory;
+                                  tmp_directory = 0;
+                                  return -1;
+                                }
+                            }
+
+                          for (; !slash_found && i < directory_len; ++i)
+                            {
+                              switch (directory[i])
+                                {
+                                  case '\\':
+                                  case '/':
+                                    slash_found = true;
+                                    break;
+                                  default:
+                                    break;
+                                }
+                            }
+                        }
+
+                      delete tmp_directory;
+                      tmp_directory = 0;
+
+                      return 0;
+                    }
+
+
+              } /* namespace Synchronize */
+          } /* namespace IPC */
+      } /* namespace Acyclic */
+  } /* namespace FAPI */

Added: fapia-trunk/FAPIAIPCSynchronize/source/FAPIAIPCSynchronizeError.cpp
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCSynchronize/source/FAPIAIPCSynchronizeError.cpp	Thu Jul 19 07:20:10 2007
@@ -0,0 +1,52 @@
+// $Id$
+
+
+#include "../interface/FAPIAIPCSynchronizeError.h"
+#include "../../interface/FAPIATrace.h"
+
+
+#if !defined (__ACE_INLINE__)
+#include "../interface/FAPIAIPCSynchronizeError.i"
+#endif /* __ACE_INLINE__ */
+
+namespace FAPI
+  {
+    namespace Acyclic
+      {
+        namespace IPC
+          {
+            namespace Synchronize
+              {
+
+/* ---------------------------------------------------------------------------*/
+
+                    Error::Error (void)
+                      {
+                        FAPIA_TRACE;
+                        open();
+                      }
+
+/* ---------------------------------------------------------------------------*/
+
+                    Error::Error (const Error& init)
+                      {
+                        FAPIA_TRACE;
+                        open();
+                        copy(init);
+                      }
+
+/* ---------------------------------------------------------------------------*/
+
+                    Error::~Error (void)
+                      {
+                        FAPIA_TRACE;
+                        close();
+                      }
+
+/* ---------------------------------------------------------------------------*/
+
+
+              }/* namespace Synchronize */
+          }/* namespace IPC */
+      } /* namespace Acyclic */
+  } /* namespace FAPI */

Added: fapia-trunk/FAPIAIPCSynchronize/source/FAPIAIPCSynchronizeInit.cpp
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCSynchronize/source/FAPIAIPCSynchronizeInit.cpp	Thu Jul 19 07:20:10 2007
@@ -0,0 +1,52 @@
+// $Id$
+
+
+#include "../interface/FAPIAIPCSynchronizeInit.h"
+#include "../../interface/FAPIATrace.h"
+
+
+#if !defined (__ACE_INLINE__)
+#include "../interface/FAPIAIPCSynchronizeInit.i"
+#endif /* __ACE_INLINE__ */
+
+namespace FAPI
+  {
+    namespace Acyclic
+      {
+        namespace IPC
+          {
+            namespace Synchronize
+              {
+
+/* ---------------------------------------------------------------------------*/
+
+                    Init::Init (void)
+                      {
+                        FAPIA_TRACE;
+                        open();
+                      }
+
+/* ---------------------------------------------------------------------------*/
+
+                    Init::Init (const Init& init)
+                      {
+                        FAPIA_TRACE;
+                        open();
+                        copy(init);
+                      }
+
+/* ---------------------------------------------------------------------------*/
+
+                    Init::~Init (void)
+                      {
+                        FAPIA_TRACE;
+                        close();
+                      }
+
+/* ---------------------------------------------------------------------------*/
+
+
+              }/* namespace Synchronize */
+          }/* namespace IPC */
+      } /* namespace Acyclic */
+  } /* namespace FAPI */

Added: fapia-trunk/FAPIAIPCSynchronize/source/FAPIAIPCSynchronizeSharedMemoryStruct.h
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCSynchronize/source/FAPIAIPCSynchronizeSharedMemoryStruct.h	Thu Jul 19 07:20:10 2007
@@ -0,0 +1,57 @@
+/* -*- C++ -*- */
+
+//=============================================================================
+/**
+ *  @file    FAPIAIPCSynchronizeSharedMemoryStruct.h
+ *
+ *  $Id$
+ *
+ *  @author Thomas Rothfuss <thomas.rothfuss at homag.de>
+ */
+//=============================================================================
+
+#ifndef _FAPI_ACYCLIC_IPC_SYNCHRONIZE_SHARED_MEMORY_STRUCT_H_
+#define _FAPI_ACYCLIC_IPC_SYNCHRONIZE_SHARED_MEMORY_STRUCT_H_
+
+#define FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_NAME_MAX_SIZE     256
+#define FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_ADDRESS_MAX_SIZE  256
+#define FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_MAX_COUNT         1024
+
+#define FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION             1
+#define FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION_LEN         10
+
+namespace FAPI
+  {
+    namespace Acyclic
+      {
+        namespace IPC
+          {
+            namespace Synchronize
+              {
+
+                /**
+                 * @struct Synchronize
+                 *
+                 * @brief This is the implementation of IPC::ISynchronize
+                 * interface.
+                 *
+                 */
+                struct SharedMemoryStruct
+                  {
+                    /// Name of the physical object.
+                    char  physical_object_name[FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_NAME_MAX_SIZE];
+
+                    /// Address of the physical object.
+                    char  physical_object_address[FAPIA_IPC_SYNCHRONIZE_PHYSICAL_OBJECT_ADDRESS_MAX_SIZE];
+
+                    /// If 0 the physical object is not active else it is.
+                    char  physical_object_active;
+
+                  }; /* struct SharedMemoryStruct */
+
+              } /* namespace Synchronize */
+          } /* namespace IPC */
+      } /* namespace Acyclic */
+  } /* namespace FAPI */
+
+#endif /* _FAPI_ACYCLIC_IPC_SYNCHRONIZE_SHARED_MEMORY_STRUCT_H_ */

Added: fapia-trunk/FAPIAIPCSynchronize/source/FAPIAIPCSynchronizeWatchdog.cpp
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCSynchronize/source/FAPIAIPCSynchronizeWatchdog.cpp	Thu Jul 19 07:20:10 2007
@@ -0,0 +1,115 @@
+// $Id$
+
+
+#include "../interface/FAPIAIPCSynchronize.h"
+#include "FAPIAIPCSynchronizeWatchdog.h"
+#include "../../interface/FAPIATrace.h"
+#include <ace/synch_t.h>
+
+
+namespace FAPI
+  {
+    namespace Acyclic
+      {
+        namespace IPC
+          {
+            namespace Synchronize
+              {
+
+/* ---------------------------------------------------------------------------*/
+
+                Watchdog::Watchdog (
+                  FAPI::Acyclic::IPC::Synchronize::Synchronize* fapia_ipc_synchronize) :
+                fapia_ipc_synchronize_ (fapia_ipc_synchronize)
+                  {
+                    FAPIA_TRACE;
+
+                    shutdown_ = false;
+                  }
+
+/* ---------------------------------------------------------------------------*/
+
+                Watchdog::~Watchdog (void)
+                  {
+                    FAPIA_TRACE;
+                  }
+
+/* ---------------------------------------------------------------------------*/
+
+                int Watchdog::svc (void)
+                  {
+                    FAPIA_TRACE;
+
+                    while (!shutdown_)
+                      {
+                        ACE_OS::sleep (1);
+
+                        if (!shutdown_)
+                          {
+                            bool update_necessary = false;
+
+                            // Test if own module is deactivated.
+                              {
+                                ACE_Read_Guard <ACE_Process_Mutex> lock (
+                                    fapia_ipc_synchronize_->fapia_synchronize_mutex_);
+
+                                SharedMemoryStruct*    shared_memory_structs =
+                                    ACE_static_cast (
+                                        SharedMemoryStruct*,
+                                        (void *)((char*)fapia_ipc_synchronize_->fapia_shared_memory_.addr () + FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION_LEN));
+
+                                if (!shared_memory_structs
+                                        [fapia_ipc_synchronize_->own_shared_memory_pos_].physical_object_active)
+                                  {
+                                    update_necessary = true;
+                                  }
+                              }
+
+                            // If own module is deactivated reactivate it.
+                            if (update_necessary)
+                              {
+                                ACE_Write_Guard <ACE_Process_Mutex> lock (
+                                    fapia_ipc_synchronize_->fapia_synchronize_mutex_);
+
+                                SharedMemoryStruct*    shared_memory_structs =
+                                    ACE_static_cast (
+                                        SharedMemoryStruct*,
+                                        (void *)((char*)fapia_ipc_synchronize_->fapia_shared_memory_.addr () + FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION_LEN));
+
+                                if (!shared_memory_structs
+                                        [fapia_ipc_synchronize_->own_shared_memory_pos_].physical_object_active)
+                                  {
+                                    // Set own physical object to active.
+                                    shared_memory_structs
+                                        [fapia_ipc_synchronize_->own_shared_memory_pos_].physical_object_active = 1;
+                                  }
+                              }
+                          }
+                      }
+
+                    return 0;
+                  }
+
+/* ---------------------------------------------------------------------------*/
+
+                int Watchdog::shutdown (void)
+                  {
+                    FAPIA_TRACE;
+                    shutdown_ = true;
+                    this->wait ();
+                    return 0;
+                  }
+
+/* ---------------------------------------------------------------------------*/
+
+                int Watchdog::close (u_long flags)
+                  {
+                    FAPIA_TRACE;
+                    ACE_UNUSED_ARG (flags);
+                    return 0;
+                  }
+
+              } /* namespace Synchronize */
+          } /* namespace IPC */
+      } /* namespace Acyclic */
+  } /* namespace FAPI */

Added: fapia-trunk/FAPIAIPCSynchronize/source/FAPIAIPCSynchronizeWatchdog.h
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCSynchronize/source/FAPIAIPCSynchronizeWatchdog.h	Thu Jul 19 07:20:10 2007
@@ -0,0 +1,103 @@
+/* -*- C++ -*- */
+
+//=============================================================================
+/**
+ *  @file    FAPIAIPCSynchronizeWatchdog.h
+ *
+ *  $Id$
+ *
+ *  @author Thomas Rothfuss <thomas.rothfuss at homag.de>
+ */
+//=============================================================================
+
+#ifndef _FAPI_ACYCLIC_IPC_SYNCHRONIZE_WATCHDOG_H_
+#define _FAPI_ACYCLIC_IPC_SYNCHRONIZE_WATCHDOG_H_
+
+#include /**/ <ace/Task.h>
+#include /**/ <ace/Activation_Queue.h>
+//#include "../../interface/FAPIA.h"
+//#include "../../FAPIAIPCParameter/interface/FAPIAIPCParameterMethodRequestWriteResponse.h"
+
+
+namespace FAPI
+  {
+    namespace Acyclic
+      {
+        namespace IPC
+          {
+            namespace Synchronize
+              {
+
+                // Forward declaration.
+                class Synchronize;
+
+                /**
+                 * @class Watchdog
+                 *
+                 * @brief This command handler acts as a watchdog for the
+                 * shared memory
+                 *
+                 */
+                class Watchdog : public ::ACE_Task<ACE_MT_SYNCH>
+
+                  {
+
+                  public:
+                    /**
+                     * @brief Constructor.
+                     *
+                     */
+                    Watchdog (
+                        FAPI::Acyclic::IPC::Synchronize::Synchronize* fapia_ipc_synchronize);
+
+                    /**
+                     * @brief Destructor.
+                     *
+                     */
+                    virtual ~Watchdog (void);
+
+                    /**
+                     * Shutdowns the thread.
+                     */
+                    int shutdown (void);
+
+                    /**
+                     * Closes the command handler.
+                     */
+                    virtual int close (u_long flags = 0);
+
+                  protected:
+
+                    /// Pointer to synchronize instance.
+                    FAPI::Acyclic::IPC::Synchronize::Synchronize* fapia_ipc_synchronize_;
+
+                    /// Flag to shutdown.
+                    bool  shutdown_;
+
+                    /**
+                     * Virtual function for receiving data.
+                     */
+                    virtual int svc (void);
+
+                  private:
+
+                    /**
+                     * Copy Constructor is private, so this object cannot be copied.
+                     */
+                    Watchdog (const Watchdog&);
+
+                    /**
+                     * Assignment operator is private, so this object cannot be copied.
+                     */
+                    const Watchdog& operator= (const Watchdog&);
+
+
+
+                  }; /* class Watchdog */
+
+              } /* namespace Synchronize */
+          } /* namespace IPC */
+      } /* namespace Acyclic */
+  } /* namespace FAPI */
+
+#endif /* _FAPI_ACYCLIC_IPC_SYNCHRONIZE_WATCHDOG_H_ */

Added: fapia-trunk/FAPIAIPCSynchronize/test/one_process/make/MPC/one_process.mpc
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCSynchronize/test/one_process/make/MPC/one_process.mpc	Thu Jul 19 07:20:10 2007
@@ -0,0 +1,13 @@
+project : FAPIAIPCSynchronizepuresource, acecomponentsexe, taocomponentsexe, cppunitcomponentsexe {
+  
+  exename = test_fapia_synchronize_one_process
+
+  header_files {
+    ../../source/*.h
+  }
+
+  source_files {
+    ../../source/*.cpp
+  }
+
+}
\ No newline at end of file

Added: fapia-trunk/FAPIAIPCSynchronize/test/one_process/make/MPC/one_process.mwc
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCSynchronize/test/one_process/make/MPC/one_process.mwc	Thu Jul 19 07:20:10 2007
@@ -0,0 +1,3 @@
+workspace {
+  one_process.mpc
+}
\ No newline at end of file

Added: fapia-trunk/FAPIAIPCSynchronize/test/one_process/make/makefile
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCSynchronize/test/one_process/make/makefile	Thu Jul 19 07:20:10 2007
@@ -0,0 +1,24 @@
+MODULE=one_process
+
+TYPES:= VC8_STATIC
+
+NMAKE_STATIC_CFG="Static_Multi_Ansi_Debug_DllRTL" "Static_Multi_Ansi_Release_DllRTL"
+NMAKE_DLL_CFG=
+
+
+MPC_DIRS := $(VIEW_ROOT)/IOFramework_vob/FAPIA/make/MPC/config $(VIEW_ROOT)/DevTools_vob/MPC/config $(VIEW_ROOT)/ACE_wrappers_vob/ACE_wrappers/make/MPC/config $(VIEW_ROOT)/DevTools_vob/cppunit/make/MPC/config 
+
+ALL:  MPC BUILD
+
+BUILD: BUILD_ALL 
+
+CLEAN:  CLEAN_BUILD CLEAN_MPC
+
+REALCLEAN: REALCLEAN_BUILD CLEAN_MPC
+
+EXPORT: EXPORT_ALL
+
+%include <.homag_make_rules>
+%include <.homag_mpc_make_rules>
+%include <.homag_build_make_rules>
+%include <.homag_export_make_rules>

Added: fapia-trunk/FAPIAIPCSynchronize/test/one_process/makeall.bat
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCSynchronize/test/one_process/makeall.bat	Thu Jul 19 07:20:10 2007
@@ -0,0 +1,2 @@
+set ARP_Tools=%cd%\..\..\..\..\..\DevTools_vob\ARP-Tools
+ccperl %arp_tools%\mk.pl %*
\ No newline at end of file

Added: fapia-trunk/FAPIAIPCSynchronize/test/one_process/makefile
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCSynchronize/test/one_process/makefile	Thu Jul 19 07:20:10 2007
@@ -0,0 +1,10 @@
+SPEC = *
+MODULE_DIRS= $(SPEC,*D)
+MODULE_DIRS = ./make
+
+
+ALL: $(MODULE_DIRS) $(MAKETARGETS)
+ %echo ALL_SOURCES $(.SOURCES)
+
+%include <.homag_make_rules>
+%include <.homag_release_make_rules>

Added: fapia-trunk/FAPIAIPCSynchronize/test/one_process/source/main.cpp
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCSynchronize/test/one_process/source/main.cpp	Thu Jul 19 07:20:10 2007
@@ -0,0 +1,21 @@
+
+#include <stdio.h>
+#include <assert.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/TestResult.h>
+#include <cppunit/TestResultCollector.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include /**/ <ace/ace.h>
+
+
+int main( int argc, char **argv)
+{
+  ACE::init ();
+  CppUnit::TextUi::TestRunner runner;
+  CppUnit::TestFactoryRegistry &registry = CppUnit::TestFactoryRegistry::getRegistry();
+  runner.addTest( registry.makeTest() );
+  bool wasSuccessful = runner.run( "", false);
+  ACE::fini ();
+  return wasSuccessful;
+}

Added: fapia-trunk/FAPIAIPCSynchronize/test/one_process/source/test_fapia_synchronize_one_process.cpp
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCSynchronize/test/one_process/source/test_fapia_synchronize_one_process.cpp	Thu Jul 19 07:20:10 2007
@@ -0,0 +1,308 @@
+// $Id$
+
+
+#include "test_fapia_synchronize_one_process.h"
+#include "../../../interface/FAPIAIPCSynchronize.h"
+
+namespace FAPI
+  {
+    namespace Acyclic
+      {
+        namespace IPC
+          {
+            namespace Synchronize
+              {
+                namespace Test
+                  {
+
+                    CPPUNIT_TEST_SUITE_REGISTRATION (OneProcessTest);
+
+/*---------------------------------------------------------------------------*/
+
+                    OneProcessTest::OneProcessTest()
+                      {
+                      }
+
+/*---------------------------------------------------------------------------*/
+
+                    void OneProcessTest::setUp()
+                      {
+                      }
+
+/*---------------------------------------------------------------------------*/
+
+                    void OneProcessTest::tearDown()
+                      {
+                      }
+
+/*---------------------------------------------------------------------------*/
+
+                    void OneProcessTest::test_init (void)
+                      {
+                        FAPI::Acyclic::IPC::Synchronize::Init         init;
+                        FAPI::Acyclic::IPC::Synchronize::Error        error;
+                        FAPI::Acyclic::IPC::Synchronize::Synchronize  synchronize;
+
+                        init.physical_object_address_ = "127.0.0.0";
+                        init.physical_object_name_    = "one_process_test";
+
+                        // Empty name.
+                        init.fapia_shared_memory_name_ = "";
+                        int rc = synchronize.init (init, error);
+
+                        CPPUNIT_ASSERT (rc == -1);
+                        CPPUNIT_ASSERT (error.error_code_ == FAPIA_ERROR_SYNCHRONIZE_COULD_NOT_BE_INITIALIZED);
+                        CPPUNIT_ASSERT (error.reason_.length () > 0);
+
+
+
+                        // Valid name.
+                        init.fapia_shared_memory_name_ = "0123";
+                        // Delete file if it exists.
+                        ACE_OS::unlink (init.fapia_shared_memory_name_.c_str ());
+                        rc = synchronize.init (init, error);
+
+                        CPPUNIT_ASSERT (rc == 0);
+                        CPPUNIT_ASSERT (error.error_code_ == FAPIA_ERROR_OK);
+                        CPPUNIT_ASSERT (error.reason_.length () == 0);
+
+                        // Valid name, deinit was not called.
+                        rc = synchronize.init (init, error);
+
+                        CPPUNIT_ASSERT (rc == -1);
+                        CPPUNIT_ASSERT (error.error_code_ == FAPIA_ERROR_SYNCHRONIZE_COULD_NOT_BE_INITIALIZED);
+                        CPPUNIT_ASSERT (error.reason_.length () != 0);
+
+                        // Deinit.
+                        rc = synchronize.deinit ();
+                        CPPUNIT_ASSERT (rc == 0);
+
+                        // Deinit. Init was not done
+                        rc = synchronize.deinit ();
+                        CPPUNIT_ASSERT (rc == -1);
+
+                        // Valid name, file already exists.
+                        rc = synchronize.init (init, error);
+
+                        CPPUNIT_ASSERT (rc == 0);
+                        CPPUNIT_ASSERT (error.error_code_ == FAPIA_ERROR_OK);
+                        CPPUNIT_ASSERT (error.reason_.length () == 0);
+
+                        // Deinit.
+                        rc = synchronize.deinit ();
+                        CPPUNIT_ASSERT (rc == 0);
+
+                        // Delete file.
+                        ACE_OS::unlink (init.fapia_shared_memory_name_.c_str ());
+
+                      }
+
+/*---------------------------------------------------------------------------*/
+
+
+                    void OneProcessTest::test_non_existing_path (void)
+                      {
+
+                          {
+                            FAPI::Acyclic::IPC::Synchronize::Init         init;
+                            FAPI::Acyclic::IPC::Synchronize::Error        error;
+                            FAPI::Acyclic::IPC::Synchronize::Synchronize  synchronize;
+
+                            init.physical_object_address_ = "127.0.0.0";
+                            init.physical_object_name_    = "one_process_test";
+
+                            // Non existing pathname.
+                            init.fapia_shared_memory_name_ = "C:\\FAPIA\\nonexistingpath\\nonexistingfile.fapia";
+                            int rc = synchronize.init (init, error);
+
+                            CPPUNIT_ASSERT (rc == 0);
+                            CPPUNIT_ASSERT (error.error_code_ == FAPIA_ERROR_OK);
+                            CPPUNIT_ASSERT (error.reason_.length () == 0);
+
+                            // Deinit.
+                            rc = synchronize.deinit ();
+                            CPPUNIT_ASSERT (rc == 0);
+
+                            init.fapia_shared_memory_name_ = "C:\\FAPIA/nonexistingpath2\\nonexistingfile.fapia";
+                            rc = synchronize.init (init, error);
+
+                            CPPUNIT_ASSERT (rc == 0);
+                            CPPUNIT_ASSERT (error.error_code_ == FAPIA_ERROR_OK);
+                            CPPUNIT_ASSERT (error.reason_.length () == 0);
+
+                            // Deinit.
+                            rc = synchronize.deinit ();
+                            CPPUNIT_ASSERT (rc == 0);
+
+                          }
+
+                        ACE_OS::unlink ("C:\\FAPIA\\nonexistingpath2\\nonexistingfile.fapia");
+                        ACE_OS::unlink ("C:\\FAPIA\\nonexistingpath\\nonexistingfile.fapia");
+                        ::rmdir ("C:\\FAPIA\\nonexistingpath2");
+                        ::rmdir ("C:\\FAPIA\\nonexistingpath");
+                        ::rmdir ("C:\\FAPIA");
+
+                      }
+
+/*---------------------------------------------------------------------------*/
+
+
+                    void OneProcessTest::test_existing_invalid_file (void)
+                      {
+                        FAPI::Acyclic::IPC::Synchronize::Init         init;
+                        init.physical_object_address_ = "127.0.0.0";
+                        init.physical_object_name_    = "one_process_test";
+                        init.fapia_shared_memory_name_ = "0123";
+                        char tmp[FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION_LEN + 1];
+                        ACE_OS::sprintf (tmp, "%010lu", FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION);
+
+                        FILE* fp = ACE_OS::fopen (
+                              init.fapia_shared_memory_name_.c_str (),
+                              "w+");
+
+                        ACE_OS::fwrite (
+                            tmp,
+                            FAPIA_IPC_SYNCHRONIZE_SHARED_MEMORY_VERSION_LEN,
+                            1,
+                            fp);
+
+                        ACE_OS::fwrite (
+                            init.physical_object_name_.c_str (),
+                            init.physical_object_name_.length (),
+                            1,
+                            fp);
+
+                        ACE_OS::fclose (fp);
+
+                          {
+                            FAPI::Acyclic::IPC::Synchronize::Error        error;
+                            FAPI::Acyclic::IPC::Synchronize::Synchronize  synchronize;
+
+                            // Non existing pathname.
+                            int rc = synchronize.init (init, error);
+
+                            CPPUNIT_ASSERT (rc == 0);
+                            CPPUNIT_ASSERT (error.error_code_ == FAPIA_ERROR_OK);
+                            CPPUNIT_ASSERT (error.reason_.length () == 0);
+                          }
+
+                        ACE_OS::unlink (init.fapia_shared_memory_name_.c_str ());
+
+                      }
+
+/*---------------------------------------------------------------------------*/
+
+
+                    void OneProcessTest::test_disable_retrieve_physical_object (void)
+                      {
+
+                        /******************************************************/
+
+                        FAPI::Acyclic::IPC::Synchronize::Init         init;
+                        FAPI::Acyclic::IPC::Synchronize::Error        error;
+                        FAPI::Acyclic::IPC::Synchronize::Synchronize  synchronize;
+
+                        init.physical_object_address_ = "127.0.0.0";
+                        init.physical_object_name_    = "one_process_test";
+                        init.fapia_shared_memory_name_ = "0123";
+
+                        /******************************************************/
+
+                        ACE_CString physical_object_name (init.physical_object_name_);
+                        ACE_CString physical_object_address;
+                        int rc = synchronize.retrieve_physical_object_address (
+                            physical_object_name,
+                            physical_object_address,
+                            error);
+
+                        CPPUNIT_ASSERT (rc == -1);
+                        CPPUNIT_ASSERT (error.error_code_ == FAPIA_ERROR_SYNCHRONIZE_COULD_NOT_BE_INITIALIZED);
+                        CPPUNIT_ASSERT (error.reason_.length () != 0);
+
+
+                        /******************************************************/
+
+                        rc = synchronize.disable_physical_object (
+                            physical_object_address,
+                            error);
+
+                        CPPUNIT_ASSERT (rc == -1);
+                        CPPUNIT_ASSERT (error.error_code_ == FAPIA_ERROR_SYNCHRONIZE_COULD_NOT_BE_INITIALIZED);
+                        CPPUNIT_ASSERT (error.reason_.length () != 0);
+
+
+                        /******************************************************/
+
+                        rc = synchronize.init (init, error);
+                        CPPUNIT_ASSERT (rc == 0);
+                        CPPUNIT_ASSERT (error.error_code_ == FAPIA_ERROR_OK);
+                        CPPUNIT_ASSERT (error.reason_.length () == 0);
+
+
+                        /******************************************************/
+
+                        rc = synchronize.retrieve_physical_object_address (
+                            physical_object_name,
+                            physical_object_address,
+                            error);
+
+                        CPPUNIT_ASSERT (rc == 0);
+                        CPPUNIT_ASSERT (error.error_code_ == FAPIA_ERROR_OK);
+                        CPPUNIT_ASSERT (error.reason_.length () == 0);
+                        CPPUNIT_ASSERT (ACE_OS::strcmp (physical_object_address.c_str (), init.physical_object_address_.c_str ()) == 0);
+
+
+                        /******************************************************/
+
+                        rc = synchronize.disable_physical_object (
+                            physical_object_address,
+                            error);
+
+                        CPPUNIT_ASSERT (rc == 0);
+                        CPPUNIT_ASSERT (error.error_code_ == FAPIA_ERROR_OK);
+                        CPPUNIT_ASSERT (error.reason_.length () == 0);
+
+                        /******************************************************/
+
+                        rc = synchronize.disable_physical_object (
+                            physical_object_address,
+                            error);
+
+                        CPPUNIT_ASSERT (rc == 0);
+                        CPPUNIT_ASSERT (error.error_code_ == FAPIA_ERROR_OK);
+                        CPPUNIT_ASSERT (error.reason_.length () == 0);
+
+
+                        /******************************************************/
+
+                        rc = synchronize.retrieve_physical_object_address (
+                            physical_object_name,
+                            physical_object_address,
+                            error);
+
+                        CPPUNIT_ASSERT (rc == -1);
+                        CPPUNIT_ASSERT (error.error_code_ == FAPIA_ERROR_OBJECT_NOT_FOUND);
+                        CPPUNIT_ASSERT (error.reason_.length () != 0);
+
+
+                        /******************************************************/
+
+                        // Deinit.
+                        rc = synchronize.deinit ();
+                        CPPUNIT_ASSERT (rc == 0);
+
+
+                        /******************************************************/
+
+
+                      }
+
+/*---------------------------------------------------------------------------*/
+
+
+                 } /* namespace Test */
+              } /* namespace Synchronize */
+          } /* namespace IPC */
+      } /* namespace Acyclic */
+  } /* namespace FAPI */
+ 

Added: fapia-trunk/FAPIAIPCSynchronize/test/one_process/source/test_fapia_synchronize_one_process.h
==============================================================================
--- (empty file)
+++ fapia-trunk/FAPIAIPCSynchronize/test/one_process/source/test_fapia_synchronize_one_process.h	Thu Jul 19 07:20:10 2007
@@ -0,0 +1,58 @@
+/* -*- C++ -*- */
+
+//=============================================================================
+/**
+ *  @file    marshallingtest.h
+ *
+ *  $Id$
+ *
+ *  @author Thomas Rothfuss <thomas.rothfuss at homag.de>
+ */
+//=============================================================================
+
+#ifndef _FAPIA_IPC_SYNCHRONIZE_ONE_PROCESS_TEST_H_
+#define _FAPIA_IPC_SYNCHRONIZE_ONE_PROCESS_TEST_H_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+namespace FAPI
+  {
+    namespace Acyclic
+      {
+        namespace IPC
+          {
+            namespace Synchronize
+              {
+                namespace Test
+                  {
+                    class OneProcessTest : public CppUnit::TestFixture
+                      {
+                      public:
+                        CPPUNIT_TEST_SUITE (OneProcessTest);
+                        CPPUNIT_TEST (test_init);
+                        CPPUNIT_TEST (test_non_existing_path);
+                        CPPUNIT_TEST (test_existing_invalid_file);
+                        CPPUNIT_TEST (test_disable_retrieve_physical_object);
+                        CPPUNIT_TEST_SUITE_END ();
+                      
+                      private:
+                      
+                      public:
+                        OneProcessTest (void);
+
+                        void setUp (void);
+                        void tearDown (void);
+
+                        void test_init (void);
+                        void test_non_existing_path (void);
+                        void test_existing_invalid_file (void);
+                        void test_disable_retrieve_physical_object (void);
+                      }; /* class OneProcessTest */
+
+                } /* namespace Test */
+              } /* namespace Synchronize */
+          } /* namespace IPC */
+      } /* namespace Acyclic */
+  } /* namespace FAPI */
+
+#endif // _FAPIA_IPC_SYNCHRONIZE_ONE_PROCESS_TEST_H_


More information about the OSADL-svn-commits mailing list