Skip to content

Commit

Permalink
Atualização do software - Versão 0.8 do dpg
Browse files Browse the repository at this point in the history
  • Loading branch information
iOsnaaente committed Jan 21, 2022
1 parent 1a35d98 commit 9d35f01
Show file tree
Hide file tree
Showing 73 changed files with 11,803 additions and 807 deletions.
11 changes: 11 additions & 0 deletions CONFIG.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
LATITUDE=-29.16530765942215
LONGITUDE=-54.89831672609559
ALTURA=425
UTC=-3
WINDOW_OPENED=Inicio
ALTITUDE=0
POS_GIR=6
POS_ELE=0
RESOLUCAO_M1=1.8
RESOLUCAO_M2=1.8
MICRO_PASSO_M1=1/16
807 changes: 0 additions & 807 deletions Tracker_0.6.py

This file was deleted.

1 change: 1 addition & 0 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__all__ = ['utils/']
Binary file added __pycache__/registry.cpython-39.pyc
Binary file not shown.
Binary file added __pycache__/themes.cpython-39.pyc
Binary file not shown.
Binary file added fonts/verdana.ttf
Binary file not shown.
Binary file added fonts/verdanab.ttf
Binary file not shown.
Binary file added fonts/verdanai.ttf
Binary file not shown.
Binary file added fonts/verdanaz.ttf
Binary file not shown.
8,199 changes: 8,199 additions & 0 deletions ico/5 Linkages Mechanism.STEP

Large diffs are not rendered by default.

Binary file added ico/large_ico.ico
Binary file not shown.
Binary file added ico/large_ico_full.ico
Binary file not shown.
Binary file added ico/small_ico.ico
Binary file not shown.
Binary file added ico/small_ico_full.ico
Binary file not shown.
Binary file added img/JetTowers-Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/Originals/Tracker_nobg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/Tracker_nobg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/engrenagem.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/engrenagem.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/fundo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/nodeRed.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
139 changes: 139 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
from dearpygui.dearpygui import *

from views.menuInicio import *
from views.menuVisualizacaoGeral import *
from views.menuPosicaoDoSol import *
from views.menuAtuadores import *
from views.menuSensores import *
from views.menuRedNodeComm import *
from views.menuConfigurações import *

from themes import *
from registry import *
from time import sleep, time

sun_data.update_date()

window_opened = ''

def resize_mainwindow ( ):
new_w = get_item_width ( 1_0 )
new_h = get_item_height( 1_0 )
if window_opened == 'Inicio' : resize_inicio ( new_w, new_h )
elif window_opened == 'Visualizacao geral' : resize_visualizacaoGeral( )
elif window_opened == 'Posicao do sol' : resize_posicaoDoSol ( )
elif window_opened == 'Atuadores' : resize_atuador ( )
elif window_opened == 'Sensores' : resize_sensores ( )
elif window_opened == 'Rednode comunicacao': resize_rednodecom ( new_w, new_h )
elif window_opened == 'Configuracoes' : resize_configuracoes ( )

def change_menu(sender, app_data, user_data ):
global window_opened
window_opened = user_data
# CLOSE ALL WINDOWS
for k in windows.keys():
for i in windows[k]:
dpg.hide_item(i)
# OPEN THE RIGHT TAB WINDOW
to_open = windows[user_data]
for i in to_open:
dpg.show_item(i)
resize_mainwindow()

def configure_viewport():
setup_viewport ( )
set_viewport_large_icon( PATH + 'ico\\large_ico.ico' )
set_viewport_small_icon( PATH + 'ico\\small_ico.ico' )
set_viewport_min_height( height = 900 )
set_viewport_min_width ( width = 1000 )
set_viewport_title ( title = 'JetTracker - Controle do sol' )

change_font()

maximize_viewport()

set_primary_window ( main_window, True )

init_inicio ( windows, change_menu )
init_visualizacaoGeral( windows )
init_posicaoDoSol ( windows )
init_atuador ( windows )
init_sensores ( windows )
init_rednodecom ( windows )
init_configuracoes ( windows )

