installed osdWireFormat.h

This commit is contained in:
Jeff Hill
2006-11-30 22:20:10 +00:00
parent ee8eec3fdb
commit 0dd205f750
3 changed files with 49 additions and 332 deletions

View File

@@ -45,124 +45,6 @@ bool comBuf::flushToWire ( wireSendAdapter & wire, const epicsTime & currentTime
return true;
}
unsigned comBuf::push ( const epicsInt16 * pValue, unsigned nElem )
{
unsigned index = this->nextWriteIndex;
unsigned available = sizeof ( this->buf ) - index;
unsigned nBytes = sizeof ( *pValue ) * nElem;
if ( nBytes > available ) {
nElem = available / sizeof ( *pValue );
}
for ( unsigned i = 0u; i < nElem; i++ ) {
this->buf[ index + 0 ] =
static_cast < epicsUInt8 > ( pValue[i] >> 8u );
this->buf[ index + 1 ] =
static_cast < epicsUInt8 > ( pValue[i] >> 0u );
index += sizeof ( *pValue );
}
this->nextWriteIndex = index;
return nElem;
}
unsigned comBuf::push ( const epicsUInt16 * pValue, unsigned nElem )
{
unsigned index = this->nextWriteIndex;
unsigned available = sizeof ( this->buf ) - index;
unsigned nBytes = sizeof ( *pValue ) * nElem;
if ( nBytes > available ) {
nElem = available / sizeof ( *pValue );
}
for ( unsigned i = 0u; i < nElem; i++ ) {
this->buf[ index + 0 ] =
static_cast < epicsUInt8 > ( pValue[i] >> 8u );
this->buf[ index + 1 ] =
static_cast < epicsUInt8 > ( pValue[i] >> 0u );
index += sizeof ( *pValue );
}
this->nextWriteIndex = index;
return nElem;
}
unsigned comBuf::push ( const epicsInt32 * pValue, unsigned nElem )
{
unsigned index = this->nextWriteIndex;
unsigned available = sizeof ( this->buf ) - index;
unsigned nBytes = sizeof ( *pValue ) * nElem;
if ( nBytes > available ) {
nElem = available / sizeof ( *pValue );
}
for ( unsigned i = 0u; i < nElem; i++ ) {
this->buf[ index + 0 ] =
static_cast < epicsUInt8 > ( pValue[i] >> 24u );
this->buf[ index + 1 ] =
static_cast < epicsUInt8 > ( pValue[i] >> 16u );
this->buf[ index + 2 ] =
static_cast < epicsUInt8 > ( pValue[i] >> 8u );
this->buf[ index + 3 ] =
static_cast < epicsUInt8 > ( pValue[i] >> 0u );
index += sizeof ( *pValue );
}
this->nextWriteIndex = index;
return nElem;
}
unsigned comBuf::push ( const epicsUInt32 * pValue, unsigned nElem )
{
unsigned index = this->nextWriteIndex;
unsigned available = sizeof ( this->buf ) - index;
unsigned nBytes = sizeof ( *pValue ) * nElem;
if ( nBytes > available ) {
nElem = available / sizeof ( *pValue );
}
for ( unsigned i = 0u; i < nElem; i++ ) {
this->buf[ index + 0 ] =
static_cast < epicsUInt8 > ( pValue[i] >> 24u );
this->buf[ index + 1 ] =
static_cast < epicsUInt8 > ( pValue[i] >> 16u );
this->buf[ index + 2 ] =
static_cast < epicsUInt8 > ( pValue[i] >> 8u );
this->buf[ index + 3 ] =
static_cast < epicsUInt8 > ( pValue[i] >> 0u );
index += sizeof ( *pValue );
}
this->nextWriteIndex = index;
return nElem;
}
unsigned comBuf::push ( const epicsFloat32 * pValue, unsigned nElem )
{
unsigned index = this->nextWriteIndex;
unsigned available = sizeof ( this->buf ) - index;
unsigned nBytes = sizeof ( *pValue ) * nElem;
if ( nBytes > available ) {
nElem = available / sizeof ( *pValue );
}
for ( unsigned i = 0u; i < nElem; i++ ) {
// allow native floating point formats to be converted to IEEE
WireSetFloat32 ( pValue[i], &this->buf[index] );
index += sizeof ( *pValue );
}
this->nextWriteIndex = index;
return nElem;
}
unsigned comBuf::push ( const epicsFloat64 * pValue, unsigned nElem )
{
unsigned index = this->nextWriteIndex;
unsigned available = sizeof ( this->buf ) - index;
unsigned nBytes = sizeof ( *pValue ) * nElem;
if ( nBytes > available ) {
nElem = available / sizeof ( *pValue );
}
for ( unsigned i = 0u; i < nElem; i++ ) {
// allow native floating point formats to be converted to IEEE
WireSetFloat64 ( pValue[i], &this->buf[index] );
index += sizeof ( *pValue );
}
this->nextWriteIndex = index;
return nElem;
}
// throwing the exception from a function that isnt inline
// shrinks the GNU compiled object code
void comBuf::throwInsufficentBytesException ()