Beispiel #1
0
        /* list box lstBxDevices */
        private void lstBxDevices_SelectedIndexChanged(object sender,
                                                       System.EventArgs e)
        {
            if (lstBxDevices.SelectedIndex < 0)
            {
                DisableMenu();
                btDevice.Enabled = false;
            }
            else
            {
                PCIE_Device dev =
                    pciDevList.Get(lstBxDevices.SelectedIndex);
                UpdateMenu(lstBxDevices.SelectedIndex);
                btDevice.Enabled = true;
                if (dev.Handle == IntPtr.Zero)
                {
                    btDevice.Text = "Open Device";
                }
                else
                {
                    btDevice.Text = "Close Device";
                }

                menuRTRegs.Visible = (dev.Regs.gPCIE_RT_Regs.Length > 0)?
                                     true : false;
            }
        }
Beispiel #2
0
        /* Configuration Space Items*/
        private void menuCfgOffset_Click(object sender, System.EventArgs e)
        {
            PCIE_Device dev =
                pciDevList.Get(lstBxDevices.SelectedIndex);
            CfgTransfersForm cfgOffsetFrom = new CfgTransfersForm(dev);

            cfgOffsetFrom.GetInput();
        }
Beispiel #3
0
        /*RunTime Registers Items*/
        private void menuRTRegsRW_Click(object sender, System.EventArgs e)
        {
            PCIE_Device dev =
                pciDevList.Get(lstBxDevices.SelectedIndex);
            RegistersForm regForm = new RegistersForm(dev, ACTION_TYPE.RT);

            regForm.GetInput();
        }
Beispiel #4
0
        /* Address Space Item */
        private void menuAddrRW_Click(object sender, System.EventArgs e)
        {
            PCIE_Device dev =
                pciDevList.Get(lstBxDevices.SelectedIndex);

            string[] sBars = dev.AddrDescToString(false);
            AddrSpaceTransferForm addrSpcFrm = new
                                               AddrSpaceTransferForm(dev, sBars);

            addrSpcFrm.GetInput();
        }
Beispiel #5
0
        /* Event Items*/
        private void menuEvents_Select(object sender, System.EventArgs e)
        {
            if (menuEvents.Enabled == false)
            {
                return;
            }
            PCIE_Device dev = pciDevList.Get(lstBxDevices.SelectedIndex);

            menuRegisterEvent.Text = dev.IsEventRegistered() ?
                                     "Unregister Events" : "Register Events";
        }
Beispiel #6
0
        /* Interrupts items*/

        private void menuInterrupts_Select(object sender,
                                           System.EventArgs e)
        {
            if (menuInterrupts.Enabled == false)
            {
                return;
            }
            PCIE_Device dev    = pciDevList.Get(lstBxDevices.SelectedIndex);
            bool        bIsEnb = dev.IsEnabledInt();

            menuEnableInt.Text = bIsEnb? "Disable Interrupts":
                                 "Enable Interrupts";
        }
Beispiel #7
0
        /* Menu*/
        private void UpdateMenu(int index)
        {
            PCIE_Device dev =
                pciDevList.Get(lstBxDevices.SelectedIndex);

            if (dev.Handle == IntPtr.Zero)
            {
                DisableMenu();
            }
            else
            {
                EnableMenu();
            }
        }
