示例#1
0
        public static bool insertRecord(qzj_record model)
        {
            bool result;

            try
            {
                OleDbConnection adoConn = new OleDbConnection();
                adoConn.ConnectionString = strConn;
                adoConn.Open();
                OleDbCommand     cmd   = adoConn.CreateCommand();
                OleDbTransaction Trans = adoConn.BeginTransaction();
                cmd.Transaction = Trans;
                Trans.Rollback();
                try
                {
                    logControl.saveLogInf("连接数据库成功");
                    string           updatesql   = SqlBuilderHelper.InsertSql <qzj_record>(model, "QZJ");
                    OleDbDataAdapter dataAdapter = new OleDbDataAdapter();
                    dataAdapter.InsertCommand             = new OleDbCommand(updatesql, adoConn);
                    dataAdapter.InsertCommand.CommandText = updatesql;
                    if (dataAdapter.InsertCommand.ExecuteNonQuery() > 0)
                    {
                        result = true;
                        logControl.saveLogInf("插入数据成功");
                    }
                    else
                    {
                        result = false;
                        logControl.saveLogInf("插入数据失败");
                    }
                    dataAdapter.Dispose();
                }
                catch (Exception er)
                {
                    result = false;
                    logControl.saveLogInf("更新数据发生异常:" + er.Message);
                    Trans.Rollback();
                }
                adoConn.Close();
            }
            catch (Exception er)
            {
                result = false;
                logControl.saveLogInf("链接到数据库失败:" + er.Message);
            }
            return(result);
        }
