def car():
    """
    Reads the car variables and gives a list with car, duration, distance_car, start_time, end_time.
    It must be executed on the day of optimization.
    """
    date = kl.date_now()
    day_type = kl.day_type()
    if not dt.car.read_variable('name_car') is 0:
        if date == manual_date_car():
            columns = [
                'duration', 'distance_car', 'start_time_manual',
                'stop_time_manual'
            ]
        else:
            columns = [
                'duration', 'distance_car', 'start_time_' + str(day_type),
                'stop_time_' + str(day_type)
            ]

        list = ['auto']
        for column in columns:
            data = dt.car.read_variable(column)
            list.append(data)
        return list
    else:
        return None
def desired_inside_temperatures():
    """
    Reads the desired inside temperatures for a whole day.
    It depends on the type of the day and if the user wants a manual schedule.
    """
    date = kl.date_now()
    day_type = kl.day_type()
    if date == manual_date_temperature():
        temperature = dt.temperature.read_variable('manual')
        return temperature
    else:
        temperature = dt.temperature.read_variable(day_type)
        return temperature
def inside_temperature_yesterday():
    """
    Reads the inside temperature from yesterday (last hour).
    It's executed on the day of optimization.
    Variable date must be in the string form '2018-02-25'.
    """
    date = kl.date_now()
    previous_date = kl.previous_date()
    if date == '2018-01-01':
        return 0
    else:
        temperature = dt.energy.select_data_last_hour('inside_temperature',
                                                      previous_date)
        return temperature
示例#4
0
def inside_temperature():
    """
    Reads the inside temperature.
    """
    time = kl.time_now()
    date = kl.date_now()
    day_type = kl.day_type()

    if date == manual_date_temperature():
        temperature = dt.temperature.select_data('manual', 'time', time)
        return temperature
    else:
        temperature = dt.temperature.select_data(day_type, 'time', time)
        return temperature
示例#5
0
def change_temperature(temperature):
    """
    Changes the temperature of the time of execution and the following hours of that day.
    """
    time = kl.time_now()
    day_type = kl.day_type()
    dt.temperature.copy_column1_to_column2(day_type, 'manual')
    start_hour = int(time[0] + time[1])

    for hour in range(start_hour, 24):
        if hour <= 9:
            key = "time='0" + str(hour) + ":00'"
            dt.temperature.update_data('manual', temperature, key)
        else:
            key = "time='" + str(hour) + ":00'"
            dt.temperature.update_data('manual', temperature, key)
示例#6
0
def set_manual_date_machines():
    """
    Sets the date when the user wants a manual machine schedule to manual.
    It takes the next day to be manual.
    """
    date = kl.next_date()
    dt.manual.update_variable('machines_schedule', date)
def storage_battery_yesterday():
    """
    Reads the battery storage from yesterday (last hour).
    It's executed on the day of optimization.
    Variable date must be in the string form '2018-02-25'.
    """
    date = kl.date_now()
    previous_date = kl.previous_date()
    if date == '2018-01-01':
        return 0
    else:
        storage = dt.energy.select_data_last_hour('storage_battery',
                                                  previous_date)
        if storage is None:
            return 0
        else:
            return storage
示例#8
0
def set_distance(distance):
    """
    Sets the distance of the car. The distance must be updated every day.
    """
    date = kl.date_now()
    if isinstance(distance,
                  int) or distance.replace('.', '').isdigit() is True:
        dt.car.update_variable('updated', date)
        dt.car.update_variable('distance_car', distance)
def electricity_price():
    """
    Returns the electricity price in a list of the day of execution.
    It must be executed on the day of optimization.
    Variable date must be in the string form '2018-02-25'.
    """
    date = kl.date_now()
    prices = dt.energy.select_data_of_date('electricity_price', date)
    return prices
def wind_speed(date=None):
    """
    Returns the wind speed in a list from the day of execution.
    """
    if date is None:
        date = kl.date_now()

    wind_speed = dt.weather_conditions.select_data_of_date('wind_speed', date)
    return wind_speed
