async private void Client_MessageReceived(object sender, NetworkItMessageEventArgs e) { await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { if (e.ReceivedMessage.Name == "RFID_TAG") { LaunchScreen.Visibility = Visibility.Collapsed; MeasureScreen.Visibility = Visibility.Collapsed; RFIDScreen.Visibility = Visibility.Visible; TagLabel.Text = e.ReceivedMessage.GetField("rfidTag"); } else if (e.ReceivedMessage.Name == "SERVO_POSITION") { double servoPosition = Double.Parse(e.ReceivedMessage.GetField("position")); double servoPositionMin = Double.Parse(e.ReceivedMessage.GetField("positionMin")); double servoPositionMax = Double.Parse(e.ReceivedMessage.GetField("positionMax")); // hack caliper measure between 0-60mm CaliperMeasure.Text = string.Format("{0:0.0}", CosineInterpolate(60.0, 0.0, (servoPosition / (servoPositionMax - servoPositionMin)))) + "mm"; Debug.WriteLine("CaliperMeasure.Text: " + CaliperMeasure.Text); }// Update your UI objects here (e.g. sliders, ellipses, etc.) }); }
//==================================== // Network events, consumer-producer pattern required private void Connection_MessageReceived(object sender, NetworkItMessageEventArgs e) { lock (messageEvents) { messageEvents.AddLast(e.ReceivedMessage); } }
async private void Client_MessageReceived(object sender, NetworkItMessageEventArgs e) { }
async private void Client_MessageReceived(object sender, NetworkItMessageEventArgs e) { await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { if (e.ReceivedMessage.Name == "RFID_TAG") { LaunchScreen.Visibility = Visibility.Collapsed; MeasureScreen.Visibility = Visibility.Collapsed; RFIDScreen.Visibility = Visibility.Visible; TagLabel.Text = e.ReceivedMessage.GetField("rfidTag"); } else if (e.ReceivedMessage.Name == "SERVO_POSITION") { double servoPosition = Double.Parse(e.ReceivedMessage.GetField("position")); double servoPositionMin = Double.Parse(e.ReceivedMessage.GetField("positionMin")); double servoPositionMax = Double.Parse(e.ReceivedMessage.GetField("positionMax")); // hack caliper measure between 0-60mm CaliperMeasure.Text = string.Format("{0:0.0}", CosineInterpolate(60.0, 0.0, (servoPosition/(servoPositionMax-servoPositionMin)))) + "mm"; Debug.WriteLine("CaliperMeasure.Text: " + CaliperMeasure.Text); }// Update your UI objects here (e.g. sliders, ellipses, etc.) }); }
private void Client_MessageReceived(object sender, NetworkItMessageEventArgs e) { WriteLogLine(e.ReceivedMessage.ToString()); }
async private void Client_MessageReceived(object sender, NetworkItMessageEventArgs e) { }
private void Client_MessageReceived(object sender, NetworkItMessageEventArgs e) { int random = RandomInt(1, 2); Debug.WriteLine(e.ReceivedMessage.ToString()); NetworkIt.Message m = e.ReceivedMessage; if (m.Subject.Equals("force")) { int power = 0; int.TryParse(m.GetField("message"), out power); Debug.WriteLine("power" + power); if (power >= 1 && power <= 2) { Debug.WriteLine("light squeeze"); if (random == 1) { soundtoPlay = new SoundPlayer("audio\\whyhellothere.wav"); soundtoPlay.Play(); } else { soundtoPlay = new SoundPlayer("audio\\caliente.wav"); soundtoPlay.Play(); } } else if (power == 3) { random = RandomInt(1, 3); Debug.WriteLine("medium squeeze"); if (random == 1) { soundtoPlay = new SoundPlayer("audio\\letsgo.wav"); soundtoPlay.Play(); } else if (random == 2) { soundtoPlay = new SoundPlayer("audio\\onestepatatime.wav"); soundtoPlay.Play(); } else if (random == 3) { soundtoPlay = new SoundPlayer("audio\\imsoalive.wav"); soundtoPlay.Play(); } } else if (power == 4) { random = RandomInt(1, 4); Debug.WriteLine("big squeeze"); if (random == 1) { soundtoPlay = new SoundPlayer("audio\\ow_easy.wav"); soundtoPlay.Play(); } else if (random == 2) { soundtoPlay = new SoundPlayer("audio\\whatstheproblem.wav"); soundtoPlay.Play(); } else if (random == 3) { soundtoPlay = new SoundPlayer("audio\\cryout.wav"); soundtoPlay.Play(); } else if (random == 4) { soundtoPlay = new SoundPlayer("audio\\youok.wav"); soundtoPlay.Play(); } } } }
private void Client_MessageReceived(object sender, NetworkItMessageEventArgs e) { Console.WriteLine("Client_MessageReceived: " + e.ReceivedMessage.Name); }
private void Client_MessageReceived(object sender, NetworkItMessageEventArgs e) { Console.WriteLine("Client_MessageReceived: " + e.ReceivedMessage.Name); }