Esempio n. 1
0
        public byte[] Encode(object o)
        {
            List <byte> data = new List <byte>();

            data.Add(0x02);
            data.Add(0x0E);
            data.Add(0x3D);

            float t  = (float)o;
            float v  = (t - 37.00f + 10) * 10;
            int   iv = (int)v;

            byte[] ivb = MachineControlProtocol.CheckSum(iv);
            data.Add((byte)ivb[0]);
            data.Add((byte)ivb[1]);

            data.Add(0x03);
            data.Add(0x00);
            data.Add(0x00);

            byte[] bytes = new byte[data.Count];
            for (int j = 0; j < data.Count; j++)
            {
                bytes[j] = data[j];
            }

            byte[] checksum = MachineControlProtocol.CheckSum(bytes);

            bytes[bytes.Count() - 2] = checksum[0];
            bytes[bytes.Count() - 1] = checksum[1];

            return(bytes);
        }
Esempio n. 2
0
        public string Parse(List <byte> data)
        {
            int disk = 0;

            switch (data[2])
            {
            case 0x30: disk = 1; break;

            case 0x31: disk = 2; break;
            }

            int p = MachineControlProtocol.HexConverToDec(data[3], data[4]);

            p = p > 45 ? p - 45 : p;
            string barcode = null;

            for (int i = 5; i < data.Count; i++)
            {
                if (data[i] == 0x03)
                {
                    break;
                }

                string v = string.Format("{0}", (char)data[i]);
                barcode += v;
            }

            return(disk + "|" + p + "|" + barcode);
        }
Esempio n. 3
0
        public string Parse(List <byte> Data)
        {
            CUVBLKService CUVBLKSer = new CUVBLKService();

            CUVBLKSer.BackupLastestToHistory();

            int i = 2;

            while (i < Data.Count - 3)
            {
                int cuvno = MachineControlProtocol.HexConverToDec(Data[i], Data[i + 1]);
                for (int j = i + 2, index = 0; j < i + 72; j = j + 6, index++)
                {
                    float blk = MachineControlProtocol.HexConverToFloat(Data[j], Data[j + 1], Data[j + 2], Data[j + 3], Data[j + 4], Data[j + 5]);
                    if (blk > -0.000001 && blk < 0.000001)
                    {
                        blk = 0.0000f;
                    }
                    else
                    {
                        blk = (float)Math.Log10(10 / blk) * MachineInfo.LightSpan;
                    }
                    CUVBLKSer.SaveLatestCuvBlkOfWaveAndCuvNO(MachineInfo.WaveLengthArray[index], cuvno, blk);
                }
                i += 74;
            }
            return("FinishUpdateCuvBlk");
        }
Esempio n. 4
0
        public string Parse(List <byte> data)
        {
            int          BlkNO = MachineControlProtocol.HexConverToDec(data[2], data[3], data[4]);
            int          index = 1;
            int          i     = 5;
            List <float> datas = new List <float>();

            while (index >= 120)
            {
                float PWL = MachineControlProtocol.HexConverToFloat(data[i], data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5]);

                datas.Add(PWL);

                i += 6;
            }

            string v = "";

            foreach (float e in datas)
            {
                v += e.ToString();
                v += "	";
            }

            //LogService.Log(BlkNO.ToString() + "	" + v, "CuvBlk.lg");

            return("");
        }
Esempio n. 5
0
        public byte[] Encode(object o)
        {
            AdjustNode AdjustNode = o as AdjustNode;

            if (AdjustNode == null || AdjustNode.NodeCode == null || AdjustNode.NodeCode.Count() != 2)
            {
                Console.WriteLine("试剂臂节点配置错误. ");
                return(null);
            }

            byte[] bytes = new byte[9];
            bytes[0] = 0x02;
            bytes[1] = 0x89;
            bytes[2] = AdjustNode.NodeCode[0];
            bytes[3] = AdjustNode.NodeCode[1];
            if (AdjustNode.OffsetCount > 0)
            {
                bytes[4] = 0x30;
            }
            else
            {
                bytes[4] = 0x31;
            }
            bytes[5] = (byte)(0x30 + Math.Abs(AdjustNode.OffsetCount));
            bytes[6] = 0x03;
            bytes[7] = 0x00;
            bytes[8] = 0x00;
            byte[] checksum = MachineControlProtocol.CheckSum(bytes);
            bytes[7] = checksum[0];
            bytes[8] = checksum[1];

            return(bytes);
        }
Esempio n. 6
0
        public string Parse(List <byte> data)
        {
            byte disk = data[2];

            for (int i = 3; i < data.Count - 3; i = i + 4)
            {
                int p = MachineControlProtocol.HexConverToDec(data[i], data[i + 1]);
                p = p > 90 ? (p - 90) : p;
                int v = MachineControlProtocol.HexConverToDec(data[i + 2], data[i + 3]);
                if (p != 0)
                {
                    switch (disk)
                    {
                    case 0x30: UpdateLatestRgtVol(1, p, v); break;

                    case 0x31: UpdateLatestRgtVol(2, p, v); break;
                    }
                }
            }
            for (int i = 0; i < data.Count; i++)
            {
                if (data[i] == 0x1C)
                {
                    TroubleLog trouble = new TroubleLog();
                    trouble.TroubleType = TROUBLETYPE.ERR;
                    trouble.TroubleUnit = "设备";
                    trouble.TroubleCode = string.Format("{0}{1}{2}{3}", (char)data[i + 1], (char)data[i + 2], (char)data[i + 3], (char)data[i + 4]);
                    trouble.TroubleInfo = null;
                    myBatis.TroubleLogSave("TroubleLogSave", trouble);
                }
            }
            return(null);
        }
Esempio n. 7
0
        public byte[] Encode(object o)
        {
            AdjustNode AdjustNode = o as AdjustNode;

            if (AdjustNode == null || AdjustNode.NodeCode == null)
            {
                return(null);
            }

            byte[] bytes = new byte[8];
            bytes[0] = 0x02;
            bytes[1] = 0x6E;
            bytes[2] = AdjustNode.NodeCode[0];
            if (AdjustNode.OffsetCount > 0)
            {
                bytes[3] = 0x30;
            }
            else
            {
                bytes[3] = 0x31;
            }
            bytes[4] = (byte)(0x30 + Math.Abs(AdjustNode.OffsetCount));
            bytes[5] = 0x03;
            bytes[6] = 0x00;
            bytes[7] = 0x00;
            byte[] checksum = MachineControlProtocol.CheckSum(bytes);
            bytes[6] = checksum[0];
            bytes[7] = checksum[1];

            return(bytes);
        }
Esempio n. 8
0
        public byte[] Encode(object o)
        {
            ManuOffsetGain ManuOffsetGain = myBatis.QueryManuOffsetGain("QueryManuOffsetGain");

            byte[] bytes = new byte[12];

            bytes[0] = 0x02;
            bytes[1] = 0x27;
            bytes[2] = (byte)('0' + ManuOffsetGain.WaveLength);
            int[] d = MachineControlProtocol.HDecConverToHex(ManuOffsetGain.OffSet);
            bytes[3]  = (byte)d[0];
            bytes[4]  = (byte)d[1];
            bytes[5]  = (byte)d[2];
            d         = MachineControlProtocol.HDecConverToHex(ManuOffsetGain.Gain);
            bytes[6]  = (byte)d[0];
            bytes[7]  = (byte)d[1];
            bytes[8]  = (byte)d[2];
            bytes[9]  = 0x03;
            bytes[10] = 0x00;
            bytes[11] = 0x00;
            byte[] checksum = MachineControlProtocol.CheckSum(bytes);
            bytes[10] = checksum[0];
            bytes[11] = checksum[1];

            return(bytes);
        }