示例#11
0
def machines():
    """
    Returns in a dictionary the vectors of the standard machines used in the mini house.
    The key is the name of the machine in string form followed by the vector in string form as value.

    The standard machines in order: 'windmolen', 'auto', 'verwarming', 'batterij', 'koelkast', 'vriezer', 'oven', 'kookplaat', 'wasmachine', 'afwasmachine',
    'droogkast', 'boiler', 'TV'.
    """
    i = dict()
    i['uur'] = kl.datetime_now()
    date_1 = kl.date_now()
    date_2 = date_1 + ' 00:00:00'
    machines = [
        'auto', 'batterij', 'koelkast', 'vriezer', 'oven', 'kookplaat',
        'wasmachine', 'afwasmachine', 'droogkast', 'boiler', 'TV'
    ]
    existing_machines = dt.machines.read_variable('machine')

    i['licht_berging'] = dt.lights.select_data('status', 'room', 'berging')
    i['licht_living'] = dt.lights.select_data('status', 'room', 'living')
    i['licht_keuken'] = dt.lights.select_data('status', 'room', 'keuken')
    i['licht_slaapkamer'] = dt.lights.select_data('status', 'room',
                                                  'slaapkamer')
    i['licht_badkamer'] = dt.lights.select_data('status', 'room', 'badkamer')
    i['verwarming'] = heating_system(date_2)
    i['windmolen'] = windmill(date_1)

    for machine in machines:
        if machine in existing_machines:
            vector = list_converter(
                dt.vectors.select_data(machine, 'date', date_2))
            i[machine] = vector
        elif machine is 'batterij':
            vector = list_converter(
                dt.vectors.select_data('batterij', 'date', date_2))
            i[machine] = vector
        elif machine is 'auto' and gb.existing_car() is not None:
            vector = list_converter(
                dt.vectors.select_data(machine, 'date', date_2))
            i[machine] = vector
        else:
            vector = 24 * [0]
            i[machine] = vector
    return i
def storage_battery(date=None):
    """
    Returns the storage in the battery on the given day or moment of execution.
    Variable date must be in the string form '2018-02-25'.
    """
    if date is None:
        date = kl.date_now()

    storage = dt.energy.select_data_of_date('storage_battery', date)
    return storage
def charging_battery(date=None):
    """
    Returns the charging battery vector of the given day or moment of execution.
    Variable date must be in the string form '2018-02-25'.
    """
    if date is None:
        date = kl.date_now()

    charging = dt.energy.select_data_of_date('charging_battery', date)
    return charging
def inside_temperatures(date=None):
    """
    Reads the inside temperatures for a whole day.
    The variable date is in form of '2018-02-25' or can be the moment of execution.
    """
    if date is None:
        date = kl.date_now()

    temperature = dt.energy.select_data_of_date('inside_temperature', date)
    return temperature
def total_usage(date=None):
    """
    Returns the usage vector of all machines on the given day or moment of execution.
    Variable date must be in the string form '2018-02-25'.
    """
    if date is None:
        date = kl.date_now()

    usages = dt.energy.select_data_of_date('total_usage', date)
    return usages
示例#16
0
def total_usage():
    """
    Returns the total usage of every hour in a list.
    """
    date = kl.date_now()
    usages = dt.energy.select_data_of_date('total_usage', date)
    if not None in usages:
        return usages
    else:
        return None
示例#17
0
def plot_windmill():
    """
    Returns the day vector of the yield of the windmill in a list.
    """
    date = kl.date_now()
    vector = dt.energy.select_data_of_date('yield_windmill', date)
    if not None in vector:
        return vector
    else:
        return None
示例#18
0
def plot_solar_panels():
    """
    Returns the day vector of the yield of the solar panels in a list.
    """
    date = kl.date_now()
    vector = dt.energy.select_data_of_date('yield_solar_panels', date)
    if not None in vector:
        return vector
    else:
        return None
def usage_heating_system(date=None):
    """
    Returns the vector of the heating system.
    Date must be in string form '2018-01-25' or can be the moment of execution.
    """
    if date is None:
        date = kl.date_now()

    usages = dt.energy.select_data_of_date('usage_heating_system', date)
    return usages
示例#20
0
def plot_day_output(machine):
    """
    Returns the vector of the given machine of the day of execution.
    """
    date = kl.date_now() + ' 00:00:00'
    vector = list_converter(dt.vectors.select_data(machine, 'date', date))
    if vector is not None:
        return vector
    else:
        return None
def radiation_diffuse_horizontal(date=None):
    """
    Returns the diffuse horizontal radiation in a list from the date of execution.
    Variable date must be in the string form '2018-02-25'.
    """
    if date is None:
        date = kl.date_now()

    radiation_diffuse = dt.weather_conditions.select_data_of_date(
        'radiation_diffuse_horizontal', date)
    return radiation_diffuse
def outside_temperatures(date=None):
    """
    Reads the outside temperatures for a whole day.
    The variable date is in form of '2018-02-25'.
    """
    if date is None:
        date = kl.date_now()

    temperature = dt.weather_conditions.select_data_of_date(
        'outside_temperature', date)
    return temperature
示例#23
0
def updated_distance():
    """
    Returns True if distance is updated for the given day.
    False if it isn't been inserted.
    """
    date = kl.date_now()
    updated = dt.car.read_variable('updated')

    if updated == date:
        return True
    else:
        return False
def optimization_output(optimization, date=None):
    """
    Given the dictionarie 'optimization' with the first element the
    name of the machine and second the status vector.
    The vector is saved in the database.
    Variable date must be in the string form '2018-02-25'.
    """
    if date is None:
        date = kl.date_now()

    for machine in optimization:
        vector = optimization[machine]
        key = "date='" + str(date) + " 00:00:00'"
        dt.vectors.update_data(machine, vector, key)
