1- use  capnp :: message :: Builder ; 
1+ use  std :: collections :: HashMap ; 
22
3+ use  capnp:: message:: Builder ; 
34use  log:: error; 
45use  sbp:: messages:: { 
56    navigation:: { MsgAgeCorrections ,  MsgUtcTime } , 
67    orientation:: MsgBaselineHeading , 
78    piksi:: MsgResetFilters , 
89} ; 
9- use  std:: { collections:: HashMap ,  io:: Write } ; 
1010
1111use  crate :: constants:: * ; 
1212use  crate :: date_conv:: * ; 
13- use  crate :: output:: { BaselineLog ,   CsvSerializer } ; 
13+ use  crate :: output:: BaselineLog ; 
1414use  crate :: piksi_tools_constants:: EMPTY_STR ; 
1515use  crate :: types:: { 
1616    BaselineNED ,  CapnProtoSender ,  Deque ,  GnssModes ,  GpsTime ,  MsgSender ,  Result ,  SharedState , 
@@ -52,9 +52,8 @@ pub(crate) struct BaselineTabButtons {
5252/// - `table`: This stores all the key/value pairs to be displayed in the Baseline Table. 
5353/// - `utc_source`: The string equivalent for the source of the UTC updates. 
5454/// - `utc_time`: The stored monotonic Utc time. 
55- /// - `baseline_log_file`: The CsvSerializer corresponding to an open velocity log if any. 
5655/// - `week`: The stored week value from GPS Time messages. 
57- pub  struct  BaselineTab < ' a ,  S :  CapnProtoSender ,   W :   Write >  { 
56+ pub  struct  BaselineTab < ' a ,  S :  CapnProtoSender >  { 
5857    age_corrections :  Option < f64 > , 
5958    client_sender :  S , 
6059    heading :  Option < f64 > , 
@@ -73,17 +72,12 @@ pub struct BaselineTab<'a, S: CapnProtoSender, W: Write> {
7372    table :  HashMap < & ' a  str ,  String > , 
7473    utc_source :  Option < String > , 
7574    utc_time :  Option < UtcDateTime > , 
76-     pub  baseline_log_file :  Option < CsvSerializer > , 
7775    week :  Option < u16 > , 
78-     wtr :  MsgSender < W > , 
76+     wtr :  MsgSender , 
7977} 
8078
81- impl < ' a ,  S :  CapnProtoSender ,  W :  Write >  BaselineTab < ' a ,  S ,  W >  { 
82-     pub  fn  new ( 
83-         shared_state :  SharedState , 
84-         client_sender :  S , 
85-         wtr :  MsgSender < W > , 
86-     )  -> BaselineTab < ' a ,  S ,  W >  { 
79+ impl < ' a ,  S :  CapnProtoSender >  BaselineTab < ' a ,  S >  { 
80+     pub  fn  new ( shared_state :  SharedState ,  client_sender :  S ,  wtr :  MsgSender )  -> BaselineTab < ' a ,  S >  { 
8781        BaselineTab  { 
8882            age_corrections :  None , 
8983            client_sender, 
@@ -122,7 +116,6 @@ impl<'a, S: CapnProtoSender, W: Write> BaselineTab<'a, S, W> {
122116            } , 
123117            utc_source :  None , 
124118            utc_time :  None , 
125-             baseline_log_file :  None , 
126119            week :  None , 
127120            wtr, 
128121        } 
@@ -294,22 +287,25 @@ impl<'a, S: CapnProtoSender, W: Write> BaselineTab<'a, S, W> {
294287            } 
295288        } 
296289
297-         if  let  Some ( baseline_file)  = & mut  self . baseline_log_file  { 
298-             let  pc_time = format ! ( "{}:{:0>6.06}" ,  tloc,  secloc) ; 
299-             if  let  Err ( err)  = baseline_file. serialize ( & BaselineLog  { 
300-                 pc_time, 
301-                 gps_time, 
302-                 tow_s :  Some ( tow) , 
303-                 north_m :  Some ( n) , 
304-                 east_m :  Some ( e) , 
305-                 down_m :  Some ( d) , 
306-                 h_accuracy_m :  Some ( h_accuracy) , 
307-                 v_accuracy_m :  Some ( v_accuracy) , 
308-                 distance_m :  Some ( dist) , 
309-                 flags :  baseline_ned_fields. flags , 
310-                 num_sats :  baseline_ned_fields. n_sats , 
311-             } )  { 
312-                 eprintln ! ( "Unable to to write to baseline log, error {}." ,  err) ; 
290+         { 
291+             let  mut  shared_data = self . shared_state . lock ( ) . unwrap ( ) ; 
292+             if  let  Some ( ref  mut  baseline_file)  = ( * shared_data) . baseline_tab . log_file  { 
293+                 let  pc_time = format ! ( "{}:{:0>6.06}" ,  tloc,  secloc) ; 
294+                 if  let  Err ( err)  = baseline_file. serialize ( & BaselineLog  { 
295+                     pc_time, 
296+                     gps_time, 
297+                     tow_s :  Some ( tow) , 
298+                     north_m :  Some ( n) , 
299+                     east_m :  Some ( e) , 
300+                     down_m :  Some ( d) , 
301+                     h_accuracy_m :  Some ( h_accuracy) , 
302+                     v_accuracy_m :  Some ( v_accuracy) , 
303+                     distance_m :  Some ( dist) , 
304+                     flags :  baseline_ned_fields. flags , 
305+                     num_sats :  baseline_ned_fields. n_sats , 
306+                 } )  { 
307+                     eprintln ! ( "Unable to to write to baseline log, error {}." ,  err) ; 
308+                 } 
313309            } 
314310        } 
315311
0 commit comments