#ifndef MDD2000MNGBASE_H
#pragma once
#define MDD2000MNGBASE_H

#include "..\Source\DriveSafetyIF.h"

#define MDD2000MNGBASE_IF_PROTOCOLVERSION_1    1

#define MDD2000MNGBASE_FWVERSION_HIPERFACEDSL 130 // 1.30 

// #define MDD2000MNGBASE_FKTFWVERSION_SAFETYSUPPORT  141  // 1.41
#define MDD2000MNGBASE_FKTFWVERSION_SAFETYSUPPORT  200

//#define MDD2000MNG_DBG_LOGGING_SDO          // logging of all SDO errors
#ifdef MDD2000MNG_DBG_LOGGING_SDO
  #pragma message("MDD2000MNG_DBG_LOGGING_SDO is active, deactivate for release!");
#endif


//*********************************************************************************************************************
// Global definitions
//*********************************************************************************************************************

// Class Version for communication in Lasal2
#define MDD2000MNG_LC2_NEWINST_L2VERSION     7

// minimal refresh time of the server
#define MDD2000MNG_MINTIMESVRUPDATE	4

// standard name of Lasal2 table
#define MDD2000MNG_STDL2TABLENAME		"DRIVETAB"

// standard file name for export the drive parameter
#define MDD2000MNG_EXPORTFILENAME    "C:\DRIVEPARA.XLS"

// maximal memory for the sdd parameter
#define MDD2000MNG_MAXMEM			5*1024

// max entries for the asynchronous buffer (must be >= 6, otherwise initialisation fails)
#define MDD2000MNG_ASY_BUFFERENTRY		128

// timeout for asynchron parameters in us 
#define MDD2000MNG_ASY_TIMEOUT   3000000

// size of one entry in the buffer
#define MDD2000MNG_PARAENTRYSIZE  5

// maximal index of the Lasal2 Buffer
#define MDD2000MNG_L2MAXINDEX      30

// error code for timeout (according to the object handling in the sigmatek functionality manual)
#define MDD2000MNG_ERR_OBJ_HANDLING_TIMEOUT  2


#define MDD2000MNG_LC2PARA_M_ROFF	  014



//****************************************************************************************
//** Defines for SDO Handling                                                           **
//****************************************************************************************

#define MDD2000MNG_DATASIZE_4BYTE    0
#define MDD2000MNG_DATASIZE_8BYTE    1
#define MDD2000MNG_DATASIZE_12BYTE   2

#define MDD2000MNG_ENTRY_TYPE_DEFAULT                   0 //default
#define MDD2000MNG_ENTRY_TYPE_REFRESH_DRIVE_PARA        1 //Refresh der Driveparameter wenn Parameterklassen vorhanden sind
#define MDD2000MNG_ENTRY_TYPE_REFRESH_DRIVE_PARA_LAST   2 //Ist der erste Part vom Refresh der Parameterklassen abgeschlossen (wird als letztes gesendet)
#define MDD2000MNG_ENTRY_TYPE_FROM_LASAL                3 //Eintrag kommt von Lasal2 Tool zum Lesen/Schreiben asynchroner Parameter

#define DS402_ASYNCPARA_DEFAULT_LASALPARA_INDEX   0xFFFF

//****************************************************************************************
//** NewInst commandos from Lasal 2 and user classes (must be compatible with old ones) **
//****************************************************************************************

#define MDD2000MNG_LC2_NEWINST_GETVERSION           6
#define MDD2000MNG_LC2_NEWINST_ONLINEOK             7
#define MDD2000MNG_LC2_NEWINST_RWPARLASAL2          8
#define MDD2000MNG_LC2_NEWINST_GETAXISINUSE         9
#define MDD2000MNG_NEWINST_INITAXLE                 13
#define MDD2000MNG_NEWINST_URINITAXLE               14
#define MDD2000MNG_LC2_NEWINST_GETSERIE             15
#define MDD2000MNG_LC2_NEWINST_GET_CHANGE_CNT       17
#define MDD2000MNG_LC2_NEWINST_GET_PARAMS           18
#define MDD2000MNG_NEWINST_GET_AXIS_PTR_LIST        20
#define MDD2000MNG_LC2_NEWINST_GET_DEVICESERIALNO   21  //Get Serial-No of head device (SDD_L2VERSION >= 6)
#define MDD2000MNG_LC2_NEWINST_GET_MNG_TRANSPARENT  23  //[SA33753] Get Transparent information (SDD_L2VERSION >= 7)

//----------------------------------------------------------------------
#define MDD2000MNG_NEWINST_GETFILE                  203 //command to get a specific file from the drive and save it on the PLC

#define MDD2000MNG_NEWINST_GETFILE_VER_1   1                   //version 1
#define MDD2000MNG_NEWINST_GETFILE_VER_MAX MDD2000MNG_NEWINST_GETFILE_VER_1   //max supported version of newinst command

//  Command Version 1 **  
//  CmdStruct
//  aPara[0]$DINT     : Command Version : 1  
//  aPara[1]$^CHAR    : Pointer to destination path + name + extension where the file should be saved on the PLC
//  aPara[2]$^CHAR    : Pointer to filename of the drive
//  aPara[3]$^CHAR    : Pointer to the file path/directory of the drive 
//  aPara[4]$^DINT    : Pointer to a 4 Byte Error variable where errorcodes will be written when there is an error (optional, can be NIL)

//  results
//  uiLng         : 4 Byte (sizeof(DINT))
//  aData[0]$DINT : Command Version : max supported version

//  retcode
//  READY ... File Upload was started succesfully (Current progress can be fetched with MDD2000MNG_NEWINST_GETFILESTATE)
//  ERROR ... File Upload Error - see ErrorCode (aPara[4]$^DINT)
//  Errorcodes: See Errorcodes for Filehandling Commands


//----------------------------------------------------------------------
#define MDD2000MNG_NEWINST_GETLOGFILE          204 //Command to upload the logfile from the drive and save it on the PLC

#define MDD2000MNG_NEWINST_GETLOGFILE_VER_1   1     //version 1
#define MDD2000MNG_NEWINST_GETLOGFILE_VER_2   2     //version 2
#define MDD2000MNG_NEWINST_GETLOGFILE_VER_MAX MDD2000MNG_NEWINST_GETLOGFILE_VER_2 //max supported version of newinst command

//  Command Version 1 **  
//  CmdStruct
//  aPara[0]$DINT     : Command Version : 1  
//  aPara[1]$^CHAR    : Pointer to destination path + name + extension where the logfile should be saved on the PLC
//  aPara[2]$^DINT    : Pointer to a 4 Byte Error variable where errorcodes will be written when there is an error (optional, can be NIL)

//  results
//  uiLng         : 4 Byte (sizeof(DINT))
//  aData[0]$DINT : Command Version : max supported version

