summaryrefslogtreecommitdiff
path: root/ext/dsent/model/optical_graph/OpticalWavelength.h
blob: 6a5f31e9abbaf46fb1bc469b533eb7779145bded (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef __DSENT_MODEL_OPTICALGRAPH_OPTICALWAVELENGTH_H__
#define __DSENT_MODEL_OPTICALGRAPH_OPTICALWAVELENGTH_H__

#include "model/OpticalModel.h"
#include "util/CommonType.h"

namespace DSENT
{
    // Optical datapath structure storing a detector table consisting of a
    // detector, the loss to that detector, and the modulator driving
    // the wavelength for that detector
    struct OpticalDataPath
    {
        OpticalLaser* laser;
        OpticalModulator* modulator;
        vector<OpticalDetector*> detectors;
        vector<double> losses;
        
        OpticalDataPath(OpticalLaser* laser_, OpticalModulator* modulator_, OpticalDetector* detector_, double loss_)
            : laser(laser_), modulator(modulator_), detectors(1, detector_), losses(1, loss_) {}
    };

    class OpticalWavelength
    {
        // A data structure of a wavelength (or a group of wavelengths). This
        // keeps track of all lasers sources, modulators, and detectors that
        // the wavelength hits.
        public:
            OpticalWavelength(const String& instance_name_, const WavelengthGroup& wavelengths_);
            ~OpticalWavelength();

        public:
            // Get tree name
            const String& getInstanceName() const;
            // Get wavelength groups
            WavelengthGroup getWavelengths() const;
            // Add a datapath for this wavelength
            void addDataPath(OpticalLaser* laser_, OpticalModulator* modulator_, OpticalDetector* detector_, double loss_);
            const vector<OpticalDataPath>* getDataPaths() const;
            // Calculate required wavelength power to reach some number of detectors
            // If number_detectors < the number of total detectors this wavelength hits then
            // it simply returns the laser power required to reach the worst-case detectors
            double getLaserPower(unsigned int number_detectors_) const;
        
        private:
            // Name of the wavelength
            const String m_instance_name_;
            // Keeps track of the wavelengths
            const WavelengthGroup m_wavelengths_;
            // Keeps track of a table of laser, detector, modulator mappings
            vector<OpticalDataPath>* m_data_paths_;            
    };
    
} // namespace DSENT

#endif // __DSENT_MODEL_OPTICALGRAPH_OPTICALWAVEGUIDE_H__