Esempio n. 9
0
        public string Parse(List <byte> Data)
        {
            float v = MachineControlProtocol.HexConverToFloat(Data[9], Data[10], Data[11], Data[12], Data[13], Data[14]);

            myBatis.UpdateVoltageValue(v);

            return(null);
        }
Esempio n. 10
0
        byte[] NullScheduleEncode()
        {
            List <byte> BList = new List <byte>();

            BList.Add(0x02);
            BList.Add(0x07);
            BList.Add(0x30);
            BList.Add(0x30);
            BList.Add(0x30);
            BList.Add(0x30);
            BList.Add(0x30);
            BList.Add(0x30);
            BList.Add(0x30);
            BList.Add(0x30);
            BList.Add(0x30);
            BList.Add(0x30);
            BList.Add(0x30);
            BList.Add(0x30);
            BList.Add(0x30);
            BList.Add(0x30);
            BList.Add(0x30);
            BList.Add(0x30);
            BList.Add(0x30);
            BList.Add(0x30);
            BList.Add(0x30);
            BList.Add(0x30);
            BList.Add(0x30);
            BList.Add(0x30);
            BList.Add(0x30);
            BList.Add(0x30);
            BList.Add(0x30);
            BList.Add(0x30);
            BList.Add(0x30);
            BList.Add(0x30);
            BList.Add(0x30);
            BList.Add(0x30);
            BList.Add(0x03);
            BList.Add(0x00);
            BList.Add(0x00);

            byte[] bytes = new byte[BList.Count];
            for (int i = 0; i < BList.Count; i++)
            {
                bytes[i] = BList[i];
            }
            byte[] checksum = MachineControlProtocol.CheckSum(bytes);
            bytes[BList.Count - 2] = checksum[0];
            bytes[BList.Count - 1] = checksum[1];
            return(bytes);
        }
Esempio n. 11
0
        //解码 0x9 0x3c
        public string Parse(List <byte> data)
        {
            string code = null;

            for (int i = 3, j = 1; j <= 53; i += 5, j++)
            {
                int    v     = MachineControlProtocol.HexConverToDec(data[i], data[i + 1], data[i + 2], data[i + 3], data[i + 4]);
                string data1 = string.Format("{0},{1}|", j, v);
                code += data1;
            }
            code = code.TrimEnd('|');

            return(code);
        }
Esempio n. 12
0
        public string Parse(List <byte> data)
        {
            int n = MachineControlProtocol.HexConverToDec(data[2], data[3], data[4]);

            TroubleLog trouble = new TroubleLog();

            trouble.TroubleType = TROUBLETYPE.ERR;
            trouble.TroubleUnit = "比色杯";
            trouble.TroubleCode = string.Format("CUV001");
            trouble.TroubleInfo = n + "号比色杯有污垢,测试无法在此号比色杯中进行";
            myBatis.TroubleLogSave("TroubleLogSave", trouble);

            return(n + "号比色杯有污垢");
        }
Esempio n. 13
0
        public byte[] AvoidPolluteTable(byte c)
        {
            List <byte> lbytes = new List <byte>();

            lbytes.Add(0x02);
            lbytes.Add(c);

            List <ReagentNeedleAntifoulingStrategyInfo> CLItems = GetR1CrossContamination();

            switch (c)
            {
            case 0x21: CLItems = GetR1CrossContamination(); break;

            case 0x22: CLItems = GetR2CrossContamination(); break;
            }
            foreach (ReagentNeedleAntifoulingStrategyInfo e in CLItems)
            {
                int   px = myBatis.QueryRunSequenceByProject(e.PolluteProName, e.PolluteProType);
                int[] p  = MachineControlProtocol.DecConverToHex(px);
                lbytes.Add((byte)p[0]);
                lbytes.Add((byte)p[1]);

                int   nx = myBatis.QueryRunSequenceByProject(e.BePollutedProName, e.BePollutedProType);
                int[] n  = MachineControlProtocol.DecConverToHex(nx);
                lbytes.Add((byte)n[0]);
                lbytes.Add((byte)n[1]);
            }
            if (lbytes.Count < 82)
            {
                for (int i = 0; i < 82 - lbytes.Count; i++)
                {
                    lbytes.Add(0x30);
                }
            }
            lbytes.Add(0x03);
            lbytes.Add(0x00);
            lbytes.Add(0x00);

            byte[] ds = new byte[lbytes.Count];//85
            for (int i = 0; i < lbytes.Count; i++)
            {
                ds[i] = lbytes[i];
            }
            byte[] checksum = MachineControlProtocol.CheckSum(ds);
            ds[lbytes.Count - 2] = checksum[0];
            ds[lbytes.Count - 1] = checksum[1];

            return(ds);
        }
Esempio n. 14
0
        public string Parse(List <byte> data)
        {
            TroubleLogService TroubleLogSer = new TroubleLogService();

            int n = MachineControlProtocol.HexConverToDec(data[2], data[3]);

            TroubleLog trouble = new TroubleLog();

            trouble.TroubleType = TROUBLETYPE.ERR;
            trouble.TroubleUnit = MyResources.Instance.FindResource("Parse1101").ToString();
            trouble.TroubleCode = "CUV001";
            trouble.TroubleInfo = n + MyResources.Instance.FindResource("Parse1102").ToString();//string.Format("{0}号比色杯有污垢,测试无法在此号比色杯中进行. ", n); ;
            TroubleLogSer.Save(trouble);

            return(n + MyResources.Instance.FindResource("Parse1103").ToString());//string.Format("{0}号比色杯有污垢. ", n);
        }
Esempio n. 15
0
        public string Parse(List <byte> data)
        {
            int v = 0;
            int p = 0;

            for (int i = 3; i < data.Count - 3; i = i + 4)
            {
                p = MachineControlProtocol.HexConverToDec(data[i], data[i + 1]);
                v = MachineControlProtocol.HexConverToDec(data[i + 2], data[i + 3]);
            }
            if (v < 5)
            {
                return("DERR");
            }

            return(null);
        }
Esempio n. 16
0
        public string Parse(List <byte> data)
        {
            if (data.Count < (5 + 7))
            {
                return(null);
            }

            TroubleLog trouble = new TroubleLog();

            trouble.TroubleType = TROUBLETYPE.ERR;
            trouble.TroubleUnit = "设备";
            trouble.TroubleCode = string.Format("{0}{1}{2}{3}{4}{5}{6}", (char)data[2], (char)data[3], (char)data[4], (char)data[5], (char)data[6], (char)data[7], (char)data[8]);
            trouble.TroubleInfo = MachineControlProtocol.BytelistToHexString(data);;
            myBatis.TroubleLogSave("TroubleLogSave", trouble);

            return(trouble.TroubleCode);
        }
