110 lines
		
	
	
		
			3.4 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			110 lines
		
	
	
		
			3.4 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| /****************************************************************************
 | |
| 
 | |
| Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
 | |
| 
 | |
| This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
 | |
| be copied by any method or incorporated into another program without
 | |
| the express written consent of Aerospace C.Power. This Information or any portion
 | |
| thereof remains the property of Aerospace C.Power. The Information contained herein
 | |
| is believed to be accurate and Aerospace C.Power assumes no responsibility or
 | |
| liability for its use in any way and conveys no license or title under
 | |
| any patent or copyright and makes no representation or warranty that this
 | |
| Information is free from patent or copyright infringement.
 | |
| 
 | |
| ****************************************************************************/
 | |
| #ifndef IOT_BRM_METER_H
 | |
| #define IOT_BRM_METER_H
 | |
| 
 | |
| #include "iot_pkt_api.h"
 | |
| 
 | |
| #ifdef __cplusplus
 | |
| extern "C" {
 | |
| #endif
 | |
| 
 | |
| /**
 | |
|  * @brief iot_brm_meter_energy_to_actual_value() - energy trans to actual value.
 | |
|  * @param e: src energy value.
 | |
|  * @param ec: Electronics constant, unit: imp/kWh
 | |
|  * @param multiple: actual value expanded multiple.
 | |
|  * @retval: actual expanded multiple energy value.
 | |
|  */
 | |
| float iot_brm_meter_energy_to_actual_value(uint32_t e, uint16_t ec,
 | |
|     uint32_t multiple);
 | |
| 
 | |
| /**
 | |
|  * @brief iot_brm_handle_meter_msg() - renew meter info from em pkt data.
 | |
|  * @param em_pkt: src em pkt data ptr.
 | |
|  */
 | |
| void iot_brm_handle_meter_msg(iot_pkt_t *em_pkt);
 | |
| 
 | |
| /**
 | |
|  * @brief iot_brm_meter_info_clear() - clear meter info.
 | |
|  */
 | |
| void iot_brm_meter_info_clear();
 | |
| 
 | |
| /**
 | |
|  * @brief iot_brm_meter_set_ratio() - set the transformation ratio of metering
 | |
|  *        transformer.
 | |
|  * @param v_ratio: The metering voltage transformer ratio will be set.
 | |
|  * @param i_ratio: The metering current transformer ratio will be set.
 | |
|  */
 | |
| void iot_brm_meter_set_ratio(uint32_t v_ratio, uint32_t i_ratio);
 | |
| 
 | |
| /**
 | |
|  * @brief iot_brm_meter_set_i_coeff() - set current coefficient.
 | |
|  * @param i_coeff: current coefficient, uint is 0.0001.
 | |
|  */
 | |
| void iot_brm_meter_set_i_coeff(uint32_t i_coeff);
 | |
| 
 | |
| /**
 | |
|  * @brief iot_brm_meter_info_backup() - backup meter info to flash.
 | |
|  */
 | |
| void iot_brm_meter_info_backup();
 | |
| 
 | |
| /**
 | |
|  * @brief iot_brm_meter_set_demand_slide_interval() - set slide interval.
 | |
|  * @param depth: demand slide interval, unit: 1minute.
 | |
|  * @retval: ERR_OK - success.
 | |
|  *          ERR_FAIL - interval invalid.
 | |
|  */
 | |
| uint32_t iot_brm_meter_set_demand_slide_interval(uint8_t interval);
 | |
| 
 | |
| /**
 | |
|  * @brief iot_brm_meter_set_demand_period() - set demand period.
 | |
|  * @param period: demand period, unit: 1minute.
 | |
|  * @retval: ERR_OK - success.
 | |
|  *          ERR_FAIL - period param invalid.
 | |
|  */
 | |
| uint32_t iot_brm_meter_set_demand_period(uint8_t period);
 | |
| 
 | |
| /**
 | |
|  * @brief iot_brm_meter_max_demand_clear() - clear meter max demand.
 | |
|  */
 | |
| void iot_brm_meter_max_demand_clear();
 | |
| 
 | |
| /**
 | |
|  * @brief iot_brm_meter_demand_update() - demand update.
 | |
|  * @param ts: integer timestamp.
 | |
|  */
 | |
| void iot_brm_meter_demand_update(uint32_t ts);
 | |
| 
 | |
| /**
 | |
|  * @brief iot_brm_meter_init() - init meter info from em device.
 | |
|  * @retval: ERR_OK - open em device success, init meter info success.
 | |
|  *          ERR_FAIL - open em device fail.
 | |
|  *          ERR_NOSUPP - no support em device.
 | |
|  *          ERR_NOMEM - init meter info fail.
 | |
|  */
 | |
| uint32_t iot_brm_meter_init();
 | |
| 
 | |
| /**
 | |
|  * @brief iot_brm_meter_deinit() - deinit meter info.
 | |
|  */
 | |
| void iot_brm_meter_deinit();
 | |
| 
 | |
| #ifdef __cplusplus
 | |
| }
 | |
| #endif
 | |
| 
 | |
| #endif /* IOT_BRM_METER_H */
 |