Poprawka w module Radioactive, poprawka czytania ułamków

pull/3/head
pawel 2022-11-06 11:41:38 +01:00
rodzic 7c5a065108
commit d1c7ae34b1
14 zmienionych plików z 54 dodań i 14 usunięć

Wyświetl plik

@ -147,12 +147,17 @@ $slownik_wszystkie = array(
array('Średnia wartość dobowa'),
array('mikrosjiwerta'),
array('na godzinę'),
array('jedna'),
array('dwie'),
array('setna'),
array('setne'),
array('setnych'),
array('dziesiąta'),
array('dziesiąte'),
array('dziesiątych'),
array('tysięczna'),
array('tysięczne'),
array('tysięcznych'),
/*
*
*

BIN
pl_google/dwie.ogg 100644

Plik binarny nie jest wyświetlany.

BIN
pl_google/jedna.ogg 100644

Plik binarny nie jest wyświetlany.

Wyświetl plik

@ -78,13 +78,21 @@ class PLGoogle(SR0WXLanguage):
pass
@remove_accents
def read_number(self, value, units=None):
def read_number(self, value, units=None, isFraction=None):
"""Converts numbers to text."""
if units is None:
retval = pyliczba.lslownie(abs(value))
else:
retval = pyliczba.cosslownie(abs(value), units)
if isFraction:
if value % 1 == 0 and retval.startswith(u("jeden ")):
retval = retval.replace(u("jeden "), u("jedna "))
if value % 2 == 0 and retval.startswith(u("dwa ")):
retval = retval.replace(u("dwa "), u("dwie "))
if value % 10 % 2 == 0:
retval = retval.replace(u("dwa "), u("dwie "))
if retval.startswith(u("jeden tysiąc")):
retval = retval.replace(u("jeden tysiąc"), u("tysiąc"))
if value < 0:
@ -142,21 +150,30 @@ class PLGoogle(SR0WXLanguage):
@remove_accents
def read_decimal(self, value):
deg1000 = [
u("tysie_czna"),
u("tysie_czne"),
u("tysie_cznych")
]
deg100 = [
u("setna"),
u("setne"),
u("setnych"),
u("setnych"),
]
deg10 = [
u("dziesia_ta"),
u("dziesia_te"),
u("dziesia_tych"),
u("dziesia_tych"),
]
if value >= 10:
return read_number(value, deg100)
if (value % 100 == 0 and value >= 100):
return read_number( value / 100, deg10, True)
elif (value % 10 == 0 and value > 9 ):
return read_number( value / 10, deg100, True)
else:
return read_number(value, deg10)
return read_number(value, deg1000, True)
@remove_accents
def read_direction(self, value, short=False):

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Wyświetl plik

@ -78,13 +78,21 @@ class PLGoogle(SR0WXLanguage):
pass
@remove_accents
def read_number(self, value, units=None):
def read_number(self, value, units=None, isFraction=None):
"""Converts numbers to text."""
if units is None:
retval = pyliczba.lslownie(abs(value))
else:
retval = pyliczba.cosslownie(abs(value), units)
if isFraction:
if value % 1 == 0 and retval.startswith(u("jeden ")):
retval = retval.replace(u("jeden "), u("jedna "))
if value % 2 == 0 and retval.startswith(u("dwa ")):
retval = retval.replace(u("dwa "), u("dwie "))
if value % 10 % 2 == 0:
retval = retval.replace(u("dwa "), u("dwie "))
if retval.startswith(u("jeden tysiąc")):
retval = retval.replace(u("jeden tysiąc"), u("tysiąc"))
if value < 0:
@ -142,21 +150,30 @@ class PLGoogle(SR0WXLanguage):
@remove_accents
def read_decimal(self, value):
deg1000 = [
u("tysie_czna"),
u("tysie_czne"),
u("tysie_cznych")
]
deg100 = [
u("setna"),
u("setne"),
u("setnych"),
u("setnych"),
]
deg10 = [
u("dziesia_ta"),
u("dziesia_te"),
u("dziesia_tych"),
u("dziesia_tych"),
]
if value >= 10:
return read_number(value, deg100)
if (value % 100 == 0 and value >= 100):
return read_number( value / 100, deg10, True)
elif (value % 10 == 0 and value > 9 ):
return read_number( value / 10, deg100, True)
else:
return read_number(value, deg10)
return read_number(value, deg1000, True)
@remove_accents
def read_direction(self, value, short=False):
@ -340,3 +357,4 @@ read_direction = pl.read_direction
read_datetime = pl.read_datetime
read_callsign = pl.read_callsign

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Wyświetl plik

@ -77,8 +77,8 @@ class RadioactiveSq9atk(SR0WXModule):
self.__logger.info("::: Przetwarzam dane...\n")
data = self.getSensorData(html)
msvCurrent = int(float(data['current'])*100)
msvAverage = int(float(data['average'])*100)
msvCurrent = int(float(data['current'])*1000)
msvAverage = int(float(data['average'])*1000)
averageValue = " ".join(["wartos_c__aktualna",self.__language.read_decimal( msvCurrent )+" ","mikrosjiwerta","na_godzine_"])
currentValue = " ".join(["s_rednia_wartos_c__dobowa",self.__language.read_decimal( msvAverage )+" ","mikrosjiwerta","na_godzine_"])