- Fix: avoid infinite loop on mulitcast read thread if no data to read

Pre-ci test passed

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4000 818b1a75-f10b-46b9-bf7c-635c3b92a50f
This commit is contained in:
Cedric Roux
2013-06-25 09:05:02 +00:00
commit 56c66c09aa
4111 changed files with 2133103 additions and 0 deletions
+340
View File
@@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
+13
View File
@@ -0,0 +1,13 @@
OMV: openair mobility visualisor
To compile:
1. install the required package: apt-get install qtcreator or go to http://qt.nokia.com/downloads to download the SDK
and install manually
2. to generate the .pro used to setup the make files, run: qmake -project QT+=opengl LIBS+=-lGLU
3. to generate the Makefile: qmake-qt4
4. to compile: make all
if the glut library is not installed, install it with: sudo apt-get install freeglut3 freeglut3-dev
For newer versions of Ubuntu (>= 11.10) you have to install another package: sudo apt-get install binutils-gold
To Test in standalone mode :
./OMV (for the moment, it only displays the window and default values for the area dimensions and node number)
Binary file not shown.

After

Width:  |  Height:  |  Size: 218 B

+205
View File
@@ -0,0 +1,205 @@
/*******************************************************************************
Eurecom OpenAirInterface 2
Copyright(c) 1999 - 2010 Eurecom
This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
version 2, as published by the Free Software Foundation.
This program is distributed in the hope it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
The full GNU General Public License is included in this distribution in
the file called "COPYING".
Contact Information
Openair Admin: openair_admin@eurecom.fr
Openair Tech : openair_tech@eurecom.fr
Forums : http://forums.eurecom.fsr/openairinterface
Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis, France
*******************************************************************************/
/*! \file communicationthread.cpp
* \brief this thread is to process the communication between the simulator and the visualisor
* \author M. Mosli
* \date 2012
* \version 0.1
* \company Eurecom
* \email: mosli@eurecom.fr
*/
#include "communicationthread.h"
typedef struct {
char *name; /*!< \brief string name of item */
int value; /*!< \brief integer value of mapping */
} mapping;
mapping omg_model_names[] = {
{"STATIC", 0},
{"RWP", 1},
{"RWALK", 2},
{"TRACE", 3},
{"SUMO", 4},
{NULL, -1}
};
mapping state_model_names[] = {
{"NOT_SYNC", 0},
{"SYNCED", 1},
{"CONNECTED", 2},
{"ATTACHED", 3},
{"DATA_COMMUNICATION", 4},
{NULL, -1}
};
/* map an int to a string. Takes a mapping array and a value */
char *map_int_to_str(mapping *map, int val) {
while (1) {
if (map->name == NULL) {
return NULL;
}
if (map->value == val) {
return map->name;
}
map++;
}
}
// mobtype = map_int_to_str(omg_model_names,omv_data.geo[i].mobility_type)
extern int pfd[2];
extern struct Geo geo[NUMBER_OF_eNB_MAX+NUMBER_OF_UE_MAX];
extern int nb_frames;
extern int node_number;
extern int nb_enb;
extern int nb_ue;
extern int nb_antennas_rx;
CommunicationThread::CommunicationThread(MyWindow* window){
this->window = window;
QObject::connect(this, SIGNAL(newData(QString, int)), window, SLOT(writeToConsole(QString, int)));
QObject::connect(this, SIGNAL(newPosition()), window->getGL(), SLOT(drawNewPosition()));
QObject::connect(this, SIGNAL(endOfTheSimulation()), window, SLOT(endOfTheSimulation()));
}
void CommunicationThread::run()
{
int nread;
int end = 0;
int counter = nb_frames;
Data_Flow_Unit data;
while (counter > 0 && !end){
switch( nread = read(pfd[0], &data, sizeof(Data_Flow_Unit))) {
case -1 :
if (counter < nb_frames)
end = 1;
perror( "read" );
break;
case 0 :
if (counter < nb_frames)
end = 1;
perror( "EOF" );
break;
default :
QString information, information_for_a_node, format_information;
geo[nb_enb].mobility_type = data.geo[nb_enb].mobility_type;
information.sprintf("\nFrame: %d\n\n",nb_frames - counter);
format_information.sprintf("Format of Log: (<X> is X's value)\nFor eNb :: [eNb <Id>] at <Mob_type>(<Position>) with <nb_connected_ue> connected UE\nFor UE :: [UE <Id>][RNTI <rnti>][state <state>] at <Mob_type>(<Position>), PL=<Pathloss>, RSRP=<rsrp>, RSRQ=<rsrq>, from eNb <connected eNb>\n==========================================================\n");
information += format_information;
end = data.end;
for (int i = 0; i<nb_enb; i++){
geo[i].Neighbors = data.geo[i].Neighbors;
geo[i].x = data.geo[i].x;
geo[i].y = data.geo[i].y;
geo[i].node_type = data.geo[i].node_type;
geo[i].mobility_type = data.geo[i].mobility_type;
information_for_a_node.sprintf("[eNb %d] at %s(%d,%d) with %d connected UE\n" , i,
map_int_to_str(omg_model_names, geo[i].mobility_type),
data.geo[i].x, data.geo[i].y,
data.geo[i].Neighbors );
information += information_for_a_node;
for(int j = 0; j<data.geo[i].Neighbors; j++)
geo[i].Neighbor[j] = data.geo[i].Neighbor[j];
}
QString state_str;
for (int i = nb_enb; i<node_number; i++){
geo[i].Neighbors = data.geo[i].Neighbors;
geo[i].x = data.geo[i].x;
geo[i].y = data.geo[i].y;
geo[i].node_type = data.geo[i].node_type;
geo[i].state = data.geo[i].state;
geo[i].connected_eNB = data.geo[i].connected_eNB;
geo[i].rnti = data.geo[i].rnti;
geo[i].RSRP = data.geo[i].RSRP;
geo[i].RSRQ = data.geo[i].RSRQ;
geo[i].Pathloss = data.geo[i].Pathloss;
geo[i].mobility_type = data.geo[i].mobility_type;
for (int ant = 0; ant < nb_antennas_rx; ant++){
geo[i].RSSI[ant] = data.geo[i].RSSI[ant];
}
information_for_a_node.sprintf("[UE %d][RNTI %d][state %s] at %s(%d,%d), PL=%d, RSRP=%d, RSRQ=%d, from eNb %d\n" ,
i - nb_enb, geo[i].rnti,map_int_to_str(state_model_names, geo[i].state),
map_int_to_str(omg_model_names, geo[i].mobility_type),
geo[i].x, geo[i].y,
geo[i].Pathloss, geo[i].RSRP, geo[i].RSRQ,
geo[i].connected_eNB);
information += information_for_a_node;
for(int j = 0; j<data.geo[i].Neighbors; j++)
geo[i].Neighbor[j] = data.geo[i].Neighbor[j];
}
emit newData(information, nb_frames - counter);
emit newPosition();
break;
}
counter--;
}
sleep(30);
emit endOfTheSimulation();
/*
switch(nread = read(pfd[0], &final, sizeof(Final_Data))){
case -1 :
perror( "read" );
break;
case 0 :
perror( "EOF" );
break;
default :
QString final_data;
final_data.sprintf("\n*** Final results ***\n\n* Node number: %d\n* Loss rate: %f\n* All forwarded packets: %d\n* Used memory [device, host]: [%d, %d]\n* Elapsed time (average): %f\n* Elapsed time (min): %f\n* Elapsed time (max): %f\n",final.node_number, final.loss, final.forwarded,final.device_memory, final.host_memory,final.average_time, final.min_time, final.max_time);
emit newData(final_data);
emit endOfTheSimulation();
break;
}
*/
}
+66
View File
@@ -0,0 +1,66 @@
/*******************************************************************************
Eurecom OpenAirInterface 2
Copyright(c) 1999 - 2010 Eurecom
This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
version 2, as published by the Free Software Foundation.
This program is distributed in the hope it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
The full GNU General Public License is included in this distribution in
the file called "COPYING".
Contact Information
Openair Admin: openair_admin@eurecom.fr
Openair Tech : openair_tech@eurecom.fr
Forums : http://forums.eurecom.fsr/openairinterface
Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis, France
*******************************************************************************/
/*! \file communicationthread.h
* \brief this thread is to process the communication between the simulator and the visualisor
* \author M. Mosli
* \date 2012
* \version 0.1
* \company Eurecom
* \email: mosli@eurecom.fr
*/
#ifndef COMMUNICATIONTHREAD_H
#define COMMUNICATIONTHREAD_H
#include <QThread>
#include <QDebug>
#include <QTextEdit>
#include "mywindow.h"
#include "structures.h"
class CommunicationThread : public QThread
{
Q_OBJECT
public:
CommunicationThread(MyWindow* window);
signals:
void newData(QString data, int frame);
void newPosition();
void endOfTheSimulation();
private:
void run();
MyWindow* window;
};
#endif // COMMUNICATIONTHREAD_H
Binary file not shown.

