예제 #1
0
 public void Notify(CMonData mdata)
 {
     qianjin.Stat = mdata.che[0];
     houtui.Stat  = mdata.che[1];
     tingche.Stat = mdata.che[2];
     xihuo.Stat   = mdata.che[3];
     groupBox1.BeginInvoke(myInvoke);
 }
예제 #2
0
 public void Copy(CMonData src)
 {
     for (int i = 0; i < xinhaocount; i++)
     {
         this.gan[i]  = src.gan[i];
         this.xian[i] = src.xian[i];
         if (i < 4)
         {
             this.che[i] = src.che[i];
         }
     }
 }
예제 #3
0
 public void Notify(CMonData mdata)
 {
     form_mdata.Copy(mdata);
     if (label_jbr.InvokeRequired)
     {
         label_jbr.BeginInvoke(formInvoke);
     }
     else
     {
         Event_CMondata(form_mdata);
     }
 }
예제 #4
0
파일: CMonitor.cs 프로젝트: wpmyj/Zhuangkao
        //单库:小车4杆作为7线,小车6杆作为8线,大车4杆作为9线。
        // 套库:小车4杆作为小车7线,小车6杆作为小车8线,大车4杆作为9线。大车7线与小车公用,大车6杆作为大车8线。

        private void readio(ref CMonData mod_s, ref CMonData mod_l)
        {
            sbyte tmpreturn = 0;

            for (int i = 0; i < 6; i++)
            {
                //iorw.write(0x378, (byte)i);
                iorw.write(settings.IO378, (byte)i);
                Thread.Sleep(lvbodelaytime);
                // tmpreturn = (sbyte)iorw.read(0x379);
                tmpreturn     = (sbyte)iorw.read(settings.IO379);
                mod_s.gan[i]  = readbit(tmpreturn, (sbyte)gan_s);
                mod_s.xian[i] = readbit(tmpreturn, (sbyte)xian_s);
                mod_l.gan[i]  = readbit(tmpreturn, (sbyte)gan_l);
                mod_l.xian[i] = readbit(tmpreturn, (sbyte)xian_l);
                if (i < 4)
                {
                    mod_s.che[i] = readbit(tmpreturn, (sbyte)che);
                    mod_l.che[i] = readbit(tmpreturn, (sbyte)che);
                }
            }

            if (che_type == 0)
            {
                //小车信号处理
                mod_s.xian[6] = mod_s.gan[3]; //小车4杆作为7线
                mod_s.gan[3]  = 1;
                mod_s.xian[7] = mod_s.gan[5]; //小车6杆作为8线
                mod_s.gan[5]  = 1;
                mod_s.xian[8] = mod_l.gan[3]; //大车4杆作为9线
                mod_l.gan[3]  = 1;
                mondata_qf_s(ref mod_s);      //取反
                mondata_adminpb_s(ref mod_s); //管理员信号屏蔽
                mondata_pb_s(ref mod_s);      //信号屏蔽
            }
            else
            {
                //大车信号处理
                mod_l.xian[6] = mod_s.gan[3]; //小车4杆作为7线
                mod_s.gan[3]  = 1;
                mod_l.xian[7] = mod_l.gan[5]; //大车6杆作为8线
                mod_l.gan[5]  = 1;
                mod_l.xian[8] = mod_l.gan[3]; //大车4杆作为9线
                mod_l.gan[3]  = 1;
                mondata_qf_l(ref mod_l);      //取反
                mondata_adminpb_l(ref mod_s); //管理员信号屏蔽
                mondata_pb_l(ref mod_s);      //信号屏蔽
            }
        }
