public void PlayAudio()
        {
            var seconds = 10;

            ISirenOfShameDevice sos = new SirenOfShameDevice();
            sos.TryConnect();
            var pattern = new AudioPattern();
            pattern.Id = 1;
            var duration = new TimeSpan(0, 0, 0, seconds);
            sos.PlayAudioPattern(pattern, duration);
        }
Пример #2
0
 public bool Equals(AudioPattern other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(other.Id == Id && Equals(other.Name, Name));
 }
Пример #3
0
 public void PlayAudioPattern(AudioPattern audioPattern, TimeSpan?durationTimeSpan)
 {
     EnsureConnected();
     if (audioPattern == null)
     {
         SendControlPacket(audioMode: 0, audioDuration: 0);
     }
     else
     {
         UInt16 duration = CalculateDurationFromTimeSpan(durationTimeSpan);
         SendControlPacket(audioMode: (byte)audioPattern.Id, audioDuration: duration);
     }
 }
Пример #4
0
 private void _timer_Tick(object sender, EventArgs e)
 {
     if (CurrentAudioDuration != null)
     {
         _currentAudioDuration = CurrentAudioDuration.Value.Add(new TimeSpan(0, 0, 0, 0, -_timer.Interval));
         if (CurrentAudioDuration.Value.TotalMilliseconds < 0)
         {
             _currentAudioPattern  = null;
             _currentAudioDuration = null;
         }
     }
     if (CurrentLightDuration != null)
     {
         _currentLightDuration = CurrentLightDuration.Value.Add(new TimeSpan(0, 0, 0, 0, -_timer.Interval));
         if (CurrentLightDuration.Value.TotalMilliseconds < 0)
         {
             _currentLightPattern  = null;
             _currentLightDuration = null;
         }
     }
     _audioPattern.Text = CurrentAudioPattern == null ? "None" : CurrentAudioPattern.Name + "(" + CurrentAudioDuration + ")";
     _ledPattern.Text   = CurrentLightPattern == null ? "None" : CurrentLightPattern.Name + "(" + CurrentLightDuration + ")";
 }
Пример #5
0
        public void InvokeSetAudio(AudioPattern audioPattern, int? duration)
        {
            if (_settings.Mute) return;

            var startSiren = SetAudio;
            if (startSiren == null) return;
            startSiren(this, new SetAudioEventArgs { AudioPattern = audioPattern, Duration = duration });
        }
Пример #6
0
        private IEnumerable<ToolStripMenuItem> GetDurations(Rule rule, LedPattern ledPattern, AudioPattern audioPattern, bool patternIsMatch, string buildDefinitionId, TriggerType triggerType, string person)
        {
            int? duration = null;
            if (rule != null)
                duration = ledPattern == null ? rule.AudioDuration : rule.LightsDuration;

            var durations = _durations.Select(d => new ToolStripMenuItem(d.Value)
            {
                Checked = patternIsMatch && duration == d.Key,
                Tag = new RuleDropDownItemTag
                {
                    AlertType = null,
                    BuildDefinitionId = buildDefinitionId,
                    TriggerPerson = person,
                    TriggerType = triggerType,
                    LedPattern = ledPattern,
                    AudioPattern = audioPattern,
                    Duration = d.Key
                }
            }).ToArray();
            foreach (var toolStripMenuItem in durations)
            {
                toolStripMenuItem.Click += RuleDropDownItemClick;
            }
            return durations;
        }
Пример #7
0
 private ToolStripMenuItem AudioPatternMenu(AudioPattern ap, Rule rule, string buildDefinitionId, TriggerType triggerType, string person)
 {
     bool patternIsMatch = false;
     if (rule != null && !rule.InheritAudioSettings && rule.AudioPattern != null)
         patternIsMatch = rule.AudioPattern.Equals(ap);
     var menu = new ToolStripMenuItem(ap.Name)
     {
         Checked = patternIsMatch
     };
     AddToolStripItems(menu.DropDownItems, GetDurations(rule, null, ap, patternIsMatch, buildDefinitionId, triggerType, person));
     return menu;
 }
 public void PlayAudioPattern(AudioPattern pattern, TimeSpan? duration)
 {
     _dlg.SetAudio(pattern, duration);
 }
