ara-astronomia / crac-client

Client for connection to crac-server via gRPC
GNU General Public License v3.0
0 stars 1 forks source link

Show gauge for UPS #18

Open spider65 opened 1 year ago

spider65 commented 1 year ago

Show Voltage and Ampere gauge with thresholds and alerts, and alert for Down power supply network

Given I want to observe When one of the metrics is in alert Then I want to be alerted

For this upgrade, due to space problems in the GUI, it would be better to use progress meters instead of guages https://github.com/PySimpleGUI/PySimpleGUI/blob/master/DemoPrograms/Demo_Progress_Meter_Simulated.py

The color of the progress meter will change as defined thresholds are added. a label will show the numerical value

spider65 commented 1 year ago

IMG-20221121-WA0000

spider65 commented 1 year ago

Test code. import PySimpleGUI as sg

print('inserisci il valore della percentuale delle batterie della cupola') batt_cupola=input() print('inserisci il valore della tensione di rete della cupola') volt_cupola=input() print('inserisci il valore della percentuale delle batterie della room') batt_room=input() print('inserisci il valore della tensione di rete della room') volt_room=input()

batt_cupola=float(batt_cupola) volt_cupola=float(volt_cupola) batt_room=float(batt_room) volt_room=float(volt_room)

batt_cupola=float(34.7)

volt_cupola=float(215.6)

batt_room=float(55.7)

volt_room=float(198.3)

sg.theme('dark') layout=[ [sg.Frame(layout = ( [sg.T('Batterie',size=(7,1)), sg.T(' %',size=(6,1), key='OUT-BATT-CUPOLA'), sg.ProgressBar(100, orientation='h', size=(17,3), bar_color=('red', 'white'), relief=sg.RELIEF_RAISED ,key='PERCENT-BATT-CUPOLA')], [sg.T('Rete',size=(7,1)),sg.T('V',size=(6,1),key='OUT-VOLT-CUPOLA'), sg.ProgressBar(250, orientation='h', size=(17,3), bar_color=('red', 'white'), relief=sg.RELIEF_RAISED ,key='VOLT-CUPOLA')], ),title='UPS cupola', relief=sg.RELIEF_GROOVE)], [sg.Frame(layout = ( [sg.T('Batterie',size=(7,1)), sg.T(' %',size=(6,1), key='OUT-BATT-ROOM'), sg.ProgressBar(100, orientation='h', size=(17,3), bar_color=('red', 'white'), relief=sg.RELIEF_RAISED ,key='PERCENT-BATT-ROOM')], [sg.T('Rete',size=(7,1)), sg.T(' V',size=(6,1), key='OUT-VOLT-ROOM'), sg.ProgressBar(250, orientation='h', size=(17,3), bar_color=('red', 'white'), relief=sg.RELIEF_RAISED ,key='VOLT-ROOM')], ),title='UPS control room', relief=sg.RELIEF_GROOVE)], [sg.RButton('leggi')] ]

window = sg.Window('UPS cupola').Layout(layout)

progress_batt_cupola = window['PERCENT-BATT-CUPOLA'] output_batt_cupola = window['OUT-BATT-CUPOLA'] progress_volt_cupola = window['VOLT-CUPOLA'] output_volt_cupola = window['OUT-VOLT-CUPOLA']

progress_batt_room = window['PERCENT-BATT-ROOM'] output_batt_room = window['OUT-BATT-ROOM'] progress_volt_room = window['VOLT-ROOM'] output_volt_room = window['OUT-VOLT-ROOM']

while True: values = window.Read()

if batt_cupola <= 15:
    progress_batt_cupola.Update(batt_cupola, bar_color=('red', 'white'))
    output_batt_cupola.Update(str(batt_cupola)+' %', text_color=('red'))
if batt_cupola >15 and batt_cupola <=25:
    progress_batt_cupola(batt_cupola, bar_color=('orange', 'white'))
    output_batt_cupola.Update(str(batt_cupola)+' %', text_color=('orange'))
if batt_cupola >25 and batt_cupola <=50:
    progress_batt_cupola.Update(batt_cupola, bar_color=('gold', 'white'))
    output_batt_cupola.Update(str(batt_cupola)+' %', text_color=('gold'))
if batt_cupola >50:
    progress_batt_cupola.Update(batt_cupola,bar_color=('green', 'white'))
    output_batt_cupola.Update(str(batt_cupola)+' %', text_color=('green'))        

if volt_cupola <= 190:
    progress_volt_cupola.Update(volt_cupola, bar_color=('red', 'white'))
    output_volt_cupola.Update(str(volt_cupola)+' V', text_color=('red'))
if volt_cupola >190 and volt_cupola <=205:
    progress_volt_cupola(volt_cupola, bar_color=('orange', 'white'))
    output_volt_cupola.Update(str(volt_cupola)+' V', text_color=('orange'))
if volt_cupola >205 and volt_cupola <=230:
    progress_volt_cupola.Update(volt_cupola, bar_color=('green', 'white'))
    output_volt_cupola.Update(str(volt_cupola)+' V', text_color=('green'))
if volt_cupola >230:
    progress_volt_cupola.Update(volt_cupola, bar_color=('red', 'white'))
    output_volt_cupola.Update(str(volt_cupola)+' V', text_color=('red'))

if batt_room <= 15:
    progress_batt_room.Update(batt_room, bar_color=('red', 'white'))
    output_batt_room.Update(str(batt_room)+' %', text_color=('red'))
if batt_room >15 and batt_room <=25:
    progress_batt_room(batt_room, bar_color=('orange', 'white'))
    output_batt_room.Update(str(batt_room)+' %', text_color=('orange'))
if batt_room >25 and batt_room <=50:
    progress_batt_room.Update(batt_room, bar_color=('gold', 'white'))
    output_batt_room.Update(str(batt_room)+' %', text_color=('gold'))
if batt_room >50:
    progress_batt_room.Update(batt_room, bar_color=('green', 'white'))
    output_batt_room.Update(str(batt_room)+' %', text_color=('green'))        

if volt_room <= 190:
    progress_volt_room.Update(volt_room, bar_color=('red', 'white'))
    output_volt_room.Update(str(volt_room)+' V', text_color=('red'))
if volt_room >190 and volt_room <=205:
    progress_volt_room(volt_room, bar_color=('orange', 'white'))
    output_volt_room.Update(str(volt_room)+' V', text_color=('orange'))
if volt_room >205 and volt_room <=230:
    progress_volt_room.Update(volt_room, bar_color=('green', 'white'))
    output_volt_room.Update(str(volt_room)+' V', text_color=('green'))
if volt_room >230:
    progress_volt_room.Update(volt_room, bar_color=('red', 'white'))
    output_volt_room.Update(str(volt_room)+' V', text_color=('red'))