From 9db1c93bf8785ceff8de4dec3f0cdcb4ac608329 Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 14 Sep 2023 22:12:40 +0200 Subject: [PATCH] initial commit. First functions --- .idea/.gitignore | 3 + .idea/inspectionProfiles/Project_Default.xml | 14 ++ .../inspectionProfiles/profiles_settings.xml | 6 + .idea/misc.xml | 4 + .idea/modules.xml | 8 ++ .idea/toll_collect.iml | 10 ++ .idea/vcs.xml | 6 + app.py | 27 ++++ config/co2_classe.json | 128 ++++++++++++++++++ config/temp.json | 0 config/vehicle_group.json | 10 ++ main.py | 6 + vehicle_group.py | 21 +++ 13 files changed, 243 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/toll_collect.iml create mode 100644 .idea/vcs.xml create mode 100644 app.py create mode 100644 config/co2_classe.json create mode 100644 config/temp.json create mode 100644 config/vehicle_group.json create mode 100644 main.py create mode 100644 vehicle_group.py diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..3531d06 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,14 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..faab36e --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..8c4343e --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/toll_collect.iml b/.idea/toll_collect.iml new file mode 100644 index 0000000..74d515a --- /dev/null +++ b/.idea/toll_collect.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app.py b/app.py new file mode 100644 index 0000000..6b99ea7 --- /dev/null +++ b/app.py @@ -0,0 +1,27 @@ +import json +from vehicle_group import get_vehicle_group + + +class App: + def __init__(self): + self._co2_class = None + self._read_configs() + + def _read_configs(self): + with open("config/co2_classe.json") as json_file: + self._co2_class = json.load(json_file) + + def get_co2_class(self, registrations_date, emission, vehicle_type, axis_type, power, cabin): + vehicle_grp = get_vehicle_group(power, cabin, vehicle_type, axis_type) + co2_limit = self._co2_class[vehicle_grp][registrations_date] + print(vehicle_grp) + print(co2_limit) + if emission < (co2_limit * 0.5): + print("Klasse 4") + elif emission < (co2_limit * 0.92): + print("Klasse 3") + elif emission < (co2_limit * 0.95): + print("Klasse 2") + else: + print("Klasse 1") + diff --git a/config/co2_classe.json b/config/co2_classe.json new file mode 100644 index 0000000..271323c --- /dev/null +++ b/config/co2_classe.json @@ -0,0 +1,128 @@ +{ + "4-UD": { + "2019": 307.23, + "2020": 299.549, + "2021": 291.869, + "2022": 284.188, + "2023": 276.507, + "2024": 268.826, + "2025": 261.146, + "2026": 251.929, + "2027": 242.712, + "2028": 233.495, + "2029": 224.278, + "2030": 215.061 + }, + "4-RD": { + "2019": 197.16, + "2020": 192.231, + "2021": 187.302, + "2022": 182.373, + "2023": 177.444, + "2024": 172.515, + "2025": 167.586, + "2026": 161.671, + "2027": 155.756, + "2028": 149.842, + "2029": 143.927, + "2030": 138.012 + }, + "5-RD": { + "2019": 84.00, + "2020": 81.900, + "2021": 79.800, + "2022": 77.700, + "2023": 75.600, + "2024": 73.500, + "2025": 71.400, + "2026": 68.880, + "2027": 66.360, + "2028": 63.840, + "2029": 61.320, + "2030": 58.800 + }, + "4-LH": { + "2019": 105.96, + "2020": 103.311, + "2021": 100.662, + "2022": 98.013, + "2023": 95.364, + "2024": 92.715, + "2025": 90.066, + "2026": 86.887, + "2027": 83.708, + "2028": 80.5296, + "2029": 77.351, + "2030": 74.172 + }, + "5-LH": { + "2019": 56.60, + "2020": 55.185, + "2021": 53.770, + "2022": 52.355, + "2023": 50.940, + "2024": 49.525, + "2025": 48.110, + "2026": 46.412, + "2027": 44.714, + "2028": 43.016, + "2029": 41.318, + "2030": 39.620 + }, + "9-RD": { + "2019": 110.98, + "2020": 108.206, + "2021": 105.431, + "2022": 102.657, + "2023": 99.882, + "2024": 97.108, + "2025": 94.333, + "2026": 91.004, + "2027": 87.674, + "2028": 84.345, + "2029": 81.015, + "2030": 77.68 + }, + "9-LH": { + "2019": 65.16, + "2020": 63.531, + "2021": 61.902, + "2022": 60.273, + "2023": 58.644, + "2024": 57.015, + "2025": 55.386, + "2026": 53.431, + "2027": 51.476, + "2028": 49.522, + "2029": 47.567, + "2030": 45.612 + }, + "10-RD": { + "2019": 83.26, + "2020": 81.179, + "2021": 79.097, + "2022": 77.016, + "2023": 74.934, + "2024": 72.853, + "2025": 70.771, + "2026": 68.273, + "2027": 65.775, + "2028": 63.278, + "2029": 60.7798, + "2030": 58.282 + }, + "10-LH": { + "2019": 58.26, + "2020": 56.804, + "2021": 55.347, + "2022": 53.891, + "2023": 52.434, + "2024": 50.978, + "2025": 49.521, + "2026": 47.773, + "2027": 46.025, + "2028": 44.278, + "2029": 42.5298, + "2030": 40.782 + } +} \ No newline at end of file diff --git a/config/temp.json b/config/temp.json new file mode 100644 index 0000000..e69de29 diff --git a/config/vehicle_group.json b/config/vehicle_group.json new file mode 100644 index 0000000..38ccf61 --- /dev/null +++ b/config/vehicle_group.json @@ -0,0 +1,10 @@ +{ + "4-UD": { + "power": "< 170", + "cabin": "both" + + }, + "4-RD": { + + } +} \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..91fee85 --- /dev/null +++ b/main.py @@ -0,0 +1,6 @@ +from app import App + + +if __name__ == '__main__': + app = App() + app.get_co2_class("2020", 54.4, 'szm', '6x2', 325, "sleep") diff --git a/vehicle_group.py b/vehicle_group.py new file mode 100644 index 0000000..53d2079 --- /dev/null +++ b/vehicle_group.py @@ -0,0 +1,21 @@ + + +def get_vehicle_group(power, cabin, vehicle_type, axis_type): + if power < 170: + return "4-UD" + elif power >= 265 and axis_type == "4x2" and vehicle_type == "lkw": + return "4-LH" + elif power > 170 and axis_type == "4x2": + return "4-RD" + elif axis_type == "6x2" and vehicle_type == "szm" and cabin == "solo": + return "10-RD" + elif axis_type == "6x2" and vehicle_type == "szm" and cabin == "sleep": + return "10-LH" + elif power >= 265 and cabin == "sleep" and axis_type == '4x2' and vehicle_type == 'szm': + return "5-LH" + elif power < 265 and axis_type == '4x2' and vehicle_type == 'szm': + return "5-RD" + elif axis_type == '6x2' and vehicle_type == 'lkw' and cabin == 'sleep': + return "9-LH" + elif axis_type == '6x2' and vehicle_type == 'lkw' and cabin == 'solo': + return "9-RD"