예제 #5
0
파일: CMonitor.cs 프로젝트: wpmyj/Zhuangkao
 public CMonitor()
 {
     settings = ModuleConfig.GetSettings();
     jifennum = settings.Jifennum;
     if (jifennum < 3 || jifennum > 100)
     {
         jifennum = 3;
     }
     iorw          = new CIO();
     mondata_s     = new CMonData();
     mondata_l     = new CMonData();
     mondata_s_cur = new CMonData();
     mondata_l_cur = new CMonData();
     mondata_s_old = new CMonData();
     mondata_l_old = new CMonData();
     jifenQueue_s  = new List <CMonData>(jifennum);
     jifenQueue_l  = new List <CMonData>(jifennum);
     //old37a = iorw.read(0x37a);
     //iorw.write(0x37a, 7);
     old37a = iorw.read(settings.IO37A);
     iorw.write(settings.IO37A, 7);
     exit          = 0;
     mrevent       = new ManualResetEvent(false);
     mythread      = new Thread(Monitor);
     delaytime     = settings.Delaytime;
     lvbodelaytime = settings.Lvbodelaytime;
     regobj        = new ArrayList();
     lbgan         = new ulong [9];
     adminpb       = new CMonData();
     adminqf       = new CMonData();
     for (int i = 0; i < 9; i++)
     {
         lbgan[i] = 0;
     }
     Che_Type   = 0;//注意此处为public变量,赋值时会做一系列同步操作
     gan_l      = settings.Gan_l;
     gan_s      = settings.Gan_s;
     xian_l     = settings.Xian_l;
     xian_s     = settings.Xian_s;
     che        = settings.Che;
     modarray_s = new CMonData[jifennum];
     modarray_l = new CMonData[jifennum];
     for (int i = 0; i < jifennum; i++)
     {
         modarray_s[i] = new CMonData();
         modarray_l[i] = new CMonData();
     }
 }
예제 #6
0
 public bool Equals(CMonData src)
 {
     for (int i = 0; i < xinhaocount; i++)
     {
         if (this.xian[i] != src.xian[i] || this.gan[i] != src.gan[i])
         {
             return(false);
         }
         if (i < 4)
         {
             if (this.che[i] != src.che[i])
             {
                 return(false);
             }
         }
     }
     return(true);
 }
예제 #7
0
파일: MonForm.cs 프로젝트: wpmyj/Zhuangkao
 public void Notify(CMonData mdata)
 {
     //string temstr;
     for (int i = 0; i < mdata.xinhaocount; i++)
     {
         if (i < 6)
         {
             gan[i].Stat     = mdata.gan[i];
             lookdata.gan[i] = mdata.gan[i];
         }
         xian[i].Stat = mdata.xian[i];
         //tmp-----data
         lookdata.xian[i] = mdata.xian[i];
     }
     try
     {
         pictureBox1.BeginInvoke(myInvoke);
     }
     catch
     {
     }
     for (int i = 0; i < mdata.xinhaocount; i++)
     {
         if (i < 6)
         {
             if ((mdata.gan[i] == 0) || (mdata.xian[i] == 0))
             {
                 alarm = true;
                 return;
             }
         }
         else
         {
             if (mdata.xian[i] == 0)
             {
                 alarm = true;
                 return;
             }
         }
     }
     alarm = false;
 }
예제 #8
0
파일: CMonitor.cs 프로젝트: wpmyj/Zhuangkao
 private void mondata_pb_l(ref CMonData mondata) //大车信号屏蔽
 {
     for (int i = 0; i < mondata.xinhaocount; i++)
     {
         if (((settings.PbGan_l >> i) & 1) == 1)
         {
             mondata.gan[i] = -1;
         }
         if (((settings.PbXian_l >> i) & 1) == 1)
         {
             mondata.xian[i] = -1;
         }
     }
     for (int i = 0; i < 4; i++)
     {
         if (((settings.PbChe_l >> i) & 1) == 1)
         {
             mondata.che[i] = 0;
         }
     }
 }
예제 #9
0
파일: CMonitor.cs 프로젝트: wpmyj/Zhuangkao
 private bool isequal(CMonData a, CMonData b) //判斷是否相等
 {
     if (a == null && b == null)
     {
         return(true);
     }
     if (a == null || b == null)
     {
         return(false);
     }
     for (int i = 0; i < 9; i++)
     {
         if (i < 6)
         {
             if ((a.gan[i] != b.gan[i]) || (a.xian[i] != b.xian[i]))
             {
                 return(false);
             }
             else
             {
                 if (i < 4)
                 {
                     if (a.che[i] != b.che[i])
                     {
                         return(false);
                     }
                 }
             }
         }
         else
         {
             if (a.xian[i] != b.xian[i])
             {
                 return(false);
             }
         }
     }
     return(true);
 }
