8 using namespace Mackie;
10 Surface::Surface( uint32_t max_strips, uint32_t unit_strips )
11 : _max_strips( max_strips ), _unit_strips( unit_strips )
18 init_strips( _max_strips, _unit_strips );
24 for( Groups::iterator it = groups.begin(); it != groups.end(); ++it )
30 for( Controls::iterator it = controls.begin(); it != controls.end(); ++it )
36 // Mackie-specific, because of multiple devices on separate ports
37 // add the strips from 9..max_strips
38 // unit_strips is the number of strips for additional units.
39 void Surface::init_strips( uint32_t max_strips, uint32_t unit_strips )
41 if ( strips.size() < max_strips )
43 strips.resize( max_strips );
44 for ( uint32_t i = strips.size(); i < max_strips; ++i )
46 // because I can't find itoa
48 os << "strip_" << i + 1;
49 string name = os.str();
51 // shallow copy existing strip
52 // which works because the controls
53 // have the same ids across units
54 Strip * strip = new Strip( *strips[i % unit_strips] );
56 // update the relevant values
60 // add to data structures
67 ostream & Mackie::operator << ( ostream & os, const Mackie::Control & control )
69 os << typeid( control ).name();
71 os << "name: " << control.name();
73 os << "id: " << "0x" << setw(4) << setfill('0') << hex << control.id() << setfill(' ');
75 os << "type: " << "0x" << setw(2) << setfill('0') << hex << control.type() << setfill(' ');
77 os << "raw_id: " << "0x" << setw(2) << setfill('0') << hex << control.raw_id() << setfill(' ');
79 os << "ordinal: " << dec << control.ordinal();
81 os << "group: " << control.group().name();
88 TODO could optimise this to use enum, but it's only
89 called during the protocol class instantiation.
96 controls = sf.groups.find{|x| x[0] =~ /strip/}.each{|x| puts x[1]}
97 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"}
99 void Strip::add( Control & control )
101 Group::add( control );
102 if ( control.name() == "gain" )
104 _gain = reinterpret_cast<Fader*>(&control);
106 else if ( control.name() == "vpot" )
108 _vpot = reinterpret_cast<Pot*>(&control);
110 else if ( control.name() == "recenable" )
112 _recenable = reinterpret_cast<Button*>(&control);
114 else if ( control.name() == "solo" )
116 _solo = reinterpret_cast<Button*>(&control);
118 else if ( control.name() == "mute" )
120 _mute = reinterpret_cast<Button*>(&control);
122 else if ( control.name() == "select" )
124 _select = reinterpret_cast<Button*>(&control);
126 else if ( control.name() == "vselect" )
128 _vselect = reinterpret_cast<Button*>(&control);
130 else if ( control.name() == "fader_touch" )
132 _fader_touch = reinterpret_cast<Button*>(&control);
134 else if ( control.type() == Control::type_led || control.type() == Control::type_led_ring )
137 cout << "Strip::add not adding " << control << endl;
142 os << "Strip::add: unknown control type " << control;
143 throw MackieControlException( os.str() );