static void Main() { Win32.AllocConsole(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); InputDialog d = new InputDialog("Connection details", "Which server:port ?", "localhost:9999"); if (d.ShowDialog() != DialogResult.OK) { return; } string[] parts = d.Input.Split(':'); string host = parts[0]; string port = parts.Length > 1 ? parts[1] : "9999"; PolhemusController polhemus = null; PhidgetController phidget = null; if (isDebug == false) { polhemus = new PolhemusController(false); phidget = new PhidgetController(polhemus); } mainForm = new Form1(polhemus, phidget, host, port); Application.Run(mainForm); }
public PolhemusController(Boolean polhemusConnected) { lastDatasetForEachStation = new Dictionary<int, Dataset>(); //for (int i = 1; i <= Constants.numberOfPlayers; i++) lastDatasetForEachStation[1] = new Dataset(); lastDatasetForEachStation[2] = new Dataset(); if (polhemusConnected == true) { try { Factory.CreateInstance(Debugmode.NoDebug); Factory.Instance.PollingDelay = 30; Factory.Instance.OnPolhemusButtonDown += new PolhemusEvent(OnPolhemusButtonDown); Factory.Instance.OnPolhemusButtonUp += new PolhemusEvent(OnPolhemusButtonUp); Factory.Instance.OnPolhemusMove += new PolhemusEvent(OnPolhemusMove); isConnected = true; Console.WriteLine("done with polhemus setup"); } catch (Exception e) { Console.WriteLine("There is no Polhemus connection: " + e); isConnected = false; } sharedPolhemusController = this; } }
//Servo servo; //Timer updateTimer; public PhidgetController(PolhemusController inPolhemusController) { polhemusController = inPolhemusController; if (Program.usePens) { penKit = new InterfaceKit(); setUpInterfaceKit(penKit); } Analog analog1 = new Analog(); setUpAnalog(analog1); /* for (int i = 0; i < analog1.outputs.Count; i++) { analog1.outputs[i].Voltage = analog1.outputs[i].VoltageMax; analog1.outputs[i].Enabled = true; }*/ }
public Form1(PolhemusController newPolhemusController, PhidgetController newPhidgetController, string host, string port) { this.host = host; this.port = port; InitializeComponent(); this.SetStyle( ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer, true); polhemusController = newPolhemusController; phidgetController = newPhidgetController; this.BackColor = Color.Black; this.Size = new Size(Program.tableWidth, Program.tableHeight); studyController = new HaikuStudyController(HaikuStudyPosition.SideBySide);//, HaikuStudyType.RealArmsPictureArms); wordBoxController = new WordBoxController(studyController); if (studyController.isActuatePenalty == true) { //phidgetController.setUpServos(); } //to snap words back to their original locations when dropped outside of a user's paper, set this to true. wordBoxController.boxesShouldSnapBack = true; studyController.wordBoxController = wordBoxController; studyController.currentCondition = HaikuStudyCondition.Cursors; studyController.isInSetUpMode = false; setMouseProperties(); setUpEmbodiments(); if (Program.kinectEnabled) { // Set up KinectTable kinectData = new KinectData(); // Set up session parameters SessionParameters sessionParams = new SessionParameters(KinectDataParams.EnableType.All); sessionParams.DataParams.validityImageEnable = false; sessionParams.DataParams.testImageEnable = false; // Connect to a local Kinect and hook up to the data event kinectClient = KinectTableNet.KinectTable.ConnectLocal(sessionParams); kinectClient.DataReady += kinectClient_DataReady; // Set up Kinect calibration kinectCalibration = new KinectCalibrationController(); // Read the saved table depth tweak value ReadTableDepthTweak(); } Cursor.Hide(); Load += Form1_Load; FormClosed += Form1_FormClosed; playerID = 0; updateTimer = new Timer(); updateTimer.Interval = 25; updateTimer.Tick += new EventHandler(updateTimer_Tick); updateTimer.Start(); }