automotive-ecu 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ad47ed36e2d54205a5c804187b85e2f2a7b91d73f2fc1bc548f691a87804c88
4
- data.tar.gz: 2ab14530309248995b479e9dc4010bf61a83f767efd62ddf9b739686791aaae5
3
+ metadata.gz: fb1a271295db80e88f49dff193115be32c7615485818d3b39b5af7a6c6e153a2
4
+ data.tar.gz: fd7bc67a0a75965cd659d812de45017f0e18581dadcb7cad4138e10abbd87109
5
5
  SHA512:
6
- metadata.gz: de3516033d423a95b0c813f3e22eed22a0195fbbf5c4d7b2dc6f3604d897d59bd4b7bc46f0b527651fa5f3c1ffecec4cc3642e3f1482033b0104154088abdb44
7
- data.tar.gz: ebaf253e55c358547cb63ad4024a8bf0e90c6bb7a529b5ab30a9117593436aacd15d546bd226a5cf7a02156edfe2193c94e67f51e59fc9545c6b9688cd35b45b
6
+ metadata.gz: 2f81b12bb0040f73348c996c4ed99a060a08036a77fd0d873b8b1897674354a8c96e77af239fa7ddad4b03ffc77606a44af1856c003446f784561e531543a3c8
7
+ data.tar.gz: 03cfce4b5c36725aa715e2e04deecb0baef10c5548aa2befa64ea9b0724e5d4b0a5d515343da28235a0839c5a230c91b6871eb8b622098dc7497f4da72ac6800
data/bin/console CHANGED
@@ -2,13 +2,6 @@
2
2
 
3
3
  require "bundler/setup"
4
4
  require "ecu"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
5
  require "irb"
6
+
14
7
  IRB.start
data/lib/core_ext.rb CHANGED
@@ -16,14 +16,6 @@ class String
16
16
  def enquote
17
17
  "\"#{to_s}\""
18
18
  end
19
-
20
- def to_regexp(ignorecase: false, multiline: false, extended: false)
21
- options = 0
22
- options = options | Regexp::EXTENDED if extended
23
- options = options | Regexp::IGNORECASE if ignorecase
24
- options = options | Regexp::MULTILINE if multiline
25
- Regexp.new(self, options)
26
- end
27
19
  end
28
20
 
29
21
  class Array
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "strscan"
2
4
 
3
5
  class Ecu
@@ -44,16 +46,19 @@ class Ecu
44
46
 
45
47
 
46
48
  def next_token
49
+ # This is a hot path during DCM parsing. Make sure to optimize
50
+ # here are far as possible
51
+
47
52
  @scan.skip(WHITESPACE)
48
53
 
49
54
  return if @scan.eos?
50
55
 
51
56
  case @doc.getbyte(@scan.pos)
52
- when 10, 13 then @scan.skip(NEWLINE) && :NEWLINE # \n \r
53
- when 34 then @scan.skip(QUOTED_TEXT) && :QUOTED_TEXT # "
54
- when 42 then @scan.skip(COMMENT) && :COMMENT # *
57
+ when 10, 13 then @scan.skip(NEWLINE) && :NEWLINE # \n \r
58
+ when 34 then @scan.skip(QUOTED_TEXT) && :QUOTED_TEXT # "
59
+ when 42 then @scan.skip(COMMENT) && :COMMENT # *
55
60
  when 64 then @scan.skip(DIMENSIONS_SEP) && :DIMENSIONS_SEP # @
56
- when 43, 45, 46, 48..57 # + - . 0-9
61
+ when 43, 45, 46, 48..57 # + - . 0-9
57
62
  if @scan.skip(FLOAT) then :FLOAT
58
63
  elsif @scan.skip(INT) then :INT
59
64
  else @scan.getch; :UNKNOWN_CHAR
@@ -71,6 +76,11 @@ class Ecu
71
76
  @scan.matched
72
77
  end
73
78
 
