AttitudeJson.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System.Collections.Generic;
  2. using Newtonsoft.Json.Linq;
  3. using o0.IMU;
  4. using o0.Geometry;
  5. using o0;
  6. public class AttitudeJson : JCUnityLib.CustomJson
  7. {
  8. public AttitudeJson() : base()
  9. {
  10. InitJsonClass<_9AxisPreProcessor>(() => new _9AxisPreProcessor(),
  11. "AccByteIndex",
  12. "GyrByteIndex",
  13. "MagByteIndex",
  14. "ByteToAcc",
  15. "ByteToGyr",
  16. "ByteToMag",
  17. "GyrCalibrater",
  18. "MagCalibrater",
  19. "ByteReverseMS"
  20. );
  21. InitJsonClass<MagnetometerAutoCalibrater>(() => new MagnetometerAutoCalibrater(),
  22. "CountPerLength",
  23. "EllipsoidFitting",
  24. "FitCountLeft",
  25. "FitThreshold",
  26. "LastTimestamp",
  27. "Lock",
  28. "MaxCount",
  29. "NewBlock",
  30. "NewBlockAccumulation",
  31. "Variance",
  32. "VectorByBlock"
  33. );
  34. InitJsonClass<ByteToShorts>(() => new ByteToShorts(3),
  35. "ByteToShort"
  36. );
  37. InitJsonClass<ByteToShort>(() => new ByteToShort(null),
  38. "MinCount",
  39. "Reverse",
  40. "Short"
  41. );
  42. InitJsonClass<MeanMaintainer<Vector<double>>>(() => new MeanMaintainer<Vector<double>>(),
  43. "Count",
  44. "Mean"
  45. );
  46. InitJsonClass<ByteToShortByVariance>(() => new ByteToShortByVariance(),
  47. "Count",
  48. "Reverse",
  49. "Short",
  50. "ThresholdRate"
  51. );
  52. InitJsonClass<EllipsoidFitting>(() => new EllipsoidFitting(default, null, default),
  53. "Center",
  54. "CorrectMatrixArray",
  55. "Radius"
  56. );
  57. InitJsonClass<Dictionary<Vector<int>, Vector<double>>>(
  58. o => JToken.FromObject(o),
  59. jt => {
  60. var o = new Dictionary<Vector<int>, Vector<double>>();
  61. foreach (JProperty item in jt)
  62. o[ParseByExporter<Vector<int>>(JArray.Parse(item.Name))]
  63. = ParseByExporter<Vector<double>>(item.Value);
  64. return o;
  65. }
  66. );
  67. InitJsonClass<Vector<int>>(
  68. o => JToken.FromObject(o),
  69. jt => new Vector<int>(jt.ToObject<int[]>())
  70. );
  71. InitJsonClass<Vector<double>>(
  72. o => JToken.FromObject(o),
  73. jt => new Vector<double>(jt.ToObject<double[]>())
  74. );
  75. }
  76. }