public void MsgPackReader(string file, bool JSON) { Success = false; MsgPack MsgPack = file.ReadMPAllAtOnce(JSON); bool compact = MsgPack.ReadBoolean("Compact"); if (file.Contains("psrData")) { if (MsgPack.ElementArray("psrData", out MsgPack psrData)) { psrDat = new psrData[psrData.Array.Length]; for (i = 0; i < psrDat.Length; i++) { psrDat[i].SetValue(psrData[i]); } } else if (MsgPack.ContainsKey("psrData")) { psrDat = null; } Success = true; } else if (file.Contains("PvList")) { if (MsgPack.ElementArray("PvList", out MsgPack PvList)) { pvList = new PvList[PvList.Array.Length]; for (i = 0; i < pvList.Length; i++) { pvList[i].SetValue(PvList[i], compact); } } else if (MsgPack.ContainsKey("PvList")) { pvList = null; } Success = true; } MsgPack = MsgPack.New; }
public static MsgPack ReadMP(this MsgPack msg, ref CountPointer <float> val, string Name) { val.Offset = 0; val.Entries = null; if (msg.ContainsKey(Name)) { val.Count = 1; val[0] = msg.ReadSingle(Name); } else if (msg.ElementArray(Name, out MsgPack Temp)) { val.Count = Temp.Array.Length; for (int i = 0; i < val.Count; i++) { val[i] = Temp[i].ReadSingle(); } } return(msg); }
public static void ReadMP(this MsgPack msg, ref CountPointer <float> val, string Name) { val.Offset = 0; val.Entries = null; if (msg.ContainsKey(Name)) { val.Count = 1; val.Entries[0] = msg.ReadSingle(Name); } else if (msg.Element <MsgPack>(Name, out MsgPack Temp)) { val.Count = Temp.Array.Length; for (int i = 0; i < val.Count; i++) { if (Temp[i] is MsgPack temp) { val.Entries[i] = temp.ReadSingle(); } } } }