plugin.cpp
/**
 * Initialise the plugin, called to get the plugin handle
 */
Initialise the plugin, called to get the plugin handle
Initialise the plugin called to get the plugin handle
PLUGIN_HANDLE plugin_init(ConfigCategory *config)
{
INA219 *ina219 = 0;
string	address, range;
	if (config->itemExists("address"))
	{
		address = config->getValue("address");
		ina219 = new INA219(strtol(address.c_str(), NULL, 10));
	}
	if (config->itemExists("range"))
	{
		INA219_CONFIGURATION conf = CONF_32V_2A;
		range = config->getValue("range");
		if (range.compare("32V2A") == 0)
		{
			conf = CONF_32V_2A;
		}
		else if (range.compare("32V1A") == 0)
		{
			conf = CONF_32V_1A;
		}
		else if (range.compare("16V400mA") == 0)
		{
			conf = CONF_16V_400MA;
		}
		ina219->configure(conf);
	}
	else
	{
		ina219->configure(CONF_32V_2A);
	}
	if (config->itemExists("asset"))
	{
		ina219->setAssetName(config->getValue("asset"));
	}
	else
	{
		ina219->setAssetName("electrical");
	}
	return (PLUGIN_HANDLE)ina219;
}
PLUGIN_HANDLE plugin_init ( ConfigCategory * config ) { INA219 * ina219 = 0 ; string address , range ; if ( config -> itemExists ( " " ) ) { address = config -> getValue ( " " ) ; ina219 = new INA219 ( strtol ( address . c_str ( ) , NULL , 10 ) ) ; } if ( config -> itemExists ( " " ) ) { INA219_CONFIGURATION conf = CONF_32V_2A ; range = config -> getValue ( " " ) ; if ( range . compare ( " " ) == 0 ) { conf = CONF_32V_2A ; } else if ( range . compare ( " " ) == 0 ) { conf = CONF_32V_1A ; } else if ( range . compare ( " " ) == 0 ) { conf = CONF_16V_400MA ; } ina219 -> configure ( conf ) ; } else { ina219 -> configure ( CONF_32V_2A ) ; } if ( config -> itemExists ( " " ) ) { ina219 -> setAssetName ( config -> getValue ( " " ) ) ; } else { ina219 -> setAssetName ( " " ) ; } return ( PLUGIN_HANDLE ) ina219 ; }
Initialise the plugin, called to get the plugin handle
Initialise the plugin called to get the plugin handle