After

Width:  |  Height:  |  Size: 218 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1017 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

+481
View File
@@ -0,0 +1,481 @@
/*******************************************************************************
Eurecom OpenAirInterface 2
Copyright(c) 1999 - 2010 Eurecom
This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
version 2, as published by the Free Software Foundation.
This program is distributed in the hope it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
The full GNU General Public License is included in this distribution in
the file called "COPYING".
Contact Information
Openair Admin: openair_admin@eurecom.fr
Openair Tech : openair_tech@eurecom.fr
Forums : http://forums.eurecom.fsr/openairinterface
Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis, France
*******************************************************************************/
/*! \file mywindow.cpp
* \brief manages the window and its components
* \author M. Mosli
* \date 2012
* \version 0.1
* \company Eurecom
* \email: mosli@eurecom.fr
*/
#include "mywindow.h"
#include "communicationthread.h"
#include <math.h>
#include <QGridLayout>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QCheckBox>
#include <QSlider>
#include <QString>
#include <QGroupBox>
#include <QIcon>
#include <QPixmap>
#include <QSpinBox>
#include <QFormLayout>
#include <QPalette>
#include <QFileDialog>
//extern pid_t simulator_pid;
extern int pfd[2];
extern struct Geo geo[NUMBER_OF_eNB_MAX+NUMBER_OF_UE_MAX];
extern CommunicationThread* communication_thread;
extern int x_area, y_area;
extern int nb_frames;
extern int nb_enb;
extern int nb_ue;
extern char frame_format[10];
extern int tdd_configuration;
int supervised_id = 0;
int nb_antennas_rx;
QString uri;
MyWindow::MyWindow() : QWidget()
{
pattern = 0;
this->setFixedSize(940, 820);
QObject::connect(this, SIGNAL(exitSignal()), qApp, SLOT(quit()));
/* Generic area widgets */
QString sim_data;
QLabel *area = new QLabel, *nbr_enb = new QLabel, *nbr_ue = new QLabel, *nbr_frames = new QLabel,
*frame_format_label = new QLabel, *tdd_label = new QLabel;
QGroupBox *generic = new QGroupBox("Generic Information", this);
QFormLayout *generic_layout = new QFormLayout;
generic_layout->setVerticalSpacing(10);
generic_layout->setHorizontalSpacing(20);
generic_frame = new QLabel("0");
sim_data.sprintf("<html>%dm x %dm</html>", x_area, y_area);
area->setText(sim_data);
sim_data.sprintf("<html>%d</html>", nb_enb);
nbr_enb->setText(sim_data);
sim_data.sprintf("<html>%d</html>", nb_ue);
nbr_ue->setText(sim_data);
sim_data.sprintf("<html>%d</html>", nb_frames);
nbr_frames->setText(sim_data);
sim_data.sprintf("<html>%s</html>", frame_format);
frame_format_label->setText(sim_data);
sim_data.sprintf("<html>%d</html>", tdd_configuration);
tdd_label->setText(sim_data);
generic_layout->addRow(new QLabel("<html><u>Area dimensions:</u></html>"), area);
generic_layout->addRow(new QLabel("<html><u>eNb node number:</u></html>"), nbr_enb);
generic_layout->addRow(new QLabel("<html><u>UE node number:</u></html>"), nbr_ue);
generic_layout->addRow(new QLabel("<html><u>Nb frames:</u></html>"), nbr_frames);
generic_layout->addRow(new QLabel("<html><u>Frame format:</u></html>"), frame_format_label);
generic_layout->addRow(new QLabel("<html><u>TDD configuration:</u></html>"), tdd_label);
generic_layout->addRow(new QLabel("<html><FONT COLOR='blue' >Frame:</FONT></html>"), generic_frame);
generic->setLayout(generic_layout);
/* Control widgets */
QCheckBox *drawConnections = new QCheckBox("Draw Connections");
drawConnections->setChecked(true);
QObject::connect(drawConnections, SIGNAL(stateChanged(int)), this, SLOT(setDrawConnections(int)));
QCheckBox *useMap = new QCheckBox("Use a Map");
useMap->setChecked(true);
QObject::connect(useMap, SIGNAL(stateChanged(int)), this, SLOT(setUseMap(int)));
QComboBox *nodes_color = new QComboBox(this);
QComboBox *links_color = new QComboBox(this);
used_map = new QComboBox(this);
QHBoxLayout *nodes_color_layout = new QHBoxLayout(this);
QHBoxLayout *links_color_layout = new QHBoxLayout(this);
QHBoxLayout *used_map_layout = new QHBoxLayout(this);
QLabel *nodes_color_label = new QLabel;
QLabel *links_color_label = new QLabel;
QLabel *used_map_label = new QLabel("Used map ");
nodes_color_label->setText("Nodes color ");
links_color_label->setText("Links color ");
QFrame *node_color_frame = new QFrame;
QFrame *link_color_frame = new QFrame;
QFrame *used_map_frame = new QFrame;
QString image;
uri.sprintf("%s/UTIL/OMV/",getenv("OPENAIR2_DIR"));
used_map->setIconSize(* (new QSize(20,20)));
image = "jpg.jpeg";
used_map->addItem(*(new QIcon (* (new QPixmap(uri + image))))," Import map");
image = "mus.png";
used_map->addItem(*(new QIcon (* (new QPixmap(uri + image))))," Mus");
image = "new.jpg";
used_map->addItem(*(new QIcon (* (new QPixmap(uri + image))))," Trefoil");
image = "new2.jpg";
used_map->addItem(*(new QIcon (* (new QPixmap(uri + image))))," Ocean");
image = "white.png";
used_map->addItem(*(new QIcon (* (new QPixmap(uri + image))))," White Bg");
image = "red.png";
used_map->addItem(*(new QIcon (* (new QPixmap(uri + image))))," Red Bg");
image = "green.png";
used_map->addItem(*(new QIcon (* (new QPixmap(uri + image))))," Green Bg");
image = "blue.png";
used_map->addItem(*(new QIcon (* (new QPixmap(uri + image))))," Blue Bg");
QObject::connect(used_map, SIGNAL(activated(int)), this, SLOT(setUsedMap(int)));
nodes_color->setIconSize(* (new QSize(30,15)));
image = "red.png";
nodes_color->addItem(*(new QIcon (* (new QPixmap(uri + image))))," Red");
image = "blue.png";
nodes_color->addItem(*(new QIcon (* (new QPixmap(uri + image))))," Blue");
image = "green.png";
nodes_color->addItem(*(new QIcon (* (new QPixmap(uri + image))))," Green");
image = "white.png";
nodes_color->addItem(*(new QIcon (* (new QPixmap(uri + image))))," White");
QObject::connect(nodes_color, SIGNAL(currentIndexChanged(int)), this, SLOT(setNodesColor(int)));
links_color->setIconSize(* (new QSize(30,15)));
image = "white.png";
links_color->addItem(*(new QIcon (* (new QPixmap(uri + image))))," White");
image = "red.png";
links_color->addItem(*(new QIcon (* (new QPixmap(uri + image))))," Red");
image = "blue.png";
links_color->addItem(*(new QIcon (* (new QPixmap(uri + image))))," Blue");
image = "green.png";
links_color->addItem(*(new QIcon (* (new QPixmap(uri + image))))," Green");
QObject::connect(links_color, SIGNAL(currentIndexChanged(int)), this, SLOT(setLinksColor(int)));
QFrame *node_size = new QFrame(this);
QLabel *nodes_size_label = new QLabel("<html><b>Size:</b></html>");
QLabel *min = new QLabel("Small");
QLabel *max = new QLabel("Big");
QSlider* size = new QSlider;
size->setMinimum(1);
size->setMaximum(3);
size->setValue(2);
size->setOrientation(Qt::Horizontal);
QObject::connect(size, SIGNAL(sliderMoved(int)), this, SLOT(updateSize(int)));
QHBoxLayout *size_layout = new QHBoxLayout;
size_layout->addWidget(nodes_size_label);
size_layout->addWidget(min);
size_layout->addWidget(size);
size_layout->addWidget(max);
node_size->setLayout(size_layout);
nodes_color_layout->addWidget(nodes_color_label);
nodes_color_layout->addWidget(nodes_color);
used_map_layout->addWidget(used_map_label);
used_map_layout->addWidget(used_map);
links_color_layout->addWidget(links_color_label);
links_color_layout->addWidget(links_color);
node_color_frame->setLayout(nodes_color_layout);
link_color_frame->setLayout(links_color_layout);
used_map_frame->setLayout(used_map_layout);
/* Specific node widgets */
QSpinBox* id_choice = new QSpinBox;
id_choice->setRange(0,nb_ue - 1);
QObject::connect(id_choice, SIGNAL(valueChanged(int)), this, SLOT(updateSupervNode(int)));
QGroupBox *specific = new QGroupBox("Specific Information", this);
QFormLayout *specific_layout = new QFormLayout;
specific_layout->setVerticalSpacing(10);
specific_layout->setHorizontalSpacing(40);
specific_position = new QLabel("(0,0)");
specific_state = new QLabel("Attached");
specific_dist = new QLabel("100");
specific_connected_enb = new QLabel("0");
specific_pathloss = new QLabel("0");
specific_rnti = new QLabel("0");
specific_rsrp = new QLabel("0");
specific_rsrq = new QLabel("0");
rssi_tab = new QLabel[nb_antennas_rx];
//ant_tab = new QLabel[nb_antennas_rx];
QHBoxLayout *rssi = new QHBoxLayout;
rssi->setSpacing(8);
//QVBoxLayout *specific_layout = new QVBoxLayout;
specific_layout->addRow(new QLabel("<html><b>UE Id </b></html>"), id_choice);
specific_layout->addRow(new QLabel("<html><b>Position </b></html>"), specific_position);
specific_layout->addRow(new QLabel("<html><b>State </b></html>"), specific_state);
specific_layout->addRow(new QLabel("<html><b>Connected eNb </b></html>"), specific_connected_enb);
specific_layout->addRow(new QLabel("<html><b>Dist. to eNb</b></html>"), specific_dist);
specific_layout->addRow(new QLabel("<html><b>Pathloss</b></html>"), specific_pathloss);
specific_layout->addRow(new QLabel("<html><b>RNTI</b></html>"), specific_rnti);
specific_layout->addRow(new QLabel("<html><b>RSRP</b></html>"), specific_rsrp);
specific_layout->addRow(new QLabel("<html><b>RSRQ</b></html>"), specific_rsrq);
rssi->addWidget(new QLabel("<html><b>RSSI </b></html>"));
for (int ant = 0; ant < nb_antennas_rx; ant++){
rssi_tab[ant].setAlignment(Qt::AlignCenter);
rssi_tab[ant].setText("-1"); // to be taken from geo (struct)
rssi_tab[ant].setFrameStyle( QFrame::Raised | QFrame::Box );
rssi_tab[ant].setFixedWidth(35);
rssi->addWidget(&rssi_tab[ant]);
}
specific_layout->addRow(rssi);
//specific_layout->addWidget(supervised_node);
specific->setLayout(specific_layout);
QGroupBox *cntl = new QGroupBox("Control Panel", this);
QVBoxLayout *cntl_layout = new QVBoxLayout;
cntl_layout->addWidget(drawConnections);
cntl_layout->addWidget(useMap);
cntl_layout->addWidget(used_map_frame);
cntl_layout->addWidget(node_color_frame);
cntl_layout->addWidget(link_color_frame);
cntl_layout->addWidget(node_size);
cntl->setLayout(cntl_layout);
/* Control area */
control_field = new QFrame(this);
control_field->setFrameShape(QFrame::StyledPanel);
control_field->setFrameStyle( QFrame::Sunken | QFrame::Panel );
control_field->setLineWidth( 2 );
QVBoxLayout *control_layout = new QVBoxLayout;
control_layout->addWidget(generic);
control_layout->addWidget(specific);
control_layout->addWidget(cntl);
control_field->setLayout(control_layout);
/* Drawing area */
openGL_field = new QFrame(this);
openGL_field->setFrameStyle( QFrame::Sunken | QFrame::Panel );
openGL_field->setLineWidth( 2 );
openGl = new OpenGLWidget();
openGl->setFixedSize(620,540);
QVBoxLayout *l1 = new QVBoxLayout;
l1->addWidget(openGl);
openGL_field->setLayout(l1);
/* Console area */
console_field = new QFrame(this);
output = new QTextEdit();
output->setReadOnly(true);
QVBoxLayout *l2 = new QVBoxLayout;
l2->addWidget(output);
console_field->setLayout(l2);
QGridLayout *layout = new QGridLayout;
layout->addWidget(openGL_field, 0, 0, 3, 3);
layout->addWidget(control_field, 0, 3, 4, 1);
layout->addWidget(console_field, 3, 0, 1, 3);
this->setLayout(layout);
communication_thread = new CommunicationThread(this);
communication_thread->start();
}
QTextEdit* MyWindow::getConsoleField(){
return this->output;
}
OpenGLWidget *MyWindow::getGL(){
return this->openGl;
}
void MyWindow::importMap(){
QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), uri, tr("Images (*.png *.jpeg *.jpg *.bmp *.gif)"));
openGl->setUsedMap(fileName);
}
void MyWindow::endOfTheSimulation(){
communication_thread->wait(); // do not exit before the thread is completed!
delete communication_thread;
emit exitSignal();
}
void MyWindow::setDrawConnections(int draw){
openGl->setDrawConnections(draw);
}
void MyWindow::setUseMap(int use){
if (!use)
used_map->setEnabled(false);
else
used_map->setEnabled(true);
openGl->setUseMap(use);
}
void MyWindow::setUsedMap(int map){
if (map > 0)
openGl->setUsedMap(map);
else
importMap();
}
void MyWindow::setNodesColor(int index){
openGl->setNodesColor(index);
}
void MyWindow::setLinksColor(int index){
openGl->setLinksColor(index);
}
void MyWindow::updateSize(int size){
openGl->updateNodeSize(size);
}
void MyWindow::updateSupervNode(int id){
supervised_id = id;
}
void MyWindow::updateSupervData(){
}
void MyWindow::writeToConsole(QString data, int frame){
this->output->append(data);
QString string;
//updating the generic information zone -- only the frame
string.sprintf("%d", frame);
generic_frame->setText(string);
//updating the specific information zone
//Updating position
string.sprintf("(%d,%d)",geo[supervised_id + nb_enb].x,geo[supervised_id + nb_enb].y);
specific_position->setText(string);
//Updating state
switch (geo[supervised_id + nb_enb].state) {
case 0:
specific_state->setText("NOT_SYNC");
break;
case 1:
specific_state->setText("SYNCED");
break;
case 2:
specific_state->setText("CONNECTED");
break;
case 3:
specific_state->setText("ATTACHED");
break;
case 4:
specific_state->setText("DATA_COMMUNICATION");
break;
}
//Updating connected eNb and distance to it
if (geo[supervised_id + nb_enb].Neighbors) {
int x1 = geo[geo[supervised_id + nb_enb].Neighbor[0]].x;
int x2 = geo[supervised_id + nb_enb].x;
int y1 = geo[geo[supervised_id + nb_enb].Neighbor[0]].y;
int y2 = geo[supervised_id + nb_enb].y;
float dist = sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
string.sprintf("%.2f", dist);
} else string = "-1";
specific_dist->setText(string);
if (geo[supervised_id + nb_enb].Neighbors) {
string.sprintf("%d", geo[supervised_id + nb_enb].Neighbor[0]);
} else string = "-1";
specific_connected_enb->setText(string);
//Updating pathloss
string.sprintf("%d", geo[supervised_id + nb_enb].Pathloss);
specific_pathloss->setText(string);
//Updating RNTI, RSRP and RSRQ
string.sprintf("%d", geo[supervised_id + nb_enb].rnti);
specific_rnti->setText(string);
string.sprintf("%d", geo[supervised_id + nb_enb].RSRP);
specific_rsrp->setText(string);
string.sprintf("%d", geo[supervised_id + nb_enb].RSRQ);
specific_rsrq->setText(string);
for (int ant = 0; ant < nb_antennas_rx; ant++) {
string.sprintf("%d", geo[supervised_id + nb_enb].RSSI[ant]);
rssi_tab[ant].setText(string);
}
}
MyWindow::~MyWindow(){
if (::close (pfd[0]) == -1 ) /* we close the read desc. */
perror( "close on read" );
delete rssi_tab;
}
+103
View File
@@ -0,0 +1,103 @@
/*******************************************************************************
Eurecom OpenAirInterface 2
Copyright(c) 1999 - 2010 Eurecom
This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
version 2, as published by the Free Software Foundation.
This program is distributed in the hope it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
The full GNU General Public License is included in this distribution in
the file called "COPYING".
Contact Information
Openair Admin: openair_admin@eurecom.fr
Openair Tech : openair_tech@eurecom.fr
Forums : http://forums.eurecom.fsr/openairinterface
Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis, France
*******************************************************************************/
/*! \file mywindow.h
* \brief manages the window and its components
* \author M. Mosli
* \date 2012
* \version 0.1
* \company Eurecom
* \email: mosli@eurecom.fr
*/
#ifndef MYWINDOW_H
#define MYWINDOW_H
#include <QPushButton>
#include <QFrame>
#include <QTextEdit>
#include <QLabel>
#include <QApplication>
#include <QComboBox>
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <signal.h>
#include "openglwidget.h"
class MyWindow : public QWidget
{
Q_OBJECT
public:
MyWindow();
QTextEdit* getConsoleField();
OpenGLWidget* getGL();
void importMap();
~MyWindow();
public slots:
void writeToConsole(QString data, int frame);
void endOfTheSimulation();
void setDrawConnections(int draw);
void setUseMap(int use);
void setUsedMap(int map);
void setNodesColor(int index);
void setLinksColor(int index);
void updateSize(int size);
void updateSupervNode(int id);
void updateSupervData();
signals:
void exitSignal();
private:
int pattern;
QComboBox *used_map;
QLabel *rssi_tab;
QLabel *specific_position;
QLabel *specific_state;
QLabel *specific_dist;
QLabel *specific_connected_enb;
QLabel *specific_pathloss;
QLabel *specific_rnti;
QLabel *specific_rsrp;
QLabel *specific_rsrq;
QLabel *generic_frame;
QLabel *simulation_data;
QFrame *control_field;
QFrame *openGL_field;
OpenGLWidget *openGl;
QFrame *console_field;
QTextEdit *output;
};
#endif // MYWINDOW_H
Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

