Beispiel #1
0
 public override void Start()
 {
     _tickCount = 0;
     Application.DoEvents();             // the timer doesn't want to start all the time...
     tmrTimer.Enabled = true;
     _playback.Start();
 }
Beispiel #2
0
        private void ThreadHandler()
        {
            float last = 0;

            _tickCount = 0;

            _playback.Load(_sequence);

            _stopWatch = new Stopwatch();
            _stopWatch.Start();

            _playback.Start();

            _playing = true;

            while (_playing)
            {
                // if we hit our interval
                if ((_stopWatch.ElapsedMilliseconds - last) >= _sequence.Interval)
                {
                    // make sure we're still inside the bounds of the song
                    if (_tickCount >= _sequence.Channels[0].Data.Length)
                    {
                        // dump out and let anyone listening know it's all over
                        Thread.Sleep(100);
                        _stopWatch.Stop();
                        _playback.Stop();
                        OnSequenceStopped(new EventArgs());
                        return;
                    }

                    // every time we tick, set the output port for the current channel on or off
                    foreach (Channel c in _sequence.Channels)
                    {
                        if (PhidgetHandler.IFKits[c.SerialNumber].outputs[c.OutputIndex] != c.Data[_tickCount])
                        {
                            PhidgetHandler.IFKits[c.SerialNumber].outputs[c.OutputIndex] = c.Data[_tickCount];
                        }
                    }

                    _tickCount++;
                    last = (_stopWatch.ElapsedMilliseconds - ((_stopWatch.ElapsedMilliseconds - last) - _sequence.Interval));
                }
                else
                {
                    Thread.Sleep((int)(_stopWatch.ElapsedMilliseconds - last));                         // give the CPU a break until it's time to act again
                }
            }
            Thread.Sleep(100);
            _stopWatch.Stop();
            _playback.Stop();
        }
Beispiel #3
0
        private void RecordThread()
        {
            float     last = 0;
            Stopwatch s    = new Stopwatch();

            _playback.Load(_sequence);

            s.Start();
            _playback.Start();

            _playing = true;

            while (_playing)
            {
                // if we've elapsed enough time, process keys
                if ((s.ElapsedMilliseconds - last) > _sequence.Interval)
                {
                    // if we're at the end, bail out
                    if (_tickCount >= _channels[0].Data.Length)
                    {
                        btnStart.PerformClick();
                    }

                    // for each channel, set the ticks on and off as keys are pressed
                    for (int i = 0; i < _channels.Count; i++)
                    {
                        if (_on[i])
                        {
                            _tempData[i][_tickCount] = _on[i];
                        }

                        // every time we tick, set the output port for the current channel on or off
                        if (chkPlay.Checked && !_on[i])
                        {
                            PhidgetHandler.IFKits[_channels[i].SerialNumber].outputs[_channels[i].OutputIndex] = _channels[i].Data[_tickCount];
                        }
                    }
                    _tickCount++;

                    // maintain the last time we did this
                    last = (s.ElapsedMilliseconds - ((s.ElapsedMilliseconds - last) - _sequence.Interval));
                }
            }

            _playback.Stop();
        }