Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[blockly] Support Quantity in more math blocks #2041

Merged
merged 7 commits into from
Oct 8, 2023

Conversation

stefan-hoehn
Copy link
Contributor

@stefan-hoehn stefan-hoehn commented Aug 25, 2023

fixes #2001

  • Adds Quantity support for more math blocks.
  • math_single had to be reimplemented
  • math_minmax was added
image

Note that there is a special case on min/max if the inputs are not of equal type an error will be shown to user:

image

In the special case of variables Blockly does its best to detect the right code to be generated for the min/max block:

  • both are variables -> then numerical input is expected
  • one of inputs is a variable: then blockly uses the type of the other non-var-block to base the generation on (either number or quantity comparison).
  • note that no type conversion of the inputs is done

Here are working examples that depict what is possible:

image

@stefan-hoehn stefan-hoehn requested a review from a team as a code owner August 25, 2023 21:54
@relativeci
Copy link

relativeci bot commented Aug 25, 2023

Job #1178: Bundle Size — 15.78MiB (+0.14%).

fa311d5(current) vs b7270d2 main#1158(baseline)

Warning

Bundle contains 16 duplicate packages – View duplicate packages

Warning

Bundle introduced 13 new packages: @jsep-plugin/regex, @jsep-plugin/arrow, @jsep-plugin/object and 10 more – View changed packages

Bundle metrics  Change 10 changes Regression 5 regressions Improvement 1 improvement
                 Current
Job #1178
     Baseline
Job #1158
Regression  Initial JS 1.85MiB(+10.75%) 1.67MiB
Regression  Initial CSS 608.95KiB(+0.01%) 608.89KiB
Change  Cache Invalidation 93.81% 93.95%
Change  Chunks 217(-0.91%) 219
Change  Assets 683(-0.87%) 689
Change  Modules 2982(+75.41%) 1700
Regression  Duplicate Modules 170(+88.89%) 90
Improvement  Duplicate Code 1.62%(-16.92%) 1.95%
Regression  Packages 152(+10.14%) 138
Regression  Duplicate Packages 16(+6.67%) 15
Bundle size by type  Change 3 changes Regression 3 regressions
                 Current
Job #1178
     Baseline
Job #1158
Regression  JS 9.27MiB (+0.18%) 9.25MiB
Regression  Other 4.73MiB (+0.11%) 4.73MiB
Regression  CSS 859.97KiB (+0.06%) 859.49KiB
Not changed  Fonts 526.1KiB 526.1KiB
Not changed  Media 295.6KiB 295.6KiB
Not changed  IMG 140.74KiB 140.74KiB
Not changed  HTML 1.23KiB 1.23KiB

View job #1178 reportView stefan-hoehn:blockly_quantity_ma... branch activity

@florian-h05 florian-h05 changed the title [blockly] support Quantity in more math blocks [blockly] Support Quantity in more math blocks Sep 23, 2023
@florian-h05 florian-h05 removed the request for review from ghys September 23, 2023 16:23
@florian-h05 florian-h05 added enhancement New feature or request main ui Main UI labels Oct 3, 2023
Copy link
Contributor

@florian-h05 florian-h05 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

I have fixed two bugs:

  • the lead type was not correctly determined due to a typo
  • the lead type did not default to Number if both input were vars, which made the block have not set an output type

stefan-hoehn and others added 7 commits October 8, 2023 15:05
Signed-off-by: Stefan Höhn <mail@stefanhoehn.com>
Signed-off-by: Stefan Höhn <mail@stefanhoehn.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Stefan Höhn <mail@stefanhoehn.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Stefan Höhn <mail@stefanhoehn.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
@florian-h05 florian-h05 merged commit e2ebc1d into openhab:main Oct 8, 2023
5 checks passed
@florian-h05 florian-h05 deleted the blockly_quantity_math branch October 8, 2023 19:16
@florian-h05 florian-h05 added this to the 4.1 milestone Oct 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request main ui Main UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[blockly] Add common Math operations support for Quantity
2 participants