private void SendSampleList(List<SignalSample> sampleList) { if (client == null) client = new WiiServiceReference.WiiServiceClient(); if (client != null) { List<WiiServiceReference.SignalSample> sendseries = new List<WiiServiceReference.SignalSample>(); int count = 0; foreach (SignalSample s in adjustedSampleList1) if (s.TimeStamp > DateTime.Now + dateDifference - sendTimer.Interval) { sendseries.Add(new WiiServiceReference.SignalSample() { Sample = s.Sample, TimeStamp = s.TimeStamp, Source = s.Source }); } byte[] send = new byte[sendseries.Count]; byte[] tmpsend; foreach (WiiServiceReference.SignalSample s in sendseries) { send[count] = Convert.ToByte(s.Sample.X); count++; } tmpsend = new MD5CryptoServiceProvider().ComputeHash(send); try { //client.SendWiimoteData(sendseries); //client.SendWiimoteDataasHash(tmpsend,sendseries[0].TimeStamp,sendseries.Count); DateLastSignalSent = DateTime.Now; //sampleList1.Clear(); client.Close(); } catch { } finally { client = null; } } }
private void button2_Click(object sender, RoutedEventArgs e) { if (client == null) client = new WiiServiceReference.WiiServiceClient(); if (client != null) { try { DateTime serverTime = client.GetServerTime(); dateDifference = (serverTime - DateTime.Now); } catch { } finally { client = null; } } }
void SendHash(string toSend) { LastSentKey = toSend; byte[] tmpsend; tmpsend = new MD5CryptoServiceProvider().ComputeHash(Encoding.ASCII.GetBytes(toSend.Substring(0, 10))); if (client == null) { client = new WiiServiceReference.WiiServiceClient(); client.CheckWiimoteDataHashCompleted += new EventHandler<WiimoteTest.WiiServiceReference.CheckWiimoteDataHashCompletedEventArgs>(client_CheckWiimoteDataHashCompleted); } if (client != null) { try { client.CheckWiimoteDataHashAsync(tmpsend); DateLastSignalSent = DateTime.Now; client.Close(); } catch { } finally { client = null; } } }
private void btnCalibrate_Click(object sender, RoutedEventArgs e) { if (client == null) client = new WiiServiceReference.WiiServiceClient(); if (client != null) { List<SignalSample> minSample = sampleList1.Take(100).ToList(); List<WiiServiceReference.SignalSample> sendseries = new List<WiiServiceReference.SignalSample>(); foreach (SignalSample s in minSample) { //WiiServiceReference.Point3 p = new WiimoteTest.WiiServiceReference.Point3() { X = s.Sample.X, Y = s.Sample.Y, Z = s.Sample.Z }; sendseries.Add(new WiiServiceReference.SignalSample() { Sample = s.Sample, TimeStamp = s.TimeStamp + dateDifference, Source = s.Source }); } try { //client.Calibrate(sendseries); } catch { } finally { client = null; } } }