private void PutMeasurementsInElements(IMeasurement measurement)
        {
            string message = $"[NMSManager]Putting measurement with GID 0x{measurement.Id.ToString("X16")} in element.";

            if (MeasurementToConnectedTerminalMap.TryGetValue(measurement.Id, out long terminalId))
            {
                if (TerminalToConnectedElementsMap.TryGetValue(terminalId, out List <long> connectedElements))
                {
                    try
                    {
                        var elementId = connectedElements.Find(
                            e => GetDMSTypeOfTopologyElement(e) != DMSType.CONNECTIVITYNODE &&
                            GetDMSTypeOfTopologyElement(e) != DMSType.ANALOG);

                        if (TopologyElements.TryGetValue(elementId, out ITopologyElement element))
                        {
                            element.Measurements.Add(measurement.Id, measurement.GetMeasurementType());
                            measurement.ElementId = elementId;

                            if (measurement.GetMeasurementType().Equals(AnalogMeasurementType.FEEDER_CURRENT.ToString()))
                            {
                                //element = new Feeder(element);
                                TopologyElements[elementId] = new Feeder(element);
                            }
                        }
                        else
                        {
                            logger.LogWarn($"{message} Element with GID {elementId.ToString("X")} does not exist in elements dictionary.");
                        }
                    }
                    catch (Exception)
                    {
                        logger.LogWarn($"{message} Failed to find appropriate element for mesuremnt with GID {measurement.Id.ToString("X")}. There is no conducting equipment connected to common terminal.");
                    }
                }
                else
                {
                    logger.LogWarn($"{message} Terminal with GID 0x{terminalId.ToString("X16")} does not exist in terminal to element map.");
                }
            }
            else
            {
                logger.LogWarn($"{message} Measurement with GID 0x{measurement.Id.ToString("X16")} does not exist in mesurement to terminal map.");
            }
        }
        private async Task <long> PutMeasurementsInElements(IMeasurement measurement)
        {
            string verboseMessage = $"{baseLogString} entering PutMeasurementsInElements method. Measurement GID {measurement?.Id:X16}.";

            Logger.LogVerbose(verboseMessage);

            var enumerableMeasurementToConnectedTerminalMap = await MeasurementToConnectedTerminalMap.GetEnumerableDictionaryAsync();

            if (enumerableMeasurementToConnectedTerminalMap.TryGetValue(measurement.Id, out long terminalId))
            {
                var enumerableTerminalToConnectedElementsMap = await TerminalToConnectedElementsMap.GetEnumerableDictionaryAsync();

                if (enumerableTerminalToConnectedElementsMap.TryGetValue(terminalId, out List <long> connectedElements))
                {
                    try
                    {
                        var elementId = connectedElements.Find(
                            e => GetDMSTypeOfTopologyElement(e) != DMSType.CONNECTIVITYNODE &&
                            GetDMSTypeOfTopologyElement(e) != DMSType.ANALOG);

                        var enumerableTopologyElements = await TopologyElements.GetEnumerableDictionaryAsync();

                        if (enumerableTopologyElements.TryGetValue(elementId, out ITopologyElement element))
                        {
                            if (!element.Measurements.ContainsKey(measurement.Id))
                            {
                                element.Measurements.Add(measurement.Id, measurement.GetMeasurementType());
                            }
                            else
                            {
                                Logger.LogWarning($"{baseLogString} PutMeasurementsInElements => element.Measurements contains key: 0x{measurement.Id:X16}");
                            }

                            measurement.ElementId = elementId;

                            if (measurement is DiscreteMeasurement)
                            {
                                var measurementProviderClient = MeasurementProviderClient.CreateClient();
                                await measurementProviderClient.AddDiscreteMeasurement((DiscreteMeasurement)measurement);
                            }

                            if (measurement.GetMeasurementType().Equals(AnalogMeasurementType.FEEDER_CURRENT.ToString()))
                            {
                                await TopologyElements.SetAsync(elementId, new Feeder(element));
                            }
                            else
                            {
                                await TopologyElements.SetAsync(elementId, element);
                            }
                        }
                        else
                        {
                            Logger.LogError($"{baseLogString} PutMeasurementsInElement => Element with GID 0x{elementId:16X} does not exist in elements dictionary.");
                        }
                    }
                    catch (Exception e)
                    {
                        Logger.LogError($"{baseLogString} PutMeasurementsInElement =>  {e.Message} {Environment.NewLine} {e.StackTrace}");
                        //Logger.LogError($"{baseLogString} PutMeasurementsInElement =>  Failed to find appropriate element for mesuremnt with GID {measurement.Id:16X}. There is no conducting equipment connected to common terminal.");
                    }
                }
                else
                {
                    Logger.LogError($"{baseLogString} PutMeasurementsInElement => Terminal with GID 0x{terminalId:X16} does not exist in terminal to element map.");
                }
            }
            else
            {
                Logger.LogError($"{baseLogString} PutMeasurementsInElement => Measurement with GID {measurement.Id:X16} does not exist in mesurement to terminal map.");
            }
            return(measurement.ElementId);
        }