A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
logical-lora-channel.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017 University of Padova
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Davide Magrin <magrinda@dei.unipd.it>
18 */
19
21
22#include "ns3/log.h"
23
24namespace ns3
25{
26namespace lorawan
27{
28
29NS_LOG_COMPONENT_DEFINE("LogicalLoraChannel");
30
31NS_OBJECT_ENSURE_REGISTERED(LogicalLoraChannel);
32
33TypeId
35{
36 static TypeId tid =
37 TypeId("ns3::LogicalLoraChannel").SetParent<Object>().SetGroupName("lorawan");
38 return tid;
39}
40
42 : m_frequency(0),
43 m_minDataRate(0),
44 m_maxDataRate(5),
45 m_enabledForUplink(true)
46{
47 NS_LOG_FUNCTION(this);
48}
49
51{
52 NS_LOG_FUNCTION(this);
53}
54
56 : m_frequency(frequency),
57 m_enabledForUplink(true)
58{
59 NS_LOG_FUNCTION(this);
60}
61
62LogicalLoraChannel::LogicalLoraChannel(double frequency, uint8_t minDataRate, uint8_t maxDataRate)
63 : m_frequency(frequency),
64 m_minDataRate(minDataRate),
65 m_maxDataRate(maxDataRate),
66 m_enabledForUplink(true)
67{
68 NS_LOG_FUNCTION(this);
69}
70
71double
73{
74 return m_frequency;
75}
76
77void
79{
80 m_minDataRate = minDataRate;
81}
82
83void
85{
86 m_maxDataRate = maxDataRate;
87}
88
89uint8_t
91{
92 return m_minDataRate;
93}
94
95uint8_t
97{
98 return m_maxDataRate;
99}
100
101void
103{
104 m_enabledForUplink = true;
105}
106
107void
109{
110 m_enabledForUplink = false;
111}
112
113bool
115{
116 return m_enabledForUplink;
117}
118
119bool
121{
122 double thisFreq = first->GetFrequency();
123 double otherFreq = second->GetFrequency();
124
125 NS_LOG_DEBUG("Checking equality between logical lora channels: " << thisFreq << " "
126 << otherFreq);
127
128 NS_LOG_DEBUG("Result:" << (thisFreq == otherFreq));
129 return (thisFreq == otherFreq);
130}
131
132bool
134{
135 return !(first == second);
136}
137} // namespace lorawan
138} // namespace ns3
A base class which provides memory management and object aggregation.
Definition: object.h:89
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
uint8_t m_minDataRate
The minimum data rate that is allowed on this channel.
uint8_t GetMaximumDataRate() const
Get the maximum data rate that is allowed on this channel.
LogicalLoraChannel()
Default constructor.
static TypeId GetTypeId()
Register this type.
void SetMinimumDataRate(uint8_t minDataRate)
‍**
double GetFrequency() const
Get the frequency (MHz).
~LogicalLoraChannel() override
Destructor.
double m_frequency
The central frequency of this channel, in MHz.
void SetEnabledForUplink()
Set this channel as enabled for uplink.
void DisableForUplink()
Set this channel as disabled for uplink.
void SetMaximumDataRate(uint8_t maxDataRate)
Set the maximum data rate that is allowed on this channel.
bool IsEnabledForUplink() const
Test whether this channel is marked as enabled for uplink.
bool m_enabledForUplink
Whether this channel can be used for uplink or not.
uint8_t GetMinimumDataRate() const
Get the minimum data rate that is allowed on this channel.
uint8_t m_maxDataRate
The maximum data rate that is allowed on this channel.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Definition: first.py:1
bool operator!=(const Ptr< LogicalLoraChannel > &first, const Ptr< LogicalLoraChannel > &second)
Overload the != operator to compare different instances of the same LogicalLoraChannel.
bool operator==(const Ptr< LogicalLoraChannel > &first, const Ptr< LogicalLoraChannel > &second)
Overload of the == operator to compare different instances of the same LogicalLoraChannel.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Definition: second.py:1