示例#2
0
 private bool writeTestResult(qzj_record model)
 {
     if (System.IO.File.Exists(extlinkdir))
     {
         ini.INIIO.WritePrivateProfileString("ExtLinkData", "Result_5147", model.LEFTTURNLEFT.ToString("0.0"), extlinkdir);
         ini.INIIO.WritePrivateProfileString("ExtLinkData", "Judge_5147", model.LEFTTURNLEFTPD == "合格"?"1":"2", extlinkdir);
         ini.INIIO.WritePrivateProfileString("ExtLinkData", "Result_5148", model.LEFTTURNRIGHT.ToString("0.0"), extlinkdir);
         ini.INIIO.WritePrivateProfileString("ExtLinkData", "Judge_5148", model.LEFTTURNRIGHTPD == "合格" ? "1" : "2", extlinkdir);
         ini.INIIO.WritePrivateProfileString("ExtLinkData", "Result_5149", model.RIGHTTURNRIGHT.ToString("0.0"), extlinkdir);
         ini.INIIO.WritePrivateProfileString("ExtLinkData", "Judge_5149", model.RIGHTTURNRIGHTPD == "合格" ? "1" : "2", extlinkdir);
         ini.INIIO.WritePrivateProfileString("ExtLinkData", "Result_5150", model.RIGHTTURNLEFT.ToString("0.0"), extlinkdir);
         ini.INIIO.WritePrivateProfileString("ExtLinkData", "Judge_5150", model.RIGHTTURNLEFTPD == "合格" ? "1" : "2", extlinkdir);
         ini.INIIO.WritePrivateProfileString("ExtLink", "ScanOK", "5", extlinkdir);
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#3
0
        private void test_Process()
        {
            try
            {
                int    STABLETIME = (int)(controller.stable_time * 20);
                int    TURNTIME   = (int)(controller.turn_time * 20);
                int    ZEROTIME   = (int)(controller.zero_time * 20);
                string sendstring;
                double leftangle, rightangle;
                double leftturnleft = 0, leftturnright = 0, rightturnleft = 0, rightturnright = 0;
                bool   leftturnleftpd = false, leftturnrightpd = false, rightturnleftpd = false, rightturnrightpd = false, zhpd = false;
                Msg(labelOrder3, panelOrder3, "请上转盘", 0);
                int carAlready = 0;

                /*while (carAlready < 30)
                 * {
                 *  if (!controller.isCarAlready) carAlready = 0;
                 *  else carAlready++;
                 *  Thread.Sleep(50);
                 * }*/
                Thread.Sleep(1500);
                Msg(labelOrder3, panelOrder3, "车辆到位", 0);
                Thread.Sleep(1000);
                controller.setClearLeft(out sendstring);
                controller.setClearRight(out sendstring);
                Thread.Sleep(100);
                controller.straightCar(out sendstring);
                Thread.Sleep(100);
                controller.unLockTable(out sendstring);
                Thread.Sleep(1000);
                int stablecount = 0;
                Msg(labelOrder3, panelOrder3, "向左打方向盘", 0);
                //while (controller.angleLeft < 5)
                //{
                //   Msg(labelLeftData, panelLeftData, controller.angleLeft.ToString("0.0"), 0, Math.Abs(controller.angleLeft - vehiclemodel.LEFTTURNLEFT) <= vehiclemodel.LEFTTURNLEFTWC ? Color.Lime : Color.Red);
                //    Msg(labelRightData, panelRightData, controller.angleRight.ToString("0.0"), 0, Math.Abs(controller.angleRight - vehiclemodel.RIGHTTURNLEFT) <= vehiclemodel.LEFTTURNLEFTWC ? Color.Lime : Color.Red);
                //   Thread.Sleep(50);
                //}
                while (stablecount < TURNTIME)//大于5度2秒以上
                {
                    leftangle  = controller.angleLeft;
                    rightangle = controller.angleRight;
                    Msg(labelLeftData, panelLeftData, leftangle.ToString("0.0"), 0, Math.Abs(leftangle - vehiclemodel.LEFTTURNLEFT) <= vehiclemodel.LEFTTURNLEFTWC ? Color.Lime : Color.Red);
                    Msg(labelRightData, panelRightData, rightangle.ToString("0.0"), 0, Math.Abs(-rightangle - vehiclemodel.RIGHTTURNLEFT) <= vehiclemodel.LEFTTURNLEFTWC ? Color.Lime : Color.Red);
                    if (controller.angleLeft < 5)
                    {
                        stablecount = 0;
                    }
                    else//显示过程中的最大值
                    {
                        if (controller.workMode == controller.ENUM_WORDMODE.WORKMODE_DEBUG)//在调试模式下一直等到连续两秒左右都在合格范围内了才继续进行
                        {
                            leftturnleft  = leftangle;
                            rightturnleft = rightangle;
                            if ((Math.Abs(leftturnleft - vehiclemodel.LEFTTURNLEFT) <= vehiclemodel.LEFTTURNLEFTWC) && (Math.Abs(-rightturnleft - vehiclemodel.RIGHTTURNLEFT) <= vehiclemodel.RIGHTTURNLEFTWC))//如果在合格范围内,开始计时
                            {
                                stablecount++;
                            }
                            else
                            {
                                stablecount = 0;
                            }
                        }
                        else//在检验模式下,要等到连续两秒左盘没有超过目前最大值时认为稳定
                        {
                            /*if (leftangle > leftturnleft)
                             * {
                             *  leftturnleft = leftangle;
                             *  rightturnleft = rightangle;
                             *  stablecount = 0;
                             * }
                             * else
                             * {
                             *  stablecount++;
                             * }*/
                            leftturnleft  = leftangle;
                            rightturnleft = rightangle;
                            stablecount++;

                            /* if ((Math.Abs(leftturnleft - vehiclemodel.LEFTTURNLEFT) <= vehiclemodel.LEFTTURNLEFTWC) && (Math.Abs(-rightturnleft - vehiclemodel.RIGHTTURNLEFT) <= vehiclemodel.RIGHTTURNLEFTWC))//如果在合格范围内,开始计时
                             * {
                             *   stablecount++;
                             * }
                             * else
                             * {
                             *   stablecount = 0;
                             * }*/
                        }
                        Msg(labelLzlldata, panelLzlldata, leftturnleft.ToString("0.0"), 0, Math.Abs(leftturnleft - vehiclemodel.LEFTTURNLEFT) <= vehiclemodel.LEFTTURNLEFTWC ? Color.Lime : Color.Red);
                        Msg(labelRzlldata, panelRzlldata, rightturnleft.ToString("0.0"), 0, Math.Abs(-rightturnleft - vehiclemodel.RIGHTTURNLEFT) <= vehiclemodel.LEFTTURNLEFTWC ? Color.Lime : Color.Red);
                    }
                    Thread.Sleep(50);
                }
                stablecount = 0;
                Msg(labelOrder3, panelOrder3, "稳定1秒", 0);
                while (stablecount < STABLETIME)
                {
                    leftangle  = controller.angleLeft;
                    rightangle = controller.angleRight;
                    Msg(labelLeftData, panelLeftData, leftangle.ToString("0.0"), 0, Math.Abs(leftangle - vehiclemodel.LEFTTURNLEFT) <= vehiclemodel.LEFTTURNLEFTWC ? Color.Lime : Color.Red);
                    Msg(labelRightData, panelRightData, rightangle.ToString("0.0"), 0, Math.Abs(-rightangle - vehiclemodel.RIGHTTURNLEFT) <= vehiclemodel.LEFTTURNLEFTWC ? Color.Lime : Color.Red);
                    if (controller.angleLeft < 5)
                    {
                        stablecount = 0;
                    }
                    else//显示过程中的最大值
                    {
                        if (controller.workMode == controller.ENUM_WORDMODE.WORKMODE_DEBUG)//在调试模式下一直等到连续两秒左右都在合格范围内了才继续进行
                        {
                            leftturnleft  = leftangle;
                            rightturnleft = rightangle;
                            if ((Math.Abs(leftturnleft - vehiclemodel.LEFTTURNLEFT) <= vehiclemodel.LEFTTURNLEFTWC) && (Math.Abs(-rightturnleft - vehiclemodel.RIGHTTURNLEFT) <= vehiclemodel.LEFTTURNLEFTWC))//如果在合格范围内,开始计时
                            {
                                stablecount++;
                            }
                            else
                            {
                                stablecount = 0;
                            }
                        }
                        else//在检验模式下,要等到连续两秒左盘没有超过目前最大值时认为稳定
                        {
                            /*if (leftangle > leftturnleft)
                             * {
                             *  leftturnleft = leftangle;
                             *  rightturnleft = rightangle;
                             *  stablecount = 0;
                             * }
                             * else
                             * {
                             *  stablecount++;
                             * }*/

                            leftturnleft  = leftangle;
                            rightturnleft = rightangle;
                            stablecount++;
                        }
                        Msg(labelLzlldata, panelLzlldata, leftturnleft.ToString("0.0"), 0, Math.Abs(leftturnleft - vehiclemodel.LEFTTURNLEFT) <= vehiclemodel.LEFTTURNLEFTWC ? Color.Lime : Color.Red);
                        Msg(labelRzlldata, panelRzlldata, rightturnleft.ToString("0.0"), 0, Math.Abs(-rightturnleft - vehiclemodel.RIGHTTURNLEFT) <= vehiclemodel.LEFTTURNLEFTWC ? Color.Lime : Color.Red);
                    }
                    Thread.Sleep(50);
                }
                leftturnleftpd = (Math.Abs(leftturnleft - vehiclemodel.LEFTTURNLEFT) <= vehiclemodel.LEFTTURNLEFTWC);
                Msg(labelllpd, panelllpd, leftturnleftpd ? "○" : "×", 0, leftturnleftpd ? Color.Lime : Color.Red);
                rightturnleftpd = (Math.Abs(-rightturnleft - vehiclemodel.RIGHTTURNLEFT) <= vehiclemodel.RIGHTTURNLEFTWC);
                Msg(labelrlpd, panelrlpd, rightturnleftpd ? "○" : "×", 0, rightturnleftpd ? Color.Lime : Color.Red);
                Msg(labelOrder3, panelOrder3, "右打方向", 0);
                stablecount = 0;
                while (controller.angleRight < 5)
                {
                    leftangle  = controller.angleLeft;
                    rightangle = controller.angleRight;
                    Msg(labelLeftData, panelLeftData, leftangle.ToString("0.0"), 0, Math.Abs(-leftangle - vehiclemodel.LEFTTURNRIGHT) <= vehiclemodel.LEFTTURNRIGHTWC ? Color.Lime : Color.Red);
                    Msg(labelRightData, panelRightData, rightangle.ToString("0.0"), 0, Math.Abs(rightangle - vehiclemodel.RIGHTTURNRIGHT) <= vehiclemodel.RIGHTTURNRIGHTWC ? Color.Lime : Color.Red);
                    Thread.Sleep(50);
                }
                Msg(labelOrder3, panelOrder3, "向右打方向盘", 0);
                stablecount = 0;
                while (stablecount < TURNTIME)//大于5度2秒以上
                {
                    leftangle  = controller.angleLeft;
                    rightangle = controller.angleRight;
                    Msg(labelLeftData, panelLeftData, leftangle.ToString("0.0"), 0, Math.Abs(-leftangle - vehiclemodel.LEFTTURNRIGHT) <= vehiclemodel.LEFTTURNRIGHTWC ? Color.Lime : Color.Red);
                    Msg(labelRightData, panelRightData, rightangle.ToString("0.0"), 0, Math.Abs(rightangle - vehiclemodel.RIGHTTURNRIGHT) <= vehiclemodel.RIGHTTURNRIGHTWC ? Color.Lime : Color.Red);
                    if (controller.angleRight < 5)
                    {
                        stablecount = 0;
                    }
                    else//显示过程中的最大值
                    {
                        if (controller.workMode == controller.ENUM_WORDMODE.WORKMODE_DEBUG)//在调试模式下一直等到连续两秒左右都在合格范围内了才继续进行
                        {
                            leftturnright  = leftangle;
                            rightturnright = rightangle;
                            if ((Math.Abs(-leftturnright - vehiclemodel.LEFTTURNRIGHT) <= vehiclemodel.LEFTTURNRIGHTWC) && (Math.Abs(rightturnright - vehiclemodel.RIGHTTURNRIGHT) <= vehiclemodel.RIGHTTURNRIGHTWC))//如果在合格范围内,开始计时
                            {
                                stablecount++;
                            }
                            else
                            {
                                stablecount = 0;
                            }
                        }
                        else//在检验模式下,要等到连续两秒左盘没有超过目前最大值时认为稳定
                        {
                            /* if (rightangle > rightturnright)
                             * {
                             *   rightturnright = rightangle;
                             *   leftturnright = leftangle;
                             *   stablecount = 0;
                             * }
                             * else
                             * {
                             *   stablecount++;
                             * }*/
                            rightturnright = rightangle;
                            leftturnright  = leftangle;
                            stablecount++;
                        }
                        Msg(labelLzrldata, panelLzrldata, leftturnright.ToString("0.0"), 0, Math.Abs(-leftturnright - vehiclemodel.LEFTTURNRIGHT) <= vehiclemodel.LEFTTURNRIGHTWC ? Color.Lime : Color.Red);
                        Msg(labelRzrldata, panelRzrldata, rightturnright.ToString("0.0"), 0, Math.Abs(rightturnright - vehiclemodel.RIGHTTURNRIGHT) <= vehiclemodel.RIGHTTURNRIGHTWC ? Color.Lime : Color.Red);
                    }
                    Thread.Sleep(50);
                }
                stablecount = 0;
                Msg(labelOrder3, panelOrder3, "稳定1秒", 0);
                while (stablecount < STABLETIME)
                {
                    leftangle  = controller.angleLeft;
                    rightangle = controller.angleRight;
                    Msg(labelLeftData, panelLeftData, leftangle.ToString("0.0"), 0, Math.Abs(-leftangle - vehiclemodel.LEFTTURNRIGHT) <= vehiclemodel.LEFTTURNRIGHTWC ? Color.Lime : Color.Red);
                    Msg(labelRightData, panelRightData, rightangle.ToString("0.0"), 0, Math.Abs(rightangle - vehiclemodel.RIGHTTURNRIGHT) <= vehiclemodel.RIGHTTURNRIGHTWC ? Color.Lime : Color.Red);
                    if (controller.angleRight < 5)
                    {
                        stablecount = 0;
                    }
                    else//显示过程中的最大值
                    {
                        if (controller.workMode == controller.ENUM_WORDMODE.WORKMODE_DEBUG)//在调试模式下一直等到连续两秒左右都在合格范围内了才继续进行
                        {
                            leftturnright  = leftangle;
                            rightturnright = rightangle;
                            if ((Math.Abs(-leftturnright - vehiclemodel.LEFTTURNRIGHT) <= vehiclemodel.LEFTTURNRIGHTWC) && (Math.Abs(rightturnright - vehiclemodel.RIGHTTURNRIGHT) <= vehiclemodel.RIGHTTURNRIGHTWC))//如果在合格范围内,开始计时
                            {
                                stablecount++;
                            }
                            else
                            {
                                stablecount = 0;
                            }
                        }
                        else//在检验模式下,要等到连续两秒左盘没有超过目前最大值时认为稳定
                        {
                            /*if (rightangle > rightturnright)
                             * {
                             *  rightturnright = rightangle;
                             *  leftturnright = leftangle;
                             *  stablecount = 0;
                             * }
                             * else
                             * {
                             *  stablecount++;
                             * }*/
                            rightturnright = rightangle;
                            leftturnright  = leftangle;
                            stablecount++;
                        }
                        Msg(labelLzrldata, panelLzrldata, leftturnright.ToString("0.0"), 0, Math.Abs(-leftturnright - vehiclemodel.LEFTTURNRIGHT) <= vehiclemodel.LEFTTURNRIGHTWC ? Color.Lime : Color.Red);
                        Msg(labelRzrldata, panelRzrldata, rightturnright.ToString("0.0"), 0, Math.Abs(rightturnright - vehiclemodel.RIGHTTURNRIGHT) <= vehiclemodel.RIGHTTURNRIGHTWC ? Color.Lime : Color.Red);
                    }
                    Thread.Sleep(50);
                }
                leftturnrightpd = (Math.Abs(-leftturnright - vehiclemodel.LEFTTURNRIGHT) <= vehiclemodel.LEFTTURNRIGHTWC);
                Msg(labellrpd, panellrpd, leftturnrightpd ? "○" : "×", 0, leftturnrightpd ? Color.Lime : Color.Red);
                rightturnrightpd = (Math.Abs(rightturnright - vehiclemodel.RIGHTTURNRIGHT) <= vehiclemodel.RIGHTTURNRIGHTWC);
                Msg(labelrrpd, panelrrpd, rightturnrightpd ? "○" : "×", 0, rightturnrightpd ? Color.Lime : Color.Red);
                Msg(labelOrder3, panelOrder3, "请回零", 0);
                stablecount = 0;
                while (stablecount < ZEROTIME)//当左盘和右盘均回到规定的回零限值后
                {
                    leftangle  = controller.angleLeft;
                    rightangle = controller.angleRight;
                    Msg(labelLeftData, panelLeftData, leftangle.ToString("0.0"), 0, controller.isLeftZero ? Color.Lime : Color.Red);
                    Msg(labelRightData, panelRightData, rightangle.ToString("0.0"), 0, controller.isRightZero ? Color.Lime : Color.Red);
                    if (!controller.isLeftZero || !controller.isRightZero)
                    {
                        stablecount = 0;
                    }
                    else
                    {
                        stablecount++;
                    }
                    Thread.Sleep(50);
                }
                zhpd = (leftturnleftpd && leftturnrightpd && rightturnleftpd && rightturnrightpd);
                Msg(labelOrder3, panelOrder3, zhpd ? "转向角 ○" : "转向角 ×", 0);
                controller.lockTable(out sendstring);
                Thread.Sleep(100);
                controller.backStraight(out sendstring);
                Thread.Sleep(1000);
                qzj_record record = new qzj_record();
                record.CLID           = System.Guid.NewGuid().ToString().Replace("-", "");
                record.STATIONID      = "";
                record.LSH            = "";
                record.CLHP           = VIN;
                record.VEHICLENAME    = VEHICLENAME;
                record.MAXSPEED       = "";
                record.JCSJ           = DateTime.Now;
                record.LEFTTURNLEFT   = leftturnleft;
                record.RIGHTTURNLEFT  = rightturnleft;
                record.LEFTTURNRIGHT  = leftturnright;
                record.RIGHTTURNRIGHT = rightturnright;
                record.XZ             = vehiclemodel.LEFTTURNLEFT.ToString() + "-" + vehiclemodel.LEFTTURNLEFTWC + "|"
                                        + vehiclemodel.RIGHTTURNLEFT.ToString() + "-" + vehiclemodel.RIGHTTURNLEFTWC + "|"
                                        + vehiclemodel.LEFTTURNRIGHT.ToString() + "-" + vehiclemodel.LEFTTURNRIGHTWC + "|"
                                        + vehiclemodel.RIGHTTURNRIGHT.ToString() + "-" + vehiclemodel.RIGHTTURNRIGHTWC;
                record.LEFTTURNLEFTPD   = leftturnleftpd ? "合格" : "不合格";
                record.RIGHTTURNLEFTPD  = rightturnleftpd ? "合格" : "不合格";
                record.LEFTTURNRIGHTPD  = leftturnrightpd ? "合格" : "不合格";
                record.RIGHTTURNRIGHTPD = rightturnrightpd ? "合格" : "不合格";
                record.ZHPD             = zhpd ? "合格" : "不合格";
                record.HASUPLOAD        = (workMode == ENUM_WORK_MODE.WORK_MODE_NET) ? "Y" : "N";
                if (!SqlControl.insertRecord(record))
                {
                    Msg(labelOrder3, panelOrder3, "数据保存失败", 0);
                    Thread.Sleep(2000);
                }
                else if (workMode == ENUM_WORK_MODE.WORK_MODE_NET)
                {
                    if (!writeTestResult(record))
                    {
                        Msg(labelOrder3, panelOrder3, "写结果数据失败", 0);
                        Thread.Sleep(2000);
                    }
                }
                stablecount = 0;

                /*while(stablecount<20)//车离开光电累计1秒后,检测流程退出
                 * {
                 *  if (!controller.isCarAlready) stablecount++;
                 *  Thread.Sleep(50);
                 * }*/
                Thread.Sleep(1500);
                controller.scanState = 0;
                CloseForm();
            }
            catch (Exception er)
            {
                logControl.saveLogInf("[exception:]" + er.Message);
                CloseForm();
            }
        }