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

Modular decom #134

Merged
merged 5 commits into from
Sep 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ openc3/spec/install/outputs
openc3/spec/examples.txt
coverage/
profile/
plugins/DEFAULT/

# local env files
.env.local
Expand Down Expand Up @@ -48,4 +49,4 @@ yarn-error.log*
# Ignore node modules
node_modules

typescript
typescript
23 changes: 23 additions & 0 deletions openc3-init/plugins/packages/openc3-accessor-test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
tools/*
.DS_Store
node_modules
/dist

# local env files
.env.local
.env.*.local

# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
727 changes: 727 additions & 0 deletions openc3-init/plugins/packages/openc3-accessor-test/LICENSE.txt

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions openc3-init/plugins/packages/openc3-accessor-test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## OpenC3 Accessor Test Plugin

[Documentation](https://openc3.com)

This plugin is used to provide examples of using different accessors

## Getting Started

1. At the OpenC3 Admin - Plugins, upload the openc3-accessor-test.gem file

## Contributing

We encourage you to contribute to OpenC3!

Contributing is easy.

1. Fork the project
2. Create a feature branch
3. Make your changes
4. Submit a pull request

Before any contributions can be incorporated we do require all contributors to agree to a Contributor License Agreement

This protects both you and us and you retain full rights to any code you write.

## License

This OpenC3 plugin is released under the AGPLv3.0 with a few addendums. See [LICENSE.txt](LICENSE.txt)
36 changes: 36 additions & 0 deletions openc3-init/plugins/packages/openc3-accessor-test/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# encoding: ascii-8bit

# Copyright 2022 OpenC3, Inc.
# 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.

PLUGIN_NAME = Dir['*.gemspec'][0].split('.')[0..-2].join('.')

task :require_version do
if ENV['VERSION']
if ENV['VERSION'] =~ /-/
# Add Timestamp to prerelease versions
ENV['VERSION'] = ENV['VERSION'] + "." + Time.now.utc.strftime("%Y%m%d%H%M%S")
end
else
puts "VERSION is required: rake <task> VERSION=X.X.X"
exit 1
end
end

task :build => [:require_version] do
_, platform, *_ = RUBY_PLATFORM.split("-")
if platform == 'mswin32' or platform == 'mingw32'
puts "Warning: Building gem on Windows will lose file permissions"
end
system("gem build #{PLUGIN_NAME}")
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# encoding: ascii-8bit

# Copyright 2022 OpenC3, Inc.
# 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.

spec = Gem::Specification.new do |s|
s.name = 'openc3-accessor-test'
s.summary = 'OpenC3 Accessor Example Plugin'
s.description = <<-EOF
This plugin is used to provide examples of using different accessors
EOF
s.authors = ['Ryan Melton', 'Jason Thomas']
s.email = ['ryan@openc3.com', 'jason@openc3.com']
s.homepage = 'https://github.com/OpenC3/openc3'

s.platform = Gem::Platform::RUBY

if ENV['VERSION']
s.version = ENV['VERSION'].dup
else
time = Time.now.strftime("%Y%m%d%H%M%S")
s.version = '0.0.0' + ".#{time}"
end
s.licenses = ['AGPL-3.0-only', 'Nonstandard']

s.files = Dir.glob("{targets,lib,procedures,tools,microservices}/**/*") + %w(Rakefile LICENSE.txt README.md plugin.txt)
end
10 changes: 10 additions & 0 deletions openc3-init/plugins/packages/openc3-accessor-test/plugin.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
VARIABLE access_target_name ACCESS
VARIABLE log_retain_time 172800
VARIABLE reduced_log_retain_time 2592000

TARGET ACCESS <%= access_target_name %>
LOG_RETAIN_TIME <%= log_retain_time %>
REDUCED_LOG_RETAIN_TIME <%= reduced_log_retain_time %>

INTERFACE <%= access_target_name %> simulated_target_interface.rb sim_access.rb
MAP_TARGET <%= access_target_name %>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
�gid_itemeitem1edmore�eitem2 eitem3�@ �Q�eitem4gExampleeitem5�
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'cbor'
data = {"id_item":2, "item1":101, "more": { "item2":12, "item3":3.14, "item4":"Example", "item5":[4, 3, 2, 1] } }
File.open("_cbor_template.bin", 'wb') do |file|
file.write(data.to_cbor)
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
COMMAND <%= target_name %> JSONCMD BIG_ENDIAN "JSON Accessor Command"
ACCESSOR JsonAccessor
TEMPLATE '{"id_item":1, "item1":101, "more": { "item2":12, "item3":3.14, "item4":"Example", "item5":[4, 3, 2, 1] } }'
APPEND_ID_PARAMETER ID_ITEM 32 INT 1 1 1 "Int Item"
KEY $.id_item
APPEND_PARAMETER ITEM1 16 UINT MIN MAX 101 "Int Item 2"
KEY $.item1
UNITS CELCIUS C
APPEND_PARAMETER ITEM2 16 UINT MIN MAX 12 "Int Item 3"
KEY $.more.item2
FORMAT_STRING "0x%X"
APPEND_PARAMETER ITEM3 64 FLOAT MIN MAX 3.14 "Float Item"
KEY $.more.item3
APPEND_PARAMETER ITEM4 128 STRING "Example" "String Item"
KEY $.more.item4
APPEND_ARRAY_PARAMETER ITEM5 8 UINT 0 "Array Item"
KEY $.more.item5