Esempio n. 17
0
        public byte[] Encode(object o)
        {
            List <byte> data = new List <byte>();

            data.Add(0x02);
            data.Add(0x09);
            data.Add(0x30);

            string key = new ActivityKeyService().GetActivityKey();

            if (string.IsNullOrEmpty(key) || string.IsNullOrWhiteSpace(key) || key.Length != 25)
            {
                for (int i = 1; i <= 32; i++)
                {
                    data.Add(0x30);
                }
            }
            else
            {
                foreach (char e in key)
                {
                    data.Add((byte)e);
                }
                for (int i = 1; i <= 7; i++)
                {
                    data.Add(0x30);
                }
            }

            data.Add(0x03);
            data.Add(0x00);
            data.Add(0x00);

            byte[] bytes = new byte[data.Count];
            for (int j = 0; j < data.Count; j++)
            {
                bytes[j] = data[j];
            }

            byte[] checksum = MachineControlProtocol.CheckSum(bytes);

            bytes[bytes.Count() - 2] = checksum[0];
            bytes[bytes.Count() - 1] = checksum[1];

            return(bytes);
        }
Esempio n. 18
0
        public byte[] Encode(object o)
        {
            List <byte> data = new List <byte>();

            data.Add(0x02);
            data.Add(0x09);
            data.Add(0x34);

            string key = o as string;

            if (key != null)
            {
                foreach (char e in key)
                {
                    data.Add((byte)e);
                }
                for (int i = 1; i <= 32 - key.Length; i++)
                {
                    data.Add(0x30);
                }
            }
            else
            {
                for (int i = 1; i <= 32; i++)
                {
                    data.Add(0x30);
                }
            }

            data.Add(0x03);
            data.Add(0x00);
            data.Add(0x00);

            byte[] bytes = new byte[data.Count];
            for (int j = 0; j < data.Count; j++)
            {
                bytes[j] = data[j];
            }

            byte[] checksum = MachineControlProtocol.CheckSum(bytes);

            bytes[bytes.Count() - 2] = checksum[0];
            bytes[bytes.Count() - 1] = checksum[1];

            return(bytes);
        }
Esempio n. 19
0
        public string Parse(List <byte> data)
        {
            myBatis.UpdateLatestWaterState("UpdateLatestWaterState", new byte[] { data[2], data[3] });
            ProcessWaterStateA(data[2], data[3]);

            int   t  = MachineControlProtocol.HexConverToDec(data[4], data[5], data[6]);
            float tf = t * 0.1f;

            myBatis.UpdateLatestCUVPanelTemperature("UpdateLatestCUVPanelTemperature", tf);

            string temstr = tf.ToString("#0.0");

            if (temstr == "0.0")
            {
                temstr = "21.0";
            }

            return(temstr);
        }
Esempio n. 20
0
        byte[] EncodeString(string str)
        {
            List <byte> data = new List <byte>();

            data.Add(0x02);
            data.Add(0x09);
            data.Add(0x3e);


            str = str.TrimEnd('|');
            string[] stres = str.Split('|');
            for (int i = 0; i < stres.Length; i++)
            {
                string   tstr   = stres[i];
                string[] tstres = tstr.Split(',');
                int      v      = int.Parse(tstres[1]);
                int[]    dd     = MachineControlProtocol.HDecConverToHex99999(v);
                for (int j = 0; j < dd.Length; j++)
                {
                    data.Add((byte)dd[j]);
                }
            }



            data.Add(0x03);
            data.Add(0x00);
            data.Add(0x00);

            byte[] bytes = new byte[data.Count];
            for (int j = 0; j < data.Count; j++)
            {
                bytes[j] = data[j];
            }

            byte[] checksum = MachineControlProtocol.CheckSum(bytes);

            bytes[bytes.Count() - 2] = checksum[0];
            bytes[bytes.Count() - 1] = checksum[1];

            return(bytes);
        }
Esempio n. 21
0
        public string Parse(List <byte> Data)
        {
            string snsrt = "";

            for (int i = 3; i < 3 + 8; i++)
            {
                snsrt += (char)Data[i];
            }
            string mstr = "";

            mstr += (char)Data[11];

            int n1 = MachineControlProtocol.HexConverToDec(Data[12], Data[13]);
            int n2 = MachineControlProtocol.HexConverToDec(Data[14], Data[15]);

            string str2 = "";

            str2 += (char)Data[16];

            return(snsrt + "|" + mstr + "|" + n1 + "|" + n2 + "|" + str2);
        }
Esempio n. 22
0
        public byte[] Encode(object o)
        {
            byte[] bytes = new byte[9];
            bytes[0] = 0x02;
            bytes[1] = 0xA2;

            string v = o as string;

            if (string.IsNullOrEmpty(v) || string.IsNullOrWhiteSpace(v))
            {
                bytes = null;
                return(null);
            }
            else
            {
                string[] vs = v.Split(' ');
                if (vs.Count() != 4)
                {
                    bytes = null;
                    return(null);
                }
                byte[] d = MachineControlProtocol.HexStringToByteArray(v, ' ');
                bytes[2] = d[0];
                bytes[3] = d[1];
                bytes[4] = d[2];
                bytes[5] = d[3];

                bytes[6] = 0x03;
                bytes[7] = 0x00;
                bytes[8] = 0x00;

                byte[] checksum = MachineControlProtocol.CheckSum(bytes);
                bytes[7] = checksum[0];
                bytes[8] = checksum[1];

                return(bytes);
            }
        }
Esempio n. 23
0
        public string Parse(List <byte> Data)
        {
            int i     = 2;
            int cuvno = MachineControlProtocol.HexConverToDec(Data[i], Data[i + 1], Data[i + 2]);

            if (cuvno == 1)
            {
                IsFisrt = true;
            }
            else
            {
                IsFisrt = false;
            }

            if (IsFisrt == true)
            {
                myBatis.BackupLastestToHistory();
                myBatis.ClearupCuvNewBlk();
            }

            for (int j = i + 3, index = 0; j < i + 72; j = j + 6, index++)
            {
                float blk = MachineControlProtocol.HexConverToFloat(Data[j], Data[j + 1], Data[j + 2], Data[j + 3], Data[j + 4], Data[j + 5]);
                if (blk > -0.000001 && blk < 0.000001)
                {
                    blk = 0.0000f;
                }
                else
                {
                    blk = (float)Math.Log10(10 / blk) * RunConfigureUtility.LightSpan;
                }
                myBatis.SaveLatestCuvBlkOfWaveAndCuvNO(System.Convert.ToInt32(RunConfigureUtility.WaveLengthList[index]), cuvno, blk);
            }

            return(cuvno.ToString());
        }
