public static SERVideoStream OpenFile(string fileName, IWin32Window parentForm, TangraOpenFileArgs args, out SerEquipmentInfo equipmentInfo) { var fileInfo = new SerFileInfo(); equipmentInfo = new SerEquipmentInfo(); byte[] observer = new byte[40]; byte[] instrument = new byte[40]; byte[] telescope = new byte[40]; TangraCore.SEROpenFile(fileName, ref fileInfo, observer, instrument, telescope, false); string fireCaptureLogFileName = Path.ChangeExtension(fileName, ".txt"); var fireCaptureTimeStamps = new Dictionary <int, DateTime>(); if (File.Exists(fireCaptureLogFileName)) { string[] fireCaptureLogLines = File.ReadAllLines(fireCaptureLogFileName); fireCaptureLogLines = fireCaptureLogLines.Where(x => x != null && x.StartsWith("Frame ")).ToArray(); if (fireCaptureLogLines.Any()) { // Parse FireCapture timestamps Regex timestampRegEx = new Regex(@"Frame (\d+):\s+(UT)?\s+(\d\d\d\d\d\d)\s+(\d\d\d\d\d\d)\.(\d+)"); foreach (string line in fireCaptureLogLines) { Match match = timestampRegEx.Match(line); if (match.Success) { string frameNo = match.Groups[1].Value; bool isUT = match.Groups[2].Value == "UT"; string ddmmyy = match.Groups[isUT ? 3 : 2].Value; string hhmmss = match.Groups[isUT ? 4 : 3].Value; double fffff = double.Parse("0." + match.Groups[isUT ? 5 : 4].Value, CultureInfo.InvariantCulture); DateTime dt = new DateTime( 2000 + int.Parse(ddmmyy.Substring(4, 2)), int.Parse(ddmmyy.Substring(2, 2)), int.Parse(ddmmyy.Substring(0, 2)), int.Parse(hhmmss.Substring(0, 2)), int.Parse(hhmmss.Substring(2, 2)), int.Parse(hhmmss.Substring(4, 2))).AddMilliseconds(fffff * 1000); fireCaptureTimeStamps.Add(int.Parse(frameNo), dt); } } } } UsageStats.Instance.ProcessedSerFiles++; UsageStats.Instance.Save(); int bitPix; double frameRate; SerUseTimeStamp serTiming; if (args != null) { bitPix = args.BitPix; frameRate = args.FrameRate; serTiming = args.SerTiming; } else { var frmInfo = new frmEnterSERFileInfo(fileInfo, fireCaptureTimeStamps.Count > 0); if (frmInfo.ShowDialog(parentForm) != DialogResult.OK) { return(null); } frameRate = frmInfo.FrameRate; bitPix = frmInfo.BitPix; serTiming = frmInfo.UseEmbeddedTimeStamps; } TangraCore.SERCloseFile(); var rv = new SERVideoStream(fileName, frameRate, bitPix, serTiming, fireCaptureTimeStamps); equipmentInfo.Instrument = rv.Instrument; equipmentInfo.Observer = rv.Observer; equipmentInfo.Telescope = rv.Telescope; if (rv.HasTimeStamps || rv.HasUTCTimeStamps || rv.HasFireCaptureTimeStamps) { var frmCheckTS = new frmCheckTimeStampsIntegrity(rv); frmCheckTS.ShowDialog(parentForm); } return(rv); }
public static SERVideoStream OpenFile(string fileName, IWin32Window parentForm, TangraOpenFileArgs args, out SerEquipmentInfo equipmentInfo) { var fileInfo = new SerFileInfo(); equipmentInfo = new SerEquipmentInfo(); byte[] observer = new byte[40]; byte[] instrument = new byte[40]; byte[] telescope = new byte[40]; TangraCore.SEROpenFile(fileName, ref fileInfo, observer, instrument, telescope, false); string fireCaptureLogFileName = Path.ChangeExtension(fileName, ".txt"); var fireCaptureTimeStamps = new Dictionary<int, DateTime>(); if (File.Exists(fireCaptureLogFileName)) { string[] fireCaptureLogLines = File.ReadAllLines(fireCaptureLogFileName); fireCaptureLogLines = fireCaptureLogLines.Where(x => x != null && x.StartsWith("Frame ")).ToArray(); if (fireCaptureLogLines.Any()) { // Parse FireCapture timestamps Regex timestampRegEx = new Regex(@"Frame (\d+):\s+(UT)?\s+(\d\d\d\d\d\d)\s+(\d\d\d\d\d\d)\.(\d+)"); foreach (string line in fireCaptureLogLines) { Match match = timestampRegEx.Match(line); if (match.Success) { string frameNo = match.Groups[1].Value; bool isUT = match.Groups[2].Value == "UT"; string ddmmyy = match.Groups[isUT ? 3 : 2].Value; string hhmmss = match.Groups[isUT ? 4 : 3].Value; double fffff = double.Parse("0." + match.Groups[isUT ? 5 : 4].Value, CultureInfo.InvariantCulture); DateTime dt = new DateTime( 2000 + int.Parse(ddmmyy.Substring(4, 2)), int.Parse(ddmmyy.Substring(2, 2)), int.Parse(ddmmyy.Substring(0, 2)), int.Parse(hhmmss.Substring(0, 2)), int.Parse(hhmmss.Substring(2, 2)), int.Parse(hhmmss.Substring(4, 2))).AddMilliseconds(fffff * 1000); fireCaptureTimeStamps.Add(int.Parse(frameNo), dt); } } } } UsageStats.Instance.ProcessedSerFiles++; UsageStats.Instance.Save(); int bitPix; double frameRate; SerUseTimeStamp serTiming; if (args != null) { bitPix = args.BitPix; frameRate = args.FrameRate; serTiming = args.SerTiming; } else { var frmInfo = new frmEnterSERFileInfo(fileInfo, fireCaptureTimeStamps.Count > 0); if (frmInfo.ShowDialog(parentForm) != DialogResult.OK) { return null; } frameRate = frmInfo.FrameRate; bitPix = frmInfo.BitPix; serTiming = frmInfo.UseEmbeddedTimeStamps; } TangraCore.SERCloseFile(); var rv = new SERVideoStream(fileName, frameRate, bitPix, serTiming, fireCaptureTimeStamps); equipmentInfo.Instrument = rv.Instrument; equipmentInfo.Observer = rv.Observer; equipmentInfo.Telescope = rv.Telescope; if (rv.HasTimeStamps || rv.HasUTCTimeStamps || rv.HasFireCaptureTimeStamps) { var frmCheckTS = new frmCheckTimeStampsIntegrity(rv); frmCheckTS.ShowDialog(parentForm); } return rv; }