Esempio n. 1
0
        private void button8_Click(object sender, EventArgs e)
        {
            String CmdStr = "FFFFFFFF0601050000";//退出测试

            SerialFun.SendToPort(SerialFun.ComPortSend, CmdStr);
            Trace.WriteLine("执行退出测试指令:" + SerialFun.SendToPort(SerialFun.ComPortSend, CmdStr));
        }
Esempio n. 2
0
        private void button10_Click(object sender, EventArgs e)
        {
            //   PrintMachine.PrintUniqueCode("2000年1月1日", "99999999");

            #region 写入id

            SerialFun.SendToPort(SerialFun.ComPortSend, " FFFFFFFF0601058500");               //允许写入UUID
            Thread.Sleep(1000);
            SerialFun.SendToPort(SerialFun.ComPortSend, " FFFFFFFFFF0CF7" + Data.UniqueCode); //允许写入UUID
            Thread.Sleep(1000);
            SerialFun.SendToPort(SerialFun.ComPortSend, " FFFFFFFF0601050000");               //

            #endregion

            int temp = 0;
            int.TryParse(Data.UniqueCode, out temp);
            temp            = temp + 1;
            Data.UniqueCode = Convert.ToString(temp, 10).PadLeft(8, '0');

            this.textBox_UniqueCode.Text = Data.UniqueCode;

            //this.textBox_UniqueCode.Invoke(myDeleUpdateTextBox, this.textBox_UniqueCode, Data.UniqueCode);

            SetConfigValue("UniqueCode", Data.UniqueCode);
        }
Esempio n. 3
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (waitSecond < 1)
            {
                this.Close();
            }
            else
            {
                waitSecond--;
                label1.Text  = "请将挡板移到车位锁上方,测试到超声波会自动退出---倒计时:" + waitSecond + "秒";
                button2.Text = "超声异常" + "(" + waitSecond + ")";


                SerialFun.SendToPort(SerialFun.ComPortSend, "FFFFFFFF0420010004");//查询

                Thread.Sleep(100);

                if (Data.ReturnStr.Length > 32)
                {
                    byte Ultrasonic_return_b9 = Convert.ToByte(Data.ReturnStr.Substring(28, 2), 16);
                    Trace.WriteLine(Ultrasonic_return_b9);
                    bool Ultrasonic_result_S1 = false;
                    bool Ultrasonic_result_S2 = false;

                    if ((Ultrasonic_return_b9 & 0xf0) != 0)
                    {
                        Ultrasonic_result_S1 = true;
                    }
                    if ((Ultrasonic_return_b9 & 0x0f) != 0)
                    {
                        Ultrasonic_result_S2 = true;
                    }

                    if (Ultrasonic_result_S1 & Ultrasonic_result_S2)
                    {
                        Data.UltrasonicStatus = 0;
                        waitSecond            = 0;
                    }
                    else if ((!Ultrasonic_result_S1) & Ultrasonic_result_S2)
                    {
                        Data.UltrasonicStatus = 1;
                    }
                    else if (Ultrasonic_result_S1 & (!Ultrasonic_result_S2))
                    {
                        Data.UltrasonicStatus = 2;
                    }
                    else
                    {
                        Data.UltrasonicStatus = 3;
                    }
                }
                else
                {
                    Data.UltrasonicStatus = 4;
                }
            }
        }
Esempio n. 4
0
        private void LifeTestThread(int nums)
        {
            int runNum = 0;

            while (threadOn)
            {
                if (SerialFun.ComPortSend.IsOpen)
                {
                    if (runNum++ < nums)
                    {                                          //FFFFFFFF051002FF00
                        String CmdStr1 = "FFFFFFFF051002FF00"; //升锁
                        SerialFun.SendToPort(SerialFun.ComPortSend, CmdStr1);

                        Thread.Sleep(5000);

                        String CmdStr2 = "FFFFFFFF051003FF00";//降锁
                        SerialFun.SendToPort(SerialFun.ComPortSend, CmdStr2);

                        Thread.Sleep(5000);

                        AlreadyRunNums += 1;
                        textBox2.BeginInvoke(new Action(() => { textBox2.Text = AlreadyRunNums.ToString();; }));
                    }
                    else
                    {
                        MessageBox.Show("测试完成!!");
                        this.button1.BeginInvoke(new Action(() => { this.button1.Text = "开始寿命测试"; }));
                        break;
                    }
                }
                else
                {
                    MessageBox.Show("串口未正确打开,设置正确后重新开始测试!");
                    this.button1.BeginInvoke(new Action(() => { this.button1.Text = "开始寿命测试"; }));
                    break;
                }
            }
        }
