Finished Temporal Sync Feature

This commit is contained in:
Christopher Remde
2020-07-08 13:55:48 +02:00
parent da2c304db8
commit 1544abd276
17 changed files with 390 additions and 118 deletions
+60 -5
View File
@@ -31,6 +31,7 @@ namespace KinectServer
Socket oServerSocket;
bool bServerRunning = false;
bool waitForSubToStart = false;
KinectSettings oSettings;
object oClientSocketLock = new object();
@@ -232,19 +233,71 @@ namespace KinectServer
}
}
/// <summary>
/// Send temporal Sync Data to all client
/// </summary>
public void SendTemporalSyncData()
{
lock (oClientSocketLock)
{
lClientSockets[0].SendTemporalSyncStatus(true, false);
for (int i = 1; i < lClientSockets.Count; i++)
{
if(lClientSockets.Count > 1 && oSettings.bEnableSync)
{
lClientSockets[i].SendTemporalSyncStatus(false, true);
byte syncOffSetCounter = 1;
for (int i = 0; i < lClientSockets.Count; i++)
{
lClientSockets[i].SendTemporalSyncStatus(true, syncOffSetCounter);
syncOffSetCounter++;
}
waitForSubToStart = true;
}
else
{
for (int i = 0; i < lClientSockets.Count; i++)
{
lClientSockets[i].SendTemporalSyncStatus(false, 0);
}
}
}
}
/// <summary>
/// Called when a sub client has started. This checks if all sub clients have already started. If yes, we initialize the master
/// </summary>
public void CheckForMasterStart()
{
if (!oSettings.bEnableSync || !waitForSubToStart)
{
return;
}
bool allSubsStarted = true;
lock (oClientSocketLock)
{
for (int i = 0; i < lClientSockets.Count; i++)
{
if (!lClientSockets[i].bSubStarted && lClientSockets[i].currentTempSyncState == KinectSocket.eTempSyncConfig.SUBORDINATE)
{
allSubsStarted = false;
break;
}
}
if (allSubsStarted)
{
for (int i = 0; i < lClientSockets.Count; i++)
{
lClientSockets[i].SendMasterInitialize();
}
}
}
}
public bool GetStoredFrame(List<List<byte>> lFramesRGB, List<List<Single>> lFramesVerts)
{
bool bNoMoreStoredFrames;
@@ -373,6 +426,8 @@ namespace KinectServer
lClientSockets.Add(new KinectSocket(newClient));
lClientSockets[lClientSockets.Count - 1].SendSettings(oSettings);
lClientSockets[lClientSockets.Count - 1].eChanged += new SocketChangedHandler(SocketListChanged);
lClientSockets[lClientSockets.Count - 1].eSubInitialized += new SubOrdinateInitialized(CheckForMasterStart);
if (eSocketListChanged != null)
{
eSocketListChanged(lClientSockets);