//------------------------------------------------------------------------------ // USB communication library -- // (C) Piero Giubilato 2007-2010, Berkeley Lab -- //------------------------------------------------------------------------------ //______________________________________________________________________________ // {Trace} // [File name] "comm_USB.h" // [Author] "Piero Giubilato" // [Version] "1.0" // [Modified by] "Piero Giubilato" // [Last revision] "13 Feb 2009" // [Language] "C++" // [Compiler] "Visual C++ 8.x 9.x" // [Member of] "Cool SEAL" // [Project] "SEAL" // [Description] "This library handles the cy_USB class and provides advanced" // "USB communication capabilities. It allows to communicate with different" // "devices at the same time by the use of multi-threaded processes." // [Key documentation] // "Visual C++ Reference Help" // "Cypress CyUSB.NET DLL Programmer's Reference" // {Trace} //______________________________________________________________________________ // Overloading check #ifndef comm_USB_H #define comm_USB_H // Standard libs #include #include //______________________________________________________________________________ class comm_USB { private: // Class constants static int const dev_count_Max = 8; // Device max count // Device(s) status data memebrs static int dev_Count; // Device count static int dev_ID[8]; // Device Ids static int dev_Flag[8]; // Device status flag static int dev_Last[8]; // Device last read size static int dev_opt_read_Len[8]; // Device optimal buffer lenght static HANDLE dev_thread_Hnd[8]; // Device thread handle static unsigned int dev_thread_ID[8]; // Device thread ID static unsigned short* dev_buffer_Adr[8]; // Device buffer handle static int dev_req_Len[8]; // Device buffer length ID // Function members static unsigned int ReadTR(void* Args); // Multithread pivot function // Test data buffer static unsigned short* fake_Chunk; // Fake buffer chunk // Force a singleton comm_USB (const comm_USB&) {}; comm_USB& operator=(comm_USB&) {}; comm_USB (); public: // konstant enum kf {kf_Ready, kf_Busy, kf_Done, kf_tOut, kf_Error}; // General USB fuctions static int Open(int VendorID, int ProductID); static int Close(); static int Reset(); static int Reset(int devID); static int Clear(int tOut = 2000); static int Clear(int devID, int tOut = 2000); static int Count(); //static int Set(int* buffSize, int* timeout); //static int Set(int devID, int* buffSize, int* timeout); static int buffer_Len(int devID); static int buffer_Len(int devID, int* len); static int timeout_Len(int devID); static int timeout_Len(int devID, int* len); // Dark SEAL specific functions static int Tune(); static int opt_read_Len(int devID); static int GetHID(int devID); // Read/Write functions static int Write(int devID, unsigned short* buffer, int* len); static int Read(int devID, unsigned short* buffer, int* len, bool wait = true, int tOut = 1000); static int read_Fake(int devID, unsigned short* buffer, int* len, bool wait = true); static bool read_Busy(int devID); static int read_Flag(int devID); static int read_Len(int devID); }; // End of overloading check #endif