Exemple #1
0
        public void OnFlash()
        {
            SignalAspect asp;

            if (_interpreterData == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(_currentState))
            {
                return;
            }

            SignalInterpreterData interp = new SignalInterpreterData((SignalInterpreterData)_interpreterData);

            string[] p;

            for (asp = interp._aspects; asp != null; asp = asp._next)
            {
                if (asp._name != null && asp._name.Equals(_currentState))
                {
                    int nxt = _nextFlashingIcon + 1;

                    if (nxt >= Configuration.MAX_FLASHING_ICONS)
                    {
                        nxt = 0;
                    }
                    p = null;
                    switch (this.direction)
                    {
                    case trkdir.W_E:
                        p = asp._iconE;
                        break;

                    case trkdir.E_W:
                        p = asp._iconW;
                        break;

                    case trkdir.N_S:
                        p = asp._iconS;
                        break;

                    case trkdir.S_N:
                        p = asp._iconN;
                        break;
                    }
                    if (p == null || p[nxt] == null)
                    {
                        nxt = 0;
                    }
                    _nextFlashingIcon = nxt;
                    GlobalFunctions.change_coord(this.x, this.y);
                    break;
                }
            }
        }
Exemple #2
0
        public SignalInterpreterData(SignalInterpreterData source)
        {
            _aspects   = source._aspects;
            _onClick   = source._onClick;
            _onCleared = source._onCleared;
            _onShunt   = source._onShunt;
            _onUpdate  = source._onUpdate;
            _onInit    = source._onInit;
            _onCross   = source._onCross;
            _onAuto    = source._onAuto;

            _mustBeClearPath = false;
        }
Exemple #3
0
        public void OnUnclear()
        {
            GlobalVariables.signals_changed = true;
            if (_interpreterData != null)
            {
                SignalInterpreterData interp = new SignalInterpreterData((SignalInterpreterData)_interpreterData);
                if (interp._onClick != null)
                {
                    interp._signal            = this;
                    GlobalVariables.expr_buff = string.Format(wxPorting.T("%s::OnUnclear(%d,%d)"), this.stateProgram, this.x, this.y);
                    GlobalFunctions.Trace(GlobalVariables.expr_buff);
                    interp.Execute(interp._onClick);
                    return;
                }
            }

            this.status = trkstat.ST_RED;
            SetAspect(wxPorting.T("red")); // _currentState = wxT("red");
            _nextFlashingIcon = 0;         // in case new aspect is not flashing
        }
Exemple #4
0
        public void OnClicked()
        {
            if (_interpreterData == null)
            {
                return;
            }

            SignalInterpreterData interp = new SignalInterpreterData((SignalInterpreterData)_interpreterData);

            if (interp._onClick == null)
            {
                return;
            }

            interp._signal            = this;
            interp._mustBeClearPath   = true;
            GlobalVariables.expr_buff = string.Format(wxPorting.T("%s::OnClicked(%d,%d)"), this.stateProgram, this.x, this.y);
            GlobalFunctions.Trace(GlobalVariables.expr_buff);
            interp.Execute(interp._onClick);
        }
Exemple #5
0
        public void OnUpdate()
        {
            //	if(this.aspect_changed)
            //	    return;

            if (_interpreterData == null)
            {
                return;
            }

            SignalInterpreterData interp = new SignalInterpreterData((SignalInterpreterData)_interpreterData);

            if (interp._onUpdate == null)
            {
                return;
            }

            interp._signal            = this;
            GlobalVariables.expr_buff = string.Format(wxPorting.T("{0}::OnUpdate({1},{2})"), this.stateProgram, this.x, this.y);
            GlobalFunctions.Trace(GlobalVariables.expr_buff);
            interp.Execute(interp._onUpdate);
        }
Exemple #6
0
        public string GetAction()
        {
            string name = GetAspect();
            SignalInterpreterData interp = (SignalInterpreterData)_interpreterData;
            SignalAspect          asp;

            if (interp == null)
            {
                if (wxPorting.T("red").Equals(name))
                {
                    return(wxPorting.T("stop"));
                }
                return(wxPorting.T("proceed"));
            }
            for (asp = interp._aspects; asp != null; asp = asp._next)
            {
                if ((name != null) && name == asp._name && string.IsNullOrEmpty(asp._action) == false)
                {
                    return(asp._action);
                }
            }
            return(wxPorting.T("proceed")); // broken signal? maybe we should stop.
        }
Exemple #7
0
        object FindIcon()
        {
            SignalInterpreterData interp = (SignalInterpreterData)_interpreterData;
            SignalAspect          asp    = interp._aspects;

            string[] p = null;
            int      ix;
            string   curState = "";

            if (string.IsNullOrEmpty(this._currentState) == false)
            {
                curState = this._currentState;
            }
            else if (this.status == trkstat.ST_GREEN)
            {
                curState = wxPorting.T("green");
            }
            else
            {
                curState = wxPorting.T("red");
            }

            while (asp != null)
            {
                if (curState.Equals(asp._name))
                {
                    break;
                }
                asp = asp._next;
            }
            if (asp == null)
            {
                return(null);
            }
            switch (this.direction)
            {
            case trkdir.W_E:
                p = asp._iconE;
                break;

            case trkdir.E_W:
                p = asp._iconW;
                break;

            case trkdir.N_S:
                p = asp._iconS;
                break;

            case trkdir.S_N:
                p = asp._iconN;
                break;
            }
            if (p == null || p.Length == 0)
            {
                return(null);
            }
            if (_isFlashing)
            {
                if (p[_nextFlashingIcon] == null)
                {
                    _nextFlashingIcon = 0;
                }

                string[] tmp = new string[p.Length - _nextFlashingIcon];
                Array.Copy(p, _nextFlashingIcon, tmp, 0, tmp.Length);
                p = tmp; // p = &p[_nextFlashingIcon];
            }
            if ((ix = GlobalFunctions.get_pixmap_index(p[0])) < 0)
            {
                return(0);
            }
            return(GlobalVariables.pixmaps[ix].pixels);
        }