fix(ui,cpn): Error in value conversion when loading LS data (#3026)
* Fix error in value conversion when loading logical switch data from YAML files (for 'Edge' and 'Timer' functions). * Remove debug print. * Fix handling of telemetry sensors in Companion.
This commit is contained in:
@@ -47,7 +47,7 @@ static int timerValue2lsw(uint32_t t)
|
|||||||
{
|
{
|
||||||
if (t < 20) {
|
if (t < 20) {
|
||||||
return t - 129;
|
return t - 129;
|
||||||
} else if (600) {
|
} else if (t < 600) {
|
||||||
return t / 5 - 113;
|
return t / 5 - 113;
|
||||||
} else {
|
} else {
|
||||||
return t / 10 - 53;
|
return t / 10 - 53;
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ std::string YamlRawSwitchEncode(const RawSwitch& rhs)
|
|||||||
|
|
||||||
case SWITCH_TYPE_SENSOR:
|
case SWITCH_TYPE_SENSOR:
|
||||||
sw_str += "T";
|
sw_str += "T";
|
||||||
sw_str += std::to_string(sval + 1);
|
sw_str += std::to_string(sval);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -131,7 +131,7 @@ RawSwitch YamlRawSwitchDecode(const std::string& sw_str)
|
|||||||
// starts at T1
|
// starts at T1
|
||||||
int sensor_idx = std::stoi(sw_str_tmp.substr(1, val_len - 1));
|
int sensor_idx = std::stoi(sw_str_tmp.substr(1, val_len - 1));
|
||||||
if ((sensor_idx > 0) && (sensor_idx <= CPN_MAX_SENSORS)) {
|
if ((sensor_idx > 0) && (sensor_idx <= CPN_MAX_SENSORS)) {
|
||||||
rhs = RawSwitch(SWITCH_TYPE_SENSOR, sensor_idx - 1);
|
rhs = RawSwitch(SWITCH_TYPE_SENSOR, sensor_idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (sw_str_tmp.substr(0, 4) == std::string("Trim")) {
|
} else if (sw_str_tmp.substr(0, 4) == std::string("Trim")) {
|
||||||
|
|||||||
@@ -1647,7 +1647,7 @@ static delayval_t timerValue2lsw(uint32_t t)
|
|||||||
{
|
{
|
||||||
if (t < 20) {
|
if (t < 20) {
|
||||||
return t - 129;
|
return t - 129;
|
||||||
} else if (600) {
|
} else if (t < 600) {
|
||||||
return t / 5 - 113;
|
return t / 5 - 113;
|
||||||
} else {
|
} else {
|
||||||
return t / 10 - 53;
|
return t / 10 - 53;
|
||||||
|
|||||||
Reference in New Issue
Block a user