|
@@ -22,12 +22,46 @@
|
|
|
#define ALL_SET_SWITCH_REG (5192)
|
|
#define ALL_SET_SWITCH_REG (5192)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+#ifdef NORTH_USER_SPECILS
|
|
|
|
|
+
|
|
|
|
|
+ #define SPAECIL_USER_TOTAL_CONSUMER (40 )
|
|
|
|
|
+ #define SPAECIL_USER_TOTAL_POWER (49 )
|
|
|
|
|
+ #define SPAECIL_USER_STATUS (100 )
|
|
|
|
|
+ #define SPAECIL_USER_STATUS_64 (103 )
|
|
|
|
|
+ #define SPAECIL_USER_WANING (2000)
|
|
|
|
|
+ #define SPAECIL_USER_FATAL_64 (2005)
|
|
|
|
|
+ #define SPAECIL_USER_SET_1 (3001)
|
|
|
|
|
+ #define SPAECIL_USER_SET_64 (3004)
|
|
|
|
|
+
|
|
|
|
|
+enum{
|
|
|
|
|
+ N_SPAECIL_CON = 0,
|
|
|
|
|
+ N_SPAECIL_STA,
|
|
|
|
|
+ N_SPAECIL_WANING,
|
|
|
|
|
+ N_SPAECIL_SET,
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+static mmap_modbus_t north_specil[] = {
|
|
|
|
|
+ [N_SPAECIL_CON ]{.offset = SPAECIL_USER_TOTAL_CONSUMER },
|
|
|
|
|
+ [N_SPAECIL_STA ]{.offset = SPAECIL_USER_STATUS },
|
|
|
|
|
+ [N_SPAECIL_WANING ]{.offset = SPAECIL_USER_WANING },
|
|
|
|
|
+ [N_SPAECIL_SET ]{.offset = SPAECIL_USER_SET_1 },
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
|
|
|
enum{
|
|
enum{
|
|
|
TYPE_U16,
|
|
TYPE_U16,
|
|
|
TYPE_U32
|
|
TYPE_U32
|
|
|
};
|
|
};
|
|
|
-
|
|
|
|
|
|
|
+enum{
|
|
|
|
|
+ NO_OPPERATION = 0,
|
|
|
|
|
+ OPEN,
|
|
|
|
|
+ CLOSE,
|
|
|
|
|
+};
|
|
|
|
|
|
|
|
enum {
|
|
enum {
|
|
|
DS_R_DEV_CHN = 0,
|
|
DS_R_DEV_CHN = 0,
|
|
@@ -96,6 +130,7 @@ static inline GlobalDeviceManager* get_dm2(void)
|
|
|
return &__globalDeviceManage2;
|
|
return &__globalDeviceManage2;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
static mmap_modbus_t modbus_single[] = {
|
|
static mmap_modbus_t modbus_single[] = {
|
|
|
[DS_R_DEV_CHN ]{.offset = DEV_CHN_REG },
|
|
[DS_R_DEV_CHN ]{.offset = DEV_CHN_REG },
|
|
|
[DS_R_OUT_INFO ]{.offset = OUT_INFO_REG },
|
|
[DS_R_OUT_INFO ]{.offset = OUT_INFO_REG },
|
|
@@ -178,6 +213,7 @@ int cascade_slave_init(void)
|
|
|
free(sh->map);
|
|
free(sh->map);
|
|
|
sh->map = NULL;
|
|
sh->map = NULL;
|
|
|
}
|
|
}
|
|
|
|
|
+#ifndef NORTH_USER_SPECILS
|
|
|
sh->map = modbus_mapping_new_start_address(0,0,0,0,TREE_DEV_CHN_REG,7000,0,0);
|
|
sh->map = modbus_mapping_new_start_address(0,0,0,0,TREE_DEV_CHN_REG,7000,0,0);
|
|
|
modbus_three[TREE_R_DEV_CHN ].addr = &mgr->triphasic_mmap->dev_chn;
|
|
modbus_three[TREE_R_DEV_CHN ].addr = &mgr->triphasic_mmap->dev_chn;
|
|
|
modbus_three[TREE_R_INPUT_ALL_A ].addr = &mgr->triphasic_mmap->i_total.pw_i_total[0];
|
|
modbus_three[TREE_R_INPUT_ALL_A ].addr = &mgr->triphasic_mmap->i_total.pw_i_total[0];
|
|
@@ -196,6 +232,13 @@ int cascade_slave_init(void)
|
|
|
modbus_three[TREE_W_CLOSE_DELAY ].addr = &mgr->triphasic_mmap->set_chn_close_delay;
|
|
modbus_three[TREE_W_CLOSE_DELAY ].addr = &mgr->triphasic_mmap->set_chn_close_delay;
|
|
|
modbus_three[TREE_W_CHN_SWITCH_STA ].addr = &mgr->triphasic_mmap->set_chn_switch_status;
|
|
modbus_three[TREE_W_CHN_SWITCH_STA ].addr = &mgr->triphasic_mmap->set_chn_switch_status;
|
|
|
modbus_three[TREE_W_ALL_CHN_STA ].addr = &mgr->triphasic_mmap->set_chn_all_switch_status;
|
|
modbus_three[TREE_W_ALL_CHN_STA ].addr = &mgr->triphasic_mmap->set_chn_all_switch_status;
|
|
|
|
|
+#else
|
|
|
|
|
+ sh->map = modbus_mapping_new_start_address(0,0,0,0,SPAECIL_USER_TOTAL_CONSUMER,4000,0,0);
|
|
|
|
|
+ north_specil[N_SPAECIL_CON ].addr = &mgr->north_user.total_elec_energy;
|
|
|
|
|
+ north_specil[N_SPAECIL_STA ].addr = &mgr->north_user.status_1_16;
|
|
|
|
|
+ north_specil[N_SPAECIL_WANING ].addr = &mgr->north_user.total_wanning;
|
|
|
|
|
+ north_specil[N_SPAECIL_SET ].addr = &mgr->north_user.set_1_16 ;
|
|
|
|
|
+#endif
|
|
|
printf("triphasic address init 6000\n");
|
|
printf("triphasic address init 6000\n");
|
|
|
//return -1;
|
|
//return -1;
|
|
|
}
|
|
}
|
|
@@ -262,7 +305,53 @@ static void slave_read(slave_handle_t *sh, uint32_t addr,int num,uint32_t reg_ty
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
void cascade_slave_read(uint32_t addr,uint32_t lenth)
|
|
void cascade_slave_read(uint32_t addr,uint32_t lenth)
|
|
|
|
|
+#ifdef NORTH_USER_SPECILS
|
|
|
|
|
+{
|
|
|
|
|
+ slave_handle_t *sh=&slHandle;
|
|
|
|
|
+ GlobalDeviceManager* mgr=get_dm();
|
|
|
|
|
+ /*
|
|
|
|
|
+ #define SPAECIL_USER_TOTAL_CONSUMER (40 )
|
|
|
|
|
+ #define SPAECIL_USER_TOTAL_POWER (49 )
|
|
|
|
|
+ #define SPAECIL_USER_STATUS (100 )
|
|
|
|
|
+ #define SPAECIL_USER_STATUS_64 (103 )
|
|
|
|
|
+ #define SPAECIL_USER_WANING (2000)
|
|
|
|
|
+ #define SPAECIL_USER_FATAL_64 (2005)
|
|
|
|
|
+ #define SPAECIL_USER_SET_1 (3001)
|
|
|
|
|
+ #define SPAECIL_USER_SET_64 (3004)
|
|
|
|
|
+ */
|
|
|
|
|
+ switch(addr)
|
|
|
|
|
+ {
|
|
|
|
|
+ case SPAECIL_USER_TOTAL_CONSUMER ... SPAECIL_USER_TOTAL_POWER:
|
|
|
|
|
+ {
|
|
|
|
|
+ int step = addr - SPAECIL_USER_TOTAL_CONSUMER;
|
|
|
|
|
+ uint16_t *map_addr = (uint16_t *)&(sh->map->tab_registers[addr - SPAECIL_USER_TOTAL_CONSUMER]);
|
|
|
|
|
+ uint16_t *offset_addr = (uint16_t*)(north_specil[N_SPAECIL_CON].addr) + step;
|
|
|
|
|
+ memcpy(map_addr,offset_addr,lenth*2);
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ case SPAECIL_USER_STATUS ... SPAECIL_USER_STATUS_64:
|
|
|
|
|
+ {
|
|
|
|
|
+ int step = addr - SPAECIL_USER_STATUS;
|
|
|
|
|
+ uint16_t *map_addr = (uint16_t *)&(sh->map->tab_registers[addr - SPAECIL_USER_TOTAL_CONSUMER]);
|
|
|
|
|
+ uint16_t *offset_addr = (uint16_t*)(north_specil[N_SPAECIL_STA].addr) + step;
|
|
|
|
|
+ memcpy(map_addr,offset_addr,lenth*2);
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ case SPAECIL_USER_WANING ... SPAECIL_USER_FATAL_64:
|
|
|
|
|
+ {
|
|
|
|
|
+ int step = addr - SPAECIL_USER_WANING;
|
|
|
|
|
+ uint16_t *map_addr = (uint16_t *)&(sh->map->tab_registers[addr - SPAECIL_USER_TOTAL_CONSUMER]);
|
|
|
|
|
+ uint16_t *offset_addr = (uint16_t*)(north_specil[N_SPAECIL_WANING].addr) + step;
|
|
|
|
|
+ memcpy(map_addr,offset_addr,lenth*2);
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ default:
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+#else
|
|
|
{
|
|
{
|
|
|
slave_handle_t *sh=&slHandle;
|
|
slave_handle_t *sh=&slHandle;
|
|
|
|
|
|
|
@@ -348,9 +437,176 @@ void cascade_slave_read(uint32_t addr,uint32_t lenth)
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
void cascade_slave_write(uint32_t addr, uint16_t val)
|
|
void cascade_slave_write(uint32_t addr, uint16_t val)
|
|
|
|
|
+#ifdef NORTH_USER_SPECILS
|
|
|
|
|
+{
|
|
|
|
|
+ GlobalDeviceManager* mgr=get_dm();
|
|
|
|
|
+ if(mgr->_globalDevInfo.product.pwr_type == SmartPDU_AC
|
|
|
|
|
+ || mgr->_globalDevInfo.product.pwr_type == SmartPDU_DC)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ }else
|
|
|
|
|
+ {
|
|
|
|
|
+ switch(addr)
|
|
|
|
|
+ {
|
|
|
|
|
+ case SPAECIL_USER_SET_1 ... SPAECIL_USER_SET_64:
|
|
|
|
|
+ {
|
|
|
|
|
+ int step = addr - SPAECIL_USER_SET_1;
|
|
|
|
|
+ uint16_t * offset_addr = (uint16_t*)(north_specil[SPAECIL_USER_STATUS].addr + step);
|
|
|
|
|
+ uint16_t buff[16] = {0};
|
|
|
|
|
+ if(*offset_addr != val)
|
|
|
|
|
+ {
|
|
|
|
|
+ uint16_t data = (*offset_addr ^ val);
|
|
|
|
|
+ for(int i = 0; i < 16;i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ if(data & (1 << i))
|
|
|
|
|
+ {
|
|
|
|
|
+ //buff[i] = 1;
|
|
|
|
|
+ if(val & (1 << i))
|
|
|
|
|
+ {
|
|
|
|
|
+ // open
|
|
|
|
|
+ buff[i] = OPEN;
|
|
|
|
|
+ }else
|
|
|
|
|
+ {
|
|
|
|
|
+ // close
|
|
|
|
|
+ buff[i] = CLOSE;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ for(int i = 0; i < 16;i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ if(buff[i])
|
|
|
|
|
+ {
|
|
|
|
|
+ int start_chn = step*16 + i;
|
|
|
|
|
+ GlobalPowerManger* _globalPowerMangerTemp = NULL ;
|
|
|
|
|
+ list_for_each_entry(_globalPowerMangerTemp, &__globalDeviceManage._globalPowerManger.list, list){
|
|
|
|
|
+ if(_globalPowerMangerTemp==NULL)
|
|
|
|
|
+ break;
|
|
|
|
|
+ if((start_chn+1) == _globalPowerMangerTemp->product_ch_id)
|
|
|
|
|
+ {
|
|
|
|
|
+ int t_ac_CtrlType=0;
|
|
|
|
|
+ int nRet = 0;
|
|
|
|
|
+ uint16_t write_data = buff[i] == OPEN ? 1 : 0;
|
|
|
|
|
+ _globalPowerMangerTemp->product_ch_status = write_data;
|
|
|
|
|
+
|
|
|
|
|
+ GlobalTreeACManager *_globalTACManager = NULL;
|
|
|
|
|
+ list_for_each_entry(_globalTACManager, &_globalPowerMangerTemp->list_Tree_AC, list_Tree_AC)
|
|
|
|
|
+ {
|
|
|
|
|
+ t_ac_CtrlType=_globalTACManager->product_ph_outputType;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (t_ac_CtrlType == 2&&(__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_Tree
|
|
|
|
|
+ ||__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One
|
|
|
|
|
+ ||__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One_B))
|
|
|
|
|
+ {
|
|
|
|
|
+ if(_globalPowerMangerTemp->product_ch_type == AC_SINGLE_S_TYPE || _globalPowerMangerTemp->product_ch_type == AC_SINGLE_B_TYPE)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ if (write_data == 1)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (_globalPowerMangerTemp->global_over_manager.product_vol_upper_enable == 1)
|
|
|
|
|
+ write_data |= ENABLE_TAC_V_UP;
|
|
|
|
|
+ if (_globalPowerMangerTemp->global_over_manager.product_vol_lower_enable == 1)
|
|
|
|
|
+ write_data |= ENABLE_TAC_V_DOWN;
|
|
|
|
|
+ if (_globalPowerMangerTemp->global_over_manager.product_cur_upper_enable == 1)
|
|
|
|
|
+ write_data |= ENABLE_TAC_A_UP;
|
|
|
|
|
+ if (_globalPowerMangerTemp->global_over_manager.product_pwr_upper_enable == 1)
|
|
|
|
|
+ write_data |= ENABLE_TAC_W_UP;
|
|
|
|
|
+ if (_globalPowerMangerTemp->global_over_manager.product_pwrcon_upper_enable == 1)
|
|
|
|
|
+ write_data |= ENABLE_TAC_P_UP;
|
|
|
|
|
+ }
|
|
|
|
|
+ g_switch_set_ac_single_s_chn_ctrl(&__globalDeviceManage._globalRelaySampManger, _globalPowerMangerTemp->product_saddr,
|
|
|
|
|
+ (_globalPowerMangerTemp->product_ch_addr- 1), write_data);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ unsigned short phsts=0;
|
|
|
|
|
+ list_for_each_entry(_globalTACManager, &_globalPowerMangerTemp->list_Tree_AC, list_Tree_AC)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (write_data == 1 && _globalTACManager->product_ph_outputStatus==1)
|
|
|
|
|
+ {
|
|
|
|
|
+ phsts=1;
|
|
|
|
|
+ if (_globalTACManager->global_over_manager.product_vol_upper_enable == 1)
|
|
|
|
|
+ phsts |= ENABLE_TAC_V_UP;
|
|
|
|
|
+ if (_globalTACManager->global_over_manager.product_vol_lower_enable == 1)
|
|
|
|
|
+ phsts |= ENABLE_TAC_V_DOWN;
|
|
|
|
|
+ if (_globalTACManager->global_over_manager.product_cur_upper_enable == 1)
|
|
|
|
|
+ phsts |= ENABLE_TAC_A_UP;
|
|
|
|
|
+ if (_globalTACManager->global_over_manager.product_pwr_upper_enable == 1)
|
|
|
|
|
+ phsts |= ENABLE_TAC_W_UP;
|
|
|
|
|
+ if (_globalTACManager->global_over_manager.product_pwrcon_upper_enable == 1)
|
|
|
|
|
+ phsts |= ENABLE_TAC_P_UP;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ phsts=0;
|
|
|
|
|
+ }
|
|
|
|
|
+ nRet= g_switch_set_t_ac_phchn_ctrl(&__globalDeviceManage._globalRelaySampManger,
|
|
|
|
|
+ _globalTACManager->product_saddr,
|
|
|
|
|
+ _globalTACManager->product_ch_addr - 1,
|
|
|
|
|
+ phsts);
|
|
|
|
|
+ }
|
|
|
|
|
+ g_switch_set_t_ac_chn_NF_ctrl(&__globalDeviceManage._globalRelaySampManger, _globalPowerMangerTemp->product_saddr, _globalPowerMangerTemp->product_ch_addr, write_data);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }else
|
|
|
|
|
+ {
|
|
|
|
|
+ if (write_data == 1)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (_globalPowerMangerTemp->global_over_manager.product_vol_upper_enable == 1)
|
|
|
|
|
+ write_data |= ENABLE_TAC_V_UP;
|
|
|
|
|
+ if (_globalPowerMangerTemp->global_over_manager.product_vol_lower_enable == 1)
|
|
|
|
|
+ write_data |= ENABLE_TAC_V_DOWN;
|
|
|
|
|
+ if (_globalPowerMangerTemp->global_over_manager.product_cur_upper_enable == 1)
|
|
|
|
|
+ write_data |= ENABLE_TAC_A_UP;
|
|
|
|
|
+ if (_globalPowerMangerTemp->global_over_manager.product_pwr_upper_enable == 1)
|
|
|
|
|
+ write_data |= ENABLE_TAC_W_UP;
|
|
|
|
|
+ if (_globalPowerMangerTemp->global_over_manager.product_pwrcon_upper_enable == 1)
|
|
|
|
|
+ write_data |= ENABLE_TAC_P_UP;
|
|
|
|
|
+ }
|
|
|
|
|
+ /*
|
|
|
|
|
+ if (isgroup)
|
|
|
|
|
+ {
|
|
|
|
|
+ sts |= ENABLE_TAC_STIME;
|
|
|
|
|
+ sts |= ENABLE_TAC_ETIME;
|
|
|
|
|
+ }*/
|
|
|
|
|
+ if (__globalDeviceManage._globalDevInfo.product.pwr_type == SmartPDU_Tree_AC_One)
|
|
|
|
|
+ {
|
|
|
|
|
+ g_switch_set_t_ac_phchn_ctrl(&__globalDeviceManage._globalRelaySampManger,
|
|
|
|
|
+ _globalPowerMangerTemp->product_saddr,
|
|
|
|
|
+ _globalPowerMangerTemp->product_ch_addr - 1,
|
|
|
|
|
+ write_data);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ g_switch_set_t_ac_chn_ctrl(&__globalDeviceManage._globalRelaySampManger,
|
|
|
|
|
+ _globalPowerMangerTemp->product_saddr,
|
|
|
|
|
+ _globalPowerMangerTemp->product_ch_addr - 1,
|
|
|
|
|
+ write_data);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ ////////////////////////////////////////////////////////////////
|
|
|
|
|
+ // if(buff[i] == OPEN)
|
|
|
|
|
+ // {
|
|
|
|
|
+ // *offset_addr |= (1 << i);
|
|
|
|
|
+ // }else
|
|
|
|
|
+ // {
|
|
|
|
|
+ // *offset_addr &= ~(1 << i);
|
|
|
|
|
+ // }
|
|
|
|
|
+ buff[i] = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ default:
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+#else
|
|
|
{
|
|
{
|
|
|
slave_handle_t *sh=&slHandle;
|
|
slave_handle_t *sh=&slHandle;
|
|
|
GlobalDeviceManager* mgr=get_dm();
|
|
GlobalDeviceManager* mgr=get_dm();
|
|
@@ -678,4 +934,4 @@ void cascade_slave_write(uint32_t addr, uint16_t val)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+#endif
|