8e0a57f13344b7a0f54fcd0f75369ba89f9fcec4
Stefan Schuermans continue implementing confi...

Stefan Schuermans authored 7 years ago

1) /*
2)  * EtherPix simulator
3)  *
4)  * Copyright 2017 Stefan Schuermans <stefan schuermans info>
5)  *
6)  * This program is free software: you can redistribute it and/or modify
7)  * it under the terms of the GNU General Public License as published by
8)  * the Free Software Foundation, version 3 of the License.
9)  *
10)  *
11)  * This program is distributed in the hope that it will be useful,
12)  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13)  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14)  * GNU General Public License for more details.
15)  *
16)  * You should have received a copy of the GNU Lesser General Public License
17)  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18)  */
19) 
20) #ifndef DISTRI_H
21) #define DISTRI_H
22) 
Stefan Schuermans complete implementation of...

Stefan Schuermans authored 7 years ago

23) #include <arpa/inet.h>
24) #include <map>
25) #include <vector>
26) 
Stefan Schuermans continue implementing confi...

Stefan Schuermans authored 7 years ago

27) #include "mapping.h"
Stefan Schuermans complete implementation of...

Stefan Schuermans authored 7 years ago

28) #include "pixel.h"
Stefan Schuermans continue implementing confi...

Stefan Schuermans authored 7 years ago

29) 
30) /// distributor
31) class Distri
32) {
33) public:
34)   /// constructor
35)   Distri();
36) 
37)   /**
38)    * @brief initialize
39)    * @param[in] distno distributor number
40)    * @param[in] outputs number of outputs
41)    * @param[in] pixels number of pixels per output
42)    */
43)   void init(unsigned long distno, unsigned long outputs, unsigned long pixels);
44) 
45)   /// get distributor number
46)   unsigned long getNo() const { return m_distno; }
47) 
48)   /// get number of outputs
49)   unsigned long getOutputs() const { return m_outputs; }
50) 
51)   /// get number of pixels at each output
52)   unsigned long getPixels() const { return m_pixels; }
53) 
Stefan Schuermans complete implementation of...

Stefan Schuermans authored 7 years ago

54)   /**
55)    * @brief set network address
56)    * @param[in] addr IPv4/port network address (UDP)
57)    */
58)   void setAddr(struct sockaddr_in const &addr);
59) 
Stefan Schuermans continue implementing confi...

Stefan Schuermans authored 7 years ago

60)   /**
61)    * @brief get mapping
62)    * @param[in] chan color channel
63)    * @return mapping mapping object of color channel
64)    * @throws std::exception in case of error
65)    */
66)   Mapping const& getMapping(Mapping::Channel chan) const;
67) 
68)   /**
69)    * @brief set mapping
70)    * @param[in] chan color channel
71)    * @param[in] mapping new mapping object for color channel
72)    * @throws std::exception in case of error
73)    */
74)   void setMapping(Mapping::Channel chan, Mapping const &mapping);
75) 
Stefan Schuermans complete implementation of...

Stefan Schuermans authored 7 years ago

76)   /**
77)    * @brief add output to distributor
78)    * @param[in] outno number of output
79)    * @throws std::exception in case of error
80)    */
81)   void addOutput(unsigned long outno);
82) 
83)   /**
84)    * @brief add pixel to output of distributor
85)    * @param[in] outno number of output
86)    * @param[in] pixel pixel object to add
87)    * @throws std::exception in case of error
88)    */
89)   void addPixel(unsigned long outno, Pixel const &pixel);
90) 
91) protected:
92)   /// output data
93)   struct Output {
94)     std::vector<Pixel> m_pixels; ///< pixels at this output
95)   };
96) 
97)   /// map out outputs: output number -> output data
98)   typedef std::map<unsigned long, Output> OutputMap;
99) 
Stefan Schuermans continue implementing confi...

Stefan Schuermans authored 7 years ago

100) protected:
Stefan Schuermans complete implementation of...

Stefan Schuermans authored 7 years ago

101)   /// distributor number
102)   unsigned long m_distno;
103)   /// number of outputs
104)   unsigned long m_outputs;
105)   /// number of pixels per output
106)   unsigned long m_pixels;
107)   /// network address
108)   struct sockaddr_in m_addr;
109)   /// mappings of color channels
110)   Mapping m_mappings[Mapping::ChannelCount];
111)   /// outputs
112)   OutputMap m_outputMap;