1. Attachments are working again! Check out this thread for more details and to report any other bugs.

For coders: how to add a built-in parameter?

Discussion in 'PriiDash (TM)' started by 2009Prius, Jun 8, 2014.

  1. 2009Prius

    2009Prius A Wimpy DIYer

    Joined:
    Mar 25, 2009
    2,705
    510
    63
    Location:
    USA
    Vehicle:
    2009 Prius
    There are many built-in parameters in PriiDash: from the very basic such as the car speed to the Prius specific such as the individual block voltages of the high voltage battery. A complete list of the built-in parameters is in the formula.txt file. The file can be customized for different kinds of cars that may have different formulas for calculating the parameters. But what if you want to add your own parameter as someone was asking recently? Some coding will be involved but the process is straightforward:
    1. Add a line in formula.txt (and command.txt if querying) to tell the program the CAN ID and how to calculate the parameter from the CAN data.
    2. In CANmsg.h, in the class Car_Data, add the new parameter param, a corresponding ParserX class pXparam, and a function fn_param(). In some cases one CAN message contains several parameters, therefore one pXparam and on fn_param() can cover several parameters.
    3. In CANmsg.cpp, in the constructor for the class Car_Data, initialize param and define variables to be used in pXparam.
    4. In formula.cpp, in the function Car_Data::map_formula, add statements to assign the expression for the pXparam class and associate the CAN ID and the pointer to the function Car_Data::fn_param, once the identifier in the formula.txt is matched. In some cases it is more convenient to have several pXparams and fn_params associated with one CAN ID, if the CAN message is very long.
    5. In formula.cpp, add definition for Car_Data::fn_param, to evaluate pXparam and extract the result into param.
    6. If you want to log the param in the csv log file, then in CANmsg.cpp, add to functions Car_Data::csv_title, Car_Data::csv_data, and Car_Data::csv_end as you see fit.

     
    hyera_rponzoni likes this.
  2. hyera_rponzoni

    hyera_rponzoni New Member

    Joined:
    May 28, 2014
    3
    0
    0
    Vehicle:
    Other Electric Vehicle
    Model:
    N/A
    thank you very much!