|
@@ -175,7 +175,7 @@ static int slave_get_info(cascade_handle_t *cas)
|
|
|
info->ch[cnt].product_ch_status = tmp->product_ch_status;
|
|
info->ch[cnt].product_ch_status = tmp->product_ch_status;
|
|
|
info->ch[cnt].start_delay = tmp->product_ch_start_delay;
|
|
info->ch[cnt].start_delay = tmp->product_ch_start_delay;
|
|
|
info->ch[cnt].stop_delay = tmp->product_ch_stop_delay;
|
|
info->ch[cnt].stop_delay = tmp->product_ch_stop_delay;
|
|
|
- if (tmp->product_ch_type==TREE_AC_TYPE) {
|
|
|
|
|
|
|
+ if (tmp->product_ch_type==TREE_AC_TYPE||(tmp->product_ch_type==AC_SINGLE_B_TYPE&&__globalDeviceManage._global_device_info->product_pwr_type == SmartPDU_Tree_AC_One_B)) {
|
|
|
cnt2 = 0;
|
|
cnt2 = 0;
|
|
|
list_for_each_entry(tmp3, &tmp->list_Tree_AC, list_Tree_AC)
|
|
list_for_each_entry(tmp3, &tmp->list_Tree_AC, list_Tree_AC)
|
|
|
{
|
|
{
|
|
@@ -246,7 +246,7 @@ static int slave_save(cascade_handle_t *cas)
|
|
|
static int mb_init(cascade_handle_t *cas, char *path, int type, int addr, uint32_t baud)
|
|
static int mb_init(cascade_handle_t *cas, char *path, int type, int addr, uint32_t baud)
|
|
|
{
|
|
{
|
|
|
int r;
|
|
int r;
|
|
|
- r = g_modbus_init(&cas->m, path, baud, type, addr, (type>0)?"master":"slave", 0);
|
|
|
|
|
|
|
+ r = g_modbus_init(&cas->m, path, baud, type, addr, (type>0)?"master":"slave", 1);
|
|
|
if(r==0) {
|
|
if(r==0) {
|
|
|
if(type>0) {
|
|
if(type>0) {
|
|
|
LOGD("___ set slave addr: %d\n", addr);
|
|
LOGD("___ set slave addr: %d\n", addr);
|
|
@@ -686,7 +686,7 @@ static int power_clear(cascade_handle_t *cas)
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (tmp->product_ch_type==TREE_AC_TYPE) {
|
|
|
|
|
|
|
+ if (tmp->product_ch_type==TREE_AC_TYPE||(tmp->product_ch_type==AC_SINGLE_B_TYPE&&__globalDeviceManage._global_device_info->product_pwr_type == SmartPDU_Tree_AC_One_B)) {
|
|
|
if(list_empty(&tmp->list_Tree_AC)) {
|
|
if(list_empty(&tmp->list_Tree_AC)) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
@@ -712,6 +712,7 @@ static int power_clear(cascade_handle_t *cas)
|
|
|
static int power_add(cascade_handle_t *cas)
|
|
static int power_add(cascade_handle_t *cas)
|
|
|
{
|
|
{
|
|
|
int i,j,nTac_chn=0,r=-1;
|
|
int i,j,nTac_chn=0,r=-1;
|
|
|
|
|
+ GlobalDeviceManager *dm1=get_dm();
|
|
|
GlobalDeviceManager *dm2=get_dm2();
|
|
GlobalDeviceManager *dm2=get_dm2();
|
|
|
GlobalPowerManger *tmp=NULL;
|
|
GlobalPowerManger *tmp=NULL;
|
|
|
GlobalTreeACManager *tmp3=NULL;
|
|
GlobalTreeACManager *tmp3=NULL;
|
|
@@ -722,7 +723,7 @@ static int power_add(cascade_handle_t *cas)
|
|
|
power_clear(cas);
|
|
power_clear(cas);
|
|
|
|
|
|
|
|
dm2->_global_device_info->product_id = cur_dev_addr;
|
|
dm2->_global_device_info->product_id = cur_dev_addr;
|
|
|
-
|
|
|
|
|
|
|
+ //插入总数据
|
|
|
if(info->prod.product_pwr_type==SmartPDU_Tree_AC_Tree ||
|
|
if(info->prod.product_pwr_type==SmartPDU_Tree_AC_Tree ||
|
|
|
info->prod.product_pwr_type==SmartPDU_Tree_AC_One ||
|
|
info->prod.product_pwr_type==SmartPDU_Tree_AC_One ||
|
|
|
info->prod.product_pwr_type==SmartPDU_Tree_AC_One_B) {
|
|
info->prod.product_pwr_type==SmartPDU_Tree_AC_One_B) {
|
|
@@ -754,7 +755,7 @@ static int power_add(cascade_handle_t *cas)
|
|
|
nTac_chn++;
|
|
nTac_chn++;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ //单条数据插入
|
|
|
for(i=0; i<info->cnt; i++) {
|
|
for(i=0; i<info->cnt; i++) {
|
|
|
tmp = (GlobalPowerManger*)malloc(sizeof(GlobalPowerManger));
|
|
tmp = (GlobalPowerManger*)malloc(sizeof(GlobalPowerManger));
|
|
|
if(!tmp) {
|
|
if(!tmp) {
|
|
@@ -773,7 +774,7 @@ static int power_add(cascade_handle_t *cas)
|
|
|
tmp->product_ch_start_delay = info->ch[i].start_delay;
|
|
tmp->product_ch_start_delay = info->ch[i].start_delay;
|
|
|
tmp->product_ch_stop_delay = info->ch[i].stop_delay;
|
|
tmp->product_ch_stop_delay = info->ch[i].stop_delay;
|
|
|
|
|
|
|
|
- if(info->ch[i].product_ch_type==TREE_AC_TYPE) {
|
|
|
|
|
|
|
+ if(info->ch[i].product_ch_type==TREE_AC_TYPE||(tmp->product_ch_type==AC_SINGLE_B_TYPE&&info->prod.product_pwr_type==SmartPDU_Tree_AC_One_B)) {
|
|
|
INIT_LIST_HEAD(&tmp->list_Tree_AC);
|
|
INIT_LIST_HEAD(&tmp->list_Tree_AC);
|
|
|
for (j=0; j<3; j++) {
|
|
for (j=0; j<3; j++) {
|
|
|
tmp3 = (GlobalTreeACManager *)malloc(sizeof(GlobalTreeACManager));
|
|
tmp3 = (GlobalTreeACManager *)malloc(sizeof(GlobalTreeACManager));
|
|
@@ -799,7 +800,6 @@ static int power_add(cascade_handle_t *cas)
|
|
|
else {
|
|
else {
|
|
|
tmp->_PowerInfo = info->ch[i].pinfo[0].power;
|
|
tmp->_PowerInfo = info->ch[i].pinfo[0].power;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
list_add_tail(&tmp->list,&dm2->_globalPowerManger.list);
|
|
list_add_tail(&tmp->list,&dm2->_globalPowerManger.list);
|
|
|
}
|
|
}
|
|
|
cascade_unlock();
|
|
cascade_unlock();
|
|
@@ -839,7 +839,7 @@ static int power_update(cascade_handle_t *cas)
|
|
|
cnt = 0;
|
|
cnt = 0;
|
|
|
list_for_each_entry(tmp, &dm2->_globalPowerManger.list, list)
|
|
list_for_each_entry(tmp, &dm2->_globalPowerManger.list, list)
|
|
|
{
|
|
{
|
|
|
- if(tmp->product_ch_type==TREE_AC_TYPE) {
|
|
|
|
|
|
|
+ if(tmp->product_ch_type==TREE_AC_TYPE||(tmp->product_ch_type==AC_SINGLE_B_TYPE&&info->prod.product_pwr_type==SmartPDU_Tree_AC_One_B)) {
|
|
|
if(list_empty(&tmp->list_Tree_AC)) {
|
|
if(list_empty(&tmp->list_Tree_AC)) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
@@ -1252,7 +1252,13 @@ static int set_modbus(cascade_handle_t *cas, ModbusInfo_t *info)
|
|
|
return -1;
|
|
return -1;
|
|
|
}
|
|
}
|
|
|
cas->inited = 1;
|
|
cas->inited = 1;
|
|
|
-
|
|
|
|
|
|
|
+ if (cas->mInfo.product_modbus_type)
|
|
|
|
|
+ {
|
|
|
|
|
+ for (size_t i = 1; i < CASCADE_MAX; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ slave_rm(cas,i);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1328,6 +1334,15 @@ int cascade_get_dlist(dev_list_t *dl)
|
|
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
+/**
|
|
|
|
|
+ * @brief 释放级联设备列表
|
|
|
|
|
+ *
|
|
|
|
|
+ * 释放给定的级联设备列表(dev_list_t)中的 slave 成员所指向的内存。
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param dl 级联设备列表指针
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return 成功返回 0,失败返回 -1
|
|
|
|
|
+ */
|
|
|
int cascade_free_dlist(dev_list_t *dl)
|
|
int cascade_free_dlist(dev_list_t *dl)
|
|
|
{
|
|
{
|
|
|
if(!dl) {
|
|
if(!dl) {
|
|
@@ -1338,6 +1353,15 @@ int cascade_free_dlist(dev_list_t *dl)
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * @brief 级联请求
|
|
|
|
|
+ *
|
|
|
|
|
+ * 根据给定的命令数据执行级联请求,并返回执行结果。
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param cmd 命令数据指针
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return 执行结果,成功返回0,失败返回-1
|
|
|
|
|
+ */
|
|
|
int cascade_request(cmd_data_t *cmd)
|
|
int cascade_request(cmd_data_t *cmd)
|
|
|
{
|
|
{
|
|
|
int r=0;
|
|
int r=0;
|
|
@@ -1368,13 +1392,12 @@ int cascade_get_ch(_OverChnPwrAckInfo *ch)
|
|
|
GlobalTreeACManager *tmp3=NULL;
|
|
GlobalTreeACManager *tmp3=NULL;
|
|
|
_OverChnPwrAckInfo *pch=NULL;
|
|
_OverChnPwrAckInfo *pch=NULL;
|
|
|
GlobalDeviceManager* dm2=get_dm2();
|
|
GlobalDeviceManager* dm2=get_dm2();
|
|
|
-
|
|
|
|
|
list_for_each_entry(tmp, &dm2->_globalPowerManger.list, list)
|
|
list_for_each_entry(tmp, &dm2->_globalPowerManger.list, list)
|
|
|
{
|
|
{
|
|
|
- if (tmp->product_ch_type==TREE_AC_TYPE){
|
|
|
|
|
|
|
+ if (tmp->product_ch_type==TREE_AC_TYPE||(tmp->product_ch_type==AC_SINGLE_B_TYPE&&dm2->_global_device_info->product_pwr_type == SmartPDU_Tree_AC_One_B)){
|
|
|
int nStatus=-1;//-1则状态不变,0、1则是子状态
|
|
int nStatus=-1;//-1则状态不变,0、1则是子状态
|
|
|
//判断是否三相单输出情况下
|
|
//判断是否三相单输出情况下
|
|
|
- if(tmp->product_ch_type==TREE_AC_TYPE) {
|
|
|
|
|
|
|
+ if(tmp->product_ch_type==TREE_AC_TYPE||(tmp->product_ch_type==AC_SINGLE_B_TYPE&&dm2->_global_device_info->product_pwr_type == SmartPDU_Tree_AC_One_B)) {
|
|
|
list_for_each_entry(tmp3, &tmp->list_Tree_AC, list_Tree_AC) {
|
|
list_for_each_entry(tmp3, &tmp->list_Tree_AC, list_Tree_AC) {
|
|
|
if (2 == tmp3->product_ph_outputType &&1==tmp3->product_ph_outputStatus)
|
|
if (2 == tmp3->product_ph_outputType &&1==tmp3->product_ph_outputStatus)
|
|
|
{//单项并且状态为输出
|
|
{//单项并且状态为输出
|
|
@@ -1412,7 +1435,7 @@ int cascade_get_ch(_OverChnPwrAckInfo *ch)
|
|
|
pch->ph_consumption = tmp3->_PowerInfo.consumption;
|
|
pch->ph_consumption = tmp3->_PowerInfo.consumption;
|
|
|
pch->ph_outputType = tmp3->product_ph_outputType;
|
|
pch->ph_outputType = tmp3->product_ph_outputType;
|
|
|
pch->ph_outputStatus = tmp3->product_ph_outputStatus;
|
|
pch->ph_outputStatus = tmp3->product_ph_outputStatus;
|
|
|
- if (dm2->_global_device_info->product_pwr_type == SmartPDU_Tree_AC_One &&
|
|
|
|
|
|
|
+ if ((dm2->_global_device_info->product_pwr_type == SmartPDU_Tree_AC_One||dm2->_global_device_info->product_pwr_type == SmartPDU_Tree_AC_One_B) &&
|
|
|
tmp3->product_ph_outputType == 2 && tmp3->product_ph_outputStatus == 2) // 如果是单项输出并且则非输出通道数据为0
|
|
tmp3->product_ph_outputType == 2 && tmp3->product_ph_outputStatus == 2) // 如果是单项输出并且则非输出通道数据为0
|
|
|
{
|
|
{
|
|
|
// 3-1模式 单项状态,不输出则数据为空
|
|
// 3-1模式 单项状态,不输出则数据为空
|