private void DataWriterFunc(LabDataBase data) { var datatype = data.GetType(); if (!_dataWriterDic.ContainsKey(datatype)) { string dataPath = string.Join("_", _saveDataPath + "/", _userId.Invoke().PadLeft(2, '0'), data.GetType().Name + ".json"); LabTools.CreatData(dataPath); _dataWriterDic.Add(datatype, new LabDataWriter(dataPath)); } _dataWriterDic[datatype].WriteData(data); }
private void DataWriterFunc(LabDataBase data) { var type = data.GetType(); if (!_dataWriterDic.ContainsKey(type)) { string dataPath = _saveDataPath + "/" + _userId.Invoke().PadLeft(2, '0') + "_" + data.GetType().Name + ".json"; LabTools.CreatData(dataPath); _dataWriterDic.Add(type, new LabDataWriter(dataPath)); } _dataWriterDic[type].WriteData(data); }
private void DoOnce(LabDataBase data) { if (!_isClientInit) { Debug.LogError("LabData未初始化"); return; } DataWriterFunc(data); if (_sendToServer) { Scope.Send(data); } }
public static T GetData <T>(LabDataBase data) where T : LabDataBase { return(data is T @base ? @base : null); }
public void DataCollect(LabDataBase data, bool loop = true, int frequency = 200) { }
public void WriteData(LabDataBase data) { _sw.WriteLine(data.ToJson()); }
/// <summary> /// 传输数据 /// </summary> public void SendData(LabDataBase data) { _dataQueue.Enqueue(data); GetDataAction?.Invoke(data); }