Beispiel #8
0
        /* Close handle to a NEWAMD86 device */
        public bool DeviceClose(int iSelectedIndex)
        {
            readSize = 0;
            //pBoard->pci_e.WriteBAR0(0, 0x10, regval);
            LogHelper.WriteLog(string.Format("断开第{0}张板卡", iSelectedIndex + 1));
            var         devices = PCIE_DeviceList.TheDeviceList();
            PCIE_Device device  = PCIE_DeviceList.TheDeviceList().Get(iSelectedIndex);
            bool        bStatus = false;

            try
            {
                Clients.Client(Context.ConnectionId).NoticeMessage("正在停止数据读取...\n");
                CloseDma();
                Clients.Client(Context.ConnectionId).NoticeMessage("已停止数据读取!\n");
                for (int i = 0; i < devices.Count; i++)
                {
                    var dev = devices.Get(i);
                    if (dev != null)
                    {
                        if (dev.Handle != IntPtr.Zero && !(bStatus = dev.Close()))
                        {
                            string str = "断开设备: 关闭设备失败 (" + dev.ToString(false) + ")";
                            Clients.Client(Context.ConnectionId).NoticeMessage(str);
                            LogHelper.WriteLog(str);
                        }
                        else
                        {
                            dev.Handle          = IntPtr.Zero;
                            dev.ppwDma          = IntPtr.Zero;
                            dev.pReportWrBuffer = IntPtr.Zero;
                            dev.pReportWrDMA    = IntPtr.Zero;
                            dev.pWbuffer        = IntPtr.Zero;
                            bStatus             = true;
                        }
                    }
                }
                if (bStatus)
                {
                    Clients.Client(Context.ConnectionId).NoticeMessage("已成功断开设备!\n");
                }
                return(bStatus);
            }
            catch (Exception ex)
            {
                LogHelper.ErrorLog(ex, "DeviceClose");
                Clients.Client(Context.ConnectionId).NoticeMessage(ex.Message + "close \n");
            }
            return(false);
        }
Beispiel #9
0
        /* Close handle to a PCIE device */
        private BOOL DeviceClose(int iSelectedIndex)
        {
            PCIE_Device device  = pciDevList.Get(iSelectedIndex);
            BOOL        bStatus = false;

            if (device.Handle != IntPtr.Zero && !(bStatus = device.Close()))
            {
                Log.ErrLog("PCIE_diag.DeviceClose: Failed closing PCIE "
                           + "device (" + device.ToString(false) + ")");
            }
            else
            {
                device.Handle = IntPtr.Zero;
            }
            return(bStatus);
        }
Beispiel #10
0
        /* Open a handle to a device */
        private bool DeviceOpen(int iSelectedIndex)  //判断设备是否开启成功
        {
            DWORD       dwStatus;
            PCIE_Device device = pciDevList.Get(iSelectedIndex);//获得当前设备

            /* Open a handle to the device */
            dwStatus = device.Open();//开启设备 获取设备状态信息
            if (dwStatus != (DWORD)wdc_err.WD_STATUS_SUCCESS)
            {
                Log.ErrLog("PCIE_diag.DeviceOpen: Failed opening a " +
                           "handle to the device (" + device.ToString(false) + ")");
                return(false);
            }
            Log.TraceLog("PCIE_diag.DeviceOpen: The device was successfully open." +
                         "You can now activate the device through the enabled menu above");
            return(true);
        }
Beispiel #11
0
        public AddrSpaceTransferForm(PCIE_Device dev, string[] sBars)
        {
            InitializeComponent();

            m_device = dev;

            for (int i = 0; i < sBars.Length; ++i)
            {
                cmboBar.Items.Add(sBars[i]);
            }

            this.Text = "Read/Write Address Space Form";

            cmboMode.Items.AddRange(new object[] { "8 bits", "16 bits", "32 bits", "64 bits" });
            cmboTransType.Items.AddRange(new object[] { "block", "non-block" });
            chkBoxInc.Enabled   = false;
            txtNumBytes.Enabled = false;
        }
Beispiel #12
0
 /* device button */ //打开设备按键处理函数
 private void btDevice_Click(object sender, System.EventArgs e)
 {
     if (btDevice.Text == "Open Device")
     {
         if (DeviceOpen(lstBxDevices.SelectedIndex) == true)
         {
             btDevice.Text = "Close Device";
             EnableMenu();
         }
     }
     else
     {
         PCIE_Device dev =
             pciDevList.Get(lstBxDevices.SelectedIndex);
         DeviceClose(lstBxDevices.SelectedIndex);
         btDevice.Text = "Open Device";
         DisableMenu();
     }
 }
