let setData use double values instead of strings.
this allows for storing value set with setData which can then be used in the cgi module to retrieve the last value set.
This commit is contained in:
@@ -43,6 +43,10 @@ static void _definePath(const char *pathName, const char *pathValue);
|
||||
static GWEN_STRINGLIST *_getListOfMatchingFiles(const char *pathName, const char *subFolder, const char *mask);
|
||||
static GWEN_BUFFER *_getRuntimeFilePath(const char *pathName, const char *sFilename);
|
||||
static GWEN_BUFFER *_findFileinPath(const char *pathName, const char *sFilename);
|
||||
static int _readUint8DataFromDouble(double d, uint16_t *pDataVal, uint16_t *pDataDenom);
|
||||
static int _readUint16DataFromDouble(double d, uint16_t *pDataVal, uint16_t *pDataDenom);
|
||||
static int _readUint32DataFromDouble(double d, uint16_t *pDataVal, uint16_t *pDataDenom);
|
||||
|
||||
static int _readUint8DataFromString(const char *s, uint16_t *pDataVal, uint16_t *pDataDenom);
|
||||
static int _readUint16DataFromString(const char *s, uint16_t *pDataVal, uint16_t *pDataDenom);
|
||||
static int _readUint32DataFromString(const char *s, uint16_t *pDataVal, uint16_t *pDataDenom);
|
||||
@@ -469,6 +473,59 @@ GWEN_BUFFER *_findFileinPath(const char *pathName, const char *sFilename)
|
||||
|
||||
|
||||
|
||||
int AQH_ReadDataFromDouble(int dataType, double d, uint16_t *pDataVal, uint16_t *pDataDenom)
|
||||
{
|
||||
switch(dataType) {
|
||||
case AQH_ValueDataType_Uint8: return _readUint8DataFromDouble(d, pDataVal, pDataDenom);
|
||||
case AQH_ValueDataType_Int:
|
||||
case AQH_ValueDataType_Uint16: return _readUint16DataFromDouble(d, pDataVal, pDataDenom);
|
||||
case AQH_ValueDataType_Uint32: return _readUint32DataFromDouble(d, pDataVal, pDataDenom);
|
||||
case AQH_ValueDataType_Rational: break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
return GWEN_ERROR_INVALID;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int _readUint8DataFromDouble(double d, uint16_t *pDataVal, uint16_t *pDataDenom)
|
||||
{
|
||||
uint8_t v;
|
||||
|
||||
v=((uint8_t) (d)) & 0xff;
|
||||
*pDataVal=v & 0xff;
|
||||
*pDataDenom=1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int _readUint16DataFromDouble(double d, uint16_t *pDataVal, uint16_t *pDataDenom)
|
||||
{
|
||||
uint16_t v;
|
||||
|
||||
v=((uint16_t) d) & 0xffff;
|
||||
*pDataVal=v;
|
||||
*pDataDenom=1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int _readUint32DataFromDouble(double d, uint16_t *pDataVal, uint16_t *pDataDenom)
|
||||
{
|
||||
uint32_t v;
|
||||
|
||||
v=((uint32_t) d) & 0xffffffff;
|
||||
|
||||
*pDataVal=(v>>16) & 0xffff;
|
||||
*pDataDenom=v & 0xffff;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int AQH_ReadDataFromString(int dataType, const char *s, uint16_t *pDataVal, uint16_t *pDataDenom)
|
||||
{
|
||||
if (s && *s) {
|
||||
|
||||
Reference in New Issue
Block a user