Beispiel #1
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);
        }
Beispiel #2
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);
        }
Beispiel #3
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);
        }
Beispiel #4
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);
        }
Beispiel #5
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);
        }
Beispiel #6
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);
        }
Beispiel #7
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);
        }
Beispiel #8
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);
        }
Beispiel #9
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);
        }
Beispiel #10
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);
            }
        }
Beispiel #11
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);
        }
Beispiel #12
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);
        }
Beispiel #13
0
        public byte[] Encode(object o)
        {
            string str = o as string;

            WashSettingData d = (WashSettingData)XmlUtilit.Deserialize(typeof(WashSettingData), str);

            if (d == null)
            {
                return(null);
            }

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

            Listbyte.Add(0x02);
            Listbyte.Add(0x90);

            Listbyte.Add((byte)('0' + d.ACount));
            Listbyte.Add((byte)('0' + d.BCount));

            Listbyte.Add((byte)('0' + 0));                                       //CC
            int[] bytes = MachineControlProtocol.DecConverToHex(d.ASMPPosition); //DD EE
            Listbyte.Add((byte)bytes[0]);
            Listbyte.Add((byte)bytes[1]);
            bytes = MachineControlProtocol.HDecConverToHex((int)d.ASMPVolume * 10);//FF GG II
            Listbyte.Add((byte)bytes[0]);
            Listbyte.Add((byte)bytes[1]);
            Listbyte.Add((byte)bytes[2]);
            int ct = (new SMPContainerTypeService().Get(d.SampleContainerType) as SMPContainerType).Code;//JJ

            Listbyte.Add((byte)('0' + ct));
            bytes = MachineControlProtocol.DecConverToHex(d.ARGTPosition1);//KK LL
            Listbyte.Add((byte)bytes[0]);
            Listbyte.Add((byte)bytes[1]);
            bytes = MachineControlProtocol.HDecConverToHex(d.ARGTVolume1);//MM NN OO
            Listbyte.Add((byte)bytes[0]);
            Listbyte.Add((byte)bytes[1]);
            Listbyte.Add((byte)bytes[2]);
            bytes = MachineControlProtocol.DecConverToHex(d.ARGTPosition2);//PP QQ
            Listbyte.Add((byte)bytes[0]);
            Listbyte.Add((byte)bytes[1]);
            bytes = MachineControlProtocol.HDecConverToHex(d.ARGTVolume2);//RR SS TT UU
            Listbyte.Add((byte)bytes[0]);
            Listbyte.Add((byte)bytes[1]);
            Listbyte.Add((byte)bytes[2]);

            Listbyte.Add((byte)('0' + 0));                                 //CC
            bytes = MachineControlProtocol.DecConverToHex(d.BSMPPosition); //DD EE
            Listbyte.Add((byte)bytes[0]);
            Listbyte.Add((byte)bytes[1]);
            bytes = MachineControlProtocol.HDecConverToHex((int)d.BSMPVolume * 10);//FF GG II
            Listbyte.Add((byte)bytes[0]);
            Listbyte.Add((byte)bytes[1]);
            Listbyte.Add((byte)bytes[2]);
            ct = (new SMPContainerTypeService().Get(d.SampleContainerType) as SMPContainerType).Code; //JJ
            Listbyte.Add((byte)('0' + ct));
            bytes = MachineControlProtocol.DecConverToHex(d.BRGTPosition1);                           //KK LL
            Listbyte.Add((byte)bytes[0]);
            Listbyte.Add((byte)bytes[1]);
            bytes = MachineControlProtocol.HDecConverToHex(d.BRGTVolume1);//MM NN OO
            Listbyte.Add((byte)bytes[0]);
            Listbyte.Add((byte)bytes[1]);
            Listbyte.Add((byte)bytes[2]);
            bytes = MachineControlProtocol.DecConverToHex(d.BRGTPosition2);//PP QQ
            Listbyte.Add((byte)bytes[0]);
            Listbyte.Add((byte)bytes[1]);
            bytes = MachineControlProtocol.HDecConverToHex(d.BRGTVolume2);//RR SS TT UU
            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);
        }
