public BatCallViewModel(BatNodeLog log, BatCall batCall, int index) { Index = index; _log = log; _batCall = batCall; _fftAnalyzer = new FftAnalyzer(2, 5); }
protected LogDetailsPageModel(BatNodeLog batLog) { EditLogCommand = new RelayCommand(() => _navigationService.EditLog(BatLog)); BatLog = batLog; _batCalls = new List<BatCall>(); FrequencyRange = new Range<uint>(0, 100); FrequencyRange.PropertyChanged += async (s, e) => await UpdateBins(); IntensityRange = new Range<uint>(0, 1024); IntensityRange.PropertyChanged += async (s, e) => await UpdateBins(); DurationRange = new Range<uint>(0, 100); DurationRange.PropertyChanged += async (s, e) => await UpdateBins(); TimeRange = new Range<uint>(0, 100); TimeRange.PropertyChanged += async (s, e) => await UpdateBins(); //BUG! Func<BatCall, bool> filter = c => IntensityRange.Contains(c.MaxPower) && FrequencyRange.Contains(c.MaxFrequency) && DurationRange.Contains(c.Duration / 1000) && TimeRange.Contains(c.StartTimeMs); FreqBins = new UintBinCollection(100, b => (uint)b.MaxFrequency, filter); IntensityBins = new UintBinCollection(200, b => (uint)b.MaxPower, filter); CallDurationBins = new UintBinCollection(100, b => b.Duration / 1000, filter); TimeBins = new TimeCallBinCollection(200, batLog.LogStart, filter); }
public BatLogViewModel(BatNodeLog batNodeLog) { FrequencyRange = new Range<int>(0, 100); IntensityRange = new Range<int>(0, 1024); _batNodeLog = batNodeLog; _bins = new TimeCallBinCollection(300, batNodeLog.LogStart, c => true); }
private void ReadInfoRecord(BatNodeLog log, BinaryReader reader) { BatInfo info = new BatInfo(); info.Time = CreateDate(reader.ReadUInt32()); info.TimeMs = reader.ReadUInt32(); info.BatteryVoltage = reader.ReadUInt16(); info.SampleDuration = reader.ReadUInt16(); log.Infos.Add(info); }
public BatCall(BatNodeLog log, uint startTimeMs, uint duration, uint maxFrequency, uint maxPower, uint avgFrequency, uint dcOffset, byte[] data) { StartTimeMs = startTimeMs; Duration = duration; MaxFrequency = maxFrequency; MaxPower = maxPower; AvgFrequency = avgFrequency; DcOffset = dcOffset; StartTime = log.LogStart.AddMilliseconds(startTimeMs); FftData = data; Enabled = true; }
public BatCall(BatNodeLog log, uint startTimeMs, uint duration, uint maxFrequency, uint maxPower, uint avgFrequency, uint dcOffset, byte[] data, byte[] powerData) { StartTimeMs = startTimeMs; Duration = duration; MaxFrequency = maxFrequency; MaxPower = maxPower; AvgFrequency = avgFrequency; DcOffset = dcOffset; StartTime = log.LogStart.AddMilliseconds(startTimeMs); FftData = data; PowerData = powerData; Enabled = true; }
public async Task<BatNodeLog> Load(IStorageFile file) { BatNodeLog log = new BatNodeLog(); log.LogStart = DateTime.UtcNow; using (Stream logStream = await file.OpenStreamForReadAsync()) { using (BinaryReader reader = new BinaryReader(logStream)) { ReadData(log, reader); } } log.CallCount = log.Calls.Count; return log; }
private void ReadHeader(BatNodeLog log, BinaryReader reader) { byte[] marker = reader.ReadBytes(2); if (marker[0] != 76) // 76 -> L { throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, "Ungültiger Marker ({0}).", marker[0])); } log.Verison = marker[1]; log.NodeId = reader.ReadByte(); uint seconds = reader.ReadUInt32(); DateTime startTime = CreateDate(seconds); log.LogStart = startTime; }
public EditLogViewModel(NavigationEventArgs navigation, BatContext db, NavigationHelper navigationHelper) { _db = db; _navigationHelper = navigationHelper; _batLog = (BatNodeLog)navigation.Parameter; SaveCommand = new RelayCommand(async () => await SaveAction()); CancelCommand = new RelayCommand(() => GoBack()); PivotItems = new ObservableCollection<PivotModelBase>(); PivotItems.Add(new EditCallsPivotModel(_batLog, this)); PivotItems.Add(new EditCallsPivotModel(_batLog, this)); }
public async Task <BatNodeLog> Load(IStorageFile file) { BatNodeLog log = new BatNodeLog(); log.LogStart = DateTime.UtcNow; using (Stream logStream = await file.OpenStreamForReadAsync()) { using (BinaryReader reader = new BinaryReader(logStream)) { ReadData(log, reader); } } log.CallCount = log.Calls.Count; return(log); }
private void ReadCallRecord(BatNodeLog log, BinaryReader reader) { BatCall call = new BatCall(); call.Duration = reader.ReadUInt32(); call.StartTimeMs = reader.ReadUInt32(); call.ClippedSamples = reader.ReadUInt16(); call.MaxPower = reader.ReadUInt16(); call.MissedSamples = reader.ReadUInt16(); call.FftData = reader.ReadBytes(512); AnalyzeFftData(call); log.Calls.Add(call); }
private void ReadData(BatNodeLog log, BinaryReader reader) { RecordTypes recordType = GetNextRecordType(reader); if (recordType != RecordTypes.Header) { throw new InvalidOperationException("No Header found in Log File!"); } ReadHeader(log, reader); while (reader.BaseStream.Position < reader.BaseStream.Length) { recordType = GetNextRecordType(reader); switch (recordType) { case RecordTypes.None: break; case RecordTypes.Call: if (log.Verison == 1) { ReadCallRecordV1(log, reader); } else { ReadCallRecordV2(log, reader); } break; case RecordTypes.Info: ReadInfoRecord(log, reader); break; case RecordTypes.Header: BatMapperEvents.Log.LogImportHeaderRecordWithinFile(reader.BaseStream.Position); break; default: throw new ArgumentOutOfRangeException(); } } }
private void ReadData(BatNodeLog log, BinaryReader reader) { while (reader.BaseStream.Position < reader.BaseStream.Length) { RecordTypes recordType = GetNextRecordType(reader); switch (recordType) { case RecordTypes.None: break; case RecordTypes.Call: ReadCallRecord(log, reader); break; case RecordTypes.Header: ReadHeader(log, reader); break; default: throw new ArgumentOutOfRangeException(); } } }
private void ReadCallRecordV1(BatNodeLog log, BinaryReader reader) { BatCall call = new BatCall(); call.Duration = reader.ReadUInt32(); call.StartTimeMs = reader.ReadUInt32(); call.ClippedSamples = reader.ReadUInt16(); call.MaxPower = reader.ReadUInt16(); call.MissedSamples = reader.ReadUInt16(); call.FftData = reader.ReadBytes(512); if (call.Duration > 100000) { call.Enabled = false; } AnalyzeFftData(call); log.Calls.Add(call); }
public static BatNodeLog CreateBatLog() { Random rnd = new Random(); byte[] data = new byte[512]; rnd.NextBytes(data); uint timeMs = 0; BatNodeLog batNodeLog = new BatNodeLog(); batNodeLog.Id = 10; batNodeLog.Name = "Log 01, Aarau"; batNodeLog.LogStart = DateTime.Now; for (int i = 0; i < 1000; i++) { timeMs += (uint)rnd.Next(1000); batNodeLog.Calls.Add(new BatCall(batNodeLog, timeMs, (uint)rnd.Next(100000), (uint)rnd.Next(50), (uint)rnd.Next(1024), (uint)rnd.Next(50), (uint)rnd.Next(1024), data)); } batNodeLog.CallCount = batNodeLog.Calls.Count; return batNodeLog; }
//public EditLogPageModel() // : this(DesignData.CreateBatLog()) //{ // Calls = new ObservableCollection<BatCallViewModel>(BatLog.Calls.Select((c, i) => new BatCallViewModel(BatLog, c, i+1))); // if (Calls.Any()) // { // SelectedCall = Calls.First(); // } //} public EditCallsPivotModel(BatNodeLog batLog, EditLogViewModel parentViewModel) : base(parentViewModel) { BatLog = batLog; Name = batLog.Name; Description = batLog.Description; StartDate = new DateTimeOffset(BatLog.LogStart.Date); StartTime = batLog.LogStart.TimeOfDay; ToggleEnabledCommand = new RelayCommand(() => { if (SelectedCall != null) { SelectedCall.Enabled = !SelectedCall.Enabled; } }); }
private void ReadHeader(BatNodeLog log, BinaryReader reader) { byte[] marker = reader.ReadBytes(2); if (marker[0] != 76) // 76 -> L { throw new InvalidOperationException("Ungültiger Marker."); } int version = marker[1]; log.NodeId = reader.ReadByte(); uint seconds = reader.ReadUInt32(); DateTime startTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Local).AddSeconds(seconds); log.LogStart = startTime; }
public async Task<IEnumerable<BatCall>> LoadCalls(BatNodeLog batLog) { return await Calls.Where(c => c.BatNodeLogId == batLog.Id).OrderBy(c => c.StartTimeMs).ToListAsync(); }
public void EditLog(BatNodeLog batLog) { _app.RootFrame.Navigate(typeof(EditLogPage), batLog); }
public void NavigateToLogDetails(BatNodeLog log) { _app.RootFrame.Navigate(typeof(LogDetailsPage), log); }