Пример #9
0
 public bool Equals(AudioPattern other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return other.Id == Id && Equals(other.Name, Name);
 }
Пример #10
0
        public void GlobalPlayAudioAlertButOnMute_NoAudio()
        {
            var rulesEngine = new RulesEngineWrapper();

            var audioPattern = new AudioPattern { Id = 2, Name = "Sally" };
            rulesEngine.Rules.Add(new Rule
            {
                TriggerType = TriggerType.InitialFailedBuild,
                AudioPattern = audioPattern,
                AudioDuration = 60,
            });

            rulesEngine.Settings.Mute = true;
            rulesEngine.InvokeStatusChecked(BuildStatusEnum.Broken);
            Assert.AreEqual(0, rulesEngine.SetAudioEvents.Count);
        }
Пример #11
0
        public void BuildInitiallyFailsWithGlobalPlayAudioAlert_SetAudio()
        {
            var rulesEngine = new RulesEngineWrapper();

            var audioPattern = new AudioPattern { Id = 2, Name = "Sally" };
            rulesEngine.Rules.Add(new Rule
            {
                TriggerType = TriggerType.InitialFailedBuild,
                AudioPattern = audioPattern,
                AudioDuration = 60,
            });

            rulesEngine.InvokeStatusChecked(BuildStatusEnum.Broken);
            Assert.AreEqual(1, rulesEngine.SetAudioEvents.Count);
            Assert.AreEqual(0, rulesEngine.SetLightsEvents.Count);
            Assert.AreEqual(new TimeSpan(0, 0, 0, 60), rulesEngine.SetAudioEvents[0].TimeSpan);
            Assert.AreEqual(audioPattern, rulesEngine.SetAudioEvents[0].AudioPattern);
        }
Пример #12
0
 public void SetAudio(AudioPattern pattern, TimeSpan?duration)
 {
     _currentAudioPattern  = pattern;
     _currentAudioDuration = duration;
 }
 public void SetAudio(AudioPattern pattern, TimeSpan? duration)
 {
     _currentAudioPattern = pattern;
     _currentAudioDuration = duration;
 }
 private void _timer_Tick(object sender, EventArgs e)
 {
     if (CurrentAudioDuration != null)
     {
         _currentAudioDuration = CurrentAudioDuration.Value.Add(new TimeSpan(0, 0, 0, 0, -_timer.Interval));
         if (CurrentAudioDuration.Value.TotalMilliseconds < 0)
         {
             _currentAudioPattern = null;
             _currentAudioDuration = null;
         }
     }
     if (CurrentLightDuration != null)
     {
         _currentLightDuration = CurrentLightDuration.Value.Add(new TimeSpan(0, 0, 0, 0, -_timer.Interval));
         if (CurrentLightDuration.Value.TotalMilliseconds < 0)
         {
             _currentLightPattern = null;
             _currentLightDuration = null;
         }
     }
     _audioPattern.Text = CurrentAudioPattern == null ? "None" : CurrentAudioPattern.Name + "(" + CurrentAudioDuration + ")";
     _ledPattern.Text = CurrentLightPattern == null ? "None" : CurrentLightPattern.Name + "(" + CurrentLightDuration + ")";
 }
 public void PlayAudioPattern(AudioPattern audioPattern, TimeSpan? durationTimeSpan)
 {
     EnsureConnected();
     if (audioPattern == null)
     {
         SendControlPacket(audioMode: 0, audioDuration: 0);
     }
     else
     {
         UInt16 duration = CalculateDurationFromTimeSpan(durationTimeSpan);
         SendControlPacket(audioMode: (byte)audioPattern.Id, audioDuration: duration);
     }
 }
 public void PlayAudioPattern(AudioPattern pattern, TimeSpan?duration)
 {
     _dlg.SetAudio(pattern, duration);
 }