//  retcode
//  READY ... File Upload was started succesfully (Current progress can be fetched with MDD2000MNG_NEWINST_GETFILESTATE)
//  ERROR ... File Upload Error - see ErrorCode (aPara[2]$^DINT)
//  Errorcodes: See Errorcodes for Filehandling Commands

//-------------------------------
//  Command Version 2 **  
//  CmdStruct
//  aPara[0]$DINT     : Command Version : 1  
//  aPara[1]$^CHAR    : Pointer to destination path + name + extension where the logfile should be saved on the PLC
//  aPara[2]$^DINT    : Pointer to a 4 Byte Error variable where errorcodes will be written when there is an error (optional, can be NIL)
//  aPara[3]$UDINT    : Select which log file is fetched from the drive: 0 .. Default logfile; 1 .. Debug log file.

//  results
//  uiLng         : 4 Byte (sizeof(DINT))
//  aData[0]$DINT : Command Version : max supported version

//  retcode
//  READY ... File Upload was started succesfully (Current progress can be fetched with MDD2000MNG_NEWINST_GETFILESTATE)
//  ERROR ... File Upload Error - see ErrorCode (aPara[2]$^DINT)
//  Errorcodes: See Errorcodes for Filehandling Commands



//----------------------------------------------------------------------
#define MDD2000MNG_NEWINST_GETFILESTATE        205 //Commando to check the current MDD2000MNG_NEWINST_GETFILE, MDD2000MNG_NEWINST_GETLOGFILE, MDD2000MNG_NEWINST_SETFILE, MDD2000MNG_NEWINST_GETFILESIZE, MDD2000MNG_NEWINST_GETFILEBUFFER progress

#define MDD2000MNG_NEWINST_GETFILESTATE_VER_1   1     //version 1
#define MDD2000MNG_NEWINST_GETFILESTATE_VER_MAX MDD2000MNG_NEWINST_GETFILESTATE_VER_1 //max supported version of newinst command

//  Command Version 1 **  
//  CmdStruct
//  aPara[0]$DINT     : Command Version : 1  
//  aPara[1]$^DINT    : Pointer to a 4 Byte Error variable where errorcodes will be written when there is an error (optional, can be NIL)
//  aPara[2]$^DINT    : Pointer to a 4 Byte variable where the progress of the file upload or download will be written in 0.1 percentage (1000 = 100%)
//  aPara[3]$^UDINT    : Pointer to where the amount of read bytes will be copied (optional, can be NIL)

//  results
//  uiLng         : 4 Byte (sizeof(DINT))
//  aData[0]$DINT : Command Version : max supported version

//  retcode
//  BUSY  ... File Handling is not finished yet
//  READY ... File Handling was not started yet / Handling is finished
//  ERROR ... File Handling Error - see ErrorCode (aPara[1]$^DINT)
//  Errorcodes: See Errorcodes for Filehandling Commands

//----------------------------------------------------------------------
#define MDD2000MNG_NEWINST_SETFILE             206 //command to write data to a specific file to the drive

#define MDD2000MNG_NEWINST_SETFILE_VER_1   1                   //version 1
#define MDD2000MNG_NEWINST_SETFILE_VER_MAX MDD2000MNG_NEWINST_SETFILE_VER_1   //max supported version of newinst command

//  Command Version 1 **  
//  CmdStruct
//  aPara[0]$DINT     : Command Version : 1  
//  aPara[1]$^void    : Pointer to databuffer which will be written to the file on the drive
//  aPara[2]$UDINT    : Length of data to be written
//  aPara[3]$^cHAR    : Pointer to the filepath/directory of the file on the drive which will be written
//  aPara[4]$^cHAR    : Pointer to the filename of the file on the drive which will be written
//  aPara[5]$^DINT    : Pointer to a 4 Byte Error variable where errorcodes will be written when there is an error (optional, can be NIL)

//  results
//  uiLng         : 4 Byte (sizeof(DINT))
//  aData[0]$DINT : Command Version : max supported version

//  retcode
//  READY ... File write was started succesfully (Current progress can be fetched with MDD2000MNG_NEWINST_GETFILESTATE)
//  ERROR ... Error, see errorcodes
//  Errorcodes: See Errorcodes for Filehandling Commands


//----------------------------------------------------------------------
#define MDD2000MNG_NEWINST_GETFILESIZE             207 //command to get a file size from a specific file on the drive

#define MDD2000MNG_NEWINST_GETFILESIZE_VER_1   1                   //version 1
#define MDD2000MNG_NEWINST_GETFILESIZE_VER_MAX MDD2000MNG_NEWINST_GETFILESIZE_VER_1   //max supported version of newinst command

//  Command Version 1 **  
//  CmdStruct
//  aPara[0]$DINT     : Command Version : 1  
//  aPara[1]$^CHAR    : Pointer to filename of the drive
//  aPara[2]$^CHAR    : Pointer to the file path/directory of the drive 
//  aPara[3]$^UDINT   : Pointer to where the filesize will be written when the retcode is READY
//  aPara[4]$^DINT    : Pointer to a 4 Byte Error variable where errorcodes will be written when there is an error (optional, can be NIL)

//  results
//  uiLng         : 4 Byte (sizeof(DINT))
//  aData[0]$DINT : Command Version : max supported version

//  retcode
//  READY ... Fetching the filesize  was started succesfully (Current progress can be fetched with MDD2000MNG_NEWINST_GETFILESTATE)
//  ERROR ... get filesize failed (see parameter pdError for more information)

//  Errorcodes: See Errorcodes for Filehandling Commands

//----------------------------------------------------------------------
#define MDD2000MNG_NEWINST_GETFILEBUFFER             208 //command to get a specific file from the drive and save it on the PLC

#define MDD2000MNG_NEWINST_GETFILEBUFFER_VER_1   1                   //version 1
#define MDD2000MNG_NEWINST_GETFILEBUFFER_VER_MAX MDD2000MNG_NEWINST_GETFILEBUFFER_VER_1   //max supported version of newinst command

//  Command Version 1 **  
//  CmdStruct
//  aPara[0]$DINT     : Command Version : 1  
//  aPara[1]$^CHAR    : Pointer to filename of the drive
//  aPara[2]$^CHAR    : Pointer to the file path/directory of the drive 
//  aPara[3]$UDINT    : Size of buffer (pDataBuffer) in bytes.
//  aPara[4]$^void    : Pointer to buffer where read data will be copied.
//  aPara[5]$UDINT    : Can be used if only x-bytes from the file should be read. Otherwise all data from the file will be read out.0 ... Read all bytes from file.x ... Read x bytes from file. (optional, can be NIL)
//  aPara[6]$^DINT    : Pointer to a 4 Byte Error variable where errorcodes will be written when there is an error (optional, can be NIL)