def closing_dpg( sender, data, user ):
with window( pos = [ get_item_width(10)/2.5, get_item_height(10)/2.5]):
add_text( 'Obrigado por usar nosso programa\nEle irá encerrar em instantes' )
sleep(2)
stop_dearpygui()

# Main Window
with window( label = 'Main Window', id = 1_0, autosize = True ) as main_window:
with menu_bar(label = "MenuBar"):
add_menu_item( label="Inicio" , callback = change_menu, user_data = "Inicio" )
add_menu_item( label="Visualização geral" , callback = change_menu, user_data = "Visualizacao geral" )
#add_menu_item( label="Posição do sol" , callback = change_menu, user_data = "Posicao do sol" )
add_menu_item( label="Atuadores" , callback = change_menu, user_data = "Atuadores" )
#add_menu_item( label="Atuação da base" , callback = change_menu, user_data = "Atuacao da base" )
#add_menu_item( label="Atuação da elevação", callback = change_menu, user_data = "Atuacao da elevacao" )
add_menu_item( label="Sensores" , callback = change_menu, user_data = "Sensores" )
add_menu_item( label="RedNode Comunicacao", callback = change_menu, user_data = "Rednode comunicacao" )
add_menu_item( label="Configurações" , callback = change_menu, user_data = "Configuracoes" )
add_menu_item( label='Sair' , callback = closing_dpg )

configure_viewport( )
add_resize_handler( main_window, callback = resize_mainwindow )
change_menu ( None, None, 'Inicio' )

time_date = 0
time_acum = 0

#show_implot_demo()

while is_dearpygui_running():
if not get_frame_count() % 1:
if window_opened == 'Inicio' : render_inicio () # ID = 1_0
elif window_opened == 'Visualizacao geral' : render_visualizacaoGeral() # ID = 2_0
elif window_opened == 'Posicao do sol' : render_posicaoDoSol() # ID = 3_0
elif window_opened == 'Atuadores' : render_atuador() # ID = 4_0
elif window_opened == 'Sensores' : render_sensores() # ID = 5_0
elif window_opened == 'Rednode comunicacao': render_rednodecom() # ID = 6_0
elif window_opened == 'Configuracoes' : render_configuracao() # ID = 9_0

time_acum += get_delta_time()
time_date += get_delta_time()

if time_acum > 1 and get_value(hora_manual) == False:
sun_data.update_date()

set_value ( day , sun_data.day )
set_value ( month , sun_data.month )
set_value ( year , sun_data.year )
set_value ( second , sun_data.second )
set_value ( minute , sun_data.minute )
set_value ( hour , sun_data.hour )
set_value ( total_seconds, sun_data.total_seconds )
set_value ( dia_juliano , sun_data.dia_juliano )

set_value ( azi , sun_data.azi )
set_value ( alt , sun_data.alt )

set_value ( sunrise_azi , sun_data.azimute_sunrise )
set_value ( sunset_azi , sun_data.azimute_sunset )
set_value ( culminant_alt, sun_data.elevation_transit )

# Se estiver conectado, pega os valores de azi do motor e alt
if get_value( CONNECTED) == True:
set_value ( MG_Angle , sun_data.azi )
set_value ( ME_Angle , sun_data.alt )

time_acum = 0
refresh_TCP_connection( None, None, None )

if time_date > 60:
send_date_ajust_motor()
time_date = 0

render_dearpygui_frame()
print('Volte Sempre')
110 changes: 110 additions & 0 deletions registry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import dearpygui.dearpygui as dpg
import os

from utils.Model import SunPosition
from serial import Serial

COMP = Serial()
DOM = [ 'Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro' ]
PATH = os.path.dirname( __file__ )
PATH_IMG = PATH + '\\utils\\img\\'

