mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
Loading...
Searching...
No Matches
wooferTweeterFilter.hpp
Go to the documentation of this file.
1/** \file
2 * \author Jared R. Males (jaredmales@gmail.com)
3 * \brief
4 * \ingroup mxAO_sim_files
5 *
6 */
7
8#ifndef __wooferTweeterFilter_hpp__
9#define __wooferTweeterFilter_hpp__
10
11#include "wooferTweeterDM.hpp"
12
13namespace mx
14{
15namespace AO
16{
17namespace sim
18{
19
20template <typename wooferFilterT, typename tweeterFilterT>
21class wooferTweeterFilter
22{
23
24 public:
25 typedef typename wooferFilterT::floatT floatT;
26
27 typedef std::complex<floatT> complexT;
28
29 /// The wavefront data type
30 typedef wavefront<floatT> wavefrontT;
31
32 /// The command type
33 typedef wooferTweeterCommand<floatT> commandT;
34
35 wooferTweeterFilter();
36
37 wooferFilterT woofer;
38 tweeterFilterT tweeter;
39
40 int wooferNModes;
41 int tweeterNModes;
42
43 public:
44 template <typename dmT>
45 void initialize( dmT &dm );
46
47 void filterCommands( commandT &filtAmps, commandT &rawAmps );
48
49 int _lowOrders;
50
51 void initMeasurements( commandT &filtAmps, commandT &rawAmps )
52 {
53 filtAmps.wooferVect.resize( 1, wooferNModes );
54 filtAmps.wooferVect.setZero();
55 filtAmps.tweeterVect.resize( 1, tweeterNModes );
56 filtAmps.tweeterVect.setZero();
57
58 rawAmps.wooferVect.resize( 1, wooferNModes );
59 rawAmps.wooferVect.setZero();
60 rawAmps.tweeterVect.resize( 1, tweeterNModes );
61 rawAmps.tweeterVect.setZero();
62 }
63};
64
65template <typename wooferFilterT, typename tweeterFilterT>
66wooferTweeterFilter<wooferFilterT, tweeterFilterT>::wooferTweeterFilter()
67{
68}
69
70template <typename wooferFilterT, typename tweeterFilterT>
71template <typename dmT>
72void wooferTweeterFilter<wooferFilterT, tweeterFilterT>::initialize( dmT &dm )
73{
74 woofer.initialize( dm.woofer );
75 wooferNModes = dm.woofer.nModes();
76
77 tweeter.initialize( dm.tweeter );
78 tweeterNModes = dm.tweeter.nModes();
79}
80
81template <typename wooferFilterT, typename tweeterFilterT>
82void wooferTweeterFilter<wooferFilterT, tweeterFilterT>::filterCommands( commandT &filtAmps, commandT &rawAmps )
83{
84 static int called = 0;
85
86 if( called == 51 )
87 {
88 woofer.setGains( 0.1 );
89 }
90
91 if( called == 101 )
92 {
93 for( int i = 78; i < 1680; ++i )
94 tweeter.setLeak( i, 0.01 );
95 }
96
97 woofer.filterCommands( filtAmps.wooferVect, rawAmps.wooferVect );
98 tweeter.filterCommands( filtAmps.tweeterVect, rawAmps.tweeterVect );
99
100 ++called;
101}
102
103} // namespace sim
104} // namespace AO
105} // namespace mx
106
107#endif //__wooferTweeterFilter_hpp__
The mxlib c++ namespace.
Definition mxError.hpp:106