Beispiel #13
0
        public RegistersForm(PCIE_Device dev, ACTION_TYPE regType)
        {
            InitializeComponent();

            m_device  = dev;
            m_regType = regType;

            switch (regType)
            {
            case ACTION_TYPE.CFG:
            {
                this.Text        = "Read/Write Configuration Space by Registers";
                lblRegs.Visible  = true;
                lblRegs.Text     = "Choose a Cfg Register";
                cmboRegs.Visible = true;
                WDC_REG[] regs = dev.Regs.gPCIE_CfgRegs;
                for (int i = 0; i < regs.GetLength(0); ++i)
                {
                    cmboRegs.Items.AddRange(new object[] { regs[i].sName +
                                                           " size: " + regs[i].dwSize.ToString("X") +
                                                           " - " + regs[i].sDesc });
                }
                break;
            }

            case ACTION_TYPE.RT:
            {
                this.Text        = "Read/Write RunTime Registers";
                lblRegs.Visible  = true;
                lblRegs.Text     = "Choose a RunTime Register";
                cmboRegs.Visible = true;
                WDC_REG[] regs = m_device.Regs.gPCIE_RT_Regs;
                for (int i = 0; i < regs.GetLength(0); ++i)
                {
                    cmboRegs.Items.AddRange(new object[] { regs[i].sName +
                                                           " size: " + regs[i].dwSize.ToString("X") +
                                                           " - " + regs[i].sDesc });
                }
                break;
            }
            }
        }
Beispiel #14
0
        /* Open a handle to a device */
        public bool DeviceOpen(int iSelectedIndex)
        {
            LogHelper.WriteLog(string.Format("连接第{0}张板卡", iSelectedIndex + 1));
            DWORD       dwStatus = 0;
            var         devices  = PCIE_DeviceList.TheDeviceList();
            PCIE_Device device   = PCIE_DeviceList.TheDeviceList().Get(iSelectedIndex);

            if (device == null)
            {
                return(false);
            }
            /* Open a handle to the device */
            try
            {
                for (int i = 0; i < devices.Count; i++)
                {
                    var dev = devices.Get(i);
                    if (dev != null)
                    {
                        dwStatus = dev.Open();
                        if (dwStatus != (DWORD)wdc_err.WD_STATUS_SUCCESS)
                        {
                            string str = "打开设备: 连接设备失败 (" + dev.ToString(false) + ")\n";
                            Clients.Client(Context.ConnectionId).NoticeMessage(str);
                            LogHelper.WriteLog(str);
                        }
                    }
                }
                Clients.Client(Context.ConnectionId).NoticeMessage("已成功连接设备!\n");
                if (dwStatus > 0)
                {
                    return(false);
                }
                return(true);
            }
            catch (Exception ex)
            {
                LogHelper.ErrorLog(ex, "DeviceOpen");
                Clients.Client(Context.ConnectionId).NoticeMessage(ex.Message + " open\n");
                return(false);
            }
        }
Beispiel #15
0
        private void OnScanDrive(PCIE_Device dev, string dvireName, int deviceIndex)
        {
            while (true)
            {
                Thread.Sleep(10);
                if (readSize == 0)
                {
                    continue;
                }
                var findDrive = DriveInfo.GetDrives().FirstOrDefault(o => o.Name == dvireName);
                if (findDrive != null)
                {
                    if (findDrive.AvailableFreeSpace < 1024 * 1024 * 1024.0 * 20)
                    {
                        var           fileName = dev.DeviceFile.Name;
                        var           index    = fileName.LastIndexOf("\\");
                        var           dirPath  = fileName.Substring(0, index + 1);
                        DirectoryInfo dir      = new DirectoryInfo(dirPath);

                        var fileList = dir.GetFiles("*", SearchOption.TopDirectoryOnly).OrderBy(o => o.CreationTime);

                        try
                        {
                            var childFile = fileList.FirstOrDefault();
                            if (childFile == null)
                            {
                                return;
                            }
                            File.Delete(childFile.FullName);
                        }
                        catch (Exception ex)
                        {
                            LogHelper.ErrorLog(ex);
                        }
                    }
                }
            }
        }