79
+ # Extracts quoted-text content without surrounding quotes in a single allocation.
80
+ def quoted_value
81
+ @scan.string.byteslice(@scan.pos - @scan.matched_size + 1, @scan.matched_size - 2)
82
+ end
83
+
74
84
  def lineno
75
85
  @doc.byteslice(0, @scan.pos).count("\n") +
76
86
  (@scan.beginning_of_line? ? 0 : 1)
@@ -1,11 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative "dcm_lexer"
2
4
  require_relative "dcm_parser_error"
5
+ require "set"
3
6
 
4
7
  class Ecu
5
8
  class LabelList
6
9
  class DcmParser
7
10
 
8
- ARY_PROPERTIES = %i( xvalue yvalue value )
11
+ ARY_PROPERTIES = Set.new([:xvalue, :yvalue, :value]).freeze
9
12
  KEY_MAPPING = {
10
13
  "ST/X": :xvalue,
11
14
  "ST/Y": :yvalue,
@@ -28,6 +31,7 @@ class Ecu
28
31
  @labels = []
29
32
  @headers = []
30
33
  @subheaders = []
34
+ @properties = {}
31
35
  reset_label!
32
36
  end
33
37
 
@@ -108,7 +112,7 @@ class Ecu
108
112
  end
109
113
  when :TEXT_PROPERTY
110
114
  case tok
111
- when :QUOTED_TEXT then append_property(lexer.token_value[1..-2])
115
+ when :QUOTED_TEXT then append_property(lexer.quoted_value)
112
116
  when :NEWLINE then finish_property
113
117
  else raise DcmParserError.new("Unexpected token #{debug_token(tok)} (state: #{@state})", lexer)
114
118
  end
@@ -214,7 +218,7 @@ class Ecu
214
218
 
215
219
  def reset_label!
216
220
  @constructor = nil
217
- @properties = {}
221
+ @properties.clear
218
222
  @key = nil
219
223
  @is_ary = false
220
224
  @value = nil
@@ -54,5 +54,14 @@ class Ecu
54
54
  def equality_properties
55
55
  [:name, :value]
56
56
  end
57
+
58
+ def self.sample(suffix="")
59
+ new \
60
+ name: PropertyGenerator.name(prefix: "PAR", suffix: suffix),
61
+ value: PropertyGenerator.value([true, false].sample),
62
+ unit: PropertyGenerator.unit,
63
+ function: PropertyGenerator.function,
64
+ description: PropertyGenerator.description
65
+ end
57
66
  end
58
67
  end
@@ -66,6 +66,20 @@ class Ecu
66
66
  [:name, :value]
67
67
  end
68
68
 
69
+ def self.sample(suffix="")
70
+ xdim = (1..10).to_a.sample
71
+ ydim = (1..10).to_a.sample
72
+ numeric = [true, false].sample
73
+ new \
74
+ name: PropertyGenerator.name(prefix: %w(VEC MAT).sample, suffix: suffix),
75
+ xdim: xdim,
76
+ ydim: ydim,
77
+ value: ydim.times.map { xdim.times.map { PropertyGenerator.value(numeric) } },
78
+ unit: PropertyGenerator.unit,
79
+ function: PropertyGenerator.function,
80
+ description: PropertyGenerator.description
81
+ end
82
+
69
83
  private
70
84
 
71
85
  def reshape_if_needed(value, xdim, ydim)
@@ -105,5 +105,24 @@ class Ecu
105
105
  [:name, :xvalue, :yvalue, :value]
106
106
  end
107
107
 
108
+ def self.sample(suffix="")
109
+ xdim = (2..10).to_a.sample
110
+ ydim = (2..10).to_a.sample
111
+ xnumeric = [true, true, false].sample
112
+ ynumeric = [true, true, false].sample
113
+ numeric = [true, true, false].sample
114
+ new \
115
+ name: PropertyGenerator.name(prefix: "MAP", suffix: suffix),
116
+ xdim: xdim,
117
+ ydim: ydim,
118
+ xvalue: xdim.times.map { PropertyGenerator.value(xnumeric) },
119
+ yvalue: ydim.times.map { PropertyGenerator.value(ynumeric) },
120
+ value: ydim.times.map { xdim.times.map { PropertyGenerator.value(numeric) } },
121
+ xunit: PropertyGenerator.unit,
122
+ yunit: PropertyGenerator.unit,
123
+ unit: PropertyGenerator.unit,
124
+ function: PropertyGenerator.function,
125
+ description: PropertyGenerator.description
126
+ end
108
127
  end
109
128
  end
@@ -80,5 +80,19 @@ class Ecu
80
80
  [:name, :xvalue, :value, :type]
81
81
  end
82
82
 
83
+ def self.sample(suffix="")
84
+ xdim = (1..10).to_a.sample
85
+ xnumeric = [true, false].sample
86
+ numeric = [true, false].sample
87
+ new \
88
+ name: PropertyGenerator.name(prefix: "CRV", suffix: suffix),
89
+ xdim: xdim,
90
+ xvalue: xdim.times.map { PropertyGenerator.value(xnumeric) },
91
+ value: xdim.times.map { PropertyGenerator.value(numeric) },
92
+ unit: PropertyGenerator.unit,
93
+ xunit: PropertyGenerator.unit,
94
+ function: PropertyGenerator.function,
95
+ description: PropertyGenerator.description
96
+ end
83
97
  end
84
98
  end
@@ -1,6 +1,7 @@
1
1
  require_relative "../interfaces/dcm/label"
2
2
  require_relative "../interfaces/lab/label"
3
3
 
4
+ require_relative "property_generator"
4
5
  require_relative "value_comparison"
5
6
  require_relative "value_printer"
6
7
 
@@ -0,0 +1,38 @@
1
+ class Ecu
2
+ class PropertyGenerator
3
+ PREFIXES = %w(PAR VEC MAT CRV MAP)
4
+ FCN1 = %w(Ldp Dmc Dcr Wc Sns)
5
+ FCN2 = %w(Pa Etf Btf Ca Tqz Msc Tqx Tqa Tqb)
6
+ TYPE = %w(ww tqw st a ax cw b sx vx v r)
7
+ LOC = %w(FL FR RL RR FA RA)
8
+ DESC = %w(Foo Bar Baz Lala Hulu)
9
+ UNIT = %w(Nm rad/s m s m/s^2 m/s -)
10
+
11
+ def self.name(prefix: nil, suffix: "")
12
+ (prefix || PREFIXES.sample) + "_" +
13
+ FCN1.sample + FCN2.sample + "_" +
14
+ TYPE.sample + (LOC + [""]).sample + "_" +
15
+ DESC.sample + DESC.sample + suffix.to_s
16
+ end
17
+
18
+ def self.unit
19
+ UNIT.sample
20
+ end
21
+
22
+ def self.function
23
+ FCN1.sample + FCN2.sample
24
+ end
25
+
26
+ def self.description
27
+ "foo bar"
28
+ end
29
+
30
+ def self.value(numeric=true)
31
+ if numeric
32
+ rand(-1e3..1e3)
33
+ else
34
+ %w(true false).sample
35
+ end
36
+ end
37
+ end
38
+ end
@@ -61,5 +61,16 @@ class Ecu
61
61
  [:name, :xvalue]
62
62
  end
63
63
 
64
+ def self.sample(suffix="")
65
+ xdim = (1..10).to_a.sample
66
+ numeric = [true, false].sample
67
+ new \
68
+ name: PropertyGenerator.name(prefix: %w(AXX AXY).sample, suffix: suffix),
69
+ xdim: xdim,
70
+ xvalue: xdim.times.map { PropertyGenerator.value(numeric) },
71
+ xunit: PropertyGenerator.unit,
72
+ function: PropertyGenerator.function,
73
+ description: PropertyGenerator.description
74
+ end
64
75
  end
65
76
  end
data/lib/ecu/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Ecu
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: automotive-ecu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Mueller
@@ -87,15 +87,9 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
- - bin/bundle
91
- - bin/coderay
92
90
  - bin/console
93
91
  - bin/htmldiff
94
- - bin/irb
95
92
  - bin/ldiff
96
- - bin/pry
97
- - bin/rake
98
- - bin/rspec
99
93
  - bin/sandbox
100
94
  - bin/setup
101
95
  - lib/core_ext.rb
@@ -143,6 +137,7 @@ files:
143
137
  - lib/ecu/labels/label.rb
144
138
  - lib/ecu/labels/label_list.rb
145
139
  - lib/ecu/labels/label_list_comparison.rb
140
+ - lib/ecu/labels/property_generator.rb
146
141
  - lib/ecu/labels/stuetzstellenverteilung.rb
147
142
  - lib/ecu/labels/value_comparison.rb
148
143
  - lib/ecu/labels/value_printer.rb
@@ -169,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
164
  - !ruby/object:Gem::Version
170
165
  version: '0'
171
166
  requirements: []
172
- rubygems_version: 4.0.10
167
+ rubygems_version: 4.0.14
173
168
  specification_version: 4
174
169
  summary: A simple API for managing automotive ecu signals and labels
175
170
  test_files: []
data/bin/bundle DELETED
@@ -1,114 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- #
5
- # This file was generated by Bundler.
6
- #
7
- # The application 'bundle' is installed as part of a gem, and
8
- # this file is here to facilitate running it.
9
- #
10
-
11
- require "rubygems"
12
-
13
- m = Module.new do
14
- module_function
15
-
16
- def invoked_as_script?
17
- File.expand_path($0) == File.expand_path(__FILE__)
18
- end
19
-
20
- def env_var_version
21
- ENV["BUNDLER_VERSION"]
22
- end
23
-
24
- def cli_arg_version
25
- return unless invoked_as_script? # don't want to hijack other binstubs
26
- return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
27
- bundler_version = nil
28
- update_index = nil
29
- ARGV.each_with_index do |a, i|
30
- if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
31
- bundler_version = a
32
- end
33
- next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
34
- bundler_version = $1
35
- update_index = i
36
- end
37
- bundler_version
38
- end
39
-
40
- def gemfile
41
- gemfile = ENV["BUNDLE_GEMFILE"]
42
- return gemfile if gemfile && !gemfile.empty?
43
-
44
- File.expand_path("../../gems.rb", __FILE__)
45
- end
46
-
47
- def lockfile
48
- lockfile =
49
- case File.basename(gemfile)
50
- when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
51
- else "#{gemfile}.lock"
52
- end
53
- File.expand_path(lockfile)
54
- end
55
-
56
- def lockfile_version
57
- return unless File.file?(lockfile)
58
- lockfile_contents = File.read(lockfile)
59
- return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
60
- Regexp.last_match(1)
61
- end
62
-
63
- def bundler_version
64
- @bundler_version ||=
65
- env_var_version || cli_arg_version ||
66
- lockfile_version
67
- end
68
-
69
- def bundler_requirement
70
- return "#{Gem::Requirement.default}.a" unless bundler_version
71
-
72
- bundler_gem_version = Gem::Version.new(bundler_version)
73
-
74
- requirement = bundler_gem_version.approximate_recommendation
75
-
76
- return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0")
77
-
78
- requirement += ".a" if bundler_gem_version.prerelease?
79
-
80
- requirement
81
- end
82
-
83
- def load_bundler!
84
- ENV["BUNDLE_GEMFILE"] ||= gemfile
85
-
86
- activate_bundler
87
- end
88
-
89
- def activate_bundler
90
- gem_error = activation_error_handling do
91
- gem "bundler", bundler_requirement
92
- end
93
- return if gem_error.nil?
94
- require_error = activation_error_handling do
95
- require "bundler/version"
96
- end
97
- return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
98
- warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
99
- exit 42
100
- end
101
-
102
- def activation_error_handling
103
- yield
104
- nil
105
- rescue StandardError, LoadError => e
106
- e
107
- end
108
- end
109
-
110
- m.load_bundler!
111
-
112
- if m.invoked_as_script?
113
- load Gem.bin_path("bundler", "bundle")
114
- end
data/bin/coderay DELETED
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- #
5
- # This file was generated by Bundler.
6
- #
7
- # The application 'coderay' is installed as part of a gem, and
8
- # this file is here to facilitate running it.
9
- #
10
-
11
- require "pathname"
12
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../gems.rb",
13
- Pathname.new(__FILE__).realpath)
14
-
15
- bundle_binstub = File.expand_path("../bundle", __FILE__)
16
-
17
- if File.file?(bundle_binstub)
18
- if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
- load(bundle_binstub)
20
- else
21
- abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
- Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
- end
24
- end
25
-
26
- require "rubygems"
27
- require "bundler/setup"
28
-
29
- load Gem.bin_path("coderay", "coderay")
data/bin/irb DELETED
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- #
5
- # This file was generated by Bundler.
6
- #
7
- # The application 'irb' is installed as part of a gem, and
8
- # this file is here to facilitate running it.
9
- #
10
-
11
- require "pathname"
12
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../gems.rb",
13
- Pathname.new(__FILE__).realpath)
14
-
15
- bundle_binstub = File.expand_path("../bundle", __FILE__)
16
-
17
- if File.file?(bundle_binstub)
18
- if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
- load(bundle_binstub)
20
- else
21
- abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
- Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
- end
24
- end
25
-
26
- require "rubygems"
27
- require "bundler/setup"
28
-
29
- load Gem.bin_path("irb", "irb")
data/bin/pry DELETED
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- #
5
- # This file was generated by Bundler.
6
- #
7
- # The application 'pry' is installed as part of a gem, and
8
- # this file is here to facilitate running it.
9
- #
10
-
11
- require "pathname"
12
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../gems.rb",
13
- Pathname.new(__FILE__).realpath)
14
-
15
- bundle_binstub = File.expand_path("../bundle", __FILE__)
16
-
17
- if File.file?(bundle_binstub)
18
- if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
- load(bundle_binstub)
20
- else
21
- abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
- Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
- end
24
- end
25
-
26
- require "rubygems"
27
- require "bundler/setup"
28
-
29
- load Gem.bin_path("pry", "pry")
data/bin/rake DELETED
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- #
5
- # This file was generated by Bundler.
6
- #
7
- # The application 'rake' is installed as part of a gem, and
8
- # this file is here to facilitate running it.
9
- #
10
-
11
- require "pathname"
12
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../gems.rb",
13
- Pathname.new(__FILE__).realpath)
14
-
15
- bundle_binstub = File.expand_path("../bundle", __FILE__)
16
-
17
- if File.file?(bundle_binstub)
18
- if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
- load(bundle_binstub)
20
- else
21
- abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
- Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
- end
24
- end
25
-
26
- require "rubygems"
27
- require "bundler/setup"
28
-
29
- load Gem.bin_path("rake", "rake")
data/bin/rspec DELETED
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- #
5
- # This file was generated by Bundler.
6
- #
7
- # The application 'rspec' is installed as part of a gem, and
8
- # this file is here to facilitate running it.
9
- #
10
-
11
- require "pathname"
12
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../gems.rb",
13
- Pathname.new(__FILE__).realpath)
14
-
15
- bundle_binstub = File.expand_path("../bundle", __FILE__)
16
-
17
- if File.file?(bundle_binstub)
18
- if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
- load(bundle_binstub)
20
- else
21
- abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
- Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
- end
24
- end
25
-
26
- require "rubygems"
27
- require "bundler/setup"
28
-
29
- load Gem.bin_path("rspec-core", "rspec")