Esempio n. 5
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (waitSecond < 1)
            {
                this.Close();
            }
            else
            {
                waitSecond--;
                label1.Text = "左右移动的挡板,测试到地磁抖动会自动退出此窗口---倒计时:" + waitSecond + "秒";

                SerialFun.SendToPort(SerialFun.ComPortSend, "FFFFFFFF0420010004");//查询
                Thread.Sleep(100);
                if (Data.ReturnStr.Length > 32)
                {
                    if (Data.ReturnStr.Substring(28, 2) == "55")
                    {
                        Data.MagneticStatus = true;
                        waitSecond          = 0;
                    }
                }
            }
        }
Esempio n. 6
0
        private void button13_Click(object sender, EventArgs e)
        {
            String CmdStr = "FFFFFFFF0300070002";//查询UUID

            SerialFun.SendToPort(SerialFun.ComPortSend, CmdStr);
        }
Esempio n. 7
0
        private void Fun_Compare()
        {
            DeleUpdateGridView  myDeleUpdate        = new DeleUpdateGridView(UpdateGridView);
            DeleUpdateGridView2 myDeleUpdate2       = new DeleUpdateGridView2(UpdateGridView2);
            DeleUpdateTextBox   myDeleUpdateTextBox = new DeleUpdateTextBox(UpdateTextBox);
            String ret1   = null;
            bool   result = true;


            if (SerialFun.ComPortSend.IsOpen)
            {
                try
                {
                    MyLog.Info("开始升锁测试");
                    #region 升锁测试
                    ret1 = SerialFun.SendToPort(SerialFun.ComPortSend, "FFFFFFFF051002FF00");//升锁
                    Thread.Sleep(500);
                    if (Data.ReturnStr == ret1)
                    {
                        dataGridView1.Invoke(myDeleUpdate, 0, "升锁中...");
                    }
                    Thread.Sleep(5000);

                    SerialFun.SendToPort(SerialFun.ComPortSend, "FFFFFFFF0420010004");//查询
                    Thread.Sleep(500);

                    if (Data.ReturnStr.Substring(22, 2) == "55")
                    {
                        dataGridView1.Invoke(myDeleUpdate, 0, "升锁成功");
                    }
                    else
                    {
                        dataGridView1.Invoke(myDeleUpdate, 0, "升锁失败");
                        result = false;
                    }
                    #endregion
                    MyLog.Info("开始降锁测试");
                    #region 降锁测试
                    ret1 = SerialFun.SendToPort(SerialFun.ComPortSend, "FFFFFFFF051003FF00");//降锁
                    Thread.Sleep(500);
                    if (Data.ReturnStr == ret1)
                    {
                        dataGridView1.Invoke(myDeleUpdate, 1, "降锁中...");
                    }
                    Thread.Sleep(5000);
                    SerialFun.SendToPort(SerialFun.ComPortSend, "FFFFFFFF0420010004");//查询
                    Thread.Sleep(500);
                    if (Data.ReturnStr.Substring(22, 2) == "ff")
                    {
                        dataGridView1.Invoke(myDeleUpdate, 1, "降锁成功");
                    }
                    else
                    {
                        dataGridView1.Invoke(myDeleUpdate, 1, "降锁失败");
                        result = false;
                    }
                    #endregion

                    #region 蜂鸣器测试
                    //ret1 = SerialFun.SendToPort(SerialFun.ComPortSend, "01051004FF00");//报警
                    //Thread.Sleep(500);
                    //if (Data.ReturnStr == ret1)
                    //{
                    //    dataGridView1.Invoke(myDeleUpdate, 2, "报警中...");
                    //}
                    //Thread.Sleep(2000);

                    //ret1 = SerialFun.SendToPort(SerialFun.ComPortSend, "01051005FF00");//取消报警
                    //Thread.Sleep(500);
                    //if (Data.ReturnStr == ret1)
                    //{
                    //    dataGridView1.Invoke(myDeleUpdate, 2, "取消报警...");
                    //}
                    //Thread.Sleep(500);

                    //UserConfirm frm = new UserConfirm();
                    //frm.ShowDialog();
                    //if (Data.AlarmStatus)
                    //{
                    //    dataGridView1.Invoke(myDeleUpdate, 2, "蜂鸣器正常");
                    //}
                    //else
                    //{
                    //    dataGridView1.Invoke(myDeleUpdate, 2, "蜂鸣器异常");
                    //    result = false;
                    //}
                    #endregion

                    MyLog.Info("开始无车情况下 超声测试以及地磁测试");
                    #region 无车情况下 超声测试以及地磁测试
                    ret1 = SerialFun.SendToPort(SerialFun.ComPortSend, "FFFFFFFF0601050300");//进入超声测试
                    Thread.Sleep(500);
                    if (Data.ReturnStr == ret1)
                    {
                        dataGridView1.Invoke(myDeleUpdate, 3, "超声测试中...");
                    }

                    bool Normal_Ultrasonic_Tag = true;
                    for (int i = 0; i < 10; i++)
                    {
                        SerialFun.SendToPort(SerialFun.ComPortSend, "FFFFFFFF0420010004");//查询
                        Thread.Sleep(200);
                        if (Data.ReturnStr.Length > 32)
                        {
                            if (Data.ReturnStr.Substring(30, 2) != "00")
                            {
                                Normal_Ultrasonic_Tag = false;
                                MyLog.Error("无车超声测试时收到异常返回:" + Data.ReturnStr);
                                break;
                            }
                        }
                    }

                    if (Normal_Ultrasonic_Tag)
                    {
                        dataGridView1.Invoke(myDeleUpdate, 3, "无车情况:超声正常");
                    }
                    else
                    {
                        byte temp_byte = Convert.ToByte(Data.ReturnStr.Substring(30, 2), 16);

                        bool temp_flag1 = false;
                        bool temp_flag2 = false;

                        if ((temp_byte & 0xf0) != 0)
                        {
                            temp_flag1 = true;
                        }
                        if ((temp_byte & 0x0f) != 0)
                        {
                            temp_flag2 = true;
                        }

                        if (temp_flag1 & temp_flag2)
                        {
                            dataGridView1.Invoke(myDeleUpdate, 3, "无车情况:超声正常");
                        }
                        else if ((!temp_flag1) & temp_flag2)
                        {
                            dataGridView1.Invoke(myDeleUpdate, 3, "无车情况:超声探头1异常");
                        }
                        else if (temp_flag1 & (!temp_flag2))
                        {
                            dataGridView1.Invoke(myDeleUpdate, 3, "无车情况:超声探头2异常");
                        }
                        else
                        {
                            dataGridView1.Invoke(myDeleUpdate, 3, "无车情况:超声探头1,2异常");
                        }

                        result = false;
                    }

                    SerialFun.SendToPort(SerialFun.ComPortSend, "FFFFFFFF0601050000"); //退出超声测试
                    Thread.Sleep(500);
                    SerialFun.SendToPort(SerialFun.ComPortSend, "FFFFFFFF0601050000"); //退出超声测试
                    Thread.Sleep(500);


                    ret1 = SerialFun.SendToPort(SerialFun.ComPortSend, "FFFFFFFF0601050400");//进入地磁测试
                    Thread.Sleep(2000);
                    if (Data.ReturnStr == ret1)
                    {
                        dataGridView1.Invoke(myDeleUpdate, 4, "地磁测试中...");
                    }

                    bool Normal_UltraMagnetic_Tag = true;
                    for (int i = 0; i < 10; i++)
                    {
                        SerialFun.SendToPort(SerialFun.ComPortSend, "FFFFFFFF0420010004");//查询
                        Thread.Sleep(200);
                        if (Data.ReturnStr.Length > 32)
                        {
                            if (Data.ReturnStr.Substring(24, 2) != "00")
                            {
                                Normal_UltraMagnetic_Tag = false;
                                MyLog.Error("无车地磁测试时收到异常返回:" + Data.ReturnStr);
                                break;
                            }
                        }
                    }

                    if (Normal_UltraMagnetic_Tag)
                    {
                        dataGridView1.Invoke(myDeleUpdate, 4, "无车情况:地磁正常");
                    }
                    else
                    {
                        dataGridView1.Invoke(myDeleUpdate, 4, "无车情况:地磁异常");
                        result = false;
                    }

                    SerialFun.SendToPort(SerialFun.ComPortSend, "FFFFFFFF0601050000"); //退出地磁测试
                    Thread.Sleep(500);
                    SerialFun.SendToPort(SerialFun.ComPortSend, "FFFFFFFF0601050000"); //退出地磁测试
                    Thread.Sleep(500);

                    #endregion


                    MyLog.Info("开始有车情况下 超声测试以及地磁测试");
                    #region  车情况下,超声测试、地磁测试

                    ret1 = SerialFun.SendToPort(SerialFun.ComPortSend, "FFFFFFFF0601050300");//进入有车超声测试
                    Thread.Sleep(500);
                    if (Data.ReturnStr == ret1)
                    {
                        dataGridView1.Invoke(myDeleUpdate, 5, "超声测试中...");
                    }

                    User_Ultrasonic_Confirm frm2 = new User_Ultrasonic_Confirm();
                    frm2.ShowDialog();

                    switch (Data.UltrasonicStatus)
                    {
                    case 0:
                        dataGridView1.Invoke(myDeleUpdate, 5, "有车情况:超声正常");
                        break;

                    case 1:
                        dataGridView1.Invoke(myDeleUpdate, 5, "有车情况:超声探头1异常");
                        result = false;
                        break;

                    case 2:
                        dataGridView1.Invoke(myDeleUpdate, 5, "有车情况:超声探头2异常");
                        result = false;
                        break;

                    case 3:
                        dataGridView1.Invoke(myDeleUpdate, 5, "有车情况:超声探头1,2异常");
                        result = false;
                        break;

                    case 4:
                        dataGridView1.Invoke(myDeleUpdate, 5, "485通讯异常");
                        result = false;
                        break;

                    default:
                        dataGridView1.Invoke(myDeleUpdate, 5, "有车情况:超声探头1,2异常");
                        result = false;
                        break;
                    }

                    SerialFun.SendToPort(SerialFun.ComPortSend, "FFFFFFFF0601050000"); //退出超声测试
                    Thread.Sleep(500);
                    SerialFun.SendToPort(SerialFun.ComPortSend, "FFFFFFFF0601050000"); //退出超声测试
                    Thread.Sleep(500);


                    ret1 = SerialFun.SendToPort(SerialFun.ComPortSend, "FFFFFFFF0601050400");//进入有车地磁测试
                    Thread.Sleep(500);
                    if (Data.ReturnStr == ret1)
                    {
                        dataGridView1.Invoke(myDeleUpdate, 6, "地磁测试中...");
                    }
                    User_Magnetic_Confirm frm3 = new User_Magnetic_Confirm();
                    frm3.ShowDialog();

                    if (Data.MagneticStatus)
                    {
                        dataGridView1.Invoke(myDeleUpdate, 6, "有车情况:地磁正常");
                    }
                    else
                    {
                        dataGridView1.Invoke(myDeleUpdate, 6, "有车情况:地磁异常");
                        result = false;
                    }


                    SerialFun.SendToPort(SerialFun.ComPortSend, "FFFFFFFF0601050000"); //退出地磁测试
                    Thread.Sleep(500);
                    SerialFun.SendToPort(SerialFun.ComPortSend, "FFFFFFFF0601050000"); //退出地磁测试
                    Thread.Sleep(500);

                    #endregion

                    if (result)
                    {
                        string timestr = string.Format("{0}-{1:D2}-{2:D2}", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
                        PrintMachine.PrintUniqueCode(timestr, Data.UniqueCode);

                        string time   = string.Format("{0}-{1:D2}-{2:D2} {3:D2}:{4:D2}:{5:D2}", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
                        string detail = "";
                        foreach (DataRow row in dtLock.Rows)
                        {
                            detail += row[2] + ",";
                        }
                        dataGridView2.Invoke(myDeleUpdate2, Data.UniqueCode, time, "测试通过", detail);

                        Data.sql.InsertValues("table_All", new string[] { Data.UniqueCode, time, "测试通过", detail });
                        Data.sql.InsertValues("table_Right", new string[] { Data.UniqueCode, time, "测试通过", detail });
                    }
                    else
                    {
                        MyLog.Error("当前测试失败,请重新测试!");

                        string time   = string.Format("{0}-{1:D2}-{2:D2} {3:D2}:{4:D2}:{5:D2}", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
                        string detail = "";
                        foreach (DataRow row in dtLock.Rows)
                        {
                            detail += row[2] + ",";
                        }
                        dataGridView2.Invoke(myDeleUpdate2, Data.UniqueCode, time, "测试失败", detail);
                        Data.sql.InsertValues("table_All", new string[] { Data.UniqueCode, time, "测试失败", detail });
                        Data.sql.InsertValues("table_Error", new string[] { Data.UniqueCode, time, "测试失败", detail });
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("串口错误,请重新配置串口!!");
                    //   MyLog.Error(ex.Message);
                    MyLog.Error(ex.ToString());
                }
            }
            else
            {
                MyLog.Error("串口未打开,测试失败,请重新测试!");
            }
            Trace.WriteLine("退出Fun_Compare");
        }
Esempio n. 8
0
        private void button9_Click(object sender, EventArgs e)
        {
            String CmdStr = "FFFFFFFF0420020004";//查询指令

            Trace.WriteLine("执行查询指令:" + SerialFun.SendToPort(SerialFun.ComPortSend, CmdStr));
        }
Esempio n. 9
0
        private void button6_Click(object sender, EventArgs e)
        {
            String CmdStr = "FFFFFFFF051006FF00";//降锁休眠

            SerialFun.SendToPort(SerialFun.ComPortSend, CmdStr);
        }