//  results
//  uiLng         : 4 Byte (sizeof(DINT))
//  aData[0]$DINT : Command Version : max supported version

//  retcode
//  READY ... File read was started succesfully (Current progress of read can be fetched with MDD2000MNG_NEWINST_GETFILESTATE)
//  ERROR ... File read Error (see parameter pdError for more information)

//  Errorcodes: See Errorcodes for Filehandling Commands

//----------------------------------------------------------------------

// Errorcodes for Filehandling Commands: MDD2000MNG_NEWINST_GETLOGFILE, MDD2000MNG_NEWINST_GETLOGFILE, MDD2000MNG_NEWINST_GETFILESTATE, MDD2000MNG_NEWINST_SETFILE, MDD2000MNG_NEWINST_GETFILESIZE, MDD2000MNG_NEWINST_GETFILEBUFFER
//  Errorcodes: 0 ... No Error
//             -1 ... Mailbox for File Upload not available
//             -2 ... Filehandling busy (other upload/download is still running)
//             -3 ... Invalid pointer given
//             -4 ... String "Filename of the drive" is too long
//             -5 ... String "Filepath of the drive" is too long
//             -6 ... String "Destination path + name + extension" is too long
//             -7 ... Vandal Communication Error
//             -8 ... Vandal Communication Timeout
//             -9 ... File was not found on drive
//            -10 ... Failed to create local file
//            -11 ... Failed to write data to local file
//            -12 ... Invalid length of file on drive (0 Byte)
//            -13 ... Buffer is to small
//            -14 ... An attempt was made to read out more bytes of data than are available in the file
//            -15 ... Failed to create thread for filehandling
//            -92 ... Command Version is not supported
//            -93 ... The writing of the asynchron parameter for reading out the log file failed
//            -94 ... Timeout when writing the asynchron parameter for reading out the log file
//            -95 ... The read-back of the asynchron parameter for reading out the log file failed
//            -96 ... Timeout when reading back the asynchron parameter for reading out the log file
//            -97 ... Axis must not be enabled
//            -98 ... Drive is not online
//            -99 ... Filehandling not supported


//*****************************************************************************
//** NewInst 0x8560-0x858F                                                   **
//*****************************************************************************

//Method to login an axis object at the manager
#define MDD2000MNG_IF_LOGINAXISOBJECT                       16#8560
#define MDD2000MNG_IF_LOGINAXISOBJECT_VER_1                 1                   //version 1
#define MDD2000MNG_IF_LOGINAXISOBJECT_VER_MAX               MDD2000MNG_IF_LOGINAXISOBJECT_VER_1   //newest implemented version

//Method to login SyncExtend object to axis
#define MDD2000MNG_IF_ADD_SYNC_ENTRY                        16#8561
#define MDD2000MNG_IF_ADD_SYNC_ENTRY_VER_1                  1
#define MDD2000MNG_IF_ADD_SYNC_ENTRY_VER_MAX                MDD2000MNG_IF_ADD_SYNC_ENTRY_VER_1

//Method to get a sync entry (SyncExtend class)
#define MDD2000MNG_IF_GET_SYNC_ENTRY                        16#8562
#define MDD2000MNG_IF_GET_SYNC_ENTRY_VER_1                  1                   //version 1
#define MDD2000MNG_IF_GET_SYNC_ENTRY_VER_MAX                MDD2000MNG_IF_GET_SYNC_ENTRY_VER_1   //newest implemented version

//Method to set a sync entry (SyncExtend class)
#define MDD2000MNG_IF_SET_SYNC_ENTRY                        16#8563
#define MDD2000MNG_IF_SET_SYNC_ENTRY_VER_1                  1                   //version 1
#define MDD2000MNG_IF_SET_SYNC_ENTRY_VER_MAX                MDD2000MNG_IF_SET_SYNC_ENTRY_VER_1   //newest implemented version

//Method is used from axis to get communication state from mng
#define MDD2000MNG_IF_GET_COMM_STATE                        16#8564
#define MDD2000MNG_IF_GET_COMM_STATE_VER_1                  1                   //version 1
#define MDD2000MNG_IF_GET_COMM_STATE_VER_MAX                MDD2000MNG_IF_GET_COMM_STATE_VER_1   //newest implemented version

//Method is called from axis to inform that axis init is finished
#define MDD2000MNG_IF_AXISINITFINISHED                      16#8565
#define MDD2000MNG_IF_AXISINITFINISHED_VER_1                1                   //version 1
#define MDD2000MNG_IF_AXISINITFINISHED_VER_MAX              MDD2000MNG_IF_AXISINITFINISHED_VER_1   //newest implemented version
#define MDD2000MNG_IF_AXISINITFINISHED_FUNCT                0
#define MDD2000MNG_IF_AXISINITFINISHED_SAFEVERIFIY          1
#define MDD2000MNG_IF_AXISINITFINISHED_SAFEZEROPOS          2

#define MDD2000MNG_IF_SET_PARALIST                          16#8566                   
#define MDD2000MNG_IF_SET_PARALIST_VER_1                    1                   //version 1
#define MDD2000MNG_IF_SET_PARALIST_VER_MAX                  MDD2000MNG_IF_SET_PARALIST_VER_1   //newest implemented version

#define MDD2000MNG_IF_GET_PARA_STATE                        16#8567
#define MDD2000MNG_IF_GET_PARA_STATE_VER_1                  1                   //version 1
#define MDD2000MNG_IF_GET_PARA_STATE_VER_MAX                MDD2000MNG_IF_GET_PARA_STATE_VER_1   //newest implemented version

#define MDD2000MNG_IF_GET_AXIS_RD_WR_PTR                    16#8568
#define MDD2000MNG_IF_GET_AXIS_RD_WR_PTR_VER_1              1                   //version 1
#define MDD2000MNG_IF_GET_AXIS_RD_WR_PTR_VER_MAX            MDD2000MNG_IF_GET_AXIS_RD_WR_PTR_VER_1   //newest implemented version

#define MDD2000MNG_IF_INIT_DRIVE                            16#8569                   
#define MDD2000MNG_IF_INIT_DRIVE_VER_1                      1                   //version 1
#define MDD2000MNG_IF_INIT_DRIVE_VER_MAX                    MDD2000MNG_IF_INIT_DRIVE_VER_1   //newest implemented version

#define MDD2000MNG_IF_IS_ANY_AXIS_ENABLED                   16#856A                   
#define MDD2000MNG_IF_IS_ANY_AXIS_ENABLED_VER_1             1                   //version 1
#define MDD2000MNG_IF_IS_ANY_AXIS_ENABLED_VER_MAX           MDD2000MNG_IF_IS_ANY_AXIS_ENABLED_VER_1   //newest implemented version

