Ejemplo n.º 1
0
        public bool u32tobyte(int deviceIndex, int deviceAddress, int regAddress, UInt32 coef)
        {
            bool flag = false;

            byte[] buff = new byte[2];
            buff[0] = (byte)((coef >> 24) & 0xff);
            buff[1] = (byte)((coef >> 16) & 0xff);
            buff[2] = (byte)((coef >> 8) & 0xff);
            buff[3] = (byte)(coef & 0xff);
            USBIO.WrtieReg(deviceIndex, deviceAddress, regAddress, IOPort.SoftHard.HARDWARE_SEQUENT, buff);
            System.Threading.Thread.Sleep(200);

            for (int i = 0; i < 4; i++)
            {
                byte[] rcoef = new byte[4];
                rcoef = USBIO.ReadReg(deviceIndex, deviceAddress, regAddress, IOPort.SoftHard.HARDWARE_SEQUENT, 4);
                if ((buff[0] != rcoef[0]) || (buff[1] != rcoef[1]) || (buff[2] != rcoef[2]) || (buff[3] != rcoef[3]))
                {
                    USBIO.WrtieReg(deviceIndex, deviceAddress, regAddress, IOPort.SoftHard.HARDWARE_SEQUENT, buff);
                    System.Threading.Thread.Sleep(200);
                }
                else
                {
                    flag = true;
                    break;
                }
            }
            return(flag);
        }
Ejemplo n.º 2
0
        //coef ieee754
        public bool floattoieee(int deviceIndex, int deviceAddress, int regAddress, float fcoef)
        {
            bool flag = false;

            byte[] bcoef = new byte[4];
            bcoef = BitConverter.GetBytes(fcoef);
            bcoef.Reverse();
            USBIO.WrtieReg(deviceIndex, deviceAddress, regAddress, IOPort.SoftHard.HARDWARE_SEQUENT, bcoef);
            System.Threading.Thread.Sleep(200);

            for (int i = 0; i < 4; i++)
            {
                byte[] rcoef = new byte[4];
                rcoef = USBIO.ReadReg(deviceIndex, deviceAddress, regAddress, IOPort.SoftHard.HARDWARE_SEQUENT, 4);
                if ((bcoef[0] != rcoef[0]) || (bcoef[1] != rcoef[1]) || (bcoef[2] != rcoef[2]) || (bcoef[3] != rcoef[3]))
                {
                    USBIO.WrtieReg(deviceIndex, deviceAddress, regAddress, IOPort.SoftHard.HARDWARE_SEQUENT, bcoef);
                    System.Threading.Thread.Sleep(200);
                }
                else
                {
                    flag = true;
                    break;
                }
            }
            return(flag);
        }
Ejemplo n.º 3
0
        public UInt32 bytetou32(int deviceIndex, int deviceAddress, int regAddress)
        {
            byte[] bcoef = new byte[4];
            bcoef = USBIO.ReadReg(deviceIndex, deviceAddress, regAddress, IOPort.SoftHard.HARDWARE_SEQUENT, 4);
            UInt32 U32coef = (UInt32)((bcoef[0] << 24) + (bcoef[1] << 16) + (bcoef[2] << 8) + bcoef[3]);

            System.Threading.Thread.Sleep(200);
            return(U32coef);
        }
Ejemplo n.º 4
0
        public UInt16 bytetou16(int deviceIndex, int deviceAddress, int regAddress)
        {
            byte[] bcoef = new byte[2];
            bcoef = USBIO.ReadReg(deviceIndex, deviceAddress, regAddress, IOPort.SoftHard.HARDWARE_SEQUENT, 2);
            System.Threading.Thread.Sleep(200);

            UInt16 U16coef = (UInt16)((bcoef[0] << 8) + bcoef[1]);

            return(U16coef);
        }
Ejemplo n.º 5
0
        public float ieeetofloat(int deviceIndex, int deviceAddress, int regAddress)
        {
            float fcoef;

            byte[] bcoef = new byte[4];
            bcoef = USBIO.ReadReg(deviceIndex, deviceAddress, regAddress, IOPort.SoftHard.HARDWARE_SEQUENT, 4);
            System.Threading.Thread.Sleep(200);
            bcoef.Reverse();
            fcoef = BitConverter.ToSingle(bcoef, 0);
            return(fcoef);
        }
Ejemplo n.º 6
0
 //set txdis soft
 public void SetSoftTxDis(int deviceIndex, int deviceAddress, int regAddress)
 {
     byte[] buff = new byte[1];
     try
     {
         buff    = USBIO.ReadReg(deviceIndex, deviceAddress, regAddress, IOPort.SoftHard.HARDWARE_SEQUENT, 1);
         buff[0] = (byte)(buff[0] | 0x40);
         USBIO.WrtieReg(deviceIndex, deviceAddress, regAddress, IOPort.SoftHard.HARDWARE_SEQUENT, buff);
         System.Threading.Thread.Sleep(1000);
     }
     catch (Exception error)
     {
         throw error;
     }
 }
