diff --git a/MeL/Core/MLCore.cs b/MeL/Core/MLCore.cs index 47cb735..23aebec 100644 --- a/MeL/Core/MLCore.cs +++ b/MeL/Core/MLCore.cs @@ -14,7 +14,12 @@ namespace OTDPlugins.MeL.Core public void Add(Vector2 point) { - if (AddTimeSeriesPoint(point, TimeNow)) + Add(point, TimeNow); + } + + public void Add(Vector2 point, DateTime time) + { + if (AddTimeSeriesPoint(point, time)) { IsReady = true; var timeMatrix = ConstructTimeDesignMatrix(); diff --git a/MeL/Filter/MeLFilter.cs b/MeL/Filter/MeLFilter.cs index c65dd73..3efc0c6 100644 --- a/MeL/Filter/MeLFilter.cs +++ b/MeL/Filter/MeLFilter.cs @@ -1,5 +1,6 @@ using System; using System.Numerics; +using OpenTabletDriver.Plugin; using OpenTabletDriver.Plugin.Attributes; using OpenTabletDriver.Plugin.Tablet; using OTDPlugins.MeL.Core; @@ -12,7 +13,15 @@ namespace OTDPlugins.MeL public Vector2 Filter(Vector2 point) { Core.Add(point); - return Core.IsReady ? Core.Predict(DateTime.UtcNow, Offset) : point; + try + { + return Core.IsReady ? Core.Predict(DateTime.UtcNow, Offset) : point; + } + catch + { + Log.Write("MeLFilter", "Unknown error in MeLCore", LogLevel.Error); + return point; + } } public FilterStage FilterStage => FilterStage.PostTranspose; diff --git a/MeL/Interpolator/MeLInterp.cs b/MeL/Interpolator/MeLInterp.cs index 586811a..27963bb 100644 --- a/MeL/Interpolator/MeLInterp.cs +++ b/MeL/Interpolator/MeLInterp.cs @@ -1,6 +1,7 @@ #if false using System.Numerics; +using OpenTabletDriver.Plugin; using OpenTabletDriver.Plugin.Attributes; using OpenTabletDriver.Plugin.Tablet.Interpolator; using OTDPlugins.MeL.Core; @@ -18,7 +19,16 @@ namespace OTDPlugins.MeL public override void Interpolate(InterpolatorArgs output) { if (Core.IsReady) - output.Position = Core.Predict(Core.TimeNow, 0); + { + try + { + output.Position = Core.Predict(Core.TimeNow, 0); + } + catch + { + Log.Write("MeLInterp", "Unknown error in MeLCore"); + } + } } [Property("Samples")]