Results 1 to 11 of 11

Thread: perform an operation on 2 fields of a CSV file?

  1. #1
    Tuner in Training
    Join Date
    Mar 2023
    Posts
    12

    perform an operation on 2 fields of a CSV file?

    Hello

    Is it possible to perform an operation on 2 fields of a CSV file?
    For example, I would like to perform the operation to display the power of my drone:
    Intensity fields in A x (battery voltage 1 + battery voltage 2)
    Is this possible in RaceRender?

  2. #2

  3. #3
    Advanced Tuner
    Join Date
    Apr 2018
    Posts
    296
    It's possible to use an Enhanced Display Object if you know exactly what the fields will be named. You could use a single Display Object to reference multiple fields within a single data file pretty easily (as long as the column header for the particular field is well known beforehand).

    This post details a similar issue where someone wanted to display Speed over a given Distance against Time.

    If you provide a sample data file, I'd be willing to put together a sample display object that you could import without needing to pre-preprocess any data before importing into RaceRender.

  4. #4
    Tuner in Training
    Join Date
    Mar 2023
    Posts
    12
    Thank you for your reply

    I know the 3 fields that interest me:
    voltageCell1
    voltageCell2
    current(A)

    I tried to modify the script but a priori it does not seem to be correct
    I exported this script under the name "Powerdrone.rro"

    Please see if you could do something with it

    Code:
    if(DataValue > MaxValue)
    	I = DataValue;
    
    u1=GetDataValue(voltageCell1); 
    u2=GetDataValue(voltageCell2); 
    //I=GetDataValue(current(A));
    
    DisplayValue=((u1+u2)*i;
    
    DisplayLabel = MaxLabel;
    DisplayColor = HighColor;
    DisplayValue = MaxValue;
    
    DrawRect(0, 0, SizeX, SizeY, DisplayColor, Filled);
    SetTextOutline(Invisible);
    TextColor = ActiveColor;
    
    DrawText(DisplayLabel + ":", OffsetX - 5, 0, TextColor, FontSize, AlignH_Right);
    
    DrawText(FormatNumber(DisplayValue, Decimals) + " " + UnitLabel, OffsetX + 16, 0, TextColor, FontSize, AlignH_Left);
    Attached Files Attached Files

  5. #5
    Advanced Tuner
    Join Date
    Apr 2018
    Posts
    296
    Quote Originally Posted by marcus_54 View Post
    Thank you for your reply

    I know the 3 fields that interest me:
    voltageCell1
    voltageCell2
    current(A)

    I tried to modify the script but a priori it does not seem to be correct
    I exported this script under the name "Powerdrone.rro"

    Please see if you could do something with it

    Code:
    if(DataValue > MaxValue)
        I = DataValue;
    
    u1=GetDataValue(voltageCell1); 
    u2=GetDataValue(voltageCell2); 
    //I=GetDataValue(current(A));
    
    DisplayValue=((u1+u2)*i;
    
    DisplayLabel = MaxLabel;
    DisplayColor = HighColor;
    DisplayValue = MaxValue;
    
    DrawRect(0, 0, SizeX, SizeY, DisplayColor, Filled);
    SetTextOutline(Invisible);
    TextColor = ActiveColor;
    
    DrawText(DisplayLabel + ":", OffsetX - 5, 0, TextColor, FontSize, AlignH_Right);
    
    DrawText(FormatNumber(DisplayValue, Decimals) + " " + UnitLabel, OffsetX + 16, 0, TextColor, FontSize, AlignH_Left);
    I'm not quite sure that I follow your logic here, but you're really close to getting the values. You need to use the GetDataIndex(DataFieldName) function first to get the index of your data column (preferably in the Background Script since that won't ever change); then you can pass that into the GetDataValue(DataFieldIndex) function to get the value in the current frame.

    Background Script:
    Code:
    // Shows recent minimum and maximum extremes for the selected data channel// This display requires "Persistent Script Variables" to be enabled
    
    
    // Options
    DisplayLabel = "Puissance:";
    UnitLabel = "W"; // May need to increase the object width for this (SizeX on the parameters tab)
    
    
    Decimals = 1; // Number of decimal places
    //OffsetX = 260; 
    OffsetX = SizeX / 2; // X coordinate where the split between label and number is centered
    
    
    HighColor = ColorA;
    ActiveColor = ColorB;
    FontSize = SizeY * 0.90;
    
    
    DefaultMaxValue = -999999999; // Lower than any expected data value
    MaxValue = DefaultMaxValue;
    
    
    VoltageCell1Index = GetDataIndex("voltageCell1");
    VoltageCell2Index = GetDataIndex("voltageCell2");
    Foreground Script:
    Code:
    if(DataValue > MaxValue) {
        MaxValue = DataValue;
    }
    
    
    u1=GetDataValue(VoltageCell1Index); 
    u2=GetDataValue(VoltageCell2Index); 
    //I = DataValue; // Always display the exact value of the current?
    I = MaxValue; // Always display whatever the maximum current was?
    
    
    
    
    DisplayColor = HighColor;
    DisplayValue=(u1+u2)*I;
    
    
    DrawRect(0, 0, SizeX, SizeY, DisplayColor, Filled);
    SetTextOutline(Invisible);
    TextColor = ActiveColor;
    
    
    DrawText(DisplayLabel, OffsetX - 5, 0, TextColor, FontSize, AlignH_Right);
    
    
    DrawText(FormatNumber(DisplayValue, Decimals) + " " + UnitLabel, OffsetX + 16, 0, TextColor, FontSize, AlignH_Left);

    PowerDrone.rro

  6. #6
    Tuner in Training
    Join Date
    Mar 2023
    Posts
    12
    Thank you very much the module works well!

    I have another problem.
    I use about 9 "top speed banners" and of the 9 that are placed, there are about 4 that tend to freeze...
    That is, when the video is played or recorded, they don't update all the time...
    On the two photos that are presented, the video to play from the beginning (photo 1) and we see the fields that are in red that are not updated̀ After pausing the realization takes place (photo 2) but when recording videos it also remains frozen.
    Where does the problem come from?
    Attached Images Attached Images

  7. #7
    Advanced Tuner
    Join Date
    Apr 2018
    Posts
    296
    It looks like almost all of those values are less in photo 2 compared to photo 1. If you want to display the current value at that frame, then you may need to remove some logic from your Enhanced Display Objects.

    For example, in the PowerDrone one above, you'd likely need to use this Foreground Script instead:
    Code:
    u1=GetDataValue(VoltageCell1Index); 
    u2=GetDataValue(VoltageCell2Index); 
    I = DataValue; // Always display the exact value of the current in this frame
    
    
    DisplayColor = HighColor;
    DisplayValue=(u1+u2)*I;
    
    
    
    
    DrawRect(0, 0, SizeX, SizeY, DisplayColor, Filled);
    SetTextOutline(Invisible);
    TextColor = ActiveColor;
    
    
    
    
    DrawText(DisplayLabel, OffsetX - 5, 0, TextColor, FontSize, AlignH_Right);
    
    
    
    
    DrawText(FormatNumber(DisplayValue, Decimals) + " " + UnitLabel, OffsetX + 16, 0, TextColor, FontSize, AlignH_Left);
    No need to keep track of a MaxValue. DataValue will be the value of the field at that given frame in the video. That frame will likely fall between two actual rows of data in your data file; so RaceRender interpolates those values and averages out the difference in the values over the time between those two data rows. What's important is that DataValue is the value of the column in that frame.

    If you only need a single field, then you can use the "Text Data" Display Object to display whatever numerical values are in that column at that given time. It has the option to add a label in front or behind by changing the mode from "Number only" to "Number & Text" or "Text & Number". You could combine this with a "Text" Display Object to have the label to the left, and then the value with a unit to the right.

  8. #8
    Tuner in Training
    Join Date
    Mar 2023
    Posts
    12
    Thank you for these tips I will try to apply them.

    For maximum values, would it be possible for RaceRender to read the last value of a data field?

    In the data field, the maximum values increase without going down to indicate the maximum a given moment personally, I preferred to have the maximum of the session.

  9. #9
    Tuner in Training
    Join Date
    Mar 2023
    Posts
    12
    The maximum is contained in the data field...
    by removing the if if(DataValue > MaxValue) ... from the script
    Everything works perfectly
    I'm super happy

  10. #10
    Tuner in Training
    Join Date
    Mar 2023
    Posts
    12
    Would it be possible to reuse the calculation made in PowerDrone to manage another gauge?

  11. #11
    Advanced Tuner
    Join Date
    Apr 2018
    Posts
    296
    Unfortunately, no. Each Display Object is independent from any other Display Objects (at least as far as scripting is concerned).

    You could add a second PowerDrone Display Object and modify the logic in that one to perform additional calculations (again, each display object is independent; so modifying a second copy won't impact the first one). You could then export that as a new template so that you can reuse it in the future.