Subversion Repositories programming

Rev

Rev 340 | Rev 345 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 340 Rev 344
Line 129... Line 129...
129
        if (active)
129
        if (active)
130
            controller->request_elevator (data.button_num+1, MOVE_DOWN);
130
            controller->request_elevator (data.button_num+1, MOVE_DOWN);
131
    }
131
    }
132
    else
132
    else
133
        s = "NOT VALID";
133
        s = "NOT VALID";
134
 
-
 
135
    std::cout << "Button Pressed: number=" << data.button_num << " -- direc="
-
 
136
        << s << " -- str=" << data.str << " -- active=" << active << std::endl;
-
 
137
}
134
}
138
 
135
 
139
void Elevator_Window::open_elevator_at (int row, int col)
136
void Elevator_Window::open_elevator_at (int row, int col)
140
{
137
{
141
    assert (row >= 0);
138
    assert (row >= 0);
Line 156... Line 153...
156
    assert (col >= 0);
153
    assert (col >= 0);
157
    assert (col < 5);
154
    assert (col < 5);
158
 
155
 
159
    const int numRows = 10;
156
    const int numRows = 10;
160
    const int numCols = 5;
157
    const int numCols = 5;
161
 
158
    
-
 
159
    images.at (row*numCols+col)->clear ();
162
    images.at (row*numCols+col)->set ("eclose.png");
160
    images.at (row*numCols+col)->set ("eclose.png");
163
}
161
}
164
 
162
 
165
void Elevator_Window::unset_up_button (int button_num)
163
void Elevator_Window::unset_up_button (int button_num)
166
{
164
{
Line 189... Line 187...
189
void Elevator_Window::set_controller (Controller *controller)
187
void Elevator_Window::set_controller (Controller *controller)
190
{
188
{
191
    this->controller = controller;
189
    this->controller = controller;
192
}
190
}
193
 
191
 
194
/*std::string*/ void Elevator_Window::get_floors_from_user (int elevator_num)
192
void Elevator_Window::get_floors_from_user (int elevator_num)
195
{
193
{
196
#if 0
-
 
197
    int res;
194
    int res;
198
    std::cout << "GETTING FLOORS FROM USER" << std::endl;
-
 
199
 
195
 
200
    Gtk::Dialog d ("Dialog");
196
    Gtk::Dialog d ("Floor Dialog", true, true);
201
    Gtk::Entry entry;
197
    Gtk::Entry entry;
-
 
198
    Gtk::Label label ("Enter floors to stop at (space seperated): ");
-
 
199
 
-
 
200
    Gtk::Box *pBox = d.get_vbox();
-
 
201
 
-
 
202
    pBox->set_spacing (10);
202
 
203
 
203
    d.get_vbox()->pack_start (entry);
204
    pBox->pack_start (label);
204
    d.add_button ("OK", 77);
205
    pBox->pack_start (entry);
205
 
206
 
-
 
207
    label.show ();
-
 
208
    entry.show ();
-
 
209
 
-
 
210
    d.add_button ("gtk-ok", 7);
-
 
211
 
-
 
212
    // Run the Dialog
206
    res = d.run ();
213
    res = d.run ();
207
 
214
 
-
 
215
    // Parse the entry
-
 
216
    std::string s = entry.get_text();
-
 
217
    std::vector<std::string> SplitVec;
-
 
218
    boost::split (SplitVec, s, boost::is_any_of(" "));
-
 
219
 
-
 
220
    const int num_floors = 10; // FIXME
-
 
221
 
-
 
222
    int i, val;
-
 
223
    for (i=0; i<SplitVec.size(); i++)
-
 
224
    {
-
 
225
        val = atoi (SplitVec[i].c_str());
-
 
226
 
-
 
227
        // Ignore values that are outside of range
-
 
228
        if (val >= 0 && val < num_floors)
-
 
229
        {
-
 
230
            controller->push_button_in_elevator (elevator_num, val);
208
    std::cout << "DONE GETTING FLOORS" << std::endl;
231
            std::cout << "Pushing button: " << val << std::endl;
-
 
232
        }
209
#endif
233
    }
210
}
234
}
211
 
235