Example #1
0
        public Qs2000State GetState(TFileData query)
        {
            string testsFile = GlobalConfigVars.DbPath + "\\" + "Tests.qsd";
            TestsFile test = ParseTestsFile(testsFile);

            string tfile = GlobalConfigVars.DbPath + "\\" + GetTFile(query.SeqNum);
            TFile tFile = ParseTFile(tfile);
            string dfile = GlobalConfigVars.DbPath + "\\" + GetDFile(query.SeqNum);
            DFile dFile = ParseDFile(dfile, tFile.Header.Identity.Name, tFile.Header.Identity.GelSize);
            // 查找配置
            TestProperties tp = test.Tests.Where(t => t.Identity.Equals(tFile.Header.Identity)).First();

            int idx = query.Id - 1;
            Qs2000State state = new Qs2000State
            {
                SeqNum = query.SeqNum.ToString(),
                SampleNum = query.Id.ToString(),
                SampleId = tFile.Datas[idx].Patient.Demographic[0],
                ScannedDate = tFile.Datas[idx].ScanDate.ToString("yyyy/MM/dd HH:mm:ss"),
                Scan = dFile.Scans[idx].DestBytes,
                TestType = tFile.Header.Identity.Name
            };
            if (!tp.bIFE)
            {
                StdScan scan = dFile.Scans[idx] as StdScan;
                state.Result = new Qs2000Result(scan.Data, scan.Fraction, tp.Fraction);
            }
            return state;
        }
Example #2
0
        public TFile ParseTFile(string file)
        {
            TFile result = new TFile();
            using (var fs = File.OpenRead(file))
            {
                using (var br = new BinaryReader(fs))
                {
                    result.Header = new TFileHeader();
                    // 读取Identity
                    var identity = new TestIdentity();
                    // identity.Name = ConvertToString(br.ReadBytes(21));
                    identity.Name = ConvertToGBString(br.ReadBytes(21)); 
                    identity.Instrument = ConvertToString(br.ReadBytes(11));
                    identity.GelSize = br.ReadInt16();
                    identity.StainType = br.ReadInt16();
                    result.Header.Identity = identity;

                    // skip
                    br.ReadBytes(220);

                    // 读取count数组
                    byte nullValue = 0xFF;
                    byte[] sampleSeqArray = br.ReadBytes(100);
                    result.Header.Count = sampleSeqArray.TakeWhile(i => i != nullValue).ToArray();
                    int sampleCount = result.Header.Count.Length;

                    // 读取数据
                    result.Datas = new List<TFileData>();
                    for (int i = 0; i < sampleCount; i++)
                    {
                        var data = new TFileData();
                        data.Patient = new PatientInfo();
                        for (int p = 0; p < 10; p++)
                        {
                            var demo = br.ReadBytes(21);
                            var demoType = br.ReadByte();
                            if (demoType == 0)
                            {
                                data.Patient.Demographic.Add(ConvertToGBString(demo));
                            }
                            if (demoType == 1)
                            {
                                data.Patient.Demographic.Add(ConvertToString(demo));
                            }
                        }
                        data.csStatus = ConvertToString(br.ReadBytes(21));
                        data.csDate = ConvertToString(br.ReadBytes(20));
                        data.Id = br.ReadByte();
                        data.Name = ConvertToGBString(br.ReadBytes(21));
                        data.Unknown = ConvertToString(br.ReadBytes(3));
                        result.Datas.Add(data);

                    }
                }
            }
            return result;
        }