152a2bc2b5dbcb2ecf9c746be019efa57fa3f3aa
Stefan Schuermans start of implementation (ha...

Stefan Schuermans authored 13 years ago

1) /* JFlexiPix - Java implementation of FlexiPix output library
2)  *
Stefan Schuermans change email address in fil...

Stefan Schuermans authored 13 years ago

3)  * Copyright 2010-2011 Stefan Schuermans <stefan schuermans info>
Stefan Schuermans start of implementation (ha...

Stefan Schuermans authored 13 years ago

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

Stefan Schuermans authored 7 years ago

21) import java.net.*;
Stefan Schuermans start of implementation (ha...

Stefan Schuermans authored 13 years ago

22) import java.util.Arrays;
23) 
24) /// FlexiPix distributor
25) class Distri
26) {
27)   /**
28)    * @brief constructor
29)    * @param[in] distri number of this distributor
30)    * @param[in] outputCnt number of outputs
31)    * @param[in] pixelCnt number pixels connected to every output
32)    */
33)   Distri(int distri, int outputCnt, int pixelCnt)
34)   {
35)     // save constructor parameters
36)     m_distri    = distri;
37)     m_outputCnt = outputCnt;
38)     m_pixelCnt  = pixelCnt;
39) 
Stefan Schuermans add support for configuring...

Stefan Schuermans authored 7 years ago

40)     // initialize address to default
41)     try {
42)       int intIp = Constants.destIpBase +
43)                   m_distri * Constants.destIpStep;
44)       byte [] byteIp = {
45)         (byte)(intIp >> 24),
46)         (byte)(intIp >> 16),
47)         (byte)(intIp >>  8),
48)         (byte)intIp
49)       };
50)       m_addr = new InetSocketAddress(InetAddress.getByAddress(byteIp),
51)                                      Constants.destPort);
52)     } catch (java.net.UnknownHostException e) {
53)       m_addr = null;
54)     } catch (java.io.IOException e) {
55)       m_addr = null;
56)     }
57) 
Stefan Schuermans implemened mapping parsing

Stefan Schuermans authored 13 years ago

58)     // allocate default mappings
59)     m_mapRed   = new Mapping();
60)     m_mapGreen = new Mapping();
61)     m_mapBlue  = new Mapping();
62) 
Stefan Schuermans start of implementation (ha...

Stefan Schuermans authored 13 years ago

63)     // allocate pixel array (no pixels configured yet)
64)     m_pixels = new Pixel [m_outputCnt * m_pixelCnt];
65) 
66)     // allocate and initialize message buffer
67)     m_msgBuf = Arrays.copyOf(Constants.mcufHdr,
68)                              Constants.mcufHdr.length +
69)                              m_outputCnt * m_pixelCnt * 3);
70)     m_msgBuf[Constants.mcufOfsOutputs] = (byte)m_outputCnt;
71)     m_msgBuf[Constants.mcufOfsPixels]  = (byte)m_pixelCnt;
72)   }
73) 
Stefan Schuermans add support for configuring...

Stefan Schuermans authored 7 years ago

74)   int               m_distri;    ///< number of this distributor
75)   int               m_outputCnt; ///< number of outputs
76)   int               m_pixelCnt;  ///< number pixels connected to every output
77)   InetSocketAddress m_addr;      ///< network address of distributor
78)   Mapping           m_mapRed;    ///< mapping information for red channel
79)   Mapping           m_mapGreen;  ///< mapping information for Green channel
80)   Mapping           m_mapBlue;   ///< mapping information for blue channel
81)   Pixel []          m_pixels;    /**< information about pixels of this
82)                                       distributor,
83)                                       index = output * m_pixelCnt + pixel */
84)   byte []           m_msgBuf;    /**< buffer for current message to send to
85)                                       distributor */