Ejemplo n.º 7
0
 public byte[] ReadWriteDriver10g(int deviceIndex, int deviceAddress, int StartAddress, int regAddress, byte operation, byte[] buffer)
 {
     //operation 80 write ldd,40 read ldd,20 store ldd
     //08 store dac,04 read dac,02 write dac
     byte[] tempData = new byte[buffer.Length + 4];
     tempData[0] = buffer[0];
     tempData[1] = buffer[1];
     tempData[2] = (byte)regAddress;
     tempData[3] = (operation);
     buffer.CopyTo(tempData, 4);
     USBIO.WrtieReg(deviceIndex, deviceAddress, StartAddress, IOPort.SoftHard.HARDWARE_SEQUENT, tempData);
     byte[] arrRead = USBIO.ReadReg(deviceIndex, deviceAddress, StartAddress, IOPort.SoftHard.HARDWARE_SEQUENT, buffer.Length);
     System.Threading.Thread.Sleep(200);
     return(arrRead);
 }
Ejemplo n.º 8
0
        //read manufacture data
        //read fwrev
        public string ReadFWRev(int deviceIndex, int deviceAddress, int regAddress)
        {
            byte[] buff  = new byte[2];
            string fwrev = "ff";

            try
            {
                buff  = USBIO.ReadReg(deviceIndex, deviceAddress, regAddress, IOPort.SoftHard.HARDWARE_SEQUENT, 2);
                fwrev = Convert.ToString((buff[0] * 256 + buff[1]), 16);
                return(fwrev.Trim());
            }
            catch (Exception error)
            {
                throw error;
            }
        }
Ejemplo n.º 9
0
        //read pn
        public string ReadPn(int deviceIndex, int deviceAddress, int regAddress)
        {
            byte[] buff1 = new byte[16];
            byte[] buff  = new byte[5];
            string pn    = "ffffffff";

            try
            {
                buff1 = USBIO.ReadReg(deviceIndex, deviceAddress, regAddress, IOPort.SoftHard.HARDWARE_SEQUENT, 16);
                pn    = Convert.ToChar(Convert.ToInt64(buff1[0])).ToString() + Convert.ToChar(Convert.ToInt64(buff1[1])).ToString() + Convert.ToChar(Convert.ToInt64(buff1[2])).ToString() + Convert.ToChar(Convert.ToInt64(buff1[3])).ToString() + Convert.ToChar(Convert.ToInt64(buff1[4])).ToString() + Convert.ToChar(Convert.ToInt64(buff1[5])).ToString() + Convert.ToChar(Convert.ToInt64(buff1[6])).ToString() + Convert.ToChar(Convert.ToInt64(buff1[7])).ToString() + Convert.ToChar(Convert.ToInt64(buff1[8])).ToString() + Convert.ToChar(Convert.ToInt64(buff1[9])).ToString() + Convert.ToChar(Convert.ToInt64(buff1[10])).ToString() + Convert.ToChar(Convert.ToInt64(buff1[11])).ToString() + Convert.ToChar(Convert.ToInt64(buff1[12])).ToString() + Convert.ToChar(Convert.ToInt64(buff1[13])).ToString() + Convert.ToChar(Convert.ToInt64(buff1[14])).ToString() + Convert.ToChar(Convert.ToInt64(buff1[15])).ToString();
                return(pn.Trim());
            }
            catch (Exception error)
            {
                throw error;
            }
        }
Ejemplo n.º 10
0
        public double readdmitxp(int deviceIndex, int deviceAddress, int regAddress)
        {
            byte[] buff = new byte[2];
            double txp  = 0.0;

            try
            {
                buff = USBIO.ReadReg(deviceIndex, deviceAddress, regAddress, IOPort.SoftHard.HARDWARE_SEQUENT, 2);
                txp  = 10 * (Math.Log10((buff[0] * 256 + buff[1]) * (1E-4)));
                txp  = Math.Round(txp, 4);
                return(txp);
            }
            catch (Exception error)
            {
                throw error;
            }
        }
Ejemplo n.º 11
0
        public double readdmibias(int deviceIndex, int deviceAddress, int regAddress)
        {
            byte[] buff = new byte[2];
            double bias = 0.0;

            try
            {
                buff = USBIO.ReadReg(deviceIndex, deviceAddress, regAddress, IOPort.SoftHard.HARDWARE_SEQUENT, 2);
                bias = (buff[0] * 256 + buff[1]) / 500.0;
                bias = Math.Round(bias, 4);
                return(bias);
            }
            catch (Exception error)
            {
                throw error;
            }
        }
Ejemplo n.º 12
0
        //vcc alarm/waring
        public double readvccaw(int deviceIndex, int deviceAddress, int regAddress)
        {
            byte[] buff  = new byte[2];
            double vccaw = 0.0;

            try
            {
                buff  = USBIO.ReadReg(deviceIndex, deviceAddress, regAddress, IOPort.SoftHard.HARDWARE_SEQUENT, 2);
                vccaw = (buff[0] * 256 + buff[1]) * 0.0001;
                vccaw = Math.Round(vccaw, 4);
                return(vccaw);
            }
            catch (Exception error)
            {
                throw error;
            }
        }
