| New file |
| | |
| | | #ifndef _BILLING_H_ |
| | | #define _BILLING_H_ |
| | | |
| | | #include "define_all.h" |
| | | #include "extern_rtc.h" |
| | | #include "administrator.h" |
| | | |
| | | #define LADDER_PRICE_DEFAULT_VER 0 |
| | | |
| | | typedef enum |
| | | { |
| | | BPM_NORMAL = 0U, // Õý³£¼Æ·Ñ |
| | | BPM_LADDER_1, |
| | | BPM_LADDER_2, |
| | | BPM_LADDER_3, |
| | | BPM_LADDER_4, |
| | | BPM_LADDER_5 |
| | | } BILLING_PRICE_MODE_NOW_T; // µ±Ç°µÄ¼Û¸ñģʽ |
| | | typedef enum |
| | | { |
| | | SPM_NORMAL = 0U, |
| | | SPM_LADDER = 0x12, // ½×Ìݵ÷¼Û |
| | | SPM_TIME = 0x13 // ʱ¼äµ÷¼Û |
| | | } SET_PRICE_MODE_T; // ÉèÖü۸ñģʽ |
| | | typedef enum |
| | | { |
| | | PPS_CYCLICALLY = 0U, |
| | | PPS_ONLY_ONE = 0x11 |
| | | } PRICE_PERIOD_STATUS_T; // ¼Û¸ñÖÜÆÚ״̬ |
| | | typedef enum |
| | | { |
| | | PPU_HOUR = 0x11, |
| | | PPU_DAY = 0x22, |
| | | PPU_MONTH = 0x33, |
| | | PPU_QUARTER = 0x44, // ¼¾¶È |
| | | PPU_YEAR = 0x55, // Äê¶È |
| | | } PRICE_PERIOD_UNIT_T; // ¼Û¸ñÖÜÆÚµ¥Î» |
| | | |
| | | #pragma pack(1) |
| | | |
| | | #define REALTIME_BILLING_FORMAT_SIZE sizeof(BILLING_REAL_PARA_T) |
| | | typedef struct |
| | | { |
| | | uint8_t price_type_mode_now; |
| | | uint32_t price_now; |
| | | double use_money_sum; |
| | | double balance_now; |
| | | double residual_gas_now; |
| | | double ladder_cumulate_sc; |
| | | } BILLING_REAL_PARA_T; // ¼Æ·Ñʵʱ²ÎÊý |
| | | |
| | | #define SYS_BILLING_ALARM_CFG_FORMAT_SIZE sizeof(BILLING_ALARM_CFG_T) |
| | | typedef struct |
| | | { |
| | | uint16_t alarm_ctl_byte_2; |
| | | uint16_t alarm_send_byte_2; |
| | | uint16_t valve_close_ctl[2]; |
| | | int32_t balance_small_value[5]; |
| | | uint32_t cumulate_flow_value; |
| | | uint8_t no_gprs_days; |
| | | uint8_t no_use_gas_days; |
| | | uint8_t reserve[5]; |
| | | } BILLING_ALARM_CFG_T; // ¼Æ·Ñ±¨¾¯ÅäÖà |
| | | |
| | | typedef struct |
| | | { |
| | | uint8_t time[6]; |
| | | uint16_t duration; |
| | | } LADDER_TIME_PRICE_PARA_T; |
| | | #define SYS_LADDER_PRICE_CFG_FORMAT_SIZE sizeof(LADDER_PRICE_CFG_PARA_T) |
| | | typedef struct |
| | | { |
| | | uint16_t price_ver; |
| | | uint32_t normal_price_now; |
| | | SET_PRICE_MODE_T set_price_type_mode; |
| | | PRICE_PERIOD_STATUS_T period_state; |
| | | uint8_t period_start_time[6]; |
| | | PRICE_PERIOD_UNIT_T period_unit; |
| | | uint16_t period_duration; |
| | | uint32_t set_ladder_price[5]; |
| | | uint32_t set_ladder_cumulate[5]; |
| | | LADDER_TIME_PRICE_PARA_T set_time_price[5]; |
| | | PRICE_PERIOD_UNIT_T time_unit; |
| | | uint8_t price_scheme_start_time[6]; |
| | | uint8_t reserve[7]; |
| | | } LADDER_PRICE_CFG_PARA_T; // ½×Ìݼ۸ñÅäÖòÎÊý |
| | | |
| | | #pragma pack() |
| | | |
| | | extern BILLING_REAL_PARA_T billing_real_para_g; |
| | | extern LADDER_PRICE_CFG_PARA_T ladder_price_cfg_para_true_g; |
| | | extern LADDER_PRICE_CFG_PARA_T ladder_price_cfg_para_new_g; |
| | | extern ErrorStatus_STM32 have_gprs_send_flag; |
| | | extern BILLING_ALARM_CFG_T billing_alarm_cfg_g; |
| | | |
| | | void Billing_RealTimeProcess(BILLING_MODE_T start_flag, __IO double single_flow_sum, LADDER_PRICE_CFG_PARA_T *ladder_cfg_p, BILLING_REAL_PARA_T *billing_para_p); |
| | | double GasCumulant_Ladder_PeriodCalculation(BILLING_MODE_T mode_flag,double single_flow_sum, |
| | | LADDER_PRICE_CFG_PARA_T *ladder_cfg_p_p, BILLING_REAL_PARA_T *billing_para_p_p); |
| | | void Add_days_CalculateYearMonTHDay(uint8_t *pYear_bcd, uint8_t *pMonth_bcd, uint8_t *pDay_bcd, uint16_t add_days); |
| | | void GasCumulant_Ladder_PeriodCfg(LADDER_PRICE_CFG_PARA_T *ladder_cfg_new, LADDER_PRICE_CFG_PARA_T *ladder_cfg_old, __IO RTC_TimeDateTypeDef *calendar); |
| | | void StartTime_NextCalculation(PRICE_PERIOD_UNIT_T price_unit, uint16_t time_duration, uint8_t *pNext_time); |
| | | |
| | | #endif |