Beispiel #16
0
        private void menuEnableInt_Click(object sender,
                                         System.EventArgs e)
        {
            PCIE_Device dev = pciDevList.Get(lstBxDevices.SelectedIndex);

            if (menuEnableInt.Text == "Enable Interrupts")
            {
                DWORD dwStatus = dev.EnableInterrupts(new
                                                      USER_INTERRUPT_CALLBACK(PCIE_IntHandler), dev.Handle);
                if (dwStatus == (DWORD)wdc_err.WD_STATUS_SUCCESS)
                {
                    menuEnableInt.Text = "Disable Interrupts";
                }
            }
            else
            {
                DWORD dwStatus = dev.DisableInterrupts();
                if (dwStatus == (DWORD)wdc_err.WD_STATUS_SUCCESS)
                {
                    menuEnableInt.Text = "Enable Interrupts";
                }
            }
        }
Beispiel #17
0
        private void NonParameterRun(PCIE_Device dev, string dvireName, int dataSize, int deviceIndex)
        {
            int wrDMASize = dataSize * 1024; //16kb

            dev.WriteBAR0(0, 0x60, 1);       //中断屏蔽
            dev.WriteBAR0(0, 0x50, 1);       //dma 写报告使能

            var dma    = (WD_DMA)dev.m_dmaMarshaler.MarshalNativeToManaged(dev.pReportWrDMA);
            var ppwDma = (WD_DMA)dev.m_dmaMarshaler.MarshalNativeToManaged(dev.ppwDma);

            dev.WriteBAR0(0, 0x58, (uint)dma.Page[0].pPhysicalAddr);           //dma 写报告地址
            //设置初始DMA写地址,长度等
            dev.WriteBAR0(0, 0x4, (uint)ppwDma.Page[0].pPhysicalAddr);         //wr_addr low
            dev.WriteBAR0(0, 0x8, (uint)(ppwDma.Page[0].pPhysicalAddr >> 32)); //wr_addr high
            dev.WriteBAR0(0, 0xC, (UInt32)wrDMASize);                          //dma wr size

            //dev.WriteBAR0(0, 56, 1);
            // dev.WriteBAR0(0, 48, 1);

            var list = DeviceChannelList[dev];

            //foreach (var item in list)
            //{
            //   dev.WriteBAR0(0, item.RegAddress, item.IsOpen == true ? (UInt32)1 : 0);
            //}
            Parallel.ForEach(list, item =>
            {
                dev.WriteBAR0(0, item.RegAddress, item.IsOpen == true ? (UInt32)1 : 0);
            });
            Thread.Sleep(1000);
            //启动DMA
            dev.WriteBAR0(0, 0x10, 1);          //dma wr 使能

            dev.Status = 1;
            IsStop     = false;
            while (!IsStop)
            {
                //var findDrive = DriveInfo.GetDrives().FirstOrDefault(o => o.Name == dvireName);
                //if (findDrive != null)
                //{
                //    if (findDrive.AvailableFreeSpace < 1024 * 1024 * 256.0)
                //    {
                //        dev.DeviceFile.SetLength(0);
                //    }
                //}
                byte[] tmpResult = new Byte[wrDMASize];
                Marshal.Copy(dev.pWbuffer, tmpResult, 0, wrDMASize);
                dev.DeviceFile.Write(tmpResult, 0, wrDMASize);
                dev.DeviceFile.Flush();
                // concurrentQueue.Enqueue(tmpResult);
                // DWORD lpNumberOfBytesWritten = 0;
                //  PCIE_Device.WriteFile(dev.DeviceFile.SafeFileHandle.DangerousGetHandle(),ref dev.pWbuffer, (uint)dataSize * 1024, out lpNumberOfBytesWritten, null);
                // Stream.Write(tmpResult, 0, tmpResult.Length);

                //var bytes = tmpResult.Length /16;
                //for (int i = 0; i < bytes; i++)
                //{
                //    var index = i * 16;
                //    byte[] result = new byte[16];
                //    for (int j = 0; j < 16; j++)
                //    {
                //        result[j] = tmpResult[index + j];
                //    }
                //    if (result[15] == 1)
                //    {
                //        WriteFile(result, list);
                //    }
                //}

                // ReadTotalSize = wrDMASize;
                readSize += wrDMASize;
                // Clients.Client(Context.ConnectionId).NotifyTotal(wrDMASize);

                dev.WriteBAR0(0, 0x10, 1);//执行下次读取
            }
            dev.WriteBAR0(0, 0x10, 0);
        }
