/// <summary> /// Event raised when the grip pressure has changed over the last iteration /// </summary> protected virtual void OnSensorDataChanged(SensorDataReceivedEventArgs AccEvent) { EventHandler <SensorDataReceivedEventArgs> handler = SensorDataChanged; if (handler != null) { handler(this, AccEvent); } }
private void EventHubReceiver_SensorDataReceived(object sender, SensorDataReceivedEventArgs e) { var data = e.WatchData; _hubContext.Clients .All .SendAsync("ReceiveData", data) .ConfigureAwait(false); }
/// <summary> /// Event handler that is called when the message is received from the android device /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnMessageReceived(object sender, TypedRequestReceivedEventArgs <String> e) { string s = e.RequestMessage; string indexParameter = s.Substring(0, 3); Console.WriteLine("indexParameter: " + indexParameter); switch (indexParameter) { case "Acc": int aindexX = s.IndexOf("X:"); int aindexY = s.IndexOf("Y:"); int aindexZ = s.IndexOf("Z:"); Acc_X = s.Substring(aindexX + 2, (aindexY - aindexX) - 2); Acc_Y = s.Substring(aindexY + 2, (aindexZ - aindexY) - 2); Acc_Z = s.Substring(aindexZ + 2); break; case "Gyr": int gindexX = s.IndexOf("X:"); int gindexY = s.IndexOf("Y:"); int gindexZ = s.IndexOf("Z:"); Gyro_X = s.Substring(gindexX + 2, (gindexY - gindexX) - 2); Gyro_Y = s.Substring(gindexY + 2, (gindexZ - gindexY) - 2); Gyro_Z = s.Substring(gindexZ + 2); break; case "Lig": Light = s.Substring(s.IndexOf("L:") + 2); break; case "Que": Answer = s.Substring(s.IndexOf("Q:") + 2); break; } SensorDataReceivedEventArgs args = new SensorDataReceivedEventArgs(); args.Answer = Answer; args.Acc_X = Acc_X; args.Acc_Y = Acc_Y; args.Acc_Z = Acc_Z; args.Gyro_X = Gyro_X; args.Gyro_Y = Gyro_Y; args.Gyro_Z = Gyro_Z; args.Light = Light; OnSensorDataChanged(args); SenderID = e.ResponseReceiverId; }