00001
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include <math.h>
00037 #include "sensor_device.h"
00038
00039
00040 Sensor_device::Sensor_device() : Environ_object(0)
00041 {
00042 class_type = SensorClass;
00043 memset(name, '\0', MAX_NAME);
00044 memset(type, '\0', MAX_NAME);
00045 }
00046
00047
00048 Sensor_device::Sensor_device(unsigned long id, char *t)
00049 : Environ_object(id)
00050 {
00051 class_type = SensorClass;
00052 memset(name, '\0', MAX_NAME);
00053 strncpy(type, t, MAX_NAME);
00054 }
00055
00056
00057 Sensor_device::~Sensor_device()
00058 {
00059 delete(data_buf);
00060 }
00061
00062
00063 void Sensor_device::set_data(const char *buf, int len)
00064 {
00065 if (data_buf != 0)
00066 free(data_buf);
00067 data_buf = new char[len + 1];
00068 memset(data_buf, '\0', len + 1);
00069 strncpy(data_buf, buf, len);
00070 }
00071
00072
00073 void Sensor_device::sq_dist_attenuate(Signal *signal, double distance)
00074 {
00075 unsigned int i;
00076 for (i = 0; i < signal->number; i++)
00077 signal->components[i].amplitude *=
00078 (long) (1.0 / pow(distance, 2));
00079 }
00080
00081
00082 void Sensor_device::wavefront_propagation(Signal signal)
00083 {
00084
00085 }