Beispiel #14
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);
        }
Beispiel #15
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);
        }
Beispiel #16
0
        public byte[] Encode(object o)
        {
            //定标品类型 血清 尿液
            string SMPType = o as string;

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

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

            case "U":
                byteList.Add(0x32);
                break;
            }
            //22.0
            //byteList.Add(0x32);
            //byteList.Add(0x32);
            //byteList.Add(0x2E);
            //byteList.Add(0x30);

            //byte[] v;
            //ISEItemSDTTable ISEItemSDTTable = null;
            //switch (SMPType)
            //{
            //    case "S":
            //        ISEItemSDTTable = new ISEItemSDTTableService().GetUsingISEItemSDTTable("S");
            //        break;
            //    case "U":
            //        ISEItemSDTTable = new ISEItemSDTTableService().GetUsingISEItemSDTTable("U");
            //        break;
            //}
            ////Na----------------------------------------------------------
            //if (ISEItemSDTTable != null)
            //{
            //    v = ConvertFloatTo9Bits(ISEItemSDTTable.NaHighSampleValue);
            //    for (int i = 0; i < v.Count(); i++)
            //    {
            //        byteList.Add(v[i]);
            //    }
            //    v = ConvertFloatTo9Bits(ISEItemSDTTable.NaHighSampleBase);
            //    for (int i = 0; i < v.Count(); i++)
            //    {
            //        byteList.Add(v[i]);
            //    }

            //    v = ConvertFloatTo9Bits(ISEItemSDTTable.NaLowSampleValue);
            //    for (int i = 0; i < v.Count(); i++)
            //    {
            //        byteList.Add(v[i]);
            //    }
            //    v = ConvertFloatTo9Bits(ISEItemSDTTable.NaLowSampleBase);
            //    for (int i = 0; i < v.Count(); i++)
            //    {
            //        byteList.Add(v[i]);
            //    }

            //    v = ConvertFloatTo9Bits(ISEItemSDTTable.NaSlope);
            //    for (int i = 0; i < v.Count(); i++)
            //    {
            //        byteList.Add(v[i]);
            //    }
            //    v = ConvertFloatTo9Bits(ISEItemSDTTable.NaDilRate);
            //    for (int i = 0; i < v.Count(); i++)
            //    {
            //        byteList.Add(v[i]);
            //    }
            //    //K----------------------------------------------------------------
            //    v = ConvertFloatTo9Bits(ISEItemSDTTable.KHighSampleValue);
            //    for (int i = 0; i < v.Count(); i++)
            //    {
            //        byteList.Add(v[i]);
            //    }
            //    v = ConvertFloatTo9Bits(ISEItemSDTTable.KHighSampleBase);
            //    for (int i = 0; i < v.Count(); i++)
            //    {
            //        byteList.Add(v[i]);
            //    }

            //    v = ConvertFloatTo9Bits(ISEItemSDTTable.KLowSampleValue);
            //    for (int i = 0; i < v.Count(); i++)
            //    {
            //        byteList.Add(v[i]);
            //    }
            //    v = ConvertFloatTo9Bits(ISEItemSDTTable.KLowSampleBase);
            //    for (int i = 0; i < v.Count(); i++)
            //    {
            //        byteList.Add(v[i]);
            //    }

            //    v = ConvertFloatTo9Bits(ISEItemSDTTable.KSlope);
            //    for (int i = 0; i < v.Count(); i++)
            //    {
            //        byteList.Add(v[i]);
            //    }
            //    v = ConvertFloatTo9Bits(ISEItemSDTTable.KDilRate);
            //    for (int i = 0; i < v.Count(); i++)
            //    {
            //        byteList.Add(v[i]);
            //    }
            //    //Cl----------------------------------------------------------------
            //    v = ConvertFloatTo9Bits(ISEItemSDTTable.ClHighSampleValue);
            //    for (int i = 0; i < v.Count(); i++)
            //    {
            //        byteList.Add(v[i]);
            //    }
            //    v = ConvertFloatTo9Bits(ISEItemSDTTable.ClHighSampleBase);
            //    for (int i = 0; i < v.Count(); i++)
            //    {
            //        byteList.Add(v[i]);
            //    }

            //    v = ConvertFloatTo9Bits(ISEItemSDTTable.ClLowSampleValue);
            //    for (int i = 0; i < v.Count(); i++)
            //    {
            //        byteList.Add(v[i]);
            //    }
            //    v = ConvertFloatTo9Bits(ISEItemSDTTable.ClLowSampleBase);
            //    for (int i = 0; i < v.Count(); i++)
            //    {
            //        byteList.Add(v[i]);
            //    }

            //    v = ConvertFloatTo9Bits(ISEItemSDTTable.ClSlope);
            //    for (int i = 0; i < v.Count(); i++)
            //    {
            //        byteList.Add(v[i]);
            //    }
            //    v = ConvertFloatTo9Bits(ISEItemSDTTable.ClDilRate);
            //    for (int i = 0; i < v.Count(); i++)
            //    {
            //        byteList.Add(v[i]);
            //    }
            //    //------------------------------------------------
            //    v = ConvertFloatTo9Bits(ISEItemSDTTable.HighThValue);
            //    for (int i = 0; i < v.Count(); i++)
            //    {
            //        byteList.Add(v[i]);
            //    }
            //    v = ConvertFloatTo9Bits(ISEItemSDTTable.HighThBase);
            //    for (int i = 0; i < v.Count(); i++)
            //    {
            //        byteList.Add(v[i]);
            //    }
            //    v = ConvertFloatTo9Bits(ISEItemSDTTable.LowThValue);
            //    for (int i = 0; i < v.Count(); i++)
            //    {
            //        byteList.Add(v[i]);
            //    }
            //    v = ConvertFloatTo9Bits(ISEItemSDTTable.LowThBase);
            //    for (int i = 0; i < v.Count(); i++)
            //    {
            //        byteList.Add(v[i]);
            //    }
            //}
            //else
            //{
            //    for (int c = 1; c <= 24; c++)
            //    {
            //        v = ConvertStringTo9Bits("0.000");
            //        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);
        }
