Sha256: e34b32f4ec539dde30af55c3523f3fced9c37a5aa9c68a44e71392963c3a1126

Contents?: true

Size: 1.28 KB

Versions: 5

Compression:

Stored size: 1.28 KB

Contents

class Ecu
  class Kennfeld < Label
    def self.dcm_header
      %r{^KENNFELD\s+(?<name>[A-Za-z0-9\._]+)\s+(?<xdim>\d+)\s+(?<ydim>\d+)}
    end

    def to_dcm(indented=false)
      fmtstr = indented ? "%-25s%s %s %s\n" : "%s %s %d %d\n"

      sprintf(fmtstr, type.upcase, name, xdim, ydim).tap do |str|
        str << "  LANGNAME #{description.enquote}\n" if description
        str << "  FUNKTION #{function}\n"            if function
        str << "  EINHEIT_X #{xunit.enquote}\n"      if xunit
        str << "  EINHEIT_Y #{yunit.enquote}\n"      if yunit
        str << "  EINHEIT_W #{unit.enquote}\n"       if unit
        str << case xvalue.first
              when Numeric then "  ST/X #{xvalue.join("   ")}\n"
              when String  then "  ST_TX/X #{xvalue.map(&:enquote).join("   ")}\n"
              end
        yvalue.each_with_index do |entry, idx|
          str << case entry
                when Numeric then "  ST/Y #{entry}\n"
                when String  then "  ST_TX/Y #{entry.enquote}\n"
                end
          str << case value[idx].first
                when Numeric then "  WERT #{value[idx].join("   ")}\n"
                when String  then "  TEXT #{value[idx].map(&:enquote).join("   ")}\n"
                end
        end
        str << "END\n"
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
automotive-ecu-0.1.10 lib/ecu/interfaces/dcm/kennfeld.rb
automotive-ecu-0.1.9 lib/ecu/interfaces/dcm/kennfeld.rb
automotive-ecu-0.1.8 lib/ecu/interfaces/dcm/kennfeld.rb
automotive-ecu-0.1.7 lib/ecu/interfaces/dcm/kennfeld.rb
automotive-ecu-0.1.6 lib/ecu/interfaces/dcm/kennfeld.rb