public ESeekM280Api() { usbDevices = new USBDeviceList(CyConst.DEVICES_CYUSB); handleException = new ExceptionCallback(ThreadException); Img_View = new Image_View(ImageView); SetDevice(); if (M280DEF.PixFormat == PixelFormat.Format16bppRgb565) { TotalPixSize = M280DEF.Image_Xsize * M280DEF.Image_Ysize * 2; } else if (M280DEF.PixFormat == PixelFormat.Format24bppRgb) { TotalPixSize = M280DEF.Image_Xsize * M280DEF.Image_Ysize * 3; } this.BufNum = TotalPixSize / (512 * M280DEF.Packet_Xfer); this.bInitM280 = false; this.bSysBusy = false; }
public void Start() { //string url = "http://localhost:9000"; //server = WebApp.Start(url); usbDevices = new USBDeviceList(CyConst.DEVICES_CYUSB); // Setup the callback routine for NullReference exception handling handleException = new ExceptionCallback(ThreadException); // Setup the callback routine for Image view from M280 board Img_View = new Image_View(ImageView); //Assign event handlers for device attachment and device removal. usbDevices.DeviceAttached += new EventHandler(usbDevices_DeviceAttached); usbDevices.DeviceRemoved += new EventHandler(usbDevices_DeviceRemoved); //Associate handler with DataReceived Event - Sachin serPort.DataReceived += serPort_DataReceived; // Set Form name //ST: Comment as we move the code to service //this.Text = M280DEF.ProName + " - V" + M280DEF.SWver; //Set and search the device with VID-PID 04b4-1003 and if found, selects the end point SetDevice(); //Initialize value if (M280DEF.PixFormat == PixelFormat.Format16bppRgb565) { TotalPixSize = M280DEF.Image_Xsize * M280DEF.Image_Ysize * 2; } else if (M280DEF.PixFormat == PixelFormat.Format24bppRgb) { TotalPixSize = M280DEF.Image_Xsize * M280DEF.Image_Ysize * 3; } if ((TotalPixSize % (512 * M280DEF.Packet_Xfer)) != 0) { //TODO: Write in event viewer //MessageBox.Show("Please check pixel size!"); } this.BufNum = TotalPixSize / (512 * M280DEF.Packet_Xfer); //ST: Comment as we move the code to service //this.timCheckStatus.Tick += new EventHandler(CheckState_Tick); //ST: Comment as we move the code to service //this.timCheckStatus.Interval = M280DEF.StatusGetInterval; this.bInitM280 = false; this.bSysBusy = false; openPort(); }
public Form1() { InitializeComponent(); // For USB Camera // Create the list of USB devices attached to the CyUSB.sys driver. usbDevices = new USBDeviceList(CyConst.DEVICES_CYUSB); // Setup the callback routine for NullReference exception handling handleException = new ExceptionCallback(ThreadException); // Setup the callback routine for Image view from M280 board Img_View = new Image_View(ImageView); //Assign event handlers for device attachment and device removal. usbDevices.DeviceAttached += new EventHandler(usbDevices_DeviceAttached); usbDevices.DeviceRemoved += new EventHandler(usbDevices_DeviceRemoved); //Associate handler with DataReceived Event - Sachin serPort.DataReceived += serPort_DataReceived; // Set Form name this.Text = M280DEF.ProName + " - V" + M280DEF.SWver; //Set and search the device with VID-PID 04b4-1003 and if found, selects the end point SetDevice(); //Initialize value if (M280DEF.PixFormat == PixelFormat.Format16bppRgb565) { TotalPixSize = M280DEF.Image_Xsize * M280DEF.Image_Ysize * 2; } else if (M280DEF.PixFormat == PixelFormat.Format24bppRgb) { TotalPixSize = M280DEF.Image_Xsize * M280DEF.Image_Ysize * 3; } if ((TotalPixSize % (512 * M280DEF.Packet_Xfer)) != 0) { MessageBox.Show("Please check pixel size!"); } this.BufNum = TotalPixSize / (512 * M280DEF.Packet_Xfer); this.timCheckStatus.Tick += new EventHandler(CheckState_Tick); this.timCheckStatus.Interval = M280DEF.StatusGetInterval; this.bInitM280 = false; this.bSysBusy = false; openPort(); }