Compare commits
No commits in common. "b837dec1160bffc83fd4e1d0b248f19a0395f356" and "0857a4763c532aad11e6998788bdcc273094b2e3" have entirely different histories.
b837dec116
...
0857a4763c
@ -9,12 +9,11 @@ public partial class OSCCollar
|
||||
{
|
||||
Layout layout = new Layout().SplitRows(
|
||||
new Layout("Top"),
|
||||
new Layout("Middle").SplitColumns(
|
||||
new Layout("Bottom").SplitColumns(
|
||||
new Layout("Config-Values"),
|
||||
new Layout("Variable-Values"),
|
||||
new Layout("Position")
|
||||
),
|
||||
new Layout("Bottom"));
|
||||
));
|
||||
if(OperatingSystem.IsWindows())
|
||||
Console.WindowWidth += 20;
|
||||
Table configTable = new Table();
|
||||
@ -37,7 +36,6 @@ public partial class OSCCollar
|
||||
layout["Config-Values"].Update(configTable);
|
||||
layout["Variable-Values"].Update(variableTable);
|
||||
layout["Position"].Update(new Panel(new Text(GetCoordinateSystem())));
|
||||
layout["Bottom"].Update(new Text($"{_lastNilMessageSent} AvatarId: {_avatarId} Runtime: {DateTime.Now.Subtract(_programStarted)}"));
|
||||
|
||||
variableTable.AddRow("Status", "");
|
||||
variableTable.AddRow("GPS 1", "");
|
||||
@ -63,9 +61,8 @@ public partial class OSCCollar
|
||||
variableTable.Rows.Update(7, 1, new Text($"{GetCalibrationValues().Item1}"));
|
||||
variableTable.Rows.Update(8, 1, new Text($"{GetCalibrationValues().Item2}"));
|
||||
layout["Position"].Update(new Panel(new Text(GetCoordinateSystem())));
|
||||
layout["Bottom"].Update(new Text($"{_lastNilMessageSent} AvatarId: {_avatarId} Runtime: {DateTime.Now.Subtract(_programStarted)}"));
|
||||
displayContext.Refresh();
|
||||
await Task.Delay(500);
|
||||
await Task.Delay(100);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ public partial class OSCCollar
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Config _config;
|
||||
private Config _config;
|
||||
private readonly int _portReceive;
|
||||
|
||||
private OSCQueryService? OscQueryService { get; set; }
|
||||
@ -38,13 +38,12 @@ public partial class OSCCollar
|
||||
private OscClient _client = null!;
|
||||
private Task _consoleOutputTask;
|
||||
|
||||
private string _avatarId = "";
|
||||
private float _leashStretch;
|
||||
private readonly Vector _unitVectorLeash = new(1, 0);
|
||||
private Vector _movementVector = new(0, 0);
|
||||
private bool _allowMoving = true;
|
||||
private DateTime _lastNilMessageSent = DateTime.UnixEpoch;
|
||||
private readonly DateTime _programStarted = DateTime.Now;
|
||||
private DateTime _lastOSCRefresh = DateTime.Now;
|
||||
private static readonly TimeSpan UpdateInterval = TimeSpan.FromMilliseconds(10);
|
||||
private static readonly TimeSpan MessageMinInterval = TimeSpan.FromMilliseconds(400);
|
||||
private GPS _gps1 = null!, _gps2 = null!, _gps3 = null!;
|
||||
@ -107,7 +106,6 @@ public partial class OSCCollar
|
||||
{
|
||||
this._server = new OscServer(this._portReceive);
|
||||
this._client = new OscClient(this._config.Ip, this._config.PortSend);
|
||||
this._server.TryAddMethod("/avatar/change", AvatarChangeHandle);
|
||||
this._server.TryAddMethod("/avatar/parameters/GPS1", GPS1Handle);
|
||||
this._server.TryAddMethod("/avatar/parameters/GPS2", GPS2Handle);
|
||||
this._server.TryAddMethod("/avatar/parameters/GPS3", GPS3Handle);
|
||||
@ -133,22 +131,16 @@ public partial class OSCCollar
|
||||
.AdvertiseOSC()
|
||||
.AdvertiseOSCQuery()
|
||||
.Build();
|
||||
this.OscQueryService.AddEndpoint<string>("/avatar/change", Attributes.AccessValues.WriteOnly);
|
||||
this.OscQueryService.AddEndpoint<float>("/avatar/parameters/GPS1", Attributes.AccessValues.WriteOnly);
|
||||
this.OscQueryService.AddEndpoint<float>("/avatar/parameters/GPS2", Attributes.AccessValues.WriteOnly);
|
||||
this.OscQueryService.AddEndpoint<float>("/avatar/parameters/GPS3", Attributes.AccessValues.WriteOnly);
|
||||
this.OscQueryService.AddEndpoint<float>("/avatar/parameters/Leash_Stretch", Attributes.AccessValues.WriteOnly);
|
||||
this.OscQueryService.AddEndpoint<bool>("/avatar/parameters/Leash_Toggle", Attributes.AccessValues.WriteOnly);
|
||||
this.OscQueryService.RefreshServices();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Handle OSC-Messages
|
||||
|
||||
private void AvatarChangeHandle(OscMessageValues messageValues)
|
||||
{
|
||||
this._avatarId = messageValues.ReadStringElement(0);
|
||||
}
|
||||
|
||||
private void AllowMovingHandle(OscMessageValues messageValues)
|
||||
{
|
||||
this._allowMoving = messageValues.ReadBooleanElement(0);
|
||||
@ -217,6 +209,12 @@ public partial class OSCCollar
|
||||
this._client.Send("/input/Vertical", Convert.ToSingle(_movementVector.Y));
|
||||
this._client.Send("/input/Horizontal", Convert.ToSingle(_movementVector.X));
|
||||
}
|
||||
|
||||
if (_lastOSCRefresh.Add(TimeSpan.FromSeconds(10)) > DateTime.Now)
|
||||
{
|
||||
this.OscQueryService?.RefreshServices();
|
||||
_lastOSCRefresh = DateTime.Now;
|
||||
}
|
||||
|
||||
Thread.Sleep(UpdateInterval);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user