Posture.cc

00001 /* -*- mode:c++ -*- ********************************************************
00002  * file:        Posture.cc
00003  *
00004  * author:      Majid Nabi <m.nabi@tue.nl>
00005  *
00006  *
00007  *              http://www.es.ele.tue.nl/nes
00008  *
00009  * copyright:   (C) 2010 Electronic Systems group(ES),
00010  *              Eindhoven University of Technology (TU/e), the Netherlands.
00011  *
00012  *
00013  *              This program is free software; you can redistribute it
00014  *              and/or modify it under the terms of the GNU General Public
00015  *              License as published by the Free Software Foundation; either
00016  *              version 2 of the License, or (at your option) any later
00017  *              version.
00018  *              For further information see file COPYING
00019  *              in the top level directory
00020  ***************************************************************************
00021  * part of:    MoBAN (Mobility Model for wireless Body Area Networks)
00022  * description:     A class to store the specification of a posture
00023  ***************************************************************************
00024  * Citation of the following publication is appreciated if you use MoBAN for
00025  * a publication of your own.
00026  *
00027  * M. Nabi, M. Geilen, T. Basten. MoBAN: A Configurable Mobility Model for Wireless Body Area Networks.
00028  * In Proc. of the 4th Int'l Conf. on Simulation Tools and Techniques, SIMUTools 2011, Barcelona, Spain, 2011.
00029  *
00030  * BibTeX:
00031  *    @inproceedings{MoBAN,
00032  *    author = "M. Nabi and M. Geilen and T. Basten.",
00033  *    title = "{MoBAN}: A Configurable Mobility Model for Wireless Body Area Networks.",
00034  *      booktitle = "Proceedings of the 4th Int'l Conf. on Simulation Tools and Techniques.",
00035  *      series = {SIMUTools '11},
00036  *      isbn = {978-963-9799-41-7},
00037  *      year = {2011},
00038  *      location = {Barcelona, Spain},
00039  *      publisher = {ICST} }
00040  *
00041  **************************************************************************/
00042 
00043 
00044 
00045 #include "Posture.h"
00046 
00047 Posture::Posture(unsigned int ID, unsigned int num)
00048 {
00049   postureID = ID;
00050   numNodes = num;
00051 
00052   nodePs = new Coord[numNodes];
00053   nodeRadius = new double[numNodes];
00054   nodeSpeed =  new double[numNodes];
00055 
00056   alphaMean = new double*[numNodes];
00057   for (unsigned int i=0;i<numNodes;++i)
00058     alphaMean[i] = new double[numNodes];
00059 
00060   alphaSD = new double*[numNodes];
00061   for (unsigned int i=0;i<numNodes;++i)
00062     alphaSD[i] = new double[numNodes];
00063 }
00064 
00065 bool Posture::setPs(unsigned int i , Coord ps)
00066 {
00067   if (i<numNodes){
00068     nodePs[i] = ps;
00069     return true;
00070   }
00071   return false;
00072 }
00073 
00074 bool Posture::setPostureName(char *str)
00075 {
00076   strcpy(posture_name,str);
00077   return true;
00078 }
00079 
00080 
00081 bool Posture::setAlphaMean(unsigned int i, unsigned int j, double alpha_mean)
00082 {
00083   if (i<numNodes && j<numNodes){
00084     alphaMean[i][j] = alpha_mean;
00085     return true;
00086   }
00087   return false;
00088 }
00089 
00090 bool Posture::setAlphaSD(unsigned int i, unsigned int j, double alpha_sd)
00091 {
00092   if (i<numNodes && j<numNodes){
00093     alphaSD[i][j] = alpha_sd;
00094     return true;
00095   }
00096   return false;
00097 }
00098 
00099 bool Posture::setRadius(unsigned int i, double radius)
00100 {
00101   if (i<numNodes){
00102     nodeRadius[i] = radius;
00103     return true;
00104   }
00105   return false;
00106 }
00107 
00108 bool Posture::setSpeed(unsigned int i , double speed)
00109 {
00110   if (i<numNodes){
00111     nodeSpeed[i] = speed;
00112     return true;
00113   }
00114   return false;
00115 }
00116 
00117 bool Posture::setPostureSpeed(double min, double max)
00118 {
00119   if (max < min)
00120     return false;
00121 
00122   postureMaxSpeed = max;
00123   postureMinSpeed = min;
00124   return true;
00125 }
00126 
00127 Coord  Posture::getPs(unsigned int i)
00128 {
00129   if (i<numNodes)
00130     return nodePs[i];
00131 
00132   return Coord(-1,-1,-1);
00133 }
00134 
00135 double Posture::getAlphaMean(unsigned int i, unsigned int j)
00136 {
00137   if (i<numNodes && j<numNodes)
00138     return alphaMean[i][j];
00139 
00140   return -1;
00141 }
00142 
00143 double Posture::getAlphaSD(unsigned int i, unsigned int j)
00144 {
00145   if (i<numNodes && j<numNodes)
00146     return alphaSD[i][j];
00147 
00148   return -1;
00149 }
00150 
00151 double Posture::getRadius(unsigned int i)
00152 {
00153   if (i<numNodes)
00154     return nodeRadius[i];
00155 
00156   return -1;
00157 }
00158 
00159 double Posture::getSpeed(unsigned int i)
00160 {
00161   if (i<numNodes)
00162     return nodeSpeed[i];
00163 
00164   return -1;
00165 }
00166 
00167 char* Posture::getPostureName()
00168 {
00169   return posture_name;
00170 }
00171 
00172 int Posture::getPostureID()
00173 {
00174   return postureID;
00175 }
00176 
00177 double Posture::getMaxSpeed()
00178 {
00179   return postureMaxSpeed;
00180 }
00181 
00182 double Posture::getMinSpeed()
00183 {
00184   return postureMinSpeed;
00185 }
00186 
00187 bool Posture::isMobile()
00188 {
00189   return postureMaxSpeed > 0;
00190 }