Skip to main content

Class DataLog

The polymorphic root type for all data payloads in the logging pipeline.

[Serializable]
public class DataLog

Inheritance​

object→DataLog

Derived​

Examples​

Subclass DataLog to add the fields needed for a specific sensor, then return an instance from Collect so the pipeline picks it up. The [Serializable] attribute is required for Unity's JSON export to reach the fields:

using System;
using mobisim.Analysis.DataCollections;

[Serializable]
public class BatteryDataLog : DataLog
{
public float chargePercent;
public float voltageV;

public BatteryDataLog(float chargePercent, float voltageV)
{
this.chargePercent = chargePercent;
this.voltageV = voltageV;
}
}

// In the IDataLoggable component on the same actor:
public DataLog Collect()
{
if (!enabled) return null;
return new BatteryDataLog(_battery.ChargePercent, _battery.VoltageV);
}
// DataCollector in the actor hierarchy discovers this component automatically and
// bundles the BatteryDataLog into a MasterDatalog on each analysis pass.

Remarks​

This class exists to give the pipeline a single, concrete base type that Unity's serialization system can represent as a [SerializeReference] field. It acts as a shared concrete base that allows MasterDatalog to store heterogeneous log entries (transform data, battery data, speed data, …) in a single List field without knowing each subtype in advance.

Every loggable component defines its own subclass (e.g. BatteryDataLog, TransformDataLog) that adds the fields relevant to that sensor. The base class itself carries no fields intentionally — if it did, every log entry in the system would pay the serialization cost of those fields even when they are irrelevant.