CreateAlarm() 공개 메소드

Creates a new active alarm for the source.
public CreateAlarm ( string alarmName, string alarmType ) : void
alarmName string Name of the alarm.
alarmType string Type of the alarm.
리턴 void
예제 #1
0
        /// <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);
        }
예제 #2
0
        /// <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;
        }