-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from grimmpp/feature-branch
Small tool added to check EEP values of a data set.
- Loading branch information
Showing
7 changed files
with
191 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
|
||
from tkinter import * | ||
import tkinter as tk | ||
from tkinter import Tk, ttk | ||
|
||
from eltakobus.message import * | ||
from eltakobus.eep import A5_08_01 | ||
|
||
from ..data import data_helper | ||
|
||
|
||
class EepChecker(): | ||
|
||
def __init__(self, main:Tk): | ||
popup = Toplevel(main, padx=4, pady=4) | ||
popup.wm_title("EEP Checker") | ||
self.popup = popup | ||
|
||
row = 0 | ||
self.l_telegram = ttk.Label(popup, text="A5 5A") | ||
self.l_telegram.grid(row=row, column=0, sticky=EW, columnspan=2) | ||
|
||
row += 1 | ||
l = ttk.Label(popup, text="EEP: ") | ||
l.grid(row=row, column=0, sticky=W) | ||
|
||
self.cb_eep = ttk.Combobox(popup, state="readonly", width="14") | ||
self.cb_eep['values'] = data_helper.get_all_eep_names() | ||
self.cb_eep.set(A5_08_01.eep_string) | ||
self.cb_eep.grid(row=row, column=1, sticky=W) | ||
self.cb_eep.bind('<<ComboboxSelected>>', lambda e: [self.set_message_type(), self.show_eep_values(e)]) | ||
|
||
|
||
row += 1 | ||
l = ttk.Label(popup, text="Message Type: ") | ||
l.grid(row=row, column=0, sticky=W) | ||
|
||
self.l_msg_type = ttk.Label(popup, text='') | ||
self.l_msg_type.grid(row=row, column=1, sticky=W) | ||
# self.cb_msg_type = ttk.Combobox(popup, state="readonly", width="14") | ||
# self.cb_msg_type['values'] = ['RPS (Org = 0x05)', '1BS (Org = 0x06)', '4BS (Org = 0x7)'] | ||
# self.cb_msg_type.set('4BS (Org = 0x7)') | ||
# self.cb_msg_type.grid(row=row, column=1, sticky=W) | ||
# self.cb_msg_type.bind('<<ComboboxSelected>>', self.show_message) | ||
|
||
|
||
row += 1 | ||
l = ttk.Label(popup, text="Data: ") | ||
l.grid(row=row, column=0, sticky=W) | ||
|
||
self.e_data = ttk.Entry(popup, width="12") | ||
self.e_data.insert(END, "aa 80 76 0f") | ||
self.e_data.bind_all('<Key>', self.show_eep_values) | ||
self.e_data.grid(row=row, column=1, sticky=W) | ||
|
||
|
||
row += 1 | ||
l = ttk.Label(popup, text="EEP Values: ") | ||
l.grid(row=row, column=0, sticky=W, columnspan=2) | ||
|
||
|
||
row += 1 | ||
self.l_result = ttk.Label(popup, text="", font=("Arial", 11)) | ||
self.l_result.grid(row=row, column=0, sticky=W, columnspan=2) | ||
|
||
|
||
row += 1 | ||
l = ttk.Label(popup, text="") | ||
l.grid(row=row, column=0, sticky=W, columnspan=2) | ||
|
||
|
||
row += 1 | ||
b = ttk.Button(popup, text="Close", command=popup.destroy) | ||
b.bind('<Return>', lambda e: popup.destroy()) | ||
b.grid(row=row, column=0, columnspan=2, sticky=E) | ||
|
||
self.show_eep_values(None) | ||
|
||
popup.wm_attributes('-toolwindow', 'True') | ||
# popup.resizable (width=False, height=False) | ||
# popup.transient(main) | ||
# popup.grab_set() | ||
|
||
# center | ||
# w = 260 | ||
# h = 260 | ||
# x = main.winfo_x() + main.winfo_width()/2 - w/2 | ||
# y = main.winfo_y() + main.winfo_height()/2 - h/2 | ||
# popup.geometry('%dx%d+%d+%d' % (w, h, x, y)) | ||
|
||
main.wait_window(popup) | ||
|
||
|
||
def enable_disable_data_fields(self): | ||
msg_type = self.cb_msg_type.get() | ||
if '4BS' in msg_type: | ||
self.e_data2.config(state=NORMAL) | ||
self.e_data1.config(state=NORMAL) | ||
self.e_data0.config(state=NORMAL) | ||
else: | ||
self.e_data2.config(state=DISABLED) | ||
self.e_data1.config(state=DISABLED) | ||
self.e_data0.config(state=DISABLED) | ||
|
||
|
||
def set_message_type(self): | ||
try: | ||
msg = Regular4BSMessage(b'\x00\x00\x00\x00', 0x00, b'\x00\x00\x00\x00', False) | ||
eep = data_helper.find_eep_by_name(self.cb_eep.get()) | ||
eep_values = data_helper.get_values_for_eep(eep, msg) | ||
self.l_msg_type.config(text= '4BS (Org = 0x7)') | ||
return '4BS (Org = 0x7)' | ||
except: | ||
pass | ||
|
||
try: | ||
msg = Regular1BSMessage(b'\x00\x00\x00\x00', 0x00, b'\x00', False) | ||
eep = data_helper.find_eep_by_name(self.cb_eep.get()) | ||
eep_values = data_helper.get_values_for_eep(eep, msg) | ||
self.l_msg_type.config(text= '1BS (Org = 0x06)') | ||
return '1BS (Org = 0x06)' | ||
except: | ||
pass | ||
|
||
try: | ||
msg = RPSMessage(b'\x00\x00\x00\x00', 0x00, b'\x00', False) | ||
eep = data_helper.find_eep_by_name(self.cb_eep.get()) | ||
eep_values = data_helper.get_values_for_eep(eep, msg) | ||
self.l_msg_type.config(text= 'RPS (Org = 0x05)') | ||
return 'RPS (Org = 0x05)' | ||
except: | ||
pass | ||
|
||
|
||
def get_data_from_entry(self): | ||
text = self.e_data.get().upper() | ||
hex_string = '0x' | ||
for c in text: | ||
if c in ['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F']: | ||
hex_string += c | ||
return int(hex_string, 16).to_bytes(4, 'big') | ||
|
||
|
||
def show_eep_values(self, event): | ||
msg_type = self.set_message_type() | ||
try: | ||
data = self.get_data_from_entry() | ||
|
||
if '4BS' in msg_type: | ||
msg = Regular4BSMessage(b'\x00\x00\x00\x00', 0x00, data, False) | ||
elif '1BS' in msg_type: | ||
data = data[0:1] | ||
msg = Regular1BSMessage(b'\x00\x00\x00\x00', 0x00, data, False) | ||
elif 'RPS' in msg_type: | ||
msg = RPSMessage(b'\x00\x00\x00\x00', 0x00, data, False) | ||
data = data[0:1] | ||
|
||
msg_text = b2a(msg.serialize()).upper() | ||
self.l_telegram.config(text=msg_text) | ||
except: | ||
self.l_telegram.config(text='') | ||
|
||
try: | ||
eep = data_helper.find_eep_by_name(self.cb_eep.get()) | ||
eep_values = data_helper.get_values_for_eep(eep, msg) | ||
self.l_result.config(text='\n'.join(eep_values).replace('_',' ')) | ||
|
||
except: | ||
self.l_result.config(text='') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters