Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

nport.cc

Go to the documentation of this file.
00001 // SuperMix version 1.0  C++ source file
00002 //
00003 // Copyright (c) 1999 California Institute of Technology.
00004 // All rights reserved.
00005 //
00006 // Redistribution and use in source and binary forms for noncommercial
00007 // purposes are permitted provided that the above copyright notice and
00008 // this paragraph are duplicated in all such forms and that any
00009 // documentation and other materials related to such distribution and
00010 // use acknowledge that the software was developed by California
00011 // Institute of Technology. Redistribution and/or use in source or
00012 // binary forms is not permitted for any commercial purpose. Use of
00013 // this software does not include a permitted use of the Institute's
00014 // name or trademark for any purpose.
00015 //
00016 // DISCLAIMER:
00017 // THIS SOFTWARE AND/OR RELATED MATERIALS ARE PROVIDED "AS-IS" WITHOUT
00018 // WARRANTY OF ANY KIND INCLUDING ANY WARRANTIES OF PERFORMANCE OR
00019 // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE OR PURPOSE (AS SET
00020 // FORTH IN UCC 23212-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
00021 // LICENSED PRODUCT, HOWEVER USED.  IN NO EVENT SHALL CALTECH/JPL BE
00022 // LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING BUT NOT LIMITED TO
00023 // INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, INCLUDING ECONOMIC
00024 // DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, REGARDLESS OF
00025 // WHETHER CALTECH/JPL SHALL BE ADVISED, HAVE REASON TO KNOW, OR IN
00026 // FACT SHALL KNOW OF THE POSSIBILITY.  THE USER BEARS ALL RISK
00027 // RELATING TO QUALITY AND PERFORMANCE OF THE SOFTWARE AND/OR RELATED
00028 // MATERIALS.
00029 //
00030 // nport.cc
00031 //
00032 // Change history:
00033 // 11/1/99:  added is_active() and is_source()
00034 // 10/22/99: device::Z0 is back to a parameter again
00035 // 7/26/99;  added state_tag::current_state; removed sdata_nport stuff
00036 // 9/30/98:  changed the fixes to device.
00037 // 9/18/98:  converted alias to subclass of data_ptr_nport
00038 // 9/18/98:  changed nport::S, C, and B
00039 // 9/16/98:  moved most alias code to nport.h;
00040 // 7/27/98:  removed nport::get_data() - now in nport.h
00041 // 7/21/98:  changed generic_nport to sdata_nport
00042 // 7/8/98:   added generic_nport
00043 // 12/29/97: some minor mods, especially compute_passive_noise
00044 // 12/19/97: modified by FR for matmath classes
00045 //           added nport::B().
00046 
00047 #include "nport.h"
00048 #include "units.h"
00049 #include "error.h"
00050 
00051 unsigned long state_tag::current_state = 1;
00052 unsigned long device::devcount = 0;
00053 
00054 parameter device::T  = 300 * Kelvin;
00055 parameter device::Z0 = 50 * Ohm;
00056 parameter device::f  = 0.0;
00057 
00058 // **************************************************************
00059 
00060 port nport::get_port(int index)
00061 {
00062   if((index > 0) && (index <=size()))
00063     return port(id, index);
00064 
00065   // Subscript out of range, return default port.
00066   error::warning("Port index out of range in nport::get_port(int).");
00067   return port();
00068 }
00069 
00070 int nport::get_port(port p)
00071 {
00072   if((p.id == id) && (p.index > 0) && (p.index <=size()))
00073   {
00074     return p.index;
00075   }
00076 
00077   // Subscript out of range, return default port.
00078   error::warning("Port out of range in nport::get_port.");
00079   return 0;
00080 }
00081 
00082 complex nport::S(int i, int j)
00083 {
00084   // Don't make any assumptions about how this device recalculates itself.
00085   // This way, we can avoid having to overload this function.
00086   const sdata *dptr = &get_data();
00087 
00088   // Check range on (i,j) and warn if invalid:
00089   if((i<1)||(j<1)||(i>size())||(j>size()))
00090     error::warning("Port number out of range for call to S(i,j).");
00091 
00092   return dptr->S.read(i,j);
00093 }
00094 
00095 complex nport::C(int i, int j)
00096 {
00097   // Don't make any assumptions about how this device recalculates itself.
00098   // This way, we can avoid having to overload this function.
00099   const sdata *dptr = &get_data();
00100 
00101   // Check range on (i,j) and warn if invalid:
00102   if((i<1)||(j<1)||(i>size())||(j>size()))
00103     error::warning("Port number out of range for call to C(i,j).");
00104 
00105   return dptr->C.read(i,j);
00106 }
00107 
00108 complex nport::B(int i)
00109 {
00110   // Don't make any assumptions about how this device recalculates itself.
00111   // This way, we can avoid having to overload this function.
00112   const sdata *dptr = &get_data();
00113 
00114   // Check range on (i) and warn if invalid:
00115   if((i<1)||(i>size()))
00116     error::warning("Port number out of range for call to B(i).");
00117 
00118   return dptr->B.read(i);
00119 }
00120 
00121 // **************************************************************
00122 
00123 alias & alias::operator=(nport & n)
00124 {
00125   // Beware of self assignment: n = n
00126   if(this != &n)
00127   {
00128     original = &n;
00129     data_ptr = &data;
00130   }
00131   return *this;
00132 }

Please direct comments and corrections to supermix@submm.caltech.edu
Go to the supermix home page
Generated by doxygen1.2.7