Skip to content

Commit

Permalink
Merge pull request #2 from angrycompany16/elisa_branch
Browse files Browse the repository at this point in the history
Elisa branch
  • Loading branch information
elisaakj authored Feb 19, 2024
2 parents 5725921 + a70dfd7 commit c4a76de
Show file tree
Hide file tree
Showing 3 changed files with 395 additions and 3 deletions.
13 changes: 10 additions & 3 deletions skeleton_project/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
#include <time.h>
#include <unistd.h>
#include "driver/elevio.h"
#include "state_machine.h"
#include "queue.h"


int main(){

/*
elevio_init();
Queue* p_main_queue = queue_init();
queue_add(p_main_queue, (Request){2, true, true});
Expand All @@ -24,7 +28,10 @@ int main(){
queue_print(p_main_queue);
queue_deinit(p_main_queue);
nanosleep(&(struct timespec){0, 20*1000*1000}, NULL);
}
*/

return 0;

return 0;
}
}
347 changes: 347 additions & 0 deletions skeleton_project/source/state_machine.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,347 @@
#include "state_machine.h"

void behaviour(State* p_current_state){

switch(*p_current_state) {
// RETNING FULLHET DØR OBSTRUKSJON
case UP_EMPTY:
// opp tom lukket false
elevio_motorDirection(DIRN_UP);
break;
case UP_UNEMPTY:
// opp utom lukket false
elevio_motorDirection(DIRN_UP);
break;
case DOWN_EMPTY:
printf("State: %d\n",*p_current_state); //test
// ned tom lukket false
elevio_motorDirection(DIRN_DOWN);
break;
case DOWN_UNEMPTY:
// ned utom lukket false
elevio_motorDirection(DIRN_DOWN);
break;
case OPEN_EMPTY:
// stille tom åpen false
elevio_motorDirection(DIRN_STOP);
break;
case OPEN_UNEMPTY:
// stille utom åpen false
elevio_motorDirection(DIRN_STOP);
break;
case CLOSED_EMPTY:
// stille tom lukket false
elevio_motorDirection(DIRN_STOP);
break;
case CLOSED_UNEMPTY:
// stille utom lukket false
elevio_motorDirection(DIRN_STOP);
break;
case BLOCKED_EMPTY:
// stille tom åpen true
elevio_motorDirection(DIRN_STOP);
break;
case BLOCKED_UNEMPTY:
// stille utom åpen true
elevio_motorDirection(DIRN_STOP);
break;
}
}


void transition(State* p_current_state, Trigger trigger){

switch(*p_current_state) {

case UP_EMPTY:
switch(trigger){
case STOP:
// do something
break;
case ENTERED_FLOOR:
// do something
break;
case OBSTRUCTION:
// do something
break;
case TIMER:
// do something
break;
case UP:
// do something
break;
case DOWN:
// do something
break;
case STAY:
// do something
break;
default:
// do something
;
}
break;

case UP_UNEMPTY:
switch(trigger){
case STOP:
// do something
break;
case ENTERED_FLOOR:
// do something
break;
case OBSTRUCTION:
// do something
break;
case TIMER:
// do something
break;
case UP:
// do something
break;
case DOWN:
// do something
break;
case STAY:
// do something
break;
default:
// do something
;
}
break;

case DOWN_EMPTY:
switch(trigger){
case STOP:
// do something
break;
case ENTERED_FLOOR:
// do something
break;
case OBSTRUCTION:
// do something
break;
case TIMER:
// do something
break;
case UP:
// do something
break;
case DOWN:
// do something
break;
case STAY:
// do something
break;
default:
// do something
;
}
break;

case DOWN_UNEMPTY:
switch(trigger){
case STOP:
// do something
break;
case ENTERED_FLOOR:
// do something
break;
case OBSTRUCTION:
// do something
break;
case TIMER:
// do something
break;
case UP:
// do something
break;
case DOWN:
// do something
break;
case STAY:
// do something
break;
default:
// do something
;
}
break;

case OPEN_EMPTY:
switch(trigger){
case STOP:
// do something
break;
case ENTERED_FLOOR:
// do something
break;
case OBSTRUCTION:
// do something
break;
case TIMER:
// do something
break;
case UP:
// do something
break;
case DOWN:
// do something
break;
case STAY:
// do something
break;
default:
// do something
;
}
break;

case OPEN_UNEMPTY:
switch(trigger){
case STOP:
// do something
break;
case ENTERED_FLOOR:
// do something
break;
case OBSTRUCTION:
// do something
break;
case TIMER:
// do something
break;
case UP:
// do something
break;
case DOWN:
// do something
break;
case STAY:
// do something
break;
default:
// do something
;
}
break;

case CLOSED_EMPTY:
switch(trigger){
case STOP:
// do something
break;
case ENTERED_FLOOR:
// do something
break;
case OBSTRUCTION:
// do something
break;
case TIMER:
// do something
break;
case UP:
// do something
break;
case DOWN:
// do something
break;
case STAY:
// do something
break;
default:
// do something
;
}
break;

case CLOSED_UNEMPTY:
switch(trigger){
case STOP:
// do something
break;
case ENTERED_FLOOR:
// do something
break;
case OBSTRUCTION:
// do something
break;
case TIMER:
// do something
break;
case UP:
// do something
break;
case DOWN:
// do something
break;
case STAY:
// do something
break;
default:
// do something
;
}
break;

case BLOCKED_EMPTY:
switch(trigger){
case STOP:
// do something
break;
case ENTERED_FLOOR:
// do something
break;
case OBSTRUCTION:
// do something
break;
case TIMER:
// do something
break;
case UP:
// do something
break;
case DOWN:
// do something
break;
case STAY:
// do something
break;
default:
// do something
;
}
break;

case BLOCKED_UNEMPTY:
switch(trigger){
case STOP:
// do something
break;
case ENTERED_FLOOR:
// do something
break;
case OBSTRUCTION:
// do something
break;
case TIMER:
// do something
break;
case UP:
// do something
break;
case DOWN:
// do something
break;
case STAY:
// do something
break;
default:
// do something
;
}
break;
}

}
Loading

0 comments on commit c4a76de

Please sign in to comment.