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

Add inject_tlm to javascript api #438

Merged
merged 1 commit into from
Feb 1, 2023
Merged

Conversation

ryanmelt
Copy link
Member

@ryanmelt ryanmelt commented Feb 1, 2023

closes #436

@ryanmelt ryanmelt requested a review from jmthomas February 1, 2023 20:02
@codecov
Copy link

codecov bot commented Feb 1, 2023

Codecov Report

Base: 75.76% // Head: 74.73% // Decreases project coverage by -1.04% ⚠️

Coverage data is based on head (9298dc8) compared to base (33f9eeb).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #438      +/-   ##
==========================================
- Coverage   75.76%   74.73%   -1.04%     
==========================================
  Files         383      455      +72     
  Lines       25403    27689    +2286     
  Branches      592      592              
==========================================
+ Hits        19247    20692    +1445     
- Misses       6062     6903     +841     
  Partials       94       94              
Flag Coverage Δ
ruby-api 50.19% <ø> (+23.82%) ⬆️
ruby-backend 78.86% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
openc3/lib/openc3/api/tlm_api.rb 98.79% <100.00%> (+<0.01%) ⬆️
...pi/config/initializers/filter_parameter_logging.rb 100.00% <0.00%> (ø)
...mos-cmd-tlm-api/app/controllers/gems_controller.rb 13.33% <0.00%> (ø)
...cosmos-cmd-tlm-api/app/models/config_events_api.rb 50.00% <0.00%> (ø)
...-api/app/controllers/internal_health_controller.rb 83.33% <0.00%> (ø)
...-tlm-api/app/channels/application_cable/channel.rb 77.77% <0.00%> (ø)
...mos-cmd-tlm-api/app/controllers/time_controller.rb 50.00% <0.00%> (ø)
...md-tlm-api/app/channels/timeline_events_channel.rb 27.27% <0.00%> (ø)
...-cmd-tlm-api/app/controllers/widgets_controller.rb 75.00% <0.00%> (ø)
...md-tlm-api/app/channels/calendar_events_channel.rb 27.27% <0.00%> (ø)
... and 65 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@jmthomas jmthomas left a comment

Choose a reason for hiding this comment

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

Please fix the one existing typo

@@ -335,7 +335,7 @@ export class OpenC3Api {
}
Copy link
Member

Choose a reason for hiding this comment

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

Line 333 has a bug: Invalid data type ${packet_name} ... it should be ${value_type}.

Copy link
Member Author

Choose a reason for hiding this comment

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

This isn't a bug. packet_name is the second positional argument, and this case is for the two argument case.

@@ -335,7 +335,7 @@ export class OpenC3Api {
}
} else {
data = await this.exec('tlm', [target_name, packet_name, item_name], {
type: data_type,
type: value_type,
Copy link
Member

Choose a reason for hiding this comment

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

We're not at all consistent with the term data_type vs value_type throughout the code. I assume you're indicating you like value_type going forward.

Copy link
Member Author

Choose a reason for hiding this comment

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

data_type = :INT, :UINT, :FLOAT, :STRING, :BLOCK, :DERIVED
value_type = :RAW, :CONVERTED, :FORMATTED, :WITH_UNITS

@@ -118,7 +118,8 @@ def set_tlm(*args, type: :CONVERTED, scope: $openc3_scope, token: $openc3_token)
# @param type [Symbol] Telemetry type, :RAW, :CONVERTED (default), :FORMATTED, or :WITH_UNITS
def inject_tlm(target_name, packet_name, item_hash = nil, type: :CONVERTED, scope: $openc3_scope, token: $openc3_token)
authorize(permission: 'tlm_set', target_name: target_name, packet_name: packet_name, scope: scope, token: token)
unless CvtModel::VALUE_TYPES.include?(type.intern)
type = type.to_s.intern
unless CvtModel::VALUE_TYPES.include?(type)
Copy link
Member

Choose a reason for hiding this comment

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

Why this change? You can call intern on an existing symbol ... it's a noop.

Copy link
Member Author

Choose a reason for hiding this comment

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

handles nil and strings coming in (which is what was happening in inject_tlm)

@ryanmelt ryanmelt merged commit f8ccdc6 into main Feb 1, 2023
@ryanmelt ryanmelt deleted the add_inject_tlm_to_javascript_api branch February 1, 2023 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose inject_tlm to the javascript api allowed commands.
2 participants