Esempio n. 24
0
        public byte[] Encode(object o)
        {
            //string strcpuID = ComputerInfo.CpuID;

            List <byte> data = new List <byte>();

            data.Add(0x02);
            data.Add(0x01);
            data.Add(0x22);

            try
            {
                string strcpuID = ComputerInfo.CpuID;
                for (int i = 0; i < strcpuID.Length; i++)
                {
                    data.Add(System.Convert.ToByte(strcpuID[i]));
                }
            }
            catch
            {
                data.Add(0x30);
            }

            data.Add(0x03);
            data.Add(0x00);
            data.Add(0x00);

            byte[] bytes = data.ToArray();

            byte[] checksum = MachineControlProtocol.CheckSum(bytes);

            bytes[bytes.Count() - 2] = checksum[0];
            bytes[bytes.Count() - 1] = checksum[1];

            return(bytes);
        }
Esempio n. 25
0
        public byte[] Encode(object o)
        {
            ISECalParaSet ISECalParaSet = o as ISECalParaSet;

            List <byte> byteList = new List <byte>();

            byteList.Add(0x02);
            byteList.Add(0xAB);
            switch (ISECalParaSet.SMPType)
            {
            case "S":
                byteList.Add(0x31);
                byteList.Add(0x31);
                break;

            case "U":
                byteList.Add(0x32);
                byteList.Add(0x32);
                break;
            }
            byteList.Add(0x34);

            //Na-----------------------------------------------------------------

            //G
            byte[] v = ConvertStringTo7Bits("1.4");
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //H
            switch (ISECalParaSet.SMPType)
            {
            case "S":
                v = ConvertStringTo7Bits("160.0");
                break;

            case "U":
                v = ConvertStringTo7Bits("200.0");
                break;
            }
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //I
            switch (ISECalParaSet.SMPType)
            {
            case "S":
                v = ConvertStringTo7Bits("130.0");
                break;

            case "U":
                v = ConvertStringTo7Bits("50.0");
                break;
            }
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //J
            v = ConvertFloatTo7Bits(ISECalParaSet.NaHSTDMaxValue);
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //K
            v = ConvertFloatTo7Bits(ISECalParaSet.NaLSTDMaxValue);
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //L
            v = ConvertFloatTo7Bits(ISECalParaSet.NaHSTDMinValue);
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //M
            v = ConvertFloatTo7Bits(ISECalParaSet.NaLSTDMinValue);
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //N
            v = ConvertStringTo7Bits("10.0");
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //O
            v = ConvertStringTo7Bits("38.0");
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //P
            v = ConvertStringTo7Bits("65.0");
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //Q
            v = ConvertStringTo7Bits("1.00");
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //R
            v = ConvertFloatTo7Bits(ISECalParaSet.NaHSTD);
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //T
            v = ConvertFloatTo7Bits(ISECalParaSet.NaLSTD);
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //预留位
            ////U
            //v = ConvertStringTo7Bits("0.0");
            //for (int i = 0; i < v.Count(); i++)
            //{
            //    byteList.Add(v[i]);
            //}
            ////V
            //v = ConvertStringTo7Bits("0.0");
            //for (int i = 0; i < v.Count(); i++)
            //{
            //    byteList.Add(v[i]);
            //}
            ////W
            //v = ConvertStringTo7Bits("0.0");
            //for (int i = 0; i < v.Count(); i++)
            //{
            //    byteList.Add(v[i]);
            //}
            ////X
            //v = ConvertStringTo7Bits("0.0");
            //for (int i = 0; i < v.Count(); i++)
            //{
            //    byteList.Add(v[i]);
            //}
            ////Y
            //v = ConvertStringTo7Bits("0.0");
            //for (int i = 0; i < v.Count(); i++)
            //{
            //    byteList.Add(v[i]);
            //}
            ////Z
            //v = ConvertStringTo7Bits("0.0");
            //for (int i = 0; i < v.Count(); i++)
            //{
            //    byteList.Add(v[i]);
            //}

            //K-------------------------------------------------------

            //G
            v = ConvertStringTo7Bits("1.3");
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //H
            switch (ISECalParaSet.SMPType)
            {
            case "S":
                v = ConvertStringTo7Bits("6.0");
                break;

            case "U":
                v = ConvertStringTo7Bits("100.0");
                break;
            }
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //I
            switch (ISECalParaSet.SMPType)
            {
            case "S":
                v = ConvertStringTo7Bits("3.5");
                break;

            case "U":
                v = ConvertStringTo7Bits("10.0");
                break;
            }
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //J
            v = ConvertFloatTo7Bits(ISECalParaSet.KHSTDMaxValue);
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //K
            v = ConvertFloatTo7Bits(ISECalParaSet.KLSTDMaxValue);
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //L
            v = ConvertFloatTo7Bits(ISECalParaSet.KHSTDMinValue);
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //M
            v = ConvertFloatTo7Bits(ISECalParaSet.KLSTDMinValue);
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //N
            v = ConvertStringTo7Bits("10.0");
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //O
            v = ConvertStringTo7Bits("38.0");
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //P
            v = ConvertStringTo7Bits("65.0");
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //Q
            v = ConvertStringTo7Bits("0.05");
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //R
            v = ConvertFloatTo7Bits(ISECalParaSet.KHSTD);
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //T
            v = ConvertFloatTo7Bits(ISECalParaSet.KLSTD);
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //预留位
            ////U
            //v = ConvertStringTo7Bits("0.0");
            //for (int i = 0; i < v.Count(); i++)
            //{
            //    byteList.Add(v[i]);
            //}
            ////V
            //v = ConvertStringTo7Bits("0.0");
            //for (int i = 0; i < v.Count(); i++)
            //{
            //    byteList.Add(v[i]);
            //}
            ////W
            //v = ConvertStringTo7Bits("0.0");
            //for (int i = 0; i < v.Count(); i++)
            //{
            //    byteList.Add(v[i]);
            //}
            ////X
            //v = ConvertStringTo7Bits("0.0");
            //for (int i = 0; i < v.Count(); i++)
            //{
            //    byteList.Add(v[i]);
            //}
            ////Y
            //v = ConvertStringTo7Bits("0.0");
            //for (int i = 0; i < v.Count(); i++)
            //{
            //    byteList.Add(v[i]);
            //}
            ////Z
            //v = ConvertStringTo7Bits("0.0");
            //for (int i = 0; i < v.Count(); i++)
            //{
            //    byteList.Add(v[i]);
            //}

            //CL------------------------------------------------------

            //G
            switch (ISECalParaSet.SMPType)
            {
            case "S":
                v = ConvertStringTo7Bits("0.0");
                break;

            case "U":
                v = ConvertStringTo7Bits("-0.1");
                break;
            }
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //H
            switch (ISECalParaSet.SMPType)
            {
            case "S":
                v = ConvertStringTo7Bits("120.0");
                break;

            case "U":
                v = ConvertStringTo7Bits("180.0");
                break;
            }
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //I
            switch (ISECalParaSet.SMPType)
            {
            case "S":
                v = ConvertStringTo7Bits("85.0");
                break;

            case "U":
                v = ConvertStringTo7Bits("50.0");
                break;
            }
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //J
            v = ConvertFloatTo7Bits(ISECalParaSet.ClHSTDMaxValue);
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //K
            v = ConvertFloatTo7Bits(ISECalParaSet.ClLSTDMaxValue);
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //L
            v = ConvertFloatTo7Bits(ISECalParaSet.ClHSTDMinValue);
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //M
            v = ConvertFloatTo7Bits(ISECalParaSet.ClLSTDMinValue);
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //N
            v = ConvertStringTo7Bits("5.0");
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //O
            v = ConvertStringTo7Bits("-65.0");
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //P
            v = ConvertStringTo7Bits("-38.0");
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //Q
            v = ConvertStringTo7Bits("1.00");
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //R
            v = ConvertFloatTo7Bits(ISECalParaSet.ClHSTD);
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //T
            v = ConvertFloatTo7Bits(ISECalParaSet.ClLSTD);
            for (int i = 0; i < v.Count(); i++)
            {
                byteList.Add(v[i]);
            }
            //预留位
            ////U
            //v = ConvertStringTo7Bits("0.0");
            //for (int i = 0; i < v.Count(); i++)
            //{
            //    byteList.Add(v[i]);
            //}
            ////V
            //v = ConvertStringTo7Bits("0.0");
            //for (int i = 0; i < v.Count(); i++)
            //{
            //    byteList.Add(v[i]);
            //}
            ////W
            //v = ConvertStringTo7Bits("0.0");
            //for (int i = 0; i < v.Count(); i++)
            //{
            //    byteList.Add(v[i]);
            //}
            ////X
            //v = ConvertStringTo7Bits("0.0");
            //for (int i = 0; i < v.Count(); i++)
            //{
            //    byteList.Add(v[i]);
            //}
            ////Y
            //v = ConvertStringTo7Bits("0.0");
            //for (int i = 0; i < v.Count(); i++)
            //{
            //    byteList.Add(v[i]);
            //}
            ////Z
            //v = ConvertStringTo7Bits("0.0");
            //for (int i = 0; i < v.Count(); i++)
            //{
            //    byteList.Add(v[i]);
            //}
            //----------------------------------------------------------------------------------------------
            byteList.Add(0x03);

            long sum = 0;

            byte[] Tbytes = new byte[byteList.Count + 2];
            for (int i = 0; i < byteList.Count; i++)
            {
                Tbytes[i] = byteList.ElementAt(i);
                sum      += (int)byteList.ElementAt(i);
            }
            byte[] Tchecksum = MachineControlProtocol.CheckSum(sum);

            Tbytes[Tbytes.Length - 2] = Tchecksum[0];
            Tbytes[Tbytes.Length - 1] = Tchecksum[1];

            return(Tbytes);
        }
