8 using namespace Mackie;
10 Surface::Surface( uint32_t max_strips )
11 : _max_strips( max_strips )
18 // TODO fix this hard coding
19 init_strips( _max_strips, 8 );
25 for( Groups::iterator it = groups.begin(); it != groups.end(); ++it )
31 for( Controls::iterator it = controls.begin(); it != controls.end(); ++it )
37 // Possibly Mackie-specific, because of multiple devices on separate ports
38 // add the strips from 9..max_strips
39 // unit_strips is the number of strips for additional units.
40 // TODO would be better to pass the MackiePorts in here, cos
41 // each might have a different number of strips
42 void Surface::init_strips( uint32_t max_strips, uint32_t unit_strips )
44 if ( strips.size() < max_strips )
46 strips.resize( max_strips );
47 for ( uint32_t i = strips.size(); i < max_strips; ++i )
49 // because I can't find itoa
51 os << "strip_" << i + 1;
52 string name = os.str();
54 // shallow copy existing strip
55 // which works because the controls
56 // have the same ids across units
57 Strip * strip = new Strip( *strips[i % unit_strips] );
59 // update the relevant values
63 // add to data structures
70 ostream & Mackie::operator << ( ostream & os, const Mackie::Control & control )
72 os << typeid( control ).name();
74 os << "name: " << control.name();
76 os << "id: " << "0x" << setw(2) << setfill('0') << hex << control.id() << setfill(' ');
78 os << "ordinal: " << dec << control.ordinal();
80 os << "group: " << control.group().name();
87 TODO could optimise this to use enum, but it's only
88 called during the protocol class instantiation.
95 controls = sf.groups.find{|x| x[0] =~ /strip/}.each{|x| puts x[1]}
96 controls[1].each {|x| puts "\telse if ( control.name() == \"#{x.name}\" )\n\t{\n\t\t_#{x.name} = reinterpret_cast<#{x.class.name}*>(&control);\n\t}\n"}
98 void Strip::add( Control & control )
100 Group::add( control );
101 if ( control.name() == "gain" )
103 _gain = reinterpret_cast<Fader*>(&control);
105 else if ( control.name() == "vpot" )
107 _vpot = reinterpret_cast<Pot*>(&control);
109 else if ( control.name() == "recenable" )
111 _recenable = reinterpret_cast<Button*>(&control);
113 else if ( control.name() == "solo" )
115 _solo = reinterpret_cast<Button*>(&control);
117 else if ( control.name() == "mute" )
119 _mute = reinterpret_cast<Button*>(&control);
121 else if ( control.name() == "select" )
123 _select = reinterpret_cast<Button*>(&control);
125 else if ( control.name() == "vselect" )
127 _vselect = reinterpret_cast<Button*>(&control);
129 else if ( control.name() == "fader_touch" )
131 _fader_touch = reinterpret_cast<Button*>(&control);
133 else if ( control.type() == Control::type_led || control.type() == Control::type_led_ring )
136 cout << "Strip::add not adding " << control << endl;
141 os << "Strip::add: unknown control type " << control;
142 throw MackieControlException( os.str() );