void Open(int i)
{
try
{
Close(i);
OpenNIState state = FState[i];
var context = new Context();
FState[i].Context = context;
context.AddLicense(FLicense);
context.GlobalMirror = false;
NodeInfoList list = context.EnumerateProductionTrees(global::OpenNI.NodeType.Device, null);
NodeInfo node = null;
if (FPinInNodes[i] != "")
{
foreach (NodeInfo nodeitem in list)
{
if (nodeitem.CreationInfo == FPinInNodes[i])
{
node = nodeitem;
break;
}
}
if (node == null)
throw (new Exception("This device is unavailable. Check upstream ListDevices node"));
context.CreateProductionTree(node);
}
state.DepthGenerator = new DepthGenerator(context);
MapOutputMode depthMode = new MapOutputMode();
depthMode.FPS = 30;
depthMode.XRes = 640;
depthMode.YRes = 480;
state.DepthGenerator.MapOutputMode = depthMode;
state.DepthGenerator.StartGenerating();
state.Start();
FPinOutContext[i] = state;
FPinOutStatus[i] = "OK";
}
catch (Exception e)
{
Close(i);
FPinOutStatus[i] = e.Message;
}
}