lib/ecu/interfaces/dcm/festwerteblock.rb in automotive-ecu-0.1.3 vs lib/ecu/interfaces/dcm/festwerteblock.rb in automotive-ecu-0.1.4
- old
+ new
@@ -1,14 +1,16 @@
require_relative "../../../core_ext"
class Ecu
class Festwerteblock < Label
def self.dcm_header
- %r{FESTWERTEBLOCK\s+(?<name>[A-Za-z0-9\._]+)\s+(?<xdim>\d+)(?:\s+@\s+(?<ydim>\d+))?}
+ %r{^FESTWERTEBLOCK\s+(?<name>[A-Za-z0-9\._]+)\s+(?<xdim>\d+)(?:\s+@\s+(?<ydim>\d+))?}
end
- def to_dcm
- "FESTWERTEBLOCK #{name} #{xdim}".tap do |str|
+ def to_dcm(indented=false)
+ fmtstr = indented ? "%-26s%s %s" : "%s %s %d"
+
+ sprintf(fmtstr, type.upcase, name, xdim).tap do |str|
str << " @ #{ydim}" if ydim != 1
str << "\n"
str << " LANGNAME #{description.enquote}\n" if description
str << " FUNKTION #{function}\n" if function
str << " EINHEIT_W #{unit.enquote}\n" if unit