public float setsetvalue(float setpoint)
        {
            sc1 = new serialCom(baudrate, parity, stopbit, length, name);
            sc1.OpenPort();
            //MessageBox.Show("Port Opened");
            int setpointint = (int)(setpoint * 10);

            byte[] setpointmsg = BitConverter.GetBytes(setpointint);
            string h           = setpointint + "";

            for (int i = 0; i < setpointmsg.Length; i++)
            {
                h += " " + setpointmsg[i];
            }
            //MessageBox.Show(h);
            ushort[]    mesg    = { 0x01, 0x06, 0x00, 0x01, setpointmsg[1], setpointmsg[0] };
            bool        success = sc1.portWrite(mesg);
            List <byte> reading = sc1.portRead();
            List <int>  offset  = sc1.gettheoffset();

            sc1.ClosePort();
            if (sc1.checkmsg())
            {
                string w = "";

                /*for (int m = 0; m < offset.Count(); m++)
                 * {
                 *  w += " " + offset[m];
                 * }*/
                int count = offset.Count() - 1;
                // w +="\n" +count + ". reading :\n";
                int k = offset.Sum() - offset[0];
                int l = reading.Count();
                MessageBox.Show("Starting= " + k + "  Finish=" + l);
                for (int i = k; i < l; i++)
                {
                    w += reading[i] + " ";
                }
                float result = (float)((reading[k + 4] * 0x100 + reading[k + 5]) / 10.0);
                w += "\n " + result + "\npart1 " + reading[k + 3] * 0x100 + "\npart2 " + reading[k + 4];
                w += "\n";
                MessageBox.Show("offset= " + w);

                return(result);
            }
            else
            {
                return(-1);
            }
        }
        public float getProcValue()
        {
            sc1 = new serialCom(baudrate, parity, stopbit, length, name);
            sc1.OpenPort();
            ushort[]    mesg    = { 0x01, 0x03, 0x00, 0x27, 0x00, 0x01 };
            bool        success = sc1.portWrite(mesg);
            List <byte> reading = sc1.portRead();
            List <int>  offset  = sc1.gettheoffset();

            sc1.ClosePort();
            //MessageBox.Show("check message is coming" + sc1.checkmsg());
            if (sc1.checkmsg())
            {
                //string w = "";

                /*for (int m = 0; m < offset.Count(); m++)
                 * {
                 *  w += " " + offset[m];
                 * }*/
                int count = offset.Count() - 1;
                // w +="\n" +count + ". reading :\n";
                int k = offset.Sum() - offset[0];
                int l = reading.Count();
                // MessageBox.Show("Starting= "+k+"  Finish="+l);

                /*for (int i = k; i < l; i++)
                 * {
                 *  w += reading[i] + " ";
                 * }*/
                float result = (float)((reading[k + 3] * 0x100 + reading[k + 4]) / 10.0);
                //float result = (float)((reading[k + 4] * 0x100 + reading[k + 5]) / 10.0);
                //w += "\n " + result + "\npart1 " + reading[k + 3] * 0x100 + "\npart2 " + reading[k + 4];
                // w += "\n";
                // MessageBox.Show("offset= " + w);

                return(result);
            }
            else
            {
                return(-1);
            }
        }