예제 #1
0
        public static ReturnClass RunModel(string Model, string RawString)
        {
            ReturnClass ret = new ReturnClass();

            ret.GoodData   = true;
            ret.countClean = RawString.Length - 1;
            switch (Model)
            {
            case "SS_CGP_TCA_50":
            {
                ret = Model_SS_CGP_TCA_50(RawString);
                break;
            }

            case "SS_CGP_TBOX_PR1":
            {
                ret = Model_SS_CGP_TBOX_PR1(RawString);
                break;
            }

            case "AMT_DISOBOX_PLUS":
            {
                ret = Model_AMT_DISOBOX_PLUS(RawString);
                break;
            }

            default:
            {
                ret = Model_Raw(RawString);
                break;
            }
            }
            return(ret);
        }
예제 #2
0
        private static ReturnClass Model_Raw(string RawString)
        {
            ReturnClass ret = new ReturnClass();

            ret.GoodData   = true;
            ret.countClean = RawString.Length - 1;
            ret.rawData    = RawString;
            ret.weightS    = RawString;
            return(ret);
        }
예제 #3
0
        private static ReturnClass Model_SS_CGP_TBOX_PR1(string RawString)
        {
            ReturnClass ret = new ReturnClass();

            ret.GoodData = false;
            ret.rawData  = RawString;
            //S  2.030?N
            try
            {
                if (RawString.Length >= 28)
                {
                    //Стартоый символ  S
                    int StartIndex = RawString.IndexOf("S");
                    //Конечный символ 03
                    int EndIndex = RawString.IndexOf(Convert.ToChar(03), StartIndex);

                    if ((StartIndex != -1) && (EndIndex != -1))
                    {
                        string tmpW = RawString.Substring(StartIndex + 2, 6);
                        ret.weightS = tmpW.Replace(" ", "");
                        ret.weightS = tmpW.Replace("+", "");
                        //Стабильность
                        if (RawString.Substring(StartIndex + 10, 1) == "1")
                        {
                            ret.stabil = true;
                        }
                        else
                        {
                            ret.stabil = false;
                        }
                        ret.countClean = EndIndex + 1;
                        ret.GoodData   = true;
                    }
                }
            }

            catch (Exception)
            {
            }
            return(ret);
        }
예제 #4
0
        private static ReturnClass Model_SS_CGP_TCA_50(string RawString)
        {
            ReturnClass ret = new ReturnClass();

            ret.GoodData = false;
            ret.rawData  = RawString;
            //S  2.030?N
            try
            {
                if (RawString.Length > 10)
                {
                    int StartIndex = RawString.IndexOf("S");
                    int EndIndex   = RawString.IndexOf("N", StartIndex);
                    if ((StartIndex != -1) && (EndIndex != -1))
                    {
                        string tmpW = RawString.Substring(StartIndex + 1, 7);
                        ret.weightS = tmpW.Replace(" ", "");

                        //Стабильность
                        if (RawString.Substring(StartIndex + 8, 1) == " ")
                        {
                            ret.stabil = true;
                        }
                        else
                        {
                            ret.stabil = false;
                        }

                        ret.rezerv1 = RawString.Substring(StartIndex + 8, 1);

                        ret.countClean = EndIndex + 1;
                        ret.GoodData   = true;
                    }
                }
            }

            catch (Exception)
            {
            }
            return(ret);
        }
예제 #5
0
        private static ReturnClass Model_AMT_DISOBOX_PLUS(string RawString)
        {
            ReturnClass ret = new ReturnClass();

            ret.GoodData = false;
            ret.rawData  = RawString;

            if (RawString.Length >= 100)
            {
                String responseDataHex;
                String responseDataParse;
                String responseDataParseHex;
                Byte[] temp = System.Text.Encoding.UTF8.GetBytes(RawString);
                responseDataHex = BitConverter.ToString(temp);

                ///23-36-31-23- Началов веса
                int i_Begin_H = responseDataHex.IndexOf("23-36-31-23");
                int i_End_H   = -1; //Значение по умолчанию
                //int i_len_H = i_End_H - i_Begin_H;

                if (i_Begin_H == -1)
                {
                    ret.GoodData = false;
                }
                else
                {
                    i_End_H = responseDataHex.IndexOf("23", i_Begin_H + 10);
                }

                if (i_End_H == -1)
                {
                    ret.GoodData = false;
                }

                responseDataParseHex = responseDataHex.Substring(i_Begin_H, i_End_H - i_Begin_H);

                responseDataParseHex = responseDataParseHex.Replace("-", String.Empty);
                int i_Begin = 0;
                //int i_End = 0;

                i_Begin = i_Begin_H / 3;
                int i_len_H = responseDataParseHex.Length;

                responseDataParse = RawString.Substring(i_Begin + 4, i_len_H / 2 - 4);


                ///Определим стабильный вес, поиском последовательности

                /* if ((responseDataHex->IndexOf("01-56-61-00") > 0) || (responseDataHex->IndexOf("01-56-5F-00") > 0)){*/
                if (responseDataHex.IndexOf("00-6C-23") > 0)
                {
                    //Стабильный вес
                    ret.stabil = true;
                }
                else
                {
                    ret.stabil = false;
                }

                if (RawString.Length > 0)
                {
                    ret.countClean = 100;
                }
                else
                {
                    ret.countClean = 0;
                }

                ret.rawData = RawString;

                //Конвертнем вес во что то настоящее
                Double w = Double.Parse(responseDataParse.Replace('.', ','));
                w           = Math.Round(w, 1);
                ret.weightS = w.ToString().Replace(',', '.');


                ret.GoodData = true;
            }

            return(ret);
        }