factor.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781
  1. /******************************************************************************
  2. 版权所有:
  3. 文件名称: factor.c
  4. 文件版本: 01.01
  5. 创建作者: sunxi
  6. 创建日期: 2013-05-20
  7. 功能说明: 通道参数处理。
  8. 其它说明:
  9. 修改记录:
  10. */
  11. /*------------------------------- 头文件 --------------------------------------
  12. */
  13. #include "head.h"
  14. /*------------------------------- 宏定义 --------------------------------------
  15. */
  16. #define FACTOR_P_BASE (-360.0/32/8)
  17. //CT PT标度,1V或1A对应的码值
  18. // = (二次有效值/一次有效值)*(AD码值范围/电压范围(V))*1.4142
  19. // = (7.07/一次有效值)*(65536/20)*1.4142
  20. // = (7.07*65536/20*1.4142)/ 一次有效值.
  21. #define SCALE_PT_BIG (32768.0) // 二次有效值为7.07V或3.53V,需对应改变ADC的输入范围
  22. #define SCALE_CT_BIG (32768.0) // 二次有效值为7.07V或3.53V,需对应改变ADC的输入范围
  23. // 使用初级电阻标识
  24. #define SCALE_PT_102K (1.650*32768/5.0*1.4142) // DTU FTU使用电阻配置100V
  25. #define SCALE_PT_120K (1.032*32768/2.5*1.4142) //153K
  26. #define SCALE_PT_150K (1.0348*32768/2.5*1.4142) // 开普测试,测量范围264 增加了电阻
  27. #define SCALE_PT_172K (0.916*32768/2.5*1.4142) // 加264V相电压二次用万用表测有效值为0.916v
  28. #define SCALE_PT_204K (0.513*32768/2.5*1.4142) // 次级电阻200k 最终版本
  29. // 使用次级电阻标识
  30. #define SCALE_CT_100A_51 (2.526*32768/5.0*1.4142) // 次级电阻51欧,,加5A相电流二次用万用表测有效值为0.127V
  31. #define SCALE_CT_10A_51 (0.254*32768/2.5*1.4142) // 次级电阻51欧,加10A相电流二次用万用表测有效值为0.254V
  32. #define SCALE_CT_10A_120 (1.27*32768/2.5*1.4142) // 次级电阻249欧,加10A相电流二次用万用表测有效值为0.643V // 零序穿心5倍 最大量程20A
  33. #define SCALE_CT_10A_249 (1.265*32768/5.0*1.4142) // 1ACT 量程20A
  34. #define SCALE_CT_10A_604 (3.235*32768/5.0*1.4142) // 次级电阻604欧,加10A相电流二次用万用表测有效值为3.235V
  35. #define SCALE_EVT (32768.0)
  36. #define SCALE_ECT (32768.0)
  37. #define SCALE_PT_DEFAULT SCALE_PT_204K
  38. #define SCALE_CT_DEFAULT SCALE_CT_100A_51
  39. /*------------------------------ 类型结构 -------------------------------------
  40. */
  41. /*------------------------------ 全局变量 -------------------------------------
  42. */
  43. // 比例系数计算方法请参考<电子互感器比例系数计算方法.xlsx>
  44. static const float g_e_k[EQU_SCALE_NUM] =
  45. {
  46. SCALE_PT_BIG/(220*1.2),
  47. SCALE_PT_DEFAULT/(220*1.2),
  48. SCALE_EVT/(108.7856586), // EQU_SCALE_EVT_3V25_100V,10/(3.25*1.414)*100;
  49. SCALE_EVT/(31.31), // EQU_SCALE_EVT 最大测到30V
  50. #if 1
  51. SCALE_CT_BIG/54.752,
  52. #else
  53. SCALE_CT_BIG/100,
  54. #endif
  55. SCALE_CT_DEFAULT/100 ,
  56. SCALE_ECT/(10.60660172), // EQU_SCALE_ECT_1V_1A, 1V=1A
  57. SCALE_ECT/(11.73797257), // EQU_SCALE_ECT_0V2_1A,0.2V=1A.
  58. SCALE_CT_10A_51/10 ,
  59. SCALE_PT_102K/(220*1.2),
  60. SCALE_PT_120K/(220*1.2),
  61. SCALE_PT_172K/(220*1.2),
  62. SCALE_PT_204K/(220*1.2),
  63. SCALE_CT_10A_604/10 ,
  64. SCALE_CT_10A_120/10 ,
  65. SCALE_CT_10A_249/10 ,
  66. };
  67. //一次/二次变比
  68. static const float g_e_ps[EQU_SCALE_NUM] =
  69. {
  70. 10000.0/220.0,
  71. 10000.0/100.0,
  72. 10000.0/100.0, // EQU_SCALE_EVT_3V25_100V,10/(3.25*1.414)*100;
  73. 5773.502692/(100.0/3), // EQU_SCALE_EVT_6V50_100V,
  74. 600.0/5.0,
  75. 600.0/5.0,
  76. 600.0/1.0, // EQU_SCALE_ECT_1V_1A, 1V=1A
  77. 20.0/1.0, // EQU_SCALE_ECT_0V2_1A,0.2V=1A.
  78. 600.0/1.0,
  79. 10000.0/100.0,
  80. 10000.0/100.0,
  81. 10000.0/100.0,
  82. 10000.0/100.0,
  83. 10000.0/100.0,
  84. 10000.0/100.0,
  85. 10000.0/100.0,
  86. };
  87. // 电子互感器和电磁互感器二次值换算的比值
  88. const float g_e_k_ECVT[EQU_SCALE_NUM] =
  89. {
  90. 1.0,
  91. 1.0,
  92. 0.0325, // EQU_SCALE_EVT_3V25_100V,10/(3.25*1.414)*100;
  93. 0.065, // EQU_SCALE_EVT_6V50_100V,
  94. 1.0,
  95. 1.0,
  96. 1.0, // EQU_SCALE_ECT_1V_1A, 1V=1A
  97. 0.2, // EQU_SCALE_ECT_0V2_1A,0.2V=1A.
  98. 1.0,
  99. 1.0,
  100. 1.0,
  101. 1.0,
  102. 1.0,
  103. 1.0,
  104. 1.0,
  105. 1.0,
  106. };
  107. struct ac_slot_factor g_ac_factor[EQU_SLOT_AC_NUM];
  108. u32 g_factor_version = ACFACTOR_FILE_VERSION;
  109. u16 g_base_v,g_base_i;
  110. /*------------------------------ 函数声明 -------------------------------------
  111. */
  112. int factor_read_all(void);
  113. int factor_printf_temp(void);
  114. /*------------------------------ 外部函数 -------------------------------------
  115. 外部函数供其它实体文件引用,必须仔细检查传入参数的合法性.
  116. */
  117. int factor_init(void)
  118. {
  119. int slot,ret;
  120. // 取默认值
  121. g_factor_version = ACFACTOR_FILE_VERSION;
  122. for(slot=0; slot<EQU_SLOT_AC_NUM; slot++)
  123. {
  124. factor_get_default(&g_ac_factor[slot]);
  125. }
  126. // 检查装置配置
  127. if(equ_config_null())
  128. {
  129. return -1;
  130. }
  131. // 从文件系统读取系数
  132. ret = factor_read_all();
  133. if(ret != 0)
  134. {
  135. rt_err_set(ERR_CODE_FACTOR,0);
  136. printf("交流系数文件错误: (ret=%d)\r\n", ret);
  137. return -2;
  138. }
  139. return 0;
  140. }
  141. int factor_exit(void)
  142. {
  143. return 0;
  144. }
  145. int factor_read(u32 slot,struct ac_slot_factor *asf)
  146. {
  147. // 检查参数
  148. slot -= g_ac_slot_begin;
  149. if(slot >= EQU_SLOT_AC_NUM || asf == NULL)
  150. {
  151. return -1;
  152. }
  153. memcpy ((u8*)asf, &g_ac_factor[slot], sizeof(struct ac_slot_factor));
  154. return 0;
  155. }
  156. /******************************************************************************
  157. 函数名称: factor_write
  158. 函数版本: 01.01
  159. 创建作者: xxxxxx
  160. 创建日期: 2015-10-23
  161. 函数说明: 创建交流系数文件
  162. 参数说明: 无
  163. 返回值: 成功返回0.
  164. 修改记录:
  165. */
  166. int factor_write(u32 slot,struct ac_slot_factor *asf)
  167. {
  168. // 检查参数
  169. slot -= g_ac_slot_begin;
  170. if(slot >= EQU_SLOT_AC_NUM || asf == NULL)
  171. {
  172. return -1;
  173. }
  174. memcpy (&g_ac_factor[slot],(u8*)asf, sizeof(struct ac_slot_factor));
  175. return 0;
  176. }
  177. /******************************************************************************
  178. 函数名称: factor_read
  179. 函数版本: 01.01
  180. 创建作者: xxxxxx
  181. 创建日期: 2015-10-23
  182. 函数说明: 读取交流系数文件
  183. 参数说明: 无
  184. 返回值: 成功返回0.
  185. 修改记录:
  186. */
  187. int factor_read_all(void)
  188. {
  189. int len;
  190. u16 crc;
  191. u8 *buf;
  192. off_t pos;
  193. struct file * pfile;
  194. //int file_size;
  195. struct acfactor_file_head_data *brh;
  196. // 创建并打开文件
  197. pfile = (struct file *)rt_file_open("/app/data/acfactor.bin",O_RDWR,0);
  198. if(IS_ERR(pfile))
  199. {
  200. return -2;
  201. }
  202. // 得到文件长度
  203. len = rt_file_getfile_size(pfile);
  204. if(len <= 0)
  205. {
  206. rt_file_close(pfile, 0);
  207. return -21;
  208. }
  209. // 分配内存
  210. buf = (u8 *)rt_malloc(len);
  211. if((buf) == NULL)
  212. {
  213. rt_file_close(pfile,0);
  214. return -3;
  215. }
  216. // 读出内容
  217. pos = 0;
  218. if(rt_file_read(pfile,buf,len,&pos) != len)
  219. {
  220. rt_file_close(pfile,0);
  221. rt_free(buf);
  222. return -4;
  223. }
  224. // 关闭文件
  225. rt_file_close(pfile,0);
  226. // 检查CRC
  227. crc = CrcStr(buf,len-2);
  228. if(crc != *(u16*)(buf+len-2))
  229. {
  230. rt_free(buf);
  231. return -5;
  232. }
  233. // 检查文件签名
  234. brh = (struct acfactor_file_head_data*)buf;
  235. if(brh->cfh.signature != SIG_ACFACTOR_FILE)
  236. {
  237. rt_free(buf);
  238. return -6;
  239. }
  240. #if 0
  241. // 检查文件版本
  242. if(brh->cfh.version != ACFACTOR_FILE_VERSION)
  243. {
  244. rt_free(buf);
  245. return -66;
  246. }
  247. #endif
  248. //noted by sunxi: 20220413 暂进屏蔽
  249. #if 0
  250. // 检查FLASH唯一ID号
  251. if (memcmp (brh->auth_id, g_auth_id, 8) != 0)
  252. {
  253. rt_free(buf);
  254. return -7;
  255. }
  256. #endif
  257. // 检查板卡数量
  258. if(brh->num != EQU_SLOT_AC_NUM)
  259. {
  260. rt_free(buf);
  261. return -77;
  262. }
  263. // 检查文件长度
  264. if(len < (int)(sizeof(*brh) + brh->num*sizeof(struct ac_slot_factor)+ 2))
  265. {
  266. rt_free(buf);
  267. return -8;
  268. }
  269. //取出文件中存储内容
  270. g_factor_version = brh->cfh.version;
  271. g_base_v = brh->base_v;
  272. g_base_i = brh->base_i;
  273. memcpy ((u8*)g_ac_factor, buf+brh->addr, EQU_SLOT_AC_NUM*sizeof(struct ac_slot_factor));
  274. rt_free(buf);
  275. return 0;
  276. }
  277. int factor_write_all(u16 base_v,u16 base_i)
  278. {
  279. unsigned int addr,file_length;
  280. u16 crc;
  281. char *p;
  282. off_t pos;
  283. int pfile;
  284. struct acfactor_file_head_data acfactor_file;
  285. // 写文件头
  286. memset(&acfactor_file,0,sizeof(acfactor_file));
  287. acfactor_file.cfh.signature = SIG_ACFACTOR_FILE;
  288. acfactor_file.cfh.version = ACFACTOR_FILE_VERSION;
  289. memcpy (&acfactor_file.auth_id, g_auth_id, 8);
  290. acfactor_file.base_v = base_v ? base_v : g_base_v;
  291. acfactor_file.base_i = base_i ? base_i : g_base_i;
  292. g_base_v = acfactor_file.base_v;
  293. g_base_i = acfactor_file.base_i;
  294. acfactor_file.addr = FILE_ADDR_ALGIN(sizeof(acfactor_file));
  295. acfactor_file.num = EQU_SLOT_AC_NUM;
  296. // 得到文件长度
  297. addr = acfactor_file.addr + acfactor_file.num * sizeof(struct ac_slot_factor);
  298. file_length = FILE_ADDR_ALGIN(addr);
  299. // 分配并初始化空间
  300. p = (u8 *)rt_malloc(file_length + 2);
  301. if(!p)
  302. {
  303. rt_err_set(ERR_CODE_FACTOR,0);
  304. return -2;
  305. }
  306. memset(p, 0, file_length + 2);
  307. // 写入文件头
  308. memcpy(p, (char *)&acfactor_file, sizeof(acfactor_file));
  309. // 写系数
  310. memcpy(p+acfactor_file.addr, g_ac_factor, EQU_SLOT_AC_NUM * sizeof(struct ac_slot_factor));
  311. // 计算CRC
  312. crc = CrcStr(p, file_length);
  313. memcpy(p+file_length, &crc, 2);
  314. //swap16(p+file_length);//added by sunxi: 大小端问题 ----- 维护工具好像没有处理crc的大小端
  315. // 创建数据文件
  316. pfile = rt_file_open("/app/data/acfactor.bin",O_CREAT|O_RDWR|O_TRUNC,0);
  317. if(IS_ERR(pfile))
  318. {
  319. rt_err_set(ERR_CODE_FACTOR,0);
  320. rt_free(p);
  321. return -3;
  322. }
  323. pos = 0;
  324. rt_file_write(pfile, p, file_length+2, &pos);
  325. rt_file_close(pfile,0);
  326. rt_free(p);
  327. system("sync");//noted by sunxi: 把写好的文件,写到系统中去,不然,断电重启,有机会掉失
  328. //清除交流告警灯
  329. rt_err_clr(ERR_CODE_FACTOR,0);
  330. return 0;
  331. }
  332. int factor_write_board(u32 slot,struct ac_slot_factor *asf)
  333. {
  334. int ret ;
  335. ret = factor_write(slot,asf);
  336. if(ret != 0)
  337. {
  338. rt_err_set(ERR_CODE_FACTOR,slot);
  339. rt_printf("factor_write_board:slot=%lu,ret=%d.\r\n",slot,ret);
  340. return -1;
  341. }
  342. g_base_v = 0;
  343. g_base_i = 0;
  344. ret = factor_write_all(0,0);
  345. return ret;
  346. }
  347. int factor_get_default(struct ac_slot_factor *asf)
  348. {
  349. int i;
  350. if(asf == NULL)
  351. {
  352. return -1;
  353. }
  354. for(i=0; i<EQU_SLOT_AC_CHN; i++)
  355. {
  356. asf->factor_e_c[i] = 1.0;
  357. asf->factor_p_c[i] = 0.0;
  358. #ifdef PROTECT_AC_ADJUST
  359. asf->factor_p_e_c[i] = 1.0;
  360. #endif
  361. asf->pq_factor[i][0] = 0.0;
  362. asf->pq_factor[i][1] = 0.0;
  363. }
  364. asf->temp = 35.0;
  365. return 0;
  366. }
  367. int factor_restore_default(void)
  368. {
  369. int slot,ret ;
  370. // 取默认值
  371. g_factor_version = ACFACTOR_FILE_VERSION;
  372. for(slot=0; slot<EQU_SLOT_AC_NUM; slot++)
  373. {
  374. factor_get_default(&g_ac_factor[slot]);
  375. }
  376. // 重新初始化开关
  377. sw_init();
  378. // 保存
  379. g_base_v = 0;
  380. g_base_i = 0;
  381. ret = factor_write_all(0,0);
  382. rt_printf("factor_restore_default(ret=%d).\r\n",ret);
  383. return ret;
  384. }
  385. int factor_e_c_get(u32 slot,u32 index,float *f)
  386. {
  387. // 检查参数
  388. if(index >=(u32)equ_get_ac_num(slot))
  389. {
  390. return -1;
  391. }
  392. if(f == NULL)
  393. {
  394. return -2;
  395. }
  396. slot -= g_ac_slot_begin;
  397. if(slot >= EQU_SLOT_AC_NUM)
  398. {
  399. return -3;
  400. }
  401. *f = g_ac_factor[slot].factor_e_c[index];
  402. return 0;
  403. }
  404. int factor_e_c_set(u32 slot,u32 index,float f)
  405. {
  406. // 检查参数
  407. if(index >=(u32)equ_get_ac_num(slot))
  408. {
  409. return -1;
  410. }
  411. slot -= g_ac_slot_begin;
  412. if(slot >= EQU_SLOT_AC_NUM)
  413. {
  414. return -2;
  415. }
  416. g_ac_factor[slot].factor_e_c[index] = f;
  417. return 0;
  418. }
  419. int factor_p_c_get(u32 slot,u32 index,float *f)
  420. {
  421. // 检查参数
  422. if(index >=(u32)equ_get_ac_num(slot))
  423. {
  424. return -1;
  425. }
  426. if(f == NULL)
  427. {
  428. return -2;
  429. }
  430. slot -= g_ac_slot_begin;
  431. if(slot >= EQU_SLOT_AC_NUM)
  432. {
  433. return -3;
  434. }
  435. *f = g_ac_factor[slot].factor_p_c[index];
  436. return 0;
  437. }
  438. int factor_p_c_set(u32 slot,u32 index,float f)
  439. {
  440. // 检查参数
  441. if(index >=(u32)equ_get_ac_num(slot))
  442. {
  443. return -1;
  444. }
  445. slot -= g_ac_slot_begin;
  446. if(slot >= EQU_SLOT_AC_NUM)
  447. {
  448. return -2;
  449. }
  450. g_ac_factor[slot].factor_p_c[index] = f;
  451. return 0;
  452. }
  453. #ifdef PROTECT_AC_ADJUST
  454. int factor_p_e_c_get(u32 slot,u32 index,float *f)
  455. {
  456. // 检查参数
  457. if(index >=(u32)equ_get_ac_num(slot))
  458. {
  459. return -1;
  460. }
  461. if(f == NULL)
  462. {
  463. return -2;
  464. }
  465. slot -= g_ac_slot_begin;
  466. if(slot >= EQU_SLOT_AC_NUM)
  467. {
  468. return -3;
  469. }
  470. *f = g_ac_factor[slot].factor_p_e_c[index];
  471. return 0;
  472. }
  473. int factor_p_e_c_set(u32 slot,u32 index,float f)
  474. {
  475. // 检查参数
  476. if(index >=(u32)equ_get_ac_num(slot))
  477. {
  478. return -1;
  479. }
  480. slot -= g_ac_slot_begin;
  481. if(slot >= EQU_SLOT_AC_NUM)
  482. {
  483. return -2;
  484. }
  485. g_ac_factor[slot].factor_p_e_c[index] = f;
  486. return 0;
  487. }
  488. #endif
  489. int factor_pq_get(u32 slot,u32 index,float *f)
  490. {
  491. // 检查参数
  492. if(index >=(u32)equ_get_ac_num(slot))
  493. {
  494. return -1;
  495. }
  496. if(f == NULL)
  497. {
  498. return -2;
  499. }
  500. slot -= g_ac_slot_begin;
  501. if(slot >= EQU_SLOT_AC_NUM)
  502. {
  503. return -3;
  504. }
  505. *f++ = g_ac_factor[slot].pq_factor[index][0];
  506. *f = g_ac_factor[slot].pq_factor[index][1];
  507. return 0;
  508. }
  509. int factor_pq_set(u32 slot,u32 index,float *f)
  510. {
  511. // 检查参数
  512. if(index >=(u32)equ_get_ac_num(slot))
  513. {
  514. return -1;
  515. }
  516. if(f == NULL)
  517. {
  518. return -2;
  519. }
  520. slot -= g_ac_slot_begin;
  521. if(slot >= EQU_SLOT_AC_NUM)
  522. {
  523. return -3;
  524. }
  525. g_ac_factor[slot].pq_factor[index][0] = *f++;
  526. g_ac_factor[slot].pq_factor[index][1] = *f;
  527. return 0;
  528. }
  529. float factor_e_k(u32 index)
  530. {
  531. if(index >= EQU_SCALE_NUM)
  532. {
  533. return -1;
  534. }
  535. return g_e_k[index];
  536. }
  537. float factor_e_ps(u32 index)
  538. {
  539. if(index >= EQU_SCALE_NUM)
  540. {
  541. return -1;
  542. }
  543. return g_e_ps[index];
  544. }
  545. float factor_p_k(u32 index)
  546. {
  547. if(index >= CFG_ADC_CHANNEL)
  548. {
  549. return 0;
  550. }
  551. #ifdef BSP_DTU2 // 只有DTU2.0是分时通道切换采样的,所有有理论的角度偏差。
  552. //#if 1 // 目前先使用此值,以保证已校准设备的兼容性
  553. return (index/8)*FACTOR_P_BASE ;
  554. #else
  555. #ifdef BSP_DTU3
  556. // 保持旧版本的兼容性
  557. {
  558. u32 us;
  559. if(g_factor_version != ACFACTOR_FILE_VERSION)
  560. {
  561. return (index/8)*FACTOR_P_BASE ;
  562. }
  563. //1倍过采样延时1us
  564. us = (index%16)/2*CFG_ADC_OS_NUM;
  565. return -g_freq*us/1000000.0*360 ;
  566. }
  567. #else
  568. return 0;
  569. #endif
  570. #endif
  571. }
  572. int factor_temp_get(int slot,float *temp)
  573. {
  574. // 检查参数
  575. slot -= g_ac_slot_begin;
  576. if(slot >= EQU_SLOT_AC_NUM)
  577. {
  578. return -1;
  579. }
  580. *temp = g_ac_factor[slot].temp;
  581. return 0;
  582. }
  583. int factor_temp_set(int slot,float temp)
  584. {
  585. // 检查参数
  586. slot -= g_ac_slot_begin;
  587. if(slot >= EQU_SLOT_AC_NUM)
  588. {
  589. return -1;
  590. }
  591. g_ac_factor[slot].temp = temp;
  592. return 0;
  593. }
  594. /*------------------------------ 内部函数 -------------------------------------
  595. 内部函数以下划线‘_’开头,不需要检查参数的合法性.
  596. */
  597. /*------------------------------ 测试函数 -------------------------------------
  598. 一个实体文件必须带一个本模块的测试函数来进行单元测试,如果的确不方便在本模块中
  599. 进行单元测试,必须在此注明实际的测试位置(例如在哪个实体文件中使用哪个测试函数).
  600. */
  601. int factor_printf(void)
  602. {
  603. int slot,j;
  604. float f;
  605. rt_printf("校正系数:\r\n");
  606. rt_printf("版本:0x%08lx.\r\n",g_factor_version);
  607. rt_printf("最后校准基准值:电压=%d,电流=%d.\r\n",g_base_v,g_base_i);
  608. for(slot=0; slot<EQU_SLOT_AC_NUM; slot++)
  609. {
  610. rt_printf("序号:%02d(temp=%f).\r\n",slot,g_ac_factor[slot].temp);
  611. for(j=0;j<EQU_SLOT_AC_CHN;j++)
  612. {
  613. rt_printf("%02d:\tec=% 9f,\tpc=% 9f,\tpq1=% 9f,\tpq2=% 9f.\r\n",j,
  614. g_ac_factor[slot].factor_e_c[j],
  615. g_ac_factor[slot].factor_p_c[j],
  616. g_ac_factor[slot].pq_factor[j][0],
  617. g_ac_factor[slot].pq_factor[j][1]);
  618. }
  619. }
  620. for(j=0;j<(int)(sizeof(g_e_k)/sizeof(g_e_k[0])); j++)
  621. {
  622. rt_printf("g_e_k[%d]:%f.\r\n",j,g_e_k[j]);
  623. }
  624. for(j=0;j<16;j++)
  625. {
  626. f = factor_p_k(j);
  627. rt_printf("factor_p_k(%02d):%f.\r\n",j,f);
  628. }
  629. return 0;
  630. }
  631. //========================== 本文件结束 =============================