|
|
@@ -51,11 +51,11 @@ static int set_ch(power_ch_t *pch)
|
|
|
}
|
|
|
static int set_open_delay(power_ch_t *pch)
|
|
|
{
|
|
|
- return power_set_start_delay(pch);
|
|
|
+ return power_set_open_delay(pch);
|
|
|
}
|
|
|
static int set_close_delay(power_ch_t *pch)
|
|
|
{
|
|
|
- return power_set_stop_delay(pch);
|
|
|
+ return power_set_close_delay(pch);
|
|
|
}
|
|
|
static int set_kb_value(power_ch_t *pch)
|
|
|
{
|
|
|
@@ -172,7 +172,7 @@ static int get_key(power_handle_t *h, uint8_t addr, board_key_t *key)
|
|
|
int i,r;
|
|
|
uint16_t tmp[2];
|
|
|
|
|
|
- if(h->prod->pwr_type==PDU_AC_I1O1 || h->prod->pwr_type==PDU_AC_I3O1_H) {
|
|
|
+ if(h->prod->type==PDU_AC_I1O1 || h->prod->type==PDU_AC_I3O1_H) {
|
|
|
r = read_reg(h, addr, POWER_AC_GET_INFO, tmp, 1);
|
|
|
if(r==0) {
|
|
|
key->type = (tmp[0]>>8)&0xFF;
|
|
|
@@ -276,7 +276,7 @@ int power_set_kb_value(power_handle_t *h, int type, int addr, kb_val_t *kv)
|
|
|
static uint8_t get_ch_idx(board_data_t *pbrd, uint8_t sch)
|
|
|
{
|
|
|
uint8_t ch=0;
|
|
|
- uint8_t pwr_type=paras_get()->prod.pwr_type;
|
|
|
+ uint8_t pwr_type=paras_get()->prod.type;
|
|
|
if(pbrd->type==TREE_AC_TYPE) {
|
|
|
if(pwr_type == PDU_AC_I3O3) {
|
|
|
ch = pbrd->ch0 + sch/3;
|
|
|
@@ -298,7 +298,7 @@ static int threshold_proc(power_handle_t *h, board_data_t *pbrd)
|
|
|
|
|
|
for (i=0; i<pbrd->chs; i++) {
|
|
|
pch = &pbrd->pch[i];
|
|
|
- if(h->prod->pwr_type==PDU_AC_I3O3) {
|
|
|
+ if(h->prod->type==PDU_AC_I3O3) {
|
|
|
times = 3;
|
|
|
|
|
|
//设置为输出三相且三相有缺失则报警
|
|
|
@@ -379,7 +379,7 @@ static int total_proc(power_handle_t *h)
|
|
|
board_data_t *pbrd=NULL;
|
|
|
|
|
|
lock_on(h->lck);
|
|
|
- if(h->prod->pwr_type==PDU_AC_I3O3) times = 3;
|
|
|
+ if(h->prod->type==PDU_AC_I3O3) times = 3;
|
|
|
for(i=0; i<h->brd_max; i++) {
|
|
|
if(h->pbrd[i]) {
|
|
|
for (j=0; i<h->pbrd[i]->chs; i++) {
|
|
|
@@ -397,7 +397,7 @@ static int total_proc(power_handle_t *h)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- h->ttl.type = h->prod->pwr_type;
|
|
|
+ h->ttl.type = h->prod->type;
|
|
|
for(k=0; k<times; k++) {
|
|
|
h->ttl.total[k].voltage = tmp[k].voltage;
|
|
|
h->ttl.total[k].current = tmp[k].current;
|
|
|
@@ -578,7 +578,7 @@ static int board_read(power_handle_t *h, board_data_t *pbrd)
|
|
|
for (i=0; i<pbrd->chs; i++) {
|
|
|
int Index = i * 16;
|
|
|
|
|
|
- if(h->prod->pwr_type==PDU_AC_I3O3) {
|
|
|
+ if(h->prod->type==PDU_AC_I3O3) {
|
|
|
int ch_idx = pbrd->ch0+i/3;
|
|
|
int ph_idx = i%3;
|
|
|
pwr = &pbrd->pch[ch_idx].power[ph_idx];
|
|
|
@@ -727,7 +727,6 @@ static void power_thread(void *arg)
|
|
|
thread_handle_t *th=(thread_handle_t*)arg;
|
|
|
power_handle_t *h=(power_handle_t*)th->attr->arg;;
|
|
|
|
|
|
- power_scan();
|
|
|
while(th->quit==0) {
|
|
|
board_query(h);
|
|
|
sleep(1);
|
|
|
@@ -761,6 +760,7 @@ int power_init(void)
|
|
|
h->brd_max = POWER_BOARD_MAX;
|
|
|
h->prod = &p->prod;
|
|
|
|
|
|
+ power_scan();
|
|
|
thread_start(THREAD_ID_POWER, power_thread, h);
|
|
|
return 0;
|
|
|
}
|
|
|
@@ -835,7 +835,7 @@ static int power_map(power_handle_t *h, int chs)
|
|
|
{
|
|
|
int i,j,r,idx=1;
|
|
|
board_data_t *pbrd=NULL;
|
|
|
- uint8_t pwr_type=paras_get()->prod.pwr_type;
|
|
|
+ uint8_t pwr_type=paras_get()->prod.type;
|
|
|
|
|
|
if(chs>0) {
|
|
|
h->chs = 0;
|
|
|
@@ -939,7 +939,7 @@ int power_scan(void)
|
|
|
pch[j].info.sch = j; //序号从0开始
|
|
|
pch[j].info.type = pkey->type;
|
|
|
|
|
|
- if(h->prod->pwr_type==PDU_AC_I3O3) {
|
|
|
+ if(h->prod->type==PDU_AC_I3O3) {
|
|
|
pch[j].info.ch = ch_idx+j/3; //序号从1开始, 发给控制板需从0开始
|
|
|
pch[j].info.ph_id = j%3;
|
|
|
}
|
|
|
@@ -949,8 +949,8 @@ int power_scan(void)
|
|
|
}
|
|
|
|
|
|
times = (pch[j].info.ch%nGroups)?pch[j].info.ch:nGroups;
|
|
|
- pch[j].info.start_delay = 1000*times;
|
|
|
- pch[j].info.stop_delay = 1000*times;
|
|
|
+ pch[j].info.open_delay = 1000*times;
|
|
|
+ pch[j].info.close_delay = 1000*times;
|
|
|
}
|
|
|
|
|
|
if(pbrd->type==AC_SINGLE_S_TYPE || pbrd->type==AC_SINGLE_B_TYPE) {
|
|
|
@@ -960,7 +960,7 @@ int power_scan(void)
|
|
|
pbrd->brk[0].info.addr = pbrd->addr;
|
|
|
}
|
|
|
|
|
|
- if(h->prod->pwr_type==PDU_AC_I3O3) {
|
|
|
+ if(h->prod->type==PDU_AC_I3O3) {
|
|
|
ch_idx += pkey->chs/3;
|
|
|
}
|
|
|
else {
|
|
|
@@ -1118,8 +1118,8 @@ int power_set_ch_sw(uint8_t ch, uint8_t on)
|
|
|
case TREE_AC_TYPE:
|
|
|
{
|
|
|
uint16_t reg;
|
|
|
- uint8_t pwr_type=paras_get()->prod.pwr_type;
|
|
|
- if(pwr_type==PDU_AC_I3O3 || pwr_type==PDU_AC_I3O1) {
|
|
|
+ uint8_t type=paras_get()->prod.type;
|
|
|
+ if(type==PDU_AC_I3O3 || type==PDU_AC_I3O1) {
|
|
|
reg = POWER_AC3_OUT_ENABLE;
|
|
|
}
|
|
|
else {
|
|
|
@@ -1552,7 +1552,7 @@ int power_set_threshold(power_ch_t *pch)
|
|
|
}
|
|
|
|
|
|
|
|
|
-int power_set_start_delay(power_ch_t *pch)
|
|
|
+int power_set_open_delay(power_ch_t *pch)
|
|
|
{
|
|
|
int r=-1;
|
|
|
uint16_t tmp[2],reg,offset;
|
|
|
@@ -1563,29 +1563,29 @@ int power_set_start_delay(power_ch_t *pch)
|
|
|
case AC_SINGLE_S_TYPE:
|
|
|
case AC_SINGLE_B_TYPE:
|
|
|
{
|
|
|
- tmp[0] = pch->info.start_delay;
|
|
|
- offset = POWER_AC_START_DELAY_TIME_L+pch->info.ch-1;
|
|
|
+ tmp[0] = pch->info.open_delay;
|
|
|
+ offset = POWER_AC_OPEN_DELAY_TIME_L+pch->info.ch-1;
|
|
|
r = write_reg(h, pch->info.addr, offset, tmp, 1);
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case DCPDU_TYPE:
|
|
|
{
|
|
|
- uint32_t time=pch->info.start_delay/1000;
|
|
|
+ uint32_t time=pch->info.open_delay/1000;
|
|
|
tmp[0] = time & 0xffff;
|
|
|
tmp[1] = (time >> 16) & 0xffff;
|
|
|
- offset = POWER_DC_SET_START_DELAY+pch->info.ch-1;
|
|
|
+ offset = POWER_DC_SET_OPEN_DELAY+pch->info.ch-1;
|
|
|
r = write_reg(h, pch->info.addr, offset, tmp, 2);
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case TREE_AC_TYPE:
|
|
|
{
|
|
|
- uint32_t time=pch->info.start_delay/1000;
|
|
|
+ uint32_t time=pch->info.open_delay/1000;
|
|
|
tmp[0] = time & 0xffff;
|
|
|
tmp[1] = (time >> 16) & 0xffff;
|
|
|
- if(h->prod->pwr_type==PDU_AC_I3O3) {
|
|
|
- offset = POWER_AC3_START_DELAY_TIME+pch->info.sch*3;
|
|
|
+ if(h->prod->type==PDU_AC_I3O3) {
|
|
|
+ offset = POWER_AC3_OPEN_DELAY_TIME+pch->info.sch*3;
|
|
|
r = write_reg(h, pch->info.addr, offset+0, tmp, 2);
|
|
|
if(r) break;
|
|
|
r = write_reg(h, pch->info.addr, offset+1, tmp, 2);
|
|
|
@@ -1594,7 +1594,7 @@ int power_set_start_delay(power_ch_t *pch)
|
|
|
if(r) break;
|
|
|
}
|
|
|
else {
|
|
|
- offset = POWER_AC3_START_DELAY_TIME+pch->info.sch;
|
|
|
+ offset = POWER_AC3_OPEN_DELAY_TIME+pch->info.sch;
|
|
|
r = write_reg(h, pch->info.addr, offset, tmp, 2);
|
|
|
}
|
|
|
}
|
|
|
@@ -1611,7 +1611,7 @@ int power_set_start_delay(power_ch_t *pch)
|
|
|
|
|
|
return r;
|
|
|
}
|
|
|
-int power_set_stop_delay(power_ch_t *pch)
|
|
|
+int power_set_close_delay(power_ch_t *pch)
|
|
|
{
|
|
|
int r=-1;
|
|
|
uint16_t tmp[2],reg,offset;
|
|
|
@@ -1622,27 +1622,27 @@ int power_set_stop_delay(power_ch_t *pch)
|
|
|
case AC_SINGLE_S_TYPE:
|
|
|
case AC_SINGLE_B_TYPE:
|
|
|
{
|
|
|
- tmp[0] = pch->info.start_delay;
|
|
|
- offset = POWER_AC_STOP_DELAY_TIME_L+pch->info.ch-1;
|
|
|
+ tmp[0] = pch->info.close_delay;
|
|
|
+ offset = POWER_AC_CLOSE_DELAY_TIME_L+pch->info.ch-1;
|
|
|
r = write_reg(h, pch->info.addr, offset, tmp, 1);
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case DCPDU_TYPE:
|
|
|
{
|
|
|
- uint32_t time=pch->info.stop_delay/1000;
|
|
|
+ uint32_t time=pch->info.close_delay/1000;
|
|
|
tmp[0] = time & 0xffff;
|
|
|
tmp[1] = (time >> 16) & 0xffff;
|
|
|
- offset = POWER_DC_SET_STOP_DELAY+pch->info.ch-1;
|
|
|
+ offset = POWER_DC_SET_CLOSE_DELAY+pch->info.ch-1;
|
|
|
//r = write_reg(h, pch->info.addr, offset, tmp, 2);
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case TREE_AC_TYPE:
|
|
|
{
|
|
|
- uint32_t time=pch->info.stop_delay/1000;
|
|
|
- if(h->prod->pwr_type==PDU_AC_I3O3) {
|
|
|
- offset = POWER_AC3_STOP_DELAY_TIME+pch->info.sch*3;
|
|
|
+ uint32_t time=pch->info.close_delay/1000;
|
|
|
+ if(h->prod->type==PDU_AC_I3O3) {
|
|
|
+ offset = POWER_AC3_CLOSE_DELAY_TIME+pch->info.sch*3;
|
|
|
r = write_reg(h, pch->info.addr, offset+0, tmp, 2);
|
|
|
if(r) break;
|
|
|
r = write_reg(h, pch->info.addr, offset+1, tmp, 2);
|
|
|
@@ -1651,7 +1651,7 @@ int power_set_stop_delay(power_ch_t *pch)
|
|
|
if(r) break;
|
|
|
}
|
|
|
else {
|
|
|
- offset = POWER_AC3_START_DELAY_TIME+pch->info.sch;
|
|
|
+ offset = POWER_AC3_CLOSE_DELAY_TIME+pch->info.sch;
|
|
|
r = write_reg(h, pch->info.addr, offset, tmp, 2);
|
|
|
}
|
|
|
}
|