Пример #1
0
        //check product weight
        bool _product_weight_is_valid()
        {
            bool r = false;

            if (MyGlobal.MyTesting.UseScaleFlag == true)
            {
                int    count = 0;
                double ul    = double.Parse(MyGlobal.MySetting.WeightUL);
                double ll    = double.Parse(MyGlobal.MySetting.WeightLL);
                MyGlobal.testFunctionLogInfo.WEIGHT.Upper_Limit         = MyGlobal.MySetting.WeightUL;
                MyGlobal.testFunctionLogInfo.WEIGHT.Lower_Limit         = MyGlobal.MySetting.WeightLL;
                MyGlobal.testFunctionLogInfo.WEIGHT.Unit_Of_Measurement = "g";

REP:
                count++;
                string weight_string = CAS_EDH.GetWeight();

                if (weight_string == null)
                {
                    if (count < 5)
                    {
                        goto REP;
                    }
                    else
                    {
                        MyGlobal.MyTesting.ErrorMessage += string.Format("Product weight can not is NULL.", weight_string);
                        MyGlobal.testFunctionLogInfo.WEIGHT.Actual_Value = "NULL";
                        MyGlobal.testFunctionLogInfo.WEIGHT.Result       = "FAIL";
                        MyGlobal.testFunctionLogInfo.Error_Message       = MyGlobal.MyTesting.ErrorMessage;
                        return(false);
                    }
                }

                double weight_value;
                if (!double.TryParse(weight_string, out weight_value))
                {
                    if (count < 5)
                    {
                        goto REP;
                    }
                    else
                    {
                        MyGlobal.MyTesting.ErrorMessage += string.Format("Product weight {0} is not valid.", weight_string);
                        MyGlobal.testFunctionLogInfo.WEIGHT.Actual_Value = weight_string;
                        MyGlobal.testFunctionLogInfo.WEIGHT.Result       = "FAIL";
                        MyGlobal.testFunctionLogInfo.Error_Message       = MyGlobal.MyTesting.ErrorMessage;
                        return(false);
                    }
                }

                MyGlobal.MyTesting.WeightActual = weight_value.ToString();
                MyGlobal.testFunctionLogInfo.WEIGHT.Actual_Value = MyGlobal.MyTesting.WeightActual;
                r = weight_value >= ll && weight_value <= ul;

                if (!r)
                {
                    if (count < 5)
                    {
                        goto REP;
                    }
                    else
                    {
                        MyGlobal.MyTesting.ErrorMessage           += string.Format("Product weight {0} is out of range {1}.", weight_string, MyGlobal.MyTesting.WeightStandard);
                        MyGlobal.testFunctionLogInfo.WEIGHT.Result = "FAIL";
                        MyGlobal.testFunctionLogInfo.Error_Message = MyGlobal.MyTesting.ErrorMessage;
                        return(false);
                    }
                }
                else
                {
                    MyGlobal.testFunctionLogInfo.WEIGHT.Result = "PASS";
                    MyGlobal.testFunctionLogInfo.Error_Message = MyGlobal.MyTesting.ErrorMessage;
                    return(true);
                }
            }
            else
            {
                return(true);
            }
        }
        //check product weight
        bool _product_weight_is_valid()
        {
            bool r = false;

            if (reworkInformation.PrintMode == "Combine label printing with product weighing")
            {
                int    count = 0;
                double ul    = double.Parse(product.weight) + double.Parse(product.bias);
                double ll    = double.Parse(product.weight) - double.Parse(product.bias);
                MyGlobal.testFunctionLogInfo.WEIGHT.Upper_Limit         = ul.ToString();
                MyGlobal.testFunctionLogInfo.WEIGHT.Lower_Limit         = ll.ToString();
                MyGlobal.testFunctionLogInfo.WEIGHT.Unit_Of_Measurement = "g";

REP:
                count++;
                string weight_string = CAS_EDH.GetWeight();

                if (weight_string == null)
                {
                    if (count < 5)
                    {
                        goto REP;
                    }
                    else
                    {
                        reworkInformation.ErrorMessage += string.Format("Product weight can not is NULL.", weight_string);
                        MyGlobal.testFunctionLogInfo.WEIGHT.Actual_Value = "NULL";
                        MyGlobal.testFunctionLogInfo.WEIGHT.Result       = "FAIL";
                        MyGlobal.testFunctionLogInfo.Error_Message       = reworkInformation.ErrorMessage;
                        return(false);
                    }
                }

                double weight_value;
                if (!double.TryParse(weight_string, out weight_value))
                {
                    if (count < 5)
                    {
                        goto REP;
                    }
                    else
                    {
                        reworkInformation.ErrorMessage += string.Format("Product weight {0} is not valid.", weight_string);
                        MyGlobal.testFunctionLogInfo.WEIGHT.Actual_Value = weight_string;
                        MyGlobal.testFunctionLogInfo.WEIGHT.Result       = "FAIL";
                        MyGlobal.testFunctionLogInfo.Error_Message       = reworkInformation.ErrorMessage;
                        return(false);
                    }
                }

                reworkInformation.WeightActual = weight_value.ToString();
                MyGlobal.testFunctionLogInfo.WEIGHT.Actual_Value = reworkInformation.WeightActual;
                r = weight_value >= ll && weight_value <= ul;

                if (!r)
                {
                    if (count < 5)
                    {
                        goto REP;
                    }
                    else
                    {
                        reworkInformation.ErrorMessage            += string.Format("Product weight {0} is out of range {1}.", weight_string, reworkInformation.WeightLimit);
                        MyGlobal.testFunctionLogInfo.WEIGHT.Result = "FAIL";
                        MyGlobal.testFunctionLogInfo.Error_Message = reworkInformation.ErrorMessage;
                        return(false);
                    }
                }
                else
                {
                    MyGlobal.testFunctionLogInfo.WEIGHT.Result = "PASS";
                    MyGlobal.testFunctionLogInfo.Error_Message = reworkInformation.ErrorMessage;
                    return(true);
                }
            }
            else
            {
                return(true);
            }
        }