123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571 |
- #ifndef __PWS1_H__
- #define __PWS1_H__
- #define PWS1_NBR_MAX (1)
- enum pws1_cmd_t{
- CMD_pws1_set_dev_aps = 0,
- CMD_pws1_set_dev_startcmd,
- CMD_pws1_set_dev_stopcmd,
- CMD_pws1_set_dev_idlecmd,
- CMD_pws1_set_dev_resetcmd,
- };
- enum pws1_runstat_t{
- PWS1_RUNSTAT_PCS_INIT = 0,
- PWS1_RUNSTAT_INIT = 1,
- PWS1_RUNSTAT_STOP = 2,
- PWS1_RUNSTAT_IDLE,
- PWS1_RUNSTAT_DHG,
- PWS1_RUNSTAT_CHG,
- PWS1_RUNSTAT_UNKOWNING,
- };
- enum pws1_runmod_t{
- PWS1_RUNMOD_ONGRID = 0,
- PWS1_RUNMOD_OFFGRID = 1,
- PWS1_RUNMOD_UNKOWNING,
- };
- enum pws1_dispatch_t{
- PWS1_DISPATCH_MODE_AC = 0,
- PWS1_DISPATCH_MODE_DC = 1,
- PWS1_DISPATCH_MODE_STRING = 2,
- };
- enum pws1_ac_power_control_mode_t{
- PWS1_AC_POWER_CONTROL_MODE_FIX_AC_POWER = 0,
- PWS1_AC_POWER_CONTROL_MODE_V_W,
- PWS1_AC_POWER_CONTROL_MODE_F_W,
- PWS1_AC_POWER_CONTROL_MODE_VW_FW,
- };
- enum pws1_cmd_src_t{
- PWS1_CMD_SRC_LOCAL_MAN = 0,
- PWS1_CMD_SRC_LOCAL_AUTO = 1,
- PWS1_CMD_SRC_REMOTE = 2,
- PWS1_CMD_SRC_UNKOWNING = 3,
- };
- typedef union
- {
- /* data */
- unsigned short value;
- struct {
- unsigned short ac_bus_ov:1; //bit0 Fault
- unsigned short ac_bus_of:1; //bit1 Fault
- unsigned short ac_bus_uv:1; //bit2 Fault
- unsigned short ac_island_pro:1; //bit3 Fault
- unsigned short dc_input_ov:1; //bit4 Fault
- unsigned short on_off_grid_tog:1; //bit5 Fault
- unsigned short ac_phase_revers:1; //bit6 Fault
- unsigned short dc_input_uv:1; //bit7 Fault
- unsigned short overload_alarm:1; //bit8 alarm
- unsigned short ac_bus_v_abnormal:1; //bit9 Fault
- unsigned short ac_phase_lost:1; //bit10 Fault
- unsigned short ac_bus_v_asym:1; //bit11 Fault
- unsigned short ac_bus_u_fre:1; //bit12 Fault
- unsigned short bat_under_energy:1; //bit13 Fault
- unsigned short dc_input_oc:1; //bit14 Fault
- unsigned short offgrid_v_phase_rever:1; //bit15 Fault
- }bits_val;
- }PWS1_STATUS0;
- typedef union
- {
- /* data */
- unsigned short value;
- struct {
- unsigned short pll_fault:1; //bit0 Fault
- unsigned short ambient_ot:1; //bit1 Alarm
- unsigned short ambient_temp_sensor:1; //bit2 Fault
- unsigned short cabinet_temp_sensor:1; //bit3 Fault
- unsigned short cabinet_ot:1; //bit4 Fault
- unsigned short offgrid_v_phase_lost:1; //bit5 Fault
- unsigned short ac_current_harmonic_abmormal:1; //bit6 Fault
- }bits_val;
- }PWS1_STATUS1;
- typedef union
- {
- /* data */
- unsigned short value;
- struct {
- unsigned short aux_24v_power_fault:1; //bit0 Fault
- unsigned short emergency_stop:1; //bit1 Fault
- unsigned short ground_fault:1; //bit2 Fault
- unsigned short dc_bus_ov:1; //bit3 Fault
- unsigned short module_ot:1; //bit4 Fault
- unsigned short module_current_asy:1; //bit5 Fault
- unsigned short fan_fault:1; //bit6 Fault
- unsigned short dc_relay_open_circuit:1; //bit7 Fault
- unsigned short Cali_param_abnormal:1; //bit8 alarm
- unsigned short bus_v_unbalanced:1; //bit9 Fault
- unsigned short fuse_blown:1; //bit10 Fault
- unsigned short dsp_init_fault:1; //bit11 Fault
- unsigned short dc_soft_start_failed:1; //bit12 Fault
- unsigned short CANA_comm:1; //bit13 Fault
- unsigned short dc_input_rever:1; //bit14 Fault
- unsigned short ac_current_dc_component_abnormal:1; //bit15 Fault
- }bits_val;
- }PWS1_STATUS2;
- typedef union
- {
- /* data */
- unsigned short value;
- struct {
- unsigned short transf_ot:1; //bit0 Fault
- unsigned short u2_comm2:1; //bit1 alarm
- unsigned short bms_or_swithoff:1; //bit2 Fault
- unsigned short SPD_fault:1; //bit3 alarm
- unsigned short over_load_timeout:1; //bit4 Fault
- unsigned short ac_soft_start_fault:1; //bit5 Fault
- unsigned short syn_sig1:1; //bit6 Fault
- unsigned short dps_version:1; //bit7 Fault
- unsigned short ac_relay_open_circuit:1; //bit8 Fault
- unsigned short sample_zero:1; //bit9 alarm
- unsigned short u2_comm1:1; //bit10 alarm
- unsigned short aux_15v_power:1; //bit11 Fault
- unsigned short module_id_re:1; //bit12 Fault
- unsigned short rs485_comm:1; //bit13 Fault
- unsigned short CANB_comm:1; //bit14 Fault
- unsigned short restart_too_much:1; //bit15 Fault
- }bits_val;
- }PWS1_STATUS3;
- typedef union
- {
- /* data */
- unsigned short value;
- struct {
- unsigned short CPLD_version:1; //bit0 Fault
- unsigned short HW_version:1; //bit1 Fault
- unsigned short dc_relay_short_circuit:1; //bit2 Fault
- unsigned short dc_bus_uv:1; //bit3 Fault
- unsigned short ac_relay_short_circuit:1; //bit4 Fault
- unsigned short syn_sig2:1; //bit5 Fault
- unsigned short param_mismatch:1; //bit6 Fault
- unsigned short CANC_comm:1; //bit7 alarm
- unsigned short ambient_oh:1; //bit8 Fault
- unsigned short bms_ov:1; //bit9 Fault
- unsigned short bms_c_abnormal:1; //bit10 Fault
- unsigned short bms_t_abmormal:1; //bit11 Fault
- unsigned short bms_shutdown:1; //bit12 Fault
- unsigned short insulation_detection:1; //bit13 Fault
- unsigned short hw_sample_abnormal:1; //bit14 Fault
- unsigned short remote_lost:1; //bit15 Fault
- }bits_val;
- }PWS1_STATUS4;
- typedef union
- {
- /* data */
- unsigned short value;
- struct {
- unsigned short reseve:4;
- unsigned short PE_N_contactor_short:1; //bit4 Fault
- unsigned short PE_N_contactor_open:1; //bit5 Fault
- unsigned short N_contractor_short:1; //bit6 Fault
- unsigned short N_contractor_open:1; //bit7 Fault
- unsigned short grid_access:1; //bit8 switch
- unsigned short grid_powerdown:1; //bit9 switch
- unsigned short grid_voltage_distortion:1; //bit10 switch
- unsigned short input_dry_contact4:1; //bit11 Fault
- unsigned short input_dry_contact5:1; //bit12 alarm
- }bits_val;
- }PWS1_STATUS9;
- typedef union
- {
- unsigned short value;
- struct {
- unsigned short on_off_status:1;//ac模块组:起停状态 0:stop,1:running
- unsigned short reserv:1;
- unsigned short on_grid_status:1;//ac模块组:并网状态 0:false,1:true
- unsigned short off_grid_status:1;//ac模块组:离网状态 0:false,1:true
- unsigned short startup_status:1;//ac模块组:启动中状态 0:false,1:true
- unsigned short reserv1:4;
- unsigned short local_manual_ctl:1;//本地手动控制状态 0:false,1:true
- unsigned short local_auto_ctl:1;//本地自动控制状态 0:false,1:true
- unsigned short remote_control:1;//远程控制状态 0:false,1:true
- }bits_val;
- }PWS1_STATUS10;
- typedef union
- {
- unsigned short value;
- struct {
- unsigned short reserv:4;//
- unsigned short droop_status:1;//下垂状态 0:false;1:true
- unsigned short quasi_sysnch_status:1;//准同期状态 0:false;1:true
- unsigned short reserv1:2;
- unsigned short ac_switch_closed:1;//交流开关闭合 0:open;1:close
- unsigned short alarm_status:1;//告警状态 0:false;1:true
- unsigned short faults_status:1;//故障状态 0:false;1:true
- unsigned short reserv2:1;//
- unsigned short pcs_init_status:1;//pcs初始化状态 0:unfinished;1:finished
- }bits_val;
- }PWS1_STATUS11;
- typedef union
- {
- unsigned short value;
- struct {
- unsigned short string1_bt_fully_chg:1;//0:false;1:true
- unsigned short string1_bt_empty_dhg:1;//0:false;1:true
- unsigned short string1_chg:1;//0:false;1:true
- unsigned short string1_dhg:1;//0:false;1:true
- unsigned short reserve:2;//0:false;1:true
- unsigned short string1_bt_constant_v_top_chg:1;//0:false;1:true
- unsigned short string1_bt_constant_v_float_chg:1;//0:false;1:true
- }bits_val;
- }PWS1_STATUS13;
- typedef union
- {
- unsigned short value;
- struct {
- unsigned short ac_module1_online:1;//ac模块组1在线,0:false;1:true
- unsigned short ac_module2_online:1;//ac模块组2在线,0:false;1:true
- unsigned short ac_module3_online:1;//ac模块组3在线,0:false;1:true
- unsigned short ac_module4_online:1;//ac模块组4在线,0:false;1:true
- unsigned short ac_module5_online:1;//ac模块组5在线,0:false;1:true
- unsigned short ac_module6_online:1;//ac模块组6在线,0:false;1:true
- unsigned short ac_module7_online:1;//ac模块组7在线,0:false;1:true
- unsigned short ac_module8_online:1;//ac模块组8在线,0:false;1:true
- unsigned short ac_module9_online:1;//ac模块组9在线,0:false;1:true
- unsigned short ac_module10_online:1;//ac模块组10在线,0:false;1:true
- unsigned short rack_func_board_online:1;//机架功能板在线,0:false;1:true
- }bits_val;
- }PWS1_STATUS25;
- typedef union
- {
- unsigned short value;
- struct {
- unsigned short ac_module1_running:1;//ac模块组1运行,0:false;1:true
- unsigned short ac_module2_running:1;//ac模块组2运行,0:false;1:true
- unsigned short ac_module3_running:1;//ac模块组3运行,0:false;1:true
- unsigned short ac_module4_running:1;//ac模块组4运行,0:false;1:true
- unsigned short ac_module5_running:1;//ac模块组5运行,0:false;1:true
- unsigned short ac_module6_running:1;//ac模块组6运行,0:false;1:true
- unsigned short ac_module7_running:1;//ac模块组7运行,0:false;1:true
- unsigned short ac_module8_running:1;//ac模块组8运行,0:false;1:true
- unsigned short ac_module9_running:1;//ac模块组9运行,0:false;1:true
- unsigned short ac_module10_running:1;//ac模块组10运行,0:false;1:true
- }bits_val;
- }PWS1_STATUS27;
- typedef union
- {
- unsigned short value;
- struct {
- unsigned short ac_module1_alarm:1;//ac模块组1报警,0:false;1:true
- unsigned short ac_module2_alarm:1;//ac模块组2报警,0:false;1:true
- unsigned short ac_module3_alarm:1;//ac模块组3报警,0:false;1:true
- unsigned short ac_module4_alarm:1;//ac模块组4报警,0:false;1:true
- unsigned short ac_module5_alarm:1;//ac模块组5报警,0:false;1:true
- unsigned short ac_module6_alarm:1;//ac模块组6报警,0:false;1:true
- unsigned short ac_module7_alarm:1;//ac模块组7报警,0:false;1:true
- unsigned short ac_module8_alarm:1;//ac模块组8报警,0:false;1:true
- unsigned short ac_module9_alarm:1;//ac模块组9报警,0:false;1:true
- unsigned short ac_module10_alarm:1;//ac模块组10报警,0:false;1:true
- unsigned short rack_func_board_alarm:1;//机架功能板报警,0:false;1:true
- }bits_val;
- }PWS1_STATUS29;
- typedef union
- {
- unsigned short value;
- struct {
- unsigned short ac_module1_fault:1;//ac模块组1故障,0:false;1:true
- unsigned short ac_module2_fault:1;//ac模块组2故障,0:false;1:true
- unsigned short ac_module3_fault:1;//ac模块组3故障,0:false;1:true
- unsigned short ac_module4_fault:1;//ac模块组4故障,0:false;1:true
- unsigned short ac_module5_fault:1;//ac模块组5故障,0:false;1:true
- unsigned short ac_module6_fault:1;//ac模块组6故障,0:false;1:true
- unsigned short ac_module7_fault:1;//ac模块组7故障,0:false;1:true
- unsigned short ac_module8_fault:1;//ac模块组8故障,0:false;1:true
- unsigned short ac_module9_fault:1;//ac模块组9故障,0:false;1:true
- unsigned short ac_module10_fault:1;//ac模块组10故障,0:false;1:true
- unsigned short rack_func_board_fault:1;//机架功能板故障,0:false;1:true
- }bits_val;
- }PWS1_STATUS31;
- struct pws1_t{
- //int chan_idx;
- char szinfo[32];
- char szmodel[32];
- int model;
- //int adr; // modbus rtu addr, by cfg
- struct tick_t bsytik;
- struct power_t pow;
- struct comm_t comm;
- //struct dac_t dac;
- struct statemachine_t sm;
- int cmd; // sm cmd
- //read only
- //ac_group fault and alarm
- PWS1_STATUS0 status0;//53000
- PWS1_STATUS1 status1;//53001
- PWS1_STATUS2 status2;//53002
- PWS1_STATUS3 status3;//53003
- PWS1_STATUS4 status4;//53004
- PWS1_STATUS9 status9;//53009
- PWS1_STATUS10 status10;//53010
- PWS1_STATUS11 status11;//53011
- PWS1_STATUS13 status13;//53013
- PWS1_STATUS25 status25;//53025
- PWS1_STATUS27 status27;//53027
- PWS1_STATUS29 status29;//53029
- PWS1_STATUS31 status31;//53031
- int runState;
- char szrunState[40];//
- int runMode;
- char szrunMode[40];
- int cmdSrc;
- char szcmdSrc[40];
- int DCbrokerState;
- char szDCbrokerState[40];
- int errstatus;
- int alarmstatus;
-
- double Uab;
- double Ubc;
- double Uca;
- double Ia;
- double Ib;
- double Ic;
- double grid_freq;
- double Pa;
- double Pb;
- double Pc;
- double Qa;
- double Qb;
- double Qc;
- double Sa;
- double Sb;
- double Sc;
- double Pfa;
- double Pfb;
- double Pfc;
- double module_temp;
- double ambient_temp;
- double Ps;
- double Qs;
- double Ss;
- double Pfs;
- unsigned int chg_accu_energy_ac;
- unsigned int dhg_accu_energy_ac;
- double operate_capacity_max;
- int chg_daily_energy_ac;
- int dhg_daily_energy_ac;
- double Pdc;
- double Udc;
- double Idc;
- unsigned int chg_accu_energy_dc;
- unsigned int dhg_accu_energy_dc;
- char CabSN[30];
- unsigned short MonitorSoftInerCode;
- unsigned short ACsoftInerCode;
- unsigned short U2softInerCode;
- unsigned short softwareV;
- //rw data---------------------------------------------------------------------------------------------------------------------------
- unsigned short grid_mode;//ongrid or off grid
- char szgrid_mode[20];
- unsigned short energy_dispatching_mode;
- char szEnergy_dispatching_mode[40];
- unsigned short start_up_mode;
- char szStart_up_mode[40];
- unsigned short reactive_power_cotrol_mode;
- double Pf_setpoint;// reg * 0.01
- double active_p_set;// reg * 0.1
- double reactive_p_set;// reg * 0.1
-
- unsigned short power_change_mode;
- char szPower_change_mode[40];
- unsigned short grid_reconnect_delay;
- double offgrid_ac_voltage_regulation;// reg * 0.01
- double offgrid_ac_freq_regulation;
- unsigned short FVRT_limit_fun;
- unsigned short FVRT_fun_enable;
- unsigned short anti_islanding_enable;
- unsigned short offgrid_ac_vol_startup_mode;
- char szOffgrid_ac_vol_startup_mode[40];
- unsigned short active_power_control_mode;
- char szActive_power_control_mode[40];
- double RR_normal_ramp_rate;
- double SS_soft_start_ramp_rate;
- unsigned short dc_control_mode;
- char szDc_control_mode[40];
- double dc_current_set;//reg*0.1
- double dc_pset;//reg*0.1
- double dc_lower_v_threshold;//reg * 0.1
- double dc_end_of_dhg_v;//reg * 0.1
- double top_chg_v;//reg * 0.1
- double end_of_chg_current;//reg * 0.1
-
- double max_chg_current;//reg * 0.1
- double max_dhg_current;//reg * 0.1
- double ov_region1_boundary;
- double ov_region1_trip_time;
- double ov_region2_boundary;
- double ov_region2_trip_time;
- double uv_region1_boundary;
- double uv_region1_trip_time;
- double uv_region2_boundary;
- double uv_region2_trip_time;
- double of_region1_boundary;
- double of_region1_trip_time;
- double of_region2_boundary;
- double of_region2_trip_time;
- double uf_region1_boundary;
- double uf_region1_trip_time;
- double uf_region2_boundary;
- double uf_region2_trip_time;
- unsigned short stop_insuation_detection;
- unsigned short year;
- unsigned short month;
- unsigned short day;
- unsigned short hour;
- unsigned short minute;
- unsigned short second;
- unsigned short bms_comm_time_out;
- unsigned short rs485_comm_time_out;
- unsigned short tcp_comm_time_out;
- unsigned short sys_start;
- unsigned short sys_stop;
- unsigned short sys_clear_faults;
- };
- extern struct pws1_t pws1[PWS1_NBR_MAX + 1];
- int pws1_init();
- int pws1_send_sm_cmd( int idx, int cmd );
- int pws1_get_ap( int idx );
- int pws1_get_errstat( int idx );
- double pws1_get_uab( int idx );
- double pws1_get_ubc( int idx );
- double pws1_get_uca( int idx );
- double pws1_get_ia( int idx );
- double pws1_get_ib( int idx );
- double pws1_get_ic( int idx );
- int pws1_get_state( int idx );
- int pws1_get_step( int idx );
- int pws1_get_tick( int idx );
- double pws1_get_tick_ave( int idx );
- double pws1_get_tick_cur( int idx );
- double pws1_get_tick_max( int idx );
- char* pws1_get_state_str( int idx );
- char* pws1_get_err_str( int idx );
- int pws1_chk_state( int idx, int stat );
- //int pws1_load_params( int idx );
- int pws1_set_aps( int idx, int aps);
- int pws1_get_aps(int idx);
- int pws1_reset_aps(int idx);
- int pws1_get_runstat( int idx );
- //char* pws1_get_runstat_str( int idx );
- int pws1_get_dcv( int idx );
- int pws1_get_dcc( int idx );
- //int pws1_get_dc_dfp( int idx );
- //int pws1_set_dev_startcmd( int idx );
- //int pws1_set_dev_stopcmd( int idx );
- //int pws1_set_dev_idlecmd( int idx );
- //int pws1_set_dev_resetcmd( int idx );
- int pws1_reset_bsytikchk(int idx);
- int pws1_is_bsytikchk_timeout(int idx);
- int pws1_set_bsytikchk_en(int idx, int val);
- int pws1_get_bsytikchk_en(int idx);
- int pws1_get_bsytikchk_from_host(int idx);
- int pws1_set_bsytik(int idx);
- int pws1_get_dev_aps( int idx );
- int pws1_get_cmd( int idx );
- void pws1_reset_cmd( int idx );
- int pws1_is_aps_changed(int idx);
- int pws1_get_last_aps(int idx);
- int pws1_set_dac_param_en(int idx, int val);
- //double pws1_get_gridv( int idx );
- //double pws1_get_gridc( int idx );
- int pws1_get_comm_st(int idx);
- int pws1_get_runmod( int idx );
- int pws1_get_chan_idx(int idx);
- int pws1_get_adr(int idx);
- char* pws1_get_comm_state_str(int idx);
- double pws1_get_dac_ave(int idx);
- double pws1_get_dac_cur(int idx);
- double pws1_get_dac_max(int idx);
- // int pws1_get_dc_ovp( int idx );
- // int pws1_get_dc_uvp( int idx );
- // int pws1_get_env_otp( int idx );
- // int pws1_get_reactor_otp( int idx );
- // int pws1_get_igbt_otp( int idx );
- double pws1_get_grid_freq( int idx );
- int pws1_get_dcp( int idx );
- // int pws1_get_breaker_ac( int idx );
- // int pws1_get_breaker_dc( int idx );
- // int pws1_get_dcbuf_cont( int idx );
- // unsigned short* pws1_get_faults(int idx);
- // unsigned short* pws1_get_warns(int idx);
- int pws1_get_dac_param_en(int idx);
- char* pws1_get_info_str(int idx);
- int pws1_get_dispatch_mode( int idx);
- int pws1_get_active_power_control_mode( int idx);
- int pws1_get_dhg_state( int idx);
- int pws1_get_chg_state( int idx);
- int pws1_get_tool_data(int idx,char* buf);
- int pws1_get_tbmqtt_main_data(int idx,char* buf);
- int pws1_get_tbmqtt_secondy_data(int idx,char* buf);
- int pws1_get_cloud_main_data(int cnt_idx,int idx,char* buf);
- int pws1_get_cloud_secondy_data(int cnt_idx,int idx,char* buf);
- int pws1_get_bkds_data(int idx,char* buf);
- #endif
|