modified: Makefile

modified:   README.md
	new file:   debugOut
	modified:   doc/docu.md
	new file:   doc/overview.drawio
	new file:   doc/overview.png
	modified:   src/config.h
	modified:   src/db.c
	modified:   src/db.h
	modified:   src/iCal.c
	modified:   src/planner.c
	modified:   src/planner.h
	new file:   src/test.c
	modified:   src/ui.c

 Changes not staged for commit:
	deleted:    debugOut
sql
simon 2024-12-10 22:06:49 +01:00
parent 550a452249
commit b502e8040c
14 changed files with 231 additions and 44 deletions

View File

@ -12,20 +12,24 @@ CONFIG=src/config.h #config file
#targets #targets
debug: ui planner db iCal debug: test ui planner db iCal config
gcc ui.o planner.o db.o iCal.o -o debugOut 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) iCal: $(CALF)
gcc -c $(CFLAGS) $(CALF) gcc -c $(CFLAGS) $(CALF)
ui: $(UIF) $(CONFIG) ui: $(UIF)
gcc -c $(CFLAGS) $(UIF) gcc -c $(CFLAGS) $(UIF)
planner: $(PLF) $(CONFIG) planner: $(PLF)
gcc -c $(CFLAGS) $(PLF) gcc -c $(CFLAGS) $(PLF)
db: $(DBF) $(CONFIG) db: $(DBF)
gcc -c $(CFLAGS) $(DBF) gcc -c $(CFLAGS) $(DBF)
clean: clean:
rm -rf *.o debugOut rm -rf *.o debugOut src/*.gch

View File

@ -25,3 +25,20 @@ Time management optimisation tool.
- Use cake cutting algorithm to calculate timetable based on subject priorities and available time. - Use cake cutting algorithm to calculate timetable based on subject priorities and available time.
- output in iCal format - 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)

BIN
debugOut Executable file

Binary file not shown.

View File

@ -8,6 +8,7 @@ typedef struct Subject{
time_t * created; time_t * created;
time_t * deadline; time_t * deadline;
int priority; int priority;
unsigned long long spare;
} Subject; } Subject;
@ -15,15 +16,8 @@ typedef struct Event {
Subject subject; Subject subject;
time_t plannedStartTime; time_t plannedStartTime;
time_t plannedEndTime; time_t plannedEndTime;
unsigned long long spare;
}Event; }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 ## Functionality

116
doc/overview.drawio Normal file
View File

@ -0,0 +1,116 @@
<mxfile host="Electron" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/25.0.2 Chrome/128.0.6613.186 Electron/32.2.7 Safari/537.36" version="25.0.2">
<diagram id="C5RBs43oDa-KdzZeNtuy" name="Page-1">
<mxGraphModel dx="1527" dy="2012" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
<root>
<mxCell id="WIyWlLk6GJQsqaUBKTNV-0" />
<mxCell id="WIyWlLk6GJQsqaUBKTNV-1" parent="WIyWlLk6GJQsqaUBKTNV-0" />
<mxCell id="sFZgEorzihY-HOV9npow-39" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=1;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="WIyWlLk6GJQsqaUBKTNV-1" source="sFZgEorzihY-HOV9npow-5" target="sFZgEorzihY-HOV9npow-36">
<mxGeometry relative="1" as="geometry">
<mxPoint x="-10" y="-10" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="sFZgEorzihY-HOV9npow-5" value="ui" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
<mxGeometry x="90" y="20" width="120" height="80" as="geometry" />
</mxCell>
<mxCell id="sFZgEorzihY-HOV9npow-6" value="db" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
<mxGeometry x="90" y="460" width="120" height="80" as="geometry" />
</mxCell>
<mxCell id="sFZgEorzihY-HOV9npow-20" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="WIyWlLk6GJQsqaUBKTNV-1" source="sFZgEorzihY-HOV9npow-7" target="sFZgEorzihY-HOV9npow-21">
<mxGeometry relative="1" as="geometry">
<mxPoint x="490" y="520" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="sFZgEorzihY-HOV9npow-7" value="iCal" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
<mxGeometry x="430" y="360" width="120" height="80" as="geometry" />
</mxCell>
<mxCell id="sFZgEorzihY-HOV9npow-8" value="planner" style="ellipse;whiteSpace=wrap;html=1;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
<mxGeometry x="430" y="30" width="120" height="80" as="geometry" />
</mxCell>
<mxCell id="sFZgEorzihY-HOV9npow-10" value="" style="curved=1;endArrow=classic;html=1;rounded=0;entryX=0.025;entryY=0.313;entryDx=0;entryDy=0;exitX=0;exitY=0.5;exitDx=0;exitDy=0;entryPerimeter=0;" edge="1" parent="WIyWlLk6GJQsqaUBKTNV-1" source="sFZgEorzihY-HOV9npow-5" target="sFZgEorzihY-HOV9npow-6">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="180" y="240" as="sourcePoint" />
<mxPoint x="140" y="280" as="targetPoint" />
<Array as="points">
<mxPoint x="50" y="180" />
<mxPoint x="30" y="370" />
<mxPoint x="80" y="430" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="sFZgEorzihY-HOV9npow-11" value="get stored subjects&lt;div&gt;&lt;br&gt;&lt;/div&gt;" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
<mxGeometry x="30" y="290" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="sFZgEorzihY-HOV9npow-12" value="" style="curved=1;endArrow=classic;html=1;rounded=0;exitX=0.5;exitY=0;exitDx=0;exitDy=0;entryX=0.5;entryY=1;entryDx=0;entryDy=0;" edge="1" parent="WIyWlLk6GJQsqaUBKTNV-1" source="sFZgEorzihY-HOV9npow-6" target="sFZgEorzihY-HOV9npow-5">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="290" y="310" as="sourcePoint" />
<mxPoint x="160" y="110" as="targetPoint" />
<Array as="points">
<mxPoint x="130" y="320" />
<mxPoint x="150" y="210" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="sFZgEorzihY-HOV9npow-13" value="return stored data" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
<mxGeometry x="130" y="280" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="sFZgEorzihY-HOV9npow-14" value="" style="endArrow=classic;html=1;rounded=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" edge="1" parent="WIyWlLk6GJQsqaUBKTNV-1" source="sFZgEorzihY-HOV9npow-5" target="sFZgEorzihY-HOV9npow-8">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="290" y="310" as="sourcePoint" />
<mxPoint x="340" y="260" as="targetPoint" />
<Array as="points" />
</mxGeometry>
</mxCell>
<mxCell id="sFZgEorzihY-HOV9npow-15" value="send subjects" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
<mxGeometry x="250" y="20" width="100" height="30" as="geometry" />
</mxCell>
<mxCell id="sFZgEorzihY-HOV9npow-18" value="" style="endArrow=classic;html=1;rounded=0;exitX=0.45;exitY=0.988;exitDx=0;exitDy=0;exitPerimeter=0;" edge="1" parent="WIyWlLk6GJQsqaUBKTNV-1" source="sFZgEorzihY-HOV9npow-8" target="sFZgEorzihY-HOV9npow-7">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="500" y="120" as="sourcePoint" />
<mxPoint x="340" y="260" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="sFZgEorzihY-HOV9npow-19" value="send event list" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
<mxGeometry x="490" y="190" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="sFZgEorzihY-HOV9npow-21" value="generate and safe iCal file" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
<mxGeometry x="430" y="490" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="sFZgEorzihY-HOV9npow-22" value="" style="endArrow=classic;html=1;rounded=0;entryX=1;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="WIyWlLk6GJQsqaUBKTNV-1" source="sFZgEorzihY-HOV9npow-8" target="sFZgEorzihY-HOV9npow-6">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="290" y="310" as="sourcePoint" />
<mxPoint x="340" y="260" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="sFZgEorzihY-HOV9npow-23" value="send updated subjects" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
<mxGeometry x="260" y="270" width="60" height="30" as="geometry" />
</mxCell>
<mxCell id="sFZgEorzihY-HOV9npow-24" value="subject db file" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
<mxGeometry x="90" y="620" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="sFZgEorzihY-HOV9npow-25" value="" style="endArrow=classic;html=1;rounded=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" edge="1" parent="WIyWlLk6GJQsqaUBKTNV-1" source="sFZgEorzihY-HOV9npow-6" target="sFZgEorzihY-HOV9npow-24">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="290" y="440" as="sourcePoint" />
<mxPoint x="340" y="390" as="targetPoint" />
<Array as="points" />
</mxGeometry>
</mxCell>
<mxCell id="sFZgEorzihY-HOV9npow-26" value="" style="endArrow=classic;startArrow=classic;html=1;rounded=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="WIyWlLk6GJQsqaUBKTNV-1" source="sFZgEorzihY-HOV9npow-6" target="sFZgEorzihY-HOV9npow-24">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="290" y="440" as="sourcePoint" />
<mxPoint x="340" y="390" as="targetPoint" />
<Array as="points" />
</mxGeometry>
</mxCell>
<mxCell id="sFZgEorzihY-HOV9npow-27" value="serialise/deserialise&lt;div&gt;&lt;br&gt;&lt;/div&gt;" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
<mxGeometry x="150" y="573" width="130" height="40" as="geometry" />
</mxCell>
<mxCell id="sFZgEorzihY-HOV9npow-36" value="" style="shape=actor;whiteSpace=wrap;html=1;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
<mxGeometry x="-30" y="-80" width="40" height="60" as="geometry" />
</mxCell>
<mxCell id="sFZgEorzihY-HOV9npow-40" value="ask human for input" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="WIyWlLk6GJQsqaUBKTNV-1">
<mxGeometry x="-10" y="20" width="60" height="30" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>

BIN
doc/overview.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

View File

@ -1,15 +1,15 @@
/* Global config file should be importet by all /* Global config file
*/ */
#ifndef CONFIG #ifndef CONFIG
#define CONFIG #define CONFIG
#include <time.h> #include <time.h>
// #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) static const time_t pauseLenght = minutes(15);
#define minutes(n) (n * 60 * seconds(n)) static const time_t minIntervalLen = minutes(30);
#define hours(n) (n * 60 *(minutes(n))
const time_t pauseLenght = minutes(15);
const time_t minIntervalLen = minutes(30);
#endif #endif

