private string InitializeEventJournal(string savePath, InitializeRecordParameter parameters) { if (string.IsNullOrEmpty(savePath)) { throw new ArgumentNullException("savePath"); } if (parameters == null) { throw new ArgumentNullException("parameters"); } string xmlCompleteFileName = string.Empty; this.EventJournal = CreateEventJournal(parameters); if (this.EventJournal != null) { Directory.CreateDirectory(savePath); this.EventJournal.EventJournalHeader.CreationSource = this.AgentUniversalName; this.EventJournal.EventJournalHeader.Id = parameters.SequenceId; this.EventJournal.EventJournalHeader.Sequenceur = parameters.SequenceId; this.EventJournal.EventJournalHeader.AcquisitionOffset = this.Configuration.Agent.Journalisation.AcquisitionOffSet; string filename = string.IsNullOrWhiteSpace(this.Configuration.Agent.Journalisation.CharacterizationFileName) ? this.AgentUniversalName : string.Format("{0}.{1}", this.Configuration.Agent.Journalisation.CharacterizationFileName, this.AgentUniversalName); xmlCompleteFileName = Path.Combine(savePath, parameters.SequenceId + "." + filename + this.EventJournalFileExtension); _eventJournalRecorder = new JournalBufferedRecorder(xmlCompleteFileName, this.EventJournal, true); } return(xmlCompleteFileName); }
protected override async Task <AcquisitionActionResult> InitializeRecordCore(InitializeRecordParameter parameters, AcquisitionActionResult result) { result = await base.InitializeRecordCore(parameters, result).ConfigureAwait(false); if (this.UseOnlyTrustworthyData) { try { await this.DataSource.Where(data => data.GpsStatus != GpsStatus.Initializing).Take(1).ToTask(this.Provider.CurrentStateTransitionCancellationToken).ConfigureAwait(false); } catch (TaskCanceledException ex) { result.IsSuccessful = false; result.Exception = ex; return(result); } } // create tracer & start tracing _tracer = new GpxTracer(this.EventJournalFileExtension, this.Append); var deviceType = this.CurrentData == null ? GpsDeviceType.Unknown : this.CurrentData.RawData.DeviceType; _tracer.StartTracing(parameters.SequenceId, this.JournalAbsoluteSavePath, deviceType); this.Provider.SequenceId = parameters.SequenceId; this.Provider.SaveFolderAbsolutePath = this.JournalAbsoluteSavePath; return(result); }
protected override async Task <AcquisitionActionResult> InitializeRecordCore(InitializeRecordParameter parameters, AcquisitionActionResult result) { result = await base.InitializeRecordCore(parameters, result).ConfigureAwait(false); await StopTransferring().ConfigureAwait(false); return(result); }
private string InitializeConfigurationJournal(string savePath, InitializeRecordParameter parameters) { if (string.IsNullOrEmpty(savePath)) { throw new ArgumentNullException("savePath"); } if (parameters == null) { throw new ArgumentNullException("parameters"); } if (string.IsNullOrEmpty(this.ConfigurationFilePath) || !File.Exists(this.ConfigurationFilePath)) { return(null); } else { Directory.CreateDirectory(savePath); var filename = string.IsNullOrWhiteSpace(this.Configuration.Agent.Journalisation.CharacterizationFileName) ? this.AgentUniversalName : string.Format("{0}.{1}", this.Configuration.Agent.Journalisation.CharacterizationFileName, this.AgentUniversalName); var completeFileName = Path.Combine(savePath, parameters.SequenceId + "." + filename + this.ConfigurationJournalFileExtension); File.Copy(this.ConfigurationFilePath, completeFileName); return(completeFileName); } }
protected override Task <AcquisitionActionResult> InitializeRecordCore(InitializeRecordParameter parameters, AcquisitionActionResult result) { this.ItineraryLogRelativeFilePath = this.SequenceId + ".iti"; try { File.Delete(Path.Combine(this.JournalAbsoluteSavePath, this.ItineraryLogRelativeFilePath)); } catch { } return(base.InitializeRecordCore(parameters, result)); }
protected override IEventJournal CreateEventJournal(InitializeRecordParameter parameters) { var journal = new DistanceAgentEventJournal(); journal.JournalHeader.ActiveMode = "AbsoluteTime"; journal.JournalHeader.Ppkm = this.Provider.EncoderNumber == 1 ? this.Provider.PPKMLeft : this.Provider.EncoderNumber == 2 ? this.Provider.PPKMRight : -1; return(journal); }
protected override IEventJournal CreateEventJournal(InitializeRecordParameter parameters) { var journal = new SpeedAgentEventJournal(); var calculated = this.Provider as CalculatedSpeedProvider; if (calculated != null) { journal.JournalHeader.BorneInferieure = calculated.Threshold - calculated.Hysteresis; journal.JournalHeader.BorneSuperieure = calculated.Threshold + calculated.Hysteresis; journal.JournalHeader.Tolerance = calculated.Hysteresis; } return(journal); }
protected override IEventJournal CreateEventJournal(InitializeRecordParameter parameters) { return(new EventPanelAgentEventJournal()); }
protected override IEventJournal CreateEventJournal(InitializeRecordParameter parameters) { return(null); }
protected abstract IEventJournal CreateEventJournal(InitializeRecordParameter parameters);
private async Task <AcquisitionActionResult> InternalInitializeRecord(InitializeRecordParameter parameters, AcquisitionActionResult result) { if (string.IsNullOrEmpty(parameters.DefaultRootPath)) { throw new InvalidOperationException("RootPath is mandatory."); } if (string.IsNullOrEmpty(this.AgentFolderPath)) { throw new InvalidOperationException("AgentFolderPath is mandatory."); } if (string.IsNullOrEmpty(this.AgentUniversalName)) { throw new InvalidOperationException("AgentUniversalName is mandatory."); } if (string.IsNullOrEmpty(this.EventJournalFileExtension)) { throw new InvalidOperationException("EventJournalFileExtension is mandatory."); } if (string.IsNullOrEmpty(this.FileJournalFileExtension)) { throw new InvalidOperationException("FileJournalFileExtension is mandatory."); } if (string.IsNullOrEmpty(parameters.SequenceId)) { throw new InvalidOperationException("SequenceId is mandatory."); } _fileJournalEntries.Clear(); this.JournalRootPath = string.IsNullOrEmpty(this.RootPath) ? parameters.DefaultRootPath : this.RootPath; this.SequenceId = parameters.SequenceId; this.Provider.SequenceId = parameters.SequenceId; this.JournalRelativeSavePath = this.AgentFolderPath; this.JournalAbsoluteSavePath = Path.Combine(this.JournalRootPath, parameters.SequenceId, this.JournalRelativeSavePath); int rootLength = 1 + Path.Combine(this.JournalRootPath, parameters.SequenceId).Length; string filename = string.IsNullOrWhiteSpace(this.Configuration.Agent.Journalisation.CharacterizationFileName) ? this.AgentUniversalName : string.Format("{0}.{1}", this.Configuration.Agent.Journalisation.CharacterizationFileName, this.AgentUniversalName); string fjxCompleteFilePath = Path.Combine(this.JournalAbsoluteSavePath, parameters.SequenceId + "." + filename + this.FileJournalFileExtension); this.FileJournalRelativePath = fjxCompleteFilePath.Substring(rootLength); string ejxCompleteFilePath = InitializeEventJournal(this.JournalAbsoluteSavePath, parameters); this.EventJournalRelativePath = string.IsNullOrEmpty(ejxCompleteFilePath) ? string.Empty : ejxCompleteFilePath.Substring(rootLength); string cjxCompleteFilePath = InitializeConfigurationJournal(this.JournalAbsoluteSavePath, parameters); this.ConfigurationJournalRelativePath = string.IsNullOrEmpty(cjxCompleteFilePath) ? string.Empty : cjxCompleteFilePath.Substring(rootLength); result.ConfigurationJournalRelativePath = this.ConfigurationJournalRelativePath; result.EventJournalRelativePath = this.EventJournalRelativePath; result.FileJournalRelativePath = this.FileJournalRelativePath; this.Provider.SaveFolderAbsolutePath = this.JournalAbsoluteSavePath; result = await InitializeRecordCore(parameters, result).ConfigureAwait(false); return(result); }
protected virtual Task <AcquisitionActionResult> InitializeRecordCore(InitializeRecordParameter parameters, AcquisitionActionResult result) { return(Task.FromResult(result)); }
public Task <AcquisitionActionResult> InitializeRecord(InitializeRecordParameter parameters) { return(MakeStateTransition(AcquisitionStep.InitializeRecord, this.Provider.InitializeRecord, parameters, InternalInitializeRecord)); }