Barst  2.0
A server that controls lab hardware.
Public Member Functions | Public Attributes | Protected Attributes | Friends | List of all members
CPeriphFTDI Class Referenceabstract
Inheritance diagram for CPeriphFTDI:
CDevice CADCPeriph CMultiRPeriph CMultiWPeriph CPinRPeriph CPinWPeriph

Public Member Functions

 CPeriphFTDI (const TCHAR szName[], const SInitPeriphFT &sInitFT)
 
virtual bool DoWork (void *pHead, DWORD dwSize, FT_HANDLE ftHandle, EStateFTDI eReason, int nError)=0
 
virtual void ProcessData (const void *pHead, DWORD dwSize, __int64 llId)=0
 
virtual void Result (void *pHead, bool bPass)=0
 
virtual EStateFTDI GetState ()=0
 
virtual DWORD GetInfo (void *pHead, DWORD dwSize)=0
 
void SetOutputBits (unsigned char ucBitOutput)
 
unsigned char GetOutputBits ()
 
- Public Member Functions inherited from CDevice
 CDevice (const TCHAR szName[])
 

Public Attributes

const SInitPeriphFT m_sInitFT
 
- Public Attributes inherited from CDevice
const std::tstring m_csName
 

Protected Attributes

EStateFTDI m_eState
 
CTimerm_pcTimer
 
unsigned char m_ucBitOutput
 
CMemRingm_pcMemRing
 
- Protected Attributes inherited from CDevice
CCommm_pcComm
 
CLogBufferm_pcLogBuffer
 
CMemPoolm_pcMemPool
 
bool m_bError
 

Friends

class CChannelFTDI
 

Detailed Description

Definition at line 110 of file ftdi device.h.

Constructor & Destructor Documentation

◆ CPeriphFTDI()

CPeriphFTDI::CPeriphFTDI ( const TCHAR  szName[],
const SInitPeriphFT sInitFT 
)
inline

szName is the unique device name. sInitFT is the init for this device.

Definition at line 115 of file ftdi device.h.

Member Function Documentation

◆ DoWork()

virtual bool CPeriphFTDI::DoWork ( void *  pHead,
DWORD  dwSize,
FT_HANDLE  ftHandle,
EStateFTDI  eReason,
int  nError 
)
pure virtual

The FTDI thread calls this function on all the devices everytime a read/write occurs. However, devices only do something if they are active or are in/activated by the this call. This is called before every write to give each device the oppertunity to update the buffer to be written. Then after the write it's called again so that the buffer can be set again to the proper values. In both cases pHead is the write buffer. The function is also called after a read with pHead pointing to the index of memory gotten from m_pcMemRing which holds the most recent buffer read. The device should claim the memory while it's used and not forget to release it after. This allows prolonged usgae of the read buffer without holding up the read thread. The device can now extract the data read. Finally, the function is also called when we need to change the state of a device. In that case it's only called on the device in question. In all cases, dwSize is the size of the buffer (in case of read it's the buffer from m_pcMemRing struct). ftHandle if the handle to the ft device, you probably shouldn't do anything with it. eReason is the reson for this call, such as prewrite etc. Defined in EStateFTDI. nError is given the reason for this call if that failed. I.e. if the reason is a post write, it indicates if the write failed. The return value has no meaning at the moment.

Implemented in CPinRPeriph, CPinWPeriph, CMultiRPeriph, CMultiWPeriph, and CADCPeriph.

◆ GetInfo()

virtual DWORD CPeriphFTDI::GetInfo ( void *  pHead,
DWORD  dwSize 
)
pure virtual

This function copies chennel specific info into pHead which could then be sent to the user in response to a query request. If phead is NULL, the function returns the required size of pHead. If non NULL, dwSize if the sise of pHead and the function returns the total size of the data copied into pHead. This funcion followes the rules where every sub-struct is proceeded by an SBase. Typically, it returns an SBaseOut sturct which holds the name of the device followed by channels specific structs.

Implements CDevice.

Implemented in CPinRPeriph, CPinWPeriph, CMultiRPeriph, CMultiWPeriph, and CADCPeriph.

◆ ProcessData()

virtual void CPeriphFTDI::ProcessData ( const void *  pHead,
DWORD  dwSize,
__int64  llId 
)
pure virtual

Comm calls this function when a user sent data to the device.

Implements CDevice.

Implemented in CPinRPeriph, CPinWPeriph, CMultiRPeriph, CMultiWPeriph, and CADCPeriph.

◆ Result()

virtual void CPeriphFTDI::Result ( void *  pHead,
bool  bPass 
)
pure virtual

Comm calls this function when it finished writing data to user sent by this device. phead is the pHead parameter in the SData struct that was sent with SendData() bPass is true if successfull and false otherwise.

Implements CDevice.

Implemented in CPinRPeriph, CPinWPeriph, CMultiRPeriph, CMultiWPeriph, and CADCPeriph.