码迷,mamicode.com
首页 > 其他好文 > 详细

结对项目开发电梯调度 - 整体设计

时间:2015-06-14 19:47:18      阅读:270      评论:0      收藏:0      [点我收藏+]

标签:

一、系统介绍

 1. 功能描述 

  本电梯系统用来控制一台运行于一个具有16层的大楼电梯,它具有上升、下降、开门、关门、载客的基本功能。

   大楼的每一层都有:

   (1) 两个指示灯:  这两个指示灯分别用于指示当前所在的层数和电梯的当前状态(上行、下行或停止); 

   (2)按钮:  除了第一层和顶层,每一层都有两个按钮(上行、下行),乘客可以呼叫上楼或下楼,顶楼只有一个下楼按钮,而第一层只有一个上楼按钮。

 2. 电梯里面具有:  标示从“1”到“16”的16个楼层按钮,用于让乘客选择所要的层数;

  注:1-8层不停

二、关键实现方法描述

  用两个队列来实现电梯的调度,电梯根据这两个队列发送来的楼层号作为目的地进行运行。在上行队列中保存了所有的上行请求的楼层号(包括楼层的呼叫和电梯里的楼层按钮请求),即保存电梯上行时需要停的楼层号。

  队列排列规则是:高于或等于电梯当前所地楼层的上行请求的楼层号从小到大排在队列的前部分,低于电梯当前所地楼层的上行请求的楼层号从小到大排在队列后部分。如果新请求的楼层号被插在队列头时同时将这个楼层号发送给电梯作为它的目的地。在下行队列中保存了所有的下行请求的楼层号(包括楼层的呼叫和电梯里楼层按钮请求),即保存电梯下行时需要停的楼层号。

三、电梯具体设计

  本次设计用的语言是.net,用的环境是VS 2010开发工具,   

  该系统用了3个.cs文件,一个主类class ElevatorController,主要定义了函数用来调度电梯。一个class Elevator,标明电梯状态;一个class Form1,设计布局,线程控制;

  1. 电梯设置: 电梯分为三种状态:静止,上升,下降。

    2 乘客分析: 乘客的需求分为“上”和“下”两种。

    3 电梯需要初始化,其中状态为静止state=0,层数floor_lift设置为1。目标层数数组需要初始化。

  程序源代码:

    1.Elevator.CS

技术分享
 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 
 6 namespace ElevatorManager
 7 {
 8     class Elevator
 9     {
10         public int floor;
11         public bool[] panel;//电梯内面板状态
12         public int direction;//up,down
13         public int gatestatus;//open,close
14         public bool isrun;
15 
16 
17         const int UP = 0;
18         const int DOWN = 1;
19 
20         const int CLOSE = 0;
21         const int OPEN = 1;
22 
23         public Elevator()
24         {
25             floor = 0;
26             panel = new bool[10];
27             for (int i = 0; i < 10; ++i)
28             {
29                 panel[i] = false;
30             }
31             direction = UP;
32             gatestatus = CLOSE;
33             isrun = false;
34         }
35 
36         public void setPanel(int i)
37         {
38             panel[i] = true;
39         }
40         
41     }
42 }
View Code

  2.ElevatorManager.CS  

