Exemplo n.º 1
0
def getEricData():
    data = readFromJson(path)
    firstDay = data["first working day"]
    firstHour = data["first hour"]
    lastHour = data["last hour"]
    measuringDuration = data["duration of one measuring"]
    interval = data["interval between measurements"]
    return firstDay,firstHour,lastHour,measuringDuration,interval
Exemplo n.º 2
0
def doSchedule(firstDay,minutesPerDay,measuringDuration,interval):
    print("we are preparing your schedule' please wait")
    cycle = math.ceil(interval/measuringDuration) + 1 
    currentPerson = 1
    status = readFromJson("status.json")
    currentDay = firstDay
    currentMinute = 0
    currentWeek = 1
    queue = []
    for i in range(1,peopleCount+1):
        if status[str(i)] == 0:
            currentPerson += 1
        else: 
            break
    for i in range(currentPerson,currentPerson+cycle):
        if str(i) not in status:
            break
        queue.append(status[str(i)])
    queueCounter = 0
    flag = 1
    while len(queue) != 0:
        if currentDay == 6:
            currentDay = 1
            currentWeek += 1
        scheduleThisDay = []
        currentMinute = 0
        # checking if there is enough time for more measuring this day
        while currentMinute <= minutesPerDay - measuringDuration: 
            if peopleCount - currentPerson  == cycle and flag:
                for i in range(currentPerson+cycle,peopleCount):
                    queue.append(status[str(i)])
                flag = 0
            if len(queue) == 0:
                break
            if queueCounter == len(queue):
                queueCounter = 0
            queue[queueCounter] -= 1
            scheduleThisDay.append(currentPerson + queueCounter)
            currentMinute += measuringDuration
            if queue[queueCounter] == 0:
                if flag:
                    del status[str(currentPerson)]
                if str(currentPerson + cycle) in status:
                    queue.append(status[str(currentPerson + cycle)])
                queue.pop(0)
                currentPerson += 1
            else: 
                queueCounter += 1          
        solution[str(daysAtWeek[currentDay-1]) + str(currentWeek)] = scheduleThisDay
        currentDay += 1
Exemplo n.º 3
0
def setFirstWorkingDay(input):
    data = readFromJson()
    data["first working day"] = str(input)
    writeToJson(data)
Exemplo n.º 4
0
def updateStatus(personNumber, status):
    data = readFromJson("status.json")
    data[personNumber] = int(status)
    writeToJson("status.json", data)
Exemplo n.º 5
0
def setInterval(input):
    data = readFromJson(path)
    data["interval between measurements"] = str(input)
    writeToJson(path, data)
Exemplo n.º 6
0
def setMeasuringDuration(input):
    data = readFromJson(path)
    data["duration of one measuring"] = str(input)
    writeToJson(path, data)
Exemplo n.º 7
0
def setLastHour(input1, input2):
    data = readFromJson(path)
    data["last hour"] = str(input1) + ":" + str(input2)
    writeToJson(path, data)