Cast Drivers in their own DataSet on meeting a certain condition

Posts: 21
Hey everyone,

I'm currently casting to a few series' that have their drivers flagged as "Am" and "Pro" but not in the traditional way of doing class, rather they run the same cars and are flagged by unique numbers or a symbol in their name to delimit who is who. I can change the symbols and backgrounds easily enough through the inbuilt features ATVO has, but I want to cast these flagged drivers into their own data set so they can be shown in their own lists.

My plan was to use a custom dataset, but I'm stuck right now.

My current psuedocode:
foreach (var itemResult in sim.Session.Current.Results)
{
if (itemResult.Entity.Name.Contains(itemFlag))
{
DataSet.Add(itemResult);
}
}


But right now I'm not able to cast the Driver entry to the CustomDataSet. I might be pushing it's functionality too far.

Any help would be appreciated!
Posts: 785
Seems like you're after the same thing as Simon here.
I'll look into making this possible.
Edited (3 times)
Posts: 785
Would it help if I were to allow you to create a custom dataset in a script and select that dataset in the usual Select Data Set window?

The script would need to have a class that overrides 'CustomStandingsDataSet'. You can override at least three important functions and return your own results:
  • FilterResults: receives all results as input, you can apply your own filtering and output only a subset
  • OrderResults: receives all results as input, you can sort the results according to your own sorting rule
  • GetSession: change the session from which you want to pull results

There are more functions to override but I highly recommend staying away from those.

Important: it only supports "results" datasets, meaning a dataset similar to "followed", "standings", "warmup", etc.

An example implementation would be this. It would create a dataset that only returns drivers with a "b" in their name, and sorted by name:
using System;
using System.Linq;
using ATVO.ThemesSDK;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Scripting.DotNET;
using ATVO.ThemeEditor.ThemeModels.DataSets;
using System.Collections.Generic;
using ATVO.ThemesSDK.Data.Results;
using ATVO.ThemesSDK.Ordering;

namespace Scripts
{
public class DsTest : CustomStandingsDataSet
{
protected override IEnumerable<IEntitySessionResult> FilterResults(
ISimulation sim,
IEnumerable<IEntitySessionResult> results)
{
// Filter all results to return only a subset
return results.Where(r => r.Entity.Name.ToLower().Contains("d"));
}

protected override IEnumerable<IEntitySessionResult> OrderResults(
ISimulation sim,
IEnumerable<IEntitySessionResult> results,
IDataOrder order)
{
// Optional: change the order of the results
return results.OrderBy(r => r.Entity.Name);

// Use the 'order' parameter to order by the selected Data Order
// This is the default implementation; can leave this out
return order.Sort(results);
}

protected override ISessionResult GetSession(ISimulation sim)
{
// Optional: change the session from which you want to pull the results
return sim.Session.Current;
}
}
}


I think I can make this work, but I have to make some changes to make the editor accept this as a data set.

Please let me know if this would work for you or if you need even more control.
Edited (1 time)
Posts: 21
Nick Thissen wrote:
Would it help if I were to allow you to create a custom dataset in a script and select that dataset in the usual Select Data Set window?

The script would need to have a class that overrides 'CustomStandingsDataSet'. You can override at least three important functions and return your own results:
  • FilterResults: receives all results as input, you can apply your own filtering and output only a subset
  • OrderResults: receives all results as input, you can sort the results according to your own sorting rule
  • GetSession: change the session from which you want to pull results

There are more functions to override but I highly recommend staying away from those.

Important: it only supports "results" datasets, meaning a dataset similar to "followed", "standings", "warmup", etc.

An example implementation would be this. It would create a dataset that only returns drivers with a "b" in their name, and sorted by name:
using System;
using System.Linq;
using ATVO.ThemesSDK;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Scripting.DotNET;
using ATVO.ThemeEditor.ThemeModels.DataSets;
using System.Collections.Generic;
using ATVO.ThemesSDK.Data.Results;
using ATVO.ThemesSDK.Ordering;

namespace Scripts
{
public class DsTest : CustomStandingsDataSet
{
protected override IEnumerable<IEntitySessionResult> FilterResults(
ISimulation sim,
IEnumerable<IEntitySessionResult> results)
        {
        // Filter all results to return only a subset
        return results.Where(r => r.Entity.Name.ToLower().Contains("d"));
        }
       
        protected override IEnumerable<IEntitySessionResult> OrderResults(
        ISimulation sim,
        IEnumerable<IEntitySessionResult> results,
        IDataOrder order)
        {
        // Optional: change the order of the results
        return results.OrderBy(r => r.Entity.Name);
       
        // Use the 'order' parameter to order by the selected Data Order
        // This is the default implementation; can leave this out
        return order.Sort(results);
        }
       
        protected override ISessionResult GetSession(ISimulation sim)
        {
        // Optional: change the session from which you want to pull the results
            return sim.Session.Current;
        }
}
}


I think I can make this work, but I have to make some changes to make the editor accept this as a data set.

Please let me know if this would work for you or if you need even more control.

Hi Nick,

This would essentially fulfill the main requirement I would have. The idea would be to allow for data to be recast into a custom user data set (based on user specified requirements within the script itself) that can be referenced as if it were a standard data set i.e the standard datasets already present within ATVO (standings, qualification etc). In my user requirements, they would essentially like to see a separation of PRO and AM GT cars done by us as broadcasters, and it would provide much more clarity than can be seen from this:



A lot of leagues make use of same class cars and delimit who are Amateur and Pro for example. We can account for this in terms of background changes, and that's fine, but they would also like to see the data separated out for the viewers.
Posts: 785
This update is now released on the alpha channel.
Posts: 21
Nick Thissen wrote:
This update is now released on the alpha channel.

Thanks Nick, I’ll update to the Alpha channel and get back to you on how well it works.

For the sake of brevity do you have any sample logic for how to properly declare datasets with the update? Or is it similar to the Custom Data Set as is in Stable branch?

Either way, I’ll get back to you.
Posts: 785
No it is not similar. You just create a script with the Dataset template, or copy it from what I posted here earlier. Add your logic at least to the FilterResults part (the rest is optional). Then save and make sure it compiled OK. After that, it should become availabl as a dataset in the regular "Select dataset" window for any widget. It works just the same as the normal standings dataset, except with your own filtering logic.
Posts: 21
Nick Thissen wrote:
No it is not similar. You just create a script with the Dataset template, or copy it from what I posted here earlier. Add your logic at least to the FilterResults part (the rest is optional). Then save and make sure it compiled OK. After that, it should become availabl as a dataset in the regular "Select dataset" window for any widget. It works just the same as the normal standings dataset, except with your own filtering logic.

Perfect. I'll cook something up and show the results.
Posts: 287
Robert, do you do it ?
I try but there is a lot of error in script acually.