Module: OmfEc::Backward::AppDefinition

Included in:
AppDefinition
Defined in:
omf_ec/lib/omf_ec/backward/app_definition.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) defMeasurement(name, &block)

XXX: This should be provided by the omf-oml glue.



75
76
77
78
79
80
81
82
# File 'omf_ec/lib/omf_ec/backward/app_definition.rb', line 75

def defMeasurement(name,&block)
  mp = {:mp => name, :fields => []}
  @fields = []
  # call the block with ourserlves to process its 'defMetric' statements
  block.call(self) if block
  @fields.each { |f| mp[:fields] << f }
  define_measurement_point(mp)
end

- (Object) defMetric(name, type, opts = {})

Define metrics to measure

Examples:

OEDL

app.defMeasurement("power") do |mp|
  mp.defMetric('power', :double, :unit => "W", :precision => 0.1, :description => 'Power')
end

Parameters:

Options Hash (opts):

  • :unit (String)

    unit of measure of the metric

  • :description (String)

    of the metric

  • :precision (Float)

    precision of the metric value

  • :range (Range)

    value range of the metric



68
69
70
71
72
# File 'omf_ec/lib/omf_ec/backward/app_definition.rb', line 68

def defMetric(name,type, opts = {})
  # the third parameter used to be a description string
  opts = {:description => opts} if opts.class!=Hash
  @fields << {:field => name, :type => type}.merge(opts)
end

- (Object) defProperty(name = :mandatory, description = nil, parameter = nil, options = {})

Add a new parameter to this Application Definition. This method is for backward compatibility with previous OEDL 5.

The OML code-generation tool, oml2-scaffold extends the range of options supported in the options hash to support generation of popt(3) command line parsing code. As for the parameters, depending on the number of dashes (two/one) in parameter, it is used as the longName/shortName for popt(3), otherwise the former defaults to name, and the latter defaults to either :mnemonic or nothing.

Parameters:

  • name (String) (defaults to: :mandatory)

    name of the property to define (mandatory)

  • description (String) (defaults to: nil)

    description of this property; oml2-scaffold uses this for the help message (popt: descrip)

  • parameter (String) (defaults to: nil)

    command-line parameter to introduce this property, including dashes if needed (can be nil)

  • options (Hash) (defaults to: {})

    list of options associated with this property

Options Hash (options):

  • :type (String)

    type of the property: :integer, :string and :boolean are supported; oml2-scaffold extends this with :int and :double (popt: argInfo)

  • :dynamic (Boolean)

    true if the property can be changed at run-time

  • :order (Fixnum)

    used to order properties when creating the command line

  • :mnemonic (String)

    one-letter mnemonic for the option (also returned by poptGetNextOpt as val)

  • :unit (String)

    unit in which this property is expressed; oml2-scaffold uses this for the help message (popt: argDescrip)

  • :default (String)

    default value if argument unspecified (optional; defaults to something sane for the :type)

  • :var_name (String)

    name of the C variable for popt(3) to store the property value into (optional; popt: arg; defaults to name, after sanitisation)

See Also:



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'omf_ec/lib/omf_ec/backward/app_definition.rb', line 37

def defProperty(name = :mandatory, description = nil, parameter = nil, options = {})
  opts = {:description => description, :cmd => parameter}
  # Map old OMF5 types to OMF6
  # Map OMF app property types to Ruby types
  options[:type] = case options[:type]
                   when :integer, :int then 'Numeric'
                   when :string then 'String'
                   when :boolean then 'Boolean'
                   when :double then 'Float'
                   # For type that we cannot understand, DON'T send it
                   else nil
                   end
  opts = opts.merge(options)
  define_parameter(Hash[name,opts])
end