COMMAND <%= target_name %> CBORCMD BIG_ENDIAN "CBOR Accessor Command"
ACCESSOR CborAccessor
TEMPLATE_FILE _cbor_template.bin
APPEND_ID_PARAMETER ID_ITEM 32 INT 2 2 2 "Int Item"
KEY $.id_item
APPEND_PARAMETER ITEM1 16 UINT MIN MAX 101 "Int Item 2"
KEY $.item1
UNITS CELCIUS C
APPEND_PARAMETER ITEM2 16 UINT MIN MAX 12 "Int Item 3"
KEY $.more.item2
FORMAT_STRING "0x%X"
APPEND_PARAMETER ITEM3 64 FLOAT MIN MAX 3.14 "Float Item"
KEY $.more.item3
APPEND_PARAMETER ITEM4 128 STRING "Example" "String Item"
KEY $.more.item4
APPEND_ARRAY_PARAMETER ITEM5 8 UINT 0 "Array Item"
KEY $.more.item5

COMMAND <%= target_name %> XMLCMD BIG_ENDIAN "XML Accessor Command"
ACCESSOR XmlAccessor
TEMPLATE '<html><head><script src="3"></script><noscript>101</noscript></head><body><img src="12"/><div><ul><li>3.14</li><li>Example</li></ul></div><div></div></body></html>'
APPEND_ID_PARAMETER ID_ITEM 32 INT 3 3 3 "Int Item"
KEY "/html/head/script/@src"
APPEND_PARAMETER ITEM1 16 UINT MIN MAX 101 "Int Item 2"
KEY "/html/head/noscript/text()"
UNITS CELCIUS C
APPEND_PARAMETER ITEM2 16 UINT MIN MAX 12 "Int Item 3"
KEY "/html/body/img/@src"
FORMAT_STRING "0x%X"
APPEND_PARAMETER ITEM3 64 FLOAT MIN MAX 3.14 "Float Item"
KEY "/html/body/div/ul/li[1]/text()"
APPEND_PARAMETER ITEM4 128 STRING "Example" "String Item"
KEY "/html/body/div/ul/li[2]/text()"

COMMAND <%= target_name %> HTMLCMD BIG_ENDIAN "HTML Accessor Command"
ACCESSOR HtmlAccessor
TEMPLATE '<!DOCTYPE html><html lang="en"><head><title>4</title><script src="101"></script></head><body><noscript>12</noscript><img src="3.14" alt="An Image"/><p>Example</p><ul><li>1</li><li>3.14</li></ul></body></html>'
APPEND_ID_PARAMETER ID_ITEM 32 INT 4 4 4 "Int Item"
KEY "/html/head/title/text()"
APPEND_PARAMETER ITEM1 16 UINT MIN MAX 101 "Int Item 2"
KEY "/html/head/script/@src"
UNITS CELCIUS C
APPEND_PARAMETER ITEM2 16 UINT MIN MAX 12 "Int Item 3"
KEY "/html/body/noscript/text()"
FORMAT_STRING "0x%X"
APPEND_PARAMETER ITEM3 64 FLOAT MIN MAX 3.14 "Float Item"
KEY "/html/body/img/@src"
APPEND_PARAMETER ITEM4 128 STRING "Example" "String Item"
KEY "/html/body/p/text()"
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
TELEMETRY <%= target_name %> JSONTLM BIG_ENDIAN "JSON Accessor Telemetry"
ACCESSOR JsonAccessor
# Template is not required for telemetry, but is useful for simulation
TEMPLATE '{"id_item":1, "item1":101, "more": { "item2":12, "item3":3.14, "item4":"Example", "item5":[4, 3, 2, 1] } }'
APPEND_ID_ITEM ID_ITEM 32 INT 1 "Int Item"
KEY $.id_item
APPEND_ITEM ITEM1 16 UINT "Int Item 2"
KEY $.item1
GENERIC_READ_CONVERSION_START UINT 16
value * 2
GENERIC_READ_CONVERSION_END
UNITS CELCIUS C
APPEND_ITEM ITEM2 16 UINT "Int Item 3"
KEY $.more.item2
FORMAT_STRING "0x%X"
APPEND_ITEM ITEM3 64 FLOAT "Float Item"
KEY $.more.item3
APPEND_ITEM ITEM4 128 STRING "String Item"
KEY $.more.item4
APPEND_ARRAY_ITEM ITEM5 8 UINT 0 "Array Item"
KEY $.more.item5

