Exemplo n.º 1
0
        /// <summary>
        /// Periodically checks for changes for any monitored area or controller.
        /// </summary>
        private void OnUpdate(object state)
        {
            try {
                lock (m_dataLock) {
                    // check if halted.
                    if (m_monitoredObjects.Count == 0)
                    {
                        m_timer.Dispose();
                        m_timer = null;
                        return;
                    }

                    for (int ii = 0; ii < m_monitoredObjects.Count; ii++)
                    {
                        MonitoredObject monitoredObject = m_monitoredObjects[ii];

                        if (monitoredObject.Area != null)
                        {
                            monitoredObject.Area.CheckForChanges(m_systemContext);
                            monitoredObject.Area.ClearChangeMasks(m_systemContext, true);
                        }

                        if (monitoredObject.Controller != null)
                        {
                            monitoredObject.Controller.CheckForChanges(m_systemContext);
                            monitoredObject.Controller.ClearChangeMasks(m_systemContext, true);
                        }
                    }
                }
            } catch (Exception e) {
                Utils.Trace(e, "FileSystemMonitor: Unexpected error updating monitored objects.");
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Starts monitoring a controller for changes.
        /// </summary>
        public int MonitorController(ControllerState controller, bool stop)
        {
            lock (m_dataLock)
            {
                MonitoredObject monitoredObject = null;

                for (int ii = 0; ii < m_monitoredObjects.Count; ii++)
                {
                    monitoredObject = m_monitoredObjects[ii];

                    if (Object.ReferenceEquals(controller, monitoredObject.Controller))
                    {
                        if (stop)
                        {
                            monitoredObject.Refs--;

                            if (monitoredObject.Refs == 0)
                            {
                                m_monitoredObjects.RemoveAt(ii);
                            }
                        }
                        else
                        {
                            monitoredObject.Refs++;
                        }

                        return(monitoredObject.Refs);
                    }
                }

                if (stop)
                {
                    return(0);
                }

                StartTimer();

                monitoredObject            = new MonitoredObject();;
                monitoredObject.Controller = controller;
                monitoredObject.Refs       = 1;

                m_monitoredObjects.Add(monitoredObject);

                return(monitoredObject.Refs);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Starts monitoring an area for changes.
        /// </summary>
        public int MonitorArea(AreaState area, bool stop)
        {
            lock (m_dataLock)
            {
                MonitoredObject monitoredObject = null;

                for (int ii = 0; ii < m_monitoredObjects.Count; ii++)
                {
                    monitoredObject = m_monitoredObjects[ii];

                    if (Object.ReferenceEquals(area, monitoredObject.Area))
                    {
                        if (stop)
                        {
                            monitoredObject.Refs--;

                            if (monitoredObject.Refs == 0)
                            {
                                m_monitoredObjects.RemoveAt(ii);
                            }
                        }
                        else
                        {
                            monitoredObject.Refs++;
                        }

                        return(monitoredObject.Refs);
                    }
                }

                if (stop)
                {
                    return(0);
                }

                StartTimer();

                monitoredObject      = new MonitoredObject();
                monitoredObject.Area = area;
                monitoredObject.Refs = 1;

                m_monitoredObjects.Add(monitoredObject);

                return(monitoredObject.Refs);
            }
        }
 public MonitoredObjectState(MonitoredObject monitoredObject, long timestamp)
 {
     MonitoredObject = monitoredObject;
     _timestamp      = timestamp;
 }
Exemplo n.º 5
0
        /// <summary>
        /// Starts monitoring a controller for changes.
        /// </summary>
        public int MonitorController(ControllerState controller, bool stop)
        {
            lock (m_dataLock)
            {
                MonitoredObject monitoredObject = null;

                for (int ii = 0; ii < m_monitoredObjects.Count; ii++)
                {
                    monitoredObject = m_monitoredObjects[ii];

                    if (Object.ReferenceEquals(controller, monitoredObject.Controller))
                    {
                        if (stop)
                        {
                            monitoredObject.Refs--;

                            if (monitoredObject.Refs == 0)
                            {
                                m_monitoredObjects.RemoveAt(ii);
                            }
                        }
                        else
                        {
                            monitoredObject.Refs++;
                        }

                        return monitoredObject.Refs;
                    }
                }
                
                if (stop)
                {
                    return 0;
                }

                StartTimer();
                
                monitoredObject = new MonitoredObject();;
                monitoredObject.Controller = controller;
                monitoredObject.Refs = 1;

                m_monitoredObjects.Add(monitoredObject);

                return monitoredObject.Refs;
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Starts monitoring an area for changes.
        /// </summary>
        public int MonitorArea(AreaState area, bool stop)
        {
            lock (m_dataLock)
            {
                MonitoredObject monitoredObject = null;

                for (int ii = 0; ii < m_monitoredObjects.Count; ii++)
                {
                    monitoredObject = m_monitoredObjects[ii];

                    if (Object.ReferenceEquals(area, monitoredObject.Area))
                    {
                        if (stop)
                        {
                            monitoredObject.Refs--;

                            if (monitoredObject.Refs == 0)
                            {
                                m_monitoredObjects.RemoveAt(ii);
                            }
                        }
                        else
                        {
                            monitoredObject.Refs++;
                        }

                        return monitoredObject.Refs;
                    }
                }
                
                if (stop)
                {
                    return 0;
                }

                StartTimer();
                
                monitoredObject = new MonitoredObject();
                monitoredObject.Area = area;
                monitoredObject.Refs = 1;

                m_monitoredObjects.Add(monitoredObject);

                return monitoredObject.Refs;
            }
        }