mirror of
https://github.com/storytold/LiveScan3D.git
synced 2026-10-15 00:04:11 +00:00
Finished Temporal Sync Feature
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user