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:
@@ -26,15 +26,6 @@
|
||||
|
||||
<unit id="and1" type="and" />
|
||||
|
||||
<unit id="zeroPosNegString1" type="zeroPosNegString">
|
||||
<params>
|
||||
<param name="valueIfNegative">OFF</param>
|
||||
<param name="valueIfZero">OFF</param>
|
||||
<param name="valueIfPositive">ON</param>
|
||||
</params>
|
||||
</unit>
|
||||
|
||||
|
||||
<unit id="valueSetOutPlug1" type="valueSet">
|
||||
<params>
|
||||
<param name="valueName">mqtt/109C2F/power</param>
|
||||
@@ -49,7 +40,6 @@
|
||||
<link sourceUnit=".timer" sourcePort="output" targetUnit="suntime1" targetPort="timer" />
|
||||
<link sourceUnit="suntime1" sourcePort="output" targetUnit="and1" targetPort="input" />
|
||||
<link sourceUnit="delayedOff1" sourcePort="output" targetUnit="and1" targetPort="input" />
|
||||
<link sourceUnit="and1" sourcePort="output" targetUnit="zeroPosNegString1" targetPort="input" />
|
||||
<link sourceUnit="zeroPosNegString1" sourcePort="output" targetUnit="valueSetOutPlug1" targetPort="input" />
|
||||
<link sourceUnit="and1" sourcePort="output" targetUnit="valueSetOutPlug1" targetPort="input" />
|
||||
</links>
|
||||
</network>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
</inputPorts>
|
||||
|
||||
<outputPorts>
|
||||
<outputPort name="output" dataType="string" />
|
||||
<outputPort name="output" dataType="double" />
|
||||
</outputPorts>
|
||||
|
||||
|
||||
|
||||
@@ -312,10 +312,29 @@ const char *_readValueAndProbablyRange(const char *s, uint64_t *ptrBitField, int
|
||||
{
|
||||
int v=0;
|
||||
|
||||
while(isdigit(*s)) {
|
||||
v*=10;
|
||||
v+=(*s)-'0';
|
||||
s++;
|
||||
if (*s=='#') {
|
||||
while(*s) {
|
||||
unsigned char c;
|
||||
|
||||
c=tolower(*s);
|
||||
if ((c>='0' && c<='9') || (c>='a' && c<='f')) {
|
||||
c-='0';
|
||||
if (c>9)
|
||||
c-=7;
|
||||
v<<=4;
|
||||
v+=c;
|
||||
}
|
||||
else
|
||||
break;
|
||||
s++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
while(isdigit(*s)) {
|
||||
v*=10;
|
||||
v+=(*s)-'0';
|
||||
s++;
|
||||
}
|
||||
}
|
||||
if (!_valueOkay(v, minValue, maxValue)) {
|
||||
DBG_INFO(NULL, "here");
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
*/
|
||||
|
||||
static void _cbInputData(AQHREACT_UNIT *unit, AQHREACT_PORT *port, const AQHREACT_DATAOBJECT *dataObject);
|
||||
static AQH_MESSAGE *_mkSetDataMsgString(AQH_OBJECT *brokerEndpoint, const char *sValueName, const AQHREACT_DATAOBJECT *dataObject);
|
||||
static AQH_MESSAGE *_mkSetDataMsgDouble(AQH_OBJECT *brokerEndpoint, const char *sValueName, const AQHREACT_DATAOBJECT *dataObject);
|
||||
|
||||
|
||||
@@ -62,12 +61,12 @@ AQHREACT_UNIT *AqHomeReact_UnitValueSet_new(AQH_OBJECT *aqh)
|
||||
port=AQHREACT_Port_new();
|
||||
AQHREACT_Port_SetName(port, "input");
|
||||
AQHREACT_Port_SetIdForUnit(port, AQHOMEREACT_UNIT_VALUESET_INSLOT_VALUE);
|
||||
AQHREACT_Port_SetDataType(port, AQHREACT_DATAOBJECTTYPE_STRING);
|
||||
AQHREACT_Port_SetDataType(port, AQHREACT_DATAOBJECTTYPE_DOUBLE);
|
||||
AQHREACT_Unit_AddInputPort(unit, port);
|
||||
|
||||
param=AQHREACT_Param_new();
|
||||
AQHREACT_Param_SetName(param, AQHOMEREACT_UNIT_VALUESET_PARAM_VALUENAME);
|
||||
AQHREACT_Param_SetDataType(param, AQHREACT_DATAOBJECTTYPE_STRING);
|
||||
AQHREACT_Param_SetDataType(param, AQHREACT_DATAOBJECTTYPE_DOUBLE);
|
||||
AQHREACT_Unit_AddParam(unit, param);
|
||||
|
||||
return unit;
|
||||
@@ -92,9 +91,6 @@ void _cbInputData(AQHREACT_UNIT *unit, AQHREACT_PORT *port, const AQHREACT_DATAO
|
||||
case AQHREACT_DATAOBJECTTYPE_DOUBLE:
|
||||
msgOut=_mkSetDataMsgDouble(brokerEndpoint, sValueName, dataObject);
|
||||
break;
|
||||
case AQHREACT_DATAOBJECTTYPE_STRING:
|
||||
msgOut=_mkSetDataMsgString(brokerEndpoint, sValueName, dataObject);
|
||||
break;
|
||||
default:
|
||||
DBG_ERROR(NULL, "Unhandled data type (%d)", AQHREACT_DataObject_GetDataType(dataObject));
|
||||
msgOut=NULL;
|
||||
@@ -130,47 +126,21 @@ void _cbInputData(AQHREACT_UNIT *unit, AQHREACT_PORT *port, const AQHREACT_DATAO
|
||||
|
||||
|
||||
|
||||
AQH_MESSAGE *_mkSetDataMsgString(AQH_OBJECT *brokerEndpoint, const char *sValueName, const AQHREACT_DATAOBJECT *dataObject)
|
||||
{
|
||||
AQH_MESSAGE *msgOut;
|
||||
AQH_VALUE *v;
|
||||
|
||||
v=AQH_Value_new();
|
||||
AQH_Value_SetNameForSystem(v, sValueName);
|
||||
|
||||
msgOut=AQH_IpcdMessageSetData_new(AQH_MSGTYPE_IPC_DATA_SETDATA,
|
||||
AQH_Endpoint_GetNextMessageId(brokerEndpoint), 0,
|
||||
v, AQHREACT_DataObject_GetStringData(dataObject));
|
||||
AQH_Value_free(v);
|
||||
return msgOut;
|
||||
}
|
||||
|
||||
|
||||
|
||||
AQH_MESSAGE *_mkSetDataMsgDouble(AQH_OBJECT *brokerEndpoint, const char *sValueName, const AQHREACT_DATAOBJECT *dataObject)
|
||||
{
|
||||
AQH_MESSAGE *msgOut;
|
||||
AQH_VALUE *v;
|
||||
double data;
|
||||
GWEN_BUFFER *buf;
|
||||
int rv;
|
||||
|
||||
v=AQH_Value_new();
|
||||
AQH_Value_SetNameForSystem(v, sValueName);
|
||||
|
||||
data=AQHREACT_DataObject_GetDoubleData(dataObject);
|
||||
buf=GWEN_Buffer_new(0, 64, 0, 1);
|
||||
rv=GWEN_Text_DoubleToBuffer(data, buf);
|
||||
if (rv<0) {
|
||||
GWEN_Buffer_free(buf);
|
||||
AQH_Value_free(v);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
msgOut=AQH_IpcdMessageSetData_new(AQH_MSGTYPE_IPC_DATA_SETDATA,
|
||||
AQH_Endpoint_GetNextMessageId(brokerEndpoint), 0,
|
||||
v, GWEN_Buffer_GetStart(buf));
|
||||
GWEN_Buffer_free(buf);
|
||||
v, data);
|
||||
AQH_Value_free(v);
|
||||
return msgOut;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user