diff --git a/Makefile b/Makefile index ba2773f..8e1ba79 100644 --- a/Makefile +++ b/Makefile @@ -12,20 +12,24 @@ CONFIG=src/config.h #config file #targets -debug: ui planner db iCal - gcc ui.o planner.o db.o iCal.o -o debugOut +debug: test ui planner db iCal config + gcc test.o ui.o planner.o db.o iCal.o -o debugOut +config: $(CONFIG) + gcc -c $(CFLAGS) $(CONFIG) +test: src/test.c + gcc -c $(CFLAGS) src/test.c iCal: $(CALF) gcc -c $(CFLAGS) $(CALF) -ui: $(UIF) $(CONFIG) +ui: $(UIF) gcc -c $(CFLAGS) $(UIF) -planner: $(PLF) $(CONFIG) +planner: $(PLF) gcc -c $(CFLAGS) $(PLF) -db: $(DBF) $(CONFIG) +db: $(DBF) gcc -c $(CFLAGS) $(DBF) clean: - rm -rf *.o debugOut + rm -rf *.o debugOut src/*.gch diff --git a/README.md b/README.md index 3ef6a53..54ed37b 100644 --- a/README.md +++ b/README.md @@ -25,3 +25,20 @@ Time management optimisation tool. - Use cake cutting algorithm to calculate timetable based on subject priorities and available time. - output in iCal format + +# Responsiilities + +- Juergen: ui +- carla: ical +- jan: db +- simon: planner + +# Project Overview + + ![Overview Flowchart](doc/overview.png) + +sample files in src/ + +# Datatypes + +[planner.h](src/planner.h) diff --git a/debugOut b/debugOut new file mode 100755 index 0000000..590cb1a Binary files /dev/null and b/debugOut differ diff --git a/doc/docu.md b/doc/docu.md index a2334fd..fa7cc69 100644 --- a/doc/docu.md +++ b/doc/docu.md @@ -8,6 +8,7 @@ typedef struct Subject{ time_t * created; time_t * deadline; int priority; + unsigned long long spare; } Subject; @@ -15,15 +16,8 @@ typedef struct Event { Subject subject; time_t plannedStartTime; time_t plannedEndTime; + unsigned long long spare; }Event; - -//to Ical -typedef struct DayPlan{ - time_t date; - Event ** plan; //arr of event* - size_t planLen;//len of plan array - size_t planSize;//allocated space fro plan array -}DayPlan; ``` ## Functionality diff --git a/doc/overview.drawio b/doc/overview.drawio new file mode 100644 index 0000000..a3a924e --- /dev/null +++ b/doc/overview.drawio @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/overview.png b/doc/overview.png new file mode 100644 index 0000000..6185182 Binary files /dev/null and b/doc/overview.png differ diff --git a/src/config.h b/src/config.h index 532710f..85f65c0 100644 --- a/src/config.h +++ b/src/config.h @@ -1,15 +1,15 @@ -/* Global config file should be importet by all +/* Global config file */ #ifndef CONFIG #define CONFIG #include +// #define seconds(n) (n * CLOCKS_PER_SEC) +#define minutes(n) (60 * n) +#define hours(n) (60 * minutes(n)) +#define days(n) (24 * hours(n)) -#define seconds(n) (n * CLOCKS_PER_SEC) -#define minutes(n) (n * 60 * seconds(n)) -#define hours(n) (n * 60 *(minutes(n)) - -const time_t pauseLenght = minutes(15); -const time_t minIntervalLen = minutes(30); +static const time_t pauseLenght = minutes(15); +static const time_t minIntervalLen = minutes(30); #endif diff --git a/src/db.c b/src/db.c index f3de444..a41e013 100644 --- a/src/db.c +++ b/src/db.c @@ -1,24 +1,20 @@ /* - * databse - * stores current state and reads previous + * INPUT: query for sotred date + * linked list of subjects to sotore + * + * OUTPUT: + * linked list of subjects from file + * OK + * + * */ - + +#include "planner.h" #include -const char format[] = "{ %s = { %s}\n"; -struct A { - char *s1; - char *s2; -}A; -int main(){ - -struct A test; - - test.s1 = "asdasd"; - test.s2 = "asdad"; - - -printf(format, test.s1, test.s2); - - +// serialize struct test +const char format[] = "{%s = {%lu, %lu, %d}\n"; // +int serialize(Subject *s) { + printf(format, s->name, s->created, s->deadline, s->priority); + return 0; } diff --git a/src/db.h b/src/db.h index 5db617d..01cea33 100644 --- a/src/db.h +++ b/src/db.h @@ -1,4 +1,7 @@ #ifndef DB #define DB +#include "planner.h" +int serialize(Subject *s); + #endif diff --git a/src/iCal.c b/src/iCal.c index e69de29..dd9b037 100644 --- a/src/iCal.c +++ b/src/iCal.c @@ -0,0 +1,6 @@ +/* INPUT: linked list of events and generate ical file + * OUTPUT: Ical File, OK to caller + * + */ + +#include "planner.h" // for subject and event structs diff --git a/src/planner.c b/src/planner.c index ecd8c57..5583fd8 100644 --- a/src/planner.c +++ b/src/planner.c @@ -1,7 +1,10 @@ /* - * Main Plannder - * gets data from user or db - * generates timetable - * modify data for next day and send to db + * INPUT: linked list of subjects + * OUTPUT: ll of events to iCal + * ll of updated subjects to db for next day + * return events_ll to caller(ui)?? * */ + +#include "planner.h" // for subject and event structs +#include "config.h" diff --git a/src/planner.h b/src/planner.h index cdfdf7f..3b2c37d 100644 --- a/src/planner.h +++ b/src/planner.h @@ -1,4 +1,22 @@ #ifndef PLANNER #define PLANNER +#include + +typedef struct Subject { + char *name; + time_t created; + time_t deadline; + int priority; + unsigned long long spare; +} Subject; + +typedef struct Event { + Subject subject; + time_t plannedStartTime; + time_t plannedEndTime; + unsigned long long spare; +} Event; + +int genPlan(Subject *head); #endif // !PLANNER diff --git a/src/test.c b/src/test.c new file mode 100644 index 0000000..0427e6c --- /dev/null +++ b/src/test.c @@ -0,0 +1,29 @@ +#include "config.h" +#include "db.h" +#include "iCal.h" +#include "planner.h" // for subject and event structs +#include "ui.h" +#include + +int main() { + + time_t now = time(NULL); + + Subject t1 = {.name = "LinAlg", + .created = now, + .deadline = now + days(5), + .priority = 3}; + + Subject t2 = { + .name = "Phys", .created = now, .deadline = now + days(2), .priority = 7}; + + // create plan + // planner([t1,t2]) + // + printf("%s\n", ctime(&now)); + + serialize(&t1); + serialize(&t2); + + return 0; +} diff --git a/src/ui.c b/src/ui.c index 5e247da..9a032b3 100644 --- a/src/ui.c +++ b/src/ui.c @@ -2,3 +2,4 @@ * command line interface for user input * */ +#include "planner.h" // for subject and event structs