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

instrument.cc

Go to the documentation of this file.
00001 // instrument.cc
00002 // SuperMix version 1.0  C++ source file
00003 //
00004 // Copyright (c) 1999 California Institute of Technology.
00005 // All rights reserved.
00006 //
00007 // Redistribution and use in source and binary forms for noncommercial
00008 // purposes are permitted provided that the above copyright notice and
00009 // this paragraph are duplicated in all such forms and that any
00010 // documentation and other materials related to such distribution and
00011 // use acknowledge that the software was developed by California
00012 // Institute of Technology. Redistribution and/or use in source or
00013 // binary forms is not permitted for any commercial purpose. Use of
00014 // this software does not include a permitted use of the Institute's
00015 // name or trademark for any purpose.
00016 //
00017 // DISCLAIMER:
00018 // THIS SOFTWARE AND/OR RELATED MATERIALS ARE PROVIDED "AS-IS" WITHOUT
00019 // WARRANTY OF ANY KIND INCLUDING ANY WARRANTIES OF PERFORMANCE OR
00020 // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE OR PURPOSE (AS SET
00021 // FORTH IN UCC 23212-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
00022 // LICENSED PRODUCT, HOWEVER USED.  IN NO EVENT SHALL CALTECH/JPL BE
00023 // LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING BUT NOT LIMITED TO
00024 // INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, INCLUDING ECONOMIC
00025 // DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, REGARDLESS OF
00026 // WHETHER CALTECH/JPL SHALL BE ADVISED, HAVE REASON TO KNOW, OR IN
00027 // FACT SHALL KNOW OF THE POSSIBILITY.  THE USER BEARS ALL RISK
00028 // RELATING TO QUALITY AND PERFORMANCE OF THE SOFTWARE AND/OR RELATED
00029 // MATERIALS.
00030 
00031 #include "instrument.h"
00032 #include "error.h"
00033 
00034 
00035 inst_circuit::inst_circuit
00036 (nport & internal_circuit,  nport & external_circuit,  int num_voltmeters) :
00037   nport(external_circuit.size()),
00038   interface_ports(external_circuit.size()),
00039   amp_ports(internal_circuit.size() - external_circuit.size() - num_voltmeters),
00040   volt_ports(num_voltmeters),
00041   int_c(internal_circuit), ext_c(external_circuit),
00042   voltmeters(volt_ports),
00043   ampmeters(amp_ports),
00044   volts(volt_ports),
00045   amps(amp_ports)
00046 
00047 {
00048   int i, j;
00049 
00050   // check validity of arguments:
00051   if(interface_ports <= 0)
00052     error::fatal("external_circuit must know its size in inst_circuit constructor.");
00053   if(amp_ports < 0)
00054     error::fatal("internal_circuit doesn't have enough ports in inst_circuit constructor.");
00055   if(volt_ports < 0)
00056     error::fatal("volt_ports < 0 in inst_circuit constructor.");
00057 
00058   // build get_data_c:
00059   for(i = 1; i <= interface_ports; ++i)
00060     get_data_c.add_port(int_c, i);
00061   for(j = 0 ; j < amp_ports; ++i, ++j)   // starts loop at i = interface_ports + 1
00062     get_data_c.connect(int_c, i, ampmeters[j], 1);
00063   for(j = 0 ; j < volt_ports; ++i, ++j)  // starts loop at i = interface_ports + amp_ports + 1
00064     get_data_c.connect(int_c, i, voltmeters[j], 1);
00065 
00066   // build voltages_c:
00067   for(i = 1; i <= interface_ports; ++i)
00068     voltages_c.connect(int_c, i, ext_c, i);
00069   for(j = 0 ; j < amp_ports; ++i, ++j)   // starts loop at i = interface_ports + 1
00070     voltages_c.connect(int_c, i, ampmeters[j], 1);
00071   for(j = 0 ; j < volt_ports; ++i, ++j)  // starts loop at i = interface_ports + amp_ports + 1
00072     voltages_c.add_port(int_c, i);
00073 
00074   // build currents_c:
00075   for(i = 1; i <= interface_ports; ++i)
00076     currents_c.connect(int_c, i, ext_c, i);
00077   for(j = 0 ; j < amp_ports; ++i, ++j)   // starts loop at i = interface_ports + 1
00078     currents_c.add_port(int_c, i);
00079   for(j = 0 ; j < volt_ports; ++i, ++j)  // starts loop at i = interface_ports + amp_ports + 1
00080     currents_c.connect(int_c, i, voltmeters[j], 1);
00081 }

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