OpticalWavelength.h revision 10448
1/* Copyright (c) 2012 Massachusetts Institute of Technology 2 * 3 * Permission is hereby granted, free of charge, to any person obtaining a copy 4 * of this software and associated documentation files (the "Software"), to deal 5 * in the Software without restriction, including without limitation the rights 6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 * copies of the Software, and to permit persons to whom the Software is 8 * furnished to do so, subject to the following conditions: 9 * 10 * The above copyright notice and this permission notice shall be included in 11 * all copies or substantial portions of the Software. 12 * 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 * THE SOFTWARE. 20 */ 21 22#ifndef __DSENT_MODEL_OPTICALGRAPH_OPTICALWAVELENGTH_H__ 23#define __DSENT_MODEL_OPTICALGRAPH_OPTICALWAVELENGTH_H__ 24 25#include "model/OpticalModel.h" 26#include "util/CommonType.h" 27 28namespace DSENT 29{ 30 // Optical datapath structure storing a detector table consisting of a 31 // detector, the loss to that detector, and the modulator driving 32 // the wavelength for that detector 33 struct OpticalDataPath 34 { 35 OpticalLaser* laser; 36 OpticalModulator* modulator; 37 vector<OpticalDetector*> detectors; 38 vector<double> losses; 39 40 OpticalDataPath(OpticalLaser* laser_, OpticalModulator* modulator_, OpticalDetector* detector_, double loss_) 41 : laser(laser_), modulator(modulator_), detectors(1, detector_), losses(1, loss_) {} 42 }; 43 44 class OpticalWavelength 45 { 46 // A data structure of a wavelength (or a group of wavelengths). This 47 // keeps track of all lasers sources, modulators, and detectors that 48 // the wavelength hits. 49 public: 50 OpticalWavelength(const String& instance_name_, const WavelengthGroup& wavelengths_); 51 ~OpticalWavelength(); 52 53 public: 54 // Get tree name 55 const String& getInstanceName() const; 56 // Get wavelength groups 57 WavelengthGroup getWavelengths() const; 58 // Add a datapath for this wavelength 59 void addDataPath(OpticalLaser* laser_, OpticalModulator* modulator_, OpticalDetector* detector_, double loss_); 60 const vector<OpticalDataPath>* getDataPaths() const; 61 // Calculate required wavelength power to reach some number of detectors 62 // If number_detectors < the number of total detectors this wavelength hits then 63 // it simply returns the laser power required to reach the worst-case detectors 64 double getLaserPower(unsigned int number_detectors_) const; 65 66 private: 67 // Name of the wavelength 68 const String m_instance_name_; 69 // Keeps track of the wavelengths 70 const WavelengthGroup m_wavelengths_; 71 // Keeps track of a table of laser, detector, modulator mappings 72 vector<OpticalDataPath>* m_data_paths_; 73 }; 74 75} // namespace DSENT 76 77#endif // __DSENT_MODEL_OPTICALGRAPH_OPTICALWAVEGUIDE_H__ 78 79