mirror of
https://github.com/vale981/VoiDPlugins
synced 2025-03-04 16:51:38 -05:00
Add basic exception handling
and make MLCore.Add a little bit more flexible
This commit is contained in:
parent
8a4fc76635
commit
bb16d036d5
3 changed files with 27 additions and 3 deletions
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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")]
|
||||
|
|
Loading…
Add table
Reference in a new issue