#define MDD2000MNG_IF_ADD_ASYNC_ENTRY_DS402                 DRIVESAFETYIF_ADD_ASYNC_ENTRY_DS402
#define MDD2000MNG_IF_ADD_ASYNC_ENTRY_DS402_VER_1           DRIVESAFETYIF_ADD_ASYNC_ENTRY_DS402_VER_1                   //version 1
#define MDD2000MNG_IF_ADD_ASYNC_ENTRY_DS402_VER_MAX         MDD2000MNG_IF_ADD_ASYNC_ENTRY_DS402_VER_1   //newest implemented version

#define MDD2000MNG_IF_IS_ONLINE                             DRIVESAFETYIF_IS_ONLINE
#define MDD2000MNG_IF_IS_ONLINE_VER_1                       DRIVESAFETYIF_IS_ONLINE_VER_1                   //version 1
#define MDD2000MNG_IF_IS_ONLINE_VER_MAX                     MDD2000MNG_IF_IS_ONLINE_VER_1   //newest implemented version

#define MDD2000MNG_IF_CREATE_DEF_PARA_BASE                  16#856D
#define MDD2000MNG_IF_CREATE_DEF_PARA_BASE_VER_1            1                   //version 1
#define MDD2000MNG_IF_CREATE_DEF_PARA_BASE_VER_MAX          MDD2000MNG_IF_CREATE_DEF_PARA_BASE_VER_1   //newest implemented version

#define MDD2000MNG_IF_GET_DRIVE_TYP_STR                     16#856E
#define MDD2000MNG_IF_GET_DRIVE_TYP_STR_VER_1               1                   //version 1
#define MDD2000MNG_IF_GET_DRIVE_TYP_STR_VER_MAX             MDD2000MNG_IF_GET_DRIVE_TYP_STR_VER_1   //newest implemented version

#define MDD2000MNG_IF_GET_MNGRDY_4_AXISCONFIG               16#856F
#define MDD2000MNG_IF_GET_MNGRDY_4_AXISCONFIG_VER_1         1                //version 1
#define MDD2000MNG_IF_GET_MNGRDY_4_AXISCONFIG_VER_MAX       MDD2000MNG_IF_GET_MNGRDY_4_AXISCONFIG_VER_1 //newest implemented version

#define MDD2000MNG_IF_SET_STATE                             16#8570
#define MDD2000MNG_IF_SET_STATE_VER_1                       1                //version 1
#define MDD2000MNG_IF_SET_STATE_VER_MAX                     MDD2000MNG_IF_SET_STATE_VER_1 //newest implemented version

#define MDD2000MNG_IF_SET_AXIS_STATE                        16#8571
#define MDD2000MNG_IF_SET_AXIS_STATE_VER_1                  1                //version 1
#define MDD2000MNG_IF_SET_AXIS_STATE_VER_MAX                MDD2000MNG_IF_SET_AXIS_STATE_VER_1 //newest implemented version

#define MDD2000MNG_IF_IS_AXIS_ENABLED                       16#8572
#define MDD2000MNG_IF_IS_AXIS_ENABLED_VER_1                 1                //version 1
#define MDD2000MNG_IF_IS_AXIS_ENABLED_VER_MAX               MDD2000MNG_IF_IS_AXIS_ENABLED_VER_1 //newest implemented version

#define MDD2000MNG_IF_GET_AXIS_STATE                        16#8573
#define MDD2000MNG_IF_GET_AXIS_STATE_VER_1                  1                   //version 1
#define MDD2000MNG_IF_GET_AXIS_STATE_VER_MAX                MDD2000MNG_IF_GET_AXIS_STATE_VER_1   //newest implemented version

#define MDD2000MNG_IF_GET_CLASS_STATE                       DRIVESAFETYIF_GET_CLASS_STATE
#define MDD2000MNG_IF_GET_CLASS_STATE_VER_1                 DRIVESAFETYIF_GET_CLASS_STATE_VER_1                   //version 1
#define MDD2000MNG_IF_GET_CLASS_STATE_VER_MAX               MDD2000MNG_IF_GET_CLASS_STATE_VER_1   //newest implemented version

#define MDD2000MNG_IF_IS_HARDWARE_AVAILABLE                 DRIVESAFETYIF_IS_HARDWARE_AVAILABLE
#define MDD2000MNG_IF_IS_HARDWARE_AVAILABLE_VER_1           DRIVESAFETYIF_IS_HARDWARE_AVAILABLE_VER_1                   //version 1
#define MDD2000MNG_IF_IS_HARDWARE_AVAILABLE_VER_MAX         MDD2000MNG_IF_IS_HARDWARE_AVAILABLE_VER_1   //newest implemented version

#define MDD2000MNG_IF_ASYNC_READY                           DRIVESAFETYIF_ASYNC_READY
#define MDD2000MNG_IF_ASYNC_READY_VER_1                     DRIVESAFETYIF_ASYNC_READY_VER_1                   //version 1
#define MDD2000MNG_IF_ASYNC_READY_VER_MAX                   MDD2000MNG_IF_ASYNC_READY_VER_1   //newest implemented version

#define MDD2000MNG_IF_ASYNC_ERROR                           DRIVESAFETYIF_ASYNC_ERROR
#define MDD2000MNG_IF_ASYNC_ERROR_VER_1                     DRIVESAFETYIF_ASYNC_ERROR_VER_1                   //version 1
#define MDD2000MNG_IF_ASYNC_ERROR_VER_MAX                   MDD2000MNG_IF_ASYNC_ERROR_VER_1   //newest implemented version

#define MDD2000MNG_IF_REFRESH_PARA_OBJECTS                  DRIVESAFETYIF_REFRESH_PARA_OBJECTS
#define MDD2000MNG_IF_REFRESH_PARA_OBJECTS_VER_1            DRIVESAFETYIF_REFRESH_PARA_OBJECTS_VER_1                   //version 1
#define MDD2000MNG_IF_REFRESH_PARA_OBJECTS_VER_MAX          MDD2000MNG_IF_REFRESH_PARA_OBJECTS_VER_1   //newest implemented version

#define MDD2000MNG_IF_SAVE_PARAMETER                        16#8579
#define MDD2000MNG_IF_SAVE_PARAMETER_VER_1                  1                   //version 1
#define MDD2000MNG_IF_SAVE_PARAMETER_VER_MAX                MDD2000MNG_IF_SAVE_PARAMETER_VER_1   //newest implemented version

#define MDD2000MNG_IF_REFRESH_PARAMETER_FINISHED            16#857A
#define MDD2000MNG_IF_REFRESH_PARAMETER_FINISHED_VER_1      1                   //version 1
#define MDD2000MNG_IF_REFRESH_PARAMETER_FINISHED_VER_MAX    MDD2000MNG_IF_REFRESH_PARAMETER_FINISHED_VER_1   //newest implemented version

