Skip to content

Commit

Permalink
PRP2-A3 serious bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jtByt.Pictures authored and jtByt.Pictures committed Jun 3, 2014
1 parent 510dd0b commit 129c5b0
Show file tree
Hide file tree
Showing 7 changed files with 187 additions and 160 deletions.
29 changes: 17 additions & 12 deletions PRP2-A3/listDatabase.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* file: listDatabase.c
* project: BScMech2-SoSe14-PRP2
* version: 1.2 (14.05.2014 15:30)
* version: 1.2.1 (03.06.2014 12:30)
* - 0.1 first version
* - 0.2 first "basic" list functions
* - 0.3 many safety functions added
Expand All @@ -10,6 +10,7 @@
* - 1.0 major changes
* - 1.1 enhanced with prewNode pointer
* - 1.2 addNode initializes data with given dataPtr
* - 1.2.1 bugfix at outputList and addNode
*
*
* Created by Jannik Beyerstedt
Expand All @@ -32,7 +33,7 @@ struct listNode {
struct listNode *nextNode;
struct listNode *prewNode;
};
typedef struct listNode *listNodePtr;
typedef struct listNode *listNodePtr;

struct listMeta {
unsigned int length;
Expand All @@ -45,10 +46,10 @@ typedef struct listMeta *list_t;

list_t initializeList () {
list_t list = malloc(sizeof(struct listMeta));
list->length = 0;
list->firstNodePtr = NULL;
list->lastNodePtr = NULL;
return list;
list->length = 0;
list->firstNodePtr = NULL;
list->lastNodePtr = NULL;
return list;
}


Expand All @@ -70,6 +71,8 @@ int addNodeAtEnd (list_t list, listDataPtr dataPtr) {
}else {
oldLastNode->nextNode = list->lastNodePtr;
list->lastNodePtr->prewNode = oldLastNode;
list->lastNodePtr->nextNode = NULL;
list->lastNodePtr->dataPtr = dataPtr;
}
return 1;
}// end list safety
Expand All @@ -94,6 +97,8 @@ int addNodeAtStart (list_t list, listDataPtr dataPtr) {
}else { // add second+ element
list->firstNodePtr->nextNode = newSecondNode;
newSecondNode->prewNode = list->firstNodePtr;
list->firstNodePtr->nextNode = newSecondNode;
list->firstNodePtr->dataPtr = dataPtr;
}
return 1;
}// end list safety
Expand Down Expand Up @@ -127,8 +132,8 @@ listDataPtr getNodeData (list_t list, int nodeNo) {
nodePtr = nodePtr->prewNode;
}
return nodePtr->dataPtr;


}else {
printf("ERROR: getNodeData: invalid nodePos number\n");
return NULL;
Expand Down Expand Up @@ -265,10 +270,10 @@ int outputList (list_t list) {
fprintf(file, "%04i-%02i-%02i T%02i:%02i:%02i;",tvar->tm_year+1900, tvar->tm_mon+1, tvar->tm_mday, tvar->tm_hour, tvar->tm_min, tvar->tm_sec);
printf("%04i-%02i-%02i T%02i:%02i:%02i; ",tvar->tm_year+1900, tvar->tm_mon+1, tvar->tm_mday, tvar->tm_hour, tvar->tm_min, tvar->tm_sec);

fprintf(file, "%i;", *(Boolean *) data->height);
printf("%i; ", *(Boolean *) data->height);
fprintf(file, "%i;", *(Boolean *) data->metal);
printf("%i; ", *(Boolean *) data->metal);
fprintf(file, "%i;", (Boolean) data->height);
printf("%i; ", (Boolean) data->height);
fprintf(file, "%i;", (Boolean) data->metal);
printf("%i; ", (Boolean) data->metal);

tvar = localtime(&data->outputTime);
fprintf(file, "%04i-%02i-%02i T%02i:%02i:%02i;",tvar->tm_year+1900, tvar->tm_mon+1, tvar->tm_mday, tvar->tm_hour, tvar->tm_min, tvar->tm_sec);
Expand Down
3 changes: 2 additions & 1 deletion PRP2-A3/listDatabase.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* file: listDatabase.c
* project: BScMech2-SoSe14-PRP2
* version: 1.2 (14.05.2014 15:30)
* version: 1.2.1 (03.06.2014 12:30)
* - 0.1 first version
* - 0.2 first "basic" list functions
* - 0.3 many safety functions added
Expand All @@ -10,6 +10,7 @@
* - 1.0 major changes
* - 1.1 enhanced with prewNode pointer
* - 1.2 addNode initializes data with given dataPtr
* - 1.2.1 bugfix at outputList
*
*
* Created by Jannik Beyerstedt
Expand Down
16 changes: 11 additions & 5 deletions PRP2-A3/stateMachine.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
/*
* file: stateMachine.c
* project: BScMech2-SoSe14-PRP2
* version: 2.2 (14.05.2014 15:30)
* version: 2.2.1 (03.06.2014 12:30)
* - 0.1 first version
* - 0.2 first and bugs fixed
* - 0.3 initial logic enhanced, main must not initialize currentState
* - 1.0 tested and OK, state logic enhancements
* - 2.0 rewritten for PRP2-A3
* - 2.1 changes for listDatabase v1.0 + minor bug-fixes
* - 2.2 changes for listDatabase v1.2
* - 2.2.1 serious bug fixes for dataStore
*
*
* Created by Jannik Beyerstedt
Expand All @@ -34,13 +35,13 @@ States savedState = INIT;
time_t junctionOpenTime = 0;
double junctionOpenDelay = 10; // seconds

list_t itemsList = NULL; // the list itself

listDataPtr dataStore = NULL; // temporary space for information


void theMachine() {

list_t itemsList = NULL;

listDataPtr dataStore = NULL;


switch (currentState) {
case START:
Expand Down Expand Up @@ -236,6 +237,7 @@ void theMachine() {
time(&dataStore->outputTime);

addNodeAtEnd(itemsList, dataStore); // add node and store data
dataStore = NULL;

clearBitInOutput(MOTOR_R | JUNCTION | LED_Q2 | LIGHT_YE);
junctionOpenTime = 0;
Expand All @@ -259,6 +261,8 @@ void theMachine() {
time(&dataStore->outputTime);

addNodeAtEnd(itemsList, dataStore); // add node and store data
dataStore = NULL;


clearBitInOutput(MOTOR_R | LIGHT_YE);
setBitInOutput(LED_START);
Expand Down Expand Up @@ -309,6 +313,8 @@ void theMachine() {
currentState = E_STOP;
printf("new: E_STOP\n");
}else if (hasTriggered(BTN_START)) {
outputList(itemsList);

clearBitInOutput(ALL_VALUES);
setBitInOutput(LED_START);

Expand Down
3 changes: 2 additions & 1 deletion PRP2-A3/stateMachine.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
/*
* file: stateMachine.c
* project: BScMech2-SoSe14-PRP2
* version: 2.2 (14.05.2014 15:30)
* version: 2.2.1 (03.06.2014 12:30)
* - 0.1 first version
* - 0.2 first and bugs fixed
* - 0.3 initial logic enhanced, main must not initialize currentState
* - 1.0 tested and OK, state logic enhancements
* - 2.0 rewritten for PRP2-A3
* - 2.1 changes for listDatabase v1.0 + minor bug-fixes
* - 2.2 changes for listDatabase v1.2
* - 2.2.1 serious bug fixes for dataStore
*
*
* Created by Jannik Beyerstedt
Expand Down
Loading

0 comments on commit 129c5b0

Please sign in to comment.