color = {
"black" : lambda alfa : [ 0, 0, 0, alfa ],
"red" : lambda alfa : [ 255, 0, 0, alfa ],
"yellow" : lambda alfa : [ 255, 255, 0, alfa ],
"green" : lambda alfa : [ 0, 255, 0, alfa ],
"ciano" : lambda alfa : [ 0, 255, 255, alfa ],
"blue" : lambda alfa : [ 0, 0, 255, alfa ],
"magenta" : lambda alfa : [ 255, 0, 255, alfa ],
"white" : lambda alfa : [ 255, 255, 255, alfa ],
'gray' : lambda alfa : [ 155, 155, 155, alfa ],
'orange' : lambda alfa : [ 255, 69, 0, alfa ],

'on_color' : lambda alfa : [ 0x3c, 0xb3, 0x71, alfa ],
'on_hover' : lambda alfa : [ 0x92, 0xe0, 0x92, alfa ],
'on_click' : lambda alfa : [ 0x20, 0xb2, 0xaa, alfa ],
'off_color' : lambda alfa : [ 0xff, 0x45, 0x00, alfa ],
'off_hover' : lambda alfa : [ 0xf0, 0x80, 0x80, alfa ],
'off_click' : lambda alfa : [ 0x8b, 0x45, 0x13, alfa ],
}

windows = {
"Inicio" : [ ],
"Visualizacao geral" : [ ],
"Posicao do sol" : [ ],
"Atuadores" : [ ],
"Atuacao da base" : [ ],
"Atuacao da elevacao": [ ],
"Sensores" : [ ],
"Rednode comunicacao": [ ],
"Configuracoes" : [ ],
'Sair' : [ ],
}

def add_image_loaded( img_path ):
w, h, c, d = dpg.load_image( img_path )
with dpg.texture_registry() as reg_id :
return dpg.add_static_texture( w, h, d, parent = reg_id )

def change_font():
with dpg.font_registry( id = 'fonts' ):
dpg.add_font( PATH + '\\fonts\\verdana.ttf', 14, default_font=True, parent='fonts')

with dpg.value_registry( id = 99_99_0 ) as registries:
LATITUDE = dpg.add_string_value( parent = registries, default_value = '-29.16530765942215', id = 99_99_1 )
LONGITUDE = dpg.add_string_value( parent = registries, default_value = '-54.89831672609559', id = 99_99_2 )

MG_uStep = dpg.add_string_value( parent = registries, default_value = '1/16' , id = 99_99_11 )
ME_uStep = dpg.add_string_value( parent = registries, default_value = '1/16' , id = 99_99_14 )

ALTITUDE = dpg.add_float_value ( parent = registries, default_value = 425 , id = 99_99_3 )
UTC_HOUR = dpg.add_int_value ( parent = registries, default_value = -3 , id = 99_99_4 )

DAY_2Compute = dpg.add_bool_value ( parent = registries, default_value = False , id = 99_99_5 )

CONNECTED = dpg.add_bool_value ( parent = registries, default_value = False , id = 99_99_6_0 )
TCP_CONNECTED= dpg.add_bool_value ( parent = registries, default_value = False , id = 99_99_6_1 )

M1_ONorOFF = dpg.add_bool_value ( parent = registries, default_value = False , id = 99_99_7 )
M2_ONorOFF = dpg.add_bool_value ( parent = registries, default_value = False , id = 99_99_8 )

MG_Resolucao = dpg.add_float_value ( parent = registries, default_value = 0.0 , id = 99_99_9 )
MG_Steps = dpg.add_float_value ( parent = registries, default_value = 0.0 , id = 99_99_10 )
ME_Resolucao = dpg.add_float_value ( parent = registries, default_value = 0.0 , id = 99_99_12 )
ME_Steps = dpg.add_float_value ( parent = registries, default_value = 0.0 , id = 99_99_13 )

MG_Angle = dpg.add_float_value ( parent = registries, default_value = 0.0 , id = 99_99_15 )
ME_Angle = dpg.add_float_value ( parent = registries, default_value = 0.0 , id = 99_99_16 )

MGSR_Angle = dpg.add_float_value ( parent = registries, default_value = 0.0 , id = 99_99_17 )
MESR_Angle = dpg.add_float_value ( parent = registries, default_value = 0.0 , id = 99_99_18 )
VelAng_M1 = dpg.add_float_value ( parent = registries, default_value = 1.0 , id = 99_99_19 )
VelAng_M2 = dpg.add_float_value ( parent = registries, default_value = 1.0 , id = 99_99_20 )