Ejemplo n.º 13
0
        public byte[] ReadWriteDriver40g(int deviceIndex, int deviceAddress, int StartAddress, int regAddress, byte channel, byte operation, byte chipset, byte[] buffer, bool Switch)
        {
            //database 0: LDD 1: AMP 2: DAC 3: CDR

            ////chipset 1tx,2rx,4dac
            ////operation 1 READ,2 WRITE,4 store
            byte chipoperation;

            byte[] tempData = new byte[0];
            if (Switch == false)
            {
                tempData      = new byte[buffer.Length + 5];
                chipoperation = (byte)((chipset << 4) + operation);
                tempData[0]   = chipoperation;
                tempData[1]   = (byte)(channel - 1);
                tempData[2]   = (byte)((regAddress >> 8) & 0xff);
                tempData[3]   = (byte)(regAddress & 0xff);
                tempData[4]   = (byte)(buffer.Length);
                buffer.CopyTo(tempData, 5);
            }
            else if (Switch == true)
            {
                tempData      = new byte[buffer.Length + 4];
                chipoperation = (byte)((chipset << 4) + operation);
                tempData[0]   = chipoperation;
                tempData[1]   = (byte)(channel - 1);
                tempData[2]   = (byte)(regAddress & 0xff);
                tempData[3]   = (byte)(buffer.Length);
                buffer.CopyTo(tempData, 4);
            }
            USBIO.WrtieReg(deviceIndex, deviceAddress, StartAddress, IOPort.SoftHard.HARDWARE_SEQUENT, tempData);
            byte[] arrRead = new byte[buffer.Length];
            for (int i = 0; i < 10; i++)
            {
                System.Threading.Thread.Sleep(50);
                byte[] temp = USBIO.ReadReg(deviceIndex, deviceAddress, StartAddress, IOPort.SoftHard.HARDWARE_SEQUENT, 1);
                if (temp[0] == 0)
                {
                    arrRead = USBIO.ReadReg(deviceIndex, deviceAddress, StartAddress + 4, IOPort.SoftHard.HARDWARE_SEQUENT, buffer.Length);
                    break;
                }
            }
            System.Threading.Thread.Sleep(200);
            return(arrRead);
        }
Ejemplo n.º 14
0
 //rx los
 public bool ChkRxLos(int deviceIndex, int deviceAddress, int regAddress)
 {
     byte[] buff = new byte[1];
     try
     {
         buff = USBIO.ReadReg(deviceIndex, deviceAddress, regAddress, IOPort.SoftHard.HARDWARE_SEQUENT, 1);
         if ((buff[0] & 0x02) != 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception error)
     {
         throw error;
     }
 }
Ejemplo n.º 15
0
        //read DMI
        public double readdmitemp(int deviceIndex, int deviceAddress, int regAddress)
        {
            byte[] buff        = new byte[2];
            double temperature = 0.0;

            try
            {
                buff = USBIO.ReadReg(deviceIndex, deviceAddress, regAddress, IOPort.SoftHard.HARDWARE_SEQUENT, 2);
                if (buff[0] > Convert.ToByte(127))
                {
                    temperature = (buff[0] + (buff[1] / 256.0)) - 256;
                }
                else
                {
                    temperature = (buff[0] + (buff[1] / 256.0));
                }
                temperature = Math.Round(temperature, 4);
                return(temperature);
            }
            catch (Exception error)
            {
                throw error;
            }
        }
Ejemplo n.º 16
0
        //read a/w
        //temp  alarm/waring
        public double readtempaw(int deviceIndex, int deviceAddress, int regAddress)
        {
            byte[] buff   = new byte[2];
            double tempaw = 0.0;

            try
            {
                buff = USBIO.ReadReg(deviceIndex, deviceAddress, regAddress, IOPort.SoftHard.HARDWARE_SEQUENT, 2);
                if (buff[0] > Convert.ToByte(127))
                {
                    tempaw = ((buff[0] * 256 + buff[1]) - 65536) / 256.0;
                }
                else
                {
                    tempaw = (buff[0] * 256 + buff[1]) / 256.0;
                }
                tempaw = Math.Round(tempaw, 4);
                return(tempaw);
            }
            catch (Exception error)
            {
                throw error;
            }
        }
Ejemplo n.º 17
0
        //read adc
        public UInt16 readadc(int deviceIndex, int deviceAddress, int regAddress)
        {
            byte[] buff = new byte[2];
            UInt16 adc  = 0;

            try
            {
                for (int i = 0; i < 4; i++)
                {
                    buff = USBIO.ReadReg(deviceIndex, deviceAddress, regAddress, IOPort.SoftHard.HARDWARE_SEQUENT, 2);
                    if (buff[0] != 0)
                    {
                        break;
                    }
                }

                adc = (UInt16)((buff[0]) * 256 + buff[1]);
                return(adc);
            }
            catch (Exception error)
            {
                throw error;
            }
        }
Ejemplo n.º 18
0
 //read/writereg
 public override byte[] ReadReg(int deviceAddress, int regAddress, int readLength)
 {
     return(USBIO.ReadReg(deviceIndex, deviceAddress, regAddress, IOPort.SoftHard.HARDWARE_SEQUENT, readLength));
 }