예제 #10
0
파일: CMonitor.cs 프로젝트: wpmyj/Zhuangkao
        public void UpdateMonData()
        {
            mondata_s_old.Copy(mondata_s);
            mondata_l_old.Copy(mondata_l);
            for (int j = 0; j < mondata_s.xinhaocount; j++)
            {
                mondata_s.xian[j] = 0;
                mondata_l.xian[j] = 0;
                if (j < 6)
                {
                    mondata_s.gan[j] = 0;
                    mondata_l.gan[j] = 0;
                }
            }

            readio(ref mondata_s, ref mondata_l);

            if (jifenQueue_s.Count >= jifennum)
            {
                jifenQueue_s.RemoveAt(0);
            }
            jifenQueue_s.Add(mondata_s);

            if (jifenQueue_l.Count >= jifennum)
            {
                jifenQueue_l.RemoveAt(0);
            }
            jifenQueue_l.Add(mondata_l);

            mondata_s = JiFen(jifenQueue_s.ToArray(), jifennum);
            mondata_l = JiFen(jifenQueue_l.ToArray(), jifennum);


            //for (int i = 0; i < jifennum; i++)
            //{
            //    readio(ref modarray_s[i], ref modarray_l[i]);
            //    for (int j = 0; j < mondata_s.xinhaocount; j++)
            //    {
            //        mondata_s.xian[j] = (sbyte)(mondata_s.xian[j] | modarray_s[i].xian[j]);
            //        mondata_l.xian[j] = (sbyte)(mondata_l.xian[j] | modarray_l[i].xian[j]);
            //        //if (j < 6)
            //        //{
            //        //    mondata_s.gan[j] = (sbyte)(mondata_s.gan[j] | modarray_s[i].gan[j]);
            //        //    mondata_l.gan[j] = (sbyte)(mondata_l.gan[j] | modarray_l[i].gan[j]);
            //        //}
            //    }
            //}

            //for (int i = 0; i < 6; i++)
            //{
            //    mondata_s.gan[i] = (sbyte)(modarray_s[jifennum - 1].gan[i] | modarray_s[jifennum - 2].gan[i] | modarray_s[jifennum - 3].gan[i]);
            //    mondata_l.gan[i] = (sbyte)(modarray_l[jifennum - 1].gan[i] | modarray_l[jifennum - 2].gan[i] | modarray_l[jifennum - 3].gan[i]);
            //}

            //for (int i = 0; i < 4; i++)
            //{
            //    mondata_s.che[i] = (sbyte)(modarray_s[jifennum - 1].che[i] & modarray_s[jifennum - 2].che[i] & modarray_s[jifennum - 3].che[i]);
            //}

            mondata_s_cur.Copy(mondata_s);
            mondata_l_cur.Copy(mondata_l);
        }
