1 #ifndef __MLPIMOTIONHELPER_H__ 2 #define __MLPIMOTIONHELPER_H__ 82 #include "targetinfo.h" 84 #if defined (TARGET_OS_VXWORKS) 86 #elif defined (TARGET_OS_WINNT) 88 #elif defined (TARGET_OS_WINCE32) 90 #elif defined (TARGET_OS_APPLE) 92 #elif defined (TARGET_OS_ANDROID) 94 #elif defined (TARGET_OS_LINUX) 97 #pragma warning "unknown operating system" 109 #define MLPI_MOTION_BIT_ACCESS(name, bit) bool name() const {return (_value & (1<<bit)) ? true : false;} 143 typedef enum MlpiDirections
145 MLPI_DIRECTION_SHORTEST_WAY = 0,
146 MLPI_DIRECTION_POSITIVE = 1,
147 MLPI_DIRECTION_NEGATIVE = 2
150 typedef enum MlpiScalingType
152 MLPI_SCALING_TYPE_TRANSLATORY_METER = 0,
153 MLPI_SCALING_TYPE_TRANSLATORY_INCH = 1,
154 MLPI_SCALING_TYPE_ROTATORY = 2,
155 MLPI_SCALING_TYPE_PERCENTAGE = 3,
156 MLPI_SCALING_TYPE_INVALID = 255
159 typedef enum MlpiScalingDataReference
161 MLPI_SCALING_REFERENCE_MOTOR_SHAFT = 0,
162 MLPI_SCALING_REFERENCE_LOAD = 1,
163 MLPI_SCALING_REFERENCE_INVALID = 255
164 }MlpiScalingDataReference;
166 typedef enum MlpiScalingFormat
168 MLPI_SCALING_FORMAT_ABSOLUTE = 0,
169 MLPI_SCALING_FORMAT_MODULO = 1,
170 MLPI_SCALING_FORMAT_INVALID = 255
173 typedef enum MlpiScalingMode
175 MLPI_SCALING_MODE_PREFERENCE = 0,
176 MLPI_SCALING_MODE_PARAMETER = 1,
177 MLPI_SCALING_MODE_INVALID = 255
180 typedef enum MlpiTimeUnit
182 MLPI_SCALING_TIME_MINUTE = 0,
183 MLPI_SCALING_TIME_SECOND = 1,
184 MLPI_SCALING_TIME_INVALID = 255
187 typedef enum MlpiTorqueUnit
189 MLPI_SCALING_TORQUE_NEWTON = 0,
190 MLPI_SCALING_TORQUE_POUND_FORCE = 1,
191 MLPI_SCALING_TORQUE_NEWTONMETER = 2,
192 MLPI_SCALING_TORQUE_INCH_POUND_FORCE = 3,
193 MLPI_SCALING_TORQUE_INVALID = 255
218 operator ULONG()
const {
225 ULONG CamTab()
const {
return _value&0x7;};
274 operator ULONG()
const {
319 switch (_value & 0xF8) {
344 : _value(condition) {
347 operator ULONG()
const {
355 bool IsActive()
const {
366 bool IsParking()
const {
377 bool IsDeactivated()
const {
388 bool IsDecoupled()
const {
401 bool IsParametrization()
const {
437 const MlpiScalingDataReference dataReference = MLPI_SCALING_REFERENCE_LOAD,
438 const MlpiScalingMode mode = MLPI_SCALING_MODE_PREFERENCE) {
442 case MLPI_SCALING_TYPE_TRANSLATORY_METER:
445 case MLPI_SCALING_TYPE_TRANSLATORY_INCH:
448 case MLPI_SCALING_TYPE_ROTATORY:
456 case MLPI_SCALING_FORMAT_ABSOLUTE:
459 case MLPI_SCALING_FORMAT_MODULO:
466 switch (dataReference)
468 case MLPI_SCALING_REFERENCE_MOTOR_SHAFT:
470 case MLPI_SCALING_REFERENCE_LOAD:
479 case MLPI_SCALING_MODE_PREFERENCE:
481 case MLPI_SCALING_MODE_PARAMETER:
489 MlpiScalingType getType()
const 491 switch (_value & 0x13)
494 return MLPI_SCALING_TYPE_TRANSLATORY_METER;
496 return MLPI_SCALING_TYPE_TRANSLATORY_INCH;
498 return MLPI_SCALING_TYPE_ROTATORY;
500 return MLPI_SCALING_TYPE_INVALID;
504 const WCHAR16* getTypeString()
const 506 switch (_value & 0x13)
509 return L
"translatory in mm";
511 return L
"translatory in inch";
519 MlpiScalingFormat getFormat()
const 521 switch (_value & 0x80)
524 return MLPI_SCALING_FORMAT_ABSOLUTE;
526 return MLPI_SCALING_FORMAT_MODULO;
528 return MLPI_SCALING_FORMAT_INVALID;
532 const WCHAR16* getFormatString()
const 534 switch (_value & 0x80)
545 MlpiScalingDataReference getReference()
const 547 switch (_value & 0x40)
550 return MLPI_SCALING_REFERENCE_MOTOR_SHAFT;
552 return MLPI_SCALING_REFERENCE_LOAD;
554 return MLPI_SCALING_REFERENCE_INVALID;
558 const WCHAR16* getReferenceString()
const 560 switch (_value & 0x40)
563 return L
"with motor shaft reference";
565 return L
"with load reference";
571 MlpiScalingMode getMode()
const 573 switch (_value & 0x08)
576 return MLPI_SCALING_MODE_PREFERENCE;
578 return MLPI_SCALING_MODE_PARAMETER;
580 return MLPI_SCALING_MODE_INVALID;
584 const WCHAR16* getModeString()
const 586 switch (_value & 0x08)
589 return L
"in preference mode";
591 return L
"parameter mode";
629 const MlpiScalingDataReference dataReference = MLPI_SCALING_REFERENCE_LOAD,
const MlpiScalingMode mode = MLPI_SCALING_MODE_PREFERENCE) {
633 case MLPI_SCALING_TYPE_TRANSLATORY_METER:
636 case MLPI_SCALING_TYPE_TRANSLATORY_INCH:
639 case MLPI_SCALING_TYPE_ROTATORY:
647 case MLPI_SCALING_TIME_MINUTE:
650 case MLPI_SCALING_TIME_SECOND:
657 switch (dataReference)
659 case MLPI_SCALING_REFERENCE_MOTOR_SHAFT:
661 case MLPI_SCALING_REFERENCE_LOAD:
670 case MLPI_SCALING_MODE_PREFERENCE:
672 case MLPI_SCALING_MODE_PARAMETER:
680 MlpiScalingType getType()
const 682 switch (_value & 0x13)
685 return MLPI_SCALING_TYPE_TRANSLATORY_METER;
687 return MLPI_SCALING_TYPE_TRANSLATORY_INCH;
689 return MLPI_SCALING_TYPE_ROTATORY;
691 return MLPI_SCALING_TYPE_INVALID;
695 const WCHAR16* getTypeString()
const 697 switch (_value & 0x13)
700 return L
"translatory in mm";
702 return L
"translatory in inch";
710 MlpiTimeUnit getTime()
const 712 switch (_value & 0x20)
715 return MLPI_SCALING_TIME_MINUTE;
717 return MLPI_SCALING_TIME_SECOND;
719 return MLPI_SCALING_TIME_INVALID;
723 const WCHAR16* getTimeString()
const 725 switch (_value & 0x20)
736 MlpiScalingDataReference getReference()
const 738 switch (_value & 0x40)
741 return MLPI_SCALING_REFERENCE_MOTOR_SHAFT;
743 return MLPI_SCALING_REFERENCE_LOAD;
745 return MLPI_SCALING_REFERENCE_INVALID;
749 const WCHAR16* getReferenceString()
const 751 switch (_value & 0x40)
754 return L
"with motor shaft reference";
756 return L
"with load reference";
762 MlpiScalingMode getMode()
const 764 switch (_value & 0x08)
767 return MLPI_SCALING_MODE_PREFERENCE;
769 return MLPI_SCALING_MODE_PARAMETER;
771 return MLPI_SCALING_MODE_INVALID;
775 const WCHAR16* getModeString()
const 777 switch (_value & 0x08)
780 return L
"in preference mode";
782 return L
"parameter mode";
820 const MlpiScalingDataReference dataReference = MLPI_SCALING_REFERENCE_LOAD,
const MlpiScalingMode mode = MLPI_SCALING_MODE_PREFERENCE) {
824 case MLPI_SCALING_TYPE_TRANSLATORY_METER:
827 case MLPI_SCALING_TYPE_TRANSLATORY_INCH:
830 case MLPI_SCALING_TYPE_ROTATORY:
837 switch (dataReference)
839 case MLPI_SCALING_REFERENCE_MOTOR_SHAFT:
841 case MLPI_SCALING_REFERENCE_LOAD:
850 case MLPI_SCALING_MODE_PREFERENCE:
852 case MLPI_SCALING_MODE_PARAMETER:
860 MlpiScalingType getType()
const 862 switch (_value & 0x13)
865 return MLPI_SCALING_TYPE_TRANSLATORY_METER;
867 return MLPI_SCALING_TYPE_TRANSLATORY_INCH;
869 return MLPI_SCALING_TYPE_ROTATORY;
871 return MLPI_SCALING_TYPE_INVALID;
875 const WCHAR16* getTypeString()
const 877 switch (_value & 0x13)
880 return L
"translatory axis in mm";
882 return L
"translatory in inch";
890 MlpiScalingDataReference getReference()
const 892 switch (_value & 0x40)
895 return MLPI_SCALING_REFERENCE_MOTOR_SHAFT;
897 return MLPI_SCALING_REFERENCE_LOAD;
899 return MLPI_SCALING_REFERENCE_INVALID;
903 const WCHAR16* getReferenceString()
const 905 switch (_value & 0x40)
908 return L
"with motor shaft reference";
910 return L
"with load reference";
916 MlpiScalingMode getMode()
const 918 switch (_value & 0x08)
921 return MLPI_SCALING_MODE_PREFERENCE;
923 return MLPI_SCALING_MODE_PARAMETER;
925 return MLPI_SCALING_MODE_INVALID;
929 const WCHAR16* getModeString()
const 931 switch (_value & 0x08)
934 return L
"in preference mode";
936 return L
"parameter mode";
974 const MlpiScalingDataReference dataReference = MLPI_SCALING_REFERENCE_LOAD,
const MlpiScalingMode mode = MLPI_SCALING_MODE_PREFERENCE) {
978 case MLPI_SCALING_TYPE_PERCENTAGE:
981 case MLPI_SCALING_TYPE_TRANSLATORY_METER:
984 case MLPI_SCALING_TYPE_TRANSLATORY_INCH:
987 case MLPI_SCALING_TYPE_ROTATORY:
994 switch (dataReference)
996 case MLPI_SCALING_REFERENCE_MOTOR_SHAFT:
998 case MLPI_SCALING_REFERENCE_LOAD:
1007 case MLPI_SCALING_MODE_PREFERENCE:
1009 case MLPI_SCALING_MODE_PARAMETER:
1017 MlpiScalingType getType()
const 1019 switch (_value & 0x13)
1022 return MLPI_SCALING_TYPE_PERCENTAGE;
1024 return MLPI_SCALING_TYPE_TRANSLATORY_METER;
1026 return MLPI_SCALING_TYPE_TRANSLATORY_INCH;
1028 return MLPI_SCALING_TYPE_ROTATORY;
1030 return MLPI_SCALING_TYPE_INVALID;
1034 const WCHAR16* getTypeString()
const 1036 switch (_value & 0x13)
1039 return L
"percentage";
1043 return L
"pound-force";
1045 return L
"newton meter";
1047 return L
"inch pound-force";
1053 MlpiScalingDataReference getReference()
const 1055 switch (_value & 0x40)
1058 return MLPI_SCALING_REFERENCE_MOTOR_SHAFT;
1060 return MLPI_SCALING_REFERENCE_LOAD;
1062 return MLPI_SCALING_REFERENCE_INVALID;
1066 const WCHAR16* getReferenceString()
const 1068 switch (_value & 0x40)
1071 return L
"with motor shaft reference";
1073 return L
"with load reference";
1079 MlpiScalingMode getMode()
const 1081 switch (_value & 0x08)
1084 return MLPI_SCALING_MODE_PREFERENCE;
1086 return MLPI_SCALING_MODE_PARAMETER;
1088 return MLPI_SCALING_MODE_INVALID;
1092 const WCHAR16* getModeString()
const 1094 switch (_value & 0x08)
1097 return L
"in preference mode";
1099 return L
"parameter mode";
1105 operator USHORT()
const {
1137 const ULONG REFRESH_TIME = 100;
1145 if(0 == motionHandle)
1150 while( !(status.done || status.error) && (timeout==
MLPI_INFINITE || timeGone<timeout) )
1152 #if defined (TARGET_OS_VXWORKS) 1153 taskDelay(REFRESH_TIME);
1154 #elif defined (TARGET_OS_WINNT) 1155 Sleep(REFRESH_TIME);
1156 #elif defined (TARGET_OS_WINCE32) 1157 Sleep(REFRESH_TIME);
1158 #elif defined (TARGET_OS_APPLE) 1159 usleep(REFRESH_TIME*1000);
1160 #elif defined (TARGET_OS_ANDROID) 1161 usleep(REFRESH_TIME*1000);
1162 #elif defined (TARGET_OS_LINUX) 1163 usleep(REFRESH_TIME*1000);
1165 #pragma warning "unknown operating system" 1169 timeGone += REFRESH_TIME;
1172 if(timeGone >= timeout)
1176 return status.additional1;
1190 const ULONG REFRESH_TIME = 100;
1195 ULONG axisState = 0;
1200 #if defined (TARGET_OS_VXWORKS) 1201 taskDelay(REFRESH_TIME);
1202 #elif defined (TARGET_OS_WINNT) 1203 Sleep(REFRESH_TIME);
1204 #elif defined (TARGET_OS_WINCE32) 1205 Sleep(REFRESH_TIME);
1206 #elif defined (TARGET_OS_APPLE) 1207 usleep(REFRESH_TIME*1000);
1208 #elif defined (TARGET_OS_ANDROID) 1209 usleep(REFRESH_TIME*1000);
1210 #elif defined (TARGET_OS_LINUX) 1211 usleep(REFRESH_TIME*1000);
1213 #pragma warning "unknown operating system" 1218 timeGone += REFRESH_TIME;
1221 if(timeGone >= timeout)
#define MLPI_S_OK
Return code "everything okay".
Drive not in Ring; Setpoint calculation not active.
Drive in Ring; Setpoint calculation active.
struct MlpiAxisConditionDecoder MlpiAxisConditionDecoder
The following struct helps to decode the axis condition as given by mlpiMotionGetCondition.
An encoder that is attached to a real drive, no motion possible.
Drive in Ring; Setpoint calculation not active; No setpoint evaluation in drive.
MLPIRESULT mlpiMotionGetStatus(const MLPIHANDLE connection, const MlpiAxisRef axis, const MLPIMOTIONHANDLE motionHandle, MlpiMotionStatus *status)
This function reads the status of a motion command.
The following struct helps to decode the axis type as given by mlpiMotionGetAxisType.
Drive in Ring; Setpoint calculation not active.
An axis that can be used when generating your own controller to operate the drive.
unsigned short USHORT
2 byte unsigned integer
struct MlpiAxisStateExtendedDecoder MlpiAxisStateExtendedDecoder
The following struct helps to decode the extended axis state as given by mlpiMotionGetAxisStateExtend...
MLPIRESULT mlpiMotionGetState(const MLPIHANDLE connection, const MlpiAxisRef axis, ULONG *value)
This function reads the state of an axis.
Drive not in Ring; Setpoint calculation not active; No setpoint evaluation in drive.
struct MlpiAxisTypeDecoder MlpiAxisTypeDecoder
The following struct helps to decode the axis type as given by mlpiMotionGetAxisType.
The following struct helps to decode the axis state as given by mlpiMotionGetAxisState or mlpiMotionG...
Drive in Ring; Setpoint calculation active; No setpoint evaluation in drive; axis in parameterization...
Drive in Ring; Setpoint calculation not active; axis in parameterization.
Drive in Ring; Setpoint calculation active; No setpoint evaluation in drive.
struct MlpiMotionStatus MlpiMotionStatus
This structure defines the status of a motion command.
wchar_t WCHAR16
UTF16 string.
unsigned int ULONG
4 byte unsigned integer
Drive in Ring; Setpoint calculation not active; No setpoint evaluation in drive; axis in parameteriza...
#define MLPI_SUCCEEDED(hr)
Returns true if given error code was successful.
unsigned long long MLPIMOTIONHANDLE
MLPI-API handle value used for motion functions.
MLPI_MOTION_BIT_ACCESS(CamTab_0, 0)
Bit0 of active CAM table of CamIn command.
#define MLPI_E_TIMEOUT
Timeout during function call.
The following struct helps to decode the extended axis state as given by mlpiMotionGetAxisStateExtend...
struct MlpiAxisScalingVelocity MlpiAxisScalingVelocity
The following struct helps to encode or decode the velocity scaling settings of the axis given or set...
Drive in Ring; Setpoint calculation active; axis in parameterization.
Drive not in Ring; Setpoint calculation not active; No setpoint evaluation in drive; axis in paramete...
The following struct helps to encode or decode the torque scaling settings of the axis given or set b...
Drive not in Ring; Setpoint calculation not active; axis in parameterization.
MLPIRESULT utilMotionWait(MLPIHANDLE connection, MlpiAxisRef axis, MLPIMOTIONHANDLE motionHandle, ULONG timeout=MLPI_INFINITE)
This function waits until a given motion command is done or an error occurs. An optional timeout can ...
MlpiAxisType
This enumeration defines the type of axis.
struct MlpiAxisScalingAcceleration MlpiAxisScalingAcceleration
The following struct helps to encode or decode the velocity scaling settings of the axis given or set...
The following struct helps to encode or decode the position scaling settings of the axis given or set...
struct MlpiAxisRef MlpiAxisRef
This structure defines the axis through the definition of control and axis number.
MlpiAxisCondition
This enumeration defines the state of an axis.
Virtual axis, no physical drive attached.
struct MlpiAxisScalingPosition MlpiAxisScalingPosition
The following struct helps to encode or decode the position scaling settings of the axis given or set...
unsigned long MLPIHANDLE
common MLPI-API handle value
The following struct helps to encode or decode the velocity scaling settings of the axis given or set...
#define MLPI_INFINITE
Infinite timeout value.
MLPIRESULT utilMotionWaitAxisInterrupted(MLPIHANDLE connection, MlpiAxisRef axis, const ULONG timeout=MLPI_INFINITE)
This function waits that the axis is no longer interrupted.
int MLPIRESULT
common MLPI-API return value
Real axis, this is the common axis when doing motion.
struct MlpiAxisScalingTorque MlpiAxisScalingTorque
The following struct helps to encode or decode the torque scaling settings of the axis given or set b...
The following struct helps to encode or decode the velocity scaling settings of the axis given or set...