N-sim
Emulation and simulation of
Wireless Sensor Networks



   Home


   Project Page


   Download


   CVS



   Installation


   Configuration


   Plug-ins




 Hosted by
SourceForge.net Logo

/home/brennan/n-sim/OrbisQuartus/shared/sensor_device.cpp

Go to the documentation of this file.
00001 
00014 /*
00015  * Copyright 2007. Los Alamos National Security, LLC. This material
00016  * was produced under U.S. Government contract DE-AC52-06NA25396 for
00017  * Los Alamos National Laboratory (LANL), which is operated by Los
00018  * Alamos National Security, LLC, for the Department of Energy. The
00019  * U.S. Government has rights to use, reproduce, and distribute this
00020  * software. NEITHER THE GOVERNMENT NOR LOS ALAMOS NATIONAL SECURITY,
00021  * LLC, MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES ANY LEGAL
00022  * LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified to
00023  * produce derivative works, such modified software should be clearly
00024  * marked, so as not to confuse it with the version available from LANL.
00025  *
00026  * Additionally, this program is free software; you can redistribute
00027  * it and/or modify it under the terms of the GNU General Public
00028  * License as published by the Free Software Foundation; version 2 of
00029  * the License. Accordingly, this program is distributed in the hope
00030  * it will be useful, but WITHOUT ANY WARRANTY; without even the
00031  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00032  * PURPOSE. See the GNU General Public License for more details.
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 }


© 2007, Los Alamos National Security, LLC.