origen 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/ctags +0 -0
- data/bin/origen +165 -1
- data/bin/rgen +2 -0
- data/config/application.rb +141 -0
- data/config/commands.rb +72 -0
- data/config/development.rb +7 -0
- data/config/environment.rb +0 -0
- data/config/rgen.policy +7 -0
- data/config/rubocop/easy.yml +620 -0
- data/config/rubocop/easy_disabled.yml +271 -0
- data/config/rubocop/easy_enabled.yml +731 -0
- data/config/rubocop/strict.yml +620 -0
- data/config/rubocop/strict_disabled.yml +247 -0
- data/config/rubocop/strict_enabled.yml +755 -0
- data/config/users.rb +20 -0
- data/config/version.rb +1 -1
- data/helpers/url.rb +68 -0
- data/lib/c99/doc_interface.rb +56 -0
- data/lib/c99/j750_interface.rb +85 -0
- data/lib/c99/nvm.rb +89 -0
- data/lib/c99/target/mock2.rb +1 -0
- data/lib/c99/target/subdir/mock3.rb +1 -0
- data/lib/option_parser/optparse.rb +12 -0
- data/lib/origen/acronyms.rb +60 -0
- data/lib/origen/application/command_dispatcher.rb +12 -0
- data/lib/origen/application/configuration.rb +206 -0
- data/lib/origen/application/configuration_manager.rb +78 -0
- data/lib/origen/application/deployer.rb +367 -0
- data/lib/origen/application/environment.rb +186 -0
- data/lib/origen/application/lsf.rb +145 -0
- data/lib/origen/application/lsf_manager.rb +657 -0
- data/lib/origen/application/plugins_manager.rb +280 -0
- data/lib/origen/application/release.rb +359 -0
- data/lib/origen/application/runner.rb +246 -0
- data/lib/origen/application/statistics.rb +191 -0
- data/lib/origen/application/target.rb +374 -0
- data/lib/origen/application/version_tracker.rb +59 -0
- data/lib/origen/application/workspace_manager.rb +151 -0
- data/lib/origen/application.rb +746 -0
- data/lib/origen/bugs/bug.rb +36 -0
- data/lib/origen/bugs.rb +45 -0
- data/lib/origen/callbacks.rb +35 -0
- data/lib/origen/chip_mode.rb +118 -0
- data/lib/origen/chip_package.rb +461 -0
- data/lib/origen/client.rb +87 -0
- data/lib/origen/code_generators/actions.rb +258 -0
- data/lib/origen/code_generators/base.rb +57 -0
- data/lib/origen/code_generators/bundler.rb +17 -0
- data/lib/origen/code_generators/gem_setup.rb +49 -0
- data/lib/origen/code_generators/rake.rb +13 -0
- data/lib/origen/code_generators/rspec.rb +12 -0
- data/lib/origen/code_generators/semver.rb +39 -0
- data/lib/origen/code_generators/timever.rb +37 -0
- data/lib/origen/code_generators.rb +111 -0
- data/lib/origen/commands/add.rb +12 -0
- data/lib/origen/commands/compile.rb +62 -0
- data/lib/origen/commands/ctags.rb +9 -0
- data/lib/origen/commands/dispatch.rb +22 -0
- data/lib/origen/commands/environment.rb +11 -0
- data/lib/origen/commands/fetch.rb +63 -0
- data/lib/origen/commands/generate.rb +130 -0
- data/lib/origen/commands/interactive.rb +73 -0
- data/lib/origen/commands/lint.rb +82 -0
- data/lib/origen/commands/lsf.rb +93 -0
- data/lib/origen/commands/merge.rb +55 -0
- data/lib/origen/commands/modifications.rb +12 -0
- data/lib/origen/commands/new.rb +113 -0
- data/lib/origen/commands/plugin.rb +105 -0
- data/lib/origen/commands/program.rb +70 -0
- data/lib/origen/commands/rc.rb +442 -0
- data/lib/origen/commands/save.rb +56 -0
- data/lib/origen/commands/target.rb +27 -0
- data/lib/origen/commands/time.rb +127 -0
- data/lib/origen/commands/version.rb +17 -0
- data/lib/origen/commands/web.rb +221 -0
- data/lib/origen/commands.rb +272 -0
- data/lib/origen/commands_global.rb +76 -0
- data/lib/origen/controller.rb +94 -0
- data/lib/origen/core_ext/array.rb +23 -0
- data/lib/origen/core_ext/bignum.rb +36 -0
- data/lib/origen/core_ext/enumerable.rb +76 -0
- data/lib/origen/core_ext/fixnum.rb +46 -0
- data/lib/origen/core_ext/hash.rb +52 -0
- data/lib/origen/core_ext/module.rb +14 -0
- data/lib/origen/core_ext/numeric.rb +126 -0
- data/lib/origen/core_ext/object.rb +13 -0
- data/lib/origen/core_ext/range.rb +7 -0
- data/lib/origen/core_ext/string.rb +124 -0
- data/lib/origen/core_ext.rb +10 -0
- data/lib/origen/database/key_value_store.rb +111 -0
- data/lib/origen/database/key_value_stores.rb +108 -0
- data/lib/origen/database.rb +6 -0
- data/lib/origen/encodings.rb +102 -0
- data/lib/origen/features/feature.rb +22 -0
- data/lib/origen/features.rb +104 -0
- data/lib/origen/file_handler.rb +429 -0
- data/lib/origen/generator/comparator.rb +56 -0
- data/lib/origen/generator/compiler.rb +277 -0
- data/lib/origen/generator/flow.rb +49 -0
- data/lib/origen/generator/job.rb +131 -0
- data/lib/origen/generator/pattern.rb +356 -0
- data/lib/origen/generator/pattern_finder.rb +155 -0
- data/lib/origen/generator/pattern_iterator.rb +55 -0
- data/lib/origen/generator/renderer.rb +113 -0
- data/lib/origen/generator/resources.rb +40 -0
- data/lib/origen/generator/stage.rb +89 -0
- data/lib/origen/generator.rb +85 -0
- data/lib/origen/global_methods.rb +205 -0
- data/lib/origen/import_manager.rb +596 -0
- data/lib/origen/location/base.rb +116 -0
- data/lib/origen/location/map.rb +83 -0
- data/lib/origen/location.rb +6 -0
- data/lib/origen/log.rb +217 -0
- data/lib/origen/logger_methods.rb +56 -0
- data/lib/origen/mode.rb +61 -0
- data/lib/origen/model.rb +267 -0
- data/lib/origen/model_initializer.rb +45 -0
- data/lib/origen/nvm/block_array.rb +72 -0
- data/lib/origen/nvm.rb +6 -0
- data/lib/origen/parameters/live.rb +22 -0
- data/lib/origen/parameters/missing.rb +28 -0
- data/lib/origen/parameters/set.rb +144 -0
- data/lib/origen/parameters.rb +107 -0
- data/lib/origen/pdm.rb +218 -0
- data/lib/origen/pins/function_proxy.rb +36 -0
- data/lib/origen/pins/ground_pin.rb +6 -0
- data/lib/origen/pins/pin.rb +860 -0
- data/lib/origen/pins/pin_bank.rb +349 -0
- data/lib/origen/pins/pin_clock.rb +124 -0
- data/lib/origen/pins/pin_collection.rb +492 -0
- data/lib/origen/pins/pin_common.rb +206 -0
- data/lib/origen/pins/port.rb +268 -0
- data/lib/origen/pins/power_pin.rb +30 -0
- data/lib/origen/pins.rb +696 -0
- data/lib/origen/registers/bit.rb +562 -0
- data/lib/origen/registers/bit_collection.rb +787 -0
- data/lib/origen/registers/container.rb +288 -0
- data/lib/origen/registers/domain.rb +16 -0
- data/lib/origen/registers/reg.rb +1406 -0
- data/lib/origen/registers/reg_collection.rb +24 -0
- data/lib/origen/registers.rb +652 -0
- data/lib/origen/regression_manager.rb +251 -0
- data/lib/origen/remote_manager.rb +340 -0
- data/lib/origen/revision_control/base.rb +257 -0
- data/lib/origen/revision_control/design_sync.rb +276 -0
- data/lib/origen/revision_control/git.rb +243 -0
- data/lib/origen/revision_control/subversion.rb +6 -0
- data/lib/origen/revision_control.rb +44 -0
- data/lib/origen/ruby_version_check.rb +131 -0
- data/lib/origen/site_config.rb +61 -0
- data/lib/origen/specs/checkers.rb +103 -0
- data/lib/origen/specs/creation_info.rb +17 -0
- data/lib/origen/specs/doc_resource.rb +91 -0
- data/lib/origen/specs/exhibit.rb +17 -0
- data/lib/origen/specs/mode_select.rb +16 -0
- data/lib/origen/specs/note.rb +17 -0
- data/lib/origen/specs/override.rb +21 -0
- data/lib/origen/specs/power_supply.rb +13 -0
- data/lib/origen/specs/spec.rb +226 -0
- data/lib/origen/specs/version_history.rb +14 -0
- data/lib/origen/specs.rb +552 -0
- data/lib/origen/sub_blocks.rb +298 -0
- data/lib/origen/tester/api.rb +277 -0
- data/lib/origen/tester/bdm/bdm.rb +25 -0
- data/lib/origen/tester/command_based_tester.rb +46 -0
- data/lib/origen/tester/doc/doc.rb +226 -0
- data/lib/origen/tester/doc/generator/flow.rb +71 -0
- data/lib/origen/tester/doc/generator/flow_line.rb +203 -0
- data/lib/origen/tester/doc/generator/test.rb +68 -0
- data/lib/origen/tester/doc/generator/test_group.rb +66 -0
- data/lib/origen/tester/doc/generator/tests.rb +47 -0
- data/lib/origen/tester/doc/generator.rb +126 -0
- data/lib/origen/tester/doc/model.rb +162 -0
- data/lib/origen/tester/generator/flow_control_api.rb +606 -0
- data/lib/origen/tester/generator/identity_map.rb +25 -0
- data/lib/origen/tester/generator/placeholder.rb +13 -0
- data/lib/origen/tester/generator/test_numberer.rb +25 -0
- data/lib/origen/tester/generator.rb +271 -0
- data/lib/origen/tester/interface.rb +154 -0
- data/lib/origen/tester/j750/files.rb +45 -0
- data/lib/origen/tester/j750/generator/flow.rb +123 -0
- data/lib/origen/tester/j750/generator/flow_line.rb +288 -0
- data/lib/origen/tester/j750/generator/patgroup.rb +111 -0
- data/lib/origen/tester/j750/generator/patgroups.rb +41 -0
- data/lib/origen/tester/j750/generator/patset.rb +111 -0
- data/lib/origen/tester/j750/generator/patsets.rb +41 -0
- data/lib/origen/tester/j750/generator/templates/flow.txt.erb +9 -0
- data/lib/origen/tester/j750/generator/templates/instances.txt.erb +16 -0
- data/lib/origen/tester/j750/generator/templates/patgroups.txt.erb +8 -0
- data/lib/origen/tester/j750/generator/templates/patsets.txt.erb +10 -0
- data/lib/origen/tester/j750/generator/test_instance.rb +846 -0
- data/lib/origen/tester/j750/generator/test_instance_group.rb +60 -0
- data/lib/origen/tester/j750/generator/test_instances.rb +182 -0
- data/lib/origen/tester/j750/generator.rb +203 -0
- data/lib/origen/tester/j750/j750.rb +845 -0
- data/lib/origen/tester/j750/j750_hpt.rb +35 -0
- data/lib/origen/tester/j750/parser/ac_spec.rb +11 -0
- data/lib/origen/tester/j750/parser/ac_specs.rb +0 -0
- data/lib/origen/tester/j750/parser/dc_spec.rb +36 -0
- data/lib/origen/tester/j750/parser/dc_specs.rb +50 -0
- data/lib/origen/tester/j750/parser/descriptions.rb +340 -0
- data/lib/origen/tester/j750/parser/flow.rb +111 -0
- data/lib/origen/tester/j750/parser/flow_line.rb +207 -0
- data/lib/origen/tester/j750/parser/flows.rb +23 -0
- data/lib/origen/tester/j750/parser/pattern_set.rb +94 -0
- data/lib/origen/tester/j750/parser/pattern_sets.rb +33 -0
- data/lib/origen/tester/j750/parser/test_instance.rb +322 -0
- data/lib/origen/tester/j750/parser/test_instances.rb +26 -0
- data/lib/origen/tester/j750/parser/timeset.rb +15 -0
- data/lib/origen/tester/j750/parser/timesets.rb +0 -0
- data/lib/origen/tester/j750/parser.rb +104 -0
- data/lib/origen/tester/jlink/jlink.rb +33 -0
- data/lib/origen/tester/parser/description_lookup.rb +64 -0
- data/lib/origen/tester/parser/searchable_array.rb +32 -0
- data/lib/origen/tester/parser/searchable_hash.rb +32 -0
- data/lib/origen/tester/parser.rb +24 -0
- data/lib/origen/tester/time.rb +338 -0
- data/lib/origen/tester/timing.rb +253 -0
- data/lib/origen/tester/ultraflex/files.rb +45 -0
- data/lib/origen/tester/ultraflex/generator/flow.rb +119 -0
- data/lib/origen/tester/ultraflex/generator/flow_line.rb +269 -0
- data/lib/origen/tester/ultraflex/generator/patgroup.rb +111 -0
- data/lib/origen/tester/ultraflex/generator/patgroups.rb +41 -0
- data/lib/origen/tester/ultraflex/generator/patset.rb +111 -0
- data/lib/origen/tester/ultraflex/generator/patsets.rb +41 -0
- data/lib/origen/tester/ultraflex/generator/templates/flow.txt.erb +9 -0
- data/lib/origen/tester/ultraflex/generator/templates/instances.txt.erb +16 -0
- data/lib/origen/tester/ultraflex/generator/templates/patgroups.txt.erb +8 -0
- data/lib/origen/tester/ultraflex/generator/templates/patsets.txt.erb +10 -0
- data/lib/origen/tester/ultraflex/generator/test_instance.rb +622 -0
- data/lib/origen/tester/ultraflex/generator/test_instance_group.rb +60 -0
- data/lib/origen/tester/ultraflex/generator/test_instances.rb +174 -0
- data/lib/origen/tester/ultraflex/generator.rb +200 -0
- data/lib/origen/tester/ultraflex/parser/ac_spec.rb +11 -0
- data/lib/origen/tester/ultraflex/parser/ac_specs.rb +0 -0
- data/lib/origen/tester/ultraflex/parser/dc_spec.rb +36 -0
- data/lib/origen/tester/ultraflex/parser/dc_specs.rb +50 -0
- data/lib/origen/tester/ultraflex/parser/descriptions.rb +342 -0
- data/lib/origen/tester/ultraflex/parser/flow.rb +111 -0
- data/lib/origen/tester/ultraflex/parser/flow_line.rb +207 -0
- data/lib/origen/tester/ultraflex/parser/flows.rb +23 -0
- data/lib/origen/tester/ultraflex/parser/pattern_set.rb +94 -0
- data/lib/origen/tester/ultraflex/parser/pattern_sets.rb +33 -0
- data/lib/origen/tester/ultraflex/parser/test_instance.rb +262 -0
- data/lib/origen/tester/ultraflex/parser/test_instances.rb +26 -0
- data/lib/origen/tester/ultraflex/parser/timeset.rb +15 -0
- data/lib/origen/tester/ultraflex/parser/timesets.rb +0 -0
- data/lib/origen/tester/ultraflex/parser.rb +104 -0
- data/lib/origen/tester/ultraflex/ultraflex.rb +759 -0
- data/lib/origen/tester/v93k/generator/flow.rb +63 -0
- data/lib/origen/tester/v93k/generator/flow_node/print.rb +10 -0
- data/lib/origen/tester/v93k/generator/flow_node.rb +17 -0
- data/lib/origen/tester/v93k/generator/pattern.rb +16 -0
- data/lib/origen/tester/v93k/generator/pattern_master.rb +54 -0
- data/lib/origen/tester/v93k/generator/templates/_test_method.txt.erb +6 -0
- data/lib/origen/tester/v93k/generator/templates/_test_suite.txt.erb +11 -0
- data/lib/origen/tester/v93k/generator/templates/template.flow.erb +121 -0
- data/lib/origen/tester/v93k/generator/templates/template.pmfl.erb +9 -0
- data/lib/origen/tester/v93k/generator/test_function.rb +103 -0
- data/lib/origen/tester/v93k/generator/test_functions.rb +79 -0
- data/lib/origen/tester/v93k/generator/test_method.rb +46 -0
- data/lib/origen/tester/v93k/generator/test_methods.rb +75 -0
- data/lib/origen/tester/v93k/generator/test_suite.rb +54 -0
- data/lib/origen/tester/v93k/generator/test_suites.rb +65 -0
- data/lib/origen/tester/v93k/generator.rb +80 -0
- data/lib/origen/tester/v93k/v93k.rb +420 -0
- data/lib/origen/tester/vector.rb +86 -0
- data/lib/origen/tester/vector_generator.rb +633 -0
- data/lib/origen/tester/vector_pipeline.rb +150 -0
- data/lib/origen/tester.rb +56 -0
- data/lib/origen/top_level.rb +134 -0
- data/lib/origen/users/ldap.rb +65 -0
- data/lib/origen/users/user.rb +149 -0
- data/lib/origen/users.rb +30 -0
- data/lib/origen/utility/block_args.rb +93 -0
- data/lib/origen/utility/csv_data.rb +110 -0
- data/lib/origen/utility/design_sync.rb +494 -0
- data/lib/origen/utility/diff.rb +158 -0
- data/lib/origen/utility/input_capture.rb +121 -0
- data/lib/origen/utility/mailer.rb +143 -0
- data/lib/origen/utility/s_record.rb +205 -0
- data/lib/origen/utility/time_and_date.rb +30 -0
- data/lib/origen/utility.rb +12 -0
- data/lib/origen/version_checker.rb +117 -0
- data/lib/origen/version_string.rb +356 -0
- data/lib/origen.rb +648 -0
- data/lib/tasks/gem.rake +27 -22
- data/origen_site_config.yml +36 -0
- data/source_setup +17 -0
- data/spec/format/rgen_formatter.rb +14 -0
- data/templates/api_doc/README.txt.erb +24 -0
- data/templates/code_generators/gemfile_app.rb +4 -0
- data/templates/code_generators/gemfile_plugin.rb +6 -0
- data/templates/code_generators/gemspec.rb +33 -0
- data/templates/code_generators/rakefile.rb +10 -0
- data/templates/code_generators/spec_helper.rb +49 -0
- data/templates/code_generators/version.rb +8 -0
- data/templates/code_generators/version_time.rb +3 -0
- data/templates/git/gitignore.erb +33 -0
- data/templates/j750/_vt_flow.txt.erb +8 -0
- data/templates/j750/_vt_instances.txt.erb +4 -0
- data/templates/j750/program_sheet.txt.erb +9 -0
- data/templates/nanoc/Rules +74 -0
- data/templates/nanoc/config.yaml +77 -0
- data/templates/nanoc/content/favicon.ico +0 -0
- data/templates/nanoc/layouts/bootstrap.html.erb +63 -0
- data/templates/nanoc/layouts/bootstrap3.html.erb +71 -0
- data/templates/nanoc/layouts/freescale.html.erb +79 -0
- data/templates/nanoc/lib/bootstrap_filter.rb +49 -0
- data/templates/nanoc/lib/codeblocks_filter.rb +41 -0
- data/templates/nanoc/lib/default.rb +2 -0
- data/templates/nanoc/lib/gzip_filter.rb +16 -0
- data/templates/nanoc/lib/haml_code_filter.rb +41 -0
- data/templates/nanoc/lib/helpers.rb +1 -0
- data/templates/nanoc/lib/search_filter.rb +62 -0
- data/templates/nanoc_dynamic/content/search.js.erb +92 -0
- data/templates/shared/web/_logo.html +10 -0
- data/templates/test/_inline_sub.txt.erb +2 -0
- data/templates/test/environment.txt.erb +1 -0
- data/templates/test/inline.txt.erb +11 -0
- data/templates/test/inspections.txt.erb +19 -0
- data/templates/test/set1/_sub1.txt.erb +12 -0
- data/templates/test/set1/_sub4.txt.erb +1 -0
- data/templates/test/set1/_sub5.txt.erb +1 -0
- data/templates/test/set1/main.txt.erb +53 -0
- data/templates/test/set1/sub_dir/_sub2.txt.erb +20 -0
- data/templates/test/set1/sub_dir/_sub3.txt.erb +12 -0
- data/templates/test/set1/sub_dir/main2.txt.erb +4 -0
- data/templates/test/set2/template_with_no_erb_1.txt +9 -0
- data/templates/test/set2/template_with_no_erb_2.txt +9 -0
- data/templates/test/set3/_layout.html.erb +4 -0
- data/templates/test/set3/content.html.erb +6 -0
- data/templates/time/filter.rb.erb +15 -0
- data/templates/time/rules.rb.erb +45 -0
- metadata +639 -5
@@ -0,0 +1,461 @@
|
|
1
|
+
module Origen
|
2
|
+
# Represents an SoC Package option
|
3
|
+
class ChipPackage
|
4
|
+
require 'colored'
|
5
|
+
attr_accessor :description
|
6
|
+
attr_accessor :number_of_rows
|
7
|
+
attr_accessor :number_of_columns
|
8
|
+
attr_accessor :interconnects
|
9
|
+
attr_accessor :types
|
10
|
+
attr_reader :upper_axes
|
11
|
+
attr_reader :lower_axes
|
12
|
+
attr_reader :rows
|
13
|
+
attr_reader :columns
|
14
|
+
attr_reader :field
|
15
|
+
attr_reader :obj
|
16
|
+
attr_reader :groups
|
17
|
+
attr_reader :group_list
|
18
|
+
attr_reader :last_empty_char
|
19
|
+
attr_reader :plottable
|
20
|
+
attr_writer :name
|
21
|
+
alias_writer :full_name, :name
|
22
|
+
# Returns the owner that $owns the mode (the SoC instance usually)
|
23
|
+
attr_accessor :owner
|
24
|
+
|
25
|
+
def name
|
26
|
+
@name || @id
|
27
|
+
end
|
28
|
+
alias_method :full_name, :name
|
29
|
+
|
30
|
+
def id
|
31
|
+
@id || name.to_s.downcase.gsub(/(\s|-)+/, '_').to_sym
|
32
|
+
end
|
33
|
+
|
34
|
+
def id=(val)
|
35
|
+
@id = val.to_s.gsub(/(\s|-)+/, '_').downcase.to_sym
|
36
|
+
end
|
37
|
+
|
38
|
+
def to_s
|
39
|
+
id.to_s
|
40
|
+
end
|
41
|
+
|
42
|
+
def to_sym
|
43
|
+
to_s.to_sym
|
44
|
+
end
|
45
|
+
|
46
|
+
def types
|
47
|
+
@types || []
|
48
|
+
end
|
49
|
+
|
50
|
+
# prepare_plot should not need to be called explicitly. It is called
|
51
|
+
# by other methods when need-be, and is fundamentallyis responsible
|
52
|
+
# for two things:
|
53
|
+
#
|
54
|
+
# 1. It checks that self.types includes a "BGA" option.
|
55
|
+
# 2. It populates the .field attribute with a multi-dimensional
|
56
|
+
# array, proportional in size to the package BGA.
|
57
|
+
#
|
58
|
+
def prepare_plot
|
59
|
+
@plottable = types.any? { |x| /BGA/i =~ x }
|
60
|
+
if @plottable
|
61
|
+
@last_empty_char = '.'
|
62
|
+
@field = []
|
63
|
+
@groups = []
|
64
|
+
@group_list = list_groups
|
65
|
+
@columns = []
|
66
|
+
jedec_rows = %w(A B C D E F G H J K L M N P R T U V W Y AA AB AC AD AE AF AG AH AJ AK AL AM AN AP AR AT AU AV AW AY BA BB BC BD BE BF BG BH BJ BK BL BM BN BP)
|
67
|
+
@number_of_rows.times { @field.insert(0, []); @number_of_columns.times { @field[0].insert(0, []) } }
|
68
|
+
@rows = jedec_rows[0, @number_of_rows]
|
69
|
+
(1..@number_of_columns).map { |item| @columns << item }
|
70
|
+
@upper_axes = []
|
71
|
+
@lower_axes = []
|
72
|
+
@columns.each_with_index do|column, index|
|
73
|
+
# if index % 2 == 0
|
74
|
+
if index.even?
|
75
|
+
temp = column.to_s
|
76
|
+
temp += ' ' unless temp.size > 1
|
77
|
+
@upper_axes << temp
|
78
|
+
@lower_axes << ' '
|
79
|
+
else
|
80
|
+
temp = column.to_s
|
81
|
+
temp += ' ' unless temp.size > 1
|
82
|
+
@lower_axes << temp
|
83
|
+
@upper_axes << ' '
|
84
|
+
end
|
85
|
+
end
|
86
|
+
else
|
87
|
+
puts 'Sorry, currently the plot feature only supports BGA package types.'
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# generate_field should not need to be called explicitly. It is called
|
92
|
+
# by other methods when need-be, and is fundamentallyis responsible
|
93
|
+
# for two things:
|
94
|
+
#
|
95
|
+
# 1. It fills the .field array with the appropriate symbols/markers.
|
96
|
+
# 2. It concatenates the array elements into printable rows, and prints
|
97
|
+
# them.
|
98
|
+
#
|
99
|
+
def generate_field(emptyChar = @last_empty_char)
|
100
|
+
if plottable
|
101
|
+
new_field = []
|
102
|
+
@field.each do |rows|
|
103
|
+
rows.each do |items|
|
104
|
+
if items.length == 0
|
105
|
+
items.insert(0, "#{emptyChar} ")
|
106
|
+
elsif emptyChar != @last_empty_char && items == ["#{last_empty_char} "]
|
107
|
+
items[0] = "#{emptyChar} "
|
108
|
+
end
|
109
|
+
end
|
110
|
+
new_field.insert(-1, rows.join(''))
|
111
|
+
end
|
112
|
+
@last_empty_char = emptyChar
|
113
|
+
package = (owner.package.nil?) ? 'No package chosen.' : owner.package.to_s
|
114
|
+
puts "\nPin field: #{package}\n\n"
|
115
|
+
group_display = @groups.join("\n")
|
116
|
+
puts "Legend: \n#{group_display}\n\n"
|
117
|
+
puts @upper_axes.join('').yellow
|
118
|
+
new_field.each_with_index { |line, index| puts line + "#{@rows[index]} (#{index + 1})\n".chop.yellow }
|
119
|
+
puts @lower_axes.join('').yellow, "\n"
|
120
|
+
end
|
121
|
+
end
|
122
|
+
alias_method :show, :generate_field
|
123
|
+
|
124
|
+
def add_power(marker = 'P')
|
125
|
+
# add_power can be called explicitly or by the .plot("power") method call.
|
126
|
+
prepare_plot if field.nil?
|
127
|
+
if plottable
|
128
|
+
pin_list = owner.power_pins.map { |_ken, pin| pin }
|
129
|
+
@groups << "#{marker} - Power"
|
130
|
+
pin_list.each do |item|
|
131
|
+
# puts items,owner.pins[items].location
|
132
|
+
begin
|
133
|
+
coordinates = coordinate(item.location)
|
134
|
+
@field[coordinates[0]][coordinates[1]] = [marker.red + ' ']
|
135
|
+
rescue
|
136
|
+
puts "#{item} doesn't appear to have a physical location in this configuration."
|
137
|
+
puts "Current package = #{owner.package}"
|
138
|
+
end
|
139
|
+
end
|
140
|
+
generate_field
|
141
|
+
end
|
142
|
+
end
|
143
|
+
alias_method :add_powers, :add_power
|
144
|
+
alias_method :plot_power, :add_power
|
145
|
+
alias_method :plot_powers, :add_power
|
146
|
+
|
147
|
+
def add_grounds(marker = 'G')
|
148
|
+
# add_grounds can be called explicitly, or by the .plot("grounds") method call.
|
149
|
+
prepare_plot if field.nil?
|
150
|
+
if plottable
|
151
|
+
pin_list = owner.ground_pins.map { |_ken, pin| pin }
|
152
|
+
@groups << "#{marker} - Ground"
|
153
|
+
pin_list.each do |item|
|
154
|
+
begin
|
155
|
+
coordinates = coordinate(item.location)
|
156
|
+
@field[coordinates[0]][coordinates[1]] = [marker.green + ' ']
|
157
|
+
rescue
|
158
|
+
puts "#{item} doesn't appear to have a physical location in this configuration."
|
159
|
+
end
|
160
|
+
end
|
161
|
+
generate_field
|
162
|
+
end
|
163
|
+
end
|
164
|
+
alias_method :add_ground, :add_grounds
|
165
|
+
alias_method :plot_ground, :add_grounds
|
166
|
+
alias_method :plot_grounds, :add_grounds
|
167
|
+
|
168
|
+
def clear
|
169
|
+
# clear removes all elements from the .field and .groups attributes.
|
170
|
+
prepare_plot if field.nil?
|
171
|
+
if plottable
|
172
|
+
@groups = []
|
173
|
+
@field = []
|
174
|
+
@number_of_rows.times { @field.insert(0, []); @number_of_columns.times { @field[0].insert(0, []) } }
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
def plot_help
|
179
|
+
prepare_plot if field.nil?
|
180
|
+
puts "\n#################### PLOT HELP ####################"
|
181
|
+
puts 'To generate in-console BGA plots, the ChipPackage class will respond to the following methods:'
|
182
|
+
puts '.list_groups, .plot(), .plot_coord(), .show(), and .clear'
|
183
|
+
if plottable
|
184
|
+
puts "\nPLOTTING GROUPS:"
|
185
|
+
puts '$dut.package.list_groups <-- to see available group names'
|
186
|
+
puts "$dut.package.plot(\"ddr_interface_1\")"
|
187
|
+
puts "$dut.package.plot_group(\"serdes_1\",'Z') <--denotes custom legend marker, Z"
|
188
|
+
puts "\nPLOTTING INDIVIDUAL PINS:"
|
189
|
+
puts "$dut.package.plot(\"d1_mdqs00\")"
|
190
|
+
puts "\nPLOTTING WITH REGEXP:"
|
191
|
+
puts "$dut.package.plot(\"d1_mdqs\") <-- Plot all controller 1 DQS pins."
|
192
|
+
puts "$dut.package.plot(\"d1_mdqs0[0-9]\") <-- Plot d1_mdqs00 - d1_mdqs09."
|
193
|
+
puts "\nADDING POWER/GROUND:"
|
194
|
+
puts "$dut.package.plot(\"grounds\")"
|
195
|
+
puts "$dut.package.plot(\"power\")"
|
196
|
+
puts "\nVIEW CURRENT PLOT\n"
|
197
|
+
puts '$dut.package.show'
|
198
|
+
else
|
199
|
+
puts 'Currently, only BGA package types are supported for in-console plotting.'
|
200
|
+
end
|
201
|
+
end
|
202
|
+
alias_method :help_plot, :plot_help
|
203
|
+
|
204
|
+
def list_groups
|
205
|
+
# returns an array of group names assigned to the package
|
206
|
+
grps = owner.pins.map { |_key, val| val.group }
|
207
|
+
grps.uniq!
|
208
|
+
rescue
|
209
|
+
return []
|
210
|
+
end
|
211
|
+
alias_method :group_list, :list_groups
|
212
|
+
|
213
|
+
def group_array(grp)
|
214
|
+
# returns an array of pins belonging to the given group
|
215
|
+
pin_list = $dut.pins.map { |_key, val| val if val.group == grp }
|
216
|
+
pin_list[0].compact!
|
217
|
+
puts 'No pins found under that group name.' unless pin_list.any?
|
218
|
+
rescue
|
219
|
+
return []
|
220
|
+
end
|
221
|
+
|
222
|
+
# ##############################################################
|
223
|
+
# ############# String/Coordinate Manipulation #################
|
224
|
+
# ##############################################################
|
225
|
+
|
226
|
+
def coordinate(location)
|
227
|
+
## Returns array of numerical equiv coordinates (e.g. "AA11" -> [20,11])
|
228
|
+
error = "\n\nSomething wrong during coordinate-mapping.\nAre you sure you passed an alphanumeric string\n to the coordinate() method?\n"
|
229
|
+
split_index = -1
|
230
|
+
location.each_char do |character|
|
231
|
+
if letter?(character)
|
232
|
+
split_index += 1
|
233
|
+
end
|
234
|
+
end
|
235
|
+
row = location[0..split_index]
|
236
|
+
column = location[split_index + 1..-1]
|
237
|
+
fail ArgumentError, error unless row.length > 0 && column.length > 0
|
238
|
+
## Now convert alphanumeric row to jedec equiv' with to_row() method
|
239
|
+
# and return coordinates.
|
240
|
+
coordinates = [to_row(row), column.to_i - 1]
|
241
|
+
end
|
242
|
+
|
243
|
+
def to_row(alphanumeric_coord)
|
244
|
+
## This maps alpha row coordinate to its appropriate Jedec:
|
245
|
+
number = alphanumeric_coord.upcase.tr('A-HJ-NPRT-WY', '1-9a-q').to_i(21) - 1
|
246
|
+
number -= (number / 21)
|
247
|
+
end
|
248
|
+
|
249
|
+
def letter?(test_character)
|
250
|
+
## Returns nil if the 'test_character' isn't a letter.
|
251
|
+
test_character =~ /[[:alpha:]]/
|
252
|
+
end
|
253
|
+
|
254
|
+
def initial(test_string)
|
255
|
+
test_string[0, 1]
|
256
|
+
end
|
257
|
+
|
258
|
+
# .plot can be called explicitly and accepts string arguments with
|
259
|
+
# or without regex styling. For example:
|
260
|
+
#
|
261
|
+
# $dut.package = :t4240
|
262
|
+
# $dut.package.plot("ddr_interface") # plots all "ddr interface" groups
|
263
|
+
# $dut.package.plot("grounds") # adds ground pins to the previously instantiated plot
|
264
|
+
# $dut.package.plot("d1_mdq37","$") # plots controller 1 mdq 37, and uses $ as a legend marker
|
265
|
+
# $dut.package.plot("d2_mdq[3-6]0) # plots d2_mdq30, d2_mdq40, d2_md520, and d2_md620
|
266
|
+
#
|
267
|
+
def plot(pinName, marker = nil)
|
268
|
+
prepare_plot if field.nil?
|
269
|
+
if plottable && pinName.is_a?(String) && /ground/ =~ pinName.downcase
|
270
|
+
add_grounds('G')
|
271
|
+
elsif plottable && pinName.is_a?(String) && /power/ =~ pinName.downcase
|
272
|
+
add_power('P')
|
273
|
+
elsif plottable && pinName.is_a?(String)
|
274
|
+
found_pins = []
|
275
|
+
owner.pins.map { |pin| found_pins << pin[1] if /#{pinName}/ =~ pin[1].name.to_s || /#{pinName}/ =~ pin[1].group.to_s }
|
276
|
+
if found_pins.size == 1 && marker.nil?
|
277
|
+
marker = initial(pinName.to_s)
|
278
|
+
while @groups.index { |grpName| grpName =~ /#{marker} -/ }
|
279
|
+
marker.next!
|
280
|
+
marker = '0' unless marker.size < 2
|
281
|
+
end
|
282
|
+
coordinates = coordinate(found_pins[0].location)
|
283
|
+
@field[coordinates[0]][coordinates[1]] = [marker.white_on_blue + ' ']
|
284
|
+
@groups.delete_if { |group| /#{pinName.to_s}/ =~ group }
|
285
|
+
@groups << "#{marker} - #{found_pins[0].name} - #{found_pins[0].location}"
|
286
|
+
elsif found_pins.size == 1
|
287
|
+
coordinates = coordinate(found_pins[0].location)
|
288
|
+
@field[coordinates[0]][coordinates[1]] = [marker.white_on_blue + ' ']
|
289
|
+
@groups.delete_if { |group| /#{pinName.to_s}/ =~ group }
|
290
|
+
@groups << "#{marker} - #{found_pins[0].name} - #{found_pins[0].location}"
|
291
|
+
else
|
292
|
+
if marker.nil?
|
293
|
+
marker = initial(pinName.to_s)
|
294
|
+
while @groups.index { |grpName| grpName =~ /#{marker} -/ }
|
295
|
+
marker.next!
|
296
|
+
marker = '0' unless marker.size < 2
|
297
|
+
end
|
298
|
+
end
|
299
|
+
reg_state = quote_regex(pinName)
|
300
|
+
found_pins.each do |item|
|
301
|
+
begin
|
302
|
+
coordinates = coordinate(item.location)
|
303
|
+
@field[coordinates[0]][coordinates[1]] = [marker + ' ']
|
304
|
+
@groups.delete_if { |group| "#{marker} - \"#{reg_state}\"" == group }
|
305
|
+
@groups << "#{marker} - \"#{pinName}\""
|
306
|
+
rescue
|
307
|
+
raise "\n#{item} doesn't appear to have a physical location in this configuration."
|
308
|
+
end
|
309
|
+
end
|
310
|
+
end
|
311
|
+
generate_field
|
312
|
+
else
|
313
|
+
puts 'Unsupported argument type.'
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
317
|
+
# .plot_coord can be called explicitly and accepts string arguments in the form
|
318
|
+
# of jedec standard BGA coordinate naming conventions.
|
319
|
+
#
|
320
|
+
# $dut.package = :t4240
|
321
|
+
# $dut.package.plot_coord("A2")
|
322
|
+
#
|
323
|
+
def plot_coord(coord, marker = nil)
|
324
|
+
prepare_plot if field.nil?
|
325
|
+
if plottable
|
326
|
+
if coord.is_a?(String)
|
327
|
+
found_pins = []
|
328
|
+
owner.pins.map { |pin| found_pins << pin[1] if coord == pin[1].location.to_s }
|
329
|
+
if marker.nil?
|
330
|
+
marker = initial(coord.to_s)
|
331
|
+
while @groups.index { |grpName| grpName =~ /#{marker} -/ }
|
332
|
+
marker.next!
|
333
|
+
marker = '0' unless marker.size < 2
|
334
|
+
end
|
335
|
+
found_pins.each do |pin|
|
336
|
+
coordinates = coordinate(pin.location)
|
337
|
+
@field[coordinates[0]][coordinates[1]] = [marker.white_on_blue + ' ']
|
338
|
+
@groups.delete_if { |group| /#{coord.to_s}/ =~ group }
|
339
|
+
@groups << "#{marker} - #{found_pins[0].name} - #{found_pins[0].location}"
|
340
|
+
end
|
341
|
+
else
|
342
|
+
coordinates = coordinate(found_pins[0].location)
|
343
|
+
@field[coordinates[0]][coordinates[1]] = [marker.white_on_blue + ' ']
|
344
|
+
@groups.delete_if { |group| /#{coord.to_s}/ =~ group }
|
345
|
+
@groups << "#{marker} - #{found_pins[0].name} - #{found_pins[0].location}"
|
346
|
+
end
|
347
|
+
if found_pins.size > 0
|
348
|
+
generate_field
|
349
|
+
else
|
350
|
+
puts "Coordinate not recognized. Jedec convention: <row><col>. E.g., A1.\nCould be power/ground pin. .plot(\"power\") or .plot(\"ground\")."
|
351
|
+
end
|
352
|
+
else
|
353
|
+
puts 'Unsupported argument type.'
|
354
|
+
end
|
355
|
+
end
|
356
|
+
end
|
357
|
+
alias_method :plot_coordinate, :plot_coord
|
358
|
+
|
359
|
+
def quote_regex(regex_statement)
|
360
|
+
with_escapes = regex_statement
|
361
|
+
with_escapes.gsub!('[', '\[')
|
362
|
+
with_escapes.gsub!(']', '\]')
|
363
|
+
with_escapes.gsub!('^', '\^')
|
364
|
+
with_escapes
|
365
|
+
end
|
366
|
+
|
367
|
+
def plot_ceo
|
368
|
+
scramble = [' +....~~~~~:,,..::~~:,......,:~==~,,....,:~==~~::,:~~,., ',
|
369
|
+
' ...++~:,,:~~~~~======~::::,,,,::=======~~::,, ',
|
370
|
+
'.................????????+,,,,::::::,,,.,,..,,,,:::????......................:+',
|
371
|
+
' ,.,:~~~~~:,~~~~:~:~~=~:~~~==++====::~~~===~~=~~==:,, ',
|
372
|
+
' ,....~++?:::,,::::~~~=======+============~~~:,~ ',
|
373
|
+
' ....+++,:,,::::~~~==========~===========~:,:,~ ',
|
374
|
+
' ,........~~~~~~============================~........: ',
|
375
|
+
' ......,~~~~~~~===~++==+=+++++++++++++++++====~===~~~.....~ ',
|
376
|
+
' ,,,::::::~~~~:,,:::,,,,:,,,,......:~~:~::,,: ',
|
377
|
+
' .....,::~~~~=============+++++++++++++++++=======~~~:..... ',
|
378
|
+
' +.,::::::~~~=~=~~~~~~~====~~~~~:::~~==~~::::, ',
|
379
|
+
' .......:~~~~=~=======++++++++++++++++++======~~........ ',
|
380
|
+
' +:,,::~===+++++====+====~~~=====~====+++++++++=~~,~+ ',
|
381
|
+
'.....................,===+??????? ,..........????????=:,....................',
|
382
|
+
'...................=????????++++:,::::::::::::::???????~.......................',
|
383
|
+
'......................+++++?????? .............=??????+:,....................',
|
384
|
+
' =~:,::~~++=~=::,,,,,,,,,: ',
|
385
|
+
' +.........,,,,,,...,,,:,,,........,,,........,? ',
|
386
|
+
' :....::~~~=========+++++++++++++++++++++++=======~~:.... ',
|
387
|
+
'...................,+???????????? ?::,:,,,,,,::????????=,......................',
|
388
|
+
'..................~???????++++,::,::::::~~:::::::+?????:.......................',
|
389
|
+
' :......:~~~~~~~=====+++++++++++++++++++++=+=====~~~......= ',
|
390
|
+
' ::,::::~~===++===:.,~~~~~~===~~~~~,,:======~~::, ',
|
391
|
+
' ,,,::::~~~~~~~~~=~~===~~~~===~=====~~~~~~:::,~ ',
|
392
|
+
'....................::~+??????? =~+ ?????+?+=,.....................',
|
393
|
+
' :,.,~~~~~,:~~~......~,,..:~=+++=~:,..:,.......:~~=~:,~ ',
|
394
|
+
' :........:~~~~~~~~~===============~~~====:,....... ',
|
395
|
+
' ::,::~~===+++++++++==~~~~=======~~====+++++==~~::: ',
|
396
|
+
' ....,:~~~~~========++++++++++++++++++++++=+=====~~~:.... ',
|
397
|
+
' ,......,~~~~~~~=======+++++++++++++++++++=====~~~....... ',
|
398
|
+
' ,........+???~:::,,,,,:~~~~==============~~~~:,,?...? ',
|
399
|
+
' ...,~~~~~,.,~=====~:,.,.,:~==+==:,,,,.,,.,,~==~::=~,,~ ',
|
400
|
+
' ,........,:::::,:::::~~~~~~~:::,,,,,,~::.......,= ',
|
401
|
+
' ::,::~:~~======~:.,~::,,,,,,,,,,,~=.,:~===~~~::, ',
|
402
|
+
'.........................???++?????====.........?????~,??+::,..................',
|
403
|
+
' ......:~:~~~=~=========+=++++++++++++++++=======~~~~:..... ',
|
404
|
+
' ,...,..,.,,.,,,,,,.:::,.,,........? ',
|
405
|
+
'.......................?++??? ...............??????+::....................',
|
406
|
+
'...........................?+????? ??~....,...+?????????=::..................',
|
407
|
+
' ......:~:~~~~~====~======~==++===+++++===========~~~.....~ ',
|
408
|
+
'..........................+????? ?????+=........??????????~::..................',
|
409
|
+
' ....::~~~====+++++=======++++++++++==============~:...~ ',
|
410
|
+
'..........................?+?????? ?++=,........????????~+:::..................',
|
411
|
+
' .......:~~~~~~======+++++++++++++++++++++=====~~~:...... ',
|
412
|
+
'.......................~?????? :.......,.........??????~:,...................',
|
413
|
+
' ,,:::::~~=~~~:,~=~~~~~~:~~~~~~~====:~~=~~::::: ',
|
414
|
+
' ~,,:::::~=====:..~~~,.,:,,.,,,.~==~,:~===~~::,:= ',
|
415
|
+
' :,....::::,:,,,,,,,.,,,,,,..,:= ',
|
416
|
+
' ..............+?????=,,,,::,,,::~:~~~~~~~~~:::::,,::??..........~ ',
|
417
|
+
' ,,.:~~====~~~==~=~~~=====~~==+======~~~~~~===~===:,: ',
|
418
|
+
' ........~~~~~======+++++++++++++++++++=======~~....... ',
|
419
|
+
' ....::~~~~===============================~~~:~===~:... ',
|
420
|
+
' ,...........,...................,..........: ',
|
421
|
+
' +....:~~~~~~~,,..,,,,,.,:~~~~~===~~~~:,.,,,,,,,:~~~~.., ',
|
422
|
+
' .......~~~~~~~~=~==+==+++++++++++++=++++++==~====~~,.....: ',
|
423
|
+
'.................~???????+++,,,:,::::::,,,,,:,:::,?????........................',
|
424
|
+
' ~,.,:~==================~~~==+==~=========++++==~::: ',
|
425
|
+
' ,....,,,,,......,,,.,..:,:,..........:~ ',
|
426
|
+
'........................?????? ++=.,,:.........++=:?????=::...................',
|
427
|
+
' .......+++?:~:,,,,::~~~==================~~~:,,.? ',
|
428
|
+
'...................,:+?????????????? =:~:::::~ ???????++:......................',
|
429
|
+
' :....,::~~~~==~====+=+++++++++==+++++++++========~~~:....: ',
|
430
|
+
'.....................~~~+?????? ~:....: ????????=:.....................',
|
431
|
+
'....................::+?????????????????::,. ????????++~......................',
|
432
|
+
' ,...,,:,.,................,,::..........,= ',
|
433
|
+
' ~::,:~~~====+++++==~:~~~~==++===~=::~==++++==:::,: ',
|
434
|
+
' ~,.,~~~~~~~,..:~...~=~::,~~=++++=~~::~~~~~~:,,,~==~:, ',
|
435
|
+
'........................~??????=+?+~:~~.........???..????=::...................',
|
436
|
+
' ,..........+????:::,::,,,:~~~~~~==~~~~~~~~~~~~,.:=?......: ',
|
437
|
+
'................=???????~,,,::,:,:,,,.......,,,,,,:~???..................= ',
|
438
|
+
' ,,::::::~~~~~~~~~~=====~~~~=====~~~~=~~~::::, ',
|
439
|
+
' ........~~~~~========+++++++==++++=========~~........ ',
|
440
|
+
' :..+,,,:~~~~~======~~~==~===~~~~======~~~:::, ',
|
441
|
+
' ~.,,::~:~~~~~~~~~~~~~~~=======~=====~~~~::,: ',
|
442
|
+
' ..............:??????+,,,,:,,,,:,,,,,,,,....,..,,::~??.............., ',
|
443
|
+
' .,:~~:~:::::.....,:~=====~:::~~~:,::~~::,, ']
|
444
|
+
pw = [16, 47, 75, 168, 53, 36, 57, 116, 94, 21, 64, 52, 13, 95, 1, 17, 32, 38, 4, 142,
|
445
|
+
26, 6, 89, 134, 44, 71, 50, 40, 170, 149, 11, 29, 167, 27, 120, 43, 21, 107, 72, 14, 54,
|
446
|
+
7, 3, 58, 55, 39, 35, 47, 113, 5, 9, 61, 162, 123, 39, 28, 18, 36, 35, 91, 41, 51, 160,
|
447
|
+
128, 54, 53, 0, 138, 165, 125, 31, 25, 19, 155, 25, 66, 3, 15, 49, 96, 49, 56, 158, 100,
|
448
|
+
147, 12, 27, 101, 56, 12, 65, 22, 124, 106, 11, 33, 46, 26, 103, 7, 45, 23, 46, 97, 9,
|
449
|
+
70, 10, 109, 119, 22, 8, 75, 151, 65, 52, 73, 72, 99, 30, 17, 1, 5, 90, 76, 81, 4, 59,
|
450
|
+
50, 82, 84, 30, 68, 102, 148, 80, 48, 74, 129, 137, 132, 69, 2, 140, 34, 144, 55, 20,
|
451
|
+
150, 24, 143, 14, 19, 86, 8, 67, 60, 63, 2, 62, 146, 24, 62, 0, 104, 68, 13, 15, 173, 79,
|
452
|
+
63, 37, 44, 93, 85, 60, 58, 67]
|
453
|
+
y = []
|
454
|
+
(0..71).each { |n| y << n + n / 2 * 3 }
|
455
|
+
y.each do |z|
|
456
|
+
puts scramble[pw[z]]
|
457
|
+
end
|
458
|
+
'Oh, hello!'
|
459
|
+
end
|
460
|
+
end
|
461
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
module Origen
|
2
|
+
# Client for communicating with the Origen server
|
3
|
+
class Client
|
4
|
+
# This is based on the example here:
|
5
|
+
# https://github.com/jnunemaker/httparty/tree/v0.9.0
|
6
|
+
|
7
|
+
require 'json'
|
8
|
+
require 'httparty'
|
9
|
+
include HTTParty
|
10
|
+
|
11
|
+
USE_DEV_SERVER = false
|
12
|
+
DEV_PORT = 3000
|
13
|
+
|
14
|
+
def post(path, options = {})
|
15
|
+
options[:port] = port
|
16
|
+
self.class.post("#{url}/#{path}", options)
|
17
|
+
end
|
18
|
+
|
19
|
+
def get(path, options = {})
|
20
|
+
self.class.get("#{url}/#{path}", options)
|
21
|
+
end
|
22
|
+
|
23
|
+
def url
|
24
|
+
"http://origen-hub.am.freescale.net:#{port}/api"
|
25
|
+
end
|
26
|
+
|
27
|
+
def port
|
28
|
+
USE_DEV_SERVER ? DEV_PORT : 80
|
29
|
+
end
|
30
|
+
|
31
|
+
def record_invocation(command)
|
32
|
+
data = {
|
33
|
+
user: Origen.current_user.core_id,
|
34
|
+
application: Origen.app.config.initials,
|
35
|
+
app_version: Origen.app.version,
|
36
|
+
origen_version: Origen.version,
|
37
|
+
command: command,
|
38
|
+
platform: Origen.running_on_windows? ? 'windows' : 'linux'
|
39
|
+
}
|
40
|
+
post('record_invocation', body: data)
|
41
|
+
end
|
42
|
+
|
43
|
+
# Returns an array of data packets for all plugins
|
44
|
+
def plugins
|
45
|
+
return @plugins if @plugins
|
46
|
+
response = get('plugins')
|
47
|
+
@plugins = JSON.parse(response.body, symbolize_names: true)[:plugins]
|
48
|
+
end
|
49
|
+
|
50
|
+
def plugin(name)
|
51
|
+
response = get("plugins/#{name}")
|
52
|
+
JSON.parse(response.body, symbolize_names: true)[:plugin]
|
53
|
+
end
|
54
|
+
|
55
|
+
# Returns a data packet for Origen core
|
56
|
+
def origen
|
57
|
+
@origen ||= begin
|
58
|
+
response = get('plugins/origen_core')
|
59
|
+
JSON.parse(response.body, symbolize_names: true)[:plugin]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
alias_method :origen_core, :origen
|
63
|
+
|
64
|
+
# This will be called by the Origen release process to post
|
65
|
+
# the latest app version information to the server
|
66
|
+
def release!
|
67
|
+
version = Origen.app.version
|
68
|
+
body = { version: version.to_s }
|
69
|
+
if version.production?
|
70
|
+
body[:type] = :production
|
71
|
+
else
|
72
|
+
body[:type] = :development
|
73
|
+
end
|
74
|
+
post("plugins/#{Origen.app.name}/release", body: body)
|
75
|
+
end
|
76
|
+
|
77
|
+
# Returns the latest production Origen version
|
78
|
+
def latest_production
|
79
|
+
Origen::VersionString.new(origen[:latest_version_prod])
|
80
|
+
end
|
81
|
+
|
82
|
+
# Returns the latest developmen Origen version
|
83
|
+
def latest_development
|
84
|
+
Origen::VersionString.new(origen[:latest_version_dev])
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|