|
|
@@ -73,7 +73,7 @@ static int slave_init(cascade_handle_t *cas)
|
|
|
}
|
|
|
static int slave_add(cascade_handle_t *cas, int addr)
|
|
|
{
|
|
|
- if(addr<=0) {
|
|
|
+ if(addr<0 || addr>CASCADE_MAX) {
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
@@ -83,7 +83,7 @@ static int slave_add(cascade_handle_t *cas, int addr)
|
|
|
}
|
|
|
static int slave_rm(cascade_handle_t *cas, int addr)
|
|
|
{
|
|
|
- if(addr<=0) {
|
|
|
+ if(addr<0 || addr>CASCADE_MAX) {
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
@@ -95,7 +95,7 @@ static int slave_rm(cascade_handle_t *cas, int addr)
|
|
|
static int slave_cnt(cascade_handle_t *cas)
|
|
|
{
|
|
|
int i,cnt=0;
|
|
|
- for(i=1; i<=CASCADE_MAX; i++) {
|
|
|
+ for(i=0; i<=CASCADE_MAX; i++) {
|
|
|
if(cas->slaves[i].addr>0) {
|
|
|
cnt++;
|
|
|
}
|
|
|
@@ -642,13 +642,14 @@ static void power_init(void)
|
|
|
GlobalDeviceManager *dm2=get_dm2();
|
|
|
|
|
|
dm2->_global_device_info = (GlobalDeviceInfo*)malloc(sizeof(GlobalDeviceInfo));
|
|
|
-
|
|
|
- dm2->_global_device_info->product_pwr_type = SmartPDU_AC;
|
|
|
- dm2->_global_device_info->product_id = 1;
|
|
|
- //dm2->_global_device_info->product_type_id = 2;
|
|
|
- strcpy(dm2->_global_device_info->product_name, dm->_global_device_info->product_name);
|
|
|
- strcpy(dm2->_global_device_info->product_number, dm->_global_device_info->product_number);
|
|
|
- strcpy(dm2->_global_device_info->product_status, dm->_global_device_info->product_status);
|
|
|
+ if(dm2->_global_device_info) {
|
|
|
+ dm2->_global_device_info->product_pwr_type = dm->_global_device_info->product_pwr_type;
|
|
|
+ dm2->_global_device_info->product_id = dm->_global_device_info->product_id;
|
|
|
+ //dm2->_global_device_info->product_type_id = 2;
|
|
|
+ strcpy(dm2->_global_device_info->product_name, dm->_global_device_info->product_name);
|
|
|
+ strcpy(dm2->_global_device_info->product_number, dm->_global_device_info->product_number);
|
|
|
+ strcpy(dm2->_global_device_info->product_status, dm->_global_device_info->product_status);
|
|
|
+ }
|
|
|
|
|
|
INIT_LIST_HEAD(&dm2->_globalPowerManger.list);
|
|
|
}
|
|
|
@@ -1027,7 +1028,7 @@ static int master_query(cascade_handle_t *cas)
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
- LOGD("____ master query cmd: %d\n", cmd->cmd);
|
|
|
+ //LOGD("____ master query cmd: %d\n", cmd->cmd);
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
@@ -1213,6 +1214,7 @@ int cascade_get_dlist(dev_list_t *dl)
|
|
|
}
|
|
|
dl->slave = sl;
|
|
|
dl->cnt = cnt;
|
|
|
+ LOGD("____dev cnt: %d\n", cnt);
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
@@ -1249,6 +1251,104 @@ int cascade_request(cmd_data_t *cmd)
|
|
|
}
|
|
|
|
|
|
|
|
|
+int cascade_get(_OverChnPwrAckInfo *chInfo)
|
|
|
+{
|
|
|
+ GlobalPowerManger* pwr=NULL;
|
|
|
+ _OverChnPwrAckInfo *pch=NULL;
|
|
|
+ GlobalDeviceManager* dm2=get_dm2();
|
|
|
+
|
|
|
+ list_for_each_entry(pwr, &dm2->_globalPowerManger.list, list)
|
|
|
+ {
|
|
|
+ if (pwr->product_ch_type==TREE_AC_TYPE)
|
|
|
+ {
|
|
|
+ GlobalTreeACManager* _TreeACTemp=NULL;
|
|
|
+ int nStatus=-1;//-1则状态不变,0、1则是子状态
|
|
|
+ //判断是否三相单输出情况下
|
|
|
+ if(pwr->product_ch_type==TREE_AC_TYPE) {
|
|
|
+ list_for_each_entry(_TreeACTemp, &pwr->list_Tree_AC, list_Tree_AC) {
|
|
|
+ if (2 == _TreeACTemp->product_ph_outputType &&1==_TreeACTemp->product_ph_outputStatus)
|
|
|
+ {//单项并且状态为输出
|
|
|
+ nStatus=_TreeACTemp->_PowerInfo.status;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ list_for_each_entry(_TreeACTemp, &pwr->list_Tree_AC, list_Tree_AC)
|
|
|
+ {
|
|
|
+ pch = (_OverChnPwrAckInfo *)malloc(sizeof(_OverChnPwrAckInfo));
|
|
|
+ if (pch == NULL) {
|
|
|
+ LOGE("pch malloc err.\n");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ pch->product_name = dm2->_global_device_info->product_name;
|
|
|
+ pch->product_number = dm2->_global_device_info->product_number;
|
|
|
+ pch->product_id = dm2->_global_device_info->product_id;
|
|
|
+ pch->productChName = pwr->product_ch_name;
|
|
|
+ pch->productChId = pwr->product_ch_id;
|
|
|
+ pch->status = pwr->_PowerInfo.status;
|
|
|
+ pch->voltage = pwr->_PowerInfo.voltage;
|
|
|
+ pch->current = pwr->_PowerInfo.current;
|
|
|
+ pch->power = pwr->_PowerInfo.power;
|
|
|
+ pch->freq = pwr->_PowerInfo.freq;
|
|
|
+ pch->consumption = pwr->_PowerInfo.consumption;
|
|
|
+ pch->factor = pwr->_PowerInfo.factor;
|
|
|
+ pch->product_ch_start_delay = pwr->product_ch_start_delay;
|
|
|
+ pch->product_ch_stop_delay = pwr->product_ch_stop_delay;
|
|
|
+ pch->product_type=pwr->product_ch_type;
|
|
|
+ pch->product_phType = _TreeACTemp->product_ph_type;
|
|
|
+ pch->ph_voltage = _TreeACTemp->_PowerInfo.voltage;
|
|
|
+ pch->ph_current = _TreeACTemp->_PowerInfo.current;
|
|
|
+ pch->ph_power = _TreeACTemp->_PowerInfo.power;
|
|
|
+ pch->ph_consumption = _TreeACTemp->_PowerInfo.consumption;
|
|
|
+ pch->ph_outputType = _TreeACTemp->product_ph_outputType;
|
|
|
+ pch->ph_outputStatus = _TreeACTemp->product_ph_outputStatus;
|
|
|
+ if (dm2->_global_device_info->product_pwr_type == SmartPDU_Tree_AC_One &&
|
|
|
+ _TreeACTemp->product_ph_outputType == 2 && _TreeACTemp->product_ph_outputStatus == 2) // 如果是单项输出并且则非输出通道数据为0
|
|
|
+ {
|
|
|
+ // 3-1模式 单项状态,不输出则数据为空
|
|
|
+ pch->ph_voltage = 0.0;
|
|
|
+ pch->ph_current = 0.0;
|
|
|
+ pch->ph_power = 0.0;
|
|
|
+ pch->ph_consumption = 0.0;
|
|
|
+ }
|
|
|
+ if (nStatus>=0)
|
|
|
+ {
|
|
|
+ pch->status = nStatus;
|
|
|
+ }else {
|
|
|
+ pch->status = pwr->_PowerInfo.status;
|
|
|
+ }
|
|
|
+ list_add_tail(&pch->list, &chInfo->list);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ pch = (_OverChnPwrAckInfo *)malloc(sizeof(_OverChnPwrAckInfo));
|
|
|
+ if (pch == NULL)
|
|
|
+ {
|
|
|
+ log_e("_overChnPwrBackInfoTemp malloc err.");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ // 填数据
|
|
|
+ pch->product_name = dm2->_global_device_info->product_name;
|
|
|
+ pch->product_number = dm2->_global_device_info->product_number;
|
|
|
+ pch->product_id = dm2->_global_device_info->product_id;
|
|
|
+ pch->productChName = pwr->product_ch_name;
|
|
|
+ pch->productChId = pwr->product_ch_id;
|
|
|
+ pch->status = pwr->_PowerInfo.status;
|
|
|
+ pch->voltage = pwr->_PowerInfo.voltage;
|
|
|
+ pch->current = pwr->_PowerInfo.current;
|
|
|
+ pch->power = pwr->_PowerInfo.power;
|
|
|
+ pch->freq = pwr->_PowerInfo.freq;
|
|
|
+ pch->consumption = pwr->_PowerInfo.consumption;
|
|
|
+ pch->factor = pwr->_PowerInfo.factor;
|
|
|
+ pch->product_ch_start_delay = pwr->product_ch_start_delay;
|
|
|
+ pch->product_ch_stop_delay = pwr->product_ch_stop_delay;
|
|
|
+ list_add_tail(&pch->list, &chInfo->list);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
int cascade_lock(void)
|
|
|
{
|
|
|
cascade_handle_t *cas=&casHandle;
|