Example #1
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;
            }
        }
Example #2
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;
            }
        }
Example #3
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);
        }
Example #4
0
        public double readdmirxp(int deviceIndex, int deviceAddress, int regAddress)
        {
            byte[] buff = new byte[2];
            double rxp  = 0.0;

            try
            {
                buff = USBIO.ReadReg(deviceIndex, deviceAddress, regAddress, IOPort.SoftHard.HARDWARE_SEQUENT, 2);
                rxp  = 10 * (Math.Log10((buff[0] * 256 + buff[1]) * (1E-4)));

                rxp = Math.Round(rxp, 4);
                return(rxp);
            }
            catch (Exception error)
            {
                throw error;
            }
        }
Example #5
0
        //set rxp alarm warning
        public void setrxpaw(int deviceIndex, int deviceAddress, int regAddress, decimal rxpaw)
        {
            byte[] buff = new byte[2];
            Int64  itest1;

            try
            {
                itest1  = Convert.ToInt64(rxpaw) * 10;
                buff[0] = Convert.ToByte(itest1 / 256);
                buff[1] = Convert.ToByte(itest1 % 256);
                USBIO.WrtieReg(deviceIndex, deviceAddress, regAddress, IOPort.SoftHard.HARDWARE_SEQUENT, buff);
                System.Threading.Thread.Sleep(1000);
            }
            catch (Exception error)
            {
                throw error;
            }
        }
Example #6
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;
     }
 }
Example #7
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;
            }
        }
Example #8
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;
            }
        }
Example #9
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;
            }
        }
Example #10
0
 public override byte[] WrtieReg(int deviceAddress, int regAddress, byte[] dataToWrite)
 {
     return(USBIO.WrtieReg(deviceIndex, deviceAddress, regAddress, IOPort.SoftHard.HARDWARE_SEQUENT, dataToWrite));
 }
Example #11
0
 //read/writereg
 public override byte[] ReadReg(int deviceAddress, int regAddress, int readLength)
 {
     return(USBIO.ReadReg(deviceIndex, deviceAddress, regAddress, IOPort.SoftHard.HARDWARE_SEQUENT, readLength));
 }