Пример #1
0
        private void tvSignalList_DoubleClick(object sender, EventArgs e)
        {
            string     selStr = tvSignalList.SelectedNode.Text;
            SignalProp prop   = SignalFactory.getSigPropByName(selStr, sigList);

            timerGetCurSig.Enabled = false;

            if (null != prop)
            {
                tlog(prop.ToString());
                curSignal = SignalFactory.buildController(prop);
                tlog(prop.ToString());
                showMap(prop.SignalID);
                showSigInfo(prop);
                rbManSpec.Checked = true;

                if (curSignal.connect())
                {
                    timerGetCurSig.Enabled = true;
                }
                else
                {
                    lblSignalName.Text = "信号机:" + prop.SignalName + " 连接失败";
                }
            }
            else
            {
                lblSignalName.Text = "未选中信号机";
            }
        }
Пример #2
0
        /// <summary>
        /// 定时获取当前信号机状态,并展示在界面上
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (specPoly == 1)
            {// 自动特勤,从数据库中取当前信号机
                if (signalDao.getState() == ConnectionState.Open)
                {
                    FProp = signalDao.getCurSigProp();
                    String state = FProp.State;
                    FProp       = SignalFactory.getSigProp(FProp.SignalID, sigList);
                    FProp.State = state;

                    if (null == FProp)
                    {
                        return;
                    }

                    if (null == curSignal || !FProp.SignalID.Equals(curSignal.Prop.SignalID))
                    {
                        curSignal = SignalFactory.buildController(FProp);
                    }

                    curSignal.Prop = FProp;
                }
                else
                {
                    timerGetCurSig.Enabled = false;
                    showPBs(false);

                    lblSignalName.Text = "数据库未连接!";
                    return;
                }
            }
            else
            {//手动特勤,从左侧列表中取当前双击的信号机
                if (null == curSignal)
                {
                    timerGetCurSig.Enabled = false;
                    showPBs(false);
                    return;
                }

                if (curSignal.updateState())
                {
                    FProp = curSignal.Prop;
                    showSigInfo(FProp);
                    // lblBaseState.Text = FProp.State;
                }
                else
                {
                    // 如果更新状态失败,则说明信号机状态异常,则停掉定时器,避免程序挂死
                    timerGetCurSig.Enabled = false;
                    lblSignalName.Text     = "获取信号机状态失败";
                    showPBs(false);
                    return;
                }

                //listBox1.Items.Insert(0, null==curSignal.Prop.State?"get state error": curSignal.Prop.State);
            }

            // 处理显示
            showPBs(true);
            showSigInfo(FProp);
            dealWithSigProp(FProp);
        }