Beispiel #18
0
        public string OnReadDma(string dvireName, int dataSize, int deviceIndex)
        {
            //var findDrive = DriveInfo.GetDrives().FirstOrDefault(o => o.Name == dvireName);
            //if (findDrive != null)
            //{
            //    if (findDrive.AvailableFreeSpace < 1024 * 1024 * 1024.0)
            //    {

            //    }
            //}
            int cout = PCIE_DeviceList.TheDeviceList().Count;

            if (cout == 1 && deviceIndex == 1)
            {
                return("");
            }
            PCIE_Device dev = PCIE_DeviceList.TheDeviceList().Get(deviceIndex);

            if (dev == null)
            {
                Clients.Client(Context.ConnectionId).NoticeMessage("设备DMA读取发生异常" + "\n");
                return("设备读取异常,请重试");
            }
            if (dev.Status == 1)
            {
                return("正在读取数据...");
            }
            Clients.Client(Context.ConnectionId).NoticeMessage("正在读取设备数据...\n");
            dev.FPGAReset(0);
            if (dev.WDC_DMAContigBufLock() != 0)
            {
                Clients.Client(Context.ConnectionId).NoticeMessage("锁定内存空间失败..." + "\n");
                //MessageBox.Show(("分配报告内存失败"));
                DeviceClose(0);
                return("锁定内存空间失败");
            }
            //DWORD wrDMASize = dataSize; //16kb
            if (!dev.DMAWriteMenAlloc((uint)0, (uint)1, (UInt32)dataSize * 1024))
            {
                //MessageBox.Show("内存分配失败!");
                Clients.Client(Context.ConnectionId).NoticeMessage("内存分配失败..." + "\n");
                DeviceClose(0);
                return("内存分配失败");
            }
            string dt = DateTime.Now.ToString("yyyyMMddHHmmss");
            // var list = DeviceChannelList[dev];
            //foreach (var item in list)
            //{
            //    var dir = Path.Combine(dvireName, item.DiskPath);
            //    if (!Directory.Exists(dir))
            //    {
            //        Directory.CreateDirectory(dir);
            //    }
            //    var filePath = Path.Combine(dir, dt);
            //    //File.Create(filePath);
            //    item.FilePath = filePath;
            //    if (item.IsOpen)
            //    {
            //        item.Stream = new FileStream(filePath, FileMode.Append, FileAccess.Write);
            //    }

            //}
            var dir = Path.Combine(dvireName, "device" + deviceIndex.ToString());

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            var filePath = Path.Combine(dir, dt);

            dev.DeviceFile = new FileStream(filePath, FileMode.Append, FileAccess.Write);
            dev.StartWrDMA(0);

            //Thread readThread = new Thread(new ParameterizedThreadStart(p =>);
            //readThread.IsBackground = true;
            //readThread.Start();
            Task.Factory.StartNew(new Action(() => OnScanDrive(dev, dvireName, deviceIndex)));
            //Thread nonParameterThread = new Thread(new ParameterizedThreadStart(p => NonParameterRun(dev, dvireName, dataSize, deviceIndex)));
            //nonParameterThread.Start();
            Task.Factory.StartNew(new Action(() => NonParameterRun(dev, dvireName, dataSize, deviceIndex))).ContinueWith(t =>
            {
                dev.DeviceFile.Flush();
                dev.DeviceFile.Close();
                dev.DeviceFile.Dispose();
            });
            return(string.Empty);
        }
