-
Notifications
You must be signed in to change notification settings - Fork 42
override_tlm sets all by default, works across processes #343
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
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -161,8 +161,8 @@ def inject_tlm(target_name, packet_name, item_hash = nil, type: :CONVERTED, scop | |
# @param args The args must either be a string followed by a value or | ||
# three strings followed by a value (see the calling style in the | ||
# description). | ||
# @param type [Symbol] Telemetry type, :RAW, :CONVERTED (default), :FORMATTED, or :WITH_UNITS | ||
def override_tlm(*args, type: :CONVERTED, scope: $openc3_scope, token: $openc3_token) | ||
# @param type [Symbol] Telemetry type, :ALL (default), :RAW, :CONVERTED, :FORMATTED, :WITH_UNITS | ||
def override_tlm(*args, type: :ALL, scope: $openc3_scope, token: $openc3_token) | ||
target_name, packet_name, item_name, value = set_tlm_process_args(args, __method__, scope: scope) | ||
authorize(permission: 'tlm_set', target_name: target_name, packet_name: packet_name, scope: scope, token: token) | ||
CvtModel.override(target_name, packet_name, item_name, value, type: type.intern, scope: scope) | ||
|
@@ -179,7 +179,7 @@ def override_tlm(*args, type: :CONVERTED, scope: $openc3_scope, token: $openc3_t | |
# | ||
# @param args The args must either be a string or three strings | ||
# (see the calling style in the description). | ||
# @param type [Symbol] Telemetry type, :RAW, :CONVERTED (default), :FORMATTED, or :WITH_UNITS | ||
# @param type [Symbol] Telemetry type, :ALL (default), :RAW, :CONVERTED, :FORMATTED, :WITH_UNITS | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All actually already was the default for normalize but this comment was wrong |
||
# Also takes :ALL which means to normalize all telemetry types | ||
def normalize_tlm(*args, type: :ALL, scope: $openc3_scope, token: $openc3_token) | ||
target_name, packet_name, item_name = tlm_process_args(args, __method__, scope: scope) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 2 additions & 61 deletions
63
openc3/lib/openc3/interfaces/protocols/override_protocol.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,4 @@ | ||
# encoding: ascii-8bit | ||
|
||
# Copyright 2022 Ball Aerospace & Technologies Corp. | ||
# All Rights Reserved. | ||
# | ||
# This program is free software; you can modify and/or redistribute it | ||
# under the terms of the GNU Affero General Public License | ||
# as published by the Free Software Foundation; version 3 with | ||
# attribution addendums as found in the LICENSE.txt | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
|
||
# Modified by OpenC3, Inc. | ||
# All changes Copyright 2022, OpenC3, Inc. | ||
# All Rights Reserved | ||
# | ||
# This file may also be used under the terms of a commercial license | ||
# if purchased from OpenC3, Inc. | ||
|
||
require 'openc3/interfaces/protocols/protocol' | ||
|
||
module OpenC3 | ||
# Protocol which permanently overrides an item value such that reading the | ||
# item returns the overriden value. Methods are prefixed with underscores | ||
# so the API can include the original name which calls out to these | ||
# methods. Clearing the override requires calling normalize_tlm. | ||
class OverrideProtocol < Protocol | ||
# @param allow_empty_data [true/false/nil] See Protocol#initialize | ||
def initialize(allow_empty_data = nil) | ||
super(allow_empty_data) | ||
end | ||
|
||
# Called to perform modifications on a read packet before it is given to the user | ||
# | ||
# @param packet [Packet] Original packet | ||
# @return [Packet] Potentially modified packet | ||
def read_packet(packet) | ||
if @interface.override_tlm && !@interface.override_tlm.empty? | ||
# Need to make sure packet is identified and defined | ||
target_names = nil | ||
target_names = @interface.tlm_target_names if @interface | ||
identified_packet = System.telemetry.identify_and_define_packet(packet, target_names) | ||
if identified_packet | ||
packet = identified_packet | ||
packets = @interface.override_tlm[packet.target_name] | ||
if packets | ||
items = packets[packet.packet_name] | ||
if items | ||
items.each do |item_name, value| | ||
# This should be safe because we check at the API level it exists | ||
packet.write(item_name, value[0], value[1]) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
return packet | ||
end | ||
end | ||
end | ||
# This class is deprecated and this file exists only to satisfy existing code requiring it | ||
# TODO: Remove this in a future release |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an API change we should note but I think it makes more sense. Especially because PacketViewer shows the WITH_UNITS by default and a call to override_tlm now changes the value in PacketViewer (least surprise).