Add output if AvatarId Changes
Add output for last nil-Message Add output for Runtime Remove OSCQuery RefreshServices
This commit is contained in:
parent
0857a4763c
commit
d16d4085fc
@ -9,11 +9,12 @@ public partial class OSCCollar
|
|||||||
{
|
{
|
||||||
Layout layout = new Layout().SplitRows(
|
Layout layout = new Layout().SplitRows(
|
||||||
new Layout("Top"),
|
new Layout("Top"),
|
||||||
new Layout("Bottom").SplitColumns(
|
new Layout("Middle").SplitColumns(
|
||||||
new Layout("Config-Values"),
|
new Layout("Config-Values"),
|
||||||
new Layout("Variable-Values"),
|
new Layout("Variable-Values"),
|
||||||
new Layout("Position")
|
new Layout("Position")
|
||||||
));
|
),
|
||||||
|
new Layout("Bottom"));
|
||||||
if(OperatingSystem.IsWindows())
|
if(OperatingSystem.IsWindows())
|
||||||
Console.WindowWidth += 20;
|
Console.WindowWidth += 20;
|
||||||
Table configTable = new Table();
|
Table configTable = new Table();
|
||||||
@ -36,6 +37,7 @@ public partial class OSCCollar
|
|||||||
layout["Config-Values"].Update(configTable);
|
layout["Config-Values"].Update(configTable);
|
||||||
layout["Variable-Values"].Update(variableTable);
|
layout["Variable-Values"].Update(variableTable);
|
||||||
layout["Position"].Update(new Panel(new Text(GetCoordinateSystem())));
|
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("Status", "");
|
||||||
variableTable.AddRow("GPS 1", "");
|
variableTable.AddRow("GPS 1", "");
|
||||||
@ -61,6 +63,7 @@ public partial class OSCCollar
|
|||||||
variableTable.Rows.Update(7, 1, new Text($"{GetCalibrationValues().Item1}"));
|
variableTable.Rows.Update(7, 1, new Text($"{GetCalibrationValues().Item1}"));
|
||||||
variableTable.Rows.Update(8, 1, new Text($"{GetCalibrationValues().Item2}"));
|
variableTable.Rows.Update(8, 1, new Text($"{GetCalibrationValues().Item2}"));
|
||||||
layout["Position"].Update(new Panel(new Text(GetCoordinateSystem())));
|
layout["Position"].Update(new Panel(new Text(GetCoordinateSystem())));
|
||||||
|
layout["Bottom"].Update(new Text($"{_lastNilMessageSent} AvatarId: {_avatarId} Runtime: {DateTime.Now.Subtract(_programStarted)}"));
|
||||||
displayContext.Refresh();
|
displayContext.Refresh();
|
||||||
await Task.Delay(100);
|
await Task.Delay(100);
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@ public partial class OSCCollar
|
|||||||
private OscClient _client = null!;
|
private OscClient _client = null!;
|
||||||
private Task _consoleOutputTask;
|
private Task _consoleOutputTask;
|
||||||
|
|
||||||
|
private string _avatarId = "";
|
||||||
private float _leashStretch;
|
private float _leashStretch;
|
||||||
private readonly Vector _unitVectorLeash = new(1, 0);
|
private readonly Vector _unitVectorLeash = new(1, 0);
|
||||||
private Vector _movementVector = new(0, 0);
|
private Vector _movementVector = new(0, 0);
|
||||||
@ -106,6 +107,7 @@ public partial class OSCCollar
|
|||||||
{
|
{
|
||||||
this._server = new OscServer(this._portReceive);
|
this._server = new OscServer(this._portReceive);
|
||||||
this._client = new OscClient(this._config.Ip, this._config.PortSend);
|
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/GPS1", GPS1Handle);
|
||||||
this._server.TryAddMethod("/avatar/parameters/GPS2", GPS2Handle);
|
this._server.TryAddMethod("/avatar/parameters/GPS2", GPS2Handle);
|
||||||
this._server.TryAddMethod("/avatar/parameters/GPS3", GPS3Handle);
|
this._server.TryAddMethod("/avatar/parameters/GPS3", GPS3Handle);
|
||||||
@ -131,16 +133,22 @@ public partial class OSCCollar
|
|||||||
.AdvertiseOSC()
|
.AdvertiseOSC()
|
||||||
.AdvertiseOSCQuery()
|
.AdvertiseOSCQuery()
|
||||||
.Build();
|
.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/GPS1", Attributes.AccessValues.WriteOnly);
|
||||||
this.OscQueryService.AddEndpoint<float>("/avatar/parameters/GPS2", 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/GPS3", Attributes.AccessValues.WriteOnly);
|
||||||
this.OscQueryService.AddEndpoint<float>("/avatar/parameters/Leash_Stretch", 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.AddEndpoint<bool>("/avatar/parameters/Leash_Toggle", Attributes.AccessValues.WriteOnly);
|
||||||
this.OscQueryService.RefreshServices();
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Handle OSC-Messages
|
#region Handle OSC-Messages
|
||||||
|
|
||||||
|
private void AvatarChangeHandle(OscMessageValues messageValues)
|
||||||
|
{
|
||||||
|
this._avatarId = messageValues.ReadStringElement(0);
|
||||||
|
}
|
||||||
|
|
||||||
private void AllowMovingHandle(OscMessageValues messageValues)
|
private void AllowMovingHandle(OscMessageValues messageValues)
|
||||||
{
|
{
|
||||||
this._allowMoving = messageValues.ReadBooleanElement(0);
|
this._allowMoving = messageValues.ReadBooleanElement(0);
|
||||||
@ -210,12 +218,6 @@ public partial class OSCCollar
|
|||||||
this._client.Send("/input/Horizontal", Convert.ToSingle(_movementVector.X));
|
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);
|
Thread.Sleep(UpdateInterval);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user