Exemple #1
0
        }//读取失败

        //读取一个字节存储单元的数据,长度29
        public static bool Readbyte(int Address, Enums.StorageType storageType, out int readValue, int plcAdd)
        {
            int  i = 0;
            byte fcs;

            if (!serialPort1.IsOpen)
            {
                serialPort1.Open();
            }
            Address = Address * 8;

            PPIAddress ppiAddress = new PPIAddress();

            ppiAddress.DAddress = Convert.ToByte(plcAdd);
            byte[] Rbyte = ppiAddress.Rbyte;

            Rbyte[22] = 0x02; //Byte 22 为读取数据的长度,01: 1 Bit 02: 1 Byte 04: 1 Word 06: Double Word
            Rbyte[24] = 0x01; //一次读取的个数

            if (storageType == Enums.StorageType.V)
            {
                Rbyte[26] = 0x01;
            }
            else
            {
                Rbyte[26] = 0x00;
            }
            Rbyte[27] = (byte)storageType;


            Rbyte[28] = Convert.ToByte(Address / 0x10000);
            Rbyte[29] = Convert.ToByte((Address / 0x100) & 0xff); //0x100 ->256;
            Rbyte[30] = Convert.ToByte(Address & 0xff);           //低位,如320H,结果为20;

            for (i = 4, fcs = 0; i < 31; i++)
            {
                fcs += Rbyte[i];
            }

            int tt = Convert.ToInt32(fcs) % 256;//添加的代码 mod 256

            Rbyte[31] = Convert.ToByte(tt);
            //  Rbyte[31] = fcs;

            byte[] Receives = ReceiveReadByte(serialPort1, Rbyte, ppiAddress);

            if (Receives != null)
            {
                receiveByte = ByteHelper.ByteToString(Receives);
                readValue   = (int)Receives[25];

                return(true);
            }

            else
            {
                readValue = 0;
                return(false);
            }
        }