Esempio n. 26
0
        public string Parse(List <byte> Data)
        {
            int i = 0;

            //温度
            for (int j = 0; j < Data.Count; j++)
            {
                if (Data[j] == 0x0E)
                {
                    i = j;
                    break;
                }
            }
            myBatis.UpdateLatestWaterState(Data[i + 1], Data[i + 2]);
            int inttemp = MachineControlProtocol.HexConverToDec(Data[i + 3], Data[i + 4], Data[i + 5]);

            myBatis.UpdateLatestCUVPanelTemperature(inttemp * 0.1f);
            //LogService.Log(string.Format("反应盘温度:{0};", tcv * 10), LogType.Debug);
            //试剂余量
            for (int j = 0; j < Data.Count; j++)
            {
                if (Data[j] == 0x2B)
                {
                    i = j;
                    break;
                }
            }
            int R1P = MachineControlProtocol.HexConverToDec(Data[i + 1], Data[i + 2]);
            int R1V = MachineControlProtocol.HexConverToDec(Data[i + 3], Data[i + 4]);

            UpdateLatestRgtVol(1, R1P, R1V);
            RgtWarning(1, R1P);
            int R2P = MachineControlProtocol.HexConverToDec(Data[i + 5], Data[i + 6]);
            int R2V = MachineControlProtocol.HexConverToDec(Data[i + 7], Data[i + 8]);

            UpdateLatestRgtVol(2, R2P, R2V);
            RgtWarning(2, R2P);
            //LogService.Log(string.Format("R1位置:{0} R1体积:{1} R2位置:{2} R2体积:{3}", R1P, R1V, R2P, R2V), LogType.Debug);
            //查找错误报头
            int erindex = -1;

            for (int j = 0; j < Data.Count(); j++)
            {
                if (Data[j] == 0x1C)
                {
                    erindex = j;
                    break;
                }
            }
            if (erindex > 0)//发生设备故障
            {
                int errcount = Data[erindex + 2] - 0x30;
                for (int j = 0; j < errcount; j++)
                {
                    int index = (erindex + 3) + j * 10;

                    int    erwn   = MachineControlProtocol.HexConverToDec(Data[index], Data[index + 1], Data[index + 2]);
                    string ercode = string.Format("{0}{1}{2}{3}{4}{5}{6}", (char)Data[index + 3], (char)Data[index + 4], (char)Data[index + 5], (char)Data[index + 6], (char)Data[index + 7], (char)Data[index + 8], (char)Data[index + 9]);
                    if (ercode == "E000415" || ercode == "E000615")
                    {
                    }
                    else
                    {
                        TroubleLog t = new TroubleLog();
                        t.TroubleCode = ercode;
                        t.TroubleType = TROUBLETYPE.ERR;
                        t.TroubleUnit = "设备";
                        t.TroubleInfo = null;
                        myBatis.TroubleLogSave("TroubleLogSave", t);
                    }

                    string cmdname = string.Format("{0}{1}", (char)Data[index + 3], (char)Data[index + 4]);
                    if (cmdname == "77" && Data[index + 5] == 0x30)//R1
                    {
                        TroubleLog trouble = new TroubleLog();
                        trouble.TroubleCode = @"0000770";
                        trouble.TroubleType = TROUBLETYPE.ERR;
                        trouble.TroubleUnit = "设备";
                        trouble.TroubleInfo = string.Format("试剂仓1清洗剂添加失败. ");
                        myBatis.TroubleLogSave("TroubleLogSave", trouble);
                    }
                    if (cmdname == "77" && Data[index + 5] == 0x31)//R2
                    {
                        TroubleLog trouble = new TroubleLog();
                        trouble.TroubleCode = @"0000771";
                        trouble.TroubleType = TROUBLETYPE.ERR;
                        trouble.TroubleUnit = "设备";
                        trouble.TroubleInfo = string.Format("试剂仓2清洗剂添加失败. ");
                        myBatis.TroubleLogSave("TroubleLogSave", trouble);
                    }
                    if (cmdname == "57" && Data[index + 5] == 0x30)//SMP
                    {
                        TroubleLog trouble = new TroubleLog();
                        trouble.TroubleCode = @"0000570";
                        trouble.TroubleType = TROUBLETYPE.ERR;
                        trouble.TroubleUnit = "设备";
                        trouble.TroubleInfo = string.Format("样本位清洗剂添加失败. ");
                        myBatis.TroubleLogSave("TroubleLogSave", trouble);
                    }
                }
            }

            return(null);
        }
