コード例 #1
0
 public LoBlock(LogramPl pl, Topic owner)
 {
     this._pl    = pl;
     this._owner = owner;
     _pins       = new List <LoVariable>();
     ManifestChanged();
     foreach (var ch in _owner.children)
     {
         GetPin(ch);
     }
     _pl.EnqueueIn(this);
 }
コード例 #2
0
        public void Tick1()
        {
            if (_owner.disposed && !Disposed)
            {
                Disposed = true;
                foreach (var p in _pins.Where(z => z.Owner.parent != _owner))
                {
                    p.DeleteLink(this);
                }
                _pins.Clear();
                if (_ctx != null)
                {
                    JsExtLib.ClearTimeout(_ctx);
                }
                _ctx      = null;
                _self     = null;
                _calcFunc = null;
                return;
            }
            var ln = 0;

            foreach (var p in _pins.Where(z => z.Source != this && z.Layer > 0))
            {
                if (ln < p.Layer)
                {
                    ln = p.Layer;
                }
            }
            ln++;
            if (_layer != ln)
            {
                List <ILoItem> route = new List <ILoItem>();
                foreach (var p in _pins.Where(z => z.Source != this && z.Layer > 0))
                {
                    if (p.Route != null)
                    {
                        route.AddRange(p.Route);
                    }
                }
                route.Add(this);
                Route  = route.ToArray();
                _layer = ln;
                foreach (var p in _pins.Where(z => z.Source == this))
                {
                    _pl.EnqueueIn(p);
                }
                //Log.Debug(this.ToString());
            }
        }
コード例 #3
0
        public void Tick1()
        {
            LoBlock bl;

            if (_owner.disposed && !Disposed)
            {
                Disposed = true;
                for (int i = _links.Count - 1; i >= 0; i--)
                {
                    if ((bl = _links[i] as LoBlock) != null)
                    {
                        bl.DeletePin(this);
                    }
                    else
                    {
                        _links[i].Owner.SetField("cctor.LoBind", null, _owner);
                    }
                }
                _links.Clear();
                _src_new = null;
            }
            bool l_ch = _src != _src_new;

            if (l_ch || (_src != null && (_src.Layer != Math.Abs(_layer) || !Object.ReferenceEquals(_src.Route, Route))))
            {
                var svo = Interlocked.Exchange(ref _src, _src_new) as LoVariable;
                if (l_ch && svo != null)
                {
                    svo.DeleteLink(this);
                }
                if (_src != null)
                {
                    _layer = _src.Layer;
                    Route  = _src.Route;
                    if (_owner.CheckAttribute(Topic.Attribute.Saved, Topic.Attribute.DB))
                    {
                        _owner.ClearAttribute(Topic.Attribute.Saved);
                    }
                    if (l_ch && (svo = _src as LoVariable) != null)
                    {
                        svo.AddLink(this);
                        if (svo._value != null && svo._value.Defined)
                        {
                            _value_new = svo._value;
                            _prim      = svo._owner;
                        }
                    }
                    if (Route != null && (bl = _links.OfType <LoBlock>().FirstOrDefault()) != null && Route.Contains(bl)) // make loop
                    {
                        if (_layer != 0)
                        {
                            _layer = -_layer;
                        }
                    }
                }
                else
                {
                    _layer = 0;
                    Route  = null;
                    if (!_owner.disposed)
                    {
                        _owner.SetAttribute(Topic.Attribute.DB);
                    }
                    if (!_links.Any())
                    {
                        Disposed = true;
                    }
                }
                if (_layer >= 0) // if _layer < 0 -> loop
                {
                    for (int i = _links.Count - 1; i >= 0; i--)
                    {
                        if (_links[i] != _src)
                        {
                            _pl.EnqueueIn(_links[i]);
                        }
                    }
                }
                //Log.Debug(this.ToString());
            }
        }