sundaylight = dpg.add_float4_value ( parent = registries, default_value = [0,0,0,0] , id = 99_99_21 )
sunrise = dpg.add_float4_value ( parent = registries, default_value = [0,0,0,0] , id = 99_99_22 )
sunset = dpg.add_float4_value ( parent = registries, default_value = [0,0,0,0] , id = 99_99_23 )
sunculminant = dpg.add_float4_value ( parent = registries, default_value = [0,0,0,0] , id = 99_99_24 )

day = dpg.add_int_value ( parent = registries, default_value = 1 , id = 99_99_25 )
month = dpg.add_int_value ( parent = registries, default_value = 1 , id = 99_99_26 )
year = dpg.add_int_value ( parent = registries, default_value = 1 , id = 99_99_27 )
second = dpg.add_int_value ( parent = registries, default_value = 1 , id = 99_99_28 )
minute = dpg.add_int_value ( parent = registries, default_value = 1 , id = 99_99_29 )
hour = dpg.add_int_value ( parent = registries, default_value = 1 , id = 99_99_30 )

total_seconds= dpg.add_int_value ( parent = registries, default_value = 1 , id = 99_99_31 )
dia_juliano = dpg.add_int_value ( parent = registries, default_value = 1 , id = 99_99_32 )

hora_manual = dpg.add_bool_value ( parent = registries, default_value = False , id = 99_99_33 )

sunrise_azi = dpg.add_float_value ( parent = registries, default_value = 0.0 , id = 99_99_34 )
sunset_azi = dpg.add_float_value ( parent = registries, default_value = 0.0 , id = 99_99_35 )
culminant_alt= dpg.add_float_value ( parent = registries, default_value = 0.0 , id = 99_99_36 )

azi = dpg.add_float_value ( parent = registries, default_value = 0.0 , id = 99_99_37 )
alt = dpg.add_float_value ( parent = registries, default_value = 0.0 , id = 99_99_38 )

sun_data = SunPosition( dpg.get_value(LATITUDE), dpg.get_value(LONGITUDE), dpg.get_value(ALTITUDE) )
sun_data.update()
5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
python==3.9.0
dearpygui==0.6.294
serial==3.5
ephem==3.7.7.1
numpy==1.20.1
22 changes: 22 additions & 0 deletions themes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import dearpygui.dearpygui as dpg
from registry import color

with dpg.theme( default_theme = True ) as theme_id:
dpg.add_theme_color( dpg.mvThemeCol_Button , (52, 140, 215), category = dpg.mvThemeCat_Core )
dpg.add_theme_style( dpg.mvStyleVar_FrameRounding, 5 , category = dpg.mvThemeCat_Core )
# um azul bem bonito -> 52, 140, 215
# um laranja bem bonito -> 255, 140, 23

with dpg.theme( id = dpg.generate_uuid() ) as Motor_On:
dpg.add_theme_color( dpg.mvThemeCol_Button , color['on_color'](255), category = dpg.mvThemeCat_Core)
dpg.add_theme_color( dpg.mvThemeCol_ButtonHovered, color['on_hover'](255), category = dpg.mvThemeCat_Core)

with dpg.theme( id = dpg.generate_uuid() ) as Motor_Off:
dpg.add_theme_color( dpg.mvThemeCol_Button , color['off_color'](255), category = dpg.mvThemeCat_Core)
dpg.add_theme_color( dpg.mvThemeCol_ButtonHovered, color['off_hover'](255), category = dpg.mvThemeCat_Core)

with dpg.theme( id = 'noborder'):
dpg.add_theme_style(dpg.mvStyleVar_ChildBorderSize, 0, category = dpg.mvThemeCat_Core)

with dpg.theme( id = 'no_win_border'):
dpg.add_theme_style( dpg.mvStyleVar_WindowBorderSize, 0 , category = dpg.mvThemeCat_Core )
14 changes: 14 additions & 0 deletions utils/Async_function_BB.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from threading import Thread

class Async_function( Thread ):
def __init__(self, func, args = 0 ):
Thread.__init__(self)
self.func = func
self.args = args
self.retr = 0

def run( self ):
self.retr = self.func( self.args )

def return_val(self):
return self.retr
Loading

0 comments on commit 9d35f01

Please sign in to comment.