예제 #11
0
        private void Event_CMondata(CMonData mdata)
        {
            xian_label.Text = "线:";
            gan_label.Text  = "杆:";

            for (int i = 0; i < 9; i++)
            {
                xian[i].Stat    = mdata.xian[i];
                xian_label.Text = xian_label.Text + " " + mdata.xian[i];
            }
            for (int i = 0; i < 6; i++)
            {
                gan[i].Stat    = mdata.gan[i];
                gan_label.Text = gan_label.Text + " " + mdata.gan[i];
            }
            if (mdata.che[0] == 1)
            {
                che_label.Text = "车: 前进";
            }
            if (mdata.che[1] == 1)
            {
                che_label.Text = "车: 后退";
            }
            if (mdata.che[2] == 1)
            {
                che_label.Text = "车: 停车";
            }
            if (mdata.che[3] == 1)
            {
                che_label.Text = "车: 熄火";
            }
            xian[6].Stat = mdata.xian[3];
            xian[7].Stat = mdata.xian[3];
            xian[8].Stat = mdata.xian[3];
            if (isstart) //考试时接收及处理IO信号
            {
                if (mdata.che[0] == 1)
                {
                    StateManager.CurrState.Che_qj();
                }
                if (mdata.che[1] == 1)
                {
                    StateManager.CurrState.Che_ht();
                }
                if (mdata.che[2] == 1)
                {
                    StateManager.CurrState.Che_tc();
                }
                if (mdata.che[3] == 1)
                {
                    StateManager.CurrState.Che_xh();
                }
                if (mdata.xian[0] == 0)
                {
                    StateManager.CurrState.Xian1_Bump();
                }
                if (mdata.xian[1] == 0)
                {
                    StateManager.CurrState.Xian2_Bump();
                }
                if (mdata.xian[2] == 0)
                {
                    StateManager.CurrState.Xian3_Bump();
                }
                if (mdata.xian[3] == 0)
                {
                    StateManager.CurrState.Xian4_Bump();
                }
                //else
                //{
                //    StateManager.CurrState.Xian4_Leave();
                //}
                if (mdata.xian[4] == 0)
                {
                    StateManager.CurrState.Xian5_Bump();
                }
                if (mdata.xian[5] == 0)
                {
                    StateManager.CurrState.Xian6_Bump();
                }

                //---增加线信号 7,8,9------------------------------
                if (mdata.xian[6] == 0)
                {
                    StateManager.CurrState.Xian7_Bump();
                }
                if (mdata.xian[7] == 0)
                {
                    StateManager.CurrState.Xian8_Bump();
                }
                //else
                //{
                //    StateManager.CurrState.Xian7_Leave();
                //}
                if (mdata.xian[8] == 0)
                {
                    StateManager.CurrState.Xian9_Bump();
                }
                //--------------------------------------------
                if (mdata.gan[0] == 0)
                {
                    StateManager.CurrState.Gan1_Bump();
                }
                if (mdata.gan[1] == 0)
                {
                    StateManager.CurrState.Gan2_Bump();
                }
                if (mdata.gan[2] == 0)
                {
                    StateManager.CurrState.Gan3_Bump();
                }
                if (mdata.gan[3] == 0)
                {
                    StateManager.CurrState.Gan4_Bump();
                }
                if (mdata.gan[4] == 0)
                {
                    StateManager.CurrState.Gan5_Bump();
                }
                if (mdata.gan[5] == 0)
                {
                    StateManager.CurrState.Gan6_Bump();
                }
            }
        }
