pdo_mapping_2WD_plus_auxiliary.h 3.07 KB
Newer Older
1
#pragma once
2 3 4 5 6 7 8 9 10

#ifdef DEF_2WD_PLUS_AUX

#if !defined (ORDINAL_IN_DATAGRAM_WD_MOTOR_LEFT)
#elif !defined (ORDINAL_IN_DATAGRAM_WD_MOTOR_RIGHT)
#elif !defined (ORDINAL_IN_DATAGRAM_AUX_MOTOR)
#error "ORDINAL_IN_DATAGRAM of motors need to be defined"
#endif

11
#include "pdo_mapping_motors.h"
12
#include "motor_manager.h"
13

14
namespace {
15 16 17
	Motor::node_id_t NodeIdLeftMotor =1;
	Motor::node_id_t NodeIdRightMotor =2;
	Motor::node_id_t NodeIdAuxiliaryMotorOne =3;
18 19 20
}

class MotorManagerWD final: public MotorManager,
21 22
public Singleton<MotorManagerWD> {
	friend class Singleton<MotorManagerWD>;
23
public:
24 25
	~MotorManagerWD() {
	}
26

27
private:
28
	Motor mMotorLeft;
29 30
	Motor mMotorRight;

31
protected:
32
	MotorManagerWD() :
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
	mMotorLeft(NodeIdLeftMotor, "MotorLeft", ORDINAL_IN_DATAGRAM_WD_MOTOR_LEFT),
	mMotorRight(NodeIdRightMotor, "MotorRight", ORDINAL_IN_DATAGRAM_WD_MOTOR_RIGHT)
	{
		mMotorLeft.getPdoHandle()->status_word.updateMapping(0xA100, 1);
		mMotorLeft.getPdoHandle()->mode_of_operation_display.updateMapping(0xA000, 1);
		mMotorLeft.getPdoHandle()->position_actual_value.updateMapping(0xA1C0, 1);
		mMotorLeft.getPdoHandle()->velocity_actual_value.updateMapping(0xA1C0, 2);
		mMotorLeft.getPdoHandle()->control_word.updateMapping(0xA580, 1);
		mMotorLeft.getPdoHandle()->mode_of_operation.updateMapping(0xA480, 1);
		mMotorLeft.getPdoHandle()->target_position.updateMapping(0xA640, 1);
		mMotorLeft.getPdoHandle()->target_velocity.updateMapping(0xA640, 2);

		mMotorRight.getPdoHandle()->status_word.updateMapping(0xA100, 2);
		mMotorRight.getPdoHandle()->mode_of_operation_display.updateMapping(0xA000, 2);
		mMotorRight.getPdoHandle()->position_actual_value.updateMapping(0xA1C0, 3);
		mMotorRight.getPdoHandle()->velocity_actual_value.updateMapping(0xA1C0, 4);
		mMotorRight.getPdoHandle()->control_word.updateMapping(0xA580, 2);
		mMotorRight.getPdoHandle()->mode_of_operation.updateMapping(0xA480, 2);
		mMotorRight.getPdoHandle()->target_position.updateMapping(0xA640, 3);
		mMotorRight.getPdoHandle()->target_velocity.updateMapping(0xA640, 4);

		AddMotor(&mMotorLeft);
		AddMotor(&mMotorRight);
56 57 58 59
	}
};

class MotorManagerAux final: public MotorManager,
60 61
public Singleton<MotorManagerAux> {
	friend class Singleton<MotorManagerAux>;
62 63 64 65 66 67 68 69 70
public:
	~MotorManagerAux() {
	}

private:
	Motor mMotorAuxiliaryOne;

protected:
	MotorManagerAux() :
71 72 73 74 75 76 77 78 79 80 81 82
	mMotorAuxiliaryOne(NodeIdAuxiliaryMotorOne, "MotorAuxiliaryOne", ORDINAL_IN_DATAGRAM_AUX_MOTOR)
	{
		mMotorAuxiliaryOne.getPdoHandle()->status_word.updateMapping(0xA100, 3);
		mMotorAuxiliaryOne.getPdoHandle()->mode_of_operation_display.updateMapping(0xA000, 3);
		mMotorAuxiliaryOne.getPdoHandle()->position_actual_value.updateMapping(0xA1C0, 5);
		mMotorAuxiliaryOne.getPdoHandle()->velocity_actual_value.updateMapping(0xA1C0, 6);
		mMotorAuxiliaryOne.getPdoHandle()->control_word.updateMapping(0xA580, 3);
		mMotorAuxiliaryOne.getPdoHandle()->mode_of_operation.updateMapping(0xA480, 3);
		mMotorAuxiliaryOne.getPdoHandle()->target_position.updateMapping(0xA640, 5);
		mMotorAuxiliaryOne.getPdoHandle()->target_velocity.updateMapping(0xA640, 6);

		AddMotor(&mMotorAuxiliaryOne);
83 84 85
	}
};

86
#endif /* DEF_2WD_PLUS_AUX */