public void OnDataSensor(object sender, DataReadyEventArgs e) { // LSL Implementation if (lslOutlet != null) { PushDataToLSL(e.Data); } if (MainWindow.isDrawing == false) { MainWindow.isDrawing = true; Thread paintThread = new Thread(PaintingHeatMap); paintThread.Start(e.Data); } }
private void handleDataReady(object sender, DataReadyEventArgs e) { if (e.seq != querySeq) //somebody else's data { return; } recvData = e.data; if (DumpSaveCB.Checked) { string folderPath = @Application.StartupPath + "\\Digger\\"; (new FileInfo(folderPath)).Directory.Create(); string fileName = Path.Combine(folderPath, "dump " + StartAddrText.Text + DateTime.Now.ToString("yyyyMMddHHmmss") + ".bin"); File.WriteAllBytes(fileName, recvData); } //Thanks to this, processing will be done in GUI thread //so we don't need to use SetBlahblahblah functions everywhere Delg.SetText(UglyMultithreadingHack, "b"); }
private void handleDataReady(object sender, DataReadyEventArgs e) { if (e.seq != querySeq) //somebody else's data { return; } recvData = e.data; if (DumpSaveCB.Checked) { string folderPath = @Application.StartupPath + "\\Digger\\"; (new FileInfo(folderPath)).Directory.Create(); string fileName = folderPath + "dump " + StartAddrText.Text + ".bin"; fileName = MainForm.NextAvailableFilename(fileName); FileStream fs = File.OpenWrite(fileName); fs.Write(recvData, 0, recvData.Length); fs.Close(); } //Thanks to this, processing will be done in GUI thread //so we don't need to use SetBlahblahblah functions everywhere MainForm.SetText(UglyMultithreadingHack, "b"); }
/// <summary> /// Is fired whenever KinectTable has new data ready. /// </summary> /// <param name="sender"></param> /// <param name="data"></param> void client_DataReady(object sender, DataReadyEventArgs args) { // Get the current data args.GetData(out data); // Show color image if available if (data.Available.colorImageEnable) { ImageFrameConverter.SetColorImage(colorBitmap, data.ColorImage); pictureBoxColor.Image = colorBitmap; } // Show depth image if available if (data.Available.depthImageEnable) { ImageFrameConverter.SetDepthImage(depthBitmap, data.DepthImage); pictureBoxDepth.Image = depthBitmap; } // Show test image if available if (data.Available.testImageEnable) { ImageFrameConverter.SetColorImage(testBitmap, data.TestImage); pictureBoxTest.Image = testBitmap; } // Create demo image and show it bool createdDemoImage = DemoImageCreator.CreateDemoImage(demoBitmap, data); if (createdDemoImage) { pictureBoxDemo.Image = demoBitmap; } return; }
private void OnReadyToSend(object sender, DataReadyEventArgs e) { _sender.SendData(e.Data); }
public void OnDataReadyEvent(DataReadyEventArgs obj) { _posts = obj.Data; OnPropertyChanged("Posts"); }
/// <summary> /// Is fired whenever KinectTable has new data ready. /// </summary> /// <param name="sender"></param> /// <param name="data"></param> void client_DataReady(object sender, DataReadyEventArgs args) { // Get the current data args.GetData(out data); // Show color image if available if (data.Available.colorImageEnable) { ImageFrameConverter.SetColorImage(colorBitmap, data.ColorImage); pictureBoxColor.Image = colorBitmap; } // Show depth image if available if (data.Available.depthImageEnable) { ImageFrameConverter.SetDepthImage(depthBitmap, data.DepthImage); pictureBoxDepth.Image = depthBitmap; } // Show test image if available if (data.Available.testImageEnable) { ImageFrameConverter.SetColorImage(testBitmap, data.TestImage); pictureBoxTest.Image = testBitmap; } // Create demo image and show it bool createdDemoImage = DemoImageCreator.CreateDemoImage(demoBitmap, data); if (createdDemoImage) pictureBoxDemo.Image = demoBitmap; return; }
private static void ValueDataReady(object sender, DataReadyEventArgs e) { Console.WriteLine(e.NewData); }
/// <summary> /// The updater_ data ready. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void UpdaterDataReady(object sender, DataReadyEventArgs e) { this.DataReady?.Invoke(this, new DataReadyEventArgs(e.NewData)); }
void hijack_DataReady(object sender, DataReadyEventArgs e) { //data是节点id if (int.Parse(e.ReceiveData.ToString()) > 128) { previous = int.Parse(e.ReceiveData.ToString()); } //data是温度值 else { if (previous == nodeId + 128) { for (Int32 i = 0; i < 4; i++) { // Update DataPoint YValue propert chart.Series[0].DataPoints[i].YValue = chart.Series[0].DataPoints[i + 1].YValue; // Changing the dataPoint YValue at runtime } chart.Series[0].DataPoints[4].YValue = double.Parse(e.ReceiveData.ToString()) + rand.NextDouble(); } } count = (count + 1) % 20; array.SetValue(int.Parse(e.ReceiveData.ToString()), count); if (count == 19) { hasNode1 = false; hasNode2 = false; hasNode3 = false; for (int i = 0; i < 20; i++) { if (array.GetValue(i).Equals(129)) { hasNode1 = true; pin1.Background = new SolidColorBrush(Colors.Red); } else if (array.GetValue(i).Equals(130)) { hasNode2 = true; pin2.Background = new SolidColorBrush(Colors.Red); } else if (array.GetValue(i).Equals(131)) { hasNode3 = true; pin3.Background = new SolidColorBrush(Colors.Red); } } if (hasNode1 == false) { pin1.Background = new SolidColorBrush(Colors.Gray); } if (hasNode2 == false) { pin2.Background = new SolidColorBrush(Colors.Gray); } if (hasNode3 == false) { pin3.Background = new SolidColorBrush(Colors.Gray); } for (int i = 0; i < 20; i++) { array.SetValue(i, 0); } } //for (Int32 i = 0; i < 4; i++) //{ // // Update DataPoint YValue propert // chart.Series[0].DataPoints[i].YValue = chart.Series[0].DataPoints[i + 1].YValue; // Changing the dataPoint YValue at runtime //} //chart.Series[0].DataPoints[4].YValue = int.Parse(e.ReceiveData.ToString()); //if (int.Parse(e.ReceiveData.ToString())>100) //{ // //VibrateController vc = VibrateController.Default; // //vc.Start(TimeSpan.FromMilliseconds(100)); //} }
/// <summary> /// The datetime provider data ready. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void DatetimeProviderDataReady(object sender, DataReadyEventArgs e) { var datareadyEventArgs = new DataReadyEventArgs(e.NewData); this.OnDataReady(datareadyEventArgs); }
/// <summary> /// The on data ready. /// </summary> /// <param name="e"> /// The e. /// </param> protected virtual void OnDataReady(DataReadyEventArgs e) { this.DataReady?.Invoke(this, e); }
// Kinect methods private void kinectClient_DataReady(object sender, DataReadyEventArgs args) { if (!studyController.currentCondition.UsesKinect() && !calibratingKinect) return; args.GetData(out kinectData); currentHand = null; var hands = kinectData.Hands; if (hands.Count() == 0) { if (showMyArm) { showMyArm = false; // Hide local arm showArms.X = false; // Hide arm on other client } // Move the cursor to the origin to prevent any crossing detection if (playerID == 0) { user1MouseLocation = user1Origin; coords.X = user1Origin.X; coords.Y = user1Origin.Y; } else if (playerID == 1) { user2MouseLocation = user2Origin; coords.X = user2Origin.X; coords.Y = user2Origin.Y; } return; } if (hands.Count() == 1) { currentHand = hands.First(); } else if (!kinectCalibration.calibrated) { currentHand = hands .OrderByDescending(h => h.MeanDepth).Take(2) .OrderByDescending(h => h.Area).First(); } else { Point center = new Point(Program.tableWidth / 2, Program.tableHeight - Program.usableHeight / 2); currentHand = hands .OrderBy(h => Utilities.distanceBetweenPoints(center, kinectCalibration.KinectToScreen(h.PalmCenter))) .First(); } if (studyController.currentCondition == HaikuStudyCondition.KinectArms || studyController.currentCondition == HaikuStudyCondition.KinectArmsVibration || calibratingKinect) { // Generate new arm image. myArmImage = new Bitmap(1280, 1024, PixelFormat.Format24bppRgb); ImageFrameConverter.SetColorImage(myArmImage, kinectData.ColorImage); // Generate the arm mask. ImageFrame mask = currentHand.CreateArmBlob(); myArmMask = new Bitmap(640, 480, PixelFormat.Format1bppIndexed); ImageFrameConverter.SetBinaryImage(myArmMask, mask); myArmRect = trimArmImages(ref myArmMask, ref myArmImage); var maskBytes = ImageToByteArray(myArmMask, ImageFormat.Png); var imgBytes = ImageToByteArrayJpeg(myArmImage, 90); if (!calibratingKinect) armImages.Send(new ArmImageMessage(imgBytes, maskBytes, myArmRect)); maskArm(myArmImage, myArmMask); if (DateTime.Now - lastArmImageFlush > TimeSpan.FromMilliseconds(40)) { armImages.Flush(); lastArmImageFlush = DateTime.Now; } } Point cursor; if (currentHand.FingerTips.Length > 0) cursor = currentHand.FingerTips.First(); else cursor = currentHand.PalmCenter; if (calibratingKinect) kinectCalibration.currentKinectLocation = cursor; if (kinectCalibration.calibrated) cursor = kinectCalibration.KinectToScreen(cursor); bool cursorOffScreen = cursor.X < 0 || cursor.X > Program.tableWidth || cursor.Y < 0 || cursor.Y > Program.tableHeight; if (showMyArm && cursorOffScreen && studyController.currentCondition.UsesKinectFakeArms() && tuioCursorID == -1) { showMyArm = false; if (!calibratingKinect) showArms.X = false; } else if (!showMyArm && !cursorOffScreen) { showMyArm = true; // Show local arm if (!calibratingKinect) showArms.X = true; // Show arm on other client } if (cursorOffScreen) return; Point avgCursor = smoothInput(cursor, recentCursors, recentDistance); if (tuioCursorID == -1) Cursor.Position = PointToScreen(avgCursor); if (studyController.currentCondition.UsesKinectOrigins()) { Point origin = currentHand.ArmBase; // Only set the origin if KinectTable could find the arm base. if (origin.X != -1) { if (kinectCalibration.calibrated) origin = kinectCalibration.KinectToScreen(origin); Point avgOrigin = smoothInput(origin, recentOrigins, recentDistance); // Create a box surrounding the window by 60px to attach arm origins to Rectangle box = new Rectangle(-60, -60, Program.tableWidth + 120, Program.tableHeight + 120); // Find angle between arm origin and cursor int xDiff = avgCursor.X - avgOrigin.X; int yDiff = avgCursor.Y - avgOrigin.Y; double theta = Math.Atan2(yDiff, xDiff); // Move the origin along the origin-cursor line to a point on the bounding box Point correctedOrigin = findIntersection(box, avgOrigin, theta); if (playerID == 0) user1Origin = correctedOrigin; else if (playerID == 1) user2Origin = correctedOrigin; origins.X = correctedOrigin.X; origins.Y = correctedOrigin.Y; } } }