private void InitializeMappings() { var mappingFiles = new DirectoryInfo(Util.CurrentMappingProfileDirectory).GetFiles("*.mapping"); foreach (var mappingFile in mappingFiles) { var profileToLoad = mappingFile.FullName; if (!string.IsNullOrEmpty(profileToLoad) && !string.IsNullOrEmpty(profileToLoad.Trim())) { var profile = MappingProfile.Load(profileToLoad); foreach (var mapping in profile.SignalMappings) { var origSource = mapping.Source; var origDestination = mapping.Destination; mapping.Source = ResolveSignal(origSource); mapping.Destination = ResolveSignal(origDestination); if (mapping.Source == null || mapping.Destination == null) { _log.Warn( $"A mapping defined in file {profileToLoad} had an unresolvable source or destination signal."); continue; } _mappings.Add(mapping); if (mapping.Source is AnalogSignal) { var mappingSource = mapping.Source as AnalogSignal; var mappingDestination = mapping.Destination as AnalogSignal; var passthru = new AnalogPassthrough { In = mappingSource, Out = mappingDestination }; passthru.Refresh(); } else if (mapping.Source is DigitalSignal) { var mappingSource = mapping.Source as DigitalSignal; var mappingDestination = (DigitalSignal)mapping.Destination; var passthru = new DigitalPassthrough { In = mappingSource, Out = mappingDestination }; passthru.Refresh(); } else if (mapping.Source is TextSignal) { var mappingSource = mapping.Source as TextSignal; var mappingDestination = (TextSignal)mapping.Destination; var passthru = new TextPassthrough { In = mappingSource, Out = mappingDestination }; passthru.Refresh(); } } } } }