Laser720Interface.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <interfaces/Laser720Interface.h>
00025
00026 #include <core/exceptions/software.h>
00027
00028 #include <cstring>
00029 #include <cstdlib>
00030
00031 namespace fawkes {
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 Laser720Interface::Laser720Interface() : Interface()
00046 {
00047 data_size = sizeof(Laser720Interface_data_t);
00048 data_ptr = malloc(data_size);
00049 data = (Laser720Interface_data_t *)data_ptr;
00050 memset(data_ptr, 0, data_size);
00051 add_fieldinfo(IFT_FLOAT, "distances", 720, &data->distances);
00052 unsigned char tmp_hash[] = {0xc6, 0x5c, 0xe2, 0xcd, 0x6, 0x6c, 0xdb, 0x3f, 0x8c, 0x81, 0x78, 0xe1, 0xba, 0xf4, 0xc5, 0x17};
00053 set_hash(tmp_hash);
00054 }
00055
00056
00057 Laser720Interface::~Laser720Interface()
00058 {
00059 free(data_ptr);
00060 }
00061
00062
00063
00064
00065
00066
00067
00068 float *
00069 Laser720Interface::distances() const
00070 {
00071 return data->distances;
00072 }
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082 float
00083 Laser720Interface::distances(unsigned int index) const
00084 {
00085 if (index > 720) {
00086 throw Exception("Index value %u out of bounds (0..720)", index);
00087 }
00088 return data->distances[index];
00089 }
00090
00091
00092
00093
00094
00095 size_t
00096 Laser720Interface::maxlenof_distances() const
00097 {
00098 return 720;
00099 }
00100
00101
00102
00103
00104
00105
00106
00107 void
00108 Laser720Interface::set_distances(const float * new_distances)
00109 {
00110 memcpy(data->distances, new_distances, sizeof(float) * 720);
00111 }
00112
00113
00114
00115
00116
00117
00118
00119
00120 void
00121 Laser720Interface::set_distances(unsigned int index, const float new_distances)
00122 {
00123 if (index > 720) {
00124 throw Exception("Index value %u out of bounds (0..720)", index);
00125 }
00126 data->distances[index] = new_distances;
00127 }
00128
00129 Message *
00130 Laser720Interface::create_message(const char *type) const
00131 {
00132 throw UnknownTypeException("The given type '%s' does not match any known "
00133 "message type for this interface type.", type);
00134 }
00135
00136
00137
00138
00139
00140 void
00141 Laser720Interface::copy_values(const Interface *other)
00142 {
00143 const Laser720Interface *oi = dynamic_cast<const Laser720Interface *>(other);
00144 if (oi == NULL) {
00145 throw TypeMismatchException("Can only copy values from interface of same type (%s vs. %s)",
00146 type(), other->type());
00147 }
00148 memcpy(data, oi->data, sizeof(Laser720Interface_data_t));
00149 }
00150
00151
00152
00153
00154
00155 bool
00156 Laser720Interface::message_valid(const Message *message) const
00157 {
00158 return false;
00159 }
00160
00161
00162 EXPORT_INTERFACE(Laser720Interface)
00163
00164
00165
00166 }