diff --git a/BiogasControllerApp-V2.1/.idea/.gitignore b/BiogasControllerApp-V2.2/.idea/.gitignore similarity index 100% rename from BiogasControllerApp-V2.1/.idea/.gitignore rename to BiogasControllerApp-V2.2/.idea/.gitignore diff --git a/BiogasControllerApp-V2.1/.idea/.name b/BiogasControllerApp-V2.2/.idea/.name similarity index 100% rename from BiogasControllerApp-V2.1/.idea/.name rename to BiogasControllerApp-V2.2/.idea/.name diff --git a/BiogasControllerApp-V2.1/.idea/ENATECH.iml b/BiogasControllerApp-V2.2/.idea/ENATECH.iml similarity index 100% rename from BiogasControllerApp-V2.1/.idea/ENATECH.iml rename to BiogasControllerApp-V2.2/.idea/ENATECH.iml diff --git a/BiogasControllerApp-V2.1/.idea/inspectionProfiles/profiles_settings.xml b/BiogasControllerApp-V2.2/.idea/inspectionProfiles/profiles_settings.xml similarity index 100% rename from BiogasControllerApp-V2.1/.idea/inspectionProfiles/profiles_settings.xml rename to BiogasControllerApp-V2.2/.idea/inspectionProfiles/profiles_settings.xml diff --git a/BiogasControllerApp-V2.1/.idea/misc.xml b/BiogasControllerApp-V2.2/.idea/misc.xml similarity index 100% rename from BiogasControllerApp-V2.1/.idea/misc.xml rename to BiogasControllerApp-V2.2/.idea/misc.xml diff --git a/BiogasControllerApp-V2.1/.idea/modules.xml b/BiogasControllerApp-V2.2/.idea/modules.xml similarity index 100% rename from BiogasControllerApp-V2.1/.idea/modules.xml rename to BiogasControllerApp-V2.2/.idea/modules.xml diff --git a/BiogasControllerApp-V2.1/BiogasControllerApp-V2.1.exe b/BiogasControllerApp-V2.2/BiogasControllerApp-V2.1.exe similarity index 100% rename from BiogasControllerApp-V2.1/BiogasControllerApp-V2.1.exe rename to BiogasControllerApp-V2.2/BiogasControllerApp-V2.1.exe diff --git a/BiogasControllerApp-V2.1/BiogasControllerAppLogo.png b/BiogasControllerApp-V2.2/BiogasControllerAppLogo.png similarity index 100% rename from BiogasControllerApp-V2.1/BiogasControllerAppLogo.png rename to BiogasControllerApp-V2.2/BiogasControllerAppLogo.png diff --git a/BiogasControllerApp-V2.1/bin/gui/gui.kv b/BiogasControllerApp-V2.2/bin/gui/gui.kv similarity index 85% rename from BiogasControllerApp-V2.1/bin/gui/gui.kv rename to BiogasControllerApp-V2.2/bin/gui/gui.kv index babb5f3..569f292 100644 --- a/BiogasControllerApp-V2.1/bin/gui/gui.kv +++ b/BiogasControllerApp-V2.2/bin/gui/gui.kv @@ -5,6 +5,7 @@ RootScreen: ProgramTemp: Program: Credits: + Modify: : title: "BiogasControllerApp" @@ -214,18 +215,18 @@ RootScreen: on_release: root.exitapp() Label: - text: "You are currently running Version 2.1.0 - If you encounter a bug, please report it!" + text: "You are currently running Version 2.2.0 - If you encounter a bug, please report it!" font_size: 13 pos_hint: {"y": -0.45, "x":0.05} Button: - text: "credits" + text: "Settings" font_size: 13 size_hint: 0.07, 0.06 pos_hint: {"x":0.01, "y":0.01} background_color: (50, 0, 0, 0.2) on_release: - app.root.current = "Credits" - root.manager.transition.direction = "left" + app.root.current = "Settings" + root.manager.transition.direction = "down" : on_pre_enter: self.reset_screen = root.resscreen() @@ -249,25 +250,25 @@ RootScreen: size_hint: 0.8, 0.3 pos_hint: {"x":0.1, "y":0.4} Label: - text: "SONDE 1: " + text: "SENSOR 1: " font_size: 20 Label: id: sonde1 text: "" Label: - text: "SONDE 2: " + text: "SENSOR 2: " font_size: 20 Label: id: sonde2 text: "" Label: - text: "SONDE 3: " + text: "SENSOR 3: " font_size: 20 Label: id: sonde3 text: "" Label: - text: "SONDE 4: " + text: "SENSOR 4: " font_size: 20 Label: id: sonde4 @@ -415,25 +416,25 @@ RootScreen: pos_hint: {"x": 0.1, "y":0.3} cols:2 Label: - text: "Temperatur Sonde 1: " + text: "Temperature Sensor 1: " TextInput: id: temp_s1 multiline: False input_filter: "float" Label: - text: "Temperatur Sonde 2: " + text: "Temperature Sensor 2: " TextInput: id: temp_s2 multiline: False input_filter: "float" Label: - text: "Temperatur Sonde 3: " + text: "Temperature Sensor 3: " TextInput: id: temp_s3 multiline: False input_filter: "float" Label: - text: "Temperatur Sonde 4: " + text: "Temperature Sensor 4: " TextInput: id: temp_s4 multiline: False @@ -474,97 +475,97 @@ RootScreen: pos_hint: {"x":0.1, "y":0.2} cols: 4 Label: - text: "Sonde 1, a:" + text: "Sensor 1, a:" TextInput: id: s1_a multiline: False input_filter: "float" Label: - text: "Sonde 1, b:" + text: "Sensor 1, b:" TextInput: id: s1_b multiline: False input_filter: "float" Label: - text: "Sonde 1, c:" + text: "Sensor 1, c:" TextInput: id: s1_c multiline: False input_filter: "float" Label: - text: "Sonde 1, Temp:" + text: "Sensor 1, Temp:" TextInput: id: s1_t multiline: False input_filter: "float" Label: - text: "Sonde 2, a:" + text: "Sensor 2, a:" TextInput: id: s2_a multiline: False input_filter: "float" Label: - text: "Sonde 2, b:" + text: "Sensor 2, b:" TextInput: id: s2_b multiline: False input_filter: "float" Label: - text: "Sonde 2, c:" + text: "Sensor 2, c:" TextInput: id: s2_c multiline: False input_filter: "float" Label: - text: "Sonde 2, Temp:" + text: "Sensor 2, Temp:" TextInput: id: s2_t multiline: False input_filter: "float" Label: - text: "Sonde 3, a:" + text: "Sensor 3, a:" TextInput: id: s3_a multiline: False input_filter: "float" Label: - text: "Sonde 3, b:" + text: "Sensor 3, b:" TextInput: id: s3_b multiline: False input_filter: "float" Label: - text: "Sonde 3, c:" + text: "Sensor 3, c:" TextInput: id: s3_c multiline: False input_filter: "float" Label: - text: "Sonde 3, Temp:" + text: "Sensor 3, Temp:" TextInput: id: s3_t multiline: False input_filter: "float" Label: - text: "Sonde 4, a:" + text: "Sensor 4, a:" TextInput: id: s4_a multiline: False input_filter: "float" Label: - text: "Sonde 4, b:" + text: "Sensor 4, b:" TextInput: id: s4_b multiline: False input_filter: "float" Label: - text: "Sonde 4, c:" + text: "Sensor 4, c:" TextInput: id: s4_c multiline: False input_filter: "float" Label: - text: "Sonde 4, Temp:" + text: "Sensor 4, Temp:" TextInput: id: s4_t multiline: False @@ -599,7 +600,7 @@ RootScreen: size_hint: 0.4, 0.2 pos_hint: {"x":0.3, "y":0.1} on_release: - app.root.current = "Home" + app.root.current = "Settings" root.manager.transition.direction = "right" GridLayout: cols:1 @@ -609,3 +610,47 @@ RootScreen: text: "This is a rework of the BiogasControllerApp V1, that was originally programmed by S. Reichmuth." Label: text: "Written by: Janis Hutz\nDesigned by: Janis Hutz\nDesign language: Kivy" + +: + on_pre_enter: self.config = root.read_config() + name: "Settings" + canvas.before: + Color: + rgba: (50,50,50,0.2) + Rectangle: + size: self.size + pos: self.pos + GridLayout: + cols: 1 + Label: + text: "Settings" + font_size: 40 + color: (0, 113, 0, 1) + bold: True + FloatLayout: + GridLayout: + pos_hint: {"x":0.05, "y":0.05} + size_hint: 0.9, 0.9 + cols: 4 + Button: + text: "Back" + background_color: (255,0,0,0.6) + on_release: + app.root.current = "Home" + root.manager.transition.direction = "up" + Button: + text: "Report a\nBug" + background_color: (255,0,0,0.6) + on_release: + root.issue_reporting() + ToggleButton: + id: prsel + text: "Easy\nreprogramming" if self.state == "normal" else "Advanced\nreprogramming" + on_text: root.change_programming() + background_color: (255,0,0,0.6) if self.state == "normal" else (0,0,255,0.6) + Button: + text: "Credits" + background_color: (255,0,0,0.6) + on_release: + app.root.current = "Credits" + root.manager.transition.direction = "left" diff --git a/BiogasControllerApp-V2.1/bin/lib/communication.py b/BiogasControllerApp-V2.2/bin/lib/communication.py similarity index 100% rename from BiogasControllerApp-V2.1/bin/lib/communication.py rename to BiogasControllerApp-V2.2/bin/lib/communication.py diff --git a/BiogasControllerApp-V2.1/bin/lib/comport_search.py b/BiogasControllerApp-V2.2/bin/lib/comport_search.py similarity index 100% rename from BiogasControllerApp-V2.1/bin/lib/comport_search.py rename to BiogasControllerApp-V2.2/bin/lib/comport_search.py diff --git a/BiogasControllerApp-V2.2/bin/lib/csv_parsers.py b/BiogasControllerApp-V2.2/bin/lib/csv_parsers.py new file mode 100644 index 0000000..d1f593c --- /dev/null +++ b/BiogasControllerApp-V2.2/bin/lib/csv_parsers.py @@ -0,0 +1,122 @@ +"""@package docstring +This is a simplification of the csv module""" + +import csv + + +class CsvRead: + """This is a class that reads csv files and depending on the module selected does do different things with it""" + def __init__(self): + self.__imp = "" + self.__raw = "" + self.__raw_list = "" + + def importing(self, path): + """Returns a list of the imported csv-file, requires path, either direct system path or relative path""" + self.__imp = open(path) + self.__raw = csv.reader(self.__imp, delimiter=',') + self.__raw_list = list(self.__raw) + self.__imp.close() + return self.__raw_list + + +class CsvWrite: + """This is a class that modifies csv files""" + def __init__(self): + self.__impl = [] + self.__strpop = [] + self.__removed = [] + self.__removing = 0 + self.__change = 0 + self.__appending = 0 + self.__imp = [] + self.__raw = [] + + def rem_str(self, path, row): + """Opens the csv-file in write mode which is specified as an argument either as direct or relative path""" + self.__imp = open(path) + self.__raw = csv.reader(self.__imp, delimiter=',') + self.__impl = list(self.__raw) + self.__removed = self.__impl.pop(row + 1) + with open(path, "w") as removedata: + self.__removing = csv.writer(removedata, delimiter=',', quoting=csv.QUOTE_MINIMAL) + self.__removing.writerow(self.__impl.pop(0)) + while len(self.__impl) > 0: + with open(path, "a") as removedata: + self.__removing = csv.writer(removedata, delimiter=',', quoting=csv.QUOTE_MINIMAL) + self.__removing.writerow(self.__impl.pop(0)) + self.__imp.close() + removedata.close() + + + def chg_str(self, path, row, pos, new_value): + """Opens the csv-file in write mode to change a value, e.g. if a recipes is changed.""" + self.__imp = open(path) + self.__raw = csv.reader(self.__imp, delimiter=',') + self.__impl = list(self.__raw) + self.__strpop = self.__impl.pop(row) + self.__strpop.pop(pos) + self.__strpop.insert(pos, new_value) + self.__impl.insert(row, self.__strpop) + with open(path, "w") as changedata: + self.__change = csv.writer(changedata, delimiter=',', quoting=csv.QUOTE_MINIMAL) + self.__change.writerow(self.__impl.pop(0)) + while len(self.__impl) > 0: + with open(path, "a") as changedata: + self.__removing = csv.writer(changedata, delimiter=',', quoting=csv.QUOTE_MINIMAL) + self.__removing.writerow(self.__impl.pop(0)) + self.__imp.close() + changedata.close() + + def chg_str_rem(self, path, row, pos): + """Opens the csv-file in write mode to change a value, e.g. if a recipes is changed.""" + self.__imp = open(path) + self.__raw = csv.reader(self.__imp, delimiter=',') + self.__impl = list(self.__raw) + self.__strpop = self.__impl.pop(row) + self.__strpop.pop(pos) + self.__strpop.pop(pos) + self.__impl.insert(row, self.__strpop) + with open(path, "w") as changedata: + self.__change = csv.writer(changedata, delimiter=',', quoting=csv.QUOTE_MINIMAL) + self.__change.writerow(self.__impl.pop(0)) + while len(self.__impl) > 0: + with open(path, "a") as changedata: + self.__removing = csv.writer(changedata, delimiter=',', quoting=csv.QUOTE_MINIMAL) + self.__removing.writerow(self.__impl.pop(0)) + self.__imp.close() + changedata.close() + + def chg_str_add(self, path, row, new_value1, new_value2): + """Opens the csv-file in write mode to change a value, e.g. if a recipes is changed.""" + self.__imp = open(path) + self.__raw = csv.reader(self.__imp, delimiter=',') + self.__impl = list(self.__raw) + self.__strpop = self.__impl.pop(row) + self.__strpop.append(new_value1) + self.__strpop.append(new_value2) + self.__impl.insert(row, self.__strpop) + with open(path, "w") as changedata: + self.__change = csv.writer(changedata, delimiter=',', quoting=csv.QUOTE_MINIMAL) + self.__change.writerow(self.__impl.pop(0)) + while len(self.__impl) > 0: + with open(path, "a") as changedata: + self.__removing = csv.writer(changedata, delimiter=',', quoting=csv.QUOTE_MINIMAL) + self.__removing.writerow(self.__impl.pop(0)) + self.__imp.close() + changedata.close() + + def app_str(self, path, value): + """Opens the csv-file in append mode and writes given input. CsvWrite.app_str(path, value). + Path can be specified both as direct or relative. value is a list. Will return an error if type of value is + not a list.""" + with open(path, "a") as appenddata: + self.__appending = csv.writer(appenddata, delimiter=',', quoting=csv.QUOTE_MINIMAL) + self.__appending.writerow(value) + appenddata.close() + + def write_str(self, path, value): + with open(path, "w") as writedata: + self.__change = csv.writer(writedata, delimiter=',', quoting=csv.QUOTE_MINIMAL) + self.__change.writerow(value) + writedata.close() diff --git a/BiogasControllerApp-V2.1/bin/lib/lib.py b/BiogasControllerApp-V2.2/bin/lib/lib.py similarity index 100% rename from BiogasControllerApp-V2.1/bin/lib/lib.py rename to BiogasControllerApp-V2.2/bin/lib/lib.py diff --git a/BiogasControllerApp-V2.1/biogascontrollerapp.py b/BiogasControllerApp-V2.2/biogascontrollerapp.py similarity index 86% rename from BiogasControllerApp-V2.1/biogascontrollerapp.py rename to BiogasControllerApp-V2.2/biogascontrollerapp.py index a14538a..f2ca531 100644 --- a/BiogasControllerApp-V2.1/biogascontrollerapp.py +++ b/BiogasControllerApp-V2.2/biogascontrollerapp.py @@ -5,12 +5,13 @@ print(""" BIOGASCONTROLLERAPP ---------- -Version 2.1 +Version 2.2 Copyright 2022 J.Hutz""") import time import threading import platform import os +import webbrowser os.environ["KIVY_NO_CONSOLELOG"] = "1" from kivy.uix.screenmanager import Screen, ScreenManager from kivy.uix.popup import Popup @@ -20,10 +21,10 @@ from kivy.clock import mainthread import bin.lib.lib import bin.lib.communication import bin.lib.comport_search +import bin.lib.csv_parsers - - - +cvr = bin.lib.csv_parsers.CsvRead() +cvw = bin.lib.csv_parsers.CsvWrite() com = bin.lib.lib.Com() ################################################################## @@ -339,24 +340,27 @@ class Program(Screen): self.__transmit.append(self.ids.s4_b.text) self.__transmit.append(self.ids.s4_c.text) self.__transmit.append(self.ids.s4_t.text) - self.coms.change_all(self.__transmit,"") - self.ids.s1_a.text = "" - self.ids.s1_b.text = "" - self.ids.s1_c.text = "" - self.ids.s1_t.text = "" - self.ids.s2_a.text = "" - self.ids.s2_b.text = "" - self.ids.s2_c.text = "" - self.ids.s2_t.text = "" - self.ids.s3_a.text = "" - self.ids.s3_b.text = "" - self.ids.s3_c.text = "" - self.ids.s3_t.text = "" - self.ids.s4_a.text = "" - self.ids.s4_b.text = "" - self.ids.s4_c.text = "" - self.ids.s4_t.text = "" - self.openconfpu() + try: + self.coms.change_all(self.__transmit, "") + self.ids.s1_a.text = "" + self.ids.s1_b.text = "" + self.ids.s1_c.text = "" + self.ids.s1_t.text = "" + self.ids.s2_a.text = "" + self.ids.s2_b.text = "" + self.ids.s2_c.text = "" + self.ids.s2_t.text = "" + self.ids.s3_a.text = "" + self.ids.s3_b.text = "" + self.ids.s3_c.text = "" + self.ids.s3_t.text = "" + self.ids.s4_a.text = "" + self.ids.s4_b.text = "" + self.ids.s4_c.text = "" + self.ids.s4_t.text = "" + self.openconfpu() + except: + self.open_confail_pu() else: self.openerrorpu() else: @@ -376,9 +380,30 @@ class Program(Screen): class ProgramTemp(Screen): + def read_config(self): + self.config_imp = [] + self.__export = [] + self.config_imp = cvr.importing("./config/config.csv") + self.__export = self.config_imp.pop(0) + self.__extracted = self.__export.pop(0) + if self.__extracted == "1": + self.ids.prsel.state = "normal" + self.__mode = 1 + else: + self.ids.prsel.state = "down" + self.__mode = 2 + def create_com(self): self.coms = bin.lib.communication.Communication() + def change_mode(self): + if self.__mode == "1": + self.ids.prsel.state = "down" + self.__mode = 2 + else: + self.ids.prsel.state = "normal" + self.__mode = 1 + def send_data(self): try: self.create_com() @@ -485,6 +510,32 @@ class Credits(Screen): pass +class Modify(Screen): + def read_config(self): + self.config_imp = [] + self.__export = [] + self.config_imp = cvr.importing("./config/config.csv") + self.__export = self.config_imp.pop(0) + self.__extracted = self.__export.pop(0) + if self.__extracted == "1": + self.ids.prsel.state = "normal" + else: + self.ids.prsel.state = "down" + + def issue_reporting(self): + webbrowser.open("https://github.com/simplePCBuilding/BiogasControllerApp/issues", new=2) + + def change_programming(self): + self.csv_import = [] + self.csv_import = cvr.importing("./config/config.csv") + self.csv_import.pop(0) + if self.ids.prsel.text == "Easy\nreprogramming": + self.csv_import.insert(0, 1) + else: + self.csv_import.insert(0, 2) + cvw.write_str("./config/config.csv", self.csv_import) + + ######################################################## # Screenmanager ######################################################## diff --git a/BiogasControllerApp-V2.2/config/config.csv b/BiogasControllerApp-V2.2/config/config.csv new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/BiogasControllerApp-V2.2/config/config.csv @@ -0,0 +1 @@ +1