#define MDD2000MNG_IF_ADD_PARA_OBJECT                       DRIVESAFETYIF_ADD_PARA_OBJECT
#define MDD2000MNG_IF_ADD_PARA_OBJECT_VER_1                 DRIVESAFETYIF_ADD_PARA_OBJECT_VER_1                   //version 1
#define MDD2000MNG_IF_ADD_PARA_OBJECT_VER_MAX               MDD2000MNG_IF_ADD_PARA_OBJECT_VER_1   //newest implemented version

#define MDD2000MNG_IF_IS_AXIS_READY_4_ASYPARA               DRIVESAFETYIF_IS_AXIS_READY_4_ASYPARA
#define MDD2000MNG_IF_IS_AXIS_READY_4_ASYPARA_VER_1         DRIVESAFETYIF_IS_AXIS_READY_4_ASYPARA_VER_1                   //version 1
#define MDD2000MNG_IF_IS_AXIS_READY_4_ASYPARA_VER_MAX       MDD2000MNG_IF_IS_AXIS_READY_4_ASYPARA_VER_1   //newest implemented version

#define MDD2000MNG_IF_SET_DIAG_MODE                         16#857D
#define MDD2000MNG_IF_SET_DIAG_MODE_VER_1                   1                   //version 1
#define MDD2000MNG_IF_SET_DIAG_MODE_VER_MAX                 MDD2000MNG_IF_SET_DIAG_MODE_VER_1   //newest implemented version

#define MDD2000MNG_IF_UPDATEPARACLASS_STATE                 DRIVESAFETYIF_UPDATEPARACLASS_STATE
#define MDD2000MNG_IF_UPDATEPARACLASS_STATE_VER_1           DRIVESAFETYIF_UPDATEPARACLASS_STATE_VER_1                   //version 1
#define MDD2000MNG_IF_UPDATEPARACLASS_STATE_VER_MAX         MDD2000MNG_IF_UPDATEPARACLASS_STATE_VER_1   //newest implemented version

#define MDD2000MNG_IF_UPDATEPARACLASS_STATE_GENERAL_ERROR                 DRIVESAFETYIF_UPDATEPARACLASS_STATE_GENERAL_ERROR
#define MDD2000MNG_IF_UPDATEPARACLASS_STATE_ASYNC_BUSY                    DRIVESAFETYIF_UPDATEPARACLASS_STATE_ASYNC_BUSY
#define MDD2000MNG_IF_UPDATEPARACLASS_STATE_GENERAL_READY                 DRIVESAFETYIF_UPDATEPARACLASS_STATE_GENERAL_READY
#define MDD2000MNG_IF_UPDATEPARACLASS_STATE_UPDATE_CY                     DRIVESAFETYIF_UPDATEPARACLASS_STATE_UPDATE_CY
#define MDD2000MNG_IF_UPDATEPARACLASS_STATE_SAFETY_READY                  DRIVESAFETYIF_UPDATEPARACLASS_STATE_SAFETY_READY 
#define MDD2000MNG_IF_UPDATEPARACLASS_STATE_SAFETY_ERROR                  DRIVESAFETYIF_UPDATEPARACLASS_STATE_SAFETY_ERROR
#define MDD2000MNG_IF_UPDATEPARACLASS_STATE_SAFETY_CHANGED                DRIVESAFETYIF_UPDATEPARACLASS_STATE_SAFETY_CHANGED
#define MDD2000MNG_IF_UPDATEPARACLASS_STATE_SAFETY_SETSERVICEMODE_PENDING DRIVESAFETYIF_UPDATEPARACLASS_STATE_SAFETY_SETSERVICEMODE_PENDING

//Method is called from axis to inform that axis init should be reset
#define MDD2000MNG_IF_RESET_SAFE_VERIFY_ZEROPOS                     16#857F
#define MDD2000MNG_IF_RESET_SAFE_VERIFY_ZEROPOS_VER_1               1                   //version 1
#define MDD2000MNG_IF_RESET_SAFE_VERIFY_ZEROPOS_VER_MAX             MDD2000MNG_IF_RESET_SAFE_VERIFY_ZEROPOS_VER_1   //newest implemented version
#define MDD2000MNG_IF_RESET_SAFE_VERIFY_ZEROPOS_SAFEVERIFIY         1
#define MDD2000MNG_IF_RESET_SAFE_VERIFY_ZEROPOS_SAFEZEROPOS         2
#define MDD2000MNG_IF_RESET_SAFE_VERIFY_ZEROPOS_SAFEVERIFIYZEROPOS  3

// Inform class the the safety configuration of the module changed
#define MDD2000MNG_IF_SAFETYCONFIG_CHANGED                         16#8580
#define MDD2000MNG_IF_SAFETYCONFIG_CHANGED_VER_1                   1                   //version 1
#define MDD2000MNG_IF_SAFETYCONFIG_CHANGED_VER_MAX                 MDD2000MNG_IF_SAFETYCONFIG_CHANGED_VER_1   //newest implemented version
//  Command Version 1 **  
//  CmdStruct
//  aPara[0]$DINT     : Command Version : 1
//  aPara[1]$HDINT    : CRC of safety config
//  aPara[2]$DINT     : SafetyLenOutFSoEFrame
//  aPara[3]$DINT     : SafetyLenInFSoEFrame

//  results
//  uiLng               : 4 Byte
//  aData[0]$DINT       : Command Version : max supported version

// Returns the result of the safety config change
#define MDD2000MNG_IF_SAFETYCONFIG_CHANGEDRESULT                   16#8581
#define MDD2000MNG_IF_SAFETYCONFIG_CHANGEDRESULT_VER_1             1                   //version 1
#define MDD2000MNG_IF_SAFETYCONFIG_CHANGEDRESULT_VER_MAX           MDD2000MNG_IF_SAFETYCONFIG_CHANGEDRESULT_VER_1   //newest implemented version
//  Command Version 1 **  
//  CmdStruct
//  aPara[0]$DINT     : Command Version : 1
//  aPara[1]$BDINT    : 0 .. Ok; Bit1 .. PDO Size Increased, change not possible

//  results
//  uiLng               : 4 Byte
//  aData[0]$DINT       : Command Version : max supported version

//*****************************************************************************
//** Drive parameter groups                                                  **
//*****************************************************************************

// definition of the group index
//Parameter index for classes which are connected to the axis class
#define MDD2000MNG_PARAIDX_MOTOR          0
#define MDD2000MNG_PARAIDX_DRIVE          1
#define MDD2000MNG_PARAIDX_CURRENT        2
#define MDD2000MNG_PARAIDX_VEL            3
#define MDD2000MNG_PARAIDX_POS            4
#define MDD2000MNG_PARAIDX_FD             5
#define MDD2000MNG_PARAIDX_APPLI          6
#define MDD2000MNG_PARAIDX_ERRORHANDLING  7
#define MDD2000MNG_PARAIDX_OPTIONAL       8
#define MDD2000MNG_PARAIDX_SAFEBRAKETEST  9
#define MDD2000MNG_PARAIDX_SAFEINFO       10