技术分享
  1 using System;
  2 using System.Collections.Generic;
  3 using System.Linq;
  4 using System.Text;
  5 using System.Threading;
  6 
  7 namespace ElevatorManager
  8 {
  9     class ElevatorController
 10     {
 11         public Elevator ele_1;
 12         public Elevator ele_2;
 13         public bool[] uppanel;
 14         public bool[] downpanel;
 15 
 16         #region 状态常量定义
 17         //电梯内
 18         const int UP = 0;
 19         const int DOWN = 1;
 20 
 21         const int CLOSE = 0;
 22         const int OPEN = 1;
 23         const int WAIT = 2;
 24 
 25         //电梯外
 26         const int EXTERIOR = 0;
 27         const int INTERIOR = 1;
 28 
 29         //任务
 30         const int MOVEUP = 0;
 31         const int MOVEDOWN = 1;
 32         const int NONE = -1;
 33 
 34         //type判断
 35         const int ELE1 = 0;
 36         const int ELE2 = 1;
 37         
 38 
 39         #endregion
 40 
 41         public ElevatorController()
 42         {
 43             ele_1 = new Elevator();
 44             ele_2 = new Elevator();
 45             uppanel = new bool[10];//电梯外 上按钮状态
 46             downpanel = new bool[10];//电梯外 下按钮状态
 47             for (int i = 0; i < 10; ++i)
 48             {
 49                 uppanel[i] = false;
 50             }
 51             for (int i = 0; i < 10; ++i)
 52             {
 53                 downpanel[i] = false;
 54             }
 55         }
 56 
 57         public void operate(int IorE, int type, int select)//操作
 58         {
 59             //操作判断
 60             if (IorE == INTERIOR)//外层IorE判断
 61             {
 62                 if (type == ELE1)//内层type判断
 63                 {
 64                     ele_1.setPanel(select);
 65                 }
 66                 else if (type == ELE2)
 67                 {
 68                     ele_2.setPanel(select);
 69                 }
 70                 else
 71                 {
 72                     Exception ex = new Exception("INTERIOR type 错误");
 73                     throw ex;
 74                 }
 75             }
 76             else if (IorE == EXTERIOR)
 77             {
 78                 if (type == UP)
 79                 {
 80                     uppanel[select] = true;
 81                 }
 82                 else if (type == DOWN)
 83                 {
 84                     downpanel[select] = true;
 85                 }
 86                 else
 87                 {
 88                     Exception ex = new Exception("EXTERIOR type 错误");
 89                     throw ex;
 90                 }
 91             }
 92             else
 93             {
 94                 Exception ex=new Exception("IorE错误");
 95                 throw ex;
 96             }
 97             
 98             //电梯是否在执行任务
 99             if (!ele_1.isrun)
100             {
101                 ele_1.isrun = true;
102                 Thread th1 = new Thread(new ThreadStart(run_ele1));
103                 th1.IsBackground = true;
104                 th1.Start();
105             }
106             if (!ele_2.isrun)
107             {
108                 ele_2.isrun = true;
109                 Thread th2 = new Thread(new ThreadStart(run_ele2));
110                 th2.IsBackground = true;
111                 th2.Start();
112             }
113         }
114 
115         public void run_ele1()
116         {
117             try
118             {
119                 run(ele_1);
120             }
121             catch (Exception ex)
122             {
123                 throw ex;
124             }
125         }
126 
127         public void run_ele2()
128         {
129             try
130             {
131                 run(ele_2);
132             }
133             catch (Exception ex)
134             {
135                 throw ex;
136             }
137         }
138 
139         public void run(Elevator ele)//运行
140         {
141             for (; isGoOn(ele); )
142             {
143                 for (operaGate(ele); ele.gatestatus == OPEN; operaGate(ele))
144                 {
145                     Thread.Sleep(5000);
146                     ele.gatestatus = CLOSE;
147                 }
148                 int task = NONE;
149                 task = gettask(ele);
150                 if (task == MOVEUP)
151                 {
152                     ele.floor += 1;
153                     if (!floorJudge(ele))
154                     {
155                         Exception ex = new Exception("楼层错误");
156                         throw ex;
157                     }
158                     Thread.Sleep(1000);
159                 }
160                 else if (task == MOVEDOWN)
161                 {
162                     ele.floor -= 1;
163                     if (!floorJudge(ele))
164                     {
165                         Exception ex = new Exception("楼层错误");
166                         throw ex;
167                     }
168                     Thread.Sleep(1000);
169                 }
170                 else if (task == NONE)
171                 {
172                     //不操作
173                     if (!floorJudge(ele))
174                     {
175                         Exception ex = new Exception("楼层错误");
176                         throw ex;
177                     }
178                 }
179                 else 
180                 {
181                     Exception ex = new Exception("获取的任务出错");
182                     throw ex;
183                 }
184             }
185             ele.isrun = false;
186         }
187 
188         public void operaGate(Elevator ele)//是否开门操作
189         {
190             if (ele.direction == UP)
191             {
192                 if(ele.panel[ele.floor]||uppanel[ele.floor])
193                 {
194                     ele.gatestatus = OPEN;
195                     //ele.direction = UP;
196                     ele.panel[ele.floor] = false;
197                     uppanel[ele.floor] = false;
198                     return;
199                 }
200                 if (!upAsk(ele))
201                 {
202                     if (downpanel[ele.floor])
203                     {
204                         ele.gatestatus = OPEN;
205                         ele.direction = DOWN;
206                         downpanel[ele.floor] = false;
207                         return;
208                     }
209                 }
210             }
211             else if (ele.direction == DOWN)
212             {
213                 if (ele.panel[ele.floor] || downpanel[ele.floor])
214                 {
215                     ele.gatestatus = OPEN;
216                     //ele.direction = DOWN;
217                     ele.panel[ele.floor] = false;
218                     downpanel[ele.floor] = false;
219                     return;
220                 }
221                 if (!downAsk(ele))
222                 {
223                     if (uppanel[ele.floor])
224                     {
225                         ele.gatestatus = OPEN;
226                         ele.direction = UP;
227                         uppanel[ele.floor] = false;
228                         return;
229                     }
230                 }
231             }
232             else
233             {
234                 Exception ex = new Exception("电梯状态出错");
235                 throw ex;
236             }
237         }
238 
239         public bool isGoOn(Elevator ele)//是否有任务判断
240         {
241             for (int i=0;i<10;++i)
242             {
243                 if (ele.panel[i])
244                 {
245                     return true;
246                 }
247                 if (uppanel[i])
248                 {
249                     return true;
250                 }
251                 if (downpanel[i])
252                 {
253                     return true; 
254                 }
255             }
256             return false;
257         }
258 
259         public int gettask(Elevator ele)//任务获取
260         {
261             if(ele.direction==UP)//方向上任务获取顺序
262             {
263                 if (upAsk(ele))
264                 {
265                     return MOVEUP;
266                 }
267                 if (downAsk(ele))
268                 {
269                     return MOVEDOWN;
270                 }
271             }
272             else if(ele.direction==DOWN)//方向下任务获取顺序
273             {
274                 if (downAsk(ele))
275                 {
276                     return MOVEDOWN;
277                 }
278                 if (upAsk(ele))
279                 {
280                     return MOVEUP;
281                 }
282             }
283             else
284             {
285                 Exception ex = new Exception("电梯状态出错");
286                 throw ex;
287             }
288             return NONE;
289         }
290 
291         public bool upAsk(Elevator ele)//上方查询
292         {
293             for (int i = ele.floor + 1; i < 10; ++i)
294             {
295                 if (ele.panel[i])
296                 {
297                     return true;
298                 }
299                 if (uppanel[i])
300                 {
301                     return true;
302                 }
303                 if (downpanel[i])
304                 {
305                     return true;
306                 }
307             }
308             return false;
309         }
310 
311         public bool downAsk(Elevator ele)//下方查询
312         {
313             for (int i = ele.floor - 1; i >= 0; --i)
314             {
315                 if (ele.panel[i])
316                 {
317                     return true;
318                 }
319                 if (uppanel[i])
320                 {
321                     return true;
322                 }
323                 if (downpanel[i])
324                 {
325                     return true;
326                 }
327             }
328             return false;
329         }
330 
331         public bool floorJudge(Elevator ele)
332         {
333             if (ele.floor>=0&&ele.floor<10)
334             { 
335                 return true;
336             }
337             return false;
338         }
339 
340     }
341 }
View Code

    3.Form1.CS

