public Scope(string filename) { //Isolate importing from main program. //Main program state is for current test setup! DATA concatdata; LoggerState sd; try { string header = IO.ReadFileHeader(filename); sd = PersistentLoggerState.LoadHeader(header); this.n_channels = sd.n_channels; //You will need to inject settings dependency into IO to decode the header //However you are splitting the file by width which is settings dependent //TODO: think about lose coupling IO and file format IO.ReadCSV <int>(filename, IO.DelegateParseInt <int>, out List <List <int> > jjdarray, ',', true); //TODO: get n_channels from header //TODO: move from IO since this is a file conversion now! IO.ConvertJJD2DATA(jjdarray, this.n_channels, out concatdata); } catch (System.Exception ex) { if (ex is System.IO.IOException || ex is System.FormatException) { MessageBox.Show(ex.Message); return; } throw; } n_channels = sd.n_channels; //Must have some devices float n_devices = concatdata.Count; if (n_devices == 0) { return; } //Should match header ?check if (System.Math.Floor(n_devices) != n_devices) { return; //devices not multiple of data width } Import(concatdata, sd.duration); }
public static bool MoveTempFileAddHeader(PersistentLoggerState settings, string filepath) { string filename = settings.data.temp_filename; if (filename == "") { return(false); } string data = File.ReadAllText(filename); string header = settings.GetHeader(); filepath = CheckPath(filepath); File.WriteAllText(filepath, header + "\r\n" + data); //Clean up File.Delete(settings.data.temp_filename); settings.data.temp_filename = ""; return(true); }