예제 #12
0
        public ExamForm(int chetype, bool isExam)
        {
            InitializeComponent();
            form_mdata = new CMonData();
            _isExam    = isExam;
            settings   = ModuleConfig.GetSettings();
            //tempBmpDir = Environment.CurrentDirectory + @"\Temp\";
            //if (!Directory.Exists(tempBmpDir))
            //    Directory.CreateDirectory(tempBmpDir);

            //显示牌初始化
            //displaycomm = new zhuangkao.Displaycomm.CDisplaycomm(settings);
            //displaycomm.Setdisplaytype = Displaycomm.DisplayType.Zhidisp;


            pictureBox_photo.ImageLocation = "img\\photonull.bmp";
            if (isExam)
            {
                //displaycomm.ShowText("准备考试");
                if (settings.IsNetwork)
                {
                    try
                    {
                        Client = new CNetClient(settings.ServerIP, settings.Devnum);
                        Client.Connect();
                        Client.Event_Devnetdata += new CNetClient.D_DEVNETDATA(netclient_Event_Devnetdata);
                    }
                    catch
                    {
                        MessageBox.Show("不能与点名中心建立网络连接", settings.Devnum.ToString() + "号库");
                    }
                }
                else
                {
                    ButtonStart.Text = "开始考试";
                }
                //-------------身份证识别-------------------------
                idcardinfo = new CIDCardInfo();
                idcardinfo.InitIDcardDev();
                idcardinfo.Start();
                idcardinfo.OnIDCardReceived += new CIDCardInfo.IDCardRequest(idcardinfo_OnIDCardReceived);
                //----------------------------------------------------------------
                student = new CStudent(settings);//增加后台数据库连接时间所以将初始化学员信息前置
                //pictureBox2.Visible = false ;

                if (chetype == 0)
                {
                    this.Text = "小型车考试";
                }
                else
                {
                    this.Text = "大型车考试";
                }
                ToolTip toolTip1 = new ToolTip();
                //--------------鼠标悬停提示------------------------
                toolTip1.AutoPopDelay = 5000;
                toolTip1.InitialDelay = 1000;
                toolTip1.ReshowDelay  = 500;
                toolTip1.ShowAlways   = true;
                toolTip1.SetToolTip(this.showLinkState1, "本地数据库连接");
                toolTip1.SetToolTip(this.showLinkState2, "远端数据库连接");

                //-----------初始化考试信息文本框-------------------
                //StudentText = new TextBox[7];
                //for (int i = 0; i < 7; i++)
                //{
                //    StudentText[i] = new System.Windows.Forms.TextBox();
                //    this.navigationPanePanel1.Controls.Add(this.StudentText[i]);
                //    this.StudentText[i].Location = new System.Drawing.Point(65, 13 + i * 20);
                //    this.StudentText[i].Size = new System.Drawing.Size(115, 21);
                //    this.StudentText[i].TabIndex = i;
                //    this.StudentText[i].KeyPress += new KeyPressEventHandler(this.StudentText_KeyPress);
                //}
                //this.StudentText[0].Leave += new System.EventHandler(this.StudentText_Leave);
                //-----------数据库连接状态灯----------------------
                showLinkState1.init();
                showLinkState2.init();
                //-------------综合初始化-----------------------------
                //-------考验员信息----------
                string    tmpconnstr = "Data Source=" + settings.Ipaddress + ";Initial Catalog=zhuangkao;Persist Security Info=True;User ID=sa;Password=cgcsxb";//mssql数据库链接
                CDatabase tmpdb      = new CMsSqlDatabase(tmpconnstr);
                //if (!tmpdb.OpenConnect())
                //{
                //    MessageBox.Show("数据库连接故障!");
                //    this.Close();
                //    return;
                //}
                while (!tmpdb.OpenConnect())
                {
                    ;
                }


                IDataReader dr = tmpdb.executeReader("select name from kyy");

                while (dr.Read())
                {
                    comboBox1.Items.Add(dr["name"]);
                    comboBox2.Items.Add(dr["name"]);
                }
                dr.Close();
                tmpdb.CloseConnect();
                comboBox1.Text = comboBox1.Items[0].ToString();
                comboBox2.Text = comboBox2.Items[0].ToString();
                // --------学员信息-----------
                // student = new CStudent(settings);
                //Thread.Sleep(500);
                student.GetKsNumber();
                label_pass.Text   = "合格:" + student.PassNumber.ToString() + "人";
                label_nopass.Text = "不合格:" + student.NoPassNumber.ToString() + "人";
                label_sum.Text    = "共计:" + Convert.ToString(student.PassNumber + student.NoPassNumber) + "人";

                showLinkState1.LinkState = student.LinkState1; //显示连接状态
                showLinkState2.LinkState = student.LinkState2;
                myprint          = new CPrintContent();        //初始化打印
                ButtonStart.Text = "申请考试";

                //初始化排队考生列表
                StudentlistView.GridLines     = true;
                StudentlistView.FullRowSelect = true;         //要选择就是一行
                StudentlistView.View          = View.Details; //定义列表显示的方式
                StudentlistView.Scrollable    = true;         //需要时候显示滚动条
                StudentlistView.HeaderStyle   = ColumnHeaderStyle.Nonclickable;
                StudentlistView.Columns.Add("序号", StudentlistView.Width * 1 / 6 + 2, HorizontalAlignment.Left);
                StudentlistView.Columns.Add("姓名", StudentlistView.Width * 2 / 6 - 4, HorizontalAlignment.Left);
                StudentlistView.Columns.Add("证号", StudentlistView.Width * 3 / 6 - 3, HorizontalAlignment.Left);
            }
            else
            {
                if (chetype == 0)
                {
                    this.Text = "小型车练习";
                }
                else
                {
                    this.Text = "大型车练习";
                }
                //displaycomm.ShowText("准备练习");
                ButtonStart.Text = "开始考试";
            }
            myinit(chetype);
        }