Exemple #1
0
        public string[] GetValues(string[] parameterList, string fileName1)
        {
            FileStream reader = new FileStream(fileName1, FileMode.Open);
            int        i      = -1;

            string[] value = new string[parameterList.Length];
            for (int j = 0; j < parameterList.Length; j++)
            {
                string parameterName = parameterList[j];
                i++;
                //if (this.PPBodyDict.Keys.Contains(parameterName))
                if (this.PPBodyDict.ContainsKey(parameterName))
                {
                    PPBodyType pbd = this.PPBodyDict[parameterName];
                    reader.Seek((long)(pbd.BytePosition - 2), SeekOrigin.Begin);
                    switch (pbd.VariableType)
                    {
                    case 0:
                    {
                        byte[] readdata = new byte[pbd.Count];
                        reader.Read(readdata, 0, pbd.Count);
                        StringBuilder sb    = new StringBuilder();
                        byte[]        array = readdata;
                        for (int k = 0; k < array.Length; k++)
                        {
                            byte b = array[k];
                            sb.Append((char)b);
                        }
                        value[i] = sb.ToString();
                        break;
                    }

                    case 1:
                    {
                        byte[] readdata = new byte[pbd.Count * 2];
                        reader.Read(readdata, 0, pbd.Count * 2);
                        value[i] = string.Concat(BitConverter.ToInt16(readdata, 0));
                        break;
                    }

                    case 2:
                    {
                        byte[] readdata = new byte[pbd.Count * 2];
                        reader.Read(readdata, 0, pbd.Count * 2);
                        value[i] = string.Concat(BitConverter.ToInt32(readdata, 0));
                        break;
                    }

                    case 3:
                    {
                        byte[] readdata = new byte[pbd.Count];
                        reader.Read(readdata, 0, pbd.Count);
                        value[i] = string.Concat(BitConverter.ToSingle(readdata, 0));
                        break;
                    }

                    case 5:
                    {
                        byte[] readdata = new byte[8];
                        reader.Read(readdata, 0, 8);
                        value[i] = this.TDateTimeConvertToCSharpString(readdata);
                        break;
                    }
                    }
                }
                else
                {
                    value[i] = "__Nothing__";
                }
            }
            reader.Close();
            return(value);
        }
Exemple #2
0
        public void init(string recipeSetName)
        {
            StreamReader initFile  = new StreamReader(recipeSetName + ".set");
            StreamReader initFile2 = new StreamReader(recipeSetName + "_Name.txt");
            string       line      = initFile.ReadLine();
            string       line2     = initFile2.ReadLine();

            while (line != null)
            {
                string[] alist = line.Split(new char[]
                {
                    ',',
                    '='
                });
                string[] alist2 = line2.Split(new char[]
                {
                    '_'
                });
                if (alist2.Length > 1)
                {
                    PPBodyType pbd = new PPBodyType();
                    pbd.BytePosition = int.Parse(alist2[0]) * 2;
                    pbd.Name         = alist2[1].Trim();
                    if (alist[1].ToUpper().StartsWith("B"))
                    {
                        pbd.VariableType = 0;
                        pbd.Count        = int.Parse(alist[1].Substring(1)) / 2;
                    }
                    else if (alist[1].ToUpper().StartsWith("L"))
                    {
                        pbd.VariableType = 2;
                        pbd.Count        = int.Parse(alist[1].Substring(1)) * 2;
                    }
                    else if (alist[1].ToUpper().StartsWith("D"))
                    {
                        pbd.VariableType = 3;
                        pbd.Count        = int.Parse(alist[1].Substring(1));
                    }
                    else if (alist[1].ToUpper().StartsWith("T"))
                    {
                        pbd.VariableType = 5;
                        pbd.Count        = int.Parse(alist[1].Substring(1)) * 8;
                    }
                    else if (alist[1].ToUpper().StartsWith("I"))
                    {
                        pbd.VariableType = 1;
                        pbd.Count        = int.Parse(alist[1].Substring(1));
                    }
                    if (this.PPBodyDict.ContainsKey(pbd.Name))
                    {
                        this.PPBodyDict.Add(pbd.Name + alist[0], pbd);
                    }
                    else
                    {
                        this.PPBodyDict.Add(pbd.Name, pbd);
                    }
                }
                line  = initFile.ReadLine();
                line2 = initFile2.ReadLine();
            }
            initFile.Close();
            initFile2.Close();
        }