mirror of
https://github.com/anklimov/lighthub
synced 2025-12-17 09:09:51 +03:00
interim commit: universal Modbus driver
This commit is contained in:
@@ -43,6 +43,7 @@ e-mail anklimov@gmail.com
|
||||
#include "modules/out_spiled.h"
|
||||
#include "modules/out_ac.h"
|
||||
#include "modules/out_motor.h"
|
||||
#include "modules/out_modbus.h"
|
||||
|
||||
short modbusBusy = 0;
|
||||
extern aJsonObject *pollingItem;
|
||||
@@ -174,6 +175,13 @@ void Item::Parse() {
|
||||
// debugSerial<<F("AC driver created")<<endl;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifndef MBUS_DISABLE
|
||||
case CH_MBUS:
|
||||
driver = new out_Modbus (this);
|
||||
// debugSerial<<F("AC driver created")<<endl;
|
||||
break;
|
||||
#endif
|
||||
default: ;
|
||||
}
|
||||
// debugSerial << F(" Item:") << itemArr->name << F(" T:") << itemType << F(" =") << getArg() << endl;
|
||||
@@ -350,16 +358,40 @@ void Item::setExt(long int par) // Only store if VAL is int (autogenerated or c
|
||||
if (!itemExt)
|
||||
{
|
||||
for (int i = aJson.getArraySize(itemArr); i <= 4; i++)
|
||||
aJson.addItemToArray(itemArr, aJson.createItem(0));
|
||||
itemExt = aJson.getArrayItem(itemArr, I_EXT);
|
||||
aJson.addItemToArray(itemArr, itemExt=aJson.createItem(0));
|
||||
//itemExt = aJson.getArrayItem(itemArr, I_EXT);
|
||||
};
|
||||
|
||||
if(itemExt->type != aJson_Int) return;
|
||||
if(!itemExt || itemExt->type != aJson_Int) return;
|
||||
itemExt->valueint = par;
|
||||
debugSerial<<F("Stored EXT:")<<par<<endl;
|
||||
}
|
||||
|
||||
|
||||
chPersistent * Item::getPersistent()
|
||||
{
|
||||
if (!itemExt) return NULL;
|
||||
if (itemExt->type == aJson_Int) return (chPersistent *) itemExt->child;
|
||||
else return NULL;
|
||||
}
|
||||
|
||||
chPersistent * Item::setPersistent(chPersistent * par)
|
||||
{
|
||||
if (!itemExt)
|
||||
{
|
||||
for (int i = aJson.getArraySize(itemArr); i <= 4; i++)
|
||||
aJson.addItemToArray(itemArr, itemExt = aJson.createItem(0));
|
||||
//itemExt = aJson.getArrayItem(itemArr, I_EXT);
|
||||
};
|
||||
|
||||
if(!itemExt || (itemExt->type != aJson_Int)) return NULL;
|
||||
itemExt->child = (aJsonObject *) par;
|
||||
// debugSerial<<F("Persisted.")<<endl;
|
||||
return par;
|
||||
}
|
||||
|
||||
|
||||
|
||||
boolean Item::isValid() {
|
||||
return (itemArr && (itemArr->type == aJson_Array));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user