View File

@ -1,24 +1,20 @@
/* /*
* databse * INPUT: query for sotred date
* stores current state and reads previous * linked list of subjects to sotore
*
* OUTPUT:
* linked list of subjects from file
* OK
*
*
*/ */
#include "planner.h"
#include <stdio.h> #include <stdio.h>
const char format[] = "{ %s = { %s}\n"; // serialize struct test
struct A { const char format[] = "{%s = {%lu, %lu, %d}\n"; //
char *s1; int serialize(Subject *s) {
char *s2; printf(format, s->name, s->created, s->deadline, s->priority);
}A; return 0;
int main(){
struct A test;
test.s1 = "asdasd";
test.s2 = "asdad";
printf(format, test.s1, test.s2);
} }

View File

@ -1,4 +1,7 @@
#ifndef DB #ifndef DB
#define DB #define DB
#include "planner.h"
int serialize(Subject *s);
#endif #endif

View File

@ -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

View File

@ -1,7 +1,10 @@
/* /*
* Main Plannder * INPUT: linked list of subjects
* gets data from user or db * OUTPUT: ll of events to iCal
* generates timetable * ll of updated subjects to db for next day
* modify data for next day and send to db * return events_ll to caller(ui)??
* *
*/ */
#include "planner.h" // for subject and event structs
#include "config.h"

View File

@ -1,4 +1,22 @@
#ifndef PLANNER #ifndef PLANNER
#define PLANNER #define PLANNER
#include <time.h>
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 #endif // !PLANNER

29
src/test.c Normal file
View File

@ -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 <stdio.h>
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;
}

View File

@ -2,3 +2,4 @@
* command line interface for user input * command line interface for user input
* *
*/ */
#include "planner.h" // for subject and event structs