First half of space weather screen. Still missing values updates on screen
This commit is contained in:
27
artemis.py
27
artemis.py
@@ -23,7 +23,7 @@ from PyQt5.QtCore import (QFileInfo,
|
|||||||
pyqtSlot,)
|
pyqtSlot,)
|
||||||
|
|
||||||
from audio_player import AudioPlayer
|
from audio_player import AudioPlayer
|
||||||
|
from space_weather_data import SpaceWeatherData
|
||||||
from double_text_button import DoubleTextButton
|
from double_text_button import DoubleTextButton
|
||||||
from download_window import DownloadWindow
|
from download_window import DownloadWindow
|
||||||
from switchable_label import SwitchableLabel, SwitchableLabelIterable
|
from switchable_label import SwitchableLabel, SwitchableLabelIterable
|
||||||
@@ -345,13 +345,10 @@ class Artemis(QMainWindow, Ui_MainWindow):
|
|||||||
|
|
||||||
# ##########################################################################################
|
# ##########################################################################################
|
||||||
|
|
||||||
# self.load_db()
|
|
||||||
|
|
||||||
# Left list widget and search bar.
|
# Left list widget and search bar.
|
||||||
self.search_bar.textChanged.connect(self.display_signals)
|
self.search_bar.textChanged.connect(self.display_signals)
|
||||||
self.result_list.currentItemChanged.connect(self.display_specs)
|
self.result_list.currentItemChanged.connect(self.display_specs)
|
||||||
self.result_list.itemDoubleClicked.connect(lambda: self.main_tab.setCurrentWidget(self.signal_properties_tab))
|
self.result_list.itemDoubleClicked.connect(lambda: self.main_tab.setCurrentWidget(self.signal_properties_tab))
|
||||||
# self.display_signals()
|
|
||||||
self.audio_widget = AudioPlayer(self.play,
|
self.audio_widget = AudioPlayer(self.play,
|
||||||
self.pause,
|
self.pause,
|
||||||
self.stop,
|
self.stop,
|
||||||
@@ -375,12 +372,33 @@ class Artemis(QMainWindow, Ui_MainWindow):
|
|||||||
BandLabel(self.ehf_left, self.ehf, self.ehf_right),
|
BandLabel(self.ehf_left, self.ehf, self.ehf_right),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Space weather
|
||||||
|
self.info_now_btn.clicked.connect(lambda : webbrowser.open(Constants.FORECAST_INFO))
|
||||||
|
self.update_now_btn.clicked.connect(self.start_update_space_weather)
|
||||||
|
self.space_weather_data = SpaceWeatherData()
|
||||||
|
self.space_weather_data.update_complete.connect(self.update_space_weather)
|
||||||
|
|
||||||
# Final operations.
|
# Final operations.
|
||||||
self.theme.initialize()
|
self.theme.initialize()
|
||||||
self.load_db()
|
self.load_db()
|
||||||
self.display_signals()
|
self.display_signals()
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
|
@pyqtSlot()
|
||||||
|
def start_update_space_weather(self):
|
||||||
|
self.update_now_bar.setMaximum(self.update_now_bar.minimum())
|
||||||
|
self.space_weather_data.update()
|
||||||
|
|
||||||
|
@pyqtSlot(bool)
|
||||||
|
def update_space_weather(self, status_ok):
|
||||||
|
self.update_now_bar.setMaximum(self.update_now_bar.minimum() + 1)
|
||||||
|
if status_ok:
|
||||||
|
print('ok') # Insert labels values and colors here.
|
||||||
|
else:
|
||||||
|
pop_up(self, title = Messages.BAD_DOWNLOAD,
|
||||||
|
text = Messages.BAD_DOWNLOAD_MSG).show()
|
||||||
|
self.space_weather_data.remove_data()
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def go_to_gfd(self, by):
|
def go_to_gfd(self, by):
|
||||||
query = "/?q="
|
query = "/?q="
|
||||||
@@ -394,7 +412,6 @@ class Artemis(QMainWindow, Ui_MainWindow):
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@pyqtSlot(QListWidgetItem)
|
@pyqtSlot(QListWidgetItem)
|
||||||
def remove_if_unselected_modulation(self, item):
|
def remove_if_unselected_modulation(self, item):
|
||||||
if not item.isSelected():
|
if not item.isSelected():
|
||||||
|
|||||||
@@ -68,6 +68,12 @@ class Database(object):
|
|||||||
|
|
||||||
class Constants(object):
|
class Constants(object):
|
||||||
ACF_DOCS = "https://aresvalley.com/documentation/"
|
ACF_DOCS = "https://aresvalley.com/documentation/"
|
||||||
|
FORECAST_XRAY = "https://services.swpc.noaa.gov/text/goes-xray-flux-primary.txt"
|
||||||
|
FORECAST_PROT = "https://services.swpc.noaa.gov/text/goes-particle-flux-primary.txt"
|
||||||
|
FORECAST_AK_IND = "https://services.swpc.noaa.gov/text/wwv.txt"
|
||||||
|
FORECAST_SGAS = "https://services.swpc.noaa.gov/text/sgas.txt"
|
||||||
|
FORECAST_G = "https://services.swpc.noaa.gov/text/3-day-forecast.txt"
|
||||||
|
FORECAST_INFO = "https://www.swpc.noaa.gov/sites/default/files/images/NOAAscales.pdf"
|
||||||
SEARCH_LABEL_IMG = "search_icon.png"
|
SEARCH_LABEL_IMG = "search_icon.png"
|
||||||
VOLUME_LABEL_IMG = "volume.png"
|
VOLUME_LABEL_IMG = "volume.png"
|
||||||
DATA_FOLDER = "Data"
|
DATA_FOLDER = "Data"
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
from PyQt5.QtCore import pyqtSlot, pyqtSignal, QObject
|
from PyQt5.QtCore import pyqtSlot, pyqtSignal, QObject
|
||||||
|
|
||||||
from threads import UpadteForecastThread, ThreadStatus
|
from threads import UpadteSpaceWeatherThread, ThreadStatus
|
||||||
from utilities import double_split
|
from utilities import double_split
|
||||||
|
|
||||||
class ForecastData(QObject):
|
class SpaceWeatherData(QObject):
|
||||||
update_complete = pyqtSignal(bool)
|
update_complete = pyqtSignal(bool)
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -13,7 +13,7 @@ class ForecastData(QObject):
|
|||||||
self.ak_index = ''
|
self.ak_index = ''
|
||||||
self.sgas = ''
|
self.sgas = ''
|
||||||
self.geo_storm = ''
|
self.geo_storm = ''
|
||||||
self.__update_thread = UpadteForecastThread(self)
|
self.__update_thread = UpadteSpaceWeatherThread(self)
|
||||||
self.__update_thread.finished.connect(self.__parse_and_emit_signal)
|
self.__update_thread.finished.connect(self.__parse_and_emit_signal)
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
@@ -21,11 +21,11 @@ class ForecastData(QObject):
|
|||||||
self.__update_thread.start()
|
self.__update_thread.start()
|
||||||
|
|
||||||
def __parse_data(self):
|
def __parse_data(self):
|
||||||
self.xray = double_split(str(self.xray))
|
self.xray = double_split(self.xray)
|
||||||
self.prot_el = double_split(str(self.prot_el))
|
self.prot_el = double_split(self.prot_el)
|
||||||
self.ak_index = double_split(str(self.ak_index))
|
self.ak_index = double_split(self.ak_index)
|
||||||
self.sgas = double_split(str(self.sgas))
|
self.sgas = double_split(self.sgas)
|
||||||
self.geo_storm = double_split(str(self.geo_storm))
|
self.geo_storm = double_split(self.geo_storm)
|
||||||
|
|
||||||
def remove_data(self):
|
def remove_data(self):
|
||||||
self.xray = ''
|
self.xray = ''
|
||||||
26
threads.py
26
threads.py
@@ -8,7 +8,6 @@ from zipfile import ZipFile
|
|||||||
from PyQt5.QtCore import QThread
|
from PyQt5.QtCore import QThread
|
||||||
from constants import Constants, Database, ChecksumWhat
|
from constants import Constants, Database, ChecksumWhat
|
||||||
from utilities import checksum_ok
|
from utilities import checksum_ok
|
||||||
import constants
|
|
||||||
|
|
||||||
class ThreadStatus(Enum):
|
class ThreadStatus(Enum):
|
||||||
OK = auto()
|
OK = auto()
|
||||||
@@ -56,3 +55,28 @@ class DownloadThread(QThread):
|
|||||||
zipped.extractall()
|
zipped.extractall()
|
||||||
except:
|
except:
|
||||||
self.__status = ThreadStatus.UNKNOWN_ERR
|
self.__status = ThreadStatus.UNKNOWN_ERR
|
||||||
|
|
||||||
|
|
||||||
|
class UpadteSpaceWeatherThread(QThread):
|
||||||
|
def __init__(self, space_weather_data):
|
||||||
|
super().__init__()
|
||||||
|
self.__status = ThreadStatus.OK
|
||||||
|
self.__space_weather_data = space_weather_data
|
||||||
|
|
||||||
|
@property
|
||||||
|
def status(self):
|
||||||
|
return self.__status
|
||||||
|
|
||||||
|
def __del__(self):
|
||||||
|
self.terminate()
|
||||||
|
self.wait()
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
try:
|
||||||
|
self.__space_weather_data.xray = str(urllib3.PoolManager().request('GET', Constants.FORECAST_XRAY).data)
|
||||||
|
self.__space_weather_data.prot_el = str(urllib3.PoolManager().request('GET', Constants.FORECAST_PROT).data)
|
||||||
|
self.__space_weather_data.ak_index = str(urllib3.PoolManager().request('GET', Constants.FORECAST_AK_IND).data)
|
||||||
|
self.__space_weather_data.sgas = str(urllib3.PoolManager().request('GET', Constants.FORECAST_SGAS).data)
|
||||||
|
self.__space_weather_data.geo_storm = str(urllib3.PoolManager().request('GET', Constants.FORECAST_G).data)
|
||||||
|
except:
|
||||||
|
self.__status = ThreadStatus.UNKNOWN_ERR
|
||||||
|
|||||||
@@ -107,3 +107,6 @@ def format_numbers(lower, upper):
|
|||||||
return f"{lower:,} {units[lower_factor]} - {upper:,} {units[upper_factor]}"
|
return f"{lower:,} {units[lower_factor]} - {upper:,} {units[upper_factor]}"
|
||||||
else:
|
else:
|
||||||
return f"{lower:,} {units[lower_factor]}"
|
return f"{lower:,} {units[lower_factor]}"
|
||||||
|
|
||||||
|
def double_split(string):
|
||||||
|
return [i.split() for i in string.splitlines()]
|
||||||
|
|||||||
Reference in New Issue
Block a user