//Parameter index for classes which are connected to the manager class
#define MDD2000MNG_PARAIDX_MNGINFO        101
#define MDD2000MNG_PARAIDX_MNGSAFEERRINFO 102

#define MDD2000MNG_MAX_PARAIDX_CNT   13 //maximal amount of different parameter indizes


// maximal indizes of parameters in the different groups

//Groups in Index SET 
#define MDD2000MNG_MAX_MOTOR_PARA    029
#define MDD2000MNG_MAX_DRIVE_PARA    049
#define MDD2000MNG_MAX_CURRENT_PARA  059
#define MDD2000MNG_MAX_VEL_PARA      069
#define MDD2000MNG_MAX_POS_PARA      079
#define MDD2000MNG_MAX_FD_PARA       089
#define MDD2000MNG_MAX_APPLI_PARA    173

//Groups in Index INFO
#define MDD2000MNG_MAX_ACT_VALUES    46



//*****************************************************************************
//** Types                                                                   **
//*****************************************************************************
  TYPE

    t_MDD2000Mng_AsyncPara_Entry : STRUCT
      pThisObj        : ^void;
      usEntry         : USINT;
      uiParaIndex     : UINT;
      usParaSubIndex  : USINT;
      usRDWR          : USINT;
      dValue          : ARRAY [0..11] OF USINT;
      bsDataInfo      : BSINT;
      udTimeStamp     : UDINT;
      udTimeoutCycles : UDINT;
      dCallID         : DINT;
      bSent           : BOOL;
      bFinished       : BOOL;
    END_STRUCT;
    
    t_MDD2000Mng_ParaObjectListEntry : STRUCT
      pObject   : pVirtualBase;
      udIndex   : UDINT;
    END_STRUCT;
    
  END_TYPE 

//*****************************************************************************
//** Parameterdefines for MDD2000 parameter                                  **
//*****************************************************************************
//*****************************************************************************
//** Drive Parameter for konfiguration                                       **
//*****************************************************************************
#define MDD2000_PID_SIGMATEKPARA_INDEX_SET 0x2210

#define MDD2000_PID_SIGMATEKPARA_INDEX_SET_MAX_NR  174

// Sub Parameter Definition
// motor parameter
#define MDD2000_SPID_M_NAME1   001
#define MDD2000_SPID_M_NAME2   002
#define MDD2000_SPID_M_NAME3   003
#define MDD2000_SPID_M_INULL   004
#define MDD2000_SPID_M_IPEAK   005
#define MDD2000_SPID_M_NMAX    006
#define MDD2000_SPID_M_POL     007
#define MDD2000_SPID_M_TORQUE  008
#define MDD2000_SPID_M_L       009
#define MDD2000_SPID_M_R       010
#define MDD2000_SPID_M_J       011
#define MDD2000_SPID_M_TYPE    012
#define MDD2000_SPID_M_RPOL    013
#define MDD2000_SPID_M_ROFF    014
#define MDD2000_SPID_M_RPULSE  015
#define MDD2000_SPID_M_RTEMP   016
#define MDD2000_SPID_M_SER     017
#define MDD2000_SPID_M_BRAKE   018


#define MDD2000_SPID_M_IFWEAK  021
#define MDD2000_SPID_M_BRDIS   022
#define MDD2000_SPID_M_BREN    023
#define MDD2000_SPID_M_UN      024
#define MDD2000_SPID_M_UBOOST  025
#define MDD2000_SPID_M_IMAG    026
#define MDD2000_SPID_M_TROT    027
#define MDD2000_SPID_M_BRI     029

// drive parameter  
#define MDD2000_SPID_G_MODE    032
#define MDD2000_SPID_G_CETIME  033
#define MDD2000_SPID_G_VMAINS  034
#define MDD2000_SPID_G_MBAL    036
#define MDD2000_SPID_G_MTEMPK  037
#define MDD2000_SPID_G_MTEMPE  038
#define MDD2000_SPID_G_PWM     039
#define MDD2000_SPID_G_DELAY   040

#define MDD2000_SPID_G_EMRAMP  042
#define MDD2000_SPID_G_MASKE1  043
#define MDD2000_SPID_G_MASKE2  044
#define MDD2000_SPID_G_MASKW   045
#define MDD2000_SPID_G_MASKD   046
#define MDD2000_SPID_G_VRAMP   047
#define MDD2000_SPID_G_SRAMP   048
#define MDD2000_SPID_G_RBAL    049

// current control parameter
#define MDD2000_SPID_C_KPQ     050
#define MDD2000_SPID_C_TN      051

#define MDD2000_SPID_C_KPDREL  053
#define MDD2000_SPID_C_KPNULL  054
#define MDD2000_SPID_C_KPPEAK  055
#define MDD2000_SPID_C_ICONT   056
#define MDD2000_SPID_C_IPEAK   057
#define MDD2000_SPID_C_IPEAKN  058
#define MDD2000_SPID_C_KFWEAK  059

#define MDD2000_SPID_C_IFWEAK  168

// velocity control parameter
#define MDD2000_SPID_V_KP      060
#define MDD2000_SPID_V_TN      061
#define MDD2000_SPID_V_T       062
#define MDD2000_SPID_V_T2      063
#define MDD2000_SPID_V_FILT    064
#define MDD2000_SPID_V_NMAX    065

#define MDD2000_SPID_V_GSH     067
#define MDD2000_SPID_V_GSL     068 
#define MDD2000_SPID_V_GF      069
  
// position control parameter  
#define MDD2000_SPID_P_KV      070
#define MDD2000_SPID_P_SFF     071
#define MDD2000_SPID_P_PSCALE  072
#define MDD2000_SPID_P_SSCALE  073
#define MDD2000_SPID_P_TFF     074
#define MDD2000_SPID_P_PEMAX   075
#define MDD2000_SPID_P_SMODE   076

// feedback parameter  
#define MDD2000_SPID_F_BW      080
#define MDD2000_SPID_F_FF      081
#define MDD2000_SPID_F_RK      082
#define MDD2000_SPID_F_BCONF   085
#define MDD2000_SPID_F_FFILT   089

// application parameter
#define MDD2000_SPID_A_JRATIO  090
#define MDD2000_SPID_A_VALRT1  091
#define MDD2000_SPID_A_VALRT2  092
#define MDD2000_SPID_A_VALTT1  093
#define MDD2000_SPID_A_VALTT2  094
#define MDD2000_SPID_A_CTIME   095

#define MDD2000_SPID_A_I2TERR  099

#define MDD2000_SPID_A_TEMPMW  101