Esempio n. 27
0
        public string Parse(List <byte> Data)
        {
            if (Data.Count < 904)
            {
                LogService.Log("非法数据包:" + MachineControlProtocol.BytelistToHexString(Data), LogType.Debug);
                return(null);
            }

            RunService             RunSer             = new RunService();
            RGTPOSManager          RGTPOSMgr          = new RGTPOSManager();
            TroubleLogService      TroubleLogSer      = new TroubleLogService();
            RealTimeCUVDataService RealTimeCUVDataSer = new RealTimeCUVDataService();

            int Pt1stWn  = 0;
            int Pt3ndWn  = 0;
            int Pt26thWn = 0;

            int BlkCUVNO = MachineControlProtocol.HexConverToDec(Data[904], Data[905], Data[906]);
            int BlkWN    = MachineControlProtocol.HexConverToDec(Data[2], Data[3], Data[4]);

            RealTimeCUVDataSer.SaveCuvNumber(BlkWN, BlkCUVNO);

            for (int i = 2; i < 886; i = i + 17)
            {
                int   WN  = MachineControlProtocol.HexConverToDec(Data[i], Data[i + 1], Data[i + 2]);
                int   PT  = MachineControlProtocol.HexConverToDec(Data[i + 3], Data[i + 4]);
                float PWL = MachineControlProtocol.HexConverToFloat(Data[i + 5], Data[i + 6], Data[i + 7], Data[i + 8], Data[i + 9], Data[i + 10]);
                float SWL = MachineControlProtocol.HexConverToFloat(Data[i + 11], Data[i + 12], Data[i + 13], Data[i + 14], Data[i + 15], Data[i + 16]);

                if (PWL > -0.000001 && PWL < 0.000001)
                {
                    PWL = 3.5f;
                }
                else
                {
                    PWL = (float)Math.Log10(10 / PWL) * MachineInfo.LightSpan;
                }
                if (SWL > -0.000001 && SWL < 0.000001)
                {
                    SWL = 3.5f;
                }
                else
                {
                    SWL = (float)Math.Log10(10 / SWL) * MachineInfo.LightSpan;
                }

                if (WN != 0 && PT != 0)
                {
                    RealTimeCUVDataService.SaveABS(WN, PT, PWL, SWL);
                }
                if (PT == 1)
                {
                    Pt1stWn = WN;
                }
                if (PT == 3)
                {
                    Pt3ndWn = WN;
                }
                if (PT == 26)
                {
                    Pt26thWn = WN;
                }

                //Console.WriteLine(string.Format("WN:{0}PT:{1}PWL:{2}SWL:{3}", WN, PT, PWL, SWL));
            }
            //温度
            float tcv = MachineControlProtocol.HexConverToFloat(Data[887], Data[888], Data[889], Data[890]);

            RunSer.UpdateLatestCUVPanelTemperature(tcv * 10);
            float tr1 = MachineControlProtocol.HexConverToFloat(Data[891], Data[892], Data[893], Data[894]);

            RunSer.UpdateLatestR1PanelTemperature(tr1 * 10);
            LogService.Log(string.Format("反应盘温度:{0};试剂盘温度 :{1}", tcv * 10, tr1 * 10), LogType.Debug);
            //试剂余量
            int R1P = MachineControlProtocol.HexConverToDec(Data[896], Data[897]);
            int R1V = MachineControlProtocol.HexConverToDec(Data[898], Data[899]);

            RGTPOSMgr.UpdateLatestRgtVol(1, R1P, R1V);
            RgtWarning(1, R1P);
            int R2P = MachineControlProtocol.HexConverToDec(Data[900], Data[901]);
            int R2V = MachineControlProtocol.HexConverToDec(Data[902], Data[903]);

            RGTPOSMgr.UpdateLatestRgtVol(1, R2P, R2V);
            RgtWarning(1, R2P);
            LogService.Log(string.Format("R1位置:{0} R1体积:{1} R2位置:{2} R2体积:{3}", R1P, R1V, R2P, R2V), LogType.Debug);
            //查找错误报头
            int erindex = 0;

            for (int i = 0; i < Data.Count(); i++)
            {
                if (Data[i] == 0x1C)
                {
                    erindex = i;
                    break;
                }
            }
            //错误信息
            if (Data[erindex] == 0x1C)
            {
                LogService.Log(MachineControlProtocol.BytelistToHexString(Data), LogType.Debug);

                int errcount = Data[erindex + 2] - 0x30;
                //Console.WriteLine(string.Format("there is {0} errors!", errcount));
                for (int i = 0; i < errcount; i++)
                {
                    int index = (erindex + 3) + i * 7;

                    string cmdname = string.Format("{0}{1}", (char)Data[index], (char)Data[index + 1]);
                    if (cmdname == "77" && Data[index + 2] == 0x30)//R1
                    {
                        RealTimeCUVDataService.RunningErrors(Pt1stWn, "R1");

                        Result r = new RealTimeCUVDataService().GetResultFromRealTimeWorkNum(Pt1stWn);
                        if (r != null)
                        {
                            TroubleLog trouble = new TroubleLog();
                            trouble.TroubleCode = @"0000770";
                            trouble.TroubleType = TROUBLETYPE.ERR;
                            trouble.TroubleUnit = @"设备";
                            trouble.TroubleInfo = string.Format("样本{0}项目{1}反应进程{2}:添加试剂1失败. ", r.SMPNO, r.ItemName, r.TCNO);
                            TroubleLogSer.Save(trouble);
                        }
                    }
                    if (cmdname == "77" && Data[index + 2] == 0x31)//R2
                    {
                        RealTimeCUVDataService.RunningErrors(Pt26thWn, "R2");

                        Result r = new RealTimeCUVDataService().GetResultFromRealTimeWorkNum(Pt26thWn);
                        if (r != null)
                        {
                            TroubleLog trouble = new TroubleLog();
                            trouble.TroubleCode = @"0000771";
                            trouble.TroubleType = TROUBLETYPE.ERR;
                            trouble.TroubleUnit = @"设备";
                            trouble.TroubleInfo = string.Format("样本{0}项目{1}反应进程{2}:添加试剂2失败. ", r.SMPNO, r.ItemName, r.TCNO);
                            TroubleLogSer.Save(trouble);
                        }
                    }
                    if (cmdname == "57" && Data[index + 2] == 0x30)//SMP
                    {
                        RealTimeCUVDataService.RunningErrors(Pt3ndWn, "SMP");

                        Result r = new RealTimeCUVDataService().GetResultFromRealTimeWorkNum(Pt3ndWn);
                        if (r != null)
                        {
                            TroubleLog trouble = new TroubleLog();
                            trouble.TroubleCode = @"0000570";
                            trouble.TroubleType = TROUBLETYPE.ERR;
                            trouble.TroubleUnit = @"设备";
                            trouble.TroubleInfo = string.Format("样本{0}项目{1}反应进程{2}:添加样本失败. ", r.SMPNO, r.ItemName, r.TCNO);
                            TroubleLogSer.Save(trouble);
                        }
                    }


                    TroubleLog t = new TroubleLog();
                    t.TroubleCode = string.Format("{0}{1}{2}{3}{4}{5}{6}", (char)Data[index], (char)Data[index + 1], (char)Data[index + 2], (char)Data[index + 3], (char)Data[index + 4], (char)Data[index + 5], (char)Data[index + 6]);
                    t.TroubleType = TROUBLETYPE.ERR;
                    t.TroubleUnit = @"设备";
                    t.TroubleInfo = null;
                    TroubleLogSer.Save(t);

                    LogService.Log("测试运行设备发生错误:" + t.TroubleCode, LogType.Debug);
                }
            }
            return(null);
        }