Beispiel #17
0
        public byte[] Encode(object o)
        {
            List <byte> data = new List <byte>();

            data.Add(0x02);
            data.Add(0x45);

            string para = o as string;
            string d    = "";
            string p    = "";

            for (int i = 0; i < para.Length; i++)
            {
                if (para[i] != ':')
                {
                    d += para[i];
                }
                else
                {
                    p = para.Substring(i + 1, para.Length - (i + 1));
                    break;
                }
            }

            switch (int.Parse(d))
            {
            case 1:
                data.Add(0x30);
                break;

            case 2:
                data.Add(0x31);
                break;
            }

            string[] poses = p.Split('|');
            foreach (string i in poses)
            {
                try
                {
                    int[] dp = MachineControlProtocol.DecConverToHex(int.Parse(i));
                    data.Add((byte)dp[0]);
                    data.Add((byte)dp[1]);
                }
                catch
                {
                    continue;
                }
            }
            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);
        }
Beispiel #18
0
        public byte[] Encode(object o)
        {
            //定标品类型 血清 尿液
            ISEItemSDTTable ISEItemSDTTable = o as ISEItemSDTTable;

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

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

            case "U":
                byteList.Add(0x32);
                break;
            }
            //22.0
            //byteList.Add(0x32);
            //byteList.Add(0x32);
            //byteList.Add(0x2E);
            //byteList.Add(0x30);

            byte[] v;
            //Na----------------------------------------------------------
            if (ISEItemSDTTable != null)
            {
                v = ConvertFloatTo9Bits(ISEItemSDTTable.NaHighSampleValue);
                for (int i = 0; i < v.Count(); i++)
                {
                    byteList.Add(v[i]);
                }
                v = ConvertFloatTo9Bits(ISEItemSDTTable.NaHighSampleBase);
                for (int i = 0; i < v.Count(); i++)
                {
                    byteList.Add(v[i]);
                }

                v = ConvertFloatTo9Bits(ISEItemSDTTable.NaLowSampleValue);
                for (int i = 0; i < v.Count(); i++)
                {
                    byteList.Add(v[i]);
                }
                v = ConvertFloatTo9Bits(ISEItemSDTTable.NaLowSampleBase);
                for (int i = 0; i < v.Count(); i++)
                {
                    byteList.Add(v[i]);
                }

                v = ConvertFloatTo9Bits(ISEItemSDTTable.NaSlope);
                for (int i = 0; i < v.Count(); i++)
                {
                    byteList.Add(v[i]);
                }
                v = ConvertFloatTo9Bits(ISEItemSDTTable.NaDilRate);
                for (int i = 0; i < v.Count(); i++)
                {
                    byteList.Add(v[i]);
                }
                //K----------------------------------------------------------------
                v = ConvertFloatTo9Bits(ISEItemSDTTable.KHighSampleValue);
                for (int i = 0; i < v.Count(); i++)
                {
                    byteList.Add(v[i]);
                }
                v = ConvertFloatTo9Bits(ISEItemSDTTable.KHighSampleBase);
                for (int i = 0; i < v.Count(); i++)
                {
                    byteList.Add(v[i]);
                }

                v = ConvertFloatTo9Bits(ISEItemSDTTable.KLowSampleValue);
                for (int i = 0; i < v.Count(); i++)
                {
                    byteList.Add(v[i]);
                }
                v = ConvertFloatTo9Bits(ISEItemSDTTable.KLowSampleBase);
                for (int i = 0; i < v.Count(); i++)
                {
                    byteList.Add(v[i]);
                }

                v = ConvertFloatTo9Bits(ISEItemSDTTable.KSlope);
                for (int i = 0; i < v.Count(); i++)
                {
                    byteList.Add(v[i]);
                }
                v = ConvertFloatTo9Bits(ISEItemSDTTable.KDilRate);
                for (int i = 0; i < v.Count(); i++)
                {
                    byteList.Add(v[i]);
                }
                //Cl----------------------------------------------------------------
                v = ConvertFloatTo9Bits(ISEItemSDTTable.ClHighSampleValue);
                for (int i = 0; i < v.Count(); i++)
                {
                    byteList.Add(v[i]);
                }
                v = ConvertFloatTo9Bits(ISEItemSDTTable.ClHighSampleBase);
                for (int i = 0; i < v.Count(); i++)
                {
                    byteList.Add(v[i]);
                }

                v = ConvertFloatTo9Bits(ISEItemSDTTable.ClLowSampleValue);
                for (int i = 0; i < v.Count(); i++)
                {
                    byteList.Add(v[i]);
                }
                v = ConvertFloatTo9Bits(ISEItemSDTTable.ClLowSampleBase);
                for (int i = 0; i < v.Count(); i++)
                {
                    byteList.Add(v[i]);
                }

                v = ConvertFloatTo9Bits(ISEItemSDTTable.ClSlope);
                for (int i = 0; i < v.Count(); i++)
                {
                    byteList.Add(v[i]);
                }
                v = ConvertFloatTo9Bits(ISEItemSDTTable.ClDilRate);
                for (int i = 0; i < v.Count(); i++)
                {
                    byteList.Add(v[i]);
                }
                //电极温度参考------------------------------------------------
                v = ConvertFloatTo9Bits(ISEItemSDTTable.HighThValue);
                for (int i = 0; i < v.Count(); i++)
                {
                    byteList.Add(v[i]);
                }
                v = ConvertFloatTo9Bits(ISEItemSDTTable.HighThBase);
                for (int i = 0; i < v.Count(); i++)
                {
                    byteList.Add(v[i]);
                }
                v = ConvertFloatTo9Bits(ISEItemSDTTable.LowThValue);
                for (int i = 0; i < v.Count(); i++)
                {
                    byteList.Add(v[i]);
                }
                v = ConvertFloatTo9Bits(ISEItemSDTTable.LowThBase);
                for (int i = 0; i < v.Count(); i++)
                {
                    byteList.Add(v[i]);
                }
                //ClFact
                v = ConvertFloatTo9Bits(ISEItemSDTTable.ClFact);
                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);
        }
