Exemplo n.º 1
0
        public byte[] GetResultInByte()
        {
            byte[] packet = null;
            switch (typeCRC)
            {
            case TypeCRC.Cycled:

                packet = Application.TranslateToUnigueFormatTcpPacket(
                    "@%" + string.Format("{0:x2}", (int)numericUpDownDevNumber.Value) + "070200" +
                    string.Format("{0:x2}", (int)numericUpDownDataLen.Value) + "00$", TypeCRC.Cycled);
                break;

            case TypeCRC.CycledTwo:

                packet = Application.TranslateToUnigueFormatTcpPacket(
                    "@%" + string.Format("{0:x2}", (int)numericUpDownDevNumber.Value) + "070200" +
                    string.Format("{0:x2}", (int)numericUpDownDataLen.Value) + "00$", TypeCRC.CycledTwo);
                break;

            case TypeCRC.CRC16:

                packet = Application.TranslateToUnigueFormatTcpPacket(
                    "@%" + string.Format("{0:x2}", (int)numericUpDownDevNumber.Value) + "070200" +
                    string.Format("{0:x2}", (int)numericUpDownDataLen.Value) + "00$", TypeCRC.CRC16);
                break;

            default:

                packet = Application.TranslateToUnigueFormatTcpPacket(
                    "@%" + string.Format("{0:x2}", (int)numericUpDownDevNumber.Value) + "070200" +
                    string.Format("{0:x2}", (int)numericUpDownDataLen.Value) + "00$", TypeCRC.Cycled);
                break;
            }
            return(packet);
        }
Exemplo n.º 2
0
        public string GetResult()
        {
            byte[] packet = null;
            switch (typeCRC)
            {
            case TypeCRC.Cycled:

                packet = Application.TranslateToUnigueFormatTcpPacket(
                    "@%" + string.Format("{0:x2}", (int)numericUpDownDevNumber.Value) + "070200" +
                    string.Format("{0:x2}", (int)numericUpDownDataLen.Value) + "00$", TypeCRC.Cycled);
                break;

            case TypeCRC.CycledTwo:

                packet = Application.TranslateToUnigueFormatTcpPacket(
                    "@%" + string.Format("{0:x2}", (int)numericUpDownDevNumber.Value) + "070200" +
                    string.Format("{0:x2}", (int)numericUpDownDataLen.Value) + "00$", TypeCRC.CycledTwo);
                break;

            case TypeCRC.CRC16:

                packet = Application.TranslateToUnigueFormatTcpPacket(
                    "@%" + string.Format("{0:x2}", (int)numericUpDownDevNumber.Value) + "070200" +
                    string.Format("{0:x2}", (int)numericUpDownDataLen.Value) + "00$", TypeCRC.CRC16);
                break;

            default:

                packet = Application.TranslateToUnigueFormatTcpPacket(
                    "@%" + string.Format("{0:x2}", (int)numericUpDownDevNumber.Value) + "070200" +
                    string.Format("{0:x2}", (int)numericUpDownDataLen.Value) + "00$", TypeCRC.Cycled);
                break;
            }

            string total = string.Empty;

            foreach (byte item in packet)
            {
                total += string.Format("{0:x2}", item) + " ";
            }
            return(total);
        }