Esempio n. 28
0
        byte[] TaskEncode(TASK t, int wn)
        {
            List <byte> Listbyte = new List <byte>();

            if (t.V == 0)
            {
                Listbyte.Add(0x02);
                Listbyte.Add(0x07);
                Listbyte.Add(0x30);
                Listbyte.Add(0x30);
                Listbyte.Add(0x31);
                int[] bytes = MachineControlProtocol.HDecConverToHex(wn);
                Listbyte.Add((byte)bytes[0]);
                Listbyte.Add((byte)bytes[1]);
                Listbyte.Add((byte)bytes[2]);

                Listbyte.Add((byte)('0' + MachineInfo.GetWaveLengthIndex(t.PW)));
                Listbyte.Add((byte)('0' + MachineInfo.GetWaveLengthIndex(t.SW)));

                //急诊和常规都在样本位取样,急诊意思就是队列优先
                if (t.PT == 1)
                {
                    t.PT = 0;
                }
                Listbyte.Add((byte)('0' + t.PT));
                Listbyte.Add(0x31);
                bytes = MachineControlProtocol.DecConverToHex(int.Parse(t.SMPPOS.TrimStart('B', 'S', 'C', 'E')));
                Listbyte.Add((byte)bytes[0]);
                Listbyte.Add((byte)bytes[1]);

                bytes = MachineControlProtocol.HDecConverToHex(t.PV);
                Listbyte.Add((byte)bytes[0]);
                Listbyte.Add((byte)bytes[1]);
                Listbyte.Add((byte)bytes[2]);

                Listbyte.Add((byte)('0' + t.CT));

                bytes = MachineControlProtocol.DecConverToHex(t.R1POS);
                Listbyte.Add((byte)bytes[0]);
                Listbyte.Add((byte)bytes[1]);

                bytes = MachineControlProtocol.HDecConverToHex(t.R1VOL);
                Listbyte.Add((byte)bytes[0]);
                Listbyte.Add((byte)bytes[1]);
                Listbyte.Add((byte)bytes[2]);

                bytes = MachineControlProtocol.DecConverToHex(t.R2POS);
                Listbyte.Add((byte)bytes[0]);
                Listbyte.Add((byte)bytes[1]);

                bytes = MachineControlProtocol.HDecConverToHex(t.R2VOL);
                Listbyte.Add((byte)bytes[0]);
                Listbyte.Add((byte)bytes[1]);
                Listbyte.Add((byte)bytes[2]);

                Listbyte.Add(0x03);
            }
            else
            {
                Listbyte.Add(0x02);
                Listbyte.Add(0x07);
                Listbyte.Add(0x30);
                Listbyte.Add(0x30);
                Listbyte.Add(0x32);

                int[] bytes = MachineControlProtocol.HDecConverToHex(wn);
                Listbyte.Add((byte)bytes[0]);
                Listbyte.Add((byte)bytes[1]);
                Listbyte.Add((byte)bytes[2]);

                Listbyte.Add((byte)('0' + MachineInfo.GetWaveLengthIndex(t.PW)));
                Listbyte.Add((byte)('0' + MachineInfo.GetWaveLengthIndex(t.SW)));

                //急诊和常规都在样本位取样,急诊意思就是队列优先
                if (t.PT == 1)
                {
                    t.PT = 0;
                }
                Listbyte.Add((byte)('0' + t.PT));
                Listbyte.Add(0x31);
                bytes = MachineControlProtocol.DecConverToHex(int.Parse(t.SMPPOS.TrimStart('B', 'S', 'C', 'E')));
                Listbyte.Add((byte)bytes[0]);
                Listbyte.Add((byte)bytes[1]);

                bytes = MachineControlProtocol.HDecConverToHex(t.PV);
                Listbyte.Add((byte)bytes[0]);
                Listbyte.Add((byte)bytes[1]);
                Listbyte.Add((byte)bytes[2]);

                Listbyte.Add((byte)('0' + t.CT));

                bytes = MachineControlProtocol.DecConverToHex(t.DPOS);
                Listbyte.Add((byte)bytes[0]);
                Listbyte.Add((byte)bytes[1]);

                bytes = MachineControlProtocol.HDecConverToHex(t.DV);
                Listbyte.Add((byte)bytes[0]);
                Listbyte.Add((byte)bytes[1]);
                Listbyte.Add((byte)bytes[2]);
                bytes = MachineControlProtocol.DecConverToHex(t.R2POS);
                Listbyte.Add((byte)bytes[0]);
                Listbyte.Add((byte)bytes[1]);
                bytes = MachineControlProtocol.HDecConverToHex(t.R2VOL);
                Listbyte.Add((byte)bytes[0]);
                Listbyte.Add((byte)bytes[1]);
                Listbyte.Add((byte)bytes[2]);
                //---------------------------------------------------------------
                bytes = MachineControlProtocol.HDecConverToHex(wn);
                Listbyte.Add((byte)bytes[0]);
                Listbyte.Add((byte)bytes[1]);
                Listbyte.Add((byte)bytes[2]);

                Listbyte.Add((byte)('0' + MachineInfo.GetWaveLengthIndex(t.PW)));
                Listbyte.Add((byte)('0' + MachineInfo.GetWaveLengthIndex(t.SW)));

                Listbyte.Add(0x0A);
                Listbyte.Add(0x31);
                bytes = MachineControlProtocol.DecConverToHex(int.Parse(t.SMPPOS.TrimStart('B', 'S', 'C', 'E')));
                Listbyte.Add((byte)bytes[0]);
                Listbyte.Add((byte)bytes[1]);
                bytes = MachineControlProtocol.HDecConverToHex(t.V);
                Listbyte.Add((byte)bytes[0]);
                Listbyte.Add((byte)bytes[1]);
                Listbyte.Add((byte)bytes[2]);
                Listbyte.Add(0x01);
                bytes = MachineControlProtocol.DecConverToHex(t.R1POS);
                Listbyte.Add((byte)bytes[0]);
                Listbyte.Add((byte)bytes[1]);
                bytes = MachineControlProtocol.HDecConverToHex(t.R1VOL);
                Listbyte.Add((byte)bytes[0]);
                Listbyte.Add((byte)bytes[1]);
                Listbyte.Add((byte)bytes[2]);
                bytes = MachineControlProtocol.DecConverToHex(t.R2POS);
                Listbyte.Add((byte)bytes[0]);
                Listbyte.Add((byte)bytes[1]);
                bytes = MachineControlProtocol.HDecConverToHex(t.R2VOL);
                Listbyte.Add((byte)bytes[0]);
                Listbyte.Add((byte)bytes[1]);
                Listbyte.Add((byte)bytes[2]);
                Listbyte.Add(0x03);
            }
            long sum = 0;

            byte[] Tbytes = new byte[Listbyte.Count + 2];
            for (int i = 0; i < Listbyte.Count; i++)
            {
                Tbytes[i] = Listbyte.ElementAt(i);
                sum      += (int)Listbyte.ElementAt(i);
            }
            byte[] Tchecksum = MachineControlProtocol.CheckSum(sum);

            Tbytes[Tbytes.Length - 2] = Tchecksum[0];
            Tbytes[Tbytes.Length - 1] = Tchecksum[1];

            return(Tbytes);
        }
