Class: Ecu

Inherits:
Object
  • Object
show all
Defined in:
lib/ecu/labels/value_printer.rb,
lib/ecu.rb,
lib/ecu/version.rb,
lib/ecu/labels/label.rb,
lib/ecu/combined_list.rb,
lib/ecu/signals/signal.rb,
lib/ecu/labels/festwert.rb,
lib/ecu/labels/kennfeld.rb,
lib/ecu/labels/kennlinie.rb,
lib/ecu/labels/label_list.rb,
lib/ecu/labels/interpolator.rb,
lib/ecu/signals/signal_list.rb,
lib/ecu/interfaces/dcm/label.rb,
lib/ecu/interfaces/lab/label.rb,
lib/ecu/interfaces/lab/signal.rb,
lib/ecu/labels/festwerteblock.rb,
lib/ecu/interfaces/dcm/festwert.rb,
lib/ecu/interfaces/dcm/kennfeld.rb,
lib/ecu/labels/value_comparison.rb,
lib/ecu/combined_list_comparison.rb,
lib/ecu/interfaces/dcm/functions.rb,
lib/ecu/interfaces/dcm/kennlinie.rb,
lib/ecu/interfaces/a2l/label_list.rb,
lib/ecu/interfaces/dcm/label_list.rb,
lib/ecu/interfaces/lab/label_list.rb,
lib/ecu/interfaces/mfile/festwert.rb,
lib/ecu/interfaces/mfile/kennfeld.rb,
lib/ecu/interfaces/a2l/signal_list.rb,
lib/ecu/interfaces/dbc/signal_list.rb,
lib/ecu/interfaces/lab/signal_list.rb,
lib/ecu/interfaces/mfile/kennlinie.rb,
lib/ecu/interfaces/dcm/festkennfeld.rb,
lib/ecu/interfaces/mfile/label_list.rb,
lib/ecu/interfaces/dcm/festkennlinie.rb,
lib/ecu/interfaces/lab/combined_list.rb,
lib/ecu/labels/label_list_comparison.rb,
lib/ecu/interfaces/dcm/festwerteblock.rb,
lib/ecu/interfaces/dcm/gruppenkennfeld.rb,
lib/ecu/interfaces/dcm/property_parser.rb,
lib/ecu/labels/stuetzstellenverteilung.rb,
lib/ecu/signals/signal_list_comparison.rb,
lib/ecu/interfaces/dcm/gruppenkennlinie.rb,
lib/ecu/interfaces/mfile/festwerteblock.rb,
lib/ecu/interfaces/dcm/malformed_dcm_error.rb,
lib/ecu/interfaces/dcm/stuetzstellenverteilung.rb,
lib/ecu/interfaces/mfile/stuetzstellenverteilung.rb

Overview

TODO: Shorten very long rows to max. display width or 80 characters

Defined Under Namespace

Classes: CombinedList, CombinedListComparison, DcmPropertyParser, Festkennfeld, Festkennlinie, Festwert, Festwerteblock, Functions, Gruppenkennfeld, Gruppenkennlinie, Interpolator, Kennfeld, Kennlinie, Label, LabelList, LabelListComparison, MalformedDcmError, Signal, SignalList, SignalListComparison, Stuetzstellenverteilung, ValueComparison, ValuePrinter

Constant Summary collapse

VERSION =
"0.1.1"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, signals: SignalList.new([]), labels: LabelList.new([]), **hsh) ⇒ Ecu

Returns a new instance of Ecu.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/ecu.rb', line 8

def initialize(name:, signals: SignalList.new([]), labels: LabelList.new([]), **hsh)
  @name    = name
  @signals = case signals
             when String     then SignalList.from_file(signals)
             when SignalList then signals
             else raise "Unknown signals format"
             end
  @labels  = case labels
             when String    then LabelList.from_file(labels)
             when LabelList then labels
             else raise "Unknown labels format"
             end
  @hsh = hsh
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object



50
51
52
53
54
# File 'lib/ecu.rb', line 50

def method_missing(m, *args, &block)
  @hsh.fetch(m) do
    raise ArgumentError.new("Cannot find property #{m}")
  end
end

Instance Attribute Details

#labelsObject (readonly)

Returns the value of attribute labels.



6
7
8
# File 'lib/ecu.rb', line 6

def labels
  @labels
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/ecu.rb', line 6

def name
  @name
end

#signalsObject (readonly)

Returns the value of attribute signals.



6
7
8
# File 'lib/ecu.rb', line 6

def signals
  @signals
end

Instance Method Details

#==(other) ⇒ Object



39
40
41
# File 'lib/ecu.rb', line 39

def ==(other)
  self.to_s == other.to_s
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/ecu.rb', line 42

def eql?(other)
  self == other
end

#hashObject



46
47
48
# File 'lib/ecu.rb', line 46

def hash
  name.hash
end

#inspectObject



35
36
37
# File 'lib/ecu.rb', line 35

def inspect
  "<Ecu: #{name}>"
end

#is_can?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/ecu.rb', line 23

def is_can?
  name[-3..-1] == "CAN"
end

#respond_to?(m, include_all = false) ⇒ Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/ecu.rb', line 56

def respond_to?(m, include_all=false)
  @hsh.keys.include?(m)
end

#shortnameObject



27
28
29
# File 'lib/ecu.rb', line 27

def shortname
  name.sub(/:.*/, "")
end

#to_sObject



31
32
33
# File 'lib/ecu.rb', line 31

def to_s
  name
end