Page 2 of 53 FirstFirst 12345678910111252 ... LastLast
Results 11 to 20 of 529

Thread: Vehicle Maintenence Plugin

  1. #11
    Mo' Programming Mo' Problems
    Auto Apps:loading...
    Sonicxtacy02's Avatar
    Join Date
    Sep 2004
    Location
    Woodbridge, VA
    Posts
    8,168
    Blog Entries
    51
    i was actually considering that last night. Should be easily done. I'd also like to come up with a cost per mile readout based on the cost label for each maintenance item but i'm not sure how to handle it. one thing i did have to do is scale the mile reading back to once ever 2 seconds because my timer that handles the calculation took more than a second the calculate and save to file. Gonna run this over the weekend and see if i come up with anymore bugs but for the last 2 days its been rock solid.

    also forgot to mention the status indicators are user definable. They are based on 3 .jpg files in the skin file. green.jpg, yellow.jpg, and red.jpg.
    mp3Car.com Senior Tech Blogger (Want a product reviewed? Contact me.)
    Find my plugins on the MP3Car App Store!
    Follow Me on Twitter or Facebook
    Live mp3Car Facebook Chat

  2. #12
    Low Bitrate eigenVector's Avatar
    Join Date
    Apr 2009
    Posts
    80
    Quote Originally Posted by Sonicxtacy02 View Post
    one thing i did have to do is scale the mile reading back to once ever 2 seconds because my timer that handles the calculation took more than a second the calculate and save to file.
    What I like to do in this situation is queue the actual write to the file in a separate thread, so that the updates to the UI are pretty fast. Then on the background thread do bulk-writes to the file instead of one at a time. File access is much slower than in-memory access, but once you have a handle open for a file, you should be able to write lots of data to it quickly.

    Not sure what you're programming this in though.

    Great job, and good luck!

  3. #13
    Mo' Programming Mo' Problems
    Auto Apps:loading...
    Sonicxtacy02's Avatar
    Join Date
    Sep 2004
    Location
    Woodbridge, VA
    Posts
    8,168
    Blog Entries
    51
    I'm writing in vb.net.. and i'm a noob (still) dont know much about multi-threading. Spose now's a good time to read up lol.
    mp3Car.com Senior Tech Blogger (Want a product reviewed? Contact me.)
    Find my plugins on the MP3Car App Store!
    Follow Me on Twitter or Facebook
    Live mp3Car Facebook Chat

  4. #14
    Low Bitrate eigenVector's Avatar
    Join Date
    Apr 2009
    Posts
    80
    Quote Originally Posted by Sonicxtacy02 View Post
    I'm writing in vb.net.. and i'm a noob (still) dont know much about multi-threading. Spose now's a good time to read up lol.
    I'd help ya out, but I'm a C# developer, so the syntax issues will cause issues.
    But basically I create a separate class to handle writes to the file. If you're using .NET 2.0 or higher, use a generic Queue to Enqueue the item you want to write to the file system. Have a private method in your class that does a loop over the queue, dequeing each item and write it to the file system.

    Your class should have one System.Threading.Thread members in it, and have it point to the method with the write loop.
    Then just call the Start Abort method on your thread to start your looping method.

    Here's a really quick and dirty example written in C#, that has not been tested. But you should be able to get the idea.
    But yes, do some reading.

    Code:
    public class QueuedWriter:IDisposable
        {
            StreamWriter writer; // writer use to actually write to the file
            Thread workerThread; // background thread used to perform the writes to the file
            Queue<string> itemsToWrite = new Queue<string>(); // queue of items that will be written to the file
            public QueuedWriter(string fileName)
            {
                writer = new StreamWriter(fileName);
                workerThread = new Thread(mainLoop); // notice, we're specifying the mainLoop method in the constructor of the Thread
                workerThread.Priority = ThreadPriority.BelowNormal;
                workerThread.Start();
            }
    
            public void WriteItem(string item)
            {
                itemsToWrite.Enqueue(item);
            }
    
            private void mainLoop()
            {
                bool abort = false;
                while (!abort)
                {
                    try
                    {
                        /// Write everything that has been queued
                        while (itemsToWrite.Count > 0)
                        {
                            writer.WriteLine(itemsToWrite.Dequeue());
                        }
                        //Nothing to write, sleep a while
                        Thread.Sleep(1000);
                        writer.Flush();
                    }
                    catch (ThreadAbortException)
                    {
                        abort = true;
                    }
                }
            }
    
            #region IDisposable Members
    
            public void Dispose()
            {
                if (workerThread != null)
                {
                    workerThread.Abort();
                }
                workerThread = null;
                if (writer != null)
                {
                    writer.Flush();
                    writer.Close();
                    writer.Dispose();
                }
            }
    
            #endregion
        }

  5. #15
    Mo' Programming Mo' Problems
    Auto Apps:loading...
    Sonicxtacy02's Avatar
    Join Date
    Sep 2004
    Location
    Woodbridge, VA
    Posts
    8,168
    Blog Entries
    51
    i've got a c# to vb.net converter.. so that will help. Thanks!
    mp3Car.com Senior Tech Blogger (Want a product reviewed? Contact me.)
    Find my plugins on the MP3Car App Store!
    Follow Me on Twitter or Facebook
    Live mp3Car Facebook Chat

  6. #16
    The Last Good Gremlin GizmoQ's Avatar
    Join Date
    Nov 2004
    Location
    St Louis
    Posts
    2,347
    Quote Originally Posted by Sonicxtacy02 View Post
    ... one thing i did have to do is scale the mile reading back to once ever 2 seconds because my timer that handles the calculation took more than a second the calculate and save to file.
    Maybe scale it back to 5 seconds for those of us with slow CPUs.
    HARDWARE: Fujitsu Stylistic ST5111w/WiFi and dock, internal Hitachi 500G HD, external 1TB HD, Sierra Wireless Aircard 550, DVD-RW, BoomzBox HD radio, XM Commander, Delorme GPS, Saitek X-52 Pro joystick, BluSoleil Bluetooth, TPMS, FB, Elm327

  7. #17
    Super Moderator
    Auto Apps:loading...
    JohnWPB's Avatar
    Join Date
    Sep 2005
    Location
    West Palm Beach, Florida
    Posts
    4,692
    Blog Entries
    1

    Looking Good Sonic!

    This is looking good Sonic! One thing I would consider is to input the odometer reading when the plugin is installed and setup, and have that updated on the screen as well. This way you have a real world comparison to see how accurate it is keeping track of the millage. Also making the value clickable, and correcting / syncing it with the actual odometer would be a major plus.

    For a quick trip to the store, many of us do not have the computer come on, but would like to keep the "system odometer" in sync with those lost tracked miles ect. Also the "floating" of the lat and lon can add up pretty fast. Back when I was trying to get Festy's gas mileage thing to work, I noticed this. With the USB GPS puck here on the desk, I left it running for a day when I left in the middle of working on it and noticed that I had traveled a few miles hahah.

    As far as frequency of updates, personally I think once ever minute, 5 minutes or so is more than enough. Oil changes are the most frequent thing to change for example, & I doubt having to know within 2 seconds that's its time for an oil change is really going to matter that much

    This would decrease the overall CPU usage, as well as not constantly thrashing / writing to the hard drive every 2 seconds.

    As for the cost per mile for items, that should be fairly simple to do. In your example its $17.50 for an oil change that is done every 3,000 miles:

    $17.50 divided by 3000 = .006 cents per mile.

    I also completely agree, and would love to see a fuel log wrapped into this! Fill er' up, enter the number of gallons, price per gallon and the odometer reading. At the next fill up do the same, and you can then have it calculate many miles per gallon you are getting.
    Front End of Choice: Ride Runner (Is there anything else??? ) & Powered by the DFX5.1 Skin Available in the Mobile App Mart

    My Fiero Build Thread

  8. #18
    THE EXPERIMENTER
    Auto Apps:loading...
    carputer1's Avatar
    Join Date
    Sep 2007
    Location
    UK,Surrey
    Posts
    1,979
    subcribe::

  9. #19
    Mo' Programming Mo' Problems
    Auto Apps:loading...
    Sonicxtacy02's Avatar
    Join Date
    Sep 2004
    Location
    Woodbridge, VA
    Posts
    8,168
    Blog Entries
    51
    Quote Originally Posted by GizmoQ View Post
    Maybe scale it back to 5 seconds for those of us with slow CPUs.
    I'll have it user settable... IF the threading idea falls through for whatever reason. If i can have the file IO done separate from the actual distance calculation it should work out great. Only problem would be if RR is closed between writes. RR really needs a way to let plugins know its terminating.

    Quote Originally Posted by JohnWPB View Post
    This is looking good Sonic! One thing I would consider is to input the odometer reading when the plugin is installed and setup, and have that updated on the screen as well. This way you have a real world comparison to see how accurate it is keeping track of the millage. Also making the value clickable, and correcting / syncing it with the actual odometer would be a major plus.
    Can do

    For a quick trip to the store, many of us do not have the computer come on, but would like to keep the "system odometer" in sync with those lost tracked miles ect. Also the "floating" of the lat and lon can add up pretty fast. Back when I was trying to get Festy's gas mileage thing to work, I noticed this. With the USB GPS puck here on the desk, I left it running for a day when I left in the middle of working on it and noticed that I had traveled a few miles hahah.
    I've got a kick out for floating coordinates that monitors the heading value. This should work really well... unless you guys are out doing high speed donuts lol.


    As far as frequency of updates, personally I think once ever minute, 5 minutes or so is more than enough. Oil changes are the most frequent thing to change for example, & I doubt having to know within 2 seconds that's its time for an oil change is really going to matter that much

    This would decrease the overall CPU usage, as well as not constantly thrashing / writing to the hard drive every 2 seconds.
    when i say the timer runs too fast at once per second only real issue is getting the lat and lon from RR before the CalculateDistance function is run. If RR hasnt reported back to the plugin before the function runs the result of the function is Nan and it crashes the system. I can probably easily write prevention for this.. but for now once every 2 seconds has been absolutely no issue on my 1.2ghz celeron i'm developing on.


    As for the cost per mile for items, that should be fairly simple to do. In your example its $17.50 for an oil change that is done every 3,000 miles:

    $17.50 divided by 3000 = .006 cents per mile.
    I will definitely add it in some capacity as it is pretty easy to do. i was thinking more along the lines of having to calculate each time the oil change is done.

    I also completely agree, and would love to see a fuel log wrapped into this! Fill er' up, enter the number of gallons, price per gallon and the odometer reading. At the next fill up do the same, and you can then have it calculate many miles per gallon you are getting.
    Will also incorporate this.

    One more thing i incorporated before leavin work on friday is a slider that gives you yet another visual indication of how close you are to exceeding your maintenance limit.
    mp3Car.com Senior Tech Blogger (Want a product reviewed? Contact me.)
    Find my plugins on the MP3Car App Store!
    Follow Me on Twitter or Facebook
    Live mp3Car Facebook Chat

  10. #20
    Mo' Programming Mo' Problems
    Auto Apps:loading...
    Sonicxtacy02's Avatar
    Join Date
    Sep 2004
    Location
    Woodbridge, VA
    Posts
    8,168
    Blog Entries
    51
    I've been plugging away at this for the last few days and i have more progress. I've completed the setup and adding maintenance screens... and also optimized the calculatedistance function a little bit so that a Nan return isnt possible. I've also incorporated a concept similar to what eigenVector suggested to keep I/O overhead down.

    Next step is to work on the fueling information. Then adding a cost calculator.
    mp3Car.com Senior Tech Blogger (Want a product reviewed? Contact me.)
    Find my plugins on the MP3Car App Store!
    Follow Me on Twitter or Facebook
    Live mp3Car Facebook Chat

Similar Threads

  1. Replies: 13
    Last Post: 05-28-2009, 03:18 PM
  2. Replies: 63
    Last Post: 03-10-2009, 07:49 PM
  3. pc reboot on sd startup
    By duanes7 in forum StreetDeck
    Replies: 3
    Last Post: 12-14-2007, 08:55 AM
  4. IRMAN plugin
    By knyarko in forum StreetDeck
    Replies: 3
    Last Post: 01-05-2007, 08:26 PM
  5. Replies: 0
    Last Post: 06-11-2006, 05:49 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •