@@ -13,6 +13,7 @@ public abstract class Tracker : MonoBehaviour
1313 {
1414 private bool recording = false ;
1515 private static string [ ] baseHeaders = new string [ ] { "time" } ;
16+ private TrackerState currentState = TrackerState . Uninitialised ;
1617
1718 /// <summary>
1819 /// Name of the object used in saving
@@ -44,7 +45,11 @@ public string DataName
4445 public bool Recording { get { return recording ; } }
4546
4647 public UXFDataTable Data { get ; private set ; } = new UXFDataTable ( ) ;
47-
48+
49+ /// <summary>
50+ /// The current state of the tracker.
51+ /// </summary>
52+ public TrackerState CurrentState { get => currentState ; }
4853
4954 /// <summary>
5055 /// When the tracker should take measurements.
@@ -87,17 +92,58 @@ public void RecordRow()
8792 /// </summary>
8893 public void StartRecording ( )
8994 {
95+ if ( currentState == TrackerState . On )
96+ {
97+ Debug . LogWarning ( $ "Start command received for tracker in state: '{ TrackerState . On } '." +
98+ $ " This will dump exisiting data! " +
99+ "If you want to restart a paused tracker, use 'ResumeRecording()' instead." ) ;
100+ }
90101 var header = baseHeaders . Concat ( CustomHeader ) ;
91102 Data = new UXFDataTable ( header . ToArray ( ) ) ;
92103 recording = true ;
104+ currentState = TrackerState . On ;
93105 }
94106
95107 /// <summary>
96108 /// Stops recording.
97109 /// </summary>
98110 public void StopRecording ( )
99111 {
112+ if ( currentState != TrackerState . On )
113+ {
114+ Debug . LogWarning ( $ "Stop command received for tracker in state: '{ currentState } '." +
115+ $ " This should only be called when tracker is in state '{ TrackerState . On } '") ;
116+ }
117+ recording = false ;
118+ currentState = TrackerState . Off ;
119+ }
120+
121+ /// <summary>
122+ /// Pauses recording.
123+ /// </summary>
124+ public void PauseRecording ( )
125+ {
126+ if ( currentState != TrackerState . On )
127+ {
128+ Debug . LogWarning ( $ "Pause command received for tracker in state: '{ currentState } '." +
129+ $ "This should only be called when tracker is in state '{ TrackerState . On } '") ;
130+ }
100131 recording = false ;
132+ currentState = TrackerState . Paused ;
133+ }
134+
135+ /// <summary>
136+ /// Resumes recording.
137+ /// </summary>
138+ public void ResumeRecording ( )
139+ {
140+ if ( currentState != TrackerState . Paused )
141+ {
142+ Debug . LogWarning ( $ "Resume command received for tracker in state: '{ currentState } '." +
143+ $ "This should only be called when tracker is in state '{ TrackerState . Paused } '") ;
144+ }
145+ recording = true ;
146+ currentState = TrackerState . On ;
101147 }
102148
103149 /// <summary>
@@ -115,4 +161,12 @@ public enum TrackerUpdateType
115161 {
116162 LateUpdate , FixedUpdate , Manual
117163 }
164+
165+ /// <summary>
166+ /// The possible states a tracker can be in.
167+ /// </summary>
168+ public enum TrackerState
169+ {
170+ On , Off , Paused , Uninitialised
171+ }
118172}
0 commit comments