- add SensorState

- add Singleton template
This commit is contained in:
ROBOTIS-zerom
2016-05-17 20:41:14 +09:00
parent 9e1300eeda
commit 2f18b587de
10 changed files with 207 additions and 67 deletions

View File

@ -5,11 +5,13 @@
* Author: zerom
*/
#ifndef ROBOTIS_FRAMEWORK_ROBOTIS_CONTROLLER_INCLUDE_DEVICE_DYNAMIXELSTATE_H_
#define ROBOTIS_FRAMEWORK_ROBOTIS_CONTROLLER_INCLUDE_DEVICE_DYNAMIXELSTATE_H_
#ifndef ROBOTIS_DEVICE_INCLUDE_ROBOTIS_DEVICE_DYNAMIXELSTATE_H_
#define ROBOTIS_DEVICE_INCLUDE_ROBOTIS_DEVICE_DYNAMIXELSTATE_H_
#include <stdint.h>
#include <robotis_framework_common/RobotisDef.h>
#include "robotis_device/TimeStamp.h"
#include "robotis_framework_common/RobotisDef.h"
#define INDIRECT_DATA_1 "indirect_data_1"
#define INDIRECT_ADDRESS_1 "indirect_address_1"
@ -17,13 +19,6 @@
namespace ROBOTIS
{
class TimeStamp {
public:
long sec;
long nsec;
TimeStamp(long sec, long nsec) : sec(sec), nsec(nsec) { }
};
class DynamixelState
{
public:
@ -57,4 +52,4 @@ public:
}
#endif /* ROBOTIS_FRAMEWORK_ROBOTIS_CONTROLLER_INCLUDE_DEVICE_DYNAMIXELSTATE_H_ */
#endif /* ROBOTIS_DEVICE_INCLUDE_ROBOTIS_DEVICE_DYNAMIXELSTATE_H_ */

View File

@ -12,6 +12,7 @@
#include <string>
#include <stdint.h>
#include "Device.h"
#include "SensorState.h"
#include "ControlTableItem.h"
namespace ROBOTIS
@ -19,8 +20,9 @@ namespace ROBOTIS
class Sensor : public Device
{
std::map<std::string, double> sensed_value;
public:
SensorState *sensor_state;
Sensor(int id, std::string model_name, float protocol_version);
};

View File

@ -0,0 +1,35 @@
/*
* SensorState.h
*
* Created on: 2016. 5. 16.
* Author: zerom
*/
#ifndef ROBOTIS_DEVICE_INCLUDE_ROBOTIS_DEVICE_SENSORSTATE_H_
#define ROBOTIS_DEVICE_INCLUDE_ROBOTIS_DEVICE_SENSORSTATE_H_
#include "robotis_device/TimeStamp.h"
#include "robotis_framework_common/RobotisDef.h"
namespace ROBOTIS
{
class SensorState
{
public:
TimeStamp update_time_stamp;
std::map<std::string, UINT32_T> bulk_read_table;
SensorState()
: update_time_stamp(0, 0)
{
bulk_read_table.clear();
}
};
}
#endif /* ROBOTIS_DEVICE_INCLUDE_ROBOTIS_DEVICE_SENSORSTATE_H_ */

View File

@ -0,0 +1,25 @@
/*
* TimeStamp.h
*
* Created on: 2016. 5. 16.
* Author: zerom
*/
#ifndef ROBOTIS_DEVICE_INCLUDE_ROBOTIS_DEVICE_TIMESTAMP_H_
#define ROBOTIS_DEVICE_INCLUDE_ROBOTIS_DEVICE_TIMESTAMP_H_
namespace ROBOTIS
{
class TimeStamp {
public:
long sec;
long nsec;
TimeStamp(long sec, long nsec) : sec(sec), nsec(nsec) { }
};
}
#endif /* ROBOTIS_DEVICE_INCLUDE_ROBOTIS_DEVICE_TIMESTAMP_H_ */

View File

@ -17,5 +17,7 @@ Sensor::Sensor(int id, std::string model_name, float protocol_version)
this->protocol_version = protocol_version;
ctrl_table.clear();
sensor_state = new SensorState();
bulk_read_items.clear();
}