Beispiel #19
0
        public string ScanDevice(int deviceIndex)
        {
            int         count = PCIE_DeviceList.TheDeviceList().Count;
            PCIE_Device dev   = PCIE_DeviceList.TheDeviceList().Get(deviceIndex);

            if (dev == null)
            {
                return("device");
            }
            if (dev.WDCScan_DMAContigBufLock() != 0)
            {
                //MessageBox.Show(("分配报告内存失败"));
                return("device");
            }
            ////DWORD wrDMASize = dataSize; //16kb
            if (!dev.ScanDMAWriteMenAlloc(16 * 1024))
            {
                //MessageBox.Show("内存分配失败!");
                return("device");
            }
            dev.StartWrDMA(0);
            dev.WriteBAR0(0, 0x60, 1);          //中断屏蔽
            dev.WriteBAR0(0, 0x50, 1);          //dma 写报告使能

            var dma    = (WD_DMA)dev.m_dmaMarshaler.MarshalNativeToManaged(dev.pScanReportWrDMA);
            var ppwDma = (WD_DMA)dev.m_dmaMarshaler.MarshalNativeToManaged(dev.pScanpwDma);

            dev.WriteBAR0(0, 0x58, (uint)dma.Page[0].pPhysicalAddr);           //dma 写报告地址
            //设置初始DMA写地址,长度等
            dev.WriteBAR0(0, 0x4, (uint)ppwDma.Page[0].pPhysicalAddr);         //wr_addr low
            dev.WriteBAR0(0, 0x8, (uint)(ppwDma.Page[0].pPhysicalAddr >> 32)); //wr_addr high
            dev.WriteBAR0(0, 0xC, (UInt32)16 * 1024);                          //dma wr size

            dev.WriteBAR0(0, 0x28, 1);
            //int readIndex = 0;
            var dt = DateTime.Now;

            while (true)
            {
                var current = (DateTime.Now - dt).Seconds;
                if (current > 1)
                {
                    break;
                }
                dev.WriteBAR0(0, 0x10, 1);
            }
            dev.WriteBAR0(0, 0x10, 1);

            dev.WriteBAR0(0, 0x28, 0);
            dev.WriteBAR0(0, 0x10, 0);
            //启动DMA
            //       //dma wr 使能
            byte[] tmpResult = new Byte[16 * 1024];
            Marshal.Copy(dev.pScanWbuffer, tmpResult, 0, 16 * 1024);
            LogHelper.WriteLog(string.Format("设备{0}自检返回数据: ", deviceIndex + 1) + CommonHelper.ByteToString(tmpResult));
            var findItem = tmpResult.Where(o => o == 63).Count();

            LogHelper.WriteLog(findItem.ToString());
            //var findItem = barList.FirstOrDefault(o => o != 63);
            if (findItem > 50)
            {
                // scanStr = "设备所有通道自检正常!";
                return(string.Empty);
            }
            else
            {
                string errorStr = deviceIndex == 0 ? "1,2,3" : " 4,5,6";
                var    query    = tmpResult.Where(o => o == 3).Count();
                if (query > 50)
                {
                    errorStr = deviceIndex == 0 ? "2,3" : " 5,6";
                }
                var query1 = tmpResult.Where(o => o == 12).Count();
                if (query1 > 50)
                {
                    errorStr = deviceIndex == 0 ? "1,3" : " 4,6";
                }
                var query2 = tmpResult.Where(o => o == 15).Count();
                if (query2 > 50)
                {
                    errorStr = deviceIndex == 0 ? "3" : " 6";
                    LogHelper.WriteLog(query2.ToString());
                }
                var query3 = tmpResult.Where(o => o == 48).Count();
                if (query3 > 50)
                {
                    errorStr = deviceIndex == 0 ? "1,2" : " 4,5";
                }
                var query4 = tmpResult.Where(o => o == 51).Count();
                if (query4 > 50)
                {
                    errorStr = deviceIndex == 0 ? "2" : " 5";
                }
                var query5 = tmpResult.Where(o => o == 60);

                if (query5.Count() > 50)
                {
                    errorStr = deviceIndex == 0 ? "1" : " 4";
                    LogHelper.WriteLog(query5.ToString());
                }
                //var query6 = tmpResult.Where(o => o == 0);
                //if (query6.Count()==tmpResult.Count())
                //{
                //    errorStr = deviceIndex == 0 ? "1,2,3" : " 4,5,6";
                //}
                //switch (findItem)
                //{
                //    case 3:
                //        errorStr = deviceIndex == 0 ? "1,2" : " 4,5";
                //        break;
                //    case 12:
                //        errorStr = deviceIndex == 0 ? "1,3" : " 4,6";
                //        break;
                //    case 15:
                //        errorStr = deviceIndex == 0 ? "1" : " 4";
                //        break;
                //    case 48:
                //        errorStr = deviceIndex == 0 ? "2,3" : " 5,6";
                //        break;
                //    case 51:
                //        errorStr = deviceIndex == 0 ? "2" : " 5";
                //        break;
                //    case 60:
                //        errorStr = deviceIndex == 0 ? "3" : " 6";
                //        break;
                //    default:
                //        errorStr ="Error";
                //        break;
                //}
                // scanStr += errorStr;
                //  tmpInfo +=errorStr+"";
                return(errorStr);
            }
        }
