示例#1
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);
        }
示例#2
0
        //set temp  alarm warning
        public void settempaw(int deviceIndex, int deviceAddress, int regAddress, decimal tempaw)
        {
            byte[] buff = new byte[2];
            Int64  itest1;

            try
            {
                if ((Convert.ToInt64(tempaw) * 256) >= 0)
                {
                    itest1  = Convert.ToInt64(tempaw) * 256;
                    buff[0] = Convert.ToByte(itest1 / 256);
                    buff[1] = Convert.ToByte(itest1 % 256);
                }
                else
                {
                    itest1  = 65536 - Math.Abs(Convert.ToInt64(tempaw) * 256);
                    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;
            }
        }
示例#3
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);
        }
示例#4
0
 //write pn
 public void SetPn(int deviceIndex, int deviceAddress, int regAddress, string pn)
 {
     byte[] buff = new byte[16];
     try
     {
         buff = Encoding.Default.GetBytes(pn.Trim());
         USBIO.WrtieReg(deviceIndex, deviceAddress, regAddress, IOPort.SoftHard.HARDWARE_SEQUENT, buff);
         System.Threading.Thread.Sleep(1000);
     }
     catch (Exception error)
     {
         throw error;
     }
 }
示例#5
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;
     }
 }
示例#6
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);
 }
示例#7
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);
        }
示例#8
0
        //set bias alarm warning
        public void setbiasaw(int deviceIndex, int deviceAddress, int regAddress, decimal biasaw)
        {
            byte[] buff = new byte[2];
            Int64  itest1;

            try
            {
                itest1  = Convert.ToInt64(biasaw) * 500;
                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;
            }
        }
示例#9
0
 public override byte[] WrtieReg(int deviceAddress, int regAddress, byte[] dataToWrite)
 {
     return(USBIO.WrtieReg(deviceIndex, deviceAddress, regAddress, IOPort.SoftHard.HARDWARE_SEQUENT, dataToWrite));
 }