| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- using System.Collections.Generic;
- using Newtonsoft.Json.Linq;
- using o0.IMU;
- using o0.Geometry;
- using o0;
- public class AttitudeJson : JCUnityLib.CustomJson
- {
- public AttitudeJson() : base()
- {
- InitJsonClass<_9AxisPreProcessor>(() => new _9AxisPreProcessor(),
- "AccByteIndex",
- "GyrByteIndex",
- "MagByteIndex",
- "ByteToAcc",
- "ByteToGyr",
- "ByteToMag",
- "GyrCalibrater",
- "MagCalibrater",
- "ByteReverseMS"
- );
- InitJsonClass<MagnetometerAutoCalibrater>(() => new MagnetometerAutoCalibrater(),
- "CountPerLength",
- "EllipsoidFitting",
- "FitCountLeft",
- "FitThreshold",
- "LastTimestamp",
- "Lock",
- "MaxCount",
- "NewBlock",
- "NewBlockAccumulation",
- "Variance",
- "VectorByBlock"
- );
- InitJsonClass<ByteToShorts>(() => new ByteToShorts(3),
- "ByteToShort"
- );
- InitJsonClass<MeanMaintainer<Vector<double>>>(() => new MeanMaintainer<Vector<double>>(),
- "Count",
- "Mean"
- );
- InitJsonClass<ByteToShortByVariance>(() => new ByteToShortByVariance(),
- "Count",
- "Reverse",
- "Short",
- "ThresholdRate"
- );
- InitJsonClass<EllipsoidFitting>(
- o => {
- var to = (EllipsoidFitting)o;
- JToken jt = new JObject();
- jt["Center"] = ToJTokenByImporter(to.Center);
- jt["CorrectMatrixArray"] = ToJTokenByImporter(to.CorrectMatrixArray);
- jt["Raduis"] = ToJTokenByImporter(to.Radius);
- return jt;
- },
- jt => {
- var o = new EllipsoidFitting(
- (Vector<double>)ParseByExporter(jt["Center"], typeof(Vector<double>)),
- null,
- (Vector<double>)ParseByExporter(jt["Radius"], typeof(Vector<double>))
- );
- o.CorrectMatrixArray = (double[][])ParseByExporter(jt["CorrectMatrixArray"], typeof(double[][]));
- return o;
- }
- );
- InitJsonClass<Dictionary<Vector<int>, Vector<double>>>(
- o => JToken.FromObject(o),
- jt => {
- var o = new Dictionary<Vector<int>, Vector<double>>();
- foreach (JProperty item in jt)
- o[ParseByExporter<Vector<int>>(JArray.Parse(item.Name))]
- = ParseByExporter<Vector<double>>(item.Value);
- return o;
- }
- );
- InitJsonClass<Vector<int>>(
- o => JToken.FromObject(o),
- jt => new Vector<int>(jt.ToObject<int[]>())
- );
- InitJsonClass<Vector<double>>(
- o => JToken.FromObject(o),
- jt => new Vector<double>(jt.ToObject<double[]>())
- );
- }
- }
|