public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
// Bind to "entitysessionresult_obj" to get the IEntitySessionResult as the value
// Cast to IEntitySessionResult type
IEntitySessionResult result = (IEntitySessionResult) value;
// Check DNS, Out, Pits, etc
if (result.Out)
return "OUT";
// We need the following information to determine whether to show interval or laps
var pos = result.ClassPosition;
var gap = result.ClassGap;
var laps = result.ClassGapLaps;
var type = result.Session.Type;
if (result.ClassPosition == 1)
return "LAP " + result.CurrentLap.Number;
// 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
// If the car is in same lap but over a minute behind, convert total seconds to proper format
var min = 0;
float sectime;
if (gap > 60)
{
min = (int) (gap / 60);
sectime = gap % 60;
return "+" + min + ":" + sectime.ToString("00.000");
}
else
return "+" + gap.ToString("0.000");
}
Emmanuel Suter wrote:
I have got the same pb, and now it is ok. I work on a laptop and I don't really put it OFF. I don't sure but it seems to be OK after a complete restart of computer.
Emmanuel Suter wrote:
What have you got on the top of script ?
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;
using System.Windows.Media;
Emmanuel Suter wrote:
Oppps, my problem is already here. Yesterday I think it solve but no .... so same as you with same sort of script for gap in ticker.
Console.WriteLine("Write this to the event log");
if (value == null)
{
// do something appropriate, in this case probably just return nothing
return null;
}
Nick Thissen wrote:
For future reference: leaving these errors in your script is bad. We make sure an error in a script does not crash ATVO so we catch these errors when they happen. However, this is very costly in terms of performance especially if it keeps happening 30 times per second.
Adding this "value == null" check is extremely fast and does not cause any performance hit, so try to add these checks as much as possible.
Nick Thissen wrote:
For future reference: leaving these errors in your script is bad. We make sure an error in a script does not crash ATVO so we catch these errors when they happen. However, this is very costly in terms of performance especially if it keeps happening 30 times per second.
Adding this "value == null" check is extremely fast and does not cause any performance hit, so try to add these checks as much as possible.
Nick Thissen wrote:
So the issue was doing the check in the wrong place? Good to specify that in case anyone else reads this :)
I also moved the topic to the right forum.
Dwayne Prins wrote:Can you check if a script is slowing it down or something else?
@Nick, Error is gone, but ATVO gets really slow quickly now :/
Edit: Well, the interface gets very slow. The overlay however keeps working fine (as far as I can tell)
Nick Thissen wrote:Dwayne Prins wrote:Can you check if a script is slowing it down or something else?
@Nick, Error is gone, but ATVO gets really slow quickly now :/
Edit: Well, the interface gets very slow. The overlay however keeps working fine (as far as I can tell)
Nick Thissen wrote:
That's interesting... I'll have to check it out why that's happening, it should not matter. Thanks for finding that!