技术分享
  1 using System;
  2 using System.Collections.Generic;
  3 using System.ComponentModel;
  4 using System.Data;
  5 using System.Drawing;
  6 using System.Linq;
  7 using System.Text;
  8 using System.Windows.Forms;
  9 using System.Threading;
 10 
 11 namespace ElevatorManager
 12 {
 13     public partial class Form1 : Form
 14     {
 15         const int UP = 0;
 16         const int DOWN = 1;
 17         const int EXTERIOR = 0;
 18         const int INTERIOR = 1;
 19         const int ELE1 = 0;
 20         const int ELE2 = 1;
 21 
 22         const int CLOSE = 0;
 23         const int OPEN = 1;
 24 
 25         List<Button> btnUpPanel;
 26         List<Button> btnDownPanel;
 27         List<Button> btnEle1;
 28         List<Button> btnEle2;
 29         Thread th_ui;
 30         ElevatorController myElevator;
 31         Image imgEleOpen;
 32         Image imgEleClose;
 33 
 34         public Form1()
 35         {
 36             InitializeComponent();
 37             System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false;
 38         }
 39 
 40         private void Form1_Load(object sender, EventArgs e)
 41         {
 42             try
 43             {
 44                 btnUpPanel = new List<Button>();
 45                 btnDownPanel = new List<Button>();
 46                 btnEle1 = new List<Button>();
 47                 btnEle2 = new List<Button>();
 48 
 49                 #region 控件获取
 50                 btnUpPanel.Add(btn_1_up);
 51                 btnUpPanel.Add(btn_2_up);
 52                 btnUpPanel.Add(btn_3_up);
 53                 btnUpPanel.Add(btn_4_up);
 54                 btnUpPanel.Add(btn_5_up);
 55                 btnUpPanel.Add(btn_6_up);
 56                 btnUpPanel.Add(btn_7_up);
 57                 btnUpPanel.Add(btn_8_up);
 58                 btnUpPanel.Add(btn_9_up);
 59                 btnUpPanel.Add(new Button());
 60 
 61                 btnDownPanel.Add(new Button());
 62                 btnDownPanel.Add(btn_2_down);
 63                 btnDownPanel.Add(btn_3_down);
 64                 btnDownPanel.Add(btn_4_down);
 65                 btnDownPanel.Add(btn_5_down);
 66                 btnDownPanel.Add(btn_6_down);
 67                 btnDownPanel.Add(btn_7_down);
 68                 btnDownPanel.Add(btn_8_down);
 69                 btnDownPanel.Add(btn_9_down);
 70                 btnDownPanel.Add(btn_10_down);
 71 
 72                 btnEle1.Add(btn_e1_f1);
 73                 btnEle1.Add(btn_e1_f2);
 74                 btnEle1.Add(btn_e1_f3);
 75                 btnEle1.Add(btn_e1_f4);
 76                 btnEle1.Add(btn_e1_f5);
 77                 btnEle1.Add(btn_e1_f6);
 78                 btnEle1.Add(btn_e1_f7);
 79                 btnEle1.Add(btn_e1_f8);
 80                 btnEle1.Add(btn_e1_f9);
 81                 btnEle1.Add(btn_e1_f10);
 82 
 83                 btnEle2.Add(btn_e2_f1);
 84                 btnEle2.Add(btn_e2_f2);
 85                 btnEle2.Add(btn_e2_f3);
 86                 btnEle2.Add(btn_e2_f4);
 87                 btnEle2.Add(btn_e2_f5);
 88                 btnEle2.Add(btn_e2_f6);
 89                 btnEle2.Add(btn_e2_f7);
 90                 btnEle2.Add(btn_e2_f8);
 91                 btnEle2.Add(btn_e2_f9);
 92                 btnEle2.Add(btn_e2_f10);
 93                 #endregion
 94 
 95                 imgEleOpen=new Bitmap(@".\elevator_open.jpg");
 96                 imgEleClose=new Bitmap(@".\elevator_close.jpg");
 97 
 98                 myElevator=new ElevatorController();
 99                 MessageBox.Show("初始化成功!!!");
100             }
101             catch(Exception ex)
102             {
103                 MessageBox.Show(ex.Message);
104             }
105             th_ui = new Thread(new ThreadStart(UIController));
106             th_ui.IsBackground=true;
107             th_ui.Start();
108         }
109 
110         public void UIController()//UI控制线程
111         {
112             try
113             {
114                 for (; true; )
115                 {
116                     #region 面板灯
117                     for (int i = 0; i < 10; ++i)
118                     {
119                         if (myElevator.uppanel[i])
120                         {
121                             btnUpPanel[i].BackColor = Color.Yellow;
122                         }
123                         if (!myElevator.uppanel[i])
124                         {
125                             btnUpPanel[i].BackColor = Color.White;
126                         }
127                         //
128                         if (myElevator.downpanel[i])
129                         {
130                             btnDownPanel[i].BackColor = Color.Yellow;
131                         }
132                         if (!myElevator.downpanel[i])
133                         {
134                             btnDownPanel[i].BackColor = Color.White;
135                         }
136                         //
137                         if (myElevator.ele_1.panel[i])
138                         {
139                             btnEle1[i].BackColor = Color.Yellow;
140                         }
141                         if (!myElevator.ele_1.panel[i])
142                         {
143                             btnEle1[i].BackColor = Color.White;
144                         }
145                         //
146                         if (myElevator.ele_2.panel[i])
147                         {
148                             btnEle2[i].BackColor = Color.Yellow;
149                         }
150                         if (!myElevator.ele_2.panel[i])
151                         {
152                             btnEle2[i].BackColor = Color.White;
153                         }
154                     }
155                     #endregion
156 
157                     label_ele1.Text = "Ele1.floor:" + (myElevator.ele_1.floor + 1).ToString();
158                     label_ele2.Text = "Ele2.floor:" + (myElevator.ele_2.floor + 1).ToString();
159 
160                     picture_ele1.Location = new Point(picture_ele1.Location.X, 500 - (50 * myElevator.ele_1.floor));
161                     picture_ele2.Location = new Point(picture_ele2.Location.X, 500 - (50 * myElevator.ele_2.floor));
162                     
163                     if (myElevator.ele_1.gatestatus == CLOSE)
164                     {
165                         picture_ele1.Image = imgEleClose;
166                     }
167                     if (myElevator.ele_1.gatestatus == OPEN)
168                     {
169                         picture_ele1.Image = imgEleOpen;
170                     }
171                     if (myElevator.ele_2.gatestatus == CLOSE)
172                     {
173                         picture_ele2.Image = imgEleClose;
174                     }
175                     if (myElevator.ele_2.gatestatus == OPEN)
176                     {
177                         picture_ele2.Image = imgEleOpen;
178                     }
179 
180                     Thread.Sleep(100);
181                 }
182             }
183             catch (Exception ex)
184             {
185                 MessageBox.Show(ex.Message);
186             }
187         }
188 
189         private void btn_1_up_Click(object sender, EventArgs e)
190         {
191             try
192             {
193                 myElevator.operate(EXTERIOR, UP, 0);
194             }
195             catch (Exception ex)
196             {
197                 MessageBox.Show(ex.Message);
198             }
199         }
200 
201         private void btn_2_down_Click(object sender, EventArgs e)
202         {
203             try
204             {
205                 myElevator.operate(EXTERIOR, DOWN, 1);
206             }
207             catch (Exception ex)
208             {
209                 MessageBox.Show(ex.Message);
210             }
211         }
212 
213         private void btn_2_up_Click(object sender, EventArgs e)
214         {
215             try
216             {
217                 myElevator.operate(EXTERIOR, UP, 1);
218             }
219             catch (Exception ex)
220             {
221                 MessageBox.Show(ex.Message);
222             }
223         }
224 
225         private void btn_3_down_Click(object sender, EventArgs e)
226         {
227             try
228             {
229                 myElevator.operate(EXTERIOR, DOWN, 2);
230             }
231             catch (Exception ex)
232             {
233                 MessageBox.Show(ex.Message);
234             }
235         }
236 
237         private void btn_3_up_Click(object sender, EventArgs e)
238         {
239             try
240             {
241                 myElevator.operate(EXTERIOR, UP, 2);
242             }
243             catch (Exception ex)
244             {
245                 MessageBox.Show(ex.Message);
246             }
247         }
248 
249         private void btn_4_down_Click(object sender, EventArgs e)
250         {
251             try
252             {
253                 myElevator.operate(EXTERIOR, DOWN, 3);
254             }
255             catch (Exception ex)
256             {
257                 MessageBox.Show(ex.Message);
258             }
259         }
260 
261         private void btn_4_up_Click(object sender, EventArgs e)
262         {
263             try
264             {
265                 myElevator.operate(EXTERIOR, UP, 3);
266             }
267             catch (Exception ex)
268             {
269                 MessageBox.Show(ex.Message);
270             }
271         }
272 
273         private void btn_5_down_Click(object sender, EventArgs e)
274         {
275             try
276             {
277                 myElevator.operate(EXTERIOR, DOWN, 4);
278             }
279             catch (Exception ex)
280             {
281                 MessageBox.Show(ex.Message);
282             }
283         }
284 
285         private void btn_5_up_Click(object sender, EventArgs e)
286         {
287             try
288             {
289                 myElevator.operate(EXTERIOR, UP, 4);
290             }
291             catch (Exception ex)
292             {
293                 MessageBox.Show(ex.Message);
294             }
295         }
296 
297         private void btn_6_down_Click(object sender, EventArgs e)
298         {
299             try
300             {
301                 myElevator.operate(EXTERIOR, DOWN, 5);
302             }
303             catch (Exception ex)
304             {
305                 MessageBox.Show(ex.Message);
306             }
307         }
308 
309         private void btn_6_up_Click(object sender, EventArgs e)
310         {
311             try
312             {
313                 myElevator.operate(EXTERIOR, UP, 5);
314             }
315             catch (Exception ex)
316             {
317                 MessageBox.Show(ex.Message);
318             }
319         }
320 
321         private void btn_7_down_Click(object sender, EventArgs e)
322         {
323             try
324             {
325                 myElevator.operate(EXTERIOR, DOWN, 6);
326             }
327             catch (Exception ex)
328             {
329                 MessageBox.Show(ex.Message);
330             }
331         }
332 
333         private void btn_7_up_Click(object sender, EventArgs e)
334         {
335             try
336             {
337                 myElevator.operate(EXTERIOR, UP, 6);
338             }
339             catch (Exception ex)
340             {
341                 MessageBox.Show(ex.Message);
342             }
343         }
344 
345         private void btn_8_down_Click(object sender, EventArgs e)
346         {
347             try
348             {
349                 myElevator.operate(EXTERIOR, DOWN, 7);
350             }
351             catch (Exception ex)
352             {
353                 MessageBox.Show(ex.Message);
354             }
355         }
356 
357         private void btn_8_up_Click(object sender, EventArgs e)
358         {
359             try
360             {
361                 myElevator.operate(EXTERIOR, UP, 7);
362             }
363             catch (Exception ex)
364             {
365                 MessageBox.Show(ex.Message);
366             }
367         }
368 
369         private void btn_9_down_Click(object sender, EventArgs e)
370         {
371             try
372             {
373                 myElevator.operate(EXTERIOR, DOWN, 8);
374             }
375             catch (Exception ex)
376             {
377                 MessageBox.Show(ex.Message);
378             }
379         }
380 
381         private void btn_9_up_Click(object sender, EventArgs e)
382         {
383             try
384             {
385                 myElevator.operate(EXTERIOR, UP, 8);
386             }
387             catch (Exception ex)
388             {
389                 MessageBox.Show(ex.Message);
390             }
391         }
392 
393         private void btn_10_down_Click(object sender, EventArgs e)
394         {
395             try
396             {
397                 myElevator.operate(EXTERIOR, DOWN, 9);
398             }
399             catch (Exception ex)
400             {
401                 MessageBox.Show(ex.Message);
402             }
403         }
404 
405         private void btn_e1_f1_Click(object sender, EventArgs e)
406         {
407             try
408             {
409                 myElevator.operate(INTERIOR, ELE1, 0);
410             }
411             catch (Exception ex)
412             {
413                 MessageBox.Show(ex.Message);
414             }
415         }
416 
417         private void btn_e1_f2_Click(object sender, EventArgs e)
418         {
419             try
420             {
421                 myElevator.operate(INTERIOR, ELE1, 1);
422             }
423             catch (Exception ex)
424             {
425                 MessageBox.Show(ex.Message);
426             }
427         }
428 
429         private void btn_e1_f3_Click(object sender, EventArgs e)
430         {
431             try
432             {
433                 myElevator.operate(INTERIOR, ELE1, 2);
434             }
435             catch (Exception ex)
436             {
437                 MessageBox.Show(ex.Message);
438             }
439         }
440 
441         private void btn_e1_f4_Click(object sender, EventArgs e)
442         {
443             try
444             {
445                 myElevator.operate(INTERIOR, ELE1, 3);
446             }
447             catch (Exception ex)
448             {
449                 MessageBox.Show(ex.Message);
450             }
451         }
452 
453         private void btn_e1_f5_Click(object sender, EventArgs e)
454         {
455             try
456             {
457                 myElevator.operate(INTERIOR, ELE1, 4);
458             }
459             catch (Exception ex)
460             {
461                 MessageBox.Show(ex.Message);
462             }
463         }
464 
465         private void btn_e1_f6_Click(object sender, EventArgs e)
466         {
467             try
468             {
469                 myElevator.operate(INTERIOR, ELE1, 5);
470             }
471             catch (Exception ex)
472             {
473                 MessageBox.Show(ex.Message);
474             }
475         }
476 
477         private void btn_e1_f7_Click(object sender, EventArgs e)
478         {
479             try
480             {
481                 myElevator.operate(INTERIOR, ELE1, 6);
482             }
483             catch (Exception ex)
484             {
485                 MessageBox.Show(ex.Message);
486             }
487         }
488 
489         private void btn_e1_f8_Click(object sender, EventArgs e)
490         {
491             try
492             {
493                 myElevator.operate(INTERIOR, ELE1, 7);
494             }
495             catch (Exception ex)
496             {
497                 MessageBox.Show(ex.Message);
498             }
499         }
500 
501         private void btn_e1_f9_Click(object sender, EventArgs e)
502         {
503             try
504             {
505                 myElevator.operate(INTERIOR, ELE1, 8);
506             }
507             catch (Exception ex)
508             {
509                 MessageBox.Show(ex.Message);
510             }
511         }
512 
513         private void btn_e1_f10_Click(object sender, EventArgs e)
514         {
515             try
516             {
517                 myElevator.operate(INTERIOR, ELE1, 9);
518             }
519             catch (Exception ex)
520             {
521                 MessageBox.Show(ex.Message);
522             }
523         }
524 
525         private void btn_e2_f1_Click(object sender, EventArgs e)
526         {
527             try
528             {
529                 myElevator.operate(INTERIOR, ELE2, 0);
530             }
531             catch (Exception ex)
532             {
533                 MessageBox.Show(ex.Message);
534             }
535         }
536 
537         private void btn_e2_f2_Click(object sender, EventArgs e)
538         {
539             try
540             {
541                 myElevator.operate(INTERIOR, ELE2, 1);
542             }
543             catch (Exception ex)
544             {
545                 MessageBox.Show(ex.Message);
546             }
547         }
548 
549         private void btn_e2_f3_Click(object sender, EventArgs e)
550         {
551             try
552             {
553                 myElevator.operate(INTERIOR, ELE2, 2);
554             }
555             catch (Exception ex)
556             {
557                 MessageBox.Show(ex.Message);
558             }
559         }
560 
561         private void btn_e2_f4_Click(object sender, EventArgs e)
562         {
563             try
564             {
565                 myElevator.operate(INTERIOR, ELE2, 3);
566             }
567             catch (Exception ex)
568             {
569                 MessageBox.Show(ex.Message);
570             }
571         }
572 
573         private void btn_e2_f5_Click(object sender, EventArgs e)
574         {
575             try
576             {
577                 myElevator.operate(INTERIOR, ELE2, 4);
578             }
579             catch (Exception ex)
580             {
581                 MessageBox.Show(ex.Message);
582             }
583         }
584 
585         private void btn_e2_f6_Click(object sender, EventArgs e)
586         {
587             try
588             {
589                 myElevator.operate(INTERIOR, ELE2, 5);
590             }
591             catch (Exception ex)
592             {
593                 MessageBox.Show(ex.Message);
594             }
595         }
596 
597         private void btn_e2_f7_Click(object sender, EventArgs e)
598         {
599             try
600             {
601                 myElevator.operate(INTERIOR, ELE2, 6);
602             }
603             catch (Exception ex)
604             {
605                 MessageBox.Show(ex.Message);
606             }
607         }
608 
609         private void btn_e2_f8_Click(object sender, EventArgs e)
610         {
611             try
612             {
613                 myElevator.operate(INTERIOR, ELE2, 7);
614             }
615             catch (Exception ex)
616             {
617                 MessageBox.Show(ex.Message);
618             }
619         }
620 
621         private void btn_e2_f9_Click(object sender, EventArgs e)
622         {
623             try
624             {
625                 myElevator.operate(INTERIOR, ELE2, 8);
626             }
627             catch (Exception ex)
628             {
629                 MessageBox.Show(ex.Message);
630             }
631         }
632 
633         private void btn_e2_f10_Click(object sender, EventArgs e)
634         {
635             try
636             {
637                 myElevator.operate(INTERIOR, ELE2, 9);
638             }
639             catch (Exception ex)
640             {
641                 MessageBox.Show(ex.Message);
642             }
643         }
644     }
645 }
View Code

 

四、测试结果  

   结过几周的不断编写和调试,最后程序得已成功运行,期间查看了不少的资料和信息,特别 是对于画布的设计效果,还有就是对于电梯开关时的音效.  

  下面是测试效果:

  1开始界面,初使是默认在第一层:

 

结对项目开发电梯调度 - 整体设计

标签:

原文地址:http://www.cnblogs.com/luyu2783/p/4575483.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!