Esempio n. 29
0
        public byte[] Encode(object o)
        {
            List <byte> data = new List <byte>();

            data.Add(0x02);
            data.Add(0x09);
            data.Add(0x32);

            try
            {
                string   str       = o as string;
                string[] filedstrs = str.Split('|');
                foreach (char e in filedstrs[0])
                {
                    data.Add((byte)e);
                }
                data.Add((byte)filedstrs[1][0]);

                int   n1     = int.Parse(filedstrs[2]);
                int[] nbytes = MachineControlProtocol.DecConverToHex(n1);
                data.Add((byte)nbytes[0]);
                data.Add((byte)nbytes[1]);

                int n2 = int.Parse(filedstrs[3]);
                nbytes = MachineControlProtocol.DecConverToHex(n2);
                data.Add((byte)nbytes[0]);
                data.Add((byte)nbytes[1]);

                data.Add((byte)filedstrs[4][0]);

                for (int i = 15; i <= 32; i++)
                {
                    data.Add(0x30);
                }
            }
            catch
            {
                data.Clear();
                for (int i = 1; i <= 32; i++)
                {
                    data.Add(0x30);
                }
            }

            data.Add(0x03);
            data.Add(0x00);
            data.Add(0x00);

            byte[] bytes = new byte[data.Count];
            for (int j = 0; j < data.Count; j++)
            {
                bytes[j] = data[j];
            }

            byte[] checksum = MachineControlProtocol.CheckSum(bytes);

            bytes[bytes.Count() - 2] = checksum[0];
            bytes[bytes.Count() - 1] = checksum[1];

            return(bytes);
        }
Esempio n. 30
0
        public string Parse(List <byte> Data)
        {
            if (Data.Count < 904)
            {
                LogService.Log("非法数据包:" + MachineControlProtocol.BytelistToHexString(Data), LogType.Debug);
                return(null);
            }

            RunService        RunSer        = new RunService();
            RGTPOSManager     RGTPOSMgr     = new RGTPOSManager();
            TroubleLogService TroubleLogSer = new TroubleLogService();

            int Pt1stWn  = 0;
            int Pt3ndWn  = 0;
            int Pt14thWn = 0;

            int BlkCUVNO = MachineControlProtocol.HexConverToDec(Data[904], Data[905], Data[906]);
            int BlkWN    = MachineControlProtocol.HexConverToDec(Data[2], Data[3], Data[4]);

            for (int i = 2; i < 886; i = i + 17)
            {
                int WN = MachineControlProtocol.HexConverToDec(Data[i], Data[i + 1], Data[i + 2]);
                int PT = MachineControlProtocol.HexConverToDec(Data[i + 3], Data[i + 4]);


                if (PT == 1)
                {
                    Pt1stWn = WN;
                }
                if (PT == 3)
                {
                    Pt3ndWn = WN;
                }
                if (PT == 14)
                {
                    Pt14thWn = WN;
                }
            }
            //温度
            float tcv = MachineControlProtocol.HexConverToFloat(Data[887], Data[888], Data[889], Data[890]);

            RunSer.UpdateLatestCUVPanelTemperature(tcv * 10);
            float tr1 = MachineControlProtocol.HexConverToFloat(Data[891], Data[892], Data[893], Data[894]);

            RunSer.UpdateLatestR1PanelTemperature(tr1 * 10);
            LogService.Log(string.Format("反应盘温度:{0};试剂盘温度 :{1}", tcv * 10, tr1 * 10), LogType.Debug);
            //试剂余量
            int R1P = MachineControlProtocol.HexConverToDec(Data[896], Data[897]);
            int R1V = MachineControlProtocol.HexConverToDec(Data[898], Data[899]);

            RGTPOSMgr.UpdateLatestRgtVol(1, R1P, R1V);
            RgtWarning(1, R1P);
            int R2P = MachineControlProtocol.HexConverToDec(Data[900], Data[901]);
            int R2V = MachineControlProtocol.HexConverToDec(Data[902], Data[903]);

            RGTPOSMgr.UpdateLatestRgtVol(1, R2P, R2V);
            RgtWarning(1, R2P);
            LogService.Log(string.Format("R1位置:{0} R1体积:{1} R2位置:{2} R2体积:{3}", R1P, R1V, R2P, R2V), LogType.Debug);
            //查找错误报头
            int erindex = 0;

            for (int i = 0; i < Data.Count(); i++)
            {
                if (Data[i] == 0x1C)
                {
                    erindex = i;
                    break;
                }
            }
            //错误信息
            if (Data[erindex] == 0x1C)
            {
                LogService.Log(MachineControlProtocol.BytelistToHexString(Data), LogType.Debug);

                int errcount = Data[erindex + 2] - 0x30;
                //Console.WriteLine(string.Format("there is {0} errors!", errcount));
                for (int i = 0; i < errcount; i++)
                {
                    int index = (erindex + 3) + i * 7;

                    string cmdname = string.Format("{0}{1}", (char)Data[index], (char)Data[index + 1]);
                    if (cmdname == "77" && Data[index + 2] == 0x30)//R1
                    {
                        TroubleLog trouble = new TroubleLog();
                        trouble.TroubleCode = @"0000770";
                        trouble.TroubleType = TROUBLETYPE.ERR;
                        trouble.TroubleUnit = @"设备";
                        trouble.TroubleInfo = string.Format("试剂位清洗液添加失败. ");
                        TroubleLogSer.Save(trouble);
                    }
                    if (cmdname == "77" && Data[index + 2] == 0x31)//R2
                    {
                        TroubleLog trouble = new TroubleLog();
                        trouble.TroubleCode = @"0000771";
                        trouble.TroubleType = TROUBLETYPE.ERR;
                        trouble.TroubleUnit = @"设备";
                        trouble.TroubleInfo = string.Format("试剂位清洗液添加失败. ");
                        TroubleLogSer.Save(trouble);
                    }
                    if (cmdname == "57" && Data[index + 2] == 0x30)//SMP
                    {
                        TroubleLog trouble = new TroubleLog();
                        trouble.TroubleCode = @"0000570";
                        trouble.TroubleType = TROUBLETYPE.ERR;
                        trouble.TroubleUnit = @"设备";
                        trouble.TroubleInfo = string.Format("样本位清洗液添加失败. ");
                        TroubleLogSer.Save(trouble);
                    }


                    TroubleLog t = new TroubleLog();
                    t.TroubleCode = string.Format("{0}{1}{2}{3}{4}{5}{6}", (char)Data[index], (char)Data[index + 1], (char)Data[index + 2], (char)Data[index + 3], (char)Data[index + 4], (char)Data[index + 5], (char)Data[index + 6]);
                    t.TroubleType = TROUBLETYPE.ERR;
                    t.TroubleUnit = @"设备";
                    t.TroubleInfo = null;
                    TroubleLogSer.Save(t);

                    LogService.Log("测试运行设备发生错误:" + t.TroubleCode, LogType.Debug);
                }
            }
            return(null);
        }