openc3 5.4.2 → 5.5.0.pre.beta0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of openc3 might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile +5 -10
- data/bin/openc3cli +8 -1
- data/data/config/_interfaces.yaml +6 -71
- data/data/config/interface_modifiers.yaml +0 -23
- data/data/config/microservice.yaml +8 -0
- data/data/config/target.yaml +1 -0
- data/data/config/widgets.yaml +6 -23
- data/lib/openc3/core_ext/string.rb +2 -2
- data/lib/openc3/io/json_rpc.rb +6 -2
- data/lib/openc3/microservices/plugin_microservice.rb +10 -1
- data/lib/openc3/models/cvt_model.rb +10 -8
- data/lib/openc3/models/metadata_model.rb +1 -1
- data/lib/openc3/models/microservice_model.rb +14 -2
- data/lib/openc3/models/model.rb +3 -11
- data/lib/openc3/models/note_model.rb +1 -1
- data/lib/openc3/models/timeline_model.rb +2 -3
- data/lib/openc3/models/traefik_model.rb +47 -0
- data/lib/openc3/models/trigger_group_model.rb +2 -3
- data/lib/openc3/script/script.rb +10 -0
- data/lib/openc3/script/storage.rb +4 -3
- data/lib/openc3/script/web_socket_api.rb +423 -0
- data/lib/openc3/streams/tcpip_client_stream.rb +1 -1
- data/lib/openc3/streams/web_socket_client_stream.rb +99 -0
- data/lib/openc3/top_level.rb +1 -16
- data/lib/openc3/utilities/authorization.rb +4 -2
- data/lib/openc3/utilities/aws_bucket.rb +4 -0
- data/lib/openc3/utilities/bucket.rb +4 -0
- data/lib/openc3/utilities/process_manager.rb +6 -5
- data/lib/openc3/version.rb +7 -7
- data/lib/openc3.rb +3 -0
- metadata +35 -6
- data/data/config/cmd_tlm_server.yaml +0 -136
- data/lib/openc3/tools/cmd_tlm_server/cmd_tlm_server_config.rb +0 -323
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openc3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.5.0.pre.beta0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Melton
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-02-
|
12
|
+
date: 2023-02-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -445,6 +445,34 @@ dependencies:
|
|
445
445
|
- - "~>"
|
446
446
|
- !ruby/object:Gem::Version
|
447
447
|
version: '0.3'
|
448
|
+
- !ruby/object:Gem::Dependency
|
449
|
+
name: websocket
|
450
|
+
requirement: !ruby/object:Gem::Requirement
|
451
|
+
requirements:
|
452
|
+
- - ">="
|
453
|
+
- !ruby/object:Gem::Version
|
454
|
+
version: '0'
|
455
|
+
type: :runtime
|
456
|
+
prerelease: false
|
457
|
+
version_requirements: !ruby/object:Gem::Requirement
|
458
|
+
requirements:
|
459
|
+
- - ">="
|
460
|
+
- !ruby/object:Gem::Version
|
461
|
+
version: '0'
|
462
|
+
- !ruby/object:Gem::Dependency
|
463
|
+
name: websocket-native
|
464
|
+
requirement: !ruby/object:Gem::Requirement
|
465
|
+
requirements:
|
466
|
+
- - ">="
|
467
|
+
- !ruby/object:Gem::Version
|
468
|
+
version: '0'
|
469
|
+
type: :runtime
|
470
|
+
prerelease: false
|
471
|
+
version_requirements: !ruby/object:Gem::Requirement
|
472
|
+
requirements:
|
473
|
+
- - ">="
|
474
|
+
- !ruby/object:Gem::Version
|
475
|
+
version: '0'
|
448
476
|
- !ruby/object:Gem::Dependency
|
449
477
|
name: dead_end
|
450
478
|
requirement: !ruby/object:Gem::Requirement
|
@@ -669,7 +697,6 @@ files:
|
|
669
697
|
- data/config/_interfaces.yaml
|
670
698
|
- data/config/_items.yaml
|
671
699
|
- data/config/_params.yaml
|
672
|
-
- data/config/cmd_tlm_server.yaml
|
673
700
|
- data/config/command.yaml
|
674
701
|
- data/config/command_modifiers.yaml
|
675
702
|
- data/config/command_telemetry.yaml
|
@@ -872,6 +899,7 @@ files:
|
|
872
899
|
- lib/openc3/models/timeline_model.rb
|
873
900
|
- lib/openc3/models/tool_config_model.rb
|
874
901
|
- lib/openc3/models/tool_model.rb
|
902
|
+
- lib/openc3/models/traefik_model.rb
|
875
903
|
- lib/openc3/models/trigger_group_model.rb
|
876
904
|
- lib/openc3/models/trigger_model.rb
|
877
905
|
- lib/openc3/models/widget_model.rb
|
@@ -916,16 +944,17 @@ files:
|
|
916
944
|
- lib/openc3/script/suite_results.rb
|
917
945
|
- lib/openc3/script/suite_runner.rb
|
918
946
|
- lib/openc3/script/telemetry.rb
|
947
|
+
- lib/openc3/script/web_socket_api.rb
|
919
948
|
- lib/openc3/streams/serial_stream.rb
|
920
949
|
- lib/openc3/streams/stream.rb
|
921
950
|
- lib/openc3/streams/tcpip_client_stream.rb
|
922
951
|
- lib/openc3/streams/tcpip_socket_stream.rb
|
952
|
+
- lib/openc3/streams/web_socket_client_stream.rb
|
923
953
|
- lib/openc3/system.rb
|
924
954
|
- lib/openc3/system/system.rb
|
925
955
|
- lib/openc3/system/system_config.rb
|
926
956
|
- lib/openc3/system/target.rb
|
927
957
|
- lib/openc3/tools/cmd_tlm_server/api.rb
|
928
|
-
- lib/openc3/tools/cmd_tlm_server/cmd_tlm_server_config.rb
|
929
958
|
- lib/openc3/tools/cmd_tlm_server/interface_thread.rb
|
930
959
|
- lib/openc3/tools/table_manager/table.rb
|
931
960
|
- lib/openc3/tools/table_manager/table_config.rb
|
@@ -1012,9 +1041,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
1012
1041
|
version: '2.7'
|
1013
1042
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
1014
1043
|
requirements:
|
1015
|
-
- - "
|
1044
|
+
- - ">"
|
1016
1045
|
- !ruby/object:Gem::Version
|
1017
|
-
version:
|
1046
|
+
version: 1.3.1
|
1018
1047
|
requirements: []
|
1019
1048
|
rubygems_version: 3.3.14
|
1020
1049
|
signing_key:
|
@@ -1,136 +0,0 @@
|
|
1
|
-
---
|
2
|
-
TITLE:
|
3
|
-
summary: Sets the Command and Telemetry Server window title
|
4
|
-
parameters:
|
5
|
-
- name: Text
|
6
|
-
required: true
|
7
|
-
description: Text to put in the title of the Command and Telemetry Server window
|
8
|
-
values: .+
|
9
|
-
PACKET_LOG_WRITER:
|
10
|
-
summary: Declare a packet log writer
|
11
|
-
description: Packet log writer is used to declare a packet log writer class and
|
12
|
-
give it a name which can be referenced by an interface. This is required if you
|
13
|
-
want interfaces to have their own dedicated log writers or want to combine
|
14
|
-
various interfaces into a single log file. By default, OpenC3 logs all data
|
15
|
-
on all interfaces into a single command log and a single telemetry log.
|
16
|
-
This keyword can also be used if you want to declare a different log file class
|
17
|
-
to create log files.
|
18
|
-
warning: You should NOT override the default without consulting a OpenC3 expert
|
19
|
-
as this may break the ability to successfully read and write log files.
|
20
|
-
example: |
|
21
|
-
PACKET_LOG_WRITER DEFAULT packet_log_writer.rb # Default
|
22
|
-
# The default logger filename will be <DATE>_openc3tlm.bin and will create a new log every 1MB
|
23
|
-
PACKET_LOG_WRITER DEFAULT packet_log_writer.rb openc3 true nil 1000000
|
24
|
-
# Create a logger named OPENC3_LOG which creates a new log every 5 min (600s)
|
25
|
-
PACKET_LOG_WRITER OPENC3_LOG packet_log_writer.rb openc3 true 600
|
26
|
-
parameters:
|
27
|
-
- name: Log Writer Name
|
28
|
-
required: true
|
29
|
-
description: The name of the log writer as reference by other cmd_tlm_server keywords.
|
30
|
-
This name also appears in the Logging tab on the Command and Telemetry Server.
|
31
|
-
values: .+
|
32
|
-
- name: Filename
|
33
|
-
required: true
|
34
|
-
description: Ruby file to use when instantiating a new log writer
|
35
|
-
values: '.+\.rb'
|
36
|
-
- name: Parameters
|
37
|
-
required: false
|
38
|
-
description: Optional parameters to pass to the log writer class when instantiating it.
|
39
|
-
AUTO_INTERFACE_TARGETS:
|
40
|
-
summary: Automatically use each target's cmd_tlm_server.txt file to define the interface
|
41
|
-
description: Look for a cmd_tlm_server.txt file at the top level
|
42
|
-
of each target directory and use this file to configure the interface for that target.
|
43
|
-
This is a good way of keeping the knowledge of how to interface to a target
|
44
|
-
within that target. However, if you use substitute target names (by using DECLARE_TARGET)
|
45
|
-
or use different IP addresses then this will not work and you'll have to use the
|
46
|
-
INTERFACE_TARGET or INTERFACE keyword.
|
47
|
-
INTERFACE_TARGET:
|
48
|
-
summary: Load the specified target's cmd_tlm_server.txt configuration file
|
49
|
-
example: |
|
50
|
-
INTERFACE_TARGET OPENC3 # Look in the OPENC3 target directory for cmd_tlm_server.txt
|
51
|
-
INTERFACE_TARGET OPENC3 config.txt # Look in the OPENC3 target directory for config.txt
|
52
|
-
parameters:
|
53
|
-
- name: Target Name
|
54
|
-
required: true
|
55
|
-
description: Name of the target
|
56
|
-
values: .+
|
57
|
-
- name: Configuration File
|
58
|
-
required: false
|
59
|
-
description: Configuration filename which contains the interface configuration.
|
60
|
-
Defaults to 'cmd_tlm_server.txt'.
|
61
|
-
values: .+
|
62
|
-
INTERFACE:
|
63
|
-
modifiers:
|
64
|
-
<%= MetaConfigParser.load('interface_modifiers.yaml').to_meta_config_yaml(4) %>
|
65
|
-
summary: Defines a connection to a physical target
|
66
|
-
description: Interfaces are what OpenC3 uses to talk to a particular piece
|
67
|
-
of hardware. Interfaces require a Ruby file which implements all the interface
|
68
|
-
methods necessary to talk to the hardware. OpenC3 defines many built in interfaces
|
69
|
-
or you can define your own as long as it implements the interface protocol.
|
70
|
-
parameters:
|
71
|
-
- name: Interface Name
|
72
|
-
required: true
|
73
|
-
description: Name of the interface. This name will appear in the
|
74
|
-
Interfaces tab of the Server and is also referenced by other keywords.
|
75
|
-
The OpenC3 convention is to name interfaces after their targets with
|
76
|
-
'_INT' appended to the name, e.g. INST_INT for the INST target.
|
77
|
-
values: \D\S*
|
78
|
-
- name: Filename
|
79
|
-
required: true
|
80
|
-
description: Ruby file to use when instantiating the interface.
|
81
|
-
values:
|
82
|
-
<%= MetaConfigParser.load('_interfaces.yaml').to_meta_config_yaml(8) %>
|
83
|
-
documentation: Additional parameters are required. Please see the [Interfaces](/docs/v5/interfaces)
|
84
|
-
documentation for more details.
|
85
|
-
ROUTER:
|
86
|
-
modifiers:
|
87
|
-
ROUTE:
|
88
|
-
summary: Map an interface to a router
|
89
|
-
description: Once an interface has been mapped to a router, all its received telemetry
|
90
|
-
will be sent out through the router.
|
91
|
-
parameters:
|
92
|
-
- name: Interface
|
93
|
-
required: true
|
94
|
-
description: Name of the interface
|
95
|
-
values: .+
|
96
|
-
<%= MetaConfigParser.load('interface_modifiers.yaml').to_meta_config_yaml(4) %>
|
97
|
-
summary: Create an interface which reverses cmd/tlm data
|
98
|
-
description: Router creates an interface which receives command packets from
|
99
|
-
their remote targets and send them out their interfaces. They receive telemetry
|
100
|
-
packets from their interfaces and send them to their remote targets. This allows
|
101
|
-
routers to be intermediaries between an external client and an actual device.
|
102
|
-
parameters:
|
103
|
-
- name: Name
|
104
|
-
required: true
|
105
|
-
description: Name of the router
|
106
|
-
values: .+
|
107
|
-
- name: Filename
|
108
|
-
required: true
|
109
|
-
description: Ruby file to use when instantiating the interface.
|
110
|
-
values:
|
111
|
-
<%= MetaConfigParser.load('_interfaces.yaml').to_meta_config_yaml(8) %>
|
112
|
-
documentation: Additional parameters are required. Please see the [Interfaces](/docs/v5/interfaces)
|
113
|
-
documentation for more details.
|
114
|
-
COLLECT_METADATA:
|
115
|
-
summary: Prompts the user for meta data when starting the Command and Telemetry Server
|
116
|
-
BACKGROUND_TASK:
|
117
|
-
modifiers:
|
118
|
-
STOPPED:
|
119
|
-
summary: Indicate the background task should not be automatically started
|
120
|
-
summary: Create a background task in the Command and Telemetry Server
|
121
|
-
description: The Server instantiates the class which must inherit from BackgroundTask
|
122
|
-
and then calls the call() method which the class must implement. The call() method
|
123
|
-
is only called once so if your background task is supposed to live on while the
|
124
|
-
Server is running, you must implement your code in a loop with a sleep to not
|
125
|
-
use all the CPU.
|
126
|
-
example: BACKGROUND_TASK example_background_task.rb
|
127
|
-
parameters:
|
128
|
-
- name: Filename
|
129
|
-
required: true
|
130
|
-
description: Ruby file which contains the background task implementation.
|
131
|
-
Must inherit from BackgroundTask and implement the call method.
|
132
|
-
values: '.+\.rb'
|
133
|
-
- name: Optional Arguments
|
134
|
-
required: false
|
135
|
-
description: Optional arguments to the background task constructor
|
136
|
-
values: .+
|
@@ -1,323 +0,0 @@
|
|
1
|
-
# encoding: ascii-8bit
|
2
|
-
|
3
|
-
# Copyright 2022 Ball Aerospace & Technologies Corp.
|
4
|
-
# All Rights Reserved.
|
5
|
-
#
|
6
|
-
# This program is free software; you can modify and/or redistribute it
|
7
|
-
# under the terms of the GNU Affero General Public License
|
8
|
-
# as published by the Free Software Foundation; version 3 with
|
9
|
-
# attribution addendums as found in the LICENSE.txt
|
10
|
-
#
|
11
|
-
# This program is distributed in the hope that it will be useful,
|
12
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
-
# GNU Affero General Public License for more details.
|
15
|
-
|
16
|
-
# Modified by OpenC3, Inc.
|
17
|
-
# All changes Copyright 2022, OpenC3, Inc.
|
18
|
-
# All Rights Reserved
|
19
|
-
#
|
20
|
-
# This file may also be used under the terms of a commercial license
|
21
|
-
# if purchased from OpenC3, Inc.
|
22
|
-
|
23
|
-
require 'openc3/config/config_parser'
|
24
|
-
|
25
|
-
module OpenC3
|
26
|
-
# Reads an ascii file that defines the configuration settings used to
|
27
|
-
# configure the Command/Telemetry Server.
|
28
|
-
class CmdTlmServerConfig
|
29
|
-
# @return [Hash<String, Interface>] Interfaces hash
|
30
|
-
attr_accessor :interfaces
|
31
|
-
# @return [Hash<String, Interface>] Routers hash
|
32
|
-
attr_accessor :routers
|
33
|
-
# @return [Hash<String, PacketLogWriterPair>] Packet log writer hash. Each
|
34
|
-
# pair encapsulates a command and telemetry log writer.
|
35
|
-
attr_accessor :packet_log_writer_pairs
|
36
|
-
# @return [Array<BackgroundTask>] Array of background tasks
|
37
|
-
attr_accessor :background_tasks
|
38
|
-
# @return [String] Command and Telemetry Server title
|
39
|
-
attr_accessor :title
|
40
|
-
# @return [Boolean] Flag indicating if meta data should be collected
|
41
|
-
attr_accessor :metadata
|
42
|
-
|
43
|
-
# Create a default pair of packet log writers and parses the
|
44
|
-
# configuration file.
|
45
|
-
#
|
46
|
-
# @param filename [String] The name of the configuration file to parse
|
47
|
-
def initialize(filename, system_config)
|
48
|
-
@system_config = system_config
|
49
|
-
@interfaces = {}
|
50
|
-
@routers = {}
|
51
|
-
@packet_log_writer_pairs = {}
|
52
|
-
# cmd_log_writer = System.default_packet_log_writer.new(:CMD, *System.default_packet_log_writer_params)
|
53
|
-
# tlm_log_writer = System.default_packet_log_writer.new(:TLM, *System.default_packet_log_writer_params)
|
54
|
-
# @packet_log_writer_pairs['DEFAULT'] = PacketLogWriterPair.new(cmd_log_writer, tlm_log_writer)
|
55
|
-
@background_tasks = []
|
56
|
-
@title = nil
|
57
|
-
@metadata = false
|
58
|
-
process_file(filename)
|
59
|
-
end
|
60
|
-
|
61
|
-
protected
|
62
|
-
|
63
|
-
def get_target_interface_name(target_name)
|
64
|
-
@interfaces.each do |interface_name, interface|
|
65
|
-
return interface_name if interface.target_names.include?(target_name)
|
66
|
-
end
|
67
|
-
nil
|
68
|
-
end
|
69
|
-
|
70
|
-
def setup_interface_or_router
|
71
|
-
current_interface_or_router = OpenStruct.new
|
72
|
-
current_interface_or_router.interfaces = []
|
73
|
-
current_interface_or_router.routers = []
|
74
|
-
current_interface_or_router.target_names = []
|
75
|
-
current_interface_or_router
|
76
|
-
end
|
77
|
-
|
78
|
-
# Processes a file and adds in the configuration defined in the file
|
79
|
-
#
|
80
|
-
# @param filename [String] The name of the configuration file to parse
|
81
|
-
# @param recursive [Boolean] Whether process_file is being called
|
82
|
-
# recursively
|
83
|
-
def process_file(filename, recursive = false)
|
84
|
-
current_interface_or_router = nil
|
85
|
-
current_type = nil
|
86
|
-
current_interface_log_added = false
|
87
|
-
|
88
|
-
Logger.info "Processing CmdTlmServer configuration in file: #{File.expand_path(filename)}"
|
89
|
-
|
90
|
-
parser = ConfigParser.new("https://openc3.com/docs/v5")
|
91
|
-
parser.parse_file(filename) do |keyword, params|
|
92
|
-
case keyword
|
93
|
-
when 'TITLE'
|
94
|
-
raise parser.error("#{keyword} not allowed in target #{filename}") if recursive
|
95
|
-
|
96
|
-
parser.verify_num_parameters(1, 1, "#{keyword} <Title Text>")
|
97
|
-
@title = params[0]
|
98
|
-
|
99
|
-
when 'PACKET_LOG_WRITER'
|
100
|
-
# usage = "PACKET_LOG_WRITER <Name> <Filename> <Specific Parameters>"
|
101
|
-
# parser.verify_num_parameters(2, nil, usage)
|
102
|
-
# packet_log_writer_name = params[0].upcase
|
103
|
-
# packet_log_writer_class = OpenC3.require_class(params[1])
|
104
|
-
|
105
|
-
# # Verify not overridding a packet log writer that is already associated with an interface
|
106
|
-
# packet_log_writer_pair = @packet_log_writer_pairs[packet_log_writer_name]
|
107
|
-
# if packet_log_writer_pair
|
108
|
-
# @interfaces.each do |interface_name, interface|
|
109
|
-
# if interface.packet_log_writer_pairs.include?(packet_log_writer_pair)
|
110
|
-
# raise parser.error("Redefining Packet Log Writer #{packet_log_writer_name} not allowed after it is associated with an interface")
|
111
|
-
# end
|
112
|
-
# end
|
113
|
-
# end
|
114
|
-
|
115
|
-
# if params[2]
|
116
|
-
# cmd_log_writer = packet_log_writer_class.new(:CMD, *params[2..-1])
|
117
|
-
# tlm_log_writer = packet_log_writer_class.new(:TLM, *params[2..-1])
|
118
|
-
# @packet_log_writer_pairs[packet_log_writer_name] = PacketLogWriterPair.new(cmd_log_writer, tlm_log_writer)
|
119
|
-
# else
|
120
|
-
# cmd_log_writer = packet_log_writer_class.new(:CMD)
|
121
|
-
# tlm_log_writer = packet_log_writer_class.new(:TLM)
|
122
|
-
# @packet_log_writer_pairs[packet_log_writer_name] = PacketLogWriterPair.new(cmd_log_writer, tlm_log_writer)
|
123
|
-
# end
|
124
|
-
|
125
|
-
when 'AUTO_INTERFACE_TARGETS'
|
126
|
-
raise parser.error("#{keyword} not allowed in target #{filename}") if recursive
|
127
|
-
|
128
|
-
usage = "#{keyword}"
|
129
|
-
parser.verify_num_parameters(0, 0, usage)
|
130
|
-
@system_config.targets.each do |target_name, target|
|
131
|
-
target_filename = File.join(target.dir, 'cmd_tlm_server.txt')
|
132
|
-
if File.exist?(target_filename)
|
133
|
-
# Skip this target if it's already been assigned an interface
|
134
|
-
next if get_target_interface_name(target.name)
|
135
|
-
raise parser.error("Cannot use #{keyword} with target name substitutions: #{target.name} != #{target.original_name}") if target.name != target.original_name
|
136
|
-
|
137
|
-
process_file(target_filename, true)
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
when 'INTERFACE_TARGET'
|
142
|
-
raise parser.error("#{keyword} not allowed in target #{filename}") if recursive
|
143
|
-
|
144
|
-
usage = "#{keyword} <Target Name> <Config File (defaults to cmd_tlm_server.txt)>"
|
145
|
-
parser.verify_num_parameters(1, 2, usage)
|
146
|
-
target = @system_config.targets[params[0].upcase]
|
147
|
-
raise parser.error("Unknown target: #{params[0].upcase}") unless target
|
148
|
-
|
149
|
-
interface_name = get_target_interface_name(target.name)
|
150
|
-
raise parser.error("Target #{target.name} already mapped to interface #{interface_name}") if interface_name
|
151
|
-
|
152
|
-
target_filename = params[1]
|
153
|
-
target_filename = 'cmd_tlm_server.txt' unless target_filename
|
154
|
-
target_filename = File.join(target.dir, target_filename)
|
155
|
-
if File.exist?(target_filename)
|
156
|
-
process_file(target_filename, true)
|
157
|
-
else
|
158
|
-
raise parser.error("#{target_filename} does not exist")
|
159
|
-
end
|
160
|
-
|
161
|
-
when 'INTERFACE'
|
162
|
-
usage = "INTERFACE <Name> <Filename> <Specific Parameters>"
|
163
|
-
parser.verify_num_parameters(2, nil, usage)
|
164
|
-
interface_name = params[0].upcase
|
165
|
-
raise parser.error("Interface '#{interface_name}' defined twice") if @interfaces[interface_name]
|
166
|
-
|
167
|
-
# interface_class = OpenC3.require_class(params[1])
|
168
|
-
# if params[2]
|
169
|
-
# current_interface_or_router = interface_class.new(*params[2..-1])
|
170
|
-
# else
|
171
|
-
# current_interface_or_router = interface_class.new
|
172
|
-
# end
|
173
|
-
current_interface_or_router = setup_interface_or_router()
|
174
|
-
current_type = :INTERFACE
|
175
|
-
current_interface_log_added = false
|
176
|
-
# current_interface_or_router.packet_log_writer_pairs << @packet_log_writer_pairs['DEFAULT']
|
177
|
-
current_interface_or_router.name = interface_name
|
178
|
-
current_interface_or_router.config_params = params[1..-1]
|
179
|
-
@interfaces[interface_name] = current_interface_or_router
|
180
|
-
|
181
|
-
when 'LOG', 'LOG_STORED', 'DONT_LOG', 'TARGET'
|
182
|
-
raise parser.error("No current interface for #{keyword}") unless current_interface_or_router and current_type == :INTERFACE
|
183
|
-
|
184
|
-
case keyword
|
185
|
-
|
186
|
-
when 'LOG'
|
187
|
-
parser.verify_num_parameters(1, 1, "#{keyword} <Packet Log Writer Name>")
|
188
|
-
# packet_log_writer_pair = @packet_log_writer_pairs[params[0].upcase]
|
189
|
-
# raise parser.error("Unknown packet log writer: #{params[0].upcase}") unless packet_log_writer_pair
|
190
|
-
# current_interface_or_router.packet_log_writer_pairs.delete(@packet_log_writer_pairs['DEFAULT']) unless current_interface_log_added
|
191
|
-
current_interface_log_added = true
|
192
|
-
# current_interface_or_router.packet_log_writer_pairs << packet_log_writer_pair unless current_interface_or_router.packet_log_writer_pairs.include?(packet_log_writer_pair)
|
193
|
-
|
194
|
-
when 'LOG_STORED'
|
195
|
-
parser.verify_num_parameters(1, 1, "#{keyword} <Packet Log Writer Name>")
|
196
|
-
# packet_log_writer_pair = @packet_log_writer_pairs[params[0].upcase]
|
197
|
-
# raise parser.error("Unknown packet log writer: #{params[0].upcase}") unless packet_log_writer_pair
|
198
|
-
# current_interface_or_router.stored_packet_log_writer_pairs << packet_log_writer_pair unless current_interface_or_router.stored_packet_log_writer_pairs.include?(packet_log_writer_pair)
|
199
|
-
|
200
|
-
when 'DONT_LOG'
|
201
|
-
parser.verify_num_parameters(0, 0, "#{keyword}")
|
202
|
-
# current_interface_or_router.packet_log_writer_pairs = []
|
203
|
-
|
204
|
-
when 'TARGET'
|
205
|
-
parser.verify_num_parameters(1, 1, "#{keyword} <Target Name>")
|
206
|
-
target_name = params[0].upcase
|
207
|
-
target = @system_config.targets[target_name]
|
208
|
-
if target
|
209
|
-
interface_name = get_target_interface_name(target.name)
|
210
|
-
raise parser.error("Target #{target.name} already mapped to interface #{interface_name}") if interface_name
|
211
|
-
|
212
|
-
target.interface = current_interface_or_router
|
213
|
-
current_interface_or_router.target_names << target_name
|
214
|
-
else
|
215
|
-
raise parser.error("Unknown target #{target_name} mapped to interface #{current_interface_or_router.name}")
|
216
|
-
end
|
217
|
-
|
218
|
-
end # end case keyword for all keywords that require a current interface
|
219
|
-
|
220
|
-
when 'DONT_CONNECT', 'DONT_RECONNECT', 'RECONNECT_DELAY', 'DISABLE_DISCONNECT', 'LOG_RAW', 'OPTION', 'PROTOCOL'
|
221
|
-
raise parser.error("No current interface or router for #{keyword}") unless current_interface_or_router
|
222
|
-
|
223
|
-
case keyword
|
224
|
-
|
225
|
-
when 'DONT_CONNECT'
|
226
|
-
parser.verify_num_parameters(0, 0, "#{keyword}")
|
227
|
-
current_interface_or_router.connect_on_startup = false
|
228
|
-
|
229
|
-
when 'DONT_RECONNECT'
|
230
|
-
parser.verify_num_parameters(0, 0, "#{keyword}")
|
231
|
-
current_interface_or_router.auto_reconnect = false
|
232
|
-
|
233
|
-
when 'RECONNECT_DELAY'
|
234
|
-
parser.verify_num_parameters(1, 1, "#{keyword} <Delay in Seconds>")
|
235
|
-
current_interface_or_router.reconnect_delay = Float(params[0])
|
236
|
-
|
237
|
-
when 'DISABLE_DISCONNECT'
|
238
|
-
parser.verify_num_parameters(0, 0, "#{keyword}")
|
239
|
-
current_interface_or_router.disable_disconnect = true
|
240
|
-
|
241
|
-
when 'LOG_RAW',
|
242
|
-
parser.verify_num_parameters(0, nil, "#{keyword} <Raw Logger Class File (optional)> <Raw Logger Parameters (optional)>")
|
243
|
-
# current_interface_or_router.raw_logger_pair = RawLoggerPair.new(current_interface_or_router.name, params)
|
244
|
-
# current_interface_or_router.start_raw_logging
|
245
|
-
|
246
|
-
when 'OPTION'
|
247
|
-
parser.verify_num_parameters(2, nil, "#{keyword} <Option Name> <Option Value 1> <Option Value 2 (optional)> <etc>")
|
248
|
-
# current_interface_or_router.set_option(params[0], params[1..-1])
|
249
|
-
|
250
|
-
when 'PROTOCOL'
|
251
|
-
usage = "#{keyword} <READ WRITE READ_WRITE> <protocol filename or classname> <Protocol specific parameters>"
|
252
|
-
parser.verify_num_parameters(2, nil, usage)
|
253
|
-
unless %w(READ WRITE READ_WRITE).include? params[0].upcase
|
254
|
-
raise parser.error("Invalid protocol type: #{params[0]}", usage)
|
255
|
-
end
|
256
|
-
|
257
|
-
begin
|
258
|
-
# klass = OpenC3.require_class(params[1])
|
259
|
-
# current_interface_or_router.add_protocol(klass, params[2..-1], params[0].upcase.intern)
|
260
|
-
rescue LoadError, StandardError => error
|
261
|
-
raise parser.error(error.message, usage)
|
262
|
-
end
|
263
|
-
|
264
|
-
end # end case keyword for all keywords that require a current interface or router
|
265
|
-
|
266
|
-
when 'ROUTER'
|
267
|
-
usage = "ROUTER <Name> <Filename> <Specific Parameters>"
|
268
|
-
parser.verify_num_parameters(2, nil, usage)
|
269
|
-
router_name = params[0].upcase
|
270
|
-
raise parser.error("Router '#{router_name}' defined twice") if @routers[router_name]
|
271
|
-
|
272
|
-
# router_class = OpenC3.require_class(params[1])
|
273
|
-
# if params[2]
|
274
|
-
# current_interface_or_router = router_class.new(*params[2..-1])
|
275
|
-
# else
|
276
|
-
# current_interface_or_router = router_class.new
|
277
|
-
# end
|
278
|
-
current_interface_or_router = setup_interface_or_router()
|
279
|
-
current_type = :ROUTER
|
280
|
-
current_interface_or_router.name = router_name
|
281
|
-
@routers[router_name] = current_interface_or_router
|
282
|
-
|
283
|
-
when 'ROUTE'
|
284
|
-
raise parser.error("No current router for #{keyword}") unless current_interface_or_router and current_type == :ROUTER
|
285
|
-
|
286
|
-
usage = "ROUTE <Interface Name>"
|
287
|
-
parser.verify_num_parameters(1, 1, usage)
|
288
|
-
interface_name = params[0].upcase
|
289
|
-
interface = @interfaces[interface_name]
|
290
|
-
raise parser.error("Unknown interface #{interface_name} mapped to router #{current_interface_or_router.name}") unless interface
|
291
|
-
|
292
|
-
unless current_interface_or_router.interfaces.include? interface
|
293
|
-
current_interface_or_router.interfaces << interface
|
294
|
-
interface.routers << current_interface_or_router
|
295
|
-
end
|
296
|
-
|
297
|
-
when 'BACKGROUND_TASK'
|
298
|
-
usage = "#{keyword} <Filename> <Specific Parameters>"
|
299
|
-
parser.verify_num_parameters(1, nil, usage)
|
300
|
-
# background_task = OpenC3.require_class(params[0])
|
301
|
-
if params[1]
|
302
|
-
@background_tasks << params
|
303
|
-
else
|
304
|
-
@background_tasks << params
|
305
|
-
end
|
306
|
-
|
307
|
-
when 'STOPPED'
|
308
|
-
parser.verify_num_parameters(0, 0, "#{keyword}")
|
309
|
-
raise parser.error("No BACKGROUND_TASK defined") if @background_tasks.empty?
|
310
|
-
# @background_tasks[-1].stopped = true
|
311
|
-
|
312
|
-
when 'COLLECT_METADATA'
|
313
|
-
parser.verify_num_parameters(0, 0, "#{keyword}")
|
314
|
-
@metadata = true
|
315
|
-
|
316
|
-
else
|
317
|
-
# blank lines will have a nil keyword and should not raise an exception
|
318
|
-
raise parser.error("Unknown keyword: #{keyword}") unless keyword.nil?
|
319
|
-
end # case
|
320
|
-
end # loop
|
321
|
-
end
|
322
|
-
end
|
323
|
-
end
|