Skip to content

Instantly share code, notes, and snippets.

@knowuh
Created December 9, 2011 20:39
Show Gist options
  • Select an option

  • Save knowuh/1453210 to your computer and use it in GitHub Desktop.

Select an option

Save knowuh/1453210 to your computer and use it in GitHub Desktop.
protoTypeGraphables
xml.OTDataCollector("local_id" => id, "name" => "datacollector", "multipleGraphableEnabled" => multi,
"title" => "#{pt.name} Sensor#{if predict_id then ' and Prediction' end} Graph", "autoScaleEnabled" => "true") {
if predict_id
xml.graphables {
xml.OTDataGraphable("connectPoints" => "true", "locked" => "true",
"color" => "0xff0000", "drawMarks" => "false", "name" => "Prediction",
"xColumn" => "0", "yColumn" => "1") {
xml.dataStore { otml_object_reference(xml, "#{predict_id}_datastore") }
}
}
end
graphableOpts = {
"connectPoints" => "true",
"color" => "0x0000ff",
"drawMarks" => "false",
"name" => "Sensor",
"xColumn" => "0",
"yColumn" => "1"
}
if multi
# (used as prototype when 'new' is clicked in multigraph
xml.prototypeGraphables {
xml.OTDataGraphable(graphableOpts) {
xml.dataProducer {
otml_calibration(pt,calibration,xml,"proto_#{id}")
}
}
}
end
xml.source {
xml.OTDataGraphable(graphableOpts) {
xml.dataProducer {
otml_calibration(pt,calibration,xml,id)
}
xml.dataStore { xml.OTDataStore("local_id" => "ds_#{id}") }
}
}
ot_axis(pt,xml,calibration)
}
# (elsewhere)
def otml_calibration(pt,calibration,xml,id)
if calibration
attributes = []
%w{ k0 k1 k2 k3 }.each do |coeff|
if calibration.data_filter.send("#{coeff}_active")
attributes << "'#{coeff}' => '#{calibration.send(coeff)}'"
end
attributes << "'sourceChannel' => '1'"
end
element_name = calibration.data_filter.otrunk_object_class[/(.*\.)(.*)/, 2]
eval("xml.#{element_name}(#{attributes.join(',')}) { xml.source { otml_sensor_data_proxy(xml, pt, id) } }")
else
otml_sensor_data_proxy(xml, pt, id)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment