24 #include <interfaces/GripperInterface.h>
26 #include <core/exceptions/software.h>
47 GripperInterface::GripperInterface() : Interface()
49 data_size =
sizeof(GripperInterface_data_t);
50 data_ptr = malloc(data_size);
51 data = (GripperInterface_data_t *)data_ptr;
52 data_ts = (interface_data_ts_t *)data_ptr;
53 memset(data_ptr, 0, data_size);
54 enum_map_GripperState[(int)OPEN] =
"OPEN";
55 enum_map_GripperState[(int)CLOSED] =
"CLOSED";
56 add_fieldinfo(IFT_ENUM,
"gripper_state", 1, &data->gripper_state,
"GripperState", &enum_map_GripperState);
57 add_messageinfo(
"OpenGripperMessage");
58 add_messageinfo(
"CloseGripperMessage");
59 unsigned char tmp_hash[] = {0xf8, 0xd6, 0x88, 0xb4, 0xfc, 0xfa, 0x1f, 0x1b, 0x20, 0x9f, 0xc, 0xd, 0x81, 0x3c, 0xba, 0xdf};
64 GripperInterface::~GripperInterface()
73 GripperInterface::tostring_GripperState(GripperState value)
const
76 case OPEN:
return "OPEN";
77 case CLOSED:
return "CLOSED";
78 default:
return "UNKNOWN";
88 GripperInterface::GripperState
89 GripperInterface::gripper_state()
const
91 return (GripperInterface::GripperState)data->gripper_state;
99 GripperInterface::maxlenof_gripper_state()
const
111 GripperInterface::set_gripper_state(
const GripperState new_gripper_state)
113 data->gripper_state = new_gripper_state;
119 GripperInterface::create_message(
const char *type)
const
121 if ( strncmp(
"OpenGripperMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
123 }
else if ( strncmp(
"CloseGripperMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
127 "message type for this interface type.", type);
136 GripperInterface::copy_values(
const Interface *other)
138 const GripperInterface *oi =
dynamic_cast<const GripperInterface *
>(other);
140 throw TypeMismatchException(
"Can only copy values from interface of same type (%s vs. %s)",
141 type(), other->type());
143 memcpy(data, oi->data,
sizeof(GripperInterface_data_t));
147 GripperInterface::enum_tostring(
const char *enumtype,
int val)
const
149 if (strcmp(enumtype,
"GripperState") == 0) {
150 return tostring_GripperState((GripperState)val);
152 throw UnknownTypeException(
"Unknown enum type %s", enumtype);
164 GripperInterface::OpenGripperMessage::OpenGripperMessage() :
Message(
"OpenGripperMessage")
166 data_size =
sizeof(OpenGripperMessage_data_t);
169 data = (OpenGripperMessage_data_t *)
data_ptr;
171 enum_map_GripperState[(int)
OPEN] =
"OPEN";
172 enum_map_GripperState[(int)
CLOSED] =
"CLOSED";
189 data = (OpenGripperMessage_data_t *)
data_ptr;
214 data_size =
sizeof(CloseGripperMessage_data_t);
217 data = (CloseGripperMessage_data_t *)
data_ptr;
219 enum_map_GripperState[(int)
OPEN] =
"OPEN";
220 enum_map_GripperState[(int)
CLOSED] =
"CLOSED";
237 data = (CloseGripperMessage_data_t *)
data_ptr;
271 EXPORT_INTERFACE(GripperInterface)