Exemple #2
0
        public bool Writebyte(int ByteAddress, Enums.StorageType storageType, Enums.StorageTypeIsV isV, int WriteValue)
        {
            if (WriteValue > 255)
            {
                return(false);
            }//最大写入值255
            int  i, Rece = 0;
            byte fcs;

            //位写操作返回都是字符串为:68 12 12 68 00 02 08 32 03 00 00 00 00 00 02 00 01 00 00 05 01 FF 47 16
            byte[] ReceivesCheck = { 0x68, 0x12, 0x12, 0x68, 0x00, 0x02, 0x08, 0x32, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x05, 0x01, 0xFF, 0x47, 0x16 };

            if (!this.serialPort1.IsOpen)
            {
                this.serialPort1.Open();
            }

            ByteAddress    = ByteAddress * 8;
            this.Wbyte[22] = 0x02; //Byte 22 为读取数据的长度,01: 1 Bit 02: 1 Byte 04: 1 Word 06: Double Word
            this.Wbyte[24] = 0x01; // Byte 24 为数据个数:这里是 01,一次读一个数据

            this.Wbyte[26] = (byte)isV;
            this.Wbyte[27] = (byte)storageType;

            //偏移量,byte 28,29,30 存储器偏移量指针 (存储器地址 *8 ):
            //  如 VB100,存储器地址为 100,偏移量指针为 800,转换成 16
            //进制就是 320H,则 Byte 28~29 这三个字节就是: 00 03 20

            // buffer[11] = Convert.ToByte(address & 0xff);//地位,如320H,结果为20
            //buffer[10] = Convert.ToByte((address / 0x100) & 0xff);//0x100 ->256
            //buffer[9] = Convert.ToByte(address / 0x10000);
            this.Wbyte[28] = Convert.ToByte(ByteAddress / 0x10000);
            this.Wbyte[29] = Convert.ToByte((ByteAddress / 0x100) & 0xff); //0x100 ->256;
            this.Wbyte[30] = Convert.ToByte(ByteAddress & 0xff);           //低位,如320H,结果为20;

            this.Wbyte[32] = 0x04;
            this.Wbyte[34] = 0x08;


            this.Wbyte[35] = Convert.ToByte(WriteValue);
            for (i = 4, fcs = 0; i < 36; i++)
            {
                fcs += this.Wbyte[i];
            }

            int tt = Convert.ToInt32(fcs) % 256;//添加的代码 mod 256

            this.Wbyte[36] = Convert.ToByte(tt);

            //再次发送指令 10 02 00 5C 5E 16 意思:请执行命令,其中,SD为起始符,始终为10H;DA为读指令的目的地址;SA源地址;FCS校验和,等于DA+SA+FC的数据和;ED始终为16H
            //SD DA  SA FC  FCS  ED
            //10 02	 00	5C	5E	 16
            for (i = 1, fcs = 0; i < 4; i++)
            {
                fcs += this.Affirm[i];
            }
            tt             = Convert.ToInt32(fcs) % 256;//添加的代码 mod 256
            this.Affirm[4] = Convert.ToByte(tt);

            this.serialPort1.DiscardInBuffer();
            this.serialPort1.DiscardOutBuffer();

            this.serialPort1.Write(this.Wbyte, 0, this.Wbyte.Length);
            //while (this.serialPort1.BytesToRead == 0) {; }

            Thread.Sleep(100);

            Rece = this.serialPort1.ReadByte();
            if (Rece == 0xE5)
            {
                this.serialPort1.DiscardInBuffer();
                this.serialPort1.DiscardOutBuffer();

                this.serialPort1.Write(this.Affirm, 0, 6);
                TimeSpan ts1 = new TimeSpan(DateTime.Now.Ticks);//返回的数据比在串口助手少第一个数据 0x68

                PortTimeout(24, ts1, this.serialPort1);

                byte[] Receives = new byte[24];
                this.serialPort1.Read(Receives, 0, 24);

                int n = 0;
                for (int j = 0; j < 24; j++)
                {
                    if (Receives[j] != ReceivesCheck[j])
                    {
                        n++;
                    }
                }
                if (n == 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Exemple #3
0
        public static bool Readbits(int ByteAddress, int bitnumber, Enums.StorageType storageType, out byte[] bitValue, int plcAdd, int bitCount = 1)//测试失败
        {
            if (bitCount > 255 || bitCount == 0 || bitCount < 0)
            {
                bitValue = new byte[] { 0 };
                return(false);
            }

            int  i = 0;
            byte fcs;

            //byte[] Receives = new byte[27 + bitCount];

            //if (storageType == Enums.StorageType.T)
            //{
            //    Receives = new byte[31 + bitCount];
            //}

            if (!serialPort1.IsOpen)
            {
                serialPort1.Open();
            }

            PPIAddress ppiAddress = new PPIAddress();

            ppiAddress.DAddress = Convert.ToByte(plcAdd);
            ByteAddress         = ByteAddress * 8 + bitnumber;
            byte[] Rbyte = ppiAddress.Rbyte;
            Rbyte[22] = 0x01;//Byte 22 为读取数据的长度,01: 1 Bit 02: 1 Byte 04: 1 Word 06: Double Word
            if (storageType == Enums.StorageType.T)
            {
                Rbyte[22] = 0x1F;
            }

            Rbyte[24] = Convert.ToByte(bitCount);// Byte 24 为数据个数:这里是 01,一次读一个数据

            if (storageType == Enums.StorageType.V)
            {
                Rbyte[26] = 0x01;
            }
            else
            {
                Rbyte[26] = 0x00;
            }
            Rbyte[27] = (byte)storageType;

            Rbyte[28] = Convert.ToByte(ByteAddress / 0x10000);
            Rbyte[29] = Convert.ToByte((ByteAddress / 0x100) & 0xff); //0x100 ->256;
            Rbyte[30] = Convert.ToByte(ByteAddress & 0xff);           //低位,如320H,结果为20;
            for (i = 4, fcs = 0; i < 31; i++)
            {
                fcs += Rbyte[i];
            }

            int tt = Convert.ToInt32(fcs) % 256;//添加的代码 mod 256

            Rbyte[31] = Convert.ToByte(tt);


            byte[] Receives = ReceiveReadByte(serialPort1, Rbyte, ppiAddress);

            if (Receives != null)
            {
                receiveByte = ByteHelper.ByteToString(Receives);
                bitValue    = new byte[bitCount];
                for (int j = 0; j < bitCount; j++)
                {
                    bitValue[j] = Receives[24 + j];
                }

                return(true);
            }

            else
            {
                bitValue = new byte[] { 0 };
                return(false);
            }
        }//读取失败
Exemple #4
0
        public bool ReadDWord(int Address, Enums.StorageType storageType, Enums.StorageTypeIsV isV, out long WordValue)
        {
            int  i, Rece = 0;
            byte fcs;

            byte[] Receives = new byte[30];

            if (!this.serialPort1.IsOpen)
            {
                this.serialPort1.Open();
            }
            Address        = Address * 8;
            this.Rbyte[22] = 0x06; //Byte 22 为读取数据的长度,01: 1 Bit 02: 1 Byte 04: 1 Word 06: Double Word
            this.Rbyte[24] = 0x01; //一次读取的个数

            this.Rbyte[26] = (byte)isV;
            this.Rbyte[27] = (byte)storageType;

            this.Rbyte[28] = Convert.ToByte(Address / 0x10000);
            this.Rbyte[29] = Convert.ToByte((Address / 0x100) & 0xff); //0x100 ->256;
            this.Rbyte[30] = Convert.ToByte(Address & 0xff);           //低位,如320H,结果为20;
            //this.Rbyte[28] = this.fbyte3;
            //this.Rbyte[29] = this.fbyte2;
            //this.Rbyte[30] = this.fbyte1;
            for (i = 4, fcs = 0; i < 31; i++)
            {
                fcs += this.Rbyte[i];
            }
            int tt = Convert.ToInt32(fcs) % 256;//添加的代码 mod 256

            this.Rbyte[31] = Convert.ToByte(tt);

            for (i = 1, fcs = 0; i < 4; i++)
            {
                fcs += this.Affirm[i];
            }
            tt             = Convert.ToInt32(fcs) % 256;//添加的代码 mod 256
            this.Affirm[4] = Convert.ToByte(tt);
            // this.Affirm[4] = fcs;

            this.serialPort1.DiscardInBuffer();
            this.serialPort1.DiscardOutBuffer();

            this.serialPort1.Write(this.Rbyte, 0, Rbyte.Length);
            Thread.Sleep(200);
            Rece = this.serialPort1.ReadByte();
            if (Rece == 0xE5)
            {
                this.serialPort1.DiscardInBuffer();
                this.serialPort1.DiscardOutBuffer();

                this.serialPort1.Write(this.Affirm, 0, 6);
                //for (i = 0; i < 10000; i++)
                //    for (int j = 0; j < 1000; j++) ;
                //  while (this.serialPort1.BytesToRead < 29) {; }
                Thread.Sleep(200);

                TimeSpan ts1 = new TimeSpan(DateTime.Now.Ticks);
                while (this.serialPort1.BytesToRead < 30)//返回的数据比在串口助手少第一个数据 0x68
                {
                    System.Threading.Thread.Sleep(100);
                    TimeSpan ts2 = new TimeSpan(DateTime.Now.Ticks);
                    TimeSpan ts  = ts2.Subtract(ts1).Duration();
                    //如果接收时间超出设定时间,则直接退出
                    if (ts.TotalMilliseconds > 5000)
                    {
                        WordValue = 0;
                        return(false);
                    }
                }// 长度为30


                this.serialPort1.Read(Receives, 0, 30);
                long d1 = Convert.ToInt32(Receives[25]);//用long类型避免出现负数
                long c1 = d1 * 16777216;
                long c2 = Receives[26] * 0x10000;
                long c3 = Receives[27] * 256;
                long c4 = Receives[28];
                WordValue = c1 + c2 + c3 + c4;
                return(true);
            }
            this.serialPort1.Close();

            WordValue = 0;
            return(false);
        }
Exemple #5
0
        public bool ReadWords(int Address, int WordCount, Enums.StorageType storageType, Enums.StorageTypeIsV isV, out byte [] WordValue)
        {
            if (WordCount > 255 || WordCount == 0 || WordCount < 0)
            {
                WordValue = new byte[] { 0 };
                return(false);
            }
            int  i, Rece = 0;
            byte fcs;

            byte[] Receives = new byte[28 + WordCount * 2];

            if (!this.serialPort1.IsOpen)
            {
                this.serialPort1.Open();
            }
            Address        = Address * 8;
            this.Rbyte[22] = 0x04;                      //Byte 22 为读取数据的长度,01: 1 Bit 02: 1 Byte 04: 1 Word 06: Double Word
            this.Rbyte[24] = Convert.ToByte(WordCount); //一次读取的个数

            this.Rbyte[26] = (byte)isV;
            this.Rbyte[27] = (byte)storageType;

            this.Rbyte[28] = Convert.ToByte(Address / 0x10000);
            this.Rbyte[29] = Convert.ToByte((Address / 0x100) & 0xff); //0x100 ->256;
            this.Rbyte[30] = Convert.ToByte(Address & 0xff);           //低位,如320H,结果为20;
            //this.Rbyte[28] = this.fbyte3;
            //this.Rbyte[29] = this.fbyte2;
            //this.Rbyte[30] = this.fbyte1;
            for (i = 4, fcs = 0; i < 31; i++)
            {
                fcs += this.Rbyte[i];
            }
            int tt = Convert.ToInt32(fcs) % 256;//添加的代码 mod 256

            this.Rbyte[31] = Convert.ToByte(tt);

            for (i = 1, fcs = 0; i < 4; i++)
            {
                fcs += this.Affirm[i];
            }
            tt             = Convert.ToInt32(fcs) % 256;//添加的代码 mod 256
            this.Affirm[4] = Convert.ToByte(tt);
            // this.Affirm[4] = fcs;

            this.serialPort1.DiscardInBuffer();
            this.serialPort1.DiscardOutBuffer();

            this.serialPort1.Write(this.Rbyte, 0, Rbyte.Length);
            Thread.Sleep(200);
            Rece = this.serialPort1.ReadByte();
            if (Rece == 0xE5)
            {
                this.serialPort1.DiscardInBuffer();
                this.serialPort1.DiscardOutBuffer();

                this.serialPort1.Write(this.Affirm, 0, 6);
                //for (i = 0; i < 10000; i++)
                //    for (int j = 0; j < 1000; j++) ;
                //  while (this.serialPort1.BytesToRead < 29) {; }
                Thread.Sleep(200);

                TimeSpan ts1 = new TimeSpan(DateTime.Now.Ticks);
                while (this.serialPort1.BytesToRead < 27 + WordCount * 2)//返回的数据比在串口助手少第一个数据 0x68
                {
                    System.Threading.Thread.Sleep(100);
                    TimeSpan ts2 = new TimeSpan(DateTime.Now.Ticks);
                    TimeSpan ts  = ts2.Subtract(ts1).Duration();
                    //如果接收时间超出设定时间,则直接退出
                    if (ts.TotalMilliseconds > 5000)
                    {
                        WordValue = new byte[] { 0 };
                        return(false);
                    }
                }// 长度为30

                WordValue = new byte[WordCount * 2];
                this.serialPort1.Read(Receives, 0, 30);
                for (int j = 0; j < WordValue.Length; j++)
                {
                    WordValue[j] = Receives[25 + j];
                }


                //WordValue = (int)(Receives[25] * 256 + Receives[26]);
                return(true);
            }
            this.serialPort1.Close();

            WordValue = new byte[] { 0 };
            return(false);
        }
Exemple #6
0
        public bool Readbytes(int Address, int byteCount, Enums.StorageType storageType, Enums.StorageTypeIsV isV, out byte [] readValue)
        {
            if (byteCount > 222 || byteCount == 0 || byteCount < 0)
            {
                readValue = new byte[] { 0 };
                return(false);
            }
            int  i, Rece = 0;
            byte fcs;

            byte[] Receives = new byte[27 + byteCount];

            if (!this.serialPort1.IsOpen)
            {
                this.serialPort1.Open();
            }
            Address = Address * 8;

            this.Rbyte[22] = 0x02;                      //Byte 22 为读取数据的长度,01: 1 Bit 02: 1 Byte 04: 1 Word 06: Double Word
            this.Rbyte[24] = Convert.ToByte(byteCount); //一次读取的个数

            this.Rbyte[26] = (byte)isV;
            this.Rbyte[27] = (byte)storageType;

            // buffer[11] = Convert.ToByte(address & 0xff);//地位,如320H,结果为20
            //buffer[10] = Convert.ToByte((address / 0x100) & 0xff);//0x100 ->256
            //buffer[9] = Convert.ToByte(address / 0x10000);
            this.Rbyte[28] = Convert.ToByte(Address / 0x10000);
            this.Rbyte[29] = Convert.ToByte((Address / 0x100) & 0xff); //0x100 ->256;
            this.Rbyte[30] = Convert.ToByte(Address & 0xff);           //低位,如320H,结果为20;
            //this.Rbyte[28] = this.fbyte3;
            //this.Rbyte[29] = this.fbyte2;
            //this.Rbyte[30] = this.fbyte1;
            for (i = 4, fcs = 0; i < 31; i++)
            {
                fcs += this.Rbyte[i];
            }

            int tt = Convert.ToInt32(fcs) % 256;//添加的代码 mod 256

            this.Rbyte[31] = Convert.ToByte(tt);
            //  this.Rbyte[31] = fcs;

            for (i = 1, fcs = 0; i < 4; i++)
            {
                fcs += this.Affirm[i];
            }

            tt             = Convert.ToInt32(fcs) % 256;//添加的代码 mod 256
            this.Affirm[4] = Convert.ToByte(tt);
            // this.Affirm[4] = fcs;

            this.serialPort1.DiscardInBuffer();
            this.serialPort1.DiscardOutBuffer();

            this.serialPort1.Write(this.Rbyte, 0, Rbyte.Length);
            while (this.serialPort1.BytesToRead == 0)
            {
                ;
            }
            Rece = this.serialPort1.ReadByte();
            if (Rece == 0xE5)
            {
                this.serialPort1.DiscardInBuffer();
                this.serialPort1.DiscardOutBuffer();

                this.serialPort1.Write(this.Affirm, 0, 6);
                Thread.Sleep(100);
                TimeSpan ts1 = new TimeSpan(DateTime.Now.Ticks);
                while (this.serialPort1.BytesToRead < 27)//返回的数据比在串口助手少第一个数据 0x68
                {
                    System.Threading.Thread.Sleep(100);
                    TimeSpan ts2 = new TimeSpan(DateTime.Now.Ticks);
                    TimeSpan ts  = ts2.Subtract(ts1).Duration();
                    //如果接收时间超出设定时间,则直接退出
                    if (ts.TotalMilliseconds > 5000)
                    {
                        readValue = new byte[] { 0 };
                        return(false);
                    }
                }

                this.serialPort1.Read(Receives, 0, Receives.Length);
                this.serialPort1.Close();
                readValue = new byte[byteCount];
                for (int j = 0; j < byteCount; j++)
                {
                    readValue[j] = Receives[25 + j];
                }

                return(true);
            }
            else
            {
                readValue = new byte[] { 0 };
                return(false);
            }
        }//测试没有读到数据,还没有成功
Exemple #7
0
        public bool Readbits(int ByteAddress, int bitnumber, int bitCount, Enums.StorageType storageType, Enums.StorageTypeIsV isV, out int[] bitValue)
        {
            if (bitCount > 255 || bitCount == 0 || bitCount < 0)
            {
                bitValue = new int[] { 0 };
                return(false);
            }

            int  i, Rece = 0;
            byte fcs;

            byte[] Receives = new byte[27 + bitCount];

            if (!this.serialPort1.IsOpen)
            {
                this.serialPort1.Open();
            }

            ByteAddress    = ByteAddress * 8 + bitnumber;
            this.Rbyte[22] = 0x01;                     //Byte 22 为读取数据的长度,01: 1 Bit 02: 1 Byte 04: 1 Word 06: Double Word
            this.Rbyte[24] = Convert.ToByte(bitCount); // Byte 24 为数据个数:这里是 01,一次读一个数据

            this.Rbyte[26] = (byte)isV;
            this.Rbyte[27] = (byte)storageType;

            //偏移量,byte 28,29,30 存储器偏移量指针 (存储器地址 *8 ):
            //  如 VB100,存储器地址为 100,偏移量指针为 800,转换成 16
            //进制就是 320H,则 Byte 28~29 这三个字节就是: 00 03 20

            // buffer[11] = Convert.ToByte(address & 0xff);//地位,如320H,结果为20
            //buffer[10] = Convert.ToByte((address / 0x100) & 0xff);//0x100 ->256
            //buffer[9] = Convert.ToByte(address / 0x10000);
            this.Rbyte[28] = Convert.ToByte(ByteAddress / 0x10000);
            this.Rbyte[29] = Convert.ToByte((ByteAddress / 0x100) & 0xff); //0x100 ->256;
            this.Rbyte[30] = Convert.ToByte(ByteAddress & 0xff);           //低位,如320H,结果为20;
            for (i = 4, fcs = 0; i < 31; i++)
            {
                fcs += this.Rbyte[i];
            }

            int tt = Convert.ToInt32(fcs) % 256;//添加的代码 mod 256

            this.Rbyte[31] = Convert.ToByte(tt);

            //再次发送指令 10 02 00 5C 5E 16 意思:请执行命令,其中,SD为起始符,始终为10H;DA为读指令的目的地址;SA源地址;FCS校验和,等于DA+SA+FC的数据和;ED始终为16H
            //SD DA  SA FC  FCS  ED
            //10 02	 00	5C	5E	 16
            for (i = 1, fcs = 0; i < 4; i++)
            {
                fcs += this.Affirm[i];
            }
            tt             = Convert.ToInt32(fcs) % 256;//添加的代码 mod 256
            this.Affirm[4] = Convert.ToByte(tt);

            this.serialPort1.DiscardInBuffer();
            this.serialPort1.DiscardOutBuffer();

            this.serialPort1.Write(this.Rbyte, 0, Rbyte.Length);
            while (this.serialPort1.BytesToRead == 0)
            {
                ;
            }
            Rece = this.serialPort1.ReadByte();
            if (Rece == 0xE5)
            {
                this.serialPort1.DiscardInBuffer();
                this.serialPort1.DiscardOutBuffer();

                this.serialPort1.Write(this.Affirm, 0, 6);
                TimeSpan ts1 = new TimeSpan(DateTime.Now.Ticks);
                while (this.serialPort1.BytesToRead < Receives.Length - 1)//返回的数据比在串口助手少第一个数据 0x68
                {
                    System.Threading.Thread.Sleep(100);

                    TimeSpan ts2 = new TimeSpan(DateTime.Now.Ticks);
                    TimeSpan ts  = ts2.Subtract(ts1).Duration();
                    //如果接收时间超出设定时间,则直接退出
                    if (ts.TotalMilliseconds > 5000)
                    {
                        bitValue = new int[] { 0 };

                        return(false);
                    }
                }// 长度为27

                this.serialPort1.Read(Receives, 0, Receives.Length);

                bitValue = new int[bitCount];
                for (int j = 0; j < bitCount; j++)
                {
                    bitValue[j] = (int)Receives[24 + j];
                }

                return(true);
            }
            else
            {
                bitValue = new int[] { 0 };
                return(false);
            }
        }//读取失败
Exemple #8
0
        private void ComboBox()
        {
            try
            {
                if (comboBox1.SelectedIndex == 0)
                {
                    Selection1 = Enums.StorageType.Bit;
                }
                else if (comboBox1.SelectedIndex == 1)
                {
                    Selection1 = Enums.StorageType.Byte;
                }
                else if (comboBox1.SelectedIndex == 2)
                {
                    Selection1 = Enums.StorageType.KB;
                }
                else if (comboBox1.SelectedIndex == 3)
                {
                    Selection1 = Enums.StorageType.MB;
                }
                else if (comboBox1.SelectedIndex == 4)
                {
                    Selection1 = Enums.StorageType.GB;
                }
                else if (comboBox1.SelectedIndex == 5)
                {
                    Selection1 = Enums.StorageType.TB;
                }
                else if (comboBox1.SelectedIndex == 6)
                {
                    Selection1 = Enums.StorageType.PB;
                }
                else if (comboBox1.SelectedIndex == 7)
                {
                    Selection1 = Enums.StorageType.EB;
                }
                else if (comboBox1.SelectedIndex == 8)
                {
                    Selection1 = Enums.StorageType.ZB;
                }
                else if (comboBox1.SelectedIndex == 9)
                {
                    Selection1 = Enums.StorageType.YB;
                }

                if (comboBox2.SelectedIndex == 0)
                {
                    Selection2 = Enums.StorageType.Bit;
                }
                else if (comboBox2.SelectedIndex == 1)
                {
                    Selection2 = Enums.StorageType.Byte;
                }
                else if (comboBox2.SelectedIndex == 2)
                {
                    Selection2 = Enums.StorageType.KB;
                }
                else if (comboBox2.SelectedIndex == 3)
                {
                    Selection2 = Enums.StorageType.MB;
                }
                else if (comboBox2.SelectedIndex == 4)
                {
                    Selection2 = Enums.StorageType.GB;
                }
                else if (comboBox2.SelectedIndex == 5)
                {
                    Selection2 = Enums.StorageType.TB;
                }
                else if (comboBox2.SelectedIndex == 6)
                {
                    Selection2 = Enums.StorageType.PB;
                }
                else if (comboBox2.SelectedIndex == 7)
                {
                    Selection2 = Enums.StorageType.EB;
                }
                else if (comboBox2.SelectedIndex == 8)
                {
                    Selection2 = Enums.StorageType.ZB;
                }
                else if (comboBox2.SelectedIndex == 9)
                {
                    Selection2 = Enums.StorageType.YB;
                }

                if (comboBox3.SelectedIndex == 0)
                {
                    Selection3 = true;
                }
                else
                {
                    Selection3 = false;
                }

                if (comboBox4.SelectedIndex == 0)
                {
                    Selection4 = true;
                }
                else
                {
                    Selection4 = false;
                }

                if (comboBox5.SelectedIndex == 0)
                {
                    Selection5 = true;
                }
                else
                {
                    Selection5 = false;
                }

                if (comboBox6.SelectedIndex == 0)
                {
                    Selection6 = "C=>F";
                }
                else
                {
                    Selection6 = "F=>C";
                }

                if (comboBox7.SelectedIndex == 0)
                {
                    Selection7 = true;
                }
                else
                {
                    Selection7 = false;
                }

                if (comboBox8.SelectedIndex == 0)
                {
                    Selection8 = true;
                }
                else
                {
                    Selection8 = false;
                }

                if (comboBox9.SelectedIndex == 0)
                {
                    Selection9 = true;
                }
                else
                {
                    Selection9 = false;
                }

                if (comboBox10.SelectedIndex == 0)
                {
                    Selection10 = true;
                }
                else
                {
                    Selection10 = false;
                }

                if (comboBox11.SelectedIndex == 0)
                {
                    Selection11 = true;
                }
                else
                {
                    Selection11 = false;
                }

                if (comboBox12.SelectedIndex == 0)
                {
                    Selection12 = "Text=>Base64";
                }
                else if (comboBox12.SelectedIndex == 1)
                {
                    Selection12 = "Text=>MD5";
                }
                else if (comboBox12.SelectedIndex == 2)
                {
                    Selection12 = "Text=>SHA1";
                }
                else if (comboBox12.SelectedIndex == 3)
                {
                    Selection12 = "Text=>SHA256";
                }
                else if (comboBox12.SelectedIndex == 4)
                {
                    Selection12 = "Text=>SHA384";
                }
                else if (comboBox12.SelectedIndex == 5)
                {
                    Selection12 = "Text=>SHA512";
                }
                else if (comboBox12.SelectedIndex == 6)
                {
                    Selection12 = "Base64=>Text";
                }

                if (comboBox17.SelectedIndex == 0)
                {
                    Selection13 = "INCH";
                }
                else if (comboBox17.SelectedIndex == 1)
                {
                    Selection13 = "CM";
                }
                else
                {
                    Selection13 = "PX";
                }

                if (comboBox13.SelectedIndex == 0)
                {
                    Selection14 = "INCH";
                }
                else if (comboBox13.SelectedIndex == 1)
                {
                    Selection14 = "CM";
                }
                else
                {
                    Selection14 = "PX";
                }

                if (comboBox16.SelectedIndex == 0)
                {
                    Selection15 = true;
                }
                else
                {
                    Selection15 = false;
                }

                if (comboBox15.SelectedIndex == 0)
                {
                    Selection16 = true;
                }
                else
                {
                    Selection16 = false;
                }

                if (comboBox14.SelectedIndex == 0)
                {
                    Selection17 = "FILE=>MD5";
                }
                else if (comboBox14.SelectedIndex == 1)
                {
                    Selection17 = "FILE=>SHA1";
                }
                else if (comboBox14.SelectedIndex == 2)
                {
                    Selection17 = "FILE=>SHA256";
                }
                else if (comboBox14.SelectedIndex == 3)
                {
                    Selection17 = "FILE=>SHA384";
                }
                else if (comboBox14.SelectedIndex == 4)
                {
                    Selection17 = "FILE=>SHA512";
                }

                if (comboBox22.SelectedIndex == 0)
                {
                    Selection18 = Enums.TimeType.Nanosecond;
                }
                else if (comboBox22.SelectedIndex == 1)
                {
                    Selection18 = Enums.TimeType.Microsecond;
                }
                else if (comboBox22.SelectedIndex == 2)
                {
                    Selection18 = Enums.TimeType.Millisecond;
                }
                else if (comboBox22.SelectedIndex == 3)
                {
                    Selection18 = Enums.TimeType.Second;
                }
                else if (comboBox22.SelectedIndex == 4)
                {
                    Selection18 = Enums.TimeType.Minute;
                }
                else if (comboBox22.SelectedIndex == 5)
                {
                    Selection18 = Enums.TimeType.Hour;
                }
                else if (comboBox22.SelectedIndex == 6)
                {
                    Selection18 = Enums.TimeType.Day;
                }
                else if (comboBox22.SelectedIndex == 7)
                {
                    Selection18 = Enums.TimeType.Week;
                }
                else if (comboBox22.SelectedIndex == 8)
                {
                    Selection18 = Enums.TimeType.Year;
                }
                else if (comboBox22.SelectedIndex == 9)
                {
                    Selection18 = Enums.TimeType.Century;
                }
                else if (comboBox22.SelectedIndex == 10)
                {
                    Selection18 = Enums.TimeType.Millennium;
                }

                if (comboBox19.SelectedIndex == 0)
                {
                    Selection19 = Enums.TimeType.Nanosecond;
                }
                else if (comboBox19.SelectedIndex == 1)
                {
                    Selection19 = Enums.TimeType.Microsecond;
                }
                else if (comboBox19.SelectedIndex == 2)
                {
                    Selection19 = Enums.TimeType.Millisecond;
                }
                else if (comboBox19.SelectedIndex == 3)
                {
                    Selection19 = Enums.TimeType.Second;
                }
                else if (comboBox19.SelectedIndex == 4)
                {
                    Selection19 = Enums.TimeType.Minute;
                }
                else if (comboBox19.SelectedIndex == 5)
                {
                    Selection19 = Enums.TimeType.Hour;
                }
                else if (comboBox19.SelectedIndex == 6)
                {
                    Selection19 = Enums.TimeType.Day;
                }
                else if (comboBox19.SelectedIndex == 7)
                {
                    Selection19 = Enums.TimeType.Week;
                }
                else if (comboBox19.SelectedIndex == 8)
                {
                    Selection19 = Enums.TimeType.Year;
                }
                else if (comboBox19.SelectedIndex == 9)
                {
                    Selection19 = Enums.TimeType.Century;
                }
                else if (comboBox19.SelectedIndex == 10)
                {
                    Selection19 = Enums.TimeType.Millennium;
                }

                if (comboBox21.SelectedIndex == 0)
                {
                    Selection20 = true;
                }
                else
                {
                    Selection20 = false;
                }

                if (comboBox20.SelectedIndex == 0)
                {
                    Selection21 = true;
                }
                else
                {
                    Selection21 = false;
                }

                if (comboBox18.SelectedIndex == 0)
                {
                    Selection22 = true;
                }
                else
                {
                    Selection22 = false;
                }

                if (comboBox23.SelectedIndex == 0)
                {
                    Selection23 = true;
                }
                else
                {
                    Selection23 = false;
                }

                if (comboBox24.SelectedIndex == 0)
                {
                    Selection24 = true;
                }
                else
                {
                    Selection24 = false;
                }

                if (comboBox25.SelectedIndex == 0)
                {
                    Selection25 = true;
                }
                else
                {
                    Selection25 = false;
                }

                if (comboBox26.SelectedIndex == 0)
                {
                    Selection26 = "MPH => KPH";
                }
                else
                {
                    Selection26 = "KPH => MPH";
                }
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.Message);
            }
        }