Beispiel #19
0
        byte[] TaskEncode(TASK t, int wn)
        {
            List <byte> Listbyte = new List <byte>();

            if (t.V == 0)
            {
                Listbyte.Add(0x02);
                Listbyte.Add(0x07);
                //普通测试包
                //if (t.ASSAYTYPE == "ISE")
                //{
                //    if (t.SMPTYPE == "U")
                //    {
                //        Listbyte.Add(0x31);
                //        Listbyte.Add(0x32);
                //        Listbyte.Add(0x31);
                //    }
                //    else
                //    {
                //        Listbyte.Add(0x31);
                //        Listbyte.Add(0x31);
                //        Listbyte.Add(0x31);
                //    }
                //}
                //else
                //{
                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' + GetWaveLengthIndex(t.PW)));
                Listbyte.Add((byte)('0' + GetWaveLengthIndex(t.SW)));

                bytes = MachineControlProtocol.DecConverToHex(t.PPNO);
                Listbyte.Add((byte)bytes[0]);
                Listbyte.Add((byte)bytes[1]);
                //急诊和常规都在样本位取样,急诊意思就是队列优先
                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));

                //int rgttype = new RunService().GetRgtPanelType();
                //if (rgttype == 2)
                //{
                //    t.R1POS += 45;
                //}
                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]);
                Listbyte.Add((byte)('0' + t.SF1));

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

                if (t.R2POS == 0)
                {
                    bytes = MachineControlProtocol.HDecConverToHex(0);
                    Listbyte.Add((byte)bytes[0]);
                    Listbyte.Add((byte)bytes[1]);
                    Listbyte.Add((byte)bytes[2]);
                    Listbyte.Add((byte)('0' + 0));
                }
                else
                {
                    bytes = MachineControlProtocol.HDecConverToHex(t.R2VOL);
                    Listbyte.Add((byte)bytes[0]);
                    Listbyte.Add((byte)bytes[1]);
                    Listbyte.Add((byte)bytes[2]);
                    Listbyte.Add((byte)('0' + t.SF2));
                }
                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' + GetWaveLengthIndex(t.PW)));
                Listbyte.Add((byte)('0' + GetWaveLengthIndex(t.SW)));

                bytes = MachineControlProtocol.DecConverToHex(t.PPNO);
                Listbyte.Add((byte)bytes[0]);
                Listbyte.Add((byte)bytes[1]);
                //急诊和常规都在样本位取样,急诊意思就是队列优先
                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]);
                Listbyte.Add((byte)('0' + t.SF1));
                bytes = MachineControlProtocol.DecConverToHex(0);
                Listbyte.Add((byte)bytes[0]);
                Listbyte.Add((byte)bytes[1]);
                bytes = MachineControlProtocol.HDecConverToHex(0);
                Listbyte.Add((byte)bytes[0]);
                Listbyte.Add((byte)bytes[1]);
                Listbyte.Add((byte)bytes[2]);
                Listbyte.Add((byte)('0' + t.SF2));
                //---------------------------------------------------------------
                bytes = MachineControlProtocol.HDecConverToHex(wn);
                Listbyte.Add((byte)bytes[0]);
                Listbyte.Add((byte)bytes[1]);
                Listbyte.Add((byte)bytes[2]);

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

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

                Listbyte.Add(0x3A);
                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(0x31);

                //int rgttype = new RunService().GetRgtPanelType();
                //if (rgttype == 2)
                //{
                //    t.R1POS += 45;
                //}
                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]);
                Listbyte.Add((byte)('0' + t.SF1));
                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((byte)('0' + t.SF2));
                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);
        }