Sub-Class Timing and Scoring

Posts: 3
Hi all. I have a question / feature request that's probably unfeasible by any stretch of the imagination, but I'll ask anyway.

We have a client that holds multiclass events, but they have 2 sub-classes (a pro division and amateur division) within 1 class. They've asked if we can separate these two divisions on the broadcast overlays. Now we were able to have different colors shown through the use of a spreadsheet, but timing and scoring is a different story. Since this client uses the same car models for both sub-classes and is technically scored as 1 class by iRacing, ATVO will also score these as 1 class. Is there a way to designate cars into a sub-class so that the sub-class is scored separately from the iRacing defined class?
Posts: 785
It may be possible relatively easily with a script. The script would read your spreadsheet (probably only the first time and then cache it in memory) and determine which car belongs to which class (e.g. by carnumber or however it's defined). Then I see several options:
  • The script may directly set ClassPosition property to the right value
  • The script may set the Class of each car to the right value

How effective this is will depend on how often we refresh these values from the api, you'll need to redo this everytime we update it. This may be only once or it may be every session info update, I'm not sure. You can always let the script run every single update but I'm not sure if that will cause some "flickering" where a car may jump between classes for a fraction of a second.

Let me know if you need help with such a script.
Posts: 66
Hey all.
I have the same problem as Amjed. I am working on an overlay for a series but they have 3 sub-classes.

I would imagine that the way to do it is similar to if you only have 2 sub-classes.

But i don't know anything about script's, and i don't know what data you will need from the sheet to get it all to work.

I hope you all can help me
Posts: 785
EDIT: After checking with Simon, I think the below code will not work. At the moment I think unfortunately it is not possible to have separate scoring for cars within the same "iRacing class". Our data simply doesn't work that way since all cars receive the same class. We will think about how we can enable this for you.

You can read the rest of my post but it will probably not work.


The data you need from the spreadsheet is anything that allows you to determine which car / driver is in which class. I don't know how you're doing that, I can imagine various ways. For example you could have designated car numbers for each class, e.g. class 1 has car numbers starting with 1XX and class 2 has numbers 2XX. Another way would be just a list of driver (customer ID/name) and which class they are in.

If you determine the class by car number you won't need a spreadsheet but can just check the car number and assign the class that way. Rough example, may not work but should be close:

public class SetCustomClass : IScript
{
public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
// Bind to "entity_object"
// Then "value" parameter will be of type IEntity
var entity = (IEntity) value;

// Get car number
var number = entity.Car.Number;

// Check first digit and set class ID, order and name
if (number.StartsWith("1"))
{
entity.Class.Id = 1;
entity.Class.Order = 1;
entity.Class.Name = "PRO";
}
else if (number.StartsWith("2"))
{
entity.Class.Id = 2;
entity.Class.Order = 2;
entity.Class.Name = "AM";
}
else
{
// Wrong car number, does not start with 1 or 2
// What to do?
}

return null;
}
}


This is not tested. I checked that you are at least allowed to set these class properties, however I am not sure what this will do. It may work fine, or it may break the scoring, I simply don't know. Give it a shot :)
Edited (1 time)
Posts: 66
Hey thx :) i will test it out and see if i can get it to work
Posts: 6
Hey Nick, I would like to follow up the approach you sketched out for Niclas a while ago (after talking to him today).

Unfortunately the example does not compile due to IEntity does not have a member or function named class. To get that running I would need some information where I can look up what members class IEntity has.

Furthermore I wonder whether I would be able to develop (and debug if necessary) a C# script directly in VisualStudio? If yes, is there a template solution or project file available?

EDIT: Found on github some information - but do not know whether this is still up-to-date. Would be great if someone could confirm that this is a viable source.
https://github.com/appgineerin/ATVO-Themes-SDK

Thanks in advance
Merlin
Edited (1 time)
Posts: 785
Yes, the Github is a good source. It is reasonably up to date except may not have the latest new features, but anything on the Github should be available as well in the code.

To more easily write the C# code, you can use Visual Studio Code, it is more or less integrated in ATVO. You can right-click a script (or the Scripts theme explorer entry) and choose "Open in VS Code". If you have VS Code setup properly it will open the script(s) in VS Code and allow you to edit them. It should give you full features like Intellisense and auto-complete.

Here is a video tutorial how to set it up and how to use it:
https://www.youtube.com/watch?v=fVf8Jy-vM-0

If you want to use Visual Studio itself (not VS Code), you can probably get that to work as well. If you select "Open in VS Code", a C# project file will be created (.csproj), which I'm sure you can simply open in Visual Studio and get to work like that. It will contain a package reference to a nuget package that contains the information for the classes so it should even compile properly.
Posts: 6
Nick Thissen wrote:
If you want to use Visual Studio itself (not VS Code), you can probably get that to work as well. If you select "Open in VS Code", a C# project file will be created (.csproj), which I'm sure you can simply open in Visual Studio and get to work like that. It will contain a package reference to a nuget package that contains the information for the classes so it should even compile properly.

Having an fully working VisualStudio2017 IDE installed - which I do use for other projects - I would like to avoid installing and customizing another IDE (=VisualStudio Code). I assume that the missing script is part of the VC Code installation and therefore I do not have the opportunity to create a project file and further use it in VC2017. Would you mind sending me just one project file thus I can work from that on?

I do assume that on compile time ATVO is generating a class library (dll) which will be used at runtime? If you can confirm that and let me know where ATVO expects the compiled .dll I do think that I can create a VC2017 project for that library from scratch.

P.S.: Here is the failure message I do get when I try to open the "script" in VSCode. Seems that during installation a view scripts are installed in C:\Windows\System32\Scripting which are missing - because I didn't install VSCode








Download logfile
Error: 6/19/2019 5:40:17 AM (UTC)
Unhandled exception
System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\WINDOWS\System32\Scripting\vscodeproject.script'.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean checkHost)
at System.IO.File.InternalReadAllText(String path, Encoding encoding, Boolean checkHost)
at System.IO.File.ReadAllText(String path)
at ATVO.ThemeEditor.Scripting.VsCodeUtil.CreateProjectFile(String path) in F:\Appgineer.in\Appgineer.in TV Overlay for iRacing\ATVO.ThemeEditor\Scripting\VsCodeUtil.cs:line 51
at ATVO.ThemeEditor.Scripting.VsCodeUtil.Open(Theme theme) in F:\Appgineer.in\Appgineer.in TV Overlay for iRacing\ATVO.ThemeEditor\Scripting\VsCodeUtil.cs:line 31
at ATVO.ThemeEditor.ViewModels.ThemeExplorerViewModel.OnOpenInVsCode() in F:\Appgineer.in\Appgineer.in TV Overlay for iRacing\ATVO.ThemeEditor\ViewModels\ThemeExplorerViewModel.cs:line 172
Posts: 785
Something is going wrong there. You should not need VS Code to have it create the csproj file. It seems to be looking for a template "vscodeproject.script" but in completely the wrong location. I'll have a look.

No ATVO does not look for compiled dll's, the scripts are compiled in memory.

You don't really need the csproj to be created by ATVO, you can also just create a new C# class library project (in full VS) yourself and install our Nuget package:
https://www.nuget.org/packages/Appgineering.ATVO/1.1.0

Then it should be able to compile and the script should also compile in ATVO.
Posts: 6
Nick Thissen wrote:
You don't really need the csproj to be created by ATVO, you can also just create a new C# class library project (in full VS) yourself and install our Nuget package:
https://www.nuget.org/packages/Appgineering.ATVO/1.1.0

Then it should be able to compile and the script should also compile in ATVO.

Thats' what I already tryed. Fired up NuGet Package Manager and looked vor ATVO and found one hit called "Appgineer.in-iRacing-API by appgineering.com" v1.0.0. But it causes errors that namespaces potentially due to msissing and assembly reference. Now I understand why that's the case.

The other package I can not find with NuGet Package Manager and I will have to figure out how I can install a package manually. By the way on the website it states that the package has been unlisted by the owner.







Edited (2 times)
Posts: 785
I unlisted it so it doenst show up in searches cause it shouldn't be necessary. I think you can still install it from package manager command line with the command shown on that page, right?

Perhaps you need to add references to the various exe and dll files in the ATVO install folder. But it should not be necessary since I think that is what the nuget package should contain...
Posts: 785
I just tested it in VS 2019.

- Create new C# project (any kind, for example Console project). At least .NET 4.5.1 or higher.
- Install our nuget package (see command in package manager console below)
- All ATVO types are available and it compiles.



Posts: 6
Can confirm that this works as well with VC2017 when using the right NuGet Package. Did just get confused by typing in ATVO in the NuGet Package Manager and getting a hit - but that was obviously the wrong package.


Still struggeling with understanding what exactly the parameters are which are provided for the methode Execute and what is expected to be returned.

P.S.: I do assume that the object provided with value is the same than used for databinding in ATVO Editor and that modified/tweeked values are supposed to be done in the structure/class type and provided to ATVO as a return value?! Otherwise the script would - from my understanding - just change local variables.
Edited (1 time)