public SimSourceNodeBackend CreateSourceNodeBackend(string name, List <Alarm> alarms, AlarmChangedEventHandler alarmChangeCallback)
        {
            SimSourceNodeBackend simSourceNodeBackend;

            lock (_lock)
            {
                simSourceNodeBackend = new SimSourceNodeBackend
                {
                    Name           = name,
                    OnAlarmChanged = alarmChangeCallback
                };

                simSourceNodeBackend.CreateAlarms(alarms);

                SourceNodes[name] = simSourceNodeBackend;
            }

            return(simSourceNodeBackend);
        }
        /// <summary>
        /// Creates a source.
        /// </summary>
        /// <param name="sourcePath">The source path.</param>
        /// <param name="alarmChangeCallback">The callback invoked when an alarm changes.</param>
        /// <returns>The source.</returns>
        public UnderlyingSystemSource CreateSource(string sourcePath, AlarmChangedEventHandler alarmChangeCallback)
        {
            UnderlyingSystemSource source = null;

            lock (m_lock)
            {
                // create a new source.
                source = new UnderlyingSystemSource();

                // extract the name from the path.
                string name = sourcePath;

                int index = name.LastIndexOf('/');

                if (index != -1)
                {
                    name = name.Substring(index + 1);
                }

                // extract the type from the path.
                string type = sourcePath;

                index = type.IndexOf('/');

                if (index != -1)
                {
                    type = type.Substring(0, index);
                }

                // create the source.
                source.SourcePath     = sourcePath;
                source.Name           = name;
                source.SourceType     = type;
                source.OnAlarmChanged = alarmChangeCallback;

                m_sources.Add(sourcePath, source);
            }


            // add the alarms based on the source type.
            // note that the source and alarm types used here are types defined by the underlying system.
            // the node manager will need to map these types to UA defined types.
            switch (source.SourceType)
            {
            case "Colours":
            {
                source.CreateAlarm("Red", "HighAlarm");
                source.CreateAlarm("Yellow", "HighLowAlarm");
                source.CreateAlarm("Green", "TripAlarm");
                break;
            }

            case "Metals":
            {
                source.CreateAlarm("Gold", "HighAlarm");
                source.CreateAlarm("Silver", "HighLowAlarm");
                source.CreateAlarm("Bronze", "TripAlarm");
                break;
            }
            }

            // return the new source.
            return(source);
        }
        /// <summary>
        /// Creates a source.
        /// </summary>
        /// <param name="sourcePath">The source path.</param>
        /// <param name="alarmChangeCallback">The callback invoked when an alarm changes.</param>
        /// <returns>The source.</returns>
        public UnderlyingSystemSource CreateSource(string sourcePath, AlarmChangedEventHandler alarmChangeCallback)
        {
            UnderlyingSystemSource source = null;

            lock (m_lock)
            {
                // create a new source.
                source = new UnderlyingSystemSource();

                // extract the name from the path.
                string name = sourcePath;

                int index = name.LastIndexOf('/');

                if (index != -1)
                {
                    name = name.Substring(index+1);
                }

                // extract the type from the path.
                string type = sourcePath;

                index = type.IndexOf('/');

                if (index != -1)
                {
                    type = type.Substring(0, index);
                }

                // create the source.
                source.SourcePath = sourcePath;
                source.Name = name;
                source.SourceType = type;
                source.OnAlarmChanged = alarmChangeCallback;

                m_sources.Add(sourcePath, source);
            }


            // add the alarms based on the source type.
            // note that the source and alarm types used here are types defined by the underlying system.
            // the node manager will need to map these types to UA defined types.
            switch (source.SourceType)
            {
                case "Colours":
                {
                    source.CreateAlarm("Red", "HighAlarm");
                    source.CreateAlarm("Yellow", "HighLowAlarm");
                    source.CreateAlarm("Green", "TripAlarm");
                    break;
                }

                case "Metals":
                {
                    source.CreateAlarm("Gold", "HighAlarm");
                    source.CreateAlarm("Silver", "HighLowAlarm");
                    source.CreateAlarm("Bronze", "TripAlarm");
                    break;
                }
            }

            // return the new source.
            return source;
        }