@@ -31,11 +31,11 @@ public partial class ATFXReaderDemo : Form
3131 #region Fields
3232 DRDConverter drdConverter = new DRDConverter ( ) ;
3333 List < string > drdOutputPath ;
34- string drdFilesSelectedPath ;
34+ private string drdFilesSelectedPath ;
3535 ProgressBarForm pgForm ;
36- bool DRDConvertSucceed = false ;
37- string savePath ;
38- string currentOpenFile ;
36+ private bool DRDConvertSucceed = false ;
37+ private string currentOpenFile ;
38+ private EventHandler < DRDConverter . ProgressEventArgs > drdProgressHandler ;
3939
4040 /// <summary>
4141 /// Determine whether the current datagridview for Signals should be displaying
@@ -95,7 +95,6 @@ public ATFXReaderDemo()
9595 clmLowAlarm . Visible = false ;
9696 clmLowAbort . Visible = false ;
9797
98- //drdConverter.ReportProgress += new EventHandler<DRDConverter.ProgressArgs>(DRDConverterCombine_ReportProgress);
9998 bgWorkerDRDCombine . DoWork += new DoWorkEventHandler ( bgWorkerDRDCombine_DoWork ) ;
10099 bgWorkerDRDCombine . ProgressChanged += new ProgressChangedEventHandler ( bgWorkerDRDCombine_ProgressChanged ) ;
101100 bgWorkerDRDCombine . RunWorkerCompleted += new RunWorkerCompletedEventHandler ( bgWorkerDRDCombine_RunWorkerCompleted ) ;
@@ -142,7 +141,7 @@ private void ShowSignals(IRecording rec)
142141 /// <param name="rec"></param>
143142 private void ShowRecordings ( IRecording rec )
144143 {
145- if ( rec as ODSATFXMLRecording == null )
144+ if ( ! ( rec is ODSATFXMLRecording ) )
146145 {
147146 lbRecordingDataInfo . Items . Clear ( ) ;
148147 lbRecordingDataInfo . Items . Add ( rec ) ; // Add the initial IRecording object
@@ -484,7 +483,7 @@ private void ShowFrameData(DataGridView grid, ISignal signal, _SpectrumScalingTy
484483 {
485484 //Gets 1 framesize signal frame data I.E 1024 points
486485 //Changing the index will display the other frame data
487- ulong [ ] [ ] frame_ul = Utility . ReadTimeStampData ( signal , frameIndex * ( int ) signal . FrameSize , ( int ) ( frameIndex + 1 ) * ( int ) signal . FrameSize - 1 ) ;
486+ ulong [ ] [ ] frame_ul = Utility . ReadTimeStampData ( signal , frameIndex * ( int ) signal . FrameSize , ( frameIndex + 1 ) * ( int ) signal . FrameSize - 1 ) ;
488487 if ( frame_ul == null ) return ;
489488
490489 var frameSize = frame_ul [ 0 ] . Length ;
@@ -564,7 +563,7 @@ private void ShowFrameData(DataGridView grid, ISignal signal, _SpectrumScalingTy
564563 }
565564 catch ( Exception e )
566565 {
567-
566+ Utility . Log ( e ) ;
568567 }
569568 finally
570569 {
@@ -599,7 +598,7 @@ private void ShowTSDATFrameDataUTC(ISignal signal)
599598 clmLowAbort . Visible = false ;
600599
601600 //Read the TSDAT file and return list<DateTimeNano> and out ulong[] that is the index
602- var utcTSDATpoints = Utility . ReadTimeStampDataUTCFormat ( out ulong [ ] frame_ul , signal , frameIndex * ( int ) signal . FrameSize , ( int ) ( frameIndex + 1 ) * ( int ) signal . FrameSize - 1 ) ;
601+ var utcTSDATpoints = Utility . ReadTimeStampDataUTCFormat ( out ulong [ ] frame_ul , signal , frameIndex * ( int ) signal . FrameSize , ( frameIndex + 1 ) * ( int ) signal . FrameSize - 1 ) ;
603602
604603 for ( int i = 0 ; i < utcTSDATpoints . Count ; i ++ )
605604 {
@@ -619,7 +618,7 @@ private void ShowTSDATFrameDataUTC(ISignal signal)
619618 /// <param name="points"></param>
620619 /// <param name="pointsUTC"></param>
621620 /// <param name="formatUTC"></param>
622- private void ShowTSDATPoints ( DataGridView grid , ulong [ ] [ ] points = null , List < DateTimeNano > pointsUTC = null , ulong [ ] frame_ul = null , bool formatUTC = false )
621+ private static void ShowTSDATPoints ( DataGridView grid , ulong [ ] [ ] points = null , List < DateTimeNano > pointsUTC = null , ulong [ ] frame_ul = null , bool formatUTC = false )
623622 {
624623 if ( ! formatUTC && points == null ) return ;
625624 if ( formatUTC && pointsUTC == null && frame_ul == null ) return ;
@@ -838,7 +837,7 @@ private void LbSignalParameter_SelectedIndexChanged(object sender, EventArgs e)
838837 /// <param name="e"></param>
839838 private void LbRecording_SelectedIndexChanged ( object sender , EventArgs e )
840839 {
841- if ( lbRecordingDataInfo . SelectedItem is IRecording rec )
840+ if ( lbRecordingDataInfo . SelectedItem is IRecording )
842841 {
843842 //Keep tracks of the displayed grid for recording if switching from recording to signal and so on
844843 switch ( recordDataInfo )
@@ -879,7 +878,6 @@ private void BtnOpen_Click(object sender, EventArgs e)
879878 }
880879
881880 currentOpenFile = tbFile . Text = dlg . FileName ;
882- savePath = Path . GetDirectoryName ( dlg . FileName ) ;
883881 if ( RecordingManager . Manager . OpenRecording ( currentOpenFile , out IRecording rec ) )
884882 {
885883 LoadRecord ( rec ) ;
@@ -1138,7 +1136,7 @@ private void btnCalculateTSDAT_Click(object sender, EventArgs e)
11381136 }
11391137 catch ( Exception ex )
11401138 {
1141-
1139+ Utility . Log ( ex ) ;
11421140 }
11431141 }
11441142
@@ -1184,7 +1182,7 @@ private void btnReadTSDAT_Click(object sender, EventArgs e)
11841182 }
11851183 catch ( Exception ex )
11861184 {
1187-
1185+ Utility . Log ( ex ) ;
11881186 }
11891187 }
11901188
@@ -1387,15 +1385,14 @@ private void tpTSDATInfo_Enter(object sender, EventArgs e)
13871385 /// <param name="e"></param>
13881386 private void bgWorkerDRDCombine_DoWork ( object sender , DoWorkEventArgs e )
13891387 {
1390- var worker = sender as BackgroundWorker ;
1391-
13921388 this . Invoke ( ( MethodInvoker ) delegate
13931389 {
13941390 pgForm = new ProgressBarForm ( ) { Owner = this } ;
13951391 pgForm . Show ( ) ;
13961392 } ) ;
13971393
1398- drdConverter . ReportProgress += new EventHandler < DRDConverter . ProgressArgs > ( DRDConverterCombine_ReportProgress ) ;
1394+ drdProgressHandler = new EventHandler < DRDConverter . ProgressEventArgs > ( DRDConverterCombine_ReportProgress ) ;
1395+ drdConverter . ReportProgress += drdProgressHandler ;
13991396 string [ ] files = Directory . GetFiles ( drdFilesSelectedPath ) ;
14001397 drdOutputPath = drdConverter . CombineDRDFiles ( files , cbOnlyDATX . Checked , cbMergeAllDRD . Checked ) ;
14011398 }
@@ -1405,7 +1402,7 @@ private void bgWorkerDRDCombine_DoWork(object sender, DoWorkEventArgs e)
14051402 /// </summary>
14061403 /// <param name="sender"></param>
14071404 /// <param name="e"></param>
1408- protected void DRDConverterCombine_ReportProgress ( object sender , DRDConverter . ProgressArgs e )
1405+ protected void DRDConverterCombine_ReportProgress ( object sender , DRDConverter . ProgressEventArgs e )
14091406 {
14101407 bgWorkerDRDCombine . ReportProgress ( e . Percentage , e . Message ) ;
14111408 }
@@ -1435,7 +1432,7 @@ private void bgWorkerDRDCombine_ProgressChanged(object sender, ProgressChangedEv
14351432 /// <param name="e"></param>
14361433 protected void bgWorkerDRDCombine_RunWorkerCompleted ( object sender , RunWorkerCompletedEventArgs e )
14371434 {
1438- drdConverter . ReportProgress -= new EventHandler < DRDConverter . ProgressArgs > ( DRDConverterCombine_ReportProgress ) ;
1435+ drdConverter . ReportProgress -= drdProgressHandler ;
14391436 pgForm . ProgressBarUpdate ( 100 , "All ods, datx, ext files combined." ) ;
14401437 pgForm . Close ( ) ;
14411438 if ( drdOutputPath != null )
@@ -1467,7 +1464,7 @@ public void ReportStatus(ExportStatus eStatus)
14671464 /// </summary>
14681465 /// <param name="sender"></param>
14691466 /// <param name="e"></param>
1470- protected void DRDConverterConvert_ReportProgress ( object sender , DRDConverter . ProgressArgs e )
1467+ protected void DRDConverterConvert_ReportProgress ( object sender , DRDConverter . ProgressEventArgs e )
14711468 {
14721469 bgWorkerDRDConvert . ReportProgress ( e . Percentage , e . Message ) ;
14731470 }
@@ -1485,7 +1482,9 @@ private void bgWorkerDRDConvert_DoWork(object sender, DoWorkEventArgs e)
14851482 pgForm = new ProgressBarForm ( ) { Owner = this } ;
14861483 pgForm . Show ( ) ;
14871484 } ) ;
1488- drdConverter . ReportProgress += new EventHandler < DRDConverter . ProgressArgs > ( DRDConverterConvert_ReportProgress ) ;
1485+
1486+ drdProgressHandler = new EventHandler < DRDConverter . ProgressEventArgs > ( DRDConverterConvert_ReportProgress ) ;
1487+ drdConverter . ReportProgress += drdProgressHandler ;
14891488 status = new ExportStatus ( ) ;
14901489 delStatus = this . ReportStatus ;
14911490 DRDConvertSucceed = drdConverter . ConvertDATATFXFile ( drdOutputPath , delStatus , status ) ;
@@ -1499,14 +1498,13 @@ private void bgWorkerDRDConvert_DoWork(object sender, DoWorkEventArgs e)
14991498 /// <param name="e"></param>
15001499 protected void bgWorkerDRDConvert_RunWorkerCompleted ( object sender , RunWorkerCompletedEventArgs e )
15011500 {
1502- drdConverter . ReportProgress -= new EventHandler < DRDConverter . ProgressArgs > ( DRDConverterConvert_ReportProgress ) ;
1501+ drdConverter . ReportProgress -= drdProgressHandler ;
15031502 pgForm . ProgressBarUpdate ( 100 , "All combined files have been converted to ATFX and DAT files." ) ;
15041503 pgForm . Close ( ) ;
15051504 if ( DRDConvertSucceed )
15061505 {
15071506 string [ ] splitPath = drdOutputPath [ 0 ] . Split ( new string [ ] { "\\ " } , StringSplitOptions . None ) ;
1508- string drdATFXPath = drdOutputPath [ 0 ] + "\\ " + splitPath [ splitPath . Length - 1 ] + ".atfx" ;
1509- savePath = drdOutputPath [ 0 ] ;
1507+ string drdATFXPath = $ "{ drdOutputPath [ 0 ] } \\ { splitPath [ splitPath . Length - 1 ] } .atfx";
15101508 currentOpenFile = drdATFXPath ;
15111509 if ( drdOutputPath . Count == 1 )
15121510 {
0 commit comments