def show_entries():

    global from_list, to_list, degrees_list

    from_list = []
    to_list = []
    degrees_list = []
    day_type = Klok.day_type()
    key_positions = get_temperature_scheme(day_type)

    for i in range(number_of_entries):

        i_entry = Entry(temp_schedule_root, width = 5)
        i_entry.place(x=530, y=170 + i*45)
        from_list.append(i_entry)
        if i == 0:
            i_entry.insert(0,"0")

        else:
            if key_positions[i-1] is not None:
                i_entry.insert(0,str(key_positions[i-1]))

    for j in range(number_of_entries):

        j_entry = Entry(temp_schedule_root, width =5)
        j_entry.place(x=630, y = 170 + j*45)
        to_list.append(j_entry)
        if j == number_of_entries-1:
            j_entry.insert(0, "0")

        else:
            if key_positions[j] is not None:
                j_entry.insert(0,str(key_positions[j]))

    for k in range(number_of_entries):

        k_entry = Entry(temp_schedule_root, width=5)
        k_entry.place(x=730 ,y= 170 + k*45)
        degrees_list.append(k_entry)

        if k == 0:
            k_entry.insert(0,str(temperature_list[0]))

        else:
            if key_positions[k-1] is not None:
                k_entry.insert(0,str(temperature_list[key_positions[k-1]]))

    plus_button = Button(temp_schedule_root, text = "+", command = lambda: add_entries(plus_button), width = 5, height = 1)
    plus_button.place(x=800, y=200 + (number_of_entries-1)*45)
示例#26
0
def start_button(machine):
    """
    Turns the given machine on.
    The machine will work from its duration from the moment of the start button is been activated.
    """
    start_time = kl.datetime_now()
    duration = dt.machines.select_data('duration', 'machine', machine)
    new_time = datetime.datetime(
        int(start_time[0:4]), int(start_time[5:7]), int(start_time[8:10]),
        int(start_time[11:13])) + datetime.timedelta(hours=float(duration))
    stop_time = new_time.strftime("2018-%m-%d %H:%M")

    key = "machine='" + str(machine) + "'"
    dt.machines.update_data('stop_button', '0', key)
    dt.machines.update_data('start_button_begin', start_time, key)
    dt.machines.update_data('start_button_end', stop_time, key)
def wind_energy_output(wind_energy, date=None):
    """
    Inserts the yield wind energy in the database.
    The variable wind_energy_output must be a list of 24 integers representing every hour of a day.
    Variable date must be in the string form '2018-02-25'.
    """
    if date is None:
        date = kl.date_now()

    for hour in range(len(wind_energy)):
        if hour <= 9:
            key = "datetime='" + str(date) + " 0" + str(hour) + ":00'"
            dt.energy.update_data('yield_windmill', wind_energy[hour], key)
        else:
            key = "datetime='" + str(date) + " " + str(hour) + ":00'"
            dt.energy.update_data('yield_windmill', wind_energy[hour], key)
def usage_heating_system_output(vector, date=None):
    """
    Inserts the vector of the heating system on the given day or moment of execution.
    Usage must be a list of length 24.
    Date must be in string form '2018-01-25' .
    """
    if date is None:
        date = kl.date_now()

    for hour in range(len(vector)):
        if hour <= 9:
            key = "datetime='" + str(date) + " 0" + str(hour) + ":00'"
            dt.energy.update_data('usage_heating_system', vector[hour], key)
        else:
            key = "datetime='" + str(date) + " " + str(hour) + ":00'"
            dt.energy.update_data('usage_heating_system', vector[hour], key)
def total_usage_output(vector, date=None):
    """
    Inserts the total usage vector in the database on the given day or moment of execution.
    The variable vector must be a list of 24 integers representing every hour of a day.
    Variable date must be in the string form '2018-02-25'.
    """
    if date is None:
        date = kl.date_now()

    for hour in range(len(vector)):
        if hour <= 9:
            key = "datetime='" + str(date) + " 0" + str(hour) + ":00'"
            dt.energy.update_data('total_usage', vector[hour], key)
        else:
            key = "datetime='" + str(date) + " " + str(hour) + ":00'"
            dt.energy.update_data('total_usage', vector[hour], key)
def storage_battery_output(storage_battery, date=None):
    """
    Inserts the battery storage on every hour of the given date.
    Storage_battery must be a list of 24 variables.
    Variable date must be in the string form '2018-02-25'.
    """
    if date is None:
        date = kl.date_now()

    time = [
        '00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00',
        '08:00', '09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00',
        '16:00', '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00'
    ]
    for i in range(len(storage_battery)):
        key = "datetime='" + str(date) + ' ' + time[i] + "'"
        dt.energy.update_data('storage_battery', storage_battery[i], key)