ns-3 PLC model
model/plc-edge.h
00001 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
00002 /*
00003  * Copyright (c) YEAR COPYRIGHTHOLDER
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License version 2 as
00007  * published by the Free Software Foundation;
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017  *
00018  * Author: Alexander Schloegl <alexander.schloegl@gmx.de>
00019  */
00020 
00021 #ifndef PLC_EDGE_H
00022 #define PLC_EDGE_H
00023 
00024 #include <map>
00025 
00026 #include "plc-defs.h"
00027 #include "plc-cable.h"
00028 #include "plc-channel.h"
00029 
00030 namespace ns3 {
00031 
00032 class PLC_Node;
00033 class PLC_Cable;
00034 
00043 class PLC_Edge : public Object
00044 {
00045         friend class PLC_Graph;
00046         friend class PLC_Outlet;
00047 
00048 public:
00049         static TypeId GetTypeId(void);
00050 
00059         PLC_Edge(Ptr<const SpectrumModel> sm, Ptr<PLC_Node> from, Ptr<PLC_Node> to);
00060 
00065         virtual ~PLC_Edge() = 0;
00066 
00071         double GetLength(void) { return m_length; }
00072 
00076         void Lock() const { m_line_mutex.Lock(); }
00077 
00081         void Unlock() const { m_line_mutex.Unlock(); }
00082 
00088         PLC_Node *GetConnectedNode(PLC_Node *src_node);
00089 
00095         virtual void CalculateInputImpedance(PLC_Node *dst_node) = 0;
00096 
00102         virtual void CalculateEdgeTransferFactor(PLC_Node *dst_node) = 0;
00103 
00110         virtual double GetAttenuationApproxdB(void) = 0;
00111 
00117         virtual double GetIdealPropagationDelay(void) = 0;
00118 
00124         bool IsInputImpedanceUp2Date(PLC_Node *dst_node);
00125 
00131         bool IsEdgeTransferFactorUp2Date(PLC_Node *dst_node);
00132 
00137         void SetInputImpedanceOutOfDate(PLC_Node *dst_node);
00138 
00143         void SetEdgeTransferFactorOutOfDate(PLC_Node *dst_node);
00144 
00150         PLC_Impedance *GetInputImpedance(PLC_Node *dst_node);
00151 
00158         void CacheImpedances(PLC_Node *dst_node, Ptr<PLC_Impedance> input_impedance, Ptr<PLC_Impedance> load_impedance);
00159 
00165         void InitEdgeTransferFactor(PLC_Node *dst_node, bool time_variant = false);
00166 
00172         PLC_EdgeTransferUnit *GetEdgeTransferUnit(PLC_Node *dst_node);
00173 
00179         PLC_EdgeTransferUnit *GetUpdatedEdgeTransferUnit(PLC_Node *dst_node);
00180 
00181         std::vector<PLC_Node *> GetNodes(void);
00182 
00183 protected:
00184         virtual void DoDispose(void);
00185 
00186         mutable PLC_Mutex                       m_line_mutex;
00187         Ptr<const SpectrumModel>        m_spectrum_model;
00188         double                                          m_propagation_delay;
00189         bool                                            added2graph;
00190         double                                          m_length;
00191 
00192         PLC_EdgeTransferDataMap         m_edge_transfer_data;
00193 };
00194 
00198 class PLC_Line : public PLC_Edge
00199 {
00200         friend class PLC_Node;
00201 
00202 public:
00203         static TypeId GetTypeId(void);
00204 
00211         PLC_Line(Ptr<PLC_Cable> cable_type, Ptr<PLC_Node> from, Ptr<PLC_Node> to);
00212         ~PLC_Line() {}
00213 
00214         /*
00215          * definition of the inherited pure virtual functions
00216          */
00217         double GetIdealPropagationDelay(void) { return m_propagation_delay; }
00218 
00219         Ptr<const PLC_Cable> GetCable(void) const { return m_cable; }
00220         Ptr<const PLC_FreqSelectiveImpedance> GetCharLineImp(void) const;
00221         Ptr<const PLC_FreqSelectiveImpedance> GetTransLineConst(void) const;
00222 
00223         void CalculateEdgeTransferFactor(PLC_Node *dst_node);
00224         double GetAttenuationApproxdB(void);
00225 
00226         void CalculateInputImpedance(PLC_Node *dst_node);
00227 
00236         template<typename ImpedanceReturnType, typename LoadImpedanceType>
00237         ImpedanceReturnType CalcLineInputImpedance(const LoadImpedanceType& z_l);
00238 
00239 private:
00240         virtual void DoDispose(void);
00241 
00242         Ptr<PLC_Cable>          m_cable;
00243 };
00244 
00251 class PLC_TwoPort : public PLC_Edge
00252 {
00253 public:
00254         static TypeId GetTypeId(void);
00255 
00269         PLC_TwoPort(
00270                                 Ptr<const SpectrumModel> sm,
00271                                 Ptr<PLC_Node> from, Ptr<PLC_Node> to,
00272                                 Ptr<PLC_ValueBase> A, Ptr<PLC_ValueBase> B, Ptr<PLC_ValueBase> C, Ptr<PLC_ValueBase> D
00273                                 );
00274 
00275 private:
00276         ushort timeVarianceIndicator;
00277 
00278         void CalculateInputImpedance(PLC_Node *dst_node);
00279         void CalculateEdgeTransferFactor(PLC_Node *dst_node);
00280         double GetAttenuationApproxdB(void);
00281         double GetIdealPropagationDelay(void);
00282 
00283         Ptr<PLC_ValueBase> m_A, m_B, m_C, m_D;
00284 };
00285 
00289 typedef PLC_TwoPort     PLC_Transformer;
00290 
00291 }
00292 
00293 #endif /* PLC_EDGE_H */
 All Classes Functions Variables Enumerations