TELEMETRY <%= target_name %> CBORTLM BIG_ENDIAN "CBOR Accessor Telemetry"
ACCESSOR CborAccessor
# Template is not required for telemetry, but is useful for simulation
TEMPLATE_FILE _cbor_template.bin
APPEND_ID_ITEM ID_ITEM 32 INT 2 "Int Item"
KEY $.id_item
APPEND_ITEM ITEM1 16 UINT "Int Item 2"
KEY $.item1
GENERIC_READ_CONVERSION_START UINT 16
value * 2
GENERIC_READ_CONVERSION_END
UNITS CELCIUS C
APPEND_ITEM ITEM2 16 UINT "Int Item 3"
KEY $.more.item2
FORMAT_STRING "0x%X"
APPEND_ITEM ITEM3 64 FLOAT "Float Item"
KEY $.more.item3
APPEND_ITEM ITEM4 128 STRING "String Item"
KEY $.more.item4
APPEND_ARRAY_ITEM ITEM5 8 UINT 0 "Array Item"
KEY $.more.item5

TELEMETRY <%= target_name %> XMLTLM BIG_ENDIAN "XML Accessor Telemetry"
ACCESSOR XmlAccessor
# Template is not required for telemetry, but is useful for simulation
TEMPLATE '<html><head><script src="3"></script><noscript>101</noscript></head><body><img src="12"/><div><ul><li>3.14</li><li>Example</li></ul></div><div></div></body></html>'
APPEND_ID_ITEM ID_ITEM 32 INT 3 "Int Item"
KEY "/html/head/script/@src"
APPEND_ITEM ITEM1 16 UINT "Int Item 2"
KEY "/html/head/noscript/text()"
GENERIC_READ_CONVERSION_START UINT 16
value * 2
GENERIC_READ_CONVERSION_END
UNITS CELCIUS C
APPEND_ITEM ITEM2 16 UINT "Int Item 3"
KEY "/html/body/img/@src"
FORMAT_STRING "0x%X"
APPEND_ITEM ITEM3 64 FLOAT "Float Item"
KEY "/html/body/div/ul/li[1]/text()"
APPEND_ITEM ITEM4 128 STRING "String Item"
KEY "/html/body/div/ul/li[2]/text()"

TELEMETRY <%= target_name %> HTMLTLM BIG_ENDIAN "HTML Accessor Telemetry"
ACCESSOR HtmlAccessor
# Template is not required for telemetry, but is useful for simulation
TEMPLATE '<!DOCTYPE html><html lang="en"><head><title>4</title><script src="101"></script></head><body><noscript>12</noscript><img src="3.14" alt="An Image"/><p>Example</p><ul><li>1</li><li>3.14</li></ul></body></html>'
APPEND_ID_ITEM ID_ITEM 32 INT 4 "Int Item"
KEY "/html/head/title/text()"
APPEND_ITEM ITEM1 16 UINT "Int Item 2"
KEY "/html/head/script/@src"
GENERIC_READ_CONVERSION_START UINT 16
value * 2
GENERIC_READ_CONVERSION_END
UNITS CELCIUS C
APPEND_ITEM ITEM2 16 UINT "Int Item 3"
KEY "/html/body/noscript/text()"
FORMAT_STRING "0x%X"
APPEND_ITEM ITEM3 64 FLOAT "Float Item"
KEY "/html/body/img/@src"
APPEND_ITEM ITEM4 128 STRING "String Item"
KEY "/html/body/p/text()"
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# encoding: ascii-8bit

# Copyright 2022 OpenC3, Inc.
# 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.

# Provides a demonstration of accessors

require 'openc3'

module OpenC3
class SimAccess < SimulatedTarget
def set_rates
set_rate('JSONTLM', 100)
set_rate('CBORTLM', 100)
set_rate('XMLTLM', 100)
set_rate('HTMLTLM', 100)
end

def tick_period_seconds
return 1 # Override this method to optimize
end

def tick_increment
return 100 # Override this method to optimize
end

def write(packet)
name = packet.packet_name.upcase

json_packet = @tlm_packets['JSONTLM']
cbor_packet = @tlm_packets['CBORTLM']
xml_packet = @tlm_packets['XMLTLM']
html_packet = @tlm_packets['HTMLTLM']

case name
when 'JSONCMD'
json_packet.buffer = packet.buffer
when 'CBORCMD'
cbor_packet.buffer = packet.buffer
when 'XMLCMD'
xml_packet.buffer = packet.buffer
when 'HTMLCMD'
html_packet.buffer = packet.buffer
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
IGNORE_PARAMETER ID_ITEM

CMD_UNIQUE_ID_MODE
TLM_UNIQUE_ID_MODE
Copy link
Member

Choose a reason for hiding this comment

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

Are these required for the new accessor modes? Or if you have the exact same ID_ITEM KEY then no?

Copy link
Member Author

Choose a reason for hiding this comment

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

They are not required if all the packets have the same Accessor, ID_ITEMS, and keys

Loading