123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- #include "plt.h"
- void abb_b23_4_comm_dac( int idx )
- {
- unsigned short tab_us[128]={0};
- struct abb_b23_4_t* dev = &abb_b23_4[idx];
- struct comm_t* comm = &dev->comm;
- int chanidx = comm->chanidx;
- int addr = comm->adr;
- int start, nb, rc, i;
- int ret = 0;
- unsigned int tmp;
- unsigned long long temp64 = 0;
- if(comm_get_state(comm) != COMMST_NORMAL){
- return;
- }
- comm_start_cal_dac_timing(comm);
- nb = 12;
- start = 0x5000;
- chan_lock(chanidx);
- usleep(100000); // 100ms
- rc = chan_read_holdingregisters_with_retry( chanidx, addr, start, nb, tab_us);
- if( rc < 0){
- comm_set_state(comm, COMMST_ERR);
- }
- chan_unlock(chanidx);
-
- if( rc == 0 ){ // read ok
- dev->pos_active_e = ((unsigned long long)tab_us[0x5000 - start]<<48 | (unsigned long long)tab_us[0x5001 - start] << 32 | (unsigned long long)tab_us[0x5002 - start] << 16 | (unsigned long long)tab_us[0x5003 - start])*0.01;
- dev->neg_active_e = ((unsigned long long)tab_us[0x5004 - start]<<48 | (unsigned long long)tab_us[0x5005 - start] << 32 | (unsigned long long)tab_us[0x5006 - start] << 16 | (unsigned long long)tab_us[0x5007 - start])*0.01;
-
- temp64 = (unsigned long long)tab_us[0x5008 - start]<<48 | (unsigned long long)tab_us[0x5009 - start] << 32 | (unsigned long long)tab_us[0x500A - start] << 16 | (unsigned long long)tab_us[0x500B - start];
- dev->com_active_e = *((signed long long *)(&temp64)) * 0.01;
- }else{
- return;
- }
- nb = 22;
- start = 0x5B00;
- chan_lock(chanidx);
- usleep(100000); // 100ms
- rc = chan_read_holdingregisters_with_retry( chanidx, addr, start, nb, tab_us);
- if( rc < 0){
- comm_set_state(comm, COMMST_ERR);
- }
- chan_unlock(chanidx);
- if( rc == 0 ){ // read ok
- dev->ua = ((unsigned int)tab_us[0x5B00 - start] << 16 | (unsigned int)tab_us[0x5B01 - start])*0.1;
- dev->ub = ((unsigned int)tab_us[0x5B02 - start] << 16 | (unsigned int)tab_us[0x5B03 - start])*0.1;
- dev->uc = ((unsigned int)tab_us[0x5B04 - start] << 16 | (unsigned int)tab_us[0x5B05 - start])*0.1;
- dev->ia = ((unsigned int)tab_us[0x5B0C - start] << 16 | (unsigned int)tab_us[0x5B0D - start])*0.01;
- dev->ib = ((unsigned int)tab_us[0x5B0E - start] << 16 | (unsigned int)tab_us[0x5B0F - start])*0.01;
- dev->ic = ((unsigned int)tab_us[0x5B10 - start] << 16 | (unsigned int)tab_us[0x5B11 - start])*0.01;
- tmp = (unsigned int)tab_us[0x5B14 - start] << 16 | (unsigned int)tab_us[0x5B15 - start];
- dev->com_ap = *((signed int*)&tmp) * 0.01 * 0.001;//w->kw
- }else{
- return ;
- }
- nb = 12;
- start = 0x5B2C;
- chan_lock(chanidx);
- usleep(100000); // 100ms
- rc = chan_read_holdingregisters_with_retry( chanidx, addr, start, nb, tab_us);
- if( rc < 0){
- comm_set_state(comm, COMMST_ERR);
- }
- chan_unlock(chanidx);
- if( rc == 0 ){ // read ok
- dev->freq = tab_us[0x5B2C - start] *0.01;
- dev->pwr_factor = *((signed short*)&tab_us[0x5B3A - start]);
- comm_stop_cal_dac_timing(comm);
- }else{
- return;
- }
- }
- // int dtsd1352_set_dev_pt( int idx, int val)
- // {
- // int ret = 0;
- // struct dtsd1352_t* dev = &dtsd1352[idx];
- // struct comm_t* comm = &dev->comm;
- // int chanidx = comm->chanidx;
- // int addr = comm->adr;
- // int regaddr = 0x008D;
- // int nb = 1;
- // chan_lock(chanidx);
- // usleep(100000); // 100ms
- // ret = chan_write_single_register_with_retry( chanidx, addr, regaddr, val);
- // chan_unlock(chanidx);
- // log_dbg("%s, idx:%d, val:%d, ret:%d", __func__, idx, val, ret);
- // return ret;
- // }
- // int dtsd1352_set_dev_ct( int idx, int val)
- // {
- // int ret = 0;
- // struct dtsd1352_t* dev = &dtsd1352[idx];
- // struct comm_t* comm = &dev->comm;
- // int chanidx = comm->chanidx;
- // int addr = comm->adr;
- // int regaddr = 0x008E;
- // int nb = 1;
- // chan_lock(chanidx);
- // usleep(100000); // 100ms
- // ret = chan_write_single_register_with_retry( chanidx, addr, regaddr, val);
- // chan_unlock(chanidx);
-
- // log_dbg("%s, idx:%d, val:%d, ret:%d", __func__, idx, val, ret);
- // return ret;
- // }
- int abb_b23_4_comm_init(int idx)
- {
- struct abb_b23_4_t* dev = &abb_b23_4[idx];
- struct comm_t* comm = &dev->comm;
- comm_set_state( comm, COMMST_ERR );
- }
- int abb_b23_4_comm_reset(int idx)
- {
- struct abb_b23_4_t* dev = &abb_b23_4[idx];
- struct comm_t* comm = &dev->comm;
- comm_set_state( comm, COMMST_NORMAL );
- comm_set_dac_param_en(comm, 1);
- }
|