Beispiel #20
0
 private void PCIE_IntHandler(PCIE_Device dev)
 {
     Log.TraceLog("interrupt for device {" + dev.ToString(false) +
                  "} received!");
 }
Beispiel #21
0
        public CfgTransfersForm(PCIE_Device dev)
        {
            InitializeComponent();

            m_device = dev;
        }
Beispiel #22
0
        private void PCIE_EventHandler(ref WD_EVENT wdEvent, PCIE_Device dev)
        {
            string sAction;

            switch ((WD_EVENT_ACTION)wdEvent.dwAction)
            {
            case WD_EVENT_ACTION.WD_INSERT:
                sAction = "WD_INSERT";
                break;

            case WD_EVENT_ACTION.WD_REMOVE:
                sAction = "WD_REMOVE";
                break;

            case WD_EVENT_ACTION.WD_POWER_CHANGED_D0:
                sAction = "WD_POWER_CHANGED_D0";
                break;

            case WD_EVENT_ACTION.WD_POWER_CHANGED_D1:
                sAction = "WD_POWER_CHANGED_D1";
                break;

            case WD_EVENT_ACTION.WD_POWER_CHANGED_D2:
                sAction = "WD_POWER_CHANGED_D2";
                break;

            case WD_EVENT_ACTION.WD_POWER_CHANGED_D3:
                sAction = "WD_POWER_CHANGED_D3";
                break;

            case WD_EVENT_ACTION.WD_POWER_SYSTEM_WORKING:
                sAction = "WD_POWER_SYSTEM_WORKING";
                break;

            case WD_EVENT_ACTION.WD_POWER_SYSTEM_SLEEPING1:
                sAction = "WD_POWER_SYSTEM_SLEEPING1";
                break;

            case WD_EVENT_ACTION.WD_POWER_SYSTEM_SLEEPING2:
                sAction = "WD_POWER_SYSTEM_SLEEPING2";
                break;

            case WD_EVENT_ACTION.WD_POWER_SYSTEM_SLEEPING3:
                sAction = "WD_POWER_SYSTEM_SLEEPING3";
                break;

            case WD_EVENT_ACTION.WD_POWER_SYSTEM_HIBERNATE:
                sAction = "WD_POWER_SYSTEM_HIBERNATE";
                break;

            case WD_EVENT_ACTION.WD_POWER_SYSTEM_SHUTDOWN:
                sAction = "WD_POWER_SYSTEM_SHUTDOWN";
                break;

            default:
                sAction = wdEvent.dwAction.ToString("X");
                break;
            }
            Log.TraceLog("Received event notification of type " + sAction +
                         " on " + dev.ToString(false));
        }