Example #1
0
        private void TimerCallback(object state)
        {
            TriggerTimerMap map = state as TriggerTimerMap;

            if (map == null)
            {
                throw new Exception("Map state unknown");
            }

            Container.EventManager.NewEvent(map.DeviceId, EventId.OutputDeactivated);
            _triggerTimers.Remove(map);
            map.TriggerTimer.Dispose();
        }
Example #2
0
        public override void TriggerOutput(string deviceId, int durationMs)
        {
            WriteLine(deviceId, string.Format("{0}, ms= {1}", nameof(TriggerOutput), durationMs));
            if (new Guid(deviceId) == Constants.Output1)
            {
                Container.EventManager.NewEvent(deviceId, EventId.OutputActivated);

                TriggerTimerMap map = new TriggerTimerMap()
                {
                    DeviceId = deviceId
                };
                map.TriggerTimer = new Timer(TimerCallback, map, 1000, Timeout.Infinite);
                _triggerTimers.Add(map);
                return;
            }
            throw new MIPDriverException("Device does not support Output commands");
        }