Barst  2.0
A server that controls lab hardware.
Public Member Functions | Public Attributes | List of all members
CPinWPeriph Class Reference
Inheritance diagram for CPinWPeriph:
CPeriphFTDI CDevice

Public Member Functions

 CPinWPeriph (const SPinInit &sPinInit, CComm *pcComm, const SInitPeriphFT &sInitFT, int &nError, HANDLE hNewData, CTimer *pcTimer)
 
bool DoWork (void *pHead, DWORD dwSize, FT_HANDLE ftHandle, EStateFTDI eReason, int nError)
 
void ProcessData (const void *pHead, DWORD dwSize, __int64 llId)
 
void Result (void *pHead, bool bPass)
 
EStateFTDI GetState ()
 
DWORD GetInfo (void *pHead, DWORD dwSize)
 
- Public Member Functions inherited from CPeriphFTDI
 CPeriphFTDI (const TCHAR szName[], const SInitPeriphFT &sInitFT)
 
void SetOutputBits (unsigned char ucBitOutput)
 
unsigned char GetOutputBits ()
 
- Public Member Functions inherited from CDevice
 CDevice (const TCHAR szName[])
 

Public Attributes

const SPinInit m_sInit
 
const unsigned char m_ucMask
 
- Public Attributes inherited from CPeriphFTDI
const SInitPeriphFT m_sInitFT
 
- Public Attributes inherited from CDevice
const std::tstring m_csName
 

Additional Inherited Members

- Protected Attributes inherited from CPeriphFTDI
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
 

Detailed Description

Definition at line 291 of file ftdi device.h.

Member Function Documentation

◆ DoWork()

bool CPinWPeriph::DoWork ( void *  pHead,
DWORD  dwSize,
FT_HANDLE  ftHandle,
EStateFTDI  eReason,
int  nError 
)
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.

Implements CPeriphFTDI.

Definition at line 614 of file cpl ft io.cpp.

◆ GetInfo()

DWORD CPinWPeriph::GetInfo ( void *  pHead,
DWORD  dwSize 
)
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 CPeriphFTDI.

Definition at line 579 of file cpl ft io.cpp.

◆ ProcessData()

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

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

Implements CPeriphFTDI.

Definition at line 726 of file cpl ft io.cpp.

◆ Result()

void CPinWPeriph::Result ( void *  pHead,
bool  bPass 
)
inlinevirtual

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 CPeriphFTDI.

Definition at line 299 of file ftdi device.h.