#define MDD2000_SPID_A_ICOM    105
#define MDD2000_SPID_A_CAP1    106
#define MDD2000_SPID_A_CAP2    107
#define MDD2000_SPID_A_DNAME1  108
#define MDD2000_SPID_A_DNAME2  109
#define MDD2000_SPID_A_DNAME3  110

#define MDD2000_SPID_A_INT1    114
#define MDD2000_SPID_A_INT2    115
#define MDD2000_SPID_A_ICOMP   116
#define MDD2000_SPID_A_CMIN    117
#define MDD2000_SPID_A_BIQCF   118
#define MDD2000_SPID_A_BIQFR   119
#define MDD2000_SPID_A_BIQCD   120
#define MDD2000_SPID_A_BIQDR   121
#define MDD2000_SPID_A_CAPFT   122
#define MDD2000_SPID_A_EIMAX   123

// optional parameter (not used atm)
#define MDD2000_SPID_O_TYPE    125
#define MDD2000_SPID_O_RPULSE  126
#define MDD2000_SPID_O_RPOL    127
#define MDD2000_SPID_O_BW      128
#define MDD2000_SPID_O_RK      129
#define MDD2000_SPID_O_FILT    130
#define MDD2000_SPID_O_BCONF   131
#define MDD2000_SPID_O_PSCALE  132

// application parameter
#define MDD2000_SPID_A_BTTS    150
#define MDD2000_SPID_A_BTTR    151
#define MDD2000_SPID_A_BTC     152
#define MDD2000_SPID_A_BTMP    153
#define MDD2000_SPID_A_TRAMP   156

//extended motor parameter
#define MDD2000_SPID_E_INENN   154
#define MDD2000_SPID_E_NNENN   155
#define MDD2000_SPID_E_I2TT    157
#define MDD2000_SPID_E_TISO    158

// application parameter
#define MDD2000_SPID_A_BVR     159

#define MDD2000_SPID_A_FB2     171
#define MDD2000_SPID_A_CME     173

//*****************************************************************************
//** Drive Parameter for infomation and commands                             **
//*****************************************************************************
// 
#define MDD2000_PID_SIGMATEKPARA_INDEX_INFO 0x2211

// Sub Parameter Definition
// actual values
#define MDD2000_SPID_I_PCMD    001
#define MDD2000_SPID_I_PE      002
#define MDD2000_SPID_I_POS     003
#define MDD2000_SPID_I_FPOS    004
#define MDD2000_SPID_I_IU      005
#define MDD2000_SPID_I_IV      006
#define MDD2000_SPID_I_MPOS    007
#define MDD2000_SPID_I_TEMPM   008
#define MDD2000_SPID_I_BCC     009
#define MDD2000_SPID_I_TEMPK   010
#define MDD2000_SPID_I_TEMPE   011
#define MDD2000_SPID_I_IPEAK   012
#define MDD2000_SPID_I_ICONT   013
#define MDD2000_SPID_I_FW      014
#define MDD2000_SPID_I_BUILD   015
#define MDD2000_SPID_I_HC      016
#define MDD2000_SPID_I_NCMD    017
#define MDD2000_SPID_I_IQ      018
#define MDD2000_SPID_I_ID      019
#define MDD2000_SPID_I_I2T     020
#define MDD2000_SPID_I_ICMD    021
#define MDD2000_SPID_I_VBUS    022
#define MDD2000_SPID_I_PBAL    023
#define MDD2000_SPID_I_N       024
#define MDD2000_SPID_I_NFILT   025
#define MDD2000_SPID_I_STATUS  026
#define MDD2000_SPID_I_SER     027
#define MDD2000_SPID_I_DERR1   028
#define MDD2000_SPID_I_CAP1    029
#define MDD2000_SPID_I_CAP2    030

#define MDD2000_SPID_I_BITS    032
#define MDD2000_SPID_I_INT1    033
#define MDD2000_SPID_I_INT2    034
#define MDD2000_SPID_I_TYPE    035 //at DCs/SRs, WA01x, MDD2000,..
#define MDD2000_SPID_I_CAPC    036
#define MDD2000_SPID_I_HW      037
#define MDD2000_SPID_I_FBB     038 
#define MDD2000_SPID_I_SAFERR  039

#define MDD2000_SPID_I_CAP12   042
#define MDD2000_SPID_I_CAP22   043
#define MDD2000_SPID_I_DERR2   044
#define MDD2000_SPID_I_DERR3   045
#define MDD2000_SPID_I_POS2    046


// drive commands
#define MDD2000_SPID_K_EN      047
#define MDD2000_SPID_K_CLRF    048
#define MDD2000_SPID_K_BRAKE   049
#define MDD2000_SPID_K_FBRW    050
#define MDD2000_SPID_K_START   051

#define MDD2000_SPID_K_CI      053
#define MDD2000_SPID_K_CINC    054
#define MDD2000_SPID_K_SPEED   055
#define MDD2000_SPID_K_STEP    056
#define MDD2000_SPID_K_PMOVE   057
#define MDD2000_SPID_K_PINC    058
#define MDD2000_SPID_K_PHI     059
#define MDD2000_SPID_K_SBT     060

#define MDD2000_SPID_T_CMD     064
#define MDD2000_SPID_K_NETIP   065
#define MDD2000_SPID_K_NETGW   066
#define MDD2000_SPID_K_NETSM   067
#define MDD2000_SPID_K_DATE    068

// drive scope Commands
#define MDD2000_SPID_P_S_CH    073
#define MDD2000_SPID_P_S_TRIGL 074
#define MDD2000_SPID_P_S_TRIGB 075
#define MDD2000_SPID_P_S_INDEX 076
#define MDD2000_SPID_P_S_WORK  077
#define MDD2000_SPID_P_S_GET1  078
#define MDD2000_SPID_P_S_GET2  079
#define MDD2000_SPID_P_S_GET3  080
#define MDD2000_SPID_P_S_STAT  081

//*****************************************************************************
//** Drive Parameter for Safety                                              **
//*****************************************************************************

// ---
#define MDD2000_PID_SAFETY_IMG_INFO              0x2060
// Sub Parameter Definition
#define MDD2000_SPID_SAFETY_IMG_FWVERSION             1
#define MDD2000_SPID_SAFETY_IMG_GITHASH               2
#define MDD2000_SPID_SAFETY_IMG_BUILDDATETIME         3
#define MDD2000_SPID_SAFETY_IMG_SC1CRC                4
#define MDD2000_SPID_SAFETY_IMG_SC2CRC                5

// ---
#define MDD2000_PID_SAFETY_CFG_INFO              0x2061
// Sub Parameter Definition
#define MDD2000_SPID_SAFETY_NO                        1
#define MDD2000_SPID_SAFETY_CFG_STATE                 2
#define MDD2000_SPID_SAFETY_CFG_CRC                   3
#define MDD2000_SPID_SAFETY_CFG_NAME_1                4
#define MDD2000_SPID_SAFETY_CFG_NAME_2                5
#define MDD2000_SPID_SAFETY_CFG_NAME_3                6
#define MDD2000_SPID_SAFETY_CFG_NAME_4                7
#define MDD2000_SPID_SAFETY_CFG_CRC_APP               8
#define MDD2000_SPID_SAFETY_CFG_OUT_FSOEFRAME         9 // size of outgoing FSoE data (MDD2000 -> SCP) in bytes
#define MDD2000_SPID_SAFETY_CFG_IN_FSOEFRAME         10 // size of incoming FSoE data (SCP -> MDD2000) in bytes

// ---
#define MDD2000_PID_SAFETY_RUN_INFO              0x2062
// Sub Parameter Definition
#define MDD2000_SPID_SAFETY_RUN_STATE                 1
#define MDD2000_SPID_SAFETY_RUN_SUBSTATE              2

// ---
#define MDD2000_PID_SAFETY_ERROR                 0x2063
// Sub Parameter Definition
#define MDD2000_SPID_SAFETY_ERROR_SC1_CODE            1
#define MDD2000_SPID_SAFETY_ERROR_SC1_INFO1           2
#define MDD2000_SPID_SAFETY_ERROR_SC1_INFO2           3     
#define MDD2000_SPID_SAFETY_ERROR_SC1_INFO3           4
#define MDD2000_SPID_SAFETY_ERROR_SC2_CODE            5
#define MDD2000_SPID_SAFETY_ERROR_SC2_INFO1           6
#define MDD2000_SPID_SAFETY_ERROR_SC2_INFO2           7
#define MDD2000_SPID_SAFETY_ERROR_SC2_INFO3           8

// ---
#define MDD2000_PID_SAFETY_COMMANDS              0x2064
// Sub Parameter Definition
#define MDD2000_SPID_SAFETY_ERROR_QUIT                1
#define MDD2000_SPID_SAFETY_FINISH_VERIFY             2
#define MDD2000_SPID_SAFETY_RESET_VERIFY              3
#define MDD2000_SPID_SAFETY_SETSERVICEMODE            4
#define MDD2000_SPID_SAFETY_LEAVESERVICEMODE          5

// ---
#define MDD2000_PID_SAFETY_AXIS_INFO             0x2260
// Sub Parameter Definition
#define MDD2000_SPID_SAFETY_AXIS_VERIFY_FEEDBACK      1
#define MDD2000_SPID_SAFETY_AXIS_FEEDBACK_STATE       2
#define MDD2000_SPID_SAFETY_AXIS_SETZEROPOS           3
#define MDD2000_SPID_SAFETY_AXIS_POSSREFTATE          4

// ---
#define MDD2000_PID_SAFETY_AXIS_FUNC_INFO        0x2261
// Sub Parameter Definition
#define MDD2000_SPID_SAFETY_AXIS_RESTARTACK           1
#define MDD2000_SPID_SAFETY_AXIS_ERRORACK             2
#define MDD2000_SPID_SAFETY_AXIS_CONT_WORD            3
#define MDD2000_SPID_SAFETY_AXIS_STATE_WORD           4
#define MDD2000_SPID_SAFETY_AXIS_ERROR_WORD           5
#define MDD2000_SPID_SAFETY_AXIS_ERR_ID               6
#define MDD2000_SPID_SAFETY_AXIS_ERR_SOURCE           7
#define MDD2000_SPID_SAFETY_AXIS_ERR_REACT            8
#define MDD2000_SPID_SAFETY_AXIS_ERR_INFO1            9
#define MDD2000_SPID_SAFETY_AXIS_ERR_INFO2           10
#define MDD2000_SPID_SAFETY_AXIS_ERR_INFO3           11

// ---
#define MDD2000_PID_SAFETY_BRAKE_TEST            0x2262
// Sub Parameter Definition
#define MDD2000_SPID_SAFETY_BRAKE_TEST_CNTDOWN        1
#define MDD2000_SPID_SAFETY_BRAKE_TEST_STATE          2
#define MDD2000_SPID_FUNCT_BRAKE_TEST_STATE           3
#define MDD2000_SPID_FUNCT_BRAKE_ERROR_INFO           4

//*****************************************************************************
//** Drive Parameter for Safety Config                                       **
//*****************************************************************************

#define MDD2000_PID_LEN_OUT_FSOEFRAME 0x4002 // size of outgoing FSoE data (MDD2000 -> SCP) in bytes
#define MDD2000_PID_LEN_IN_FSOEFRAME  0x4003 // size of incoming FSoE data (SCP -> MDD2000) in bytes

//*****************************************************************************
//** Drive Parameter for Safety Function Config                              **
//*****************************************************************************

#define MDD2000_SFKTCFG_IDX_MIN       0x6600
#define MDD2000_SFKTCFG_IDX_MAX       0x67FF 
#define MDD2000_SFKTCFG_IDXOFFSET     0x0800 // Index Offset between axis

#define MDD2000_PID_SFKTCFG_CTRLWORD_FKTMAPPING       0x6750
#define MDD2000_PID_SFKTCFG_STATEWORD_FKTMAPPING      0x6751

#define MDD2000_SPIDMAX_SFKTCFG_CTRLSTATEWORD_FKTMAPPING      16  // 16 possible mappings

#define MDD2000_AXISSAFE_MAX_IDX_SAFEFKT                      17  // 18 Possible Safety Functions

// Stop Functions
#define MDD2000_PID_SFKTCFG_STO       0x6640
#define MDD2000_PID_SFKTCFG_SS1       0x6650
#define MDD2000_PID_SFKTCFG_SS2       0x6670
#define MDD2000_PID_SFKTCFG_SOS       0x6668

// Break Functions
#define MDD2000_PID_SFKTCFG_SBC       0x6660
#define MDD2000_PID_SFKTCFG_SBT       0x6720

// Limit Functions
#define MDD2000_PID_SFKTCFG_SLS       0x6690
#define MDD2000_PID_SFKTCFG_SLP       0x66A0
#define MDD2000_PID_SFKTCFG_SLA       0x6700
#define MDD2000_PID_SFKTCFG_SLT       0x66B0
#define MDD2000_PID_SFKTCFG_SLI       0x66B8
#define MDD2000_PID_SFKTCFG_SDI       0x66D0

// Monitoring Functions
#define MDD2000_PID_SFKTCFG_SMS       0x66A8
#define MDD2000_PID_SFKTCFG_SMP       0x6730
#define MDD2000_PID_SFKTCFG_SMA       0x66C8
#define MDD2000_PID_SFKTCFG_SMT       0x6738
#define MDD2000_PID_SFKTCFG_SSM       0x66E0
#define MDD2000_PID_SFKTCFG_SCA       0x66E8

//*************************************************************************************




#endif