+90
View File
@@ -0,0 +1,90 @@
/*******************************************************************************
Eurecom OpenAirInterface 2
Copyright(c) 1999 - 2010 Eurecom
This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
version 2, as published by the Free Software Foundation.
This program is distributed in the hope it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
The full GNU General Public License is included in this distribution in
the file called "COPYING".
Contact Information
Openair Admin: openair_admin@eurecom.fr
Openair Tech : openair_tech@eurecom.fr
Forums : http://forums.eurecom.fsr/openairinterface
Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis, France
*******************************************************************************/
/*! \file omv.cpp
* \brief openair mobility visualisor
* \author M. Mosli
* \date 2012
* \version 0.1
* \company Eurecom
* \email: mosli@eurecom.fr
*/
#include "mywindow.h"
#include <stdlib.h>
#include <sys/stat.h>
#include "communicationthread.h"
//pid_t simulator_pid;
int pfd[2];
struct Geo geo[NUMBER_OF_eNB_MAX+NUMBER_OF_UE_MAX];
int x_area, y_area, z_area;
int nb_frames;
int nb_enb;
int nb_ue;
int node_number;
char frame_format[10];
int tdd_configuration;
extern int nb_antennas_rx;
CommunicationThread* communication_thread;
void init_parameters(int frames, int num_enb, int num_ue, float x, float y, float z, int nb_antenna, char* frame_config, int tdd_config){
x_area = (x == 0) ? 1 : (int) x;
y_area = (y == 0) ? 1 : (int) y;
z_area = (z == 0) ? 1 : (int) z;
nb_enb = num_enb;
nb_ue = num_ue;
node_number = nb_enb + nb_ue;
nb_frames = frames;
nb_antennas_rx = nb_antenna;
strcpy(&frame_format[0], frame_config);
tdd_configuration= tdd_config;
}
int main(int argc, char *argv[]) {
if (argc <= 1)
init_parameters(100,1, 5, 5000.0,5000.0,1000.0, 4,"TDD", 3);
else {
init_parameters(atoi(argv[2]), atoi(argv[3]), atoi(argv[4]), atof(argv[5]),atof(argv[6]),atof(argv[7]),atoi(argv[8]), argv[9], atoi(argv[10]));
pfd[0]= atoi(argv[1]);
}
QApplication app(argc, argv);
MyWindow window;
window.move(*(new QPoint(150,100)));
window.show();
int end_value = app.exec();
return end_value;
}
+568
View File
@@ -0,0 +1,568 @@
/*******************************************************************************
Eurecom OpenAirInterface 2
Copyright(c) 1999 - 2010 Eurecom
This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
version 2, as published by the Free Software Foundation.
This program is distributed in the hope it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
The full GNU General Public License is included in this distribution in
the file called "COPYING".
Contact Information
Openair Admin: openair_admin@eurecom.fr
Openair Tech : openair_tech@eurecom.fr
Forums : http://forums.eurecom.fsr/openairinterface
Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis, France
*******************************************************************************/
/*! \file openglwidget.cpp
* \brief area devoted to draw the nodes and their connections
* \author M. Mosli
* \date 2012
* \version 0.1
* \company Eurecom
* \email: mosli@eurecom.fr
*/
#include "openglwidget.h"
#include <GL/glu.h>
#include <stdio.h>
extern struct Geo geo[NUMBER_OF_eNB_MAX+NUMBER_OF_UE_MAX];
extern int x_area;
extern int y_area;
extern int z_area;
extern int node_number;
extern int nb_enb;
int use_map = 1;
int node_color = 0;
int link_color = 0;
int w = 10, h = 16, sw = 24, sh = 22;
QString usedMap;
void drawMeter() {
glBegin(GL_LINES);
glVertex2d(-3,0);
glVertex2d(3,0);
glVertex2d(-3,0);
glVertex2d(-3,-5);
glVertex2d(0,0);
glVertex2d(0,-5);
glVertex2d(3,0);
glVertex2d(3,-5);
glEnd();
}
OpenGLWidget::OpenGLWidget()
{
geo[0].x = -1;
draw_connections = true;
QString uri;
QString image;
uri.sprintf("%s/UTIL/OMV/",getenv("OPENAIR2_DIR"));
image = "mus.png";
usedMap = uri + image;
}
void OpenGLWidget::paintGL()
{
glClearColor(0,0,0,0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
gluOrtho2D(0,620,0,540);
glColor3d(0,0,0);
if (use_map)
loadTexture();
glTranslated(50,20,0);
drawSquare(0, 0, 6, 10, 24, 24);
glTranslated(0,500,0);
drawMeter();
glTranslated(-10,0,0);
drawSquare(y_area % 10, 0, 6, 10, 24, 24);
glTranslated(10,0,0);
if (y_area >= 10) {
glTranslated(-20,0,0);
drawSquare((y_area % 100) / 10, 0, 6, 10, 24, 24);
glTranslated(20,0,0);
}
if (y_area >= 100) {
glTranslated(-30,0,0);
drawSquare((y_area % 1000) / 100, 0, 6, 10, 24, 24);
glTranslated(30,0,0);
}
if (y_area >= 1000) {
glTranslated(-40,0,0);
drawSquare(y_area / 1000, 0, 6, 10, 24, 24);
glTranslated(40,0,0);
}
glTranslated(561,-500,0);
drawMeter();
glTranslated(-10,0,0);
drawSquare(x_area % 10, 0, 6, 10, 24, 24);
glTranslated(10,0,0);
if (x_area >= 10) {
glTranslated(-20,0,0);
drawSquare((x_area % 100) / 10, 0, 6, 10, 24, 24);
glTranslated(20,0,0);
}
if (x_area >= 100) {
glTranslated(-30,0,0);
drawSquare((x_area % 1000) / 100, 0, 6, 10, 24, 24);
glTranslated(30,0,0);
}
if (x_area >= 1000) {
glTranslated(-40,0,0);
drawSquare(x_area / 1000, 0, 6, 10, 24, 24);
glTranslated(40,0,0);
}
//glTranslated(-1 * (x_area >= 1000 ? 601 : (x_area >= 100 ? 611 : (x_area >= 10 ? 621 : 631))),0,0);
glTranslated(-552,0,0);
drawGrid();
if (draw_connections)
drawConnections();
drawNodes();
}
void OpenGLWidget::loadTexture(){
QImage b;
glColor3d(255,255,255);
glEnable(GL_TEXTURE_2D);
textures[0] = bindTexture(QPixmap(usedMap), GL_TEXTURE_2D);
glBegin(GL_QUADS);
glTexCoord2d(0,1); glVertex2d(58,520);
glTexCoord2d(0,0); glVertex2d(58,20);
glTexCoord2d(1,0); glVertex2d(558,20);
glTexCoord2d(1,1); glVertex2d(558,520);
glEnd();
glDisable(GL_TEXTURE_2D);
}
void OpenGLWidget::drawNewPosition(){
updateGL();
}
void OpenGLWidget::setDrawConnections(int draw){
this->draw_connections = draw;
updateGL();
}
void OpenGLWidget::setUseMap(int use){
use_map = use;
updateGL();
}
void OpenGLWidget::setUsedMap(QString map_path){
usedMap = map_path;
}
void OpenGLWidget::setUsedMap(int map){
QString uri;
QString image;
uri.sprintf("%s/UTIL/OMV/",getenv("OPENAIR2_DIR"));
switch (map){
case 1:
image = "mus.png";
usedMap = uri + image;
break;
case 2:
image = "new.jpg";
usedMap = uri + image;
break;
case 3:
image = "new2.jpg";
usedMap = uri + image;
break;
case 4:
image = "white.png";
usedMap = uri + image;
break;
case 5:
image = "red.png";
usedMap = uri + image;
break;
case 6:
image = "green.png";
usedMap = uri + image;
break;
case 7:
image = "blue.png";
usedMap = uri + image;
break;
}
}
void OpenGLWidget::setNodesColor(int index){
node_color = index;
updateGL();
}
void OpenGLWidget::setLinksColor(int index){
link_color = index;
updateGL();
}
void OpenGLWidget::updateNodeSize(int size){
switch (size) {
case 1:
w = 8;
h = 12;
sw = 20;
sh = 18;
break;
case 2:
w = 10;
h = 16;
sw = 24;
sh = 22;
break;
case 3:
w = 12;
h = 20;
sw = 28;
sh = 26;
break;
}
updateGL();
}
OpenGLWidget::~OpenGLWidget(){
glDeleteTextures(1, textures);
}
void OpenGLWidget::drawConnections(){
for (int i=0; i<node_number; i++){
for (int j=i+1; j<node_number; j++){
int k=0;
while((geo[i].Neighbor[k]!=j)&&(k<geo[i].Neighbors)){
k++;
}
if(k < geo[i].Neighbors){
//glColor3d(255,255,255);
switch (link_color) {
case 1:
glColor3d(255,0,0);
break;
case 2:
glColor3d(0,0,255);
break;
case 3:
glColor3d(0,255,0);
break;
case 0:
glColor3d(255,255,255);
break;
}
//choose it according to the number of displayed nodes
glLineWidth(0.7);
glBegin(GL_LINES);
if (geo[i].node_type == 0)
glVertex2d((int)(((float)geo[i].x/(float)x_area)*500),(int)(((float)(geo[i].y + 2 * sh)/(float)y_area)*500));
else
glVertex2d((int)(((float)geo[i].x/(float)x_area)*500),(int)(((float)geo[i].y/(float)y_area)*500));
if (geo[j].node_type == 0)
glVertex2d((int)(((float)geo[j].x/(float)x_area)*500),(int)(((float)(geo[j].y + 2 * sh)/(float)y_area)*500));
else
glVertex2d((int)(((float)geo[j].x/(float)x_area)*500),(int)(((float)geo[j].y/(float)y_area)*500));
glEnd();
}
}
}
}
void OpenGLWidget::drawNodes(){
if (geo[0].x != -1){
glTranslated((int)(((float)geo[0].x/(float)x_area)*500), (int)(((float)geo[0].y/(float)y_area)*500),0);
//gluSphere(params,50,25,25);
if (geo[0].node_type == 0){
glColor3d(0,255,0);
drawBaseStation(0);
}else{
glColor3d(0,255,100);
drawSquare(0, 1, w, h, sw, sh);
}
for (int i=1; i<node_number; i++){
glTranslated((int)(((float)geo[i].x/(float)x_area)*500) - (int)(((float)geo[i-1].x/(float)x_area)*500),
(int)(((float)geo[i].y/(float)y_area)*500) - (int)(((float)geo[i-1].y/(float)y_area)*500),0);
if (geo[i].node_type == 0){
glColor3d(0,255,0);
drawBaseStation(i);
}else{
glColor3d(0,255,100);
drawSquare(i - nb_enb, 1, w, h, sw, sh);
}
}
glTranslated(-(int)(((float)geo[node_number - 1].x/(float)x_area)*500),-(int)(((float)geo[node_number - 1].y/y_area)*500),0);
}
}
void OpenGLWidget::drawGrid(){
glColor3d(0,0,255);
glLineWidth(1.0);
glBegin(GL_LINES);
/* Lines that are parallel to (Ox) */
for (int i=0; i <= y_area; i+= y_area){
glVertex2d(0,(int)(((float)i/(float)y_area)*500));
glVertex2d(500,(int)(((float)i/(float)y_area)*500));
}
/* Lines that are parallel to (Oy) */
for (int i=0; i <= x_area; i+= x_area){
glVertex2d((int)(((float)i/(float)x_area)*500),0);
glVertex2d((int)(((float)i/(float)x_area)*500),500);
}
glEnd();
}
void OpenGLWidget::drawSquare(int digit, int back, int w, int h, int sw, int sh){
glColor3d(0,255,100);
if (back == 1)
if (digit < 10 && digit >= 0) {
glBegin(GL_QUADS);
glVertex2d(-sw/2,-sh/2);
glVertex2d(-sw/2, sh/2);
glVertex2d( sw/2, sh/2);
glVertex2d( sw/2,-sh/2);
glEnd();
} else {
glBegin(GL_QUADS);
glVertex2d(-(sw*2)/3,-sh/2);
glVertex2d(-(sw*2)/3, sh/2);
glVertex2d( (sw*2)/3, sh/2);
glVertex2d( (sw*2)/3,-sh/2);
glEnd();
}
//draw the digit
//set the right color
if (back)
switch (node_color) {
case 0:
glColor3d(255,0,0);
break;
case 1:
glColor3d(0,0,255);
break;
case 2:
glColor3d(0,255,0);
break;
case 3:
glColor3d(255,255,255);
break;
}
else
glColor3d(255,0,0);
if (digit < 10 && digit >= 0) {
glBegin(GL_LINES);
switch (digit){
case 0:
glVertex2d(-w/2,h/2);
glVertex2d(w/2,h/2);
glVertex2d(-w/2,-h/2);
glVertex2d(w/2,-h/2);
glVertex2d(w/2,-h/2);
glVertex2d(w/2,h/2);
glVertex2d(-w/2,-h/2);
glVertex2d(-w/2,h/2);
break;
case 1:
glVertex2d(w/2,h/2);
glVertex2d(w/2,-h/2);
break;
case 2:
glVertex2d(-w/2,h/2);
glVertex2d(w/2,h/2);
glVertex2d(w/2,h/2);
glVertex2d(w/2,0);
glVertex2d(-w/2,0);
glVertex2d(w/2,0);
glVertex2d(-w/2,-h/2);
glVertex2d(-w/2,0);
glVertex2d(-w/2,-h/2);
glVertex2d(w/2,-h/2);
break;
case 3:
glVertex2d(w/2,h/2);
glVertex2d(w/2,-h/2);
glVertex2d(-w/2,h/2);
glVertex2d(w/2,h/2);
glVertex2d(w/2,0);
glVertex2d(-w/2,0);
glVertex2d(-w/2,-h/2);
glVertex2d(w/2,-h/2);
break;
case 4:
glVertex2d(w/2,-h/2);
glVertex2d(w/2,h/2);
glVertex2d(-w/2,h/2);
glVertex2d(-w/2,0);
glVertex2d(-w/2,0);
glVertex2d(w/2,0);
break;
case 5:
glVertex2d(-w/2,h/2);
glVertex2d(w/2,h/2);
glVertex2d(-w/2,h/2);
glVertex2d(-w/2,0);
glVertex2d(-w/2,0);
glVertex2d(w/2,0);
glVertex2d(w/2,-h/2);
glVertex2d(w/2,0);
glVertex2d(-w/2,-h/2);
glVertex2d(w/2,-h/2);
break;
case 6:
glVertex2d(-w/2,h/2);
glVertex2d(w/2,h/2);
glVertex2d(-w/2,h/2);
glVertex2d(-w/2,-h/2);
glVertex2d(-w/2,0);
glVertex2d(w/2,0);
glVertex2d(w/2,-h/2);
glVertex2d(w/2,0);
glVertex2d(-w/2,-h/2);
glVertex2d(w/2,-h/2);
break;
case 7:
glVertex2d(w/2,h/2);
glVertex2d(w/2,-h/2);
glVertex2d(-w/2,h/2);
glVertex2d(w/2,h/2);
break;
case 8:
glVertex2d(-w/2,0);
glVertex2d(w/2,0);
glVertex2d(-w/2,h/2);
glVertex2d(w/2,h/2);
glVertex2d(-w/2,-h/2);
glVertex2d(w/2,-h/2);
glVertex2d(w/2,-h/2);
glVertex2d(w/2,h/2);
glVertex2d(-w/2,0);
glVertex2d(-w/2,h/2);
break;
case 9:
glVertex2d(-w/2,0);
glVertex2d(w/2,0);
glVertex2d(-w/2,h/2);
glVertex2d(w/2,h/2);
glVertex2d(-w/2,-h/2);
glVertex2d(w/2,-h/2);
glVertex2d(w/2,-h/2);
glVertex2d(w/2,h/2);
glVertex2d(-w/2,-h/2);
glVertex2d(-w/2,h/2);
break;
}
glEnd();
} else {
glTranslated(w - 2,0,0);
drawSquare(digit % 10, 2, w, h, sw, sh);
glTranslated(-2 * w + 4 ,0,0);
drawSquare(digit / 10, 2, w, h, sw, sh);
glTranslated(w - 2,0,0);
}
}
void OpenGLWidget::drawBaseStation(int digit){
/* GLUquadric* params;
params = gluNewQuadric();
gluQuadricDrawStyle(params,GLU_FILL);
gluDisk(params,0,sw/2,20,1);
gluDeleteQuadric(params);*/
glLineWidth(2.0);
glBegin(GL_TRIANGLES);
glVertex2d(0,2*sh);
glVertex2d(-sw*2/3,-sh/2);
glVertex2d(sw*2/3,-sh/2);
glEnd();
drawSquare(digit, 2, w, h, sw, sh);
}
+82
View File
@@ -0,0 +1,82 @@
/*******************************************************************************
Eurecom OpenAirInterface 2
Copyright(c) 1999 - 2010 Eurecom
This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
version 2, as published by the Free Software Foundation.
This program is distributed in the hope it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
The full GNU General Public License is included in this distribution in
the file called "COPYING".
Contact Information
Openair Admin: openair_admin@eurecom.fr
Openair Tech : openair_tech@eurecom.fr
Forums : http://forums.eurecom.fsr/openairinterface
Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis, France
*******************************************************************************/
/*! \file openglwidget.cpp
* \brief area devoted to draw the nodes and their connections
* \author M. Mosli
* \date 2012
* \version 0.1
* \company Eurecom
* \email: mosli@eurecom.fr
*/
#ifndef OPENGLWIDGET_H
#define OPENGLWIDGET_H
#include <QGLWidget>
#include <QString>
#include "qgl.h"
#include "structures.h"
class OpenGLWidget : public QGLWidget
{
Q_OBJECT
public:
OpenGLWidget();
void drawGrid();
void drawNodes();
void loadTexture();
void drawConnections();
void drawSquare(int digit, int back, int w, int h, int sw, int sh);
void drawBaseStation(int digit);
void setDrawConnections(int draw);
void setUseMap(int use);
void setUsedMap(int map);
void setUsedMap(QString map_path);
void setLinksColor(int index);
void setNodesColor(int index);
void updateNodeSize(int size);
~OpenGLWidget();
protected:
void paintGL();
public slots:
void drawNewPosition();
private:
GLuint textures[9];
bool draw_connections;
QImage b_station;
};
#endif // OPENGLWIDGET_H
Binary file not shown.

After

Width:  |  Height:  |  Size: 220 B

+78
View File
@@ -0,0 +1,78 @@
/*******************************************************************************
Eurecom OpenAirInterface 2
Copyright(c) 1999 - 2010 Eurecom
This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
version 2, as published by the Free Software Foundation.
This program is distributed in the hope it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
The full GNU General Public License is included in this distribution in
the file called "COPYING".
Contact Information
Openair Admin: openair_admin@eurecom.fr
Openair Tech : openair_tech@eurecom.fr
Forums : http://forums.eurecom.fsr/openairinterface
Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis, France
*******************************************************************************/
/*! \file structures.h
* \brief structures used for the
* \author M. Mosli
* \date 2012
* \version 0.1
* \company Eurecom
* \email: mosli@eurecom.fr
*/
#ifndef STRUCTURES_H
#define STRUCTURES_H
#ifndef __PHY_IMPLEMENTATION_DEFS_H__
#define Maxneighbor 64
#define NUMBER_OF_UE_MAX 64
#define NUMBER_OF_eNB_MAX 3
#define NB_ANTENNAS_RX 4
#endif
//
// how to add an underlying map as OMV background
typedef struct Geo {
int x, y,z;
//int Speedx, Speedy, Speedz; // speeds in each of direction
int mobility_type; // model of mobility
int node_type;
int Neighbors; // number of neighboring nodes (distance between the node and its neighbors < 100)
int Neighbor[NUMBER_OF_UE_MAX]; // array of its neighbors
//relavent to UE only
unsigned short state;
unsigned short rnti;
unsigned int connected_eNB;
int RSSI[NB_ANTENNAS_RX];
int RSRP;
int RSRQ;
int Pathloss;
/// more info to display
} Geo;
typedef struct Data_Flow_Unit {
// int total_num_nodes;
struct Geo geo[NUMBER_OF_eNB_MAX+NUMBER_OF_UE_MAX];
int end;
}Data_Flow_Unit;
#endif // STRUCTURES_H
Binary file not shown.

After

Width:  |  Height:  |  Size: 218 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB