So far I have not seen any issue with the timers. But I do notice that the theme itself is super slow because of two issues in your scripts:
1. TeamOrDriver script does not do a proper null check. If you had looked in the Event Log you could have seen a ton of errors, and the script is basically running non-stop as fast as it can but failing every time. A simple null-check prevents the continuous exceptions and makes the theme run smoothly for me.
2. Pit script sometimes receives a string value instead of a IEntitySessionResult value. Probably you used a wrong binding somewhere. I added a simple check to stop if the value type is incorrect.
using System;
using ATVO.ThemesSDK;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Scripting.DotNET;
using ATVO.ThemesSDK.Data.Results;
namespace Scripts
{
public class TeamOrDriver : IScript
{
public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
IEntitySessionResult result = (IEntitySessionResult) value;
// Nick: added check if result or result.Entity is null
if (result?.Entity == null)
return "";
string team = result.Entity.Name;
if (team[0] == '\0')
{
return result.Entity.CurrentDriver;
}
else
{
return result.Entity.Name;
}
//if (result.Entity.Name = 0)
// return result.Entity.CurrentDriver;
//else
// return result.Entity.Name;
}
}
}
using System;
using ATVO.ThemesSDK;
using ATVO.ThemesSDK.Data.Entity;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Controls;
using ATVO.ThemeEditor.Scripting.DotNET;
using ATVO.ThemesSDK.Data.Enums;
using ATVO.ThemesSDK.Data.Results;
namespace Scripts
{
public class Script : IScript
{
public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
// Bind to "entitysessionresult_obj" to get the IEntitySessionResult as the value
// Nick: Check type of value and cast
if (!(value is IEntitySessionResult))
{
Console.WriteLine("Pit script was bound to wrong type: " + value.GetType());
return null;
}
var result = (IEntitySessionResult)value;
// Check DNS, Out, Pits, etc
if (result == null)
return "";
if (result.DidNotStart)
return "DNS";
if (result.Out)
return "OUT";
if (result.Entity?.Car?.Movement?.IsInPits == true)
return "IN PITS";
if (result.Finished)
return "FIN";
// If none of these are true, then show the gap
// We need the following information to determine whether to show gap or laps
var pos = result.LivePosition;
var gap = result.LiveGap;
var laps = result.LiveGapLaps;
var type = result.Session.Type;
// Optional: there is no gap for P1 so show nothing
if (pos == 1)
return "Leader";
// If car is lapped AND this is a race session,
// then show nr of gap laps instead of gap time
if (laps > 0 && type == SessionType.Race)
{
if (laps == 1)
return "1 Lap"; // to avoid incorrect "1 Laps"
else
return laps + " Laps";
}
// If the car is in the same lap just return the time
return gap.ToString("0.0");
}
}
}