Advertisement
Guest User

set direction

a guest
Mar 1st, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. void FSM_set_current_direction(){
  2. puts("FSM_set_current_direction");
  3.  
  4.  
  5.  
  6.  
  7. if (qSys_is_order_array_empty()){
  8. puts("order array empty...");
  9. FSM_current_direction = 0;
  10. return;
  11. }
  12.  
  13.  
  14.  
  15. if(elev_get_floor_sensor_signal() == -1 ){
  16.  
  17. if(FSM_current_direction == DIRN_UP){
  18. if(FSM_orders_above())
  19. FSM_current_direction = DIRN_UP;
  20. else if(FSM_orders_below())
  21. FSM_current_direction = DIRN_DOWN;
  22. else
  23. FSM_current_direction = DIRN_DOWN;
  24. }
  25. else if (FSM_current_direction == DIRN_DOWN){
  26. if(FSM_orders_above())
  27. FSM_current_direction = DIRN_UP;
  28. else if(FSM_orders_below())
  29. FSM_current_direction = DIRN_DOWN;
  30. else
  31. FSM_current_direction = DIRN_DOWN;
  32.  
  33. }
  34. }
  35.  
  36. if(FSM_current_direction == DIRN_UP){
  37. puts("On its way up...\n");
  38.  
  39. if(FSM_orders_above()){
  40. puts("dir set to up");
  41.  
  42. return;
  43. }
  44. else if (FSM_orders_below()){
  45. FSM_current_direction = DIRN_STOP;
  46. puts("dir set to down");
  47.  
  48. return;
  49. }
  50. else{
  51. FSM_current_direction = DIRN_STOP;
  52. puts("dir set to stop");
  53.  
  54. return;
  55. }
  56. }
  57.  
  58. else if(FSM_current_direction == DIRN_DOWN){
  59. puts("On its way down...\n");
  60. if(FSM_orders_below()){
  61. puts("dir set to down");
  62.  
  63. return;
  64. }
  65. else if (FSM_orders_above){
  66. FSM_current_direction = DIRN_UP;
  67. puts("dir set to up");
  68. return;
  69. }
  70. else{
  71. FSM_current_direction = DIRN_STOP;
  72. puts("dir set to stop");
  73.  
  74. return;
  75. }
  76.  
  77. }
  78. else{
  79. if(FSM_orders_above()){
  80. puts("On its way nowhere...\n");
  81.  
  82. FSM_current_direction = DIRN_UP;
  83. puts("dir set to up");
  84.  
  85. return;
  86. }
  87. else if (FSM_orders_below()){
  88. FSM_current_direction = DIRN_DOWN;
  89. puts("dir set to down");
  90.  
  91. return;
  92. }
  93. else{
  94. FSM_current_direction = DIRN_STOP;
  95. puts("dir set to stop");
  96.  
  97. return;
  98. }
  99. }
  100.  
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement