public KinectManager(GUI p, OmicronServer o) { kinectTable = new Hashtable(); newElevationKinectSensorList = new ArrayList(); //kinectColorViewer = new KinectColorViewer(p); kinectDepthViewer = new KinectDepthViewer(p); //KinectSkeletonViewerOnDepth = new KinectSkeletonViewer(p); //KinectSkeletonViewerOnDepth.ShowBones = true; //KinectSkeletonViewerOnDepth.ShowJoints = true; //KinectSkeletonViewerOnDepth.ShowCenter = true; //KinectSkeletonViewerOnDepth.ImageType = ImageType.Depth; //ShowBones="true" ShowJoints="true" ShowCenter="true" ImageType="Depth" server = o; gui = p; KinectStart(); // Create a timer with a ten second interval. elevationTimer = new Timer(10000); // Hook up the Elapsed event for the timer. elevationTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent); elevationTimer.Interval = timerIncrement; elevationTimer.Enabled = true; }
public GUI() { InitializeComponent(); SetKinectEnabled(false); omegaDesk = new OmicronServer(this); // Handles client connections touchManager = new TouchManager(this, omegaDesk); // PQLabs touch try { kinectManager = new KinectManager(this, omegaDesk); // Kinect via Kinect for Windows SDK kinectEnabled = true; } catch (Exception e) { //Console.WriteLine("KinectManager: Initialization exception: {0}", e.Message); Console.WriteLine("KinectManager: Failed to find Kinect SDK v1.7"); Console.WriteLine("KinectManager: Disabling Kinect"); } // Default GUI values touchServerList.Text = touchManager.GetServerIP(); messagePortBox.Text = omegaDesk.GetMsgPort().ToString(); pqGestureBox.Checked = touchManager.IsPQGesturesEnabled(); touchPointBox.Checked = touchManager.IsTouchPointsEnabled(); if (kinectEnabled) { voiceRecogCheckBox.Checked = kinectManager.IsVoiceInterfaceEnabled(); kinectAudioDebugTextCheckBox.Checked = kinectManager.IsVoiceConsoleTextEnabled(); } if( kinectSensorListBox.Items.Count > 0 ) kinectSensorListBox.SelectedIndex = 0; //if (kinectManager.GetKinectElevation() <= 27 && kinectManager.GetKinectElevation() >= -27) //{ // kinectElevationBar.Value = kinectManager.GetKinectElevation(); // elevationLabel.Text = kinectManager.GetKinectElevation().ToString(); //} thresholdBar.Value = touchManager.GetMoveThreshold(); thresholdNumLabel.Text = touchManager.GetMoveThreshold().ToString(); maxBlobSizeBar.Value = touchManager.GetMaxBlobSize(); maxBlobSizeNumLabel.Text = touchManager.GetMaxBlobSize().ToString(); bool serverOnStartup = false; // Config state to start server on startup? // Check for libraries if (touchManager.IsDisabled()) touchGroupBox.Enabled = false; if (!kinectEnabled) { kinectTabControl.Enabled = false; } // Read the config file try { String line; System.IO.StreamReader file = new System.IO.StreamReader("config.cfg"); bool readingServerList = false; bool readingClientList = false; bool readingKinectSpeechList = false; while ((line = file.ReadLine()) != null) { if (line.Contains('\t')) // Remove leading tabs line = line.Substring(line.IndexOf('\t') + 1, line.Length - 1); if (!line.StartsWith("//")) // Ignore comment lines { if (line.Contains("//")) // Remove trailing comments line = line.Substring(0, line.IndexOf('/') - 1); if (line.Contains("ServerUpOnStartup") && line.Contains("true") ) { serverOnStartup = true; continue; } if (line.Contains("EnableTouch") && line.Contains("true")) { touchEnableBox.Checked = true; } if (line.Contains("UseTouchPoints") && line.Contains("true")) { touchManager.SetTouchPoints(true); continue; } if (line.Contains("UseTouchGestures") && line.Contains("true")) { touchManager.SetPQGestures(true); continue; } if (line.Contains("MaxBlobSize") ) { int lineLength = line.Length - line.IndexOf('=') - 3; line = line.Substring(line.IndexOf('=') + 2, lineLength); setMaxBlobSize(Convert.ToInt16(line, 10)); continue; } if (line.Contains("MessagePort")) { int lineLength = line.Length - line.IndexOf('=') - 3; line = line.Substring(line.IndexOf('=') + 2, lineLength); int msgPort = (Convert.ToInt16(line, 10)); messagePortBox.Items.Add(msgPort); messagePortBox.Text = msgPort.ToString(); omegaDesk.SetMsgPort(msgPort); continue; } if (line.Contains("SERVER")) { readingServerList = true; continue; } else if (line.Contains("CLIENT")) { readingClientList = true; continue; } else if (line.Contains("SPEECH_CHOICES")) { readingKinectSpeechList = true; continue; } else if (line.Contains("}")) { readingServerList = false; readingClientList = false; readingKinectSpeechList = false; } if (readingServerList && !line.Contains("{") && !line.Contains("}")) { touchServerList.Items.Add(line); touchServerList.Text = line; } if (readingClientList && !line.Contains("{") && !line.Contains("}")) { touchClientList.Items.Add(line); touchClientList.Text = line; } if (readingKinectSpeechList && !line.Contains("{") && !line.Contains("}")) { if( kinectEnabled ) kinectManager.AddSpeechGrammarChoice(line); } } } } catch (FileNotFoundException e) { } // Set startup config settings if (serverOnStartup) { connectServerButton_Click(null, null); } pqGestureBox.Checked = touchManager.IsPQGesturesEnabled(); touchPointBox.Checked = touchManager.IsTouchPointsEnabled(); if (touchEnableBox.Checked) { touchManager.InitAndConnectServer(); } switch (omegaDesk.getOutputType()) { case (OmicronServer.OutputType.TacTile): tacTileRadioButton.Checked = true; break; case (OmicronServer.OutputType.Omicron): oinputserverRadioButton.Checked = true; break; case (OmicronServer.OutputType.Omicron_Legacy): oinputLegacyRadioButton.Checked = true; break; } // Update speech grammar and refresh GUI list if (kinectEnabled) kinectManager.GenerateNewSpeechGrammar(); speechGrammarListBox.Items.Clear(); if (kinectEnabled) foreach( String s in kinectManager.speechChoiceList ) speechGrammarListBox.Items.Add(s); //switch (kinectManager.GetSkeletonMode()) //{ // case (KinectManager.SkeletonMode.Off): // kinectSkeletonOffButton.Checked = true; // break; // case (KinectManager.SkeletonMode.Default): // kinectSkeletonDefaultButton.Checked = true; // break; // case (KinectManager.SkeletonMode.Seated): // kinectSkeletonSeatedButton.Checked = true; // break; //} }
public TouchManager(GUI g, OmicronServer o) { touchID = new int[maxTouches]; IDsHeld = new ArrayList(); ID_x = new float[maxTouches]; ID_y = new float[maxTouches]; ID_xW = new float[maxTouches]; ID_yW = new float[maxTouches]; omegaDesk = o; for (int i = 0; i < maxTouches; i++) { touchID[i] = 0; ID_x[i] = 0; ID_y[i] = 0; } // Initialize to check if DLL is present try { // initialize InitFuncOnTG(); // set the functions on receive SetFuncsOnReceiveProc(); disabled = false; } catch (Exception ex) { Console.WriteLine("TouchManager: Initialization exception: {0}", ex.Message); Console.WriteLine("TouchManager: Disabling touch"); disabled = true; } }
public Client(String clientAddr, int dataPrt, OmicronServer.OutputType outputType) { clientID = clientsCreated; clientsCreated++; udpClient = new UdpClient(); // Parse client address and remove the port, leaving the IPAddress of client String parsedIP = clientAddr; clientAddress = clientAddr; dataPort = dataPrt; IPAddress clientIP = IPAddress.Parse(parsedIP); data = ""; // Connect to the client's dataport udpClient.Connect(clientIP, dataPort); active = true; switch (outputType) { case (OmicronServer.OutputType.TacTile): dataFormat = OmicronServer.OutputType.TacTile; break; case (OmicronServer.OutputType.Omicron_Legacy): dataFormat = OmicronServer.OutputType.Omicron_Legacy; break; case (OmicronServer.OutputType.Omicron): dataFormat = OmicronServer.OutputType.Omicron; break; } }