diff --git a/.github/workflows/build-cmake.yml b/.github/workflows/build-cmake.yml new file mode 100644 index 0000000..82ac45d --- /dev/null +++ b/.github/workflows/build-cmake.yml @@ -0,0 +1,57 @@ +name: CMake + +on: + pull_request: + branches: ["main"] + paths: + - ".github/workflows/build-cmake.yml" + - "ipc/**/*.c" + - "ipc/**/*.h" + - "**/CMakeLists.txt" + - "cmake/*.cmake" + push: + branches: ["main"] + paths: + - ".github/workflows/build-cmake.yml" + - "ipc/**/*.c" + - "ipc/**/*.h" + - "**/CMakeLists.txt" + - "cmake/*.cmake" + +jobs: + linux-build-cmake: + name: Linux + runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + compiler: ["gcc", "clang"] + steps: + - uses: actions/checkout@v5 + - name: Setup CMake + run: | + CC=${{ matrix.compiler }} cmake -S . -B build + - name: Build + run: | + CC=${{ matrix.compiler }} cmake --build build + + windows-build-cmake: + name: Windows + runs-on: windows-latest + strategy: + fail-fast: true + matrix: + compiler: ["cl.exe", "gcc.exe"] + steps: + - uses: actions/checkout@v5 + - uses: ilammy/msvc-dev-cmd@v1.13.0 + - name: Setup CMake + run: | + cmake -S . -B build + env: + CC: ${{ matrix.compiler }} + - name: Build + run: | + cmake --build build + env: + CC: ${{ matrix.compiler }} diff --git a/.github/workflows/build.yml b/.github/workflows/build-meson.yml similarity index 94% rename from .github/workflows/build.yml rename to .github/workflows/build-meson.yml index 65b7320..9247b4a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build-meson.yml @@ -1,17 +1,17 @@ -name: Build and Test +name: Meson on: pull_request: branches: ["main"] paths: - - ".github/workflows/build.yml" + - ".github/workflows/build-meson.yml" - "ipc/**/*.c" - "ipc/**/*.h" - "**/meson.build" push: branches: ["main"] paths: - - ".github/workflows/build.yml" + - ".github/workflows/build-meson.yml" - "ipc/**/*.c" - "ipc/**/*.h" - "**/meson.build" @@ -41,6 +41,7 @@ jobs: - name: Verbosely Test run: | meson test -v -C build + windows-build-meson: name: Windows runs-on: windows-latest diff --git a/.gitignore b/.gitignore index 260a04a..72e7ff1 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,8 @@ build compile_commands.json .cache .meson-subproject-wrap-hash.txt + +*.a* +*.so* +*.lib +*.dll diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..69f58be --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,43 @@ +cmake_minimum_required(VERSION 3.30..4.0) +project(libtestrig + LANGUAGES C) + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") + +set(LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib") +set(IPC_DIR "${LIB_DIR}/ipc") +set(EPOS_DIR "${LIB_DIR}/epos2") + +set(IPC_SOURCES + "${IPC_DIR}/ipc.c" + "${IPC_DIR}/constants.c" + "${IPC_DIR}/message.c" + "${IPC_DIR}/os.c") + +set(EPOS_SOURCES + "${EPOS_DIR}/epos2.c" + "${EPOS_DIR}/connect.c" + "${EPOS_DIR}/definitions.c" + "${EPOS_DIR}/manage.c" + "${EPOS_DIR}/identify.c") + +set(LIBTESTRIG_SOURCES ${IPC_SOURCES}) + +find_package(EPOSCmd) +if (EPOSCmd_FOUND) + list(APPEND LIBTESTRIG_SOURCES ${EPOS_SOURCES}) +else() + message("Controller capabilities not being built.") +endif() + +add_library(Libtestrig SHARED ${LIBTESTRIG_SOURCES}) +target_compile_definitions(Libtestrig PRIVATE COMPILING_TESTRIG_DLL) +target_include_directories(Libtestrig PUBLIC ${LIB_DIR}) + +if (WIN32) + target_link_libraries(Libtestrig PRIVATE Ws2_32) +endif() + +if (EPOSCmd_FOUND) + target_link_libraries(Libtestrig PUBLIC EPOSCmd) +endif() diff --git a/cmake/FindEPOSCmd.cmake b/cmake/FindEPOSCmd.cmake new file mode 100644 index 0000000..e69de29 diff --git a/epos2/definitions.h b/epos2/definitions.h deleted file mode 100644 index 6b47795..0000000 --- a/epos2/definitions.h +++ /dev/null @@ -1,533 +0,0 @@ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -//Communication -int CreateCommunication(); -int DeleteCommunication(); - -// Data Recorder -int CreateDataRecorderCmdManager(void* KeyHandle); -int DeleteDataRecorderCmdManager(); - -/************************************************************************************************************************************* -* INITIALISATION FUNCTIONS -*************************************************************************************************************************************/ - -//Communication -void* VCS_OpenDevice(char* DeviceName, char* ProtocolStackName, char* InterfaceName, char* PortName, unsigned int* pErrorCode); -int VCS_SetProtocolStackSettings(void* KeyHandle, unsigned int Baudrate, unsigned int Timeout, unsigned int* pErrorCode); -int VCS_GetProtocolStackSettings(void* KeyHandle, unsigned int* pBaudrate, unsigned int* pTimeout, unsigned int* pErrorCode); -int VCS_CloseDevice(void* KeyHandle, unsigned int* pErrorCode); -int VCS_CloseAllDevices(unsigned int* pErrorCode); - -//Gateway -int VCS_SetGatewaySettings(void* KeyHandle, unsigned int Baudrate, unsigned int* pErrorCode); -int VCS_GetGatewaySettings(void* KeyHandle, unsigned int* pBaudrate, unsigned int* pErrorCode); - -//Sub device -void* VCS_OpenSubDevice(void* DeviceHandle, char* DeviceName, char* ProtocolStackName, unsigned int* pErrorCode); -int VCS_CloseSubDevice(void* KeyHandle, unsigned int* pErrorCode); -int VCS_CloseAllSubDevices(void* DeviceHandle, unsigned int* pErrorCode); - -//Info -int VCS_GetDriverInfo(char* p_pszLibraryName, unsigned short p_usMaxLibraryNameStrSize,char* p_pszLibraryVersion, unsigned short p_usMaxLibraryVersionStrSize, unsigned int* p_pErrorCode); -int VCS_GetVersion(void* KeyHandle, unsigned short NodeId, unsigned short* pHardwareVersion, unsigned short* pSoftwareVersion, unsigned short* pApplicationNumber, unsigned short* pApplicationVersion, unsigned int* pErrorCode); -int VCS_GetErrorInfo(unsigned int ErrorCodeValue, char* pErrorInfo, unsigned short MaxStrSize); - -//Advanced Functions -int VCS_GetDeviceNameSelection(int StartOfSelection, char* pDeviceNameSel, unsigned short MaxStrSize, int* pEndOfSelection, unsigned int* pErrorCode); -int VCS_GetProtocolStackNameSelection(char* DeviceName, int StartOfSelection, char* pProtocolStackNameSel, unsigned short MaxStrSize, int* pEndOfSelection, unsigned int* pErrorCode); -int VCS_GetInterfaceNameSelection(char* DeviceName, char* ProtocolStackName, int StartOfSelection, char* pInterfaceNameSel, unsigned short MaxStrSize, int* pEndOfSelection, unsigned int* pErrorCode); -int VCS_GetPortNameSelection(char* DeviceName, char* ProtocolStackName, char* InterfaceName, int StartOfSelection, char* pPortSel, unsigned short MaxStrSize, int* pEndOfSelection, unsigned int* pErrorCode); -int VCS_ResetPortNameSelection(char* DeviceName, char* ProtocolStackName, char* InterfaceName, unsigned int* pErrorCode); -int VCS_GetBaudrateSelection(char* DeviceName, char* ProtocolStackName, char* InterfaceName, char* PortName, int StartOfSelection, unsigned int* pBaudrateSel, int* pEndOfSelection, unsigned int* pErrorCode); -int VCS_GetKeyHandle(char* DeviceName, char* ProtocolStackName, char* InterfaceName, char* PortName, void** pKeyHandle, unsigned int* pErrorCode); -int VCS_GetDeviceName(void* KeyHandle, char* pDeviceName, unsigned short MaxStrSize, unsigned int* pErrorCode); -int VCS_GetProtocolStackName(void* KeyHandle, char* pProtocolStackName, unsigned short MaxStrSize, unsigned int* pErrorCode); -int VCS_GetInterfaceName(void* KeyHandle, char* pInterfaceName, unsigned short MaxStrSize, unsigned int* pErrorCode); -int VCS_GetPortName(void* KeyHandle, char* pPortName, unsigned short MaxStrSize, unsigned int* pErrorCode); - -/************************************************************************************************************************************* -* CONFIGURATION FUNCTIONS -*************************************************************************************************************************************/ - -//General -int VCS_SetObject(void* KeyHandle, unsigned short NodeId, unsigned short ObjectIndex, unsigned char ObjectSubIndex, void* pData, unsigned int NbOfBytesToWrite, unsigned int* pNbOfBytesWritten, unsigned int* pErrorCode); -int VCS_GetObject(void* KeyHandle, unsigned short NodeId, unsigned short ObjectIndex, unsigned char ObjectSubIndex, void* pData, unsigned int NbOfBytesToRead, unsigned int* pNbOfBytesRead, unsigned int* pErrorCode); -int VCS_Restore(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); -int VCS_Store(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); - -//Advanced Functions -//Motor -int VCS_SetMotorType(void* KeyHandle, unsigned short NodeId, unsigned short MotorType, unsigned int* pErrorCode); -int VCS_SetDcMotorParameter(void* KeyHandle, unsigned short NodeId, unsigned short NominalCurrent, unsigned short MaxOutputCurrent, unsigned short ThermalTimeConstant, unsigned int* pErrorCode); -int VCS_SetDcMotorParameterEx(void* KeyHandle, unsigned short NodeId, unsigned int NominalCurrent, unsigned int MaxOutputCurrent, unsigned short ThermalTimeConstant, unsigned int* pErrorCode); -int VCS_SetEcMotorParameter(void* KeyHandle, unsigned short NodeId, unsigned short NominalCurrent, unsigned short MaxOutputCurrent, unsigned short ThermalTimeConstant, unsigned char NbOfPolePairs, unsigned int* pErrorCode); -int VCS_SetEcMotorParameterEx(void* KeyHandle, unsigned short NodeId, unsigned int NominalCurrent, unsigned int MaxOutputCurrent, unsigned short ThermalTimeConstant, unsigned char NbOfPolePairs, unsigned int* pErrorCode); -int VCS_GetMotorType(void* KeyHandle, unsigned short NodeId, unsigned short* pMotorType, unsigned int* pErrorCode); -int VCS_GetDcMotorParameter(void* KeyHandle, unsigned short NodeId, unsigned short* pNominalCurrent, unsigned short* pMaxOutputCurrent, unsigned short* pThermalTimeConstant, unsigned int* pErrorCode); -int VCS_GetDcMotorParameterEx(void* KeyHandle, unsigned short NodeId, unsigned int* pNominalCurrent, unsigned int* pMaxOutputCurrent, unsigned short* pThermalTimeConstant, unsigned int* pErrorCode); -int VCS_GetEcMotorParameter(void* KeyHandle, unsigned short NodeId, unsigned short* pNominalCurrent, unsigned short* pMaxOutputCurrent, unsigned short* pThermalTimeConstant, unsigned char* pNbOfPolePairs, unsigned int* pErrorCode); -int VCS_GetEcMotorParameterEx(void* KeyHandle, unsigned short NodeId, unsigned int* pNominalCurrent, unsigned int* pMaxOutputCurrent, unsigned short* pThermalTimeConstant, unsigned char* pNbOfPolePairs, unsigned int* pErrorCode); - -//Sensor -int VCS_SetSensorType(void* KeyHandle, unsigned short NodeId, unsigned short SensorType, unsigned int* pErrorCode); -int VCS_SetIncEncoderParameter(void* KeyHandle, unsigned short NodeId, unsigned int EncoderResolution, int InvertedPolarity, unsigned int* pErrorCode); -int VCS_SetHallSensorParameter(void* KeyHandle, unsigned short NodeId, int InvertedPolarity, unsigned int* pErrorCode); -int VCS_SetSsiAbsEncoderParameter(void* KeyHandle, unsigned short NodeId, unsigned short DataRate, unsigned short NbOfMultiTurnDataBits, unsigned short NbOfSingleTurnDataBits, int InvertedPolarity, unsigned int* pErrorCode); -int VCS_SetSsiAbsEncoderParameterEx(void* KeyHandle, unsigned short NodeId, unsigned short DataRate, unsigned short NbOfMultiTurnDataBits, unsigned short NbOfSingleTurnDataBits, unsigned short NbOfSpecialDataBits, int InvertedPolarity, unsigned short Timeout, unsigned short PowerupTime, unsigned int* pErrorCode); -int VCS_SetSsiAbsEncoderParameterEx2(void* KeyHandle, unsigned short NodeId, unsigned short DataRate, unsigned short NbOfSpecialDataBitsLeading, unsigned short NbOfMultiTurnDataBits, unsigned short NbOfMultiTurnPositionBits, unsigned short NbOfSingleTurnDataBits, unsigned short NbOfSingleTurnPositionBits, unsigned short NbOfSpecialDataBitsTrailing, int InvertedPolarity, unsigned short Timeout, unsigned short PowerupTime, int CheckFrame, int ReferenceReset, unsigned int* pErrorCode); -int VCS_GetSensorType(void* KeyHandle, unsigned short NodeId, unsigned short* pSensorType, unsigned int* pErrorCode); -int VCS_GetIncEncoderParameter(void* KeyHandle, unsigned short NodeId, unsigned int* pEncoderResolution, int* pInvertedPolarity, unsigned int* pErrorCode); -int VCS_GetHallSensorParameter(void* KeyHandle, unsigned short NodeId, int* pInvertedPolarity, unsigned int* pErrorCode); -int VCS_GetSsiAbsEncoderParameter(void* KeyHandle, unsigned short NodeId, unsigned short* pDataRate, unsigned short* pNbOfMultiTurnDataBits, unsigned short* pNbOfSingleTurnDataBits, int* pInvertedPolarity, unsigned int* pErrorCode); -int VCS_GetSsiAbsEncoderParameterEx(void* KeyHandle, unsigned short NodeId, unsigned short* pDataRate, unsigned short* pNbOfMultiTurnDataBits, unsigned short* pNbOfSingleTurnDataBits, unsigned short* pNbOfSpecialDataBits, int* pInvertedPolarity, unsigned short* pTimeout, unsigned short* pPowerupTime, unsigned int* pErrorCode); -int VCS_GetSsiAbsEncoderParameterEx2(void* KeyHandle, unsigned short NodeId, unsigned short* pDataRate, unsigned short* pNbOfSpecialDataBitsLeading, unsigned short* pNbOfMultiTurnDataBits, unsigned short* pNbOfMultiTurnPositionBits, unsigned short* pNbOfSingleTurnDataBits, unsigned short* pNbOfSingleTurnPositionBits, unsigned short* pNbOfSpecialDataBitsTrailing, int* pInvertedPolarity, unsigned short* pTimeout, unsigned short* pPowerupTime, int* pCheckFrame, int* pReferenceReset, unsigned int* pErrorCode); - -//Safety -int VCS_SetMaxFollowingError(void* KeyHandle, unsigned short NodeId, unsigned int MaxFollowingError, unsigned int* pErrorCode); -int VCS_GetMaxFollowingError(void* KeyHandle, unsigned short NodeId, unsigned int* pMaxFollowingError, unsigned int* pErrorCode); -int VCS_SetMaxProfileVelocity(void* KeyHandle, unsigned short NodeId, unsigned int MaxProfileVelocity, unsigned int* pErrorCode); -int VCS_GetMaxProfileVelocity(void* KeyHandle, unsigned short NodeId, unsigned int* pMaxProfileVelocity, unsigned int* pErrorCode); -int VCS_SetMaxAcceleration(void* KeyHandle, unsigned short NodeId, unsigned int MaxAcceleration, unsigned int* pErrorCode); -int VCS_GetMaxAcceleration(void* KeyHandle, unsigned short NodeId, unsigned int* pMaxAcceleration, unsigned int* pErrorCode); - -//Controller Gains -int VCS_SetControllerGain(void* KeyHandle, unsigned short NodeId, unsigned short EController, unsigned short EGain, unsigned long long Value, unsigned int* pErrorCode); -int VCS_GetControllerGain(void* KeyHandle, unsigned short NodeId, unsigned short EController, unsigned short EGain, unsigned long long* pValue, unsigned int* pErrorCode); - -//Inputs/Outputs -int VCS_DigitalInputConfiguration(void* KeyHandle, unsigned short NodeId, unsigned short DigitalInputNb, unsigned short Configuration, int Mask, int Polarity, int ExecutionMask, unsigned int* pErrorCode); -int VCS_DigitalOutputConfiguration(void* KeyHandle, unsigned short NodeId, unsigned short DigitalOutputNb, unsigned short Configuration, int State, int Mask, int Polarity, unsigned int* pErrorCode); -int VCS_AnalogInputConfiguration(void* KeyHandle, unsigned short NodeId, unsigned short AnalogInputNb, unsigned short Configuration, int ExecutionMask, unsigned int* pErrorCode); -int VCS_AnalogOutputConfiguration(void* KeyHandle, unsigned short NodeId, unsigned short AnalogOutputNb, unsigned short Configuration, unsigned int* pErrorCode); - -//Units -int VCS_SetVelocityUnits(void* KeyHandle, unsigned short NodeId, unsigned char VelDimension, signed char VelNotation, unsigned int* pErrorCode); -int VCS_GetVelocityUnits(void* KeyHandle, unsigned short NodeId, unsigned char* pVelDimension, char* pVelNotation, unsigned int* pErrorCode); - -//Compatibility Functions (do not use) -int VCS_SetPositionRegulatorGain(void* KeyHandle, unsigned short NodeId, unsigned short P, unsigned short I, unsigned short D, unsigned int* pErrorCode); -int VCS_SetPositionRegulatorFeedForward(void* KeyHandle, unsigned short NodeId, unsigned short VelocityFeedForward, unsigned short AccelerationFeedForward, unsigned int* pErrorCode); -int VCS_GetPositionRegulatorGain(void* KeyHandle, unsigned short NodeId, unsigned short* pP, unsigned short* pI, unsigned short* pD, unsigned int* pErrorCode); -int VCS_GetPositionRegulatorFeedForward(void* KeyHandle, unsigned short NodeId, unsigned short* pVelocityFeedForward, unsigned short* pAccelerationFeedForward, unsigned int* pErrorCode); - -int VCS_SetVelocityRegulatorGain(void* KeyHandle, unsigned short NodeId, unsigned short P, unsigned short I, unsigned int* pErrorCode); -int VCS_SetVelocityRegulatorFeedForward(void* KeyHandle, unsigned short NodeId, unsigned short VelocityFeedForward, unsigned short AccelerationFeedForward, unsigned int* pErrorCode); -int VCS_GetVelocityRegulatorGain(void* KeyHandle, unsigned short NodeId, unsigned short* pP, unsigned short* pI, unsigned int* pErrorCode); -int VCS_GetVelocityRegulatorFeedForward(void* KeyHandle, unsigned short NodeId, unsigned short* pVelocityFeedForward, unsigned short* pAccelerationFeedForward, unsigned int* pErrorCode); - -int VCS_SetCurrentRegulatorGain(void* KeyHandle, unsigned short NodeId, unsigned short P, unsigned short I, unsigned int* pErrorCode); -int VCS_GetCurrentRegulatorGain(void* KeyHandle, unsigned short NodeId, unsigned short* pP, unsigned short* pI, unsigned int* pErrorCode); - -/************************************************************************************************************************************* -* OPERATION FUNCTIONS -*************************************************************************************************************************************/ - -//OperationMode -int VCS_SetOperationMode(void* KeyHandle, unsigned short NodeId, char OperationMode, unsigned int* pErrorCode); -int VCS_GetOperationMode(void* KeyHandle, unsigned short NodeId, char* pOperationMode, unsigned int* pErrorCode); - -//StateMachine -int VCS_ResetDevice(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); -int VCS_SetState(void* KeyHandle, unsigned short NodeId, unsigned short State, unsigned int* pErrorCode); -int VCS_SetEnableState(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); -int VCS_SetDisableState(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); -int VCS_SetQuickStopState(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); -int VCS_ClearFault(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); -int VCS_GetState(void* KeyHandle, unsigned short NodeId, unsigned short* pState, unsigned int* pErrorCode); -int VCS_GetEnableState(void* KeyHandle, unsigned short NodeId, int* pIsEnabled, unsigned int* pErrorCode); -int VCS_GetDisableState(void* KeyHandle, unsigned short NodeId, int* pIsDisabled, unsigned int* pErrorCode); -int VCS_GetQuickStopState(void* KeyHandle, unsigned short NodeId, int* pIsQuickStopped, unsigned int* pErrorCode); -int VCS_GetFaultState(void* KeyHandle, unsigned short NodeId, int* pIsInFault, unsigned int* pErrorCode); - -//ErrorHandling -int VCS_GetNbOfDeviceError(void* KeyHandle, unsigned short NodeId, unsigned char *pNbDeviceError, unsigned int *pErrorCode); -int VCS_GetDeviceErrorCode(void* KeyHandle, unsigned short NodeId, unsigned char DeviceErrorNumber, unsigned int *pDeviceErrorCode, unsigned int *pErrorCode); - -//Motion Info -int VCS_GetMovementState(void* KeyHandle, unsigned short NodeId, int* pTargetReached, unsigned int* pErrorCode); -int VCS_GetPositionIs(void* KeyHandle, unsigned short NodeId, int* pPositionIs, unsigned int* pErrorCode); -int VCS_GetVelocityIs(void* KeyHandle, unsigned short NodeId, int* pVelocityIs, unsigned int* pErrorCode); -int VCS_GetVelocityIsAveraged(void* KeyHandle, unsigned short NodeId, int* pVelocityIsAveraged, unsigned int* pErrorCode); -int VCS_GetCurrentIs(void* KeyHandle, unsigned short NodeId, short* pCurrentIs, unsigned int* pErrorCode); -int VCS_GetCurrentIsEx(void* KeyHandle, unsigned short NodeId, int* pCurrentIs, unsigned int* pErrorCode); -int VCS_GetCurrentIsAveraged(void* KeyHandle, unsigned short NodeId, short* pCurrentIsAveraged, unsigned int* pErrorCode); -int VCS_GetCurrentIsAveragedEx(void* KeyHandle, unsigned short NodeId, int* pCurrentIsAveraged, unsigned int* pErrorCode); -int VCS_WaitForTargetReached(void* KeyHandle, unsigned short NodeId, unsigned int Timeout, unsigned int* pErrorCode); - -//Profile Position Mode -int VCS_ActivateProfilePositionMode(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); -int VCS_SetPositionProfile(void* KeyHandle, unsigned short NodeId, unsigned int ProfileVelocity, unsigned int ProfileAcceleration, unsigned int ProfileDeceleration, unsigned int* pErrorCode); -int VCS_GetPositionProfile(void* KeyHandle, unsigned short NodeId, unsigned int* pProfileVelocity, unsigned int* pProfileAcceleration, unsigned int* pProfileDeceleration, unsigned int* pErrorCode); -int VCS_MoveToPosition(void* KeyHandle, unsigned short NodeId, long TargetPosition, int Absolute, int Immediately, unsigned int* pErrorCode); -int VCS_GetTargetPosition(void* KeyHandle, unsigned short NodeId, long* pTargetPosition, unsigned int* pErrorCode); -int VCS_HaltPositionMovement(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); - -//Advanced Functions -int VCS_EnablePositionWindow(void* KeyHandle, unsigned short NodeId, unsigned int PositionWindow, unsigned short PositionWindowTime, unsigned int* pErrorCode); -int VCS_DisablePositionWindow(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); - -//Profile Velocity Mode -int VCS_ActivateProfileVelocityMode(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); -int VCS_SetVelocityProfile(void* KeyHandle, unsigned short NodeId, unsigned int ProfileAcceleration, unsigned int ProfileDeceleration, unsigned int* pErrorCode); -int VCS_GetVelocityProfile(void* KeyHandle, unsigned short NodeId, unsigned int* pProfileAcceleration, unsigned int* pProfileDeceleration, unsigned int* pErrorCode); -int VCS_MoveWithVelocity(void* KeyHandle, unsigned short NodeId, long TargetVelocity, unsigned int* pErrorCode); -int VCS_GetTargetVelocity(void* KeyHandle, unsigned short NodeId, long* pTargetVelocity, unsigned int* pErrorCode); -int VCS_HaltVelocityMovement(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); - -//Advanced Functions -int VCS_EnableVelocityWindow(void* KeyHandle, unsigned short NodeId, unsigned int VelocityWindow, unsigned short VelocityWindowTime, unsigned int* pErrorCode); -int VCS_DisableVelocityWindow(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); - -//Homing Mode -int VCS_ActivateHomingMode(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); -int VCS_SetHomingParameter(void* KeyHandle, unsigned short NodeId, unsigned int HomingAcceleration, unsigned int SpeedSwitch, unsigned int SpeedIndex, int HomeOffset, unsigned short CurrentThreshold, int HomePosition, unsigned int* pErrorCode); -int VCS_GetHomingParameter(void* KeyHandle, unsigned short NodeId, unsigned int* pHomingAcceleration, unsigned int* pSpeedSwitch, unsigned int* pSpeedIndex, int* pHomeOffset, unsigned short* pCurrentThreshold, int* pHomePosition, unsigned int* pErrorCode); -int VCS_FindHome(void* KeyHandle, unsigned short NodeId, signed char HomingMethod, unsigned int* pErrorCode); -int VCS_StopHoming(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); -int VCS_DefinePosition(void* KeyHandle, unsigned short NodeId, int HomePosition, unsigned int* pErrorCode); -int VCS_WaitForHomingAttained(void* KeyHandle, unsigned short NodeId, int Timeout, unsigned int* pErrorCode); -int VCS_GetHomingState(void* KeyHandle, unsigned short NodeId, int* pHomingAttained, int* pHomingError, unsigned int* pErrorCode); - -//Interpolated Position Mode -int VCS_ActivateInterpolatedPositionMode(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); -int VCS_SetIpmBufferParameter(void* KeyHandle, unsigned short NodeId, unsigned short UnderflowWarningLimit, unsigned short OverflowWarningLimit, unsigned int* pErrorCode); -int VCS_GetIpmBufferParameter(void* KeyHandle, unsigned short NodeId, unsigned short* pUnderflowWarningLimit, unsigned short* pOverflowWarningLimit, unsigned int* pMaxBufferSize, unsigned int* pErrorCode); -int VCS_ClearIpmBuffer(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); -int VCS_GetFreeIpmBufferSize(void* KeyHandle, unsigned short NodeId, unsigned int* pBufferSize, unsigned int* pErrorCode); -int VCS_AddPvtValueToIpmBuffer(void* KeyHandle, unsigned short NodeId, long Position, long Velocity, unsigned char Time, unsigned int* pErrorCode); -int VCS_StartIpmTrajectory(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); -int VCS_StopIpmTrajectory(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); -int VCS_GetIpmStatus(void* KeyHandle, unsigned short NodeId, int* pTrajectoryRunning, int* pIsUnderflowWarning, int* pIsOverflowWarning, int* pIsVelocityWarning, int* pIsAccelerationWarning, int* pIsUnderflowError, int* pIsOverflowError, int* pIsVelocityError, int* pIsAccelerationError, unsigned int* pErrorCode); - -//Position Mode -int VCS_ActivatePositionMode(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); -int VCS_SetPositionMust(void* KeyHandle, unsigned short NodeId, long PositionMust, unsigned int* pErrorCode); -int VCS_GetPositionMust(void* KeyHandle, unsigned short NodeId, long* pPositionMust, unsigned int* pErrorCode); - -//Advanced Functions -int VCS_ActivateAnalogPositionSetpoint(void* KeyHandle, unsigned short NodeId, unsigned short AnalogInputNumber, float Scaling, long Offset, unsigned int* pErrorCode); -int VCS_DeactivateAnalogPositionSetpoint(void* KeyHandle, unsigned short NodeId, unsigned short AnalogInputNumber, unsigned int* pErrorCode); -int VCS_EnableAnalogPositionSetpoint(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); -int VCS_DisableAnalogPositionSetpoint(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); - -//Velocity Mode -int VCS_ActivateVelocityMode(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); -int VCS_SetVelocityMust(void* KeyHandle, unsigned short NodeId, long VelocityMust, unsigned int* pErrorCode); -int VCS_GetVelocityMust(void* KeyHandle, unsigned short NodeId, long* pVelocityMust, unsigned int* pErrorCode); - -//Advanced Functions -int VCS_ActivateAnalogVelocitySetpoint(void* KeyHandle, unsigned short NodeId, unsigned short AnalogInputNumber, float Scaling, long Offset, unsigned int* pErrorCode); -int VCS_DeactivateAnalogVelocitySetpoint(void* KeyHandle, unsigned short NodeId, unsigned short AnalogInputNumber, unsigned int* pErrorCode); -int VCS_EnableAnalogVelocitySetpoint(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); -int VCS_DisableAnalogVelocitySetpoint(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); - -//Current Mode -int VCS_ActivateCurrentMode(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); -int VCS_SetCurrentMust(void* KeyHandle, unsigned short NodeId, short CurrentMust, unsigned int* pErrorCode); -int VCS_SetCurrentMustEx(void* KeyHandle, unsigned short NodeId, int CurrentMust, unsigned int* pErrorCode); -int VCS_GetCurrentMust(void* KeyHandle, unsigned short NodeId, short* pCurrentMust, unsigned int* pErrorCode); -int VCS_GetCurrentMustEx(void* KeyHandle, unsigned short NodeId, int* pCurrentMust, unsigned int* pErrorCode); - -//Advanced Functions -int VCS_ActivateAnalogCurrentSetpoint(void* KeyHandle, unsigned short NodeId, unsigned short AnalogInputNumber, float Scaling, short Offset, unsigned int* pErrorCode); -int VCS_DeactivateAnalogCurrentSetpoint(void* KeyHandle, unsigned short NodeId, unsigned short AnalogInputNumber, unsigned int* pErrorCode); -int VCS_EnableAnalogCurrentSetpoint(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); -int VCS_DisableAnalogCurrentSetpoint(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); - -//MasterEncoder Mode -int VCS_ActivateMasterEncoderMode(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); -int VCS_SetMasterEncoderParameter(void* KeyHandle, unsigned short NodeId, unsigned short ScalingNumerator, unsigned short ScalingDenominator, unsigned char Polarity, unsigned int MaxVelocity, unsigned int MaxAcceleration, unsigned int* pErrorCode); -int VCS_GetMasterEncoderParameter(void* KeyHandle, unsigned short NodeId, unsigned short* pScalingNumerator, unsigned short* pScalingDenominator, unsigned char* pPolarity, unsigned int* pMaxVelocity, unsigned int* pMaxAcceleration, unsigned int* pErrorCode); - -//StepDirection Mode -int VCS_ActivateStepDirectionMode(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); -int VCS_SetStepDirectionParameter(void* KeyHandle, unsigned short NodeId, unsigned short ScalingNumerator, unsigned short ScalingDenominator, unsigned char Polarity, unsigned int MaxVelocity, unsigned int MaxAcceleration, unsigned int* pErrorCode); -int VCS_GetStepDirectionParameter(void* KeyHandle, unsigned short NodeId, unsigned short* pScalingNumerator, unsigned short* pScalingDenominator, unsigned char* pPolarity, unsigned int* pMaxVelocity, unsigned int* pMaxAcceleration, unsigned int* pErrorCode); - -//Inputs Outputs -//General -int VCS_GetAllDigitalInputs(void* KeyHandle, unsigned short NodeId, unsigned short* pInputs, unsigned int* pErrorCode); -int VCS_GetAllDigitalOutputs(void* KeyHandle, unsigned short NodeId, unsigned short* pOutputs, unsigned int* pErrorCode); -int VCS_SetAllDigitalOutputs(void* KeyHandle, unsigned short NodeId, unsigned short Outputs, unsigned int* pErrorCode); -int VCS_GetAnalogInput(void* KeyHandle, unsigned short NodeId, unsigned short InputNumber, unsigned short* pAnalogValue, unsigned int* pErrorCode); -int VCS_GetAnalogInputVoltage(void* KeyHandle, unsigned short NodeId, unsigned short InputNumber, long* pVoltageValue, unsigned int* pErrorCode); -int VCS_GetAnalogInputState(void* KeyHandle, unsigned short NodeId, unsigned short Configuration, long* pStateValue, unsigned int* pErrorCode); -int VCS_SetAnalogOutput(void* KeyHandle, unsigned short NodeId, unsigned short OutputNumber, unsigned short AnalogValue, unsigned int* pErrorCode); -int VCS_SetAnalogOutputVoltage(void* KeyHandle, unsigned short NodeId, unsigned short OutputNumber, long VoltageValue, unsigned int* pErrorCode); -int VCS_SetAnalogOutputState(void* KeyHandle, unsigned short NodeId, unsigned short Configuration, long StateValue, unsigned int* pErrorCode); - -//Position Compare -int VCS_SetPositionCompareParameter(void* KeyHandle, unsigned short NodeId, unsigned char OperationalMode, unsigned char IntervalMode, unsigned char DirectionDependency, unsigned short IntervalWidth, unsigned short IntervalRepetitions, unsigned short PulseWidth, unsigned int* pErrorCode); -int VCS_GetPositionCompareParameter(void* KeyHandle, unsigned short NodeId, unsigned char* pOperationalMode, unsigned char* pIntervalMode, unsigned char* pDirectionDependency, unsigned short* pIntervalWidth, unsigned short* pIntervalRepetitions, unsigned short* pPulseWidth, unsigned int* pErrorCode); -int VCS_ActivatePositionCompare(void* KeyHandle, unsigned short NodeId, unsigned short DigitalOutputNumber, int Polarity, unsigned int* pErrorCode); -int VCS_DeactivatePositionCompare(void* KeyHandle, unsigned short NodeId, unsigned short DigitalOutputNumber, unsigned int* pErrorCode); -int VCS_EnablePositionCompare(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); -int VCS_DisablePositionCompare(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); -int VCS_SetPositionCompareReferencePosition(void* KeyHandle, unsigned short NodeId, long ReferencePosition, unsigned int* pErrorCode); - -//Position Marker -int VCS_SetPositionMarkerParameter(void* KeyHandle, unsigned short NodeId, unsigned char PositionMarkerEdgeType, unsigned char PositionMarkerMode, unsigned int* pErrorCode); -int VCS_GetPositionMarkerParameter(void* KeyHandle, unsigned short NodeId, unsigned char* pPositionMarkerEdgeType, unsigned char* pPositionMarkerMode, unsigned int* pErrorCode); -int VCS_ActivatePositionMarker(void* KeyHandle, unsigned short NodeId, unsigned short DigitalInputNumber, int Polarity, unsigned int* pErrorCode); -int VCS_DeactivatePositionMarker(void* KeyHandle, unsigned short NodeId, unsigned short DigitalInputNumber, unsigned int* pErrorCode); -int VCS_ReadPositionMarkerCounter(void* KeyHandle, unsigned short NodeId, unsigned short* pCount, unsigned int* pErrorCode); -int VCS_ReadPositionMarkerCapturedPosition(void* KeyHandle, unsigned short NodeId, unsigned short CounterIndex, long* pCapturedPosition, unsigned int* pErrorCode); -int VCS_ResetPositionMarkerCounter(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); - -//******************************************************************************************************************* -// DATA RECORDING FUNCTIONS -//******************************************************************************************************************* - -//DataRecorder Setup -int VCS_SetRecorderParameter(void* KeyHandle, unsigned short NodeId, unsigned short SamplingPeriod, unsigned short NbOfPrecedingSamples, unsigned int* pErrorCode); -int VCS_GetRecorderParameter(void* KeyHandle, unsigned short NodeId, unsigned short* pSamplingPeriod, unsigned short* pNbOfPrecedingSamples, unsigned int* pErrorCode); -int VCS_EnableTrigger(void* KeyHandle, unsigned short NodeId, unsigned char TriggerType, unsigned int* pErrorCode); -int VCS_DisableAllTriggers(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); -int VCS_ActivateChannel(void* KeyHandle, unsigned short NodeId, unsigned char ChannelNumber, unsigned short ObjectIndex, unsigned char ObjectSubIndex, unsigned char ObjectSize, unsigned int* pErrorCode); -int VCS_DeactivateAllChannels(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); - -//DataRecorder Status -int VCS_StartRecorder(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); -int VCS_StopRecorder(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); -int VCS_ForceTrigger(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); -int VCS_IsRecorderRunning(void* KeyHandle, unsigned short NodeId, int* pRunning, unsigned int* pErrorCode); -int VCS_IsRecorderTriggered(void* KeyHandle, unsigned short NodeId, int* pTriggered, unsigned int* pErrorCode); - -//DataRecorder Data -int VCS_ReadChannelVectorSize(void* KeyHandle, unsigned short NodeId, unsigned int* pVectorSize, unsigned int* pErrorCode); -int VCS_ReadChannelDataVector(void* KeyHandle, unsigned short NodeId, unsigned char ChannelNumber, unsigned char* pDataVectorBuffer, unsigned int VectorBufferSize, unsigned int* pErrorCode); - -//Advanced Functions -int VCS_ReadDataBuffer(void* KeyHandle, unsigned short NodeId, unsigned char* pDataBuffer, unsigned int BufferSizeToRead, unsigned int* pBufferSizeRead, unsigned short* pVectorStartOffset, unsigned short* pMaxNbOfSamples, unsigned short* pNbOfRecordedSamples, unsigned int* pErrorCode); -int VCS_ExtractChannelDataVector(void* KeyHandle, unsigned short NodeId, unsigned char ChannelNumber, unsigned char* pDataBuffer, unsigned int BufferSize, unsigned char* pDataVector, unsigned int VectorSize, unsigned short VectorStartOffset, unsigned short MaxNbOfSamples, unsigned short NbOfRecordedSamples, unsigned int* pErrorCode); - -/************************************************************************************************************************************* -* LOW LAYER FUNCTIONS -*************************************************************************************************************************************/ - -//CanLayer Functions -int VCS_SendCANFrame(void* KeyHandle, unsigned short CobID, unsigned short Length, void* pData, unsigned int* pErrorCode); -int VCS_ReadCANFrame(void* KeyHandle, unsigned short CobID, unsigned short Length, void* pData, unsigned int Timeout, unsigned int* pErrorCode); -int VCS_RequestCANFrame(void* KeyHandle, unsigned short CobID, unsigned short Length, void* pData, unsigned int* pErrorCode); -int VCS_SendNMTService(void* KeyHandle, unsigned short NodeId, unsigned short CommandSpecifier, unsigned int* pErrorCode); - -/************************************************************************************************************************************* -* TYPE DEFINITIONS -*************************************************************************************************************************************/ -//Communication -//Dialog Mode -const int DM_PROGRESS_DLG = 0; -const int DM_PROGRESS_AND_CONFIRM_DLG = 1; -const int DM_CONFIRM_DLG = 2; -const int DM_NO_DLG = 3; - -//Configuration -//MotorType -const unsigned short MT_DC_MOTOR = 1; -const unsigned short MT_EC_SINUS_COMMUTATED_MOTOR = 10; -const unsigned short MT_EC_BLOCK_COMMUTATED_MOTOR = 11; - -//SensorType -const unsigned short ST_UNKNOWN = 0; -const unsigned short ST_INC_ENCODER_3CHANNEL = 1; -const unsigned short ST_INC_ENCODER_2CHANNEL = 2; -const unsigned short ST_HALL_SENSORS = 3; -const unsigned short ST_SSI_ABS_ENCODER_BINARY = 4; -const unsigned short ST_SSI_ABS_ENCODER_GREY = 5; -const unsigned short ST_INC_ENCODER2_3CHANNEL = 6; -const unsigned short ST_INC_ENCODER2_2CHANNEL = 7; -const unsigned short ST_ANALOG_INC_ENCODER_3CHANNEL = 8; -const unsigned short ST_ANALOG_INC_ENCODER_2CHANNEL = 9; - -//In- and outputs -//Digital input configuration -const unsigned short DIC_NEGATIVE_LIMIT_SWITCH = 0; -const unsigned short DIC_POSITIVE_LIMIT_SWITCH = 1; -const unsigned short DIC_HOME_SWITCH = 2; -const unsigned short DIC_POSITION_MARKER = 3; -const unsigned short DIC_DRIVE_ENABLE = 4; -const unsigned short DIC_QUICK_STOP = 5; -const unsigned short DIC_GENERAL_PURPOSE_J = 6; -const unsigned short DIC_GENERAL_PURPOSE_I = 7; -const unsigned short DIC_GENERAL_PURPOSE_H = 8; -const unsigned short DIC_GENERAL_PURPOSE_G = 9; -const unsigned short DIC_GENERAL_PURPOSE_F = 10; -const unsigned short DIC_GENERAL_PURPOSE_E = 11; -const unsigned short DIC_GENERAL_PURPOSE_D = 12; -const unsigned short DIC_GENERAL_PURPOSE_C = 13; -const unsigned short DIC_GENERAL_PURPOSE_B = 14; -const unsigned short DIC_GENERAL_PURPOSE_A = 15; - -//Digital output configuration -const unsigned short DOC_READY_FAULT = 0; -const unsigned short DOC_POSITION_COMPARE = 1; -const unsigned short DOC_GENERAL_PURPOSE_H = 8; -const unsigned short DOC_GENERAL_PURPOSE_G = 9; -const unsigned short DOC_GENERAL_PURPOSE_F = 10; -const unsigned short DOC_GENERAL_PURPOSE_E = 11; -const unsigned short DOC_GENERAL_PURPOSE_D = 12; -const unsigned short DOC_GENERAL_PURPOSE_C = 13; -const unsigned short DOC_GENERAL_PURPOSE_B = 14; -const unsigned short DOC_GENERAL_PURPOSE_A = 15; - -//Analog input configuration -const unsigned short AIC_ANALOG_CURRENT_SETPOINT = 0; -const unsigned short AIC_ANALOG_VELOCITY_SETPOINT = 1; -const unsigned short AIC_ANALOG_POSITION_SETPOINT = 2; -const unsigned short AIC_GENERAL_PURPOSE_H = 8; -const unsigned short AIC_GENERAL_PURPOSE_G = 9; -const unsigned short AIC_GENERAL_PURPOSE_F = 10; -const unsigned short AIC_GENERAL_PURPOSE_E = 11; -const unsigned short AIC_GENERAL_PURPOSE_D = 12; -const unsigned short AIC_GENERAL_PURPOSE_C = 13; -const unsigned short AIC_GENERAL_PURPOSE_B = 14; -const unsigned short AIC_GENERAL_PURPOSE_A = 15; - -//Analog output configuration -const unsigned short AOC_GENERAL_PURPOSE_A = 0; -const unsigned short AOC_GENERAL_PURPOSE_B = 1; - -//Units -//VelocityDimension -const unsigned char VD_RPM = 0xA4; - -//VelocityNotation -const signed char VN_STANDARD = 0; -const signed char VN_DECI = -1; -const signed char VN_CENTI = -2; -const signed char VN_MILLI = -3; - -//Operational mode -const signed char OMD_PROFILE_POSITION_MODE = 1; -const signed char OMD_PROFILE_VELOCITY_MODE = 3; -const signed char OMD_HOMING_MODE = 6; -const signed char OMD_INTERPOLATED_POSITION_MODE = 7; -const signed char OMD_POSITION_MODE = -1; -const signed char OMD_VELOCITY_MODE = -2; -const signed char OMD_CURRENT_MODE = -3; -const signed char OMD_MASTER_ENCODER_MODE = -5; -const signed char OMD_STEP_DIRECTION_MODE = -6; - -//States -const unsigned short ST_DISABLED = 0; -const unsigned short ST_ENABLED = 1; -const unsigned short ST_QUICKSTOP = 2; -const unsigned short ST_FAULT = 3; - -//Homing mode -//Homing method -const char HM_ACTUAL_POSITION = 35; -const char HM_NEGATIVE_LIMIT_SWITCH = 17; -const char HM_NEGATIVE_LIMIT_SWITCH_AND_INDEX = 1; -const char HM_POSITIVE_LIMIT_SWITCH = 18; -const char HM_POSITIVE_LIMIT_SWITCH_AND_INDEX = 2; -const char HM_HOME_SWITCH_POSITIVE_SPEED = 23; -const char HM_HOME_SWITCH_POSITIVE_SPEED_AND_INDEX = 7; -const char HM_HOME_SWITCH_NEGATIVE_SPEED = 27; -const char HM_HOME_SWITCH_NEGATIVE_SPEED_AND_INDEX = 11; -const char HM_CURRENT_THRESHOLD_POSITIVE_SPEED = -3; -const char HM_CURRENT_THRESHOLD_POSITIVE_SPEED_AND_INDEX = -1; -const char HM_CURRENT_THRESHOLD_NEGATIVE_SPEED = -4; -const char HM_CURRENT_THRESHOLD_NEGATIVE_SPEED_AND_INDEX = -2; -const char HM_INDEX_POSITIVE_SPEED = 34; -const char HM_INDEX_NEGATIVE_SPEED = 33; - -//Input Output PositionMarker -//PositionMarkerEdgeType -const unsigned char PET_BOTH_EDGES = 0; -const unsigned char PET_RISING_EDGE = 1; -const unsigned char PET_FALLING_EDGE = 2; - -//PositionMarkerMode -const unsigned char PM_CONTINUOUS = 0; -const unsigned char PM_SINGLE = 1; -const unsigned char PM_MULTIPLE = 2; - -//Input Output PositionCompare -//PositionCompareOperationalMode -const unsigned char PCO_SINGLE_POSITION_MODE = 0; -const unsigned char PCO_POSITION_SEQUENCE_MODE = 1; - -//PositionCompareIntervalMode -const unsigned char PCI_NEGATIVE_DIR_TO_REFPOS = 0; -const unsigned char PCI_POSITIVE_DIR_TO_REFPOS = 1; -const unsigned char PCI_BOTH_DIR_TO_REFPOS = 2; - -//PositionCompareDirectionDependency -const unsigned char PCD_MOTOR_DIRECTION_NEGATIVE = 0; -const unsigned char PCD_MOTOR_DIRECTION_POSITIVE = 1; -const unsigned char PCD_MOTOR_DIRECTION_BOTH = 2; - -//Data recorder -//Trigger type -const unsigned short DR_MOVEMENT_START_TRIGGER = 1; //bit 1 -const unsigned short DR_ERROR_TRIGGER = 2; //bit 2 -const unsigned short DR_DIGITAL_INPUT_TRIGGER = 4; //bit 3 -const unsigned short DR_MOVEMENT_END_TRIGGER = 8; //bit 4 - -//CanLayer Functions -const unsigned short NCS_START_REMOTE_NODE = 1; -const unsigned short NCS_STOP_REMOTE_NODE = 2; -const unsigned short NCS_ENTER_PRE_OPERATIONAL = 128; -const unsigned short NCS_RESET_NODE = 129; -const unsigned short NCS_RESET_COMMUNICATION = 130; - -// Controller Gains -// EController -const unsigned short EC_PI_CURRENT_CONTROLLER = 1; -const unsigned short EC_PI_VELOCITY_CONTROLLER = 10; -const unsigned short EC_PI_VELOCITY_CONTROLLER_WITH_OBSERVER = 11; -const unsigned short EC_PID_POSITION_CONTROLLER = 20; -const unsigned short EC_DUAL_LOOP_POSITION_CONTROLLER = 21; - -// EGain (EC_PI_CURRENT_CONTROLLER) -const unsigned short EG_PICC_P_GAIN = 1; -const unsigned short EG_PICC_I_GAIN = 2; - -// EGain (EC_PI_VELOCITY_CONTROLLER) -const unsigned short EG_PIVC_P_GAIN = 1; -const unsigned short EG_PIVC_I_GAIN = 2; -const unsigned short EG_PIVC_FEED_FORWARD_VELOCITY_GAIN = 10; -const unsigned short EG_PIVC_FEED_FORWARD_ACCELERATION_GAIN = 11; - -// EGain (EC_PI_VELOCITY_CONTROLLER_WITH_OBSERVER) -const unsigned short EG_PIVCWO_P_GAIN = 1; -const unsigned short EG_PIVCWO_I_GAIN = 2; -const unsigned short EG_PIVCWO_FEED_FORWARD_VELOCITY_GAIN = 10; -const unsigned short EG_PIVCWO_FEED_FORWARD_ACCELERATION_GAIN = 11; -const unsigned short EG_PIVCWO_OBSERVER_THETA_GAIN = 20; -const unsigned short EG_PIVCWO_OBSERVER_OMEGA_GAIN = 21; -const unsigned short EG_PIVCWO_OBSERVER_TAU_GAIN = 22; - -// EGain (EC_PID_POSITION_CONTROLLER) -const unsigned short EG_PIDPC_P_GAIN = 1; -const unsigned short EG_PIDPC_I_GAIN = 2; -const unsigned short EG_PIDPC_D_GAIN = 3; -const unsigned short EG_PIDPC_FEED_FORWARD_VELOCITY_GAIN = 10; -const unsigned short EG_PIDPC_FEED_FORWARD_ACCELERATION_GAIN = 11; - -// EGain (EC_DUAL_LOOP_POSITION_CONTROLLER) -const unsigned short EG_DLPC_AUXILIARY_LOOP_P_GAIN = 1; -const unsigned short EG_DLPC_AUXILIARY_LOOP_I_GAIN = 2; -const unsigned short EG_DLPC_AUXILIARY_LOOP_FEED_FORWARD_VELOCITY_GAIN = 10; -const unsigned short EG_DLPC_AUXILIARY_LOOP_FEED_FORWARD_ACCELERATION_GAIN = 11; -const unsigned short EG_DLPC_AUXILIARY_LOOP_OBSERVER_THETA_GAIN = 20; -const unsigned short EG_DLPC_AUXILIARY_LOOP_OBSERVER_OMEGA_GAIN = 21; -const unsigned short EG_DLPC_AUXILIARY_LOOP_OBSERVER_TAU_GAIN = 22; -const unsigned short EG_DLPC_MAIN_LOOP_P_GAIN_LOW = 101; -const unsigned short EG_DLPC_MAIN_LOOP_P_GAIN_HIGH = 102; -const unsigned short EG_DLPC_MAIN_LOOP_GAIN_SCHEDULING_WEIGHT = 110; -const unsigned short EG_DLPC_MAIN_LOOP_FILTER_COEFFICIENT_A = 120; -const unsigned short EG_DLPC_MAIN_LOOP_FILTER_COEFFICIENT_B = 121; -const unsigned short EG_DLPC_MAIN_LOOP_FILTER_COEFFICIENT_C = 122; -const unsigned short EG_DLPC_MAIN_LOOP_FILTER_COEFFICIENT_D = 123; -const unsigned short EG_DLPC_MAIN_LOOP_FILTER_COEFFICIENT_E = 124; - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/lib/epos2/LICENSE b/lib/epos2/LICENSE new file mode 100644 index 0000000..0994412 --- /dev/null +++ b/lib/epos2/LICENSE @@ -0,0 +1,3 @@ +The EPOS brand of controllers and associated command library is copyright © maxon. All rights reserved. + +No infringement or intent thereof is made by the developers of this software. diff --git a/lib/epos2/connect.c b/lib/epos2/connect.c new file mode 100644 index 0000000..dab2d1f --- /dev/null +++ b/lib/epos2/connect.c @@ -0,0 +1,111 @@ +#include + +#include "epos2.h" +#include "connect.h" +#include "definitions.h" +#include "identify.h" + +static void FailedOpenDevice(uint32_t error_code) { + PrintError(error_code); + printf("Failed to open device with with following characteristics:\n"); +} + +uint32_t InitializeDevice(struct Controller* controller_out, void* node, uint8_t node_id) { + uint32_t error_code = 0; + + node = VCS_OpenDevice(controller_out->Name, + controller_out->Protocol, + controller_out->Interface, + controller_out->Port, + &error_code); + + controller_out->NodeId = node_id; + + if (node == 0 || error_code != 0) { + FailedOpenDevice(error_code); + PrintControllerCharacteristics(controller_out); + } + + CleanEnableDevice(controller_out, node); + + return error_code; +} + +uint32_t InitializeDevices(struct Controller controllers_out[], void* node_1, void* node_2, void* node_3) { + uint32_t error_code = 0; + + node_1 = VCS_OpenDevice(controllers_out[0].Name, + controllers_out[0].Protocol, + controllers_out[0].Interface, + controllers_out[0].Port, + &error_code); + + controllers_out[0].NodeId = 1; + + if (node_1 == 0 || error_code != 0) { + FailedOpenDevice(error_code); + PrintControllerCharacteristics(&controllers_out[0]); + return error_code; + }; + + CleanEnableDevice(&controllers_out[0], node_1); + + node_2 = VCS_OpenSubDevice(node_1, + controllers_out[1].Name, + controllers_out[1].Protocol, + &error_code); + + controllers_out[1].NodeId = 2; + + if (node_2 == 0 || error_code != 0) { + FailedOpenDevice(error_code); + PrintControllerCharacteristics(&controllers_out[1]); + return error_code; + }; + + CleanEnableDevice(&controllers_out[1], node_2); + + node_3 = VCS_OpenSubDevice(node_2, + controllers_out[2].Name, + controllers_out[2].Protocol, + &error_code); + + if (node_3 == 0 || error_code != 0) { + FailedOpenDevice(error_code); + PrintControllerCharacteristics(&controllers_out[2]); + return error_code; + }; + + controllers_out[2].NodeId = 3; + + CleanEnableDevice(&controllers_out[2], node_2); + + return 0; +} // uint32_t InitializeThreeDevices + +uint32_t CleanEnableDevice(struct Controller* controller, void* device_handle) { + if (device_handle == 0) { return 0x2000000B; } + uint32_t error_code = 0; + int ret; + + ret = VCS_ClearFault(device_handle, controller->NodeId, &error_code); + if (ret == 0) { return error_code; } + + ret = VCS_SetEnableState(device_handle, controller->NodeId, &error_code); + controller->State = CTRL_STATE_OPENED; + return error_code; +} + +uint32_t CloseDevice(struct Controller* controller, void* device_handle) { + if (device_handle == 0) { return 0x2000000B; } + uint32_t error_code = 0; + int ret; + + ret = VCS_CloseDevice(device_handle, &error_code); + if (ret == 0) { return error_code; } + + ret = VCS_SetDisableState(device_handle, controller->NodeId, &error_code); + controller->State = CTRL_STATE_CLOSED; + return error_code; +} + diff --git a/lib/epos2/connect.h b/lib/epos2/connect.h new file mode 100644 index 0000000..4c3273a --- /dev/null +++ b/lib/epos2/connect.h @@ -0,0 +1,48 @@ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include "libtestrig_api.h" +#include "controller.h" + +#ifdef __cplusplus +} // extern "C" (headers) +namespace VSCL::Rig { +extern "C" { +#endif // __cplusplus + +uint32_t TESTRIG_API CleanEnableDevice(struct Controller* controller, void* device_handle); + +/* + * @brief Opens communication to the device and sets its state for a clean init. + * + * Refer to Page 162 of the manual under INITIALIZATION, + * which describes several of the methods wrapped here. + */ +uint32_t TESTRIG_API InitializeDevice(struct Controller* controller_out, void* node, uint8_t node_id); + +/* + * @brief Opens communication to the device and sets its state for a clean init. + * This makes a lot of assumptions + * + * Refer to Page 162 of the manual under INITIALIZATION, + * which describes several of the methods wrapped here. + */ +uint32_t TESTRIG_API InitializeDevices(struct Controller controllers_out[], void* node_1, void* node_2, void* node_3); + +/* + * Closes all connections to the controller + * + * Refer to Page 162 of the manual under CLOSING PROCEDURE, + * which describes several of the methods wrapped here. + */ +uint32_t TESTRIG_API CloseDevice(struct Controller* controller, void* device_handle); + +#ifdef __cplusplus +} // extern "C" +} // namespace VSCL::Rig +#endif // __cplusplus diff --git a/lib/epos2/controller.h b/lib/epos2/controller.h new file mode 100644 index 0000000..b1070ba --- /dev/null +++ b/lib/epos2/controller.h @@ -0,0 +1,43 @@ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +#include + +#ifdef __cplusplus +} // extern "C" (headers) +namespace VSCL::Rig { +extern "C" { +#endif // __cplusplus + +enum ControllerState { + CTRL_STATE_CLOSED = 1, + CTRL_STATE_OPENED = 2, +}; + +/* + * @brief A struct representing a controller. + * + * Refer to the parameters passed to VCS_OpenDevice, Page 13 of the Manual. + */ +struct Controller { + // The name of the controller. + char Name[8]; + // The name of the communication protocol. + char Protocol[16]; + // The name of the connection interface. + char Interface[64]; + // The name of the port used in connection. + char Port[8]; + // The node of the controller. + uint8_t NodeId; + // State of the controller. + enum ControllerState State; +}; + +#ifdef __cplusplus +} // extern "C" +} // namespace VSCL::Rig +#endif // __cplusplus diff --git a/lib/epos2/definitions.c b/lib/epos2/definitions.c new file mode 100644 index 0000000..b7e0049 --- /dev/null +++ b/lib/epos2/definitions.c @@ -0,0 +1,215 @@ +// ******************************************************************************************************************* +// maxon motor ag, CH-6072 Sachseln +// ******************************************************************************************************************* +// Copyright © 2003 - 2021, maxon motor ag. +// All rights reserved. +// ******************************************************************************************************************* + +#include "definitions.h" + +const int DM_PROGRESS_DLG = 0; +const int DM_PROGRESS_AND_CONFIRM_DLG = 1; +const int DM_CONFIRM_DLG = 2; +const int DM_NO_DLG = 3; + +//Configuration +//MotorType +const unsigned short MT_DC_MOTOR = 1; +const unsigned short MT_EC_SINUS_COMMUTATED_MOTOR = 10; +const unsigned short MT_EC_BLOCK_COMMUTATED_MOTOR = 11; + +//SensorType +const unsigned short ST_UNKNOWN = 0; +const unsigned short ST_INC_ENCODER_3CHANNEL = 1; +const unsigned short ST_INC_ENCODER_2CHANNEL = 2; +const unsigned short ST_HALL_SENSORS = 3; +const unsigned short ST_SSI_ABS_ENCODER_BINARY = 4; +const unsigned short ST_SSI_ABS_ENCODER_GREY = 5; +const unsigned short ST_INC_ENCODER2_3CHANNEL = 6; +const unsigned short ST_INC_ENCODER2_2CHANNEL = 7; +const unsigned short ST_ANALOG_INC_ENCODER_3CHANNEL = 8; +const unsigned short ST_ANALOG_INC_ENCODER_2CHANNEL = 9; + +//In- and outputs +//Digital input configuration +const unsigned short DIC_NEGATIVE_LIMIT_SWITCH = 0; +const unsigned short DIC_POSITIVE_LIMIT_SWITCH = 1; +const unsigned short DIC_HOME_SWITCH = 2; +const unsigned short DIC_POSITION_MARKER = 3; +const unsigned short DIC_DRIVE_ENABLE = 4; +const unsigned short DIC_QUICK_STOP = 5; +const unsigned short DIC_GENERAL_PURPOSE_J = 6; +const unsigned short DIC_GENERAL_PURPOSE_I = 7; +const unsigned short DIC_GENERAL_PURPOSE_H = 8; +const unsigned short DIC_GENERAL_PURPOSE_G = 9; +const unsigned short DIC_GENERAL_PURPOSE_F = 10; +const unsigned short DIC_GENERAL_PURPOSE_E = 11; +const unsigned short DIC_GENERAL_PURPOSE_D = 12; +const unsigned short DIC_GENERAL_PURPOSE_C = 13; +const unsigned short DIC_GENERAL_PURPOSE_B = 14; +const unsigned short DIC_GENERAL_PURPOSE_A = 15; + +//Digital output configuration +const unsigned short DOC_READY_FAULT = 0; +const unsigned short DOC_POSITION_COMPARE = 1; +const unsigned short DOC_GENERAL_PURPOSE_H = 8; +const unsigned short DOC_GENERAL_PURPOSE_G = 9; +const unsigned short DOC_GENERAL_PURPOSE_F = 10; +const unsigned short DOC_GENERAL_PURPOSE_E = 11; +const unsigned short DOC_GENERAL_PURPOSE_D = 12; +const unsigned short DOC_GENERAL_PURPOSE_C = 13; +const unsigned short DOC_GENERAL_PURPOSE_B = 14; +const unsigned short DOC_GENERAL_PURPOSE_A = 15; + +//Analog input configuration +const unsigned short AIC_ANALOG_CURRENT_SETPOINT = 0; +const unsigned short AIC_ANALOG_VELOCITY_SETPOINT = 1; +const unsigned short AIC_ANALOG_POSITION_SETPOINT = 2; +const unsigned short AIC_GENERAL_PURPOSE_H = 8; +const unsigned short AIC_GENERAL_PURPOSE_G = 9; +const unsigned short AIC_GENERAL_PURPOSE_F = 10; +const unsigned short AIC_GENERAL_PURPOSE_E = 11; +const unsigned short AIC_GENERAL_PURPOSE_D = 12; +const unsigned short AIC_GENERAL_PURPOSE_C = 13; +const unsigned short AIC_GENERAL_PURPOSE_B = 14; +const unsigned short AIC_GENERAL_PURPOSE_A = 15; + +//Analog output configuration +const unsigned short AOC_GENERAL_PURPOSE_A = 0; +const unsigned short AOC_GENERAL_PURPOSE_B = 1; + +//Units +//VelocityDimension +const unsigned char VD_RPM = 0xA4; + +//VelocityNotation +const signed char VN_STANDARD = 0; +const signed char VN_DECI = -1; +const signed char VN_CENTI = -2; +const signed char VN_MILLI = -3; + +//Operational mode +const signed char OMD_PROFILE_POSITION_MODE = 1; +const signed char OMD_PROFILE_VELOCITY_MODE = 3; +const signed char OMD_HOMING_MODE = 6; +const signed char OMD_INTERPOLATED_POSITION_MODE = 7; +const signed char OMD_POSITION_MODE = -1; +const signed char OMD_VELOCITY_MODE = -2; +const signed char OMD_CURRENT_MODE = -3; +const signed char OMD_MASTER_ENCODER_MODE = -5; +const signed char OMD_STEP_DIRECTION_MODE = -6; + +//States +const unsigned short ST_DISABLED = 0; +const unsigned short ST_ENABLED = 1; +const unsigned short ST_QUICKSTOP = 2; +const unsigned short ST_FAULT = 3; + +//Homing mode +//Homing method +const char HM_ACTUAL_POSITION = 35; +const char HM_NEGATIVE_LIMIT_SWITCH = 17; +const char HM_NEGATIVE_LIMIT_SWITCH_AND_INDEX = 1; +const char HM_POSITIVE_LIMIT_SWITCH = 18; +const char HM_POSITIVE_LIMIT_SWITCH_AND_INDEX = 2; +const char HM_HOME_SWITCH_POSITIVE_SPEED = 23; +const char HM_HOME_SWITCH_POSITIVE_SPEED_AND_INDEX = 7; +const char HM_HOME_SWITCH_NEGATIVE_SPEED = 27; +const char HM_HOME_SWITCH_NEGATIVE_SPEED_AND_INDEX = 11; +const char HM_CURRENT_THRESHOLD_POSITIVE_SPEED = -3; +const char HM_CURRENT_THRESHOLD_POSITIVE_SPEED_AND_INDEX = -1; +const char HM_CURRENT_THRESHOLD_NEGATIVE_SPEED = -4; +const char HM_CURRENT_THRESHOLD_NEGATIVE_SPEED_AND_INDEX = -2; +const char HM_INDEX_POSITIVE_SPEED = 34; +const char HM_INDEX_NEGATIVE_SPEED = 33; + +//Input Output PositionMarker +//PositionMarkerEdgeType +const unsigned char PET_BOTH_EDGES = 0; +const unsigned char PET_RISING_EDGE = 1; +const unsigned char PET_FALLING_EDGE = 2; + +//PositionMarkerMode +const unsigned char PM_CONTINUOUS = 0; +const unsigned char PM_SINGLE = 1; +const unsigned char PM_MULTIPLE = 2; + +//Input Output PositionCompare +//PositionCompareOperationalMode +const unsigned char PCO_SINGLE_POSITION_MODE = 0; +const unsigned char PCO_POSITION_SEQUENCE_MODE = 1; + +//PositionCompareIntervalMode +const unsigned char PCI_NEGATIVE_DIR_TO_REFPOS = 0; +const unsigned char PCI_POSITIVE_DIR_TO_REFPOS = 1; +const unsigned char PCI_BOTH_DIR_TO_REFPOS = 2; + +//PositionCompareDirectionDependency +const unsigned char PCD_MOTOR_DIRECTION_NEGATIVE = 0; +const unsigned char PCD_MOTOR_DIRECTION_POSITIVE = 1; +const unsigned char PCD_MOTOR_DIRECTION_BOTH = 2; + +//Data recorder +//Trigger type +const unsigned short DR_MOVEMENT_START_TRIGGER = 1; //bit 1 +const unsigned short DR_ERROR_TRIGGER = 2; //bit 2 +const unsigned short DR_DIGITAL_INPUT_TRIGGER = 4; //bit 3 +const unsigned short DR_MOVEMENT_END_TRIGGER = 8; //bit 4 + +//CanLayer Functions +const unsigned short NCS_START_REMOTE_NODE = 1; +const unsigned short NCS_STOP_REMOTE_NODE = 2; +const unsigned short NCS_ENTER_PRE_OPERATIONAL = 128; +const unsigned short NCS_RESET_NODE = 129; +const unsigned short NCS_RESET_COMMUNICATION = 130; + +// Controller Gains +// EController +const unsigned short EC_PI_CURRENT_CONTROLLER = 1; +const unsigned short EC_PI_VELOCITY_CONTROLLER = 10; +const unsigned short EC_PI_VELOCITY_CONTROLLER_WITH_OBSERVER = 11; +const unsigned short EC_PID_POSITION_CONTROLLER = 20; +const unsigned short EC_DUAL_LOOP_POSITION_CONTROLLER = 21; + +// EGain (EC_PI_CURRENT_CONTROLLER) +const unsigned short EG_PICC_P_GAIN = 1; +const unsigned short EG_PICC_I_GAIN = 2; + +// EGain (EC_PI_VELOCITY_CONTROLLER) +const unsigned short EG_PIVC_P_GAIN = 1; +const unsigned short EG_PIVC_I_GAIN = 2; +const unsigned short EG_PIVC_FEED_FORWARD_VELOCITY_GAIN = 10; +const unsigned short EG_PIVC_FEED_FORWARD_ACCELERATION_GAIN = 11; + +// EGain (EC_PI_VELOCITY_CONTROLLER_WITH_OBSERVER) +const unsigned short EG_PIVCWO_P_GAIN = 1; +const unsigned short EG_PIVCWO_I_GAIN = 2; +const unsigned short EG_PIVCWO_FEED_FORWARD_VELOCITY_GAIN = 10; +const unsigned short EG_PIVCWO_FEED_FORWARD_ACCELERATION_GAIN = 11; +const unsigned short EG_PIVCWO_OBSERVER_THETA_GAIN = 20; +const unsigned short EG_PIVCWO_OBSERVER_OMEGA_GAIN = 21; +const unsigned short EG_PIVCWO_OBSERVER_TAU_GAIN = 22; + +// EGain (EC_PID_POSITION_CONTROLLER) +const unsigned short EG_PIDPC_P_GAIN = 1; +const unsigned short EG_PIDPC_I_GAIN = 2; +const unsigned short EG_PIDPC_D_GAIN = 3; +const unsigned short EG_PIDPC_FEED_FORWARD_VELOCITY_GAIN = 10; +const unsigned short EG_PIDPC_FEED_FORWARD_ACCELERATION_GAIN = 11; + +// EGain (EC_DUAL_LOOP_POSITION_CONTROLLER) +const unsigned short EG_DLPC_AUXILIARY_LOOP_P_GAIN = 1; +const unsigned short EG_DLPC_AUXILIARY_LOOP_I_GAIN = 2; +const unsigned short EG_DLPC_AUXILIARY_LOOP_FEED_FORWARD_VELOCITY_GAIN = 10; +const unsigned short EG_DLPC_AUXILIARY_LOOP_FEED_FORWARD_ACCELERATION_GAIN = 11; +const unsigned short EG_DLPC_AUXILIARY_LOOP_OBSERVER_THETA_GAIN = 20; +const unsigned short EG_DLPC_AUXILIARY_LOOP_OBSERVER_OMEGA_GAIN = 21; +const unsigned short EG_DLPC_AUXILIARY_LOOP_OBSERVER_TAU_GAIN = 22; +const unsigned short EG_DLPC_MAIN_LOOP_P_GAIN_LOW = 101; +const unsigned short EG_DLPC_MAIN_LOOP_P_GAIN_HIGH = 102; +const unsigned short EG_DLPC_MAIN_LOOP_GAIN_SCHEDULING_WEIGHT = 110; +const unsigned short EG_DLPC_MAIN_LOOP_FILTER_COEFFICIENT_A = 120; +const unsigned short EG_DLPC_MAIN_LOOP_FILTER_COEFFICIENT_B = 121; +const unsigned short EG_DLPC_MAIN_LOOP_FILTER_COEFFICIENT_C = 122; +const unsigned short EG_DLPC_MAIN_LOOP_FILTER_COEFFICIENT_D = 123; +const unsigned short EG_DLPC_MAIN_LOOP_FILTER_COEFFICIENT_E = 124; diff --git a/lib/epos2/definitions.h b/lib/epos2/definitions.h new file mode 100644 index 0000000..c302192 --- /dev/null +++ b/lib/epos2/definitions.h @@ -0,0 +1,585 @@ +// ******************************************************************************************************************* +// maxon motor ag, CH-6072 Sachseln +// ******************************************************************************************************************* +// Copyright © 2003 - 2021, maxon motor ag. +// All rights reserved. +// ******************************************************************************************************************* + +#pragma once + +#ifndef EposDllExports +#define EposDllExports +#if defined(_WIN32) && !defined(__GNUC__) + #define Initialisation_DllExport __declspec(dllexport) + #define HelpFunctions_DllExport __declspec(dllexport) + #define Configuration_DllExport __declspec(dllexport) + #define Status_DllExport __declspec(dllexport) + #define StateMachine_DllExport __declspec(dllexport) + #define ErrorHandling_DllExport __declspec(dllexport) + #define MotionInfo_DllExport __declspec(dllexport) + #define ProfilePositionMode_DllExport __declspec(dllexport) + #define ProfileVelocityMode_DllExport __declspec(dllexport) + #define HomingMode_DllExport __declspec(dllexport) + #define InterpolatedPositionMode_DllExport __declspec(dllexport) + #define PositionMode_DllExport __declspec(dllexport) + #define VelocityMode_DllExport __declspec(dllexport) + #define CurrentMode_DllExport __declspec(dllexport) + #define MasterEncoderMode_DllExport __declspec(dllexport) + #define StepDirectionMode_DllExport __declspec(dllexport) + #define InputsOutputs_DllExport __declspec(dllexport) + #define DataRecording_DllExport __declspec(dllexport) + #define CanLayer_DllExport __declspec(dllexport) +#else + #define Initialisation_DllExport + #define HelpFunctions_DllExport + #define Configuration_DllExport + #define Status_DllExport + #define StateMachine_DllExport + #define ErrorHandling_DllExport + #define MotionInfo_DllExport + #define ProfilePositionMode_DllExport + #define ProfileVelocityMode_DllExport + #define HomingMode_DllExport + #define InterpolatedPositionMode_DllExport + #define PositionMode_DllExport + #define VelocityMode_DllExport + #define CurrentMode_DllExport + #define MasterEncoderMode_DllExport + #define StepDirectionMode_DllExport + #define InputsOutputs_DllExport + #define DataRecording_DllExport + #define CanLayer_DllExport +#endif // _WIN32 +#endif // EposDllExports + +#ifdef __cplusplus +extern "C" { +#endif + +////Communication +//int CreateCommunication(); +//int DeleteCommunication(); +// +//// Data Recorder +//int CreateDataRecorderCmdManager(void* KeyHandle); +//int DeleteDataRecorderCmdManager(); + +/************************************************************************************************************************************* +* INITIALISATION FUNCTIONS +*************************************************************************************************************************************/ + +//Communication +Initialisation_DllExport void* VCS_OpenDevice(char* DeviceName, char* ProtocolStackName, char* InterfaceName, char* PortName, unsigned int* pErrorCode); +Initialisation_DllExport int VCS_SetProtocolStackSettings(void* KeyHandle, unsigned int Baudrate, unsigned int Timeout, unsigned int* pErrorCode); +Initialisation_DllExport int VCS_GetProtocolStackSettings(void* KeyHandle, unsigned int* pBaudrate, unsigned int* pTimeout, unsigned int* pErrorCode); +Initialisation_DllExport int VCS_CloseDevice(void* KeyHandle, unsigned int* pErrorCode); +Initialisation_DllExport int VCS_CloseAllDevices(unsigned int* pErrorCode); + +//Gateway +Initialisation_DllExport int VCS_SetGatewaySettings(void* KeyHandle, unsigned int Baudrate, unsigned int* pErrorCode); +Initialisation_DllExport int VCS_GetGatewaySettings(void* KeyHandle, unsigned int* pBaudrate, unsigned int* pErrorCode); + +//Sub device +Initialisation_DllExport void* VCS_OpenSubDevice(void* DeviceHandle, char* DeviceName, char* ProtocolStackName, unsigned int* pErrorCode); +Initialisation_DllExport int VCS_CloseSubDevice(void* KeyHandle, unsigned int* pErrorCode); +Initialisation_DllExport int VCS_CloseAllSubDevices(void* DeviceHandle, unsigned int* pErrorCode); + +//Info +HelpFunctions_DllExport int VCS_GetDriverInfo(char* p_pszLibraryName, unsigned short p_usMaxLibraryNameStrSize,char* p_pszLibraryVersion, unsigned short p_usMaxLibraryVersionStrSize, unsigned int* p_pErrorCode); +HelpFunctions_DllExport int VCS_GetVersion(void* KeyHandle, unsigned short NodeId, unsigned short* pHardwareVersion, unsigned short* pSoftwareVersion, unsigned short* pApplicationNumber, unsigned short* pApplicationVersion, unsigned int* pErrorCode); +HelpFunctions_DllExport int VCS_GetErrorInfo(unsigned int ErrorCodeValue, char* pErrorInfo, unsigned short MaxStrSize); + +//Advanced Functions +HelpFunctions_DllExport int VCS_GetDeviceNameSelection(int StartOfSelection, char* pDeviceNameSel, unsigned short MaxStrSize, int* pEndOfSelection, unsigned int* pErrorCode); +HelpFunctions_DllExport int VCS_GetProtocolStackNameSelection(char* DeviceName, int StartOfSelection, char* pProtocolStackNameSel, unsigned short MaxStrSize, int* pEndOfSelection, unsigned int* pErrorCode); +HelpFunctions_DllExport int VCS_GetInterfaceNameSelection(char* DeviceName, char* ProtocolStackName, int StartOfSelection, char* pInterfaceNameSel, unsigned short MaxStrSize, int* pEndOfSelection, unsigned int* pErrorCode); +HelpFunctions_DllExport int VCS_GetPortNameSelection(char* DeviceName, char* ProtocolStackName, char* InterfaceName, int StartOfSelection, char* pPortSel, unsigned short MaxStrSize, int* pEndOfSelection, unsigned int* pErrorCode); +HelpFunctions_DllExport int VCS_ResetPortNameSelection(char* DeviceName, char* ProtocolStackName, char* InterfaceName, unsigned int* pErrorCode); +HelpFunctions_DllExport int VCS_GetBaudrateSelection(char* DeviceName, char* ProtocolStackName, char* InterfaceName, char* PortName, int StartOfSelection, unsigned int* pBaudrateSel, int* pEndOfSelection, unsigned int* pErrorCode); +HelpFunctions_DllExport int VCS_GetKeyHandle(char* DeviceName, char* ProtocolStackName, char* InterfaceName, char* PortName, void** pKeyHandle, unsigned int* pErrorCode); +HelpFunctions_DllExport int VCS_GetDeviceName(void* KeyHandle, char* pDeviceName, unsigned short MaxStrSize, unsigned int* pErrorCode); +HelpFunctions_DllExport int VCS_GetProtocolStackName(void* KeyHandle, char* pProtocolStackName, unsigned short MaxStrSize, unsigned int* pErrorCode); +HelpFunctions_DllExport int VCS_GetInterfaceName(void* KeyHandle, char* pInterfaceName, unsigned short MaxStrSize, unsigned int* pErrorCode); +HelpFunctions_DllExport int VCS_GetPortName(void* KeyHandle, char* pPortName, unsigned short MaxStrSize, unsigned int* pErrorCode); + +/************************************************************************************************************************************* +* CONFIGURATION FUNCTIONS +*************************************************************************************************************************************/ + +//General +Configuration_DllExport int VCS_SetObject(void* KeyHandle, unsigned short NodeId, unsigned short ObjectIndex, unsigned char ObjectSubIndex, void* pData, unsigned int NbOfBytesToWrite, unsigned int* pNbOfBytesWritten, unsigned int* pErrorCode); +Configuration_DllExport int VCS_GetObject(void* KeyHandle, unsigned short NodeId, unsigned short ObjectIndex, unsigned char ObjectSubIndex, void* pData, unsigned int NbOfBytesToRead, unsigned int* pNbOfBytesRead, unsigned int* pErrorCode); +Configuration_DllExport int VCS_Restore(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); +Configuration_DllExport int VCS_Store(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); + +//Advanced Functions +//Motor +Configuration_DllExport int VCS_SetMotorType(void* KeyHandle, unsigned short NodeId, unsigned short MotorType, unsigned int* pErrorCode); +Configuration_DllExport int VCS_SetDcMotorParameter(void* KeyHandle, unsigned short NodeId, unsigned short NominalCurrent, unsigned short MaxOutputCurrent, unsigned short ThermalTimeConstant, unsigned int* pErrorCode); +Configuration_DllExport int VCS_SetDcMotorParameterEx(void* KeyHandle, unsigned short NodeId, unsigned int NominalCurrent, unsigned int MaxOutputCurrent, unsigned short ThermalTimeConstant, unsigned int* pErrorCode); +Configuration_DllExport int VCS_SetEcMotorParameter(void* KeyHandle, unsigned short NodeId, unsigned short NominalCurrent, unsigned short MaxOutputCurrent, unsigned short ThermalTimeConstant, unsigned char NbOfPolePairs, unsigned int* pErrorCode); +Configuration_DllExport int VCS_SetEcMotorParameterEx(void* KeyHandle, unsigned short NodeId, unsigned int NominalCurrent, unsigned int MaxOutputCurrent, unsigned short ThermalTimeConstant, unsigned char NbOfPolePairs, unsigned int* pErrorCode); +Configuration_DllExport int VCS_GetMotorType(void* KeyHandle, unsigned short NodeId, unsigned short* pMotorType, unsigned int* pErrorCode); +Configuration_DllExport int VCS_GetDcMotorParameter(void* KeyHandle, unsigned short NodeId, unsigned short* pNominalCurrent, unsigned short* pMaxOutputCurrent, unsigned short* pThermalTimeConstant, unsigned int* pErrorCode); +Configuration_DllExport int VCS_GetDcMotorParameterEx(void* KeyHandle, unsigned short NodeId, unsigned int* pNominalCurrent, unsigned int* pMaxOutputCurrent, unsigned short* pThermalTimeConstant, unsigned int* pErrorCode); +Configuration_DllExport int VCS_GetEcMotorParameter(void* KeyHandle, unsigned short NodeId, unsigned short* pNominalCurrent, unsigned short* pMaxOutputCurrent, unsigned short* pThermalTimeConstant, unsigned char* pNbOfPolePairs, unsigned int* pErrorCode); +Configuration_DllExport int VCS_GetEcMotorParameterEx(void* KeyHandle, unsigned short NodeId, unsigned int* pNominalCurrent, unsigned int* pMaxOutputCurrent, unsigned short* pThermalTimeConstant, unsigned char* pNbOfPolePairs, unsigned int* pErrorCode); + +//Sensor +Configuration_DllExport int VCS_SetSensorType(void* KeyHandle, unsigned short NodeId, unsigned short SensorType, unsigned int* pErrorCode); +Configuration_DllExport int VCS_SetIncEncoderParameter(void* KeyHandle, unsigned short NodeId, unsigned int EncoderResolution, int InvertedPolarity, unsigned int* pErrorCode); +Configuration_DllExport int VCS_SetHallSensorParameter(void* KeyHandle, unsigned short NodeId, int InvertedPolarity, unsigned int* pErrorCode); +Configuration_DllExport int VCS_SetSsiAbsEncoderParameter(void* KeyHandle, unsigned short NodeId, unsigned short DataRate, unsigned short NbOfMultiTurnDataBits, unsigned short NbOfSingleTurnDataBits, int InvertedPolarity, unsigned int* pErrorCode); +Configuration_DllExport int VCS_SetSsiAbsEncoderParameterEx(void* KeyHandle, unsigned short NodeId, unsigned short DataRate, unsigned short NbOfMultiTurnDataBits, unsigned short NbOfSingleTurnDataBits, unsigned short NbOfSpecialDataBits, int InvertedPolarity, unsigned short Timeout, unsigned short PowerupTime, unsigned int* pErrorCode); +Configuration_DllExport int VCS_SetSsiAbsEncoderParameterEx2(void* KeyHandle, unsigned short NodeId, unsigned short DataRate, unsigned short NbOfSpecialDataBitsLeading, unsigned short NbOfMultiTurnDataBits, unsigned short NbOfMultiTurnPositionBits, unsigned short NbOfSingleTurnDataBits, unsigned short NbOfSingleTurnPositionBits, unsigned short NbOfSpecialDataBitsTrailing, int InvertedPolarity, unsigned short Timeout, unsigned short PowerupTime, int CheckFrame, int ReferenceReset, unsigned int* pErrorCode); +Configuration_DllExport int VCS_GetSensorType(void* KeyHandle, unsigned short NodeId, unsigned short* pSensorType, unsigned int* pErrorCode); +Configuration_DllExport int VCS_GetIncEncoderParameter(void* KeyHandle, unsigned short NodeId, unsigned int* pEncoderResolution, int* pInvertedPolarity, unsigned int* pErrorCode); +Configuration_DllExport int VCS_GetHallSensorParameter(void* KeyHandle, unsigned short NodeId, int* pInvertedPolarity, unsigned int* pErrorCode); +Configuration_DllExport int VCS_GetSsiAbsEncoderParameter(void* KeyHandle, unsigned short NodeId, unsigned short* pDataRate, unsigned short* pNbOfMultiTurnDataBits, unsigned short* pNbOfSingleTurnDataBits, int* pInvertedPolarity, unsigned int* pErrorCode); +Configuration_DllExport int VCS_GetSsiAbsEncoderParameterEx(void* KeyHandle, unsigned short NodeId, unsigned short* pDataRate, unsigned short* pNbOfMultiTurnDataBits, unsigned short* pNbOfSingleTurnDataBits, unsigned short* pNbOfSpecialDataBits, int* pInvertedPolarity, unsigned short* pTimeout, unsigned short* pPowerupTime, unsigned int* pErrorCode); +Configuration_DllExport int VCS_GetSsiAbsEncoderParameterEx2(void* KeyHandle, unsigned short NodeId, unsigned short* pDataRate, unsigned short* pNbOfSpecialDataBitsLeading, unsigned short* pNbOfMultiTurnDataBits, unsigned short* pNbOfMultiTurnPositionBits, unsigned short* pNbOfSingleTurnDataBits, unsigned short* pNbOfSingleTurnPositionBits, unsigned short* pNbOfSpecialDataBitsTrailing, int* pInvertedPolarity, unsigned short* pTimeout, unsigned short* pPowerupTime, int* pCheckFrame, int* pReferenceReset, unsigned int* pErrorCode); + +//Safety +Configuration_DllExport int VCS_SetMaxFollowingError(void* KeyHandle, unsigned short NodeId, unsigned int MaxFollowingError, unsigned int* pErrorCode); +Configuration_DllExport int VCS_GetMaxFollowingError(void* KeyHandle, unsigned short NodeId, unsigned int* pMaxFollowingError, unsigned int* pErrorCode); +Configuration_DllExport int VCS_SetMaxProfileVelocity(void* KeyHandle, unsigned short NodeId, unsigned int MaxProfileVelocity, unsigned int* pErrorCode); +Configuration_DllExport int VCS_GetMaxProfileVelocity(void* KeyHandle, unsigned short NodeId, unsigned int* pMaxProfileVelocity, unsigned int* pErrorCode); +Configuration_DllExport int VCS_SetMaxAcceleration(void* KeyHandle, unsigned short NodeId, unsigned int MaxAcceleration, unsigned int* pErrorCode); +Configuration_DllExport int VCS_GetMaxAcceleration(void* KeyHandle, unsigned short NodeId, unsigned int* pMaxAcceleration, unsigned int* pErrorCode); + +//Controller Gains +Configuration_DllExport int VCS_SetControllerGain(void* KeyHandle, unsigned short NodeId, unsigned short EController, unsigned short EGain, unsigned long long Value, unsigned int* pErrorCode); +Configuration_DllExport int VCS_GetControllerGain(void* KeyHandle, unsigned short NodeId, unsigned short EController, unsigned short EGain, unsigned long long* pValue, unsigned int* pErrorCode); + +//Inputs/Outputs +Configuration_DllExport int VCS_DigitalInputConfiguration(void* KeyHandle, unsigned short NodeId, unsigned short DigitalInputNb, unsigned short Configuration, int Mask, int Polarity, int ExecutionMask, unsigned int* pErrorCode); +Configuration_DllExport int VCS_DigitalOutputConfiguration(void* KeyHandle, unsigned short NodeId, unsigned short DigitalOutputNb, unsigned short Configuration, int State, int Mask, int Polarity, unsigned int* pErrorCode); +Configuration_DllExport int VCS_AnalogInputConfiguration(void* KeyHandle, unsigned short NodeId, unsigned short AnalogInputNb, unsigned short Configuration, int ExecutionMask, unsigned int* pErrorCode); +Configuration_DllExport int VCS_AnalogOutputConfiguration(void* KeyHandle, unsigned short NodeId, unsigned short AnalogOutputNb, unsigned short Configuration, unsigned int* pErrorCode); + +//Units +Configuration_DllExport int VCS_SetVelocityUnits(void* KeyHandle, unsigned short NodeId, unsigned char VelDimension, signed char VelNotation, unsigned int* pErrorCode); +Configuration_DllExport int VCS_GetVelocityUnits(void* KeyHandle, unsigned short NodeId, unsigned char* pVelDimension, char* pVelNotation, unsigned int* pErrorCode); + +//Compatibility Functions (do not use) +Configuration_DllExport int VCS_SetPositionRegulatorGain(void* KeyHandle, unsigned short NodeId, unsigned short P, unsigned short I, unsigned short D, unsigned int* pErrorCode); +Configuration_DllExport int VCS_SetPositionRegulatorFeedForward(void* KeyHandle, unsigned short NodeId, unsigned short VelocityFeedForward, unsigned short AccelerationFeedForward, unsigned int* pErrorCode); +Configuration_DllExport int VCS_GetPositionRegulatorGain(void* KeyHandle, unsigned short NodeId, unsigned short* pP, unsigned short* pI, unsigned short* pD, unsigned int* pErrorCode); +Configuration_DllExport int VCS_GetPositionRegulatorFeedForward(void* KeyHandle, unsigned short NodeId, unsigned short* pVelocityFeedForward, unsigned short* pAccelerationFeedForward, unsigned int* pErrorCode); + +Configuration_DllExport int VCS_SetVelocityRegulatorGain(void* KeyHandle, unsigned short NodeId, unsigned short P, unsigned short I, unsigned int* pErrorCode); +Configuration_DllExport int VCS_SetVelocityRegulatorFeedForward(void* KeyHandle, unsigned short NodeId, unsigned short VelocityFeedForward, unsigned short AccelerationFeedForward, unsigned int* pErrorCode); +Configuration_DllExport int VCS_GetVelocityRegulatorGain(void* KeyHandle, unsigned short NodeId, unsigned short* pP, unsigned short* pI, unsigned int* pErrorCode); +Configuration_DllExport int VCS_GetVelocityRegulatorFeedForward(void* KeyHandle, unsigned short NodeId, unsigned short* pVelocityFeedForward, unsigned short* pAccelerationFeedForward, unsigned int* pErrorCode); + +Configuration_DllExport int VCS_SetCurrentRegulatorGain(void* KeyHandle, unsigned short NodeId, unsigned short P, unsigned short I, unsigned int* pErrorCode); +Configuration_DllExport int VCS_GetCurrentRegulatorGain(void* KeyHandle, unsigned short NodeId, unsigned short* pP, unsigned short* pI, unsigned int* pErrorCode); + +/************************************************************************************************************************************* +* OPERATION FUNCTIONS +*************************************************************************************************************************************/ + +//OperationMode +Status_DllExport int VCS_SetOperationMode(void* KeyHandle, unsigned short NodeId, char OperationMode, unsigned int* pErrorCode); +Status_DllExport int VCS_GetOperationMode(void* KeyHandle, unsigned short NodeId, char* pOperationMode, unsigned int* pErrorCode); + +//StateMachine +StateMachine_DllExport int VCS_ResetDevice(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); +StateMachine_DllExport int VCS_SetState(void* KeyHandle, unsigned short NodeId, unsigned short State, unsigned int* pErrorCode); +StateMachine_DllExport int VCS_SetEnableState(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); +StateMachine_DllExport int VCS_SetDisableState(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); +StateMachine_DllExport int VCS_SetQuickStopState(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); +StateMachine_DllExport int VCS_ClearFault(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); +StateMachine_DllExport int VCS_GetState(void* KeyHandle, unsigned short NodeId, unsigned short* pState, unsigned int* pErrorCode); +StateMachine_DllExport int VCS_GetEnableState(void* KeyHandle, unsigned short NodeId, int* pIsEnabled, unsigned int* pErrorCode); +StateMachine_DllExport int VCS_GetDisableState(void* KeyHandle, unsigned short NodeId, int* pIsDisabled, unsigned int* pErrorCode); +StateMachine_DllExport int VCS_GetQuickStopState(void* KeyHandle, unsigned short NodeId, int* pIsQuickStopped, unsigned int* pErrorCode); +StateMachine_DllExport int VCS_GetFaultState(void* KeyHandle, unsigned short NodeId, int* pIsInFault, unsigned int* pErrorCode); + +//ErrorHandling +ErrorHandling_DllExport int VCS_GetNbOfDeviceError(void* KeyHandle, unsigned short NodeId, unsigned char *pNbDeviceError, unsigned int *pErrorCode); +ErrorHandling_DllExport int VCS_GetDeviceErrorCode(void* KeyHandle, unsigned short NodeId, unsigned char DeviceErrorNumber, unsigned int *pDeviceErrorCode, unsigned int *pErrorCode); + +//Motion Info +MotionInfo_DllExport int VCS_GetMovementState(void* KeyHandle, unsigned short NodeId, int* pTargetReached, unsigned int* pErrorCode); +MotionInfo_DllExport int VCS_GetPositionIs(void* KeyHandle, unsigned short NodeId, int* pPositionIs, unsigned int* pErrorCode); +MotionInfo_DllExport int VCS_GetVelocityIs(void* KeyHandle, unsigned short NodeId, int* pVelocityIs, unsigned int* pErrorCode); +MotionInfo_DllExport int VCS_GetVelocityIsAveraged(void* KeyHandle, unsigned short NodeId, int* pVelocityIsAveraged, unsigned int* pErrorCode); +MotionInfo_DllExport int VCS_GetCurrentIs(void* KeyHandle, unsigned short NodeId, short* pCurrentIs, unsigned int* pErrorCode); +MotionInfo_DllExport int VCS_GetCurrentIsEx(void* KeyHandle, unsigned short NodeId, int* pCurrentIs, unsigned int* pErrorCode); +MotionInfo_DllExport int VCS_GetCurrentIsAveraged(void* KeyHandle, unsigned short NodeId, short* pCurrentIsAveraged, unsigned int* pErrorCode); +MotionInfo_DllExport int VCS_GetCurrentIsAveragedEx(void* KeyHandle, unsigned short NodeId, int* pCurrentIsAveraged, unsigned int* pErrorCode); +MotionInfo_DllExport int VCS_WaitForTargetReached(void* KeyHandle, unsigned short NodeId, unsigned int Timeout, unsigned int* pErrorCode); + +//Profile Position Mode +ProfilePositionMode_DllExport int VCS_ActivateProfilePositionMode(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); +ProfilePositionMode_DllExport int VCS_SetPositionProfile(void* KeyHandle, unsigned short NodeId, unsigned int ProfileVelocity, unsigned int ProfileAcceleration, unsigned int ProfileDeceleration, unsigned int* pErrorCode); +ProfilePositionMode_DllExport int VCS_GetPositionProfile(void* KeyHandle, unsigned short NodeId, unsigned int* pProfileVelocity, unsigned int* pProfileAcceleration, unsigned int* pProfileDeceleration, unsigned int* pErrorCode); +ProfilePositionMode_DllExport int VCS_MoveToPosition(void* KeyHandle, unsigned short NodeId, long TargetPosition, int Absolute, int Immediately, unsigned int* pErrorCode); +ProfilePositionMode_DllExport int VCS_GetTargetPosition(void* KeyHandle, unsigned short NodeId, long* pTargetPosition, unsigned int* pErrorCode); +ProfilePositionMode_DllExport int VCS_HaltPositionMovement(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); + +//Advanced Functions +ProfilePositionMode_DllExport int VCS_EnablePositionWindow(void* KeyHandle, unsigned short NodeId, unsigned int PositionWindow, unsigned short PositionWindowTime, unsigned int* pErrorCode); +ProfilePositionMode_DllExport int VCS_DisablePositionWindow(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); + +//Profile Velocity Mode +ProfileVelocityMode_DllExport int VCS_ActivateProfileVelocityMode(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); +ProfileVelocityMode_DllExport int VCS_SetVelocityProfile(void* KeyHandle, unsigned short NodeId, unsigned int ProfileAcceleration, unsigned int ProfileDeceleration, unsigned int* pErrorCode); +ProfileVelocityMode_DllExport int VCS_GetVelocityProfile(void* KeyHandle, unsigned short NodeId, unsigned int* pProfileAcceleration, unsigned int* pProfileDeceleration, unsigned int* pErrorCode); +ProfileVelocityMode_DllExport int VCS_MoveWithVelocity(void* KeyHandle, unsigned short NodeId, long TargetVelocity, unsigned int* pErrorCode); +ProfileVelocityMode_DllExport int VCS_GetTargetVelocity(void* KeyHandle, unsigned short NodeId, long* pTargetVelocity, unsigned int* pErrorCode); +ProfileVelocityMode_DllExport int VCS_HaltVelocityMovement(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); + +//Advanced Functions +ProfileVelocityMode_DllExport int VCS_EnableVelocityWindow(void* KeyHandle, unsigned short NodeId, unsigned int VelocityWindow, unsigned short VelocityWindowTime, unsigned int* pErrorCode); +ProfileVelocityMode_DllExport int VCS_DisableVelocityWindow(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); + +//Homing Mode +HomingMode_DllExport int VCS_ActivateHomingMode(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); +HomingMode_DllExport int VCS_SetHomingParameter(void* KeyHandle, unsigned short NodeId, unsigned int HomingAcceleration, unsigned int SpeedSwitch, unsigned int SpeedIndex, int HomeOffset, unsigned short CurrentThreshold, int HomePosition, unsigned int* pErrorCode); +HomingMode_DllExport int VCS_GetHomingParameter(void* KeyHandle, unsigned short NodeId, unsigned int* pHomingAcceleration, unsigned int* pSpeedSwitch, unsigned int* pSpeedIndex, int* pHomeOffset, unsigned short* pCurrentThreshold, int* pHomePosition, unsigned int* pErrorCode); +HomingMode_DllExport int VCS_FindHome(void* KeyHandle, unsigned short NodeId, signed char HomingMethod, unsigned int* pErrorCode); +HomingMode_DllExport int VCS_StopHoming(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); +HomingMode_DllExport int VCS_DefinePosition(void* KeyHandle, unsigned short NodeId, int HomePosition, unsigned int* pErrorCode); +HomingMode_DllExport int VCS_WaitForHomingAttained(void* KeyHandle, unsigned short NodeId, int Timeout, unsigned int* pErrorCode); +HomingMode_DllExport int VCS_GetHomingState(void* KeyHandle, unsigned short NodeId, int* pHomingAttained, int* pHomingError, unsigned int* pErrorCode); + +//Interpolated Position Mode +InterpolatedPositionMode_DllExport int VCS_ActivateInterpolatedPositionMode(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); +InterpolatedPositionMode_DllExport int VCS_SetIpmBufferParameter(void* KeyHandle, unsigned short NodeId, unsigned short UnderflowWarningLimit, unsigned short OverflowWarningLimit, unsigned int* pErrorCode); +InterpolatedPositionMode_DllExport int VCS_GetIpmBufferParameter(void* KeyHandle, unsigned short NodeId, unsigned short* pUnderflowWarningLimit, unsigned short* pOverflowWarningLimit, unsigned int* pMaxBufferSize, unsigned int* pErrorCode); +InterpolatedPositionMode_DllExport int VCS_ClearIpmBuffer(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); +InterpolatedPositionMode_DllExport int VCS_GetFreeIpmBufferSize(void* KeyHandle, unsigned short NodeId, unsigned int* pBufferSize, unsigned int* pErrorCode); +InterpolatedPositionMode_DllExport int VCS_AddPvtValueToIpmBuffer(void* KeyHandle, unsigned short NodeId, long Position, long Velocity, unsigned char Time, unsigned int* pErrorCode); +InterpolatedPositionMode_DllExport int VCS_StartIpmTrajectory(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); +InterpolatedPositionMode_DllExport int VCS_StopIpmTrajectory(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); +InterpolatedPositionMode_DllExport int VCS_GetIpmStatus(void* KeyHandle, unsigned short NodeId, int* pTrajectoryRunning, int* pIsUnderflowWarning, int* pIsOverflowWarning, int* pIsVelocityWarning, int* pIsAccelerationWarning, int* pIsUnderflowError, int* pIsOverflowError, int* pIsVelocityError, int* pIsAccelerationError, unsigned int* pErrorCode); + +//Position Mode +PositionMode_DllExport int VCS_ActivatePositionMode(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); +PositionMode_DllExport int VCS_SetPositionMust(void* KeyHandle, unsigned short NodeId, long PositionMust, unsigned int* pErrorCode); +PositionMode_DllExport int VCS_GetPositionMust(void* KeyHandle, unsigned short NodeId, long* pPositionMust, unsigned int* pErrorCode); + +//Advanced Functions +PositionMode_DllExport int VCS_ActivateAnalogPositionSetpoint(void* KeyHandle, unsigned short NodeId, unsigned short AnalogInputNumber, float Scaling, long Offset, unsigned int* pErrorCode); +PositionMode_DllExport int VCS_DeactivateAnalogPositionSetpoint(void* KeyHandle, unsigned short NodeId, unsigned short AnalogInputNumber, unsigned int* pErrorCode); +PositionMode_DllExport int VCS_EnableAnalogPositionSetpoint(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); +PositionMode_DllExport int VCS_DisableAnalogPositionSetpoint(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); + +//Velocity Mode +VelocityMode_DllExport int VCS_ActivateVelocityMode(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); +VelocityMode_DllExport int VCS_SetVelocityMust(void* KeyHandle, unsigned short NodeId, long VelocityMust, unsigned int* pErrorCode); +VelocityMode_DllExport int VCS_GetVelocityMust(void* KeyHandle, unsigned short NodeId, long* pVelocityMust, unsigned int* pErrorCode); + +//Advanced Functions +VelocityMode_DllExport int VCS_ActivateAnalogVelocitySetpoint(void* KeyHandle, unsigned short NodeId, unsigned short AnalogInputNumber, float Scaling, long Offset, unsigned int* pErrorCode); +VelocityMode_DllExport int VCS_DeactivateAnalogVelocitySetpoint(void* KeyHandle, unsigned short NodeId, unsigned short AnalogInputNumber, unsigned int* pErrorCode); +VelocityMode_DllExport int VCS_EnableAnalogVelocitySetpoint(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); +VelocityMode_DllExport int VCS_DisableAnalogVelocitySetpoint(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); + +//Current Mode +CurrentMode_DllExport int VCS_ActivateCurrentMode(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); +CurrentMode_DllExport int VCS_SetCurrentMust(void* KeyHandle, unsigned short NodeId, short CurrentMust, unsigned int* pErrorCode); +CurrentMode_DllExport int VCS_SetCurrentMustEx(void* KeyHandle, unsigned short NodeId, int CurrentMust, unsigned int* pErrorCode); +CurrentMode_DllExport int VCS_GetCurrentMust(void* KeyHandle, unsigned short NodeId, short* pCurrentMust, unsigned int* pErrorCode); +CurrentMode_DllExport int VCS_GetCurrentMustEx(void* KeyHandle, unsigned short NodeId, int* pCurrentMust, unsigned int* pErrorCode); + +//Advanced Functions +CurrentMode_DllExport int VCS_ActivateAnalogCurrentSetpoint(void* KeyHandle, unsigned short NodeId, unsigned short AnalogInputNumber, float Scaling, short Offset, unsigned int* pErrorCode); +CurrentMode_DllExport int VCS_DeactivateAnalogCurrentSetpoint(void* KeyHandle, unsigned short NodeId, unsigned short AnalogInputNumber, unsigned int* pErrorCode); +CurrentMode_DllExport int VCS_EnableAnalogCurrentSetpoint(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); +CurrentMode_DllExport int VCS_DisableAnalogCurrentSetpoint(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); + +//MasterEncoder Mode +MasterEncoderMode_DllExport int VCS_ActivateMasterEncoderMode(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); +MasterEncoderMode_DllExport int VCS_SetMasterEncoderParameter(void* KeyHandle, unsigned short NodeId, unsigned short ScalingNumerator, unsigned short ScalingDenominator, unsigned char Polarity, unsigned int MaxVelocity, unsigned int MaxAcceleration, unsigned int* pErrorCode); +MasterEncoderMode_DllExport int VCS_GetMasterEncoderParameter(void* KeyHandle, unsigned short NodeId, unsigned short* pScalingNumerator, unsigned short* pScalingDenominator, unsigned char* pPolarity, unsigned int* pMaxVelocity, unsigned int* pMaxAcceleration, unsigned int* pErrorCode); + +//StepDirection Mode +StepDirectionMode_DllExport int VCS_ActivateStepDirectionMode(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); +StepDirectionMode_DllExport int VCS_SetStepDirectionParameter(void* KeyHandle, unsigned short NodeId, unsigned short ScalingNumerator, unsigned short ScalingDenominator, unsigned char Polarity, unsigned int MaxVelocity, unsigned int MaxAcceleration, unsigned int* pErrorCode); +StepDirectionMode_DllExport int VCS_GetStepDirectionParameter(void* KeyHandle, unsigned short NodeId, unsigned short* pScalingNumerator, unsigned short* pScalingDenominator, unsigned char* pPolarity, unsigned int* pMaxVelocity, unsigned int* pMaxAcceleration, unsigned int* pErrorCode); + +//Inputs Outputs +//General +InputsOutputs_DllExport int VCS_GetAllDigitalInputs(void* KeyHandle, unsigned short NodeId, unsigned short* pInputs, unsigned int* pErrorCode); +InputsOutputs_DllExport int VCS_GetAllDigitalOutputs(void* KeyHandle, unsigned short NodeId, unsigned short* pOutputs, unsigned int* pErrorCode); +InputsOutputs_DllExport int VCS_SetAllDigitalOutputs(void* KeyHandle, unsigned short NodeId, unsigned short Outputs, unsigned int* pErrorCode); +InputsOutputs_DllExport int VCS_GetAnalogInput(void* KeyHandle, unsigned short NodeId, unsigned short InputNumber, unsigned short* pAnalogValue, unsigned int* pErrorCode); +InputsOutputs_DllExport int VCS_GetAnalogInputVoltage(void* KeyHandle, unsigned short NodeId, unsigned short InputNumber, long* pVoltageValue, unsigned int* pErrorCode); +InputsOutputs_DllExport int VCS_GetAnalogInputState(void* KeyHandle, unsigned short NodeId, unsigned short Configuration, long* pStateValue, unsigned int* pErrorCode); +InputsOutputs_DllExport int VCS_SetAnalogOutput(void* KeyHandle, unsigned short NodeId, unsigned short OutputNumber, unsigned short AnalogValue, unsigned int* pErrorCode); +InputsOutputs_DllExport int VCS_SetAnalogOutputVoltage(void* KeyHandle, unsigned short NodeId, unsigned short OutputNumber, long VoltageValue, unsigned int* pErrorCode); +InputsOutputs_DllExport int VCS_SetAnalogOutputState(void* KeyHandle, unsigned short NodeId, unsigned short Configuration, long StateValue, unsigned int* pErrorCode); + +//Position Compare +InputsOutputs_DllExport int VCS_SetPositionCompareParameter(void* KeyHandle, unsigned short NodeId, unsigned char OperationalMode, unsigned char IntervalMode, unsigned char DirectionDependency, unsigned short IntervalWidth, unsigned short IntervalRepetitions, unsigned short PulseWidth, unsigned int* pErrorCode); +InputsOutputs_DllExport int VCS_GetPositionCompareParameter(void* KeyHandle, unsigned short NodeId, unsigned char* pOperationalMode, unsigned char* pIntervalMode, unsigned char* pDirectionDependency, unsigned short* pIntervalWidth, unsigned short* pIntervalRepetitions, unsigned short* pPulseWidth, unsigned int* pErrorCode); +InputsOutputs_DllExport int VCS_ActivatePositionCompare(void* KeyHandle, unsigned short NodeId, unsigned short DigitalOutputNumber, int Polarity, unsigned int* pErrorCode); +InputsOutputs_DllExport int VCS_DeactivatePositionCompare(void* KeyHandle, unsigned short NodeId, unsigned short DigitalOutputNumber, unsigned int* pErrorCode); +InputsOutputs_DllExport int VCS_EnablePositionCompare(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); +InputsOutputs_DllExport int VCS_DisablePositionCompare(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); +InputsOutputs_DllExport int VCS_SetPositionCompareReferencePosition(void* KeyHandle, unsigned short NodeId, long ReferencePosition, unsigned int* pErrorCode); + +//Position Marker +InputsOutputs_DllExport int VCS_SetPositionMarkerParameter(void* KeyHandle, unsigned short NodeId, unsigned char PositionMarkerEdgeType, unsigned char PositionMarkerMode, unsigned int* pErrorCode); +InputsOutputs_DllExport int VCS_GetPositionMarkerParameter(void* KeyHandle, unsigned short NodeId, unsigned char* pPositionMarkerEdgeType, unsigned char* pPositionMarkerMode, unsigned int* pErrorCode); +InputsOutputs_DllExport int VCS_ActivatePositionMarker(void* KeyHandle, unsigned short NodeId, unsigned short DigitalInputNumber, int Polarity, unsigned int* pErrorCode); +InputsOutputs_DllExport int VCS_DeactivatePositionMarker(void* KeyHandle, unsigned short NodeId, unsigned short DigitalInputNumber, unsigned int* pErrorCode); +InputsOutputs_DllExport int VCS_ReadPositionMarkerCounter(void* KeyHandle, unsigned short NodeId, unsigned short* pCount, unsigned int* pErrorCode); +InputsOutputs_DllExport int VCS_ReadPositionMarkerCapturedPosition(void* KeyHandle, unsigned short NodeId, unsigned short CounterIndex, long* pCapturedPosition, unsigned int* pErrorCode); +InputsOutputs_DllExport int VCS_ResetPositionMarkerCounter(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); + +//******************************************************************************************************************* +// DATA RECORDING FUNCTIONS +//******************************************************************************************************************* + +//DataRecorder Setup +DataRecording_DllExport int VCS_SetRecorderParameter(void* KeyHandle, unsigned short NodeId, unsigned short SamplingPeriod, unsigned short NbOfPrecedingSamples, unsigned int* pErrorCode); +DataRecording_DllExport int VCS_GetRecorderParameter(void* KeyHandle, unsigned short NodeId, unsigned short* pSamplingPeriod, unsigned short* pNbOfPrecedingSamples, unsigned int* pErrorCode); +DataRecording_DllExport int VCS_EnableTrigger(void* KeyHandle, unsigned short NodeId, unsigned char TriggerType, unsigned int* pErrorCode); +DataRecording_DllExport int VCS_DisableAllTriggers(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); +DataRecording_DllExport int VCS_ActivateChannel(void* KeyHandle, unsigned short NodeId, unsigned char ChannelNumber, unsigned short ObjectIndex, unsigned char ObjectSubIndex, unsigned char ObjectSize, unsigned int* pErrorCode); +DataRecording_DllExport int VCS_DeactivateAllChannels(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); + +//DataRecorder Status +DataRecording_DllExport int VCS_StartRecorder(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); +DataRecording_DllExport int VCS_StopRecorder(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); +DataRecording_DllExport int VCS_ForceTrigger(void* KeyHandle, unsigned short NodeId, unsigned int* pErrorCode); +DataRecording_DllExport int VCS_IsRecorderRunning(void* KeyHandle, unsigned short NodeId, int* pRunning, unsigned int* pErrorCode); +DataRecording_DllExport int VCS_IsRecorderTriggered(void* KeyHandle, unsigned short NodeId, int* pTriggered, unsigned int* pErrorCode); + +//DataRecorder Data +DataRecording_DllExport int VCS_ReadChannelVectorSize(void* KeyHandle, unsigned short NodeId, unsigned int* pVectorSize, unsigned int* pErrorCode); +DataRecording_DllExport int VCS_ReadChannelDataVector(void* KeyHandle, unsigned short NodeId, unsigned char ChannelNumber, unsigned char* pDataVectorBuffer, unsigned int VectorBufferSize, unsigned int* pErrorCode); + +//Advanced Functions +DataRecording_DllExport int VCS_ReadDataBuffer(void* KeyHandle, unsigned short NodeId, unsigned char* pDataBuffer, unsigned int BufferSizeToRead, unsigned int* pBufferSizeRead, unsigned short* pVectorStartOffset, unsigned short* pMaxNbOfSamples, unsigned short* pNbOfRecordedSamples, unsigned int* pErrorCode); +DataRecording_DllExport int VCS_ExtractChannelDataVector(void* KeyHandle, unsigned short NodeId, unsigned char ChannelNumber, unsigned char* pDataBuffer, unsigned int BufferSize, unsigned char* pDataVector, unsigned int VectorSize, unsigned short VectorStartOffset, unsigned short MaxNbOfSamples, unsigned short NbOfRecordedSamples, unsigned int* pErrorCode); + +/************************************************************************************************************************************* +* LOW LAYER FUNCTIONS +*************************************************************************************************************************************/ + +//CanLayer Functions +CanLayer_DllExport int VCS_SendCANFrame(void* KeyHandle, unsigned short CobID, unsigned short Length, void* pData, unsigned int* pErrorCode); +CanLayer_DllExport int VCS_ReadCANFrame(void* KeyHandle, unsigned short CobID, unsigned short Length, void* pData, unsigned int Timeout, unsigned int* pErrorCode); +CanLayer_DllExport int VCS_RequestCANFrame(void* KeyHandle, unsigned short CobID, unsigned short Length, void* pData, unsigned int* pErrorCode); +CanLayer_DllExport int VCS_SendNMTService(void* KeyHandle, unsigned short NodeId, unsigned short CommandSpecifier, unsigned int* pErrorCode); + +/************************************************************************************************************************************* +* TYPE DEFINITIONS +*************************************************************************************************************************************/ +//Communication +//Dialog Mode +extern const int DM_PROGRESS_DLG; //= 0; +extern const int DM_PROGRESS_AND_CONFIRM_DLG; //= 1; +extern const int DM_CONFIRM_DLG; //= 2; +extern const int DM_NO_DLG; //= 3; + +//Configuration +//MotorType +extern const unsigned short MT_DC_MOTOR; //= 1; +extern const unsigned short MT_EC_SINUS_COMMUTATED_MOTOR; //= 10; +extern const unsigned short MT_EC_BLOCK_COMMUTATED_MOTOR; //= 11; + +//SensorType +extern const unsigned short ST_UNKNOWN; //= 0; +extern const unsigned short ST_INC_ENCODER_3CHANNEL; //= 1; +extern const unsigned short ST_INC_ENCODER_2CHANNEL; //= 2; +extern const unsigned short ST_HALL_SENSORS; //= 3; +extern const unsigned short ST_SSI_ABS_ENCODER_BINARY; //= 4; +extern const unsigned short ST_SSI_ABS_ENCODER_GREY; //= 5; +extern const unsigned short ST_INC_ENCODER2_3CHANNEL; //= 6; +extern const unsigned short ST_INC_ENCODER2_2CHANNEL; //= 7; +extern const unsigned short ST_ANALOG_INC_ENCODER_3CHANNEL; //= 8; +extern const unsigned short ST_ANALOG_INC_ENCODER_2CHANNEL; //= 9; + +//In- and outputs +//Digital input configuration +extern const unsigned short DIC_NEGATIVE_LIMIT_SWITCH; //= 0; +extern const unsigned short DIC_POSITIVE_LIMIT_SWITCH; //= 1; +extern const unsigned short DIC_HOME_SWITCH; //= 2; +extern const unsigned short DIC_POSITION_MARKER; //= 3; +extern const unsigned short DIC_DRIVE_ENABLE; //= 4; +extern const unsigned short DIC_QUICK_STOP; //= 5; +extern const unsigned short DIC_GENERAL_PURPOSE_J; //= 6; +extern const unsigned short DIC_GENERAL_PURPOSE_I; //= 7; +extern const unsigned short DIC_GENERAL_PURPOSE_H; //= 8; +extern const unsigned short DIC_GENERAL_PURPOSE_G; //= 9; +extern const unsigned short DIC_GENERAL_PURPOSE_F; //= 10; +extern const unsigned short DIC_GENERAL_PURPOSE_E; //= 11; +extern const unsigned short DIC_GENERAL_PURPOSE_D; //= 12; +extern const unsigned short DIC_GENERAL_PURPOSE_C; //= 13; +extern const unsigned short DIC_GENERAL_PURPOSE_B; //= 14; +extern const unsigned short DIC_GENERAL_PURPOSE_A; //= 15; + +//Digital output configuration +extern const unsigned short DOC_READY_FAULT; //= 0; +extern const unsigned short DOC_POSITION_COMPARE; //= 1; +extern const unsigned short DOC_GENERAL_PURPOSE_H; //= 8; +extern const unsigned short DOC_GENERAL_PURPOSE_G; //= 9; +extern const unsigned short DOC_GENERAL_PURPOSE_F; //= 10; +extern const unsigned short DOC_GENERAL_PURPOSE_E; //= 11; +extern const unsigned short DOC_GENERAL_PURPOSE_D; //= 12; +extern const unsigned short DOC_GENERAL_PURPOSE_C; //= 13; +extern const unsigned short DOC_GENERAL_PURPOSE_B; //= 14; +extern const unsigned short DOC_GENERAL_PURPOSE_A; //= 15; + +//Analog input configuration +extern const unsigned short AIC_ANALOG_CURRENT_SETPOINT; //= 0; +extern const unsigned short AIC_ANALOG_VELOCITY_SETPOINT; //= 1; +extern const unsigned short AIC_ANALOG_POSITION_SETPOINT; //= 2; +extern const unsigned short AIC_GENERAL_PURPOSE_H; //= 8; +extern const unsigned short AIC_GENERAL_PURPOSE_G; //= 9; +extern const unsigned short AIC_GENERAL_PURPOSE_F; //= 10; +extern const unsigned short AIC_GENERAL_PURPOSE_E; //= 11; +extern const unsigned short AIC_GENERAL_PURPOSE_D; //= 12; +extern const unsigned short AIC_GENERAL_PURPOSE_C; //= 13; +extern const unsigned short AIC_GENERAL_PURPOSE_B; //= 14; +extern const unsigned short AIC_GENERAL_PURPOSE_A; //= 15; + +//Analog output configuration +extern const unsigned short AOC_GENERAL_PURPOSE_A; //= 0; +extern const unsigned short AOC_GENERAL_PURPOSE_B; //= 1; + +//Units +//VelocityDimension +extern const unsigned char VD_RPM; //= 0xA4; + +//VelocityNotation +extern const signed char VN_STANDARD; //= 0; +extern const signed char VN_DECI; //= -1; +extern const signed char VN_CENTI; //= -2; +extern const signed char VN_MILLI; //= -3; + +//Operational mode +extern const signed char OMD_PROFILE_POSITION_MODE; //= 1; +extern const signed char OMD_PROFILE_VELOCITY_MODE; //= 3; +extern const signed char OMD_HOMING_MODE; //= 6; +extern const signed char OMD_INTERPOLATED_POSITION_MODE; //; //= 7; +extern const signed char OMD_POSITION_MODE; //= -1; +extern const signed char OMD_VELOCITY_MODE; //= -2; +extern const signed char OMD_CURRENT_MODE; //; //= -3; +extern const signed char OMD_MASTER_ENCODER_MODE; //= -5; +extern const signed char OMD_STEP_DIRECTION_MODE; //= -6; + +//States +extern const unsigned short ST_DISABLED; //= 0; +extern const unsigned short ST_ENABLED; //= 1; +extern const unsigned short ST_QUICKSTOP; //= 2; +extern const unsigned short ST_FAULT; //= 3; + +//Homing mode +//Homing method +extern const char HM_ACTUAL_POSITION; //= 35; +extern const char HM_NEGATIVE_LIMIT_SWITCH; //= 17; +extern const char HM_NEGATIVE_LIMIT_SWITCH_AND_INDEX; //= 1; +extern const char HM_POSITIVE_LIMIT_SWITCH; //= 18; +extern const char HM_POSITIVE_LIMIT_SWITCH_AND_INDEX; //= 2; +extern const char HM_HOME_SWITCH_POSITIVE_SPEED; //= 23; +extern const char HM_HOME_SWITCH_POSITIVE_SPEED_AND_INDEX; //= 7; +extern const char HM_HOME_SWITCH_NEGATIVE_SPEED; //= 27; +extern const char HM_HOME_SWITCH_NEGATIVE_SPEED_AND_INDEX; //= 11; +extern const char HM_CURRENT_THRESHOLD_POSITIVE_SPEED; //= -3; +extern const char HM_CURRENT_THRESHOLD_POSITIVE_SPEED_AND_INDEX; //= -1; +extern const char HM_CURRENT_THRESHOLD_NEGATIVE_SPEED; //= -4; +extern const char HM_CURRENT_THRESHOLD_NEGATIVE_SPEED_AND_INDEX; //= -2; +extern const char HM_INDEX_POSITIVE_SPEED; //= 34; +extern const char HM_INDEX_NEGATIVE_SPEED; //= 33; + +//Input Output PositionMarker +//PositionMarkerEdgeType +extern const unsigned char PET_BOTH_EDGES; //= 0; +extern const unsigned char PET_RISING_EDGE; //= 1; +extern const unsigned char PET_FALLING_EDGE; //= 2; + +//PositionMarkerMode +extern const unsigned char PM_CONTINUOUS; //= 0; +extern const unsigned char PM_SINGLE; //= 1; +extern const unsigned char PM_MULTIPLE; //= 2; + +//Input Output PositionCompare +//PositionCompareOperationalMode +extern const unsigned char PCO_SINGLE_POSITION_MODE; //= 0; +extern const unsigned char PCO_POSITION_SEQUENCE_MODE; //= 1; + +//PositionCompareIntervalMode +extern const unsigned char PCI_NEGATIVE_DIR_TO_REFPOS; //= 0; +extern const unsigned char PCI_POSITIVE_DIR_TO_REFPOS; //; //= 1; +extern const unsigned char PCI_BOTH_DIR_TO_REFPOS; //; //= 2; + +//PositionCompareDirectionDependency +extern const unsigned char PCD_MOTOR_DIRECTION_NEGATIVE; //= 0; +extern const unsigned char PCD_MOTOR_DIRECTION_POSITIVE; //= 1; +extern const unsigned char PCD_MOTOR_DIRECTION_BOTH; //= 2; + +//Data recorder +//Trigger type +extern const unsigned short DR_MOVEMENT_START_TRIGGER; //= 1;//bit 1 +extern const unsigned short DR_ERROR_TRIGGER; //= 2;//bit 2 +extern const unsigned short DR_DIGITAL_INPUT_TRIGGER; //= 4;//bit 3 +extern const unsigned short DR_MOVEMENT_END_TRIGGER; //= 8;//bit 4 + +//CanLayer Functions +extern const unsigned short NCS_START_REMOTE_NODE; //= 1; +extern const unsigned short NCS_STOP_REMOTE_NODE; //= 2; +extern const unsigned short NCS_ENTER_PRE_OPERATIONAL; //= 128; +extern const unsigned short NCS_RESET_NODE; //= 129; +extern const unsigned short NCS_RESET_COMMUNICATION; //= 130; + +// Controller Gains +// EController +extern const unsigned short EC_PI_CURRENT_CONTROLLER; //= 1; +extern const unsigned short EC_PI_VELOCITY_CONTROLLER; //= 10; +extern const unsigned short EC_PI_VELOCITY_CONTROLLER_WITH_OBSERVER; //= 11; +extern const unsigned short EC_PID_POSITION_CONTROLLER; //= 20; +extern const unsigned short EC_DUAL_LOOP_POSITION_CONTROLLER; //= 21; + +// EGain (EC_PI_CURRENT_CONTROLLER) +extern const unsigned short EG_PICC_P_GAIN; //= 1; +extern const unsigned short EG_PICC_I_GAIN; //= 2; + +// EGain (EC_PI_VELOCITY_CONTROLLER) +extern const unsigned short EG_PIVC_P_GAIN; //= 1; +extern const unsigned short EG_PIVC_I_GAIN; //= 2; +extern const unsigned short EG_PIVC_FEED_FORWARD_VELOCITY_GAIN; //= 10; +extern const unsigned short EG_PIVC_FEED_FORWARD_ACCELERATION_GAIN; //= 11; + +// EGain (EC_PI_VELOCITY_CONTROLLER_WITH_OBSERVER) +extern const unsigned short EG_PIVCWO_P_GAIN; //= 1; +extern const unsigned short EG_PIVCWO_I_GAIN; //= 2; +extern const unsigned short EG_PIVCWO_FEED_FORWARD_VELOCITY_GAIN; //= 10; +extern const unsigned short EG_PIVCWO_FEED_FORWARD_ACCELERATION_GAIN; //= 11; +extern const unsigned short EG_PIVCWO_OBSERVER_THETA_GAIN; //= 20; +extern const unsigned short EG_PIVCWO_OBSERVER_OMEGA_GAIN; //= 21; +extern const unsigned short EG_PIVCWO_OBSERVER_TAU_GAIN; //= 22; + +// EGain (EC_PID_POSITION_CONTROLLER) +extern const unsigned short EG_PIDPC_P_GAIN; //= 1; +extern const unsigned short EG_PIDPC_I_GAIN; //= 2; +extern const unsigned short EG_PIDPC_D_GAIN; //= 3; +extern const unsigned short EG_PIDPC_FEED_FORWARD_VELOCITY_GAIN; //= 10; +extern const unsigned short EG_PIDPC_FEED_FORWARD_ACCELERATION_GAIN; //= 11; + +// EGain (EC_DUAL_LOOP_POSITION_CONTROLLER) +extern const unsigned short EG_DLPC_AUXILIARY_LOOP_P_GAIN; //= 1; +extern const unsigned short EG_DLPC_AUXILIARY_LOOP_I_GAIN; //= 2; +extern const unsigned short EG_DLPC_AUXILIARY_LOOP_FEED_FORWARD_VELOCITY_GAIN; //= 10; +extern const unsigned short EG_DLPC_AUXILIARY_LOOP_FEED_FORWARD_ACCELERATION_GAIN; //= 11; +extern const unsigned short EG_DLPC_AUXILIARY_LOOP_OBSERVER_THETA_GAIN; //= 20; +extern const unsigned short EG_DLPC_AUXILIARY_LOOP_OBSERVER_OMEGA_GAIN; //= 21; +extern const unsigned short EG_DLPC_AUXILIARY_LOOP_OBSERVER_TAU_GAIN; //= 22; +extern const unsigned short EG_DLPC_MAIN_LOOP_P_GAIN_LOW; //= 101; +extern const unsigned short EG_DLPC_MAIN_LOOP_P_GAIN_HIGH; //= 102; +extern const unsigned short EG_DLPC_MAIN_LOOP_GAIN_SCHEDULING_WEIGHT; //= 110; +extern const unsigned short EG_DLPC_MAIN_LOOP_FILTER_COEFFICIENT_A; //= 120; +extern const unsigned short EG_DLPC_MAIN_LOOP_FILTER_COEFFICIENT_B; //= 121; +extern const unsigned short EG_DLPC_MAIN_LOOP_FILTER_COEFFICIENT_C; //= 122; +extern const unsigned short EG_DLPC_MAIN_LOOP_FILTER_COEFFICIENT_D; //= 123; +extern const unsigned short EG_DLPC_MAIN_LOOP_FILTER_COEFFICIENT_E; //= 124; + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/lib/epos2/epos2.c b/lib/epos2/epos2.c new file mode 100644 index 0000000..0770a61 --- /dev/null +++ b/lib/epos2/epos2.c @@ -0,0 +1,31 @@ +#include +#include "epos2.h" + +const char* DEFAULT_NAME = "EPOS2"; + +int DecodeError(const uint32_t error_code, char* error_msg, uint8_t max_size) { + int ret = VCS_GetErrorInfo(error_code, error_msg, max_size); + if (ret == 0) { printf("ERROR: Failed to decode error\n"); } + + return ret; +} + +int PrintError(const uint32_t error_code) { + char msg[64] = { 0 }; + int ret = DecodeError(error_code, msg, 64); + printf("ERROR 0x%X: %s\n", error_code, msg); + + return ret; +} + +uint32_t ResetDevice(void *device_handle, struct Controller *controller_in) { + if (device_handle == 0) { return 0x2000000B; } + uint32_t error_code = 0; + int ret = VCS_ResetDevice(device_handle, controller_in->NodeId, &error_code); + if (ret == 0) { + PrintError(error_code); + printf("Device failed to be reset: %s\n", controller_in->Name); + } + + return error_code; +} diff --git a/lib/epos2/epos2.h b/lib/epos2/epos2.h new file mode 100644 index 0000000..e4535ba --- /dev/null +++ b/lib/epos2/epos2.h @@ -0,0 +1,35 @@ +#pragma once + +#include "libtestrig_api.h" +#include "definitions.h" +#include "controller.h" +#include "identify.h" +#include "connect.h" +#include "manage.h" + +#ifdef __cplusplus +namespace VSCL::Rig { +extern "C" { +#endif // __cplusplus + +extern const char* DEFAULT_NAME; + +/* + * @brief Decode a given error code to its corresponding message. + */ +int TESTRIG_API DecodeError(const uint32_t error_code, char* error_msg, uint8_t max_size); + +/* + * @brief Decode and print an error code's corresponding message. + */ +int TESTRIG_API PrintError(const uint32_t error_code); + +/* + * @brief Reset a device. + */ +uint32_t TESTRIG_API ResetDevice(void* device_handle, struct Controller* controller_in); + +#ifdef __cplusplus +} // extern "C" +} // namespace VSCL::Rig +#endif // __cplusplus diff --git a/lib/epos2/identify.c b/lib/epos2/identify.c new file mode 100644 index 0000000..a9749cb --- /dev/null +++ b/lib/epos2/identify.c @@ -0,0 +1,162 @@ +#include +#include + +#include "controller.h" +#include "definitions.h" +#include "identify.h" + +static void WarnOverExpectant(const int size, const int n, const char* name) { + if (size <= n) { return; } + printf("Warning: You attempted to probe for more controllers than was connected: "); + printf("%i requested was greater than %i connected: ", size, n); + printf("routine %s\n", name); +} + +uint32_t AcquireDeviceNames(struct Controller controllers_out[], int size) { + uint32_t error_code = 0; + int n = 0; + int selection_end; + + int name_found = VCS_GetDeviceNameSelection( + 1, controllers_out[0].Name, 8, + &selection_end, &error_code); + if (name_found != 0) { return error_code; } + n++; + + while (selection_end == 0 && n < size) { + name_found = VCS_GetDeviceNameSelection( + 0, controllers_out[n].Name, 8, + &selection_end, &error_code); + + if (name_found != 0) { return error_code; } + n++; + } + + WarnOverExpectant(size, n, "naming"); + return error_code; +} + +uint32_t AcquireDeviceProtocols(struct Controller controllers_out[], int size) { + uint32_t error_code = 0; + int n = 0; + int selection_end; + + int protocol_found = VCS_GetProtocolStackNameSelection( + controllers_out[0].Name, 1, + controllers_out[0].Protocol, 16, + &selection_end, &error_code); + if (protocol_found == 0) { return error_code; } + n++; + + while (selection_end == 0 && n < size) { + protocol_found = VCS_GetProtocolStackNameSelection( + controllers_out[n].Name, 0, + controllers_out[n].Protocol, 16, + &selection_end, &error_code); + + if (protocol_found == 0) { return error_code; } + n++; + } + + WarnOverExpectant(size, n, "protocol finding"); + return error_code; +} + +uint32_t AcquireDeviceInterfaces(struct Controller controllers_out[], int size) { + uint32_t error_code = 0; + int n = 0; + int selection_end; + + int interface_found = VCS_GetInterfaceNameSelection( + controllers_out[0].Name, controllers_out[0].Protocol, 1, + controllers_out[0].Interface, 64, &selection_end, &error_code); + if (interface_found == 0) { return error_code; } + n++; + + while (selection_end == 0 && n < size) { + interface_found = VCS_GetInterfaceNameSelection( + controllers_out[n].Name, controllers_out[n].Protocol, 0, + controllers_out[n].Interface, 64, &selection_end, &error_code); + + if (interface_found == 0) { return error_code; } + n++; + } + + WarnOverExpectant(size, n, "interface finding"); + return error_code; +} + +uint32_t AcquireDevicePorts(struct Controller controllers_out[], int size) { + uint32_t error_code = 0; + int n = 0; + int selection_end; + + int port_found = VCS_GetPortNameSelection( + controllers_out[0].Name, controllers_out[0].Protocol, controllers_out[0].Interface, 1, + controllers_out[0].Port, 8, &selection_end, &error_code); + if (port_found == 0) { return error_code; } + n++; + + while (selection_end == 0 && n < size) { + port_found = VCS_GetPortNameSelection( + controllers_out[n].Name, controllers_out[n].Protocol, controllers_out[n].Interface, 0, + controllers_out[n].Port, 8, &selection_end, &error_code); + if (port_found == 0) { return error_code; } + n++; + } + + WarnOverExpectant(size, n, "port finding"); + return error_code; +} + +uint32_t AcquireDeviceInfos(struct Controller controllers_out[], int size, int flags) { + uint32_t error_code = 0; + + if (flags & (1 << 2)) { memset(controllers_out, 0, sizeof(*controllers_out)); } + + if (flags & (1 << 1)) { + for (int i = 0; i < size; i++) { + strncpy(controllers_out[i].Name, "EPOS2", 6); + strncpy(controllers_out[i].Protocol, "CANopen", 8); + } + } + else { + error_code = AcquireDeviceNames(controllers_out, size); + if (error_code != 0) { return error_code; }; + + error_code = AcquireDeviceProtocols(controllers_out, size); + if (error_code != 0) { return error_code; }; + } + + error_code = AcquireDeviceInterfaces(controllers_out, size); + if (error_code != 0) { return error_code; } + + error_code = AcquireDevicePorts(controllers_out, size); + if (error_code != 0) { return error_code; } + + return 0; +} + +uint32_t SetDeviceNode(struct Controller* controller_out, void* handle, uint8_t old_node, uint8_t new_node) { + uint32_t error_code = 0; + uint32_t bytes_written = 0; + int ret; + + ret = VCS_SetObject( + handle, old_node, + 0x2000, 0x00, + &new_node, 1, + &bytes_written, &error_code); + + if (ret != 0) { controller_out->NodeId = new_node; } + + return error_code; +} + +void PrintControllerCharacteristics(struct Controller* controller) { + printf("- Name: %s\n", controller->Name); + printf("- Node: %i\n", controller->NodeId); + printf("- Protocol: %s\n", controller->Protocol); + printf("- Interface: %s\n", controller->Interface); + printf("- Port: %s\n", controller->Port); +} diff --git a/lib/epos2/identify.h b/lib/epos2/identify.h new file mode 100644 index 0000000..d711f44 --- /dev/null +++ b/lib/epos2/identify.h @@ -0,0 +1,75 @@ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +#include +#include "libtestrig_api.h" +#include "controller.h" + +#ifdef __cplusplus +} // extern "C" (headers) +namespace VSCL::Rig { +extern "C" { +#endif // __cplusplus + +enum ACQUIRE_DEVICE_INFORMATION_FLAGS { + FLAG_ACQUIRE_INIT_DEFAULTS = 1, + FLAG_ACQUIRE_ZERO_INIT = 2, +}; + +/* + * @brief Finds the name of the Controllers in the array. + * This operates on all connected controllers. + * + * Refer to Page 3-25 of the manual. + */ +uint32_t TESTRIG_API AcquireDeviceNames(struct Controller controllers_out[], int size); + +/* + * @brief Finds the protocol stacks of the Controller in the array. + * This operates on all connected controllers. + * + * Refer to Page 3-26 of the manual. + */ +uint32_t TESTRIG_API AcquireDeviceProtocols(struct Controller controllers_out[], int size); + +/* + * @brief Finds the interfaces of the Controller in the array. + * This operates on all connected controllers. + * + * Refer to Page 3-27 of the manual. + */ +uint32_t TESTRIG_API AcquireDeviceInterfaces(struct Controller controllers_out[], int size); + +/* + * @brief Finds the ports of the Controller in the array. + * This operates on all connected controllers. + * + * Refer to Page 3-28 of the manual. + */ +uint32_t TESTRIG_API AcquireDevicePorts(struct Controller controllers_out[], int size); + +/* + * @brief Acquire the information on the set number of controllers. + */ +uint32_t TESTRIG_API AcquireDeviceInfos(struct Controller controllers_out[], int size, int flags); + +/* + * @brief Set the controller to be identified by the given node on the network. + * + * Refer to 8-135 of the firmware manual. An unconfigured node is found at node 0. + */ +uint32_t TESTRIG_API SetDeviceNode(struct Controller* controller_out, void* handle, uint8_t old_node, uint8_t new_node); + +/* + * @brief Print out controller characteristics. + */ +void TESTRIG_API PrintControllerCharacteristics(struct Controller* controller_out); + + +#ifdef __cplusplus +} // extern "C" +} // namespace VSCL::Rig +#endif // __cplusplus diff --git a/lib/epos2/manage.c b/lib/epos2/manage.c new file mode 100644 index 0000000..8a1f81e --- /dev/null +++ b/lib/epos2/manage.c @@ -0,0 +1,21 @@ +#include +#include "manage.h" + +uint32_t RigAbort(const struct Controller* controller_in, void* device_handle) { + uint32_t error_code = 0; + if (device_handle == 0) { return 0x2000000B; } + + printf("WARNING: Attempting to call abort on %s of node %i!!\n", + controller_in->Name, controller_in->NodeId); + + int ret = VCS_SetQuickStopState(device_handle, controller_in->NodeId, &error_code); + if (ret == 0) { + PrintError(error_code); + printf("DANGER: Failed to abort rig operations!\n"); + } + else { + printf("WARNING: Successfully aborted operations.\n"); + } + + return error_code; +} diff --git a/lib/epos2/manage.h b/lib/epos2/manage.h new file mode 100644 index 0000000..3bee245 --- /dev/null +++ b/lib/epos2/manage.h @@ -0,0 +1,26 @@ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include "epos2.h" +#include "controller.h" + +#ifdef __cplusplus +} // extern "C" (headers) +namespace VSCL::Rig { +extern "C" { +#endif // __cplusplus + +/* + * Attempt to abort the test rig. + */ +uint32_t TESTRIG_API RigAbort(const struct Controller* controller_in, void* device_handle); + +#ifdef __cplusplus +} // extern "C" +} // namespace VSCL::Rig +#endif // __cplusplus diff --git a/lib/epos2/meson.build b/lib/epos2/meson.build new file mode 100644 index 0000000..0e562f5 --- /dev/null +++ b/lib/epos2/meson.build @@ -0,0 +1,40 @@ +fs = import('fs') +cc = meson.get_compiler('c') + +if (fs.is_dir(meson.current_source_dir() / 'bin')) + +message('Controller capabilities being built.') + +# Windows +if (operating_system == 'windows') + if not (cpu_architecture in ['x86', 'x86_64']) + error('Unsupported architecture') + endif + +# Linux +elif (operating_system == 'linux') + if not (cpu_architecture in valid_arch) + error('Unsupported architecture') + endif + + epos2 = declare_dependency( + version: '6.8.1.0', + dependencies: cc.find_library('EposCmd', + dirs: [meson.current_source_dir() / 'bin'], + required: false), + ) + + epos2_srcs = [ './epos2/epos2.c', './epos2/definitions.c', + './epos2/identify.c', './epos2/connect.c', './epos2/manage.c' ] + +# Others +else + error('Unsupported operating system') +endif + +# CI etc. +else + message('[WARNING] Controller capabilities not being built. Continuing to create library anyway.') + epos2 = declare_dependency() + epos2_srcs = [ ] +endif diff --git a/ipc/LICENSE b/lib/ipc/LICENSE similarity index 100% rename from ipc/LICENSE rename to lib/ipc/LICENSE diff --git a/ipc/constants.c b/lib/ipc/constants.c similarity index 100% rename from ipc/constants.c rename to lib/ipc/constants.c diff --git a/ipc/constants.h b/lib/ipc/constants.h similarity index 95% rename from ipc/constants.h rename to lib/ipc/constants.h index eb15aca..732bff4 100644 --- a/ipc/constants.h +++ b/lib/ipc/constants.h @@ -9,7 +9,7 @@ extern "C" { #ifdef __cplusplus } -namespace VSCL { +namespace VSCL::IPC { extern "C" { #endif // __cplusplus @@ -51,5 +51,5 @@ TESTRIG_API enum HEADER_RET { #ifdef __cplusplus } // extern "C" -} // namespace VSCL +} // namespace VSCL::IPC #endif // __cplusplus diff --git a/ipc/ipc.c b/lib/ipc/ipc.c similarity index 100% rename from ipc/ipc.c rename to lib/ipc/ipc.c diff --git a/ipc/ipc.h b/lib/ipc/ipc.h similarity index 100% rename from ipc/ipc.h rename to lib/ipc/ipc.h diff --git a/ipc/meson.build b/lib/ipc/meson.build similarity index 59% rename from ipc/meson.build rename to lib/ipc/meson.build index 39871de..0dddf79 100644 --- a/ipc/meson.build +++ b/lib/ipc/meson.build @@ -1,12 +1,3 @@ -# RM ME WHEN EPOS2 is merged -## Machine info -operating_system = host_machine.system() -cpu_architecture = host_machine.cpu_family() -valid_os = ['windows', 'linux'] -valid_arch = ['x86', 'x86_64', 'aarch64', 'arm'] - -# END RM - if (operating_system.to_lower() == 'windows') ipc_os_deps = declare_dependency( dependencies: cc.find_library('Ws2_32', @@ -16,4 +7,4 @@ elif (operating_system.to_lower() == 'linux') ipc_os_deps = declare_dependency() else error('Unsupported operating system or build environment: ' + operating_system) -endif \ No newline at end of file +endif diff --git a/ipc/message.c b/lib/ipc/message.c similarity index 100% rename from ipc/message.c rename to lib/ipc/message.c diff --git a/ipc/message.h b/lib/ipc/message.h similarity index 100% rename from ipc/message.h rename to lib/ipc/message.h diff --git a/ipc/os.c b/lib/ipc/os.c similarity index 100% rename from ipc/os.c rename to lib/ipc/os.c diff --git a/ipc/os.h b/lib/ipc/os.h similarity index 100% rename from ipc/os.h rename to lib/ipc/os.h diff --git a/libtestrig_api.h b/lib/libtestrig_api.h similarity index 95% rename from libtestrig_api.h rename to lib/libtestrig_api.h index f3da688..c294eb7 100644 --- a/libtestrig_api.h +++ b/lib/libtestrig_api.h @@ -1,3 +1,5 @@ +#pragma once + #ifndef TESTRIG_API #if defined(_WIN32) && !defined(__GNUC__) #ifdef COMPILING_TESTRIG_DLL diff --git a/lib/meson.build b/lib/meson.build new file mode 100644 index 0000000..e39e29a --- /dev/null +++ b/lib/meson.build @@ -0,0 +1,9 @@ +## Main Binary Definitions +subdir('ipc') +subdir('epos2') + +srcs = [ 'ipc/ipc.c', 'ipc/message.c', 'ipc/constants.c', 'ipc/os.c' ] + epos2_srcs +lib = shared_library('testrig', srcs, + dependencies: [ ipc_os_deps, epos2 ], c_args: ['-DCOMPILING_TESTRIG_DLL'] ) +dep = declare_dependency(include_directories: '.', + link_with: lib, dependencies: epos2) diff --git a/meson.build b/meson.build index 381629a..1fc3de5 100644 --- a/meson.build +++ b/meson.build @@ -1,13 +1,13 @@ project('libtestrig', 'c', default_options: ['warning_level=everything']) fs = import('fs') - cc = meson.get_compiler('c') -subdir('ipc') - -srcs = [ 'ipc/ipc.c', 'ipc/message.c', 'ipc/constants.c', 'ipc/os.c' ] -lib = shared_library('testrig', srcs, dependencies: ipc_os_deps, c_args: ['-DCOMPILING_TESTRIG_DLL']) -dep = declare_dependency(include_directories: '.', link_with: lib) +## Machine info +operating_system = host_machine.system() +cpu_architecture = host_machine.cpu_family() +valid_os = ['windows', 'linux'] +valid_arch = ['x86', 'x86_64', 'aarch64', 'arm'] -subdir('test') \ No newline at end of file +subdir('lib') +subdir('test') diff --git a/test/meson.build b/test/meson.build index 01bc379..6a33a4f 100644 --- a/test/meson.build +++ b/test/meson.build @@ -14,8 +14,6 @@ elif (operating_system.to_lower() == 'windows') dependencies: cc.find_library('Kernel32', required: true), ) - -message(meson.project_source_root() / 'build') dllcopy = [find_program('python'), meson.project_source_root() / 'test' / 'copy_dlls.meson.py', @@ -33,4 +31,4 @@ message(meson.project_source_root() / 'build') test('discrete', mgr_exe, args: [ server_exe.full_path(), client_exe.full_path() ], depends: [ client_exe, server_exe, move_dlls_py ]) -endif \ No newline at end of file +endif