> Hmmmm... that is intriguing. Probably overkill for my immediate needs,
> but I see how a simplified version might do it for me. And definitely
> opens up some intriguing possibilities.
> 
> John, how do you think you'd hook a dyno up to the app... that could
> be VERY useful, given this little app's future.

While not being John, or even knowing a dyno from a dino... :)

Assuming you can get the data feed from the dyno in *some* sort
of computer-readable format (CSV, tab-sep values, XML, JSON,
YAML, column-delimited, whatever), you can simply ship that file
over to some Python code.  This could even theoretically be done
via a file-upload, as Django focuses on web-apps.  I usually ship
data around in tab-separated format, making it fairly easy to
then simply open the file, split it and assign the data.

  class Engine(Model):
    ...
    def load_torque(self, filename):
      """ assumes the file is of the format
          torque\trpm
      """
      for line in file(filename):
        try:
          torque, rpm = map(int, line.rstrip('\n').split('\t',1))
        except:  # bogus data on the line?
          continue
        reading = self.torquereading_set.objects.create(
          torque=torque, rpm=rpm)

I might have the syntax wrong on that
"torquereading_set.objects.create" bit, but it should give you
the idea.

Depending on how much data the dyno generates, or if you just
want the max, as you detailed, you could alter that a bit...


  max_torque = 0, at_rpm = 0
  for line in file(filename):
    try:
      torque, rpm = map(...)
    except:
      continue
    if torque > max_torque:
      max_torque, at_rpm = torque, rpm
  # by this point, max_torque and at_rpm hold the values for
  # the maximum torque reading from the data set

Or you could sample the data if you have thousands of readings:

  for i, line in enumerate(file(filename)):
    if i % 5 <> 0: continue
    # rest of the code from the first listing

which would sample every 5th line in the file.

Hope this gives you some ideas to work with...

-tim



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to