Merge branch 'emsesp:dev' into dev

This commit is contained in:
Proddy
2024-10-22 22:08:38 +02:00
committed by GitHub
13 changed files with 880 additions and 797 deletions

View File

@@ -369,6 +369,7 @@ const ApplicationSettings = () => {
margin="normal"
select
>
<MenuItem value="cz">Česky (CZ)</MenuItem>
<MenuItem value="de">Deutsch (DE)</MenuItem>
<MenuItem value="en">English (EN)</MenuItem>
<MenuItem value="fr">Français (FR)</MenuItem>

View File

@@ -342,7 +342,7 @@ const cz: Translation = {
AUTO_SCROLL: 'Automatické rolování',
DASHBOARD: 'Dashboard',
NO_DATA: 'Žádná data nejsou k dispozici',
DASHBOARD_1: 'Přizpůsobte si dashboard označením EMS entit jako Oblíbené pomocí modulu Přizpůsobení.',
DASHBOARD_1: 'Přizpůsobte si dashboard označením EMS entit jako Oblíbené pomocí modulu Přizpůsobení',
DEVELOPER_MODE: 'Developer Mode' // TODO translate
};

View File

@@ -143,7 +143,7 @@ const de: Translation = {
CUSTOMIZATIONS_RESTART: 'Alle Anpassungen wurden entfernt. Neustart...',
CUSTOMIZATIONS_FULL: 'Ausgewählte Entitäten haben das Limit überschritten. Bitte stapelweise speichern!',
CUSTOMIZATIONS_SAVED: 'Anpassungen gespeichert',
CUSTOMIZATIONS_HELP_1: 'Wählen Sie ein Gerät aus und passen Sie die Entitäten mithilfe der Optionen an.',
CUSTOMIZATIONS_HELP_1: 'Wählen Sie ein Gerät aus und passen Sie die Entitäten mithilfe der Optionen an',
CUSTOMIZATIONS_HELP_2: 'Als Favorit markieren',
CUSTOMIZATIONS_HELP_3: 'Schreibaktion deaktivieren',
CUSTOMIZATIONS_HELP_4: 'Von MQTT und API ausschließen',
@@ -186,8 +186,8 @@ const de: Translation = {
FILESYSTEM: 'Dateisystem (Genutzt / Frei)',
BUFFER_SIZE: 'Max. Puffergröße',
COMPACT: 'Kompakte Darstellung',
DOWNLOAD_SETTINGS_TEXT: 'Erstellen Sie eine Sicherung Ihrer Konfigurationen und Einstellungen.',
UPLOAD_TEXT: 'Laden Sie eine neue Firmware-Datei (.bin) oder eine Sicherungsdatei (.json) hoch.',
DOWNLOAD_SETTINGS_TEXT: 'Erstellen Sie eine Sicherung Ihrer Konfigurationen und Einstellungen',
UPLOAD_TEXT: 'Laden Sie eine neue Firmware-Datei (.bin) oder eine Sicherungsdatei (.json) hoch',
UPLOAD_DROP_TEXT: 'Klicken Sie hier, oder ziehen Sie eine Datei hierher.',
ERROR: 'Unerwarteter Fehler, bitte versuchen Sie es erneut.',
TIME_SET: 'Zeit gesetzt',
@@ -322,7 +322,7 @@ const de: Translation = {
MODULES: 'Module',
MODULES_1: 'Externe Module aktivieren oder deaktivieren',
MODULES_UPDATED: 'Module aktualisiert',
MODULES_DESCRIPTION: 'Klicken Sie auf das Modul, um EMS-ESP-Bibliotheksmodule zu aktivieren oder zu deaktivieren.',
MODULES_DESCRIPTION: 'Klicken Sie auf das Modul, um EMS-ESP-Bibliotheksmodule zu aktivieren oder zu deaktivieren',
MODULES_NONE: 'Keine externen Module erkannt',
RENAME: 'Umbenennen',
ENABLE_MODBUS: 'Modbus aktivieren',
@@ -342,7 +342,7 @@ const de: Translation = {
AUTO_SCROLL: 'Automatisches Scrollen',
DASHBOARD: 'Dashboard',
NO_DATA: 'Keine Daten verfügbar',
DASHBOARD_1: 'Passen Sie Ihr Dashboard an, indem Sie EMS-Entitäten mithilfe des Moduls „Anpassungen“ als Favorit markieren.',
DASHBOARD_1: 'Passen Sie Ihr Dashboard an, indem Sie EMS-Entitäten mithilfe des Moduls „Anpassungen“ als Favorit markieren',
DEVELOPER_MODE: 'Entwicklermodus'
};

View File

@@ -174,7 +174,7 @@ const pl: BaseTranslation = {
USE: 'Aby zaktualizować firmware skorzystaj z funkcji',
FACTORY_RESET: 'Ustawienia fabryczne',
SYSTEM_FACTORY_TEXT: 'Interfejs EMS-ESP został przywrócony do ustawień fabrycznych i zostanie teraz ponownie uruchomiony.',
SYSTEM_FACTORY_TEXT_DIALOG: 'Na pewno chcesz przywrócić ustawienia fabryczne interfejsu EMS-ESP? ',
SYSTEM_FACTORY_TEXT_DIALOG: 'Na pewno chcesz przywrócić ustawienia fabryczne interfejsu EMS-ESP?',
STABLE: 'Stable', // TODO translate
DEVELOPMENT: 'Testowe',
EMS_ESP_VER: 'Wersja Firmware',
@@ -299,7 +299,7 @@ const pl: BaseTranslation = {
SCHEDULE_TIMER_2: 'co minutę',
SCHEDULE_TIMER_3: 'co godzinę',
CUSTOM_ENTITIES: '{{N|n|}}iestandardowe{{|j|}} encj{{e|i|}}',
ENTITIES_HELP_1: 'Zdefiniuj niestandardowe encje dla magistrali EMS.',
ENTITIES_HELP_1: 'Zdefiniuj niestandardowe encje dla magistrali EMS',
ENTITIES_UPDATED: 'Niestandardowe encje zostały uaktualnione.',
WRITEABLE: 'Zapisywalna',
SHOWING: 'Wyświetlane',

View File

@@ -342,7 +342,7 @@ const sk: Translation = {
AUTO_SCROLL: 'Automatické rolovanie',
DASHBOARD: 'Panel',
NO_DATA: 'Nie sú k dispozícii žiadne údaje',
DASHBOARD_1: 'Prispôsobte si svoj informačný panel tak, že označíte entity EMS ako Obľúbené pomocou modulu Prispôsobenia.',
DASHBOARD_1: 'Prispôsobte si svoj informačný panel tak, že označíte entity EMS ako Obľúbené pomocou modulu Prispôsobenia',
DEVELOPER_MODE: 'Developer Mode' // TODO translate
};

View File

@@ -412,6 +412,7 @@ class EMSdevice {
static constexpr uint8_t EMS_DEVICE_ID_DHW8 = 0x2F; // last DHW module id?
// generic type IDs
static constexpr uint16_t EMS_TYPE_NAME = 0x01; // device config for ems devices, name ascii on offset 27ff for ems+
static constexpr uint16_t EMS_TYPE_VERSION = 0x02; // type ID for Version information. Generic across all EMS devices.
static constexpr uint16_t EMS_TYPE_UBADevices = 0x07; // EMS connected devices
static constexpr uint16_t EMS_TYPE_DEVICEERROR = 0xBE;

View File

@@ -881,6 +881,9 @@ std::string EMSESP::pretty_telegram(std::shared_ptr<const Telegram> telegram) {
if (type_name.empty()) {
// check for global/common types like Version & UBADevices
switch (telegram->type_id) {
case EMSdevice::EMS_TYPE_NAME:
type_name = "DeviceName";
break;
case EMSdevice::EMS_TYPE_VERSION:
type_name = "Version";
break;
@@ -959,6 +962,27 @@ void EMSESP::process_UBADevices(std::shared_ptr<const Telegram> telegram) {
}
}
// read deviceName from telegram 0x01 offset 27 and set it to custom name
void EMSESP::process_deviceName(std::shared_ptr<const Telegram> telegram) {
// exit if only part of name fields
if (telegram->offset > 27 || (telegram->offset + telegram->message_length) < 29) {
return;
}
char name[16];
uint8_t len = telegram->offset + telegram->message_length - 27;
strlcpy(name, (const char *)&telegram->message_data[27 - telegram->offset], len < 16 ? len : 16);
if (strlen(name)) {
webCustomizationService.read([&](WebCustomization const & settings) {
for (EntityCustomization e : settings.entityCustomizations) {
if ((e.device_id == telegram->src) && e.custom_name.empty()) {
e.custom_name = name;
break;
}
}
});
}
}
// process the Version telegram (type 0x02), which is a common type
// e.g. 09 0B 02 00 PP V1 V2
void EMSESP::process_version(std::shared_ptr<const Telegram> telegram) {
@@ -1000,6 +1024,8 @@ void EMSESP::process_version(std::shared_ptr<const Telegram> telegram) {
// add it - will be overwritten if device already exists
(void)add_device(device_id, product_id, version, brand);
// request the deviceName from telegram 0x01
send_read_request(EMSdevice::EMS_TYPE_NAME, device_id, 27);
}
// find the device object that matches the deviceID and see if it has a matching telegram type handler
@@ -1050,6 +1076,9 @@ bool EMSESP::process_telegram(std::shared_ptr<const Telegram> telegram) {
if (telegram->type_id == EMSdevice::EMS_TYPE_VERSION) {
process_version(telegram);
return true;
} else if (telegram->type_id == EMSdevice::EMS_TYPE_NAME) {
process_deviceName(telegram);
return true;
} else if (telegram->type_id == EMSdevice::EMS_TYPE_UBADevices) {
// do not flood tx-queue with version requests while waiting for km200
if (!wait_km_) {
@@ -1444,7 +1473,8 @@ void EMSESP::incoming_telegram(uint8_t * data, const uint8_t length) {
// not for response to raw send commands without read_id set
if ((response_id_ == 0 || read_id_ > 0) && (txservice_.read_next_tx(data[3], length) == read_id_)) {
read_next_ = true;
txservice_.send();
txservice_.send(); // read next part withing same poll or:
// txservice_.send_poll(); // close the bus, next request in new poll
} else {
read_next_ = false;
txservice_.send_poll(); // close the bus

View File

@@ -249,6 +249,7 @@ class EMSESP {
private:
static std::string device_tostring(const uint8_t device_id);
static void process_UBADevices(std::shared_ptr<const Telegram> telegram);
static void process_deviceName(std::shared_ptr<const Telegram> telegram);
static void process_version(std::shared_ptr<const Telegram> telegram);
static void publish_response(std::shared_ptr<const Telegram> telegram);
static void publish_all_loop();

File diff suppressed because it is too large Load Diff

View File

@@ -72,6 +72,27 @@ std::deque<Token> exprToTokens(const std::string & expr) {
if (*p == '\0') {
--p;
}
} else if (strncmp(p, "int", 3) == 0) {
p += 2;
tokens.emplace_back(Token::Type::Unary, "i", 5);
} else if (strncmp(p, "round", 5) == 0) {
p += 4;
tokens.emplace_back(Token::Type::Unary, "r", 5);
} else if (strncmp(p, "abs", 3) == 0) {
p += 2;
tokens.emplace_back(Token::Type::Unary, "a", 5);
} else if (strncmp(p, "log", 3) == 0) {
p += 2;
tokens.emplace_back(Token::Type::Unary, "l", 5);
} else if (strncmp(p, "exp", 3) == 0) {
p += 2;
tokens.emplace_back(Token::Type::Unary, "e", 5);
} else if (strncmp(p, "sqrt", 4) == 0) {
p += 3;
tokens.emplace_back(Token::Type::Unary, "s", 5);
} else if (strncmp(p, "pow", 3) == 0) {
p += 2;
tokens.emplace_back(Token::Type::Unary, "p", 5);
} else if (*p >= 'a' && *p <= 'z') {
const auto * b = p;
while ((*p >= 'a' && *p <= 'z') || (*p == '_')) {
@@ -448,6 +469,27 @@ std::string calculate(const std::string & expr) {
}
stack.push_back(to_logic(rhs) == 0 ? "1" : "0");
break;
case 'i':
stack.push_back(to_string(std::stoi(rhs)));
break;
case 'r':
stack.push_back(to_string(std::round(std::stod(rhs))));
break;
case 'a':
stack.push_back(to_string(std::abs(std::stod(rhs))));
break;
case 'e':
stack.push_back(to_string(std::exp(std::stod(rhs))));
break;
case 'l':
stack.push_back(to_string(std::log(std::stod(rhs))));
break;
case 's':
stack.push_back(to_string(std::sqrt(std::stod(rhs))));
break;
case 'p':
stack.push_back(to_string(std::pow(std::stod(rhs), 2)));
break;
}
} break;
case Token::Type::Compare: {

View File

@@ -68,7 +68,8 @@ const char * const languages[] = {EMSESP_LOCALE_EN,
EMSESP_LOCALE_FR,
EMSESP_LOCALE_TR,
EMSESP_LOCALE_IT,
EMSESP_LOCALE_SK};
EMSESP_LOCALE_SK,
EMSESP_LOCALE_CZ};
#endif
static constexpr uint8_t NUM_LANGUAGES = sizeof(languages) / sizeof(const char *);

View File

@@ -343,9 +343,10 @@ void TxService::send_telegram(const QueuedTxTelegram & tx_telegram) {
message_p = 6;
} else {
// READ
telegram_raw[4] = telegram->message_data[0]; // #bytes to return, which we assume is the only byte in the message block
telegram_raw[5] = (telegram->type_id >> 8) - 1; // type, 1st byte, high-byte, subtract 0x100
telegram_raw[6] = telegram->type_id & 0xFF; // type, 2nd byte, low-byte
telegram_raw[4] =
telegram->message_data[0] > 25 ? 25 : telegram->message_data[0]; // #bytes to return, which we assume is the only byte in the message block
telegram_raw[5] = (telegram->type_id >> 8) - 1; // type, 1st byte, high-byte, subtract 0x100
telegram_raw[6] = telegram->type_id & 0xFF; // type, 2nd byte, low-byte
message_p = 7;
copy_data = false; // there are no more data values after the type_id when reading on EMS+
}
@@ -354,6 +355,11 @@ void TxService::send_telegram(const QueuedTxTelegram & tx_telegram) {
telegram_raw[2] = telegram->type_id;
telegram_raw[3] = telegram->offset;
message_p = 4;
if (telegram->operation == Telegram::Operation::TX_READ) {
telegram_raw[4] = telegram->message_data[0] > 27 ? 27 : telegram->message_data[0];
message_p = 5;
copy_data = false; // there are no more data value
}
}
if (copy_data) {

View File

@@ -50,7 +50,7 @@ static constexpr int8_t EMS_VALUE_INT8_NOTSET = 0x7F; // for signed 8-
static constexpr uint16_t EMS_VALUE_UINT16_NOTSET = 0x7D00; // 32000: for 2-byte unsigned shorts
static constexpr int16_t EMS_VALUE_INT16_NOTSET = 0x7D00; // 32000: for 2-byte signed shorts
static constexpr uint32_t EMS_VALUE_UINT24_NOTSET = 0x00FFFFFF; // for 3-byte longs
static constexpr uint32_t EMS_VALUE_UINT32_NOTSET = 0xFFFFFFFF; // for 4-byte longs
static constexpr uint32_t EMS_VALUE_UINT32_NOTSET = 0xFFFFFF00; // for 4-byte longs
static constexpr uint8_t EMS_MAX_TELEGRAM_LENGTH = 32; // max length of a complete EMS telegram
static constexpr uint8_t EMS_MAX_TELEGRAM_MESSAGE_LENGTH = 27; // max length of message block, assuming EMS1.0