Example #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 = "未选中信号机";
            }
        }
Example #2
0
        private void showState(SignalProp prop)
        {
            if (null == prop || prop.SignalID.Equals(""))
            {
                return;
            }

            String signal = prop.SignalID;

            if (null == curSignal || !signal.Equals(curSignal.Prop.SignalID.ToUpper()))
            {
                showMap(signal);
            }

            prop = SignalFactory.getSigProp(signal, sigList);

            int idx = 0;

            Trace.WriteLine(" showState: " + prop.ToString());

            try
            {
                // 东/南/西/北
                for (int i = 0; i < 4; i++)
                {
                    //直/左/右/人
                    for (int j = 0; j < 4; j++)
                    {
                        idx = i * 4 + j + 1;
                        string     str = "pb" + idx;
                        PictureBox pb  = (PictureBox)getCtrlByName(str);
                        //if (pb == null)
                        //    continue;

                        if (pb != null)
                        {
                            if (idx > prop.State.Length)
                            {
                                continue;
                            }

                            string c = prop.State.Substring(idx - 1, 1);
                            byte   s = byte.Parse(c);
                            Point  p = prop.Pos[idx - 1];
                            // Trace.WriteLine("  point: " + p.ToString() + " ang: " + prop.Angle[i]);
                            showAState(pb, p, prop.Angle[i], idx, s);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError("showstate error: " + ex.StackTrace);
            }
        }