📄 simuintp.c
字号:
{ int i, j, k, sa_index; sa_index = 0; for (i = 0; i < 6; i++) { for (j = sa_index; j < MAX_SUM_CODES; j++) if (SUM_ISSET(j, p_sum_flags)) { strcpy(tl1_val[S1_I + i], summary_code[j]); break; } if (j == MAX_SUM_CODES) { for (k = i; k < 6; k++) strcpy(tl1_val[S1_I + k], ""); break; } sa_index = ++j; }}static int check_for_pars(int param_i){ int i; for (i = 0; i < MAX_PARS_PARAMS; i++) if (param_i == pars_params[i]) return (TRUE); return (FALSE);}static void add_d_to_buffer(dbl_set * p_dbl_flags, char *TL1Response, int param_i){ int pars_needed; /*TRUE if parenthesis are used to format the output */ static char par_str[20]; sprintf(par_str, "%s=", tl1_params[param_i]); if (!DBL_ISSET(param_i, p_dbl_flags)) { return; } /* we have a valid double, let's process */ strcat(TL1Response, par_str); pars_needed = check_for_pars(param_i); if (pars_needed) strcat(TL1Response, "("); strcat(TL1Response, tl1_val[param_i]); if (pars_needed) strcat(TL1Response, ")"); strcat(TL1Response, ",");}static int is_line_present(int start_i, int end_i){ int i; for (i = start_i; i <= end_i; i++) if (tl1_val[i][0] != '\0') return (TRUE); return (FALSE);}static int is_d_line_present(dbl_set * p_dbl_flags, int start_i, int end_i){ int i; for (i = start_i; i <= end_i; i++) if (DBL_ISSET(i, p_dbl_flags)) return (TRUE); return (FALSE);}void TL1FmtResponse(dbl_set * p_dbl_flags, char *TL1Response){ strcat(TL1Response, "\r\n \"V="); if (tl1_val[V_I][0] == '\0') strcpy(tl1_val[V_I], ver_codes[VER98]); strcat(TL1Response, tl1_val[V_I]); strcat(TL1Response, ","); if (tl1_val[S1_I][0] != '\0') { strcat(TL1Response, "S1="); strcat(TL1Response, tl1_val[S1_I]); strcat(TL1Response, ","); if (tl1_val[S2_I][0] != '\0') { strcat(TL1Response, "S2="); strcat(TL1Response, tl1_val[S2_I]); strcat(TL1Response, ","); if (tl1_val[S3_I][0] != '\0') { strcat(TL1Response, "S3="); strcat(TL1Response, tl1_val[S3_I]); strcat(TL1Response, ","); if (tl1_val[S4_I][0] != '\0') { strcat(TL1Response, "S4="); strcat(TL1Response, tl1_val[S4_I]); strcat(TL1Response, ","); if (tl1_val[S5_I][0] != '\0') { strcat(TL1Response, "S5="); strcat(TL1Response, tl1_val[S5_I]); strcat(TL1Response, ","); if (tl1_val[S6_I][0] != '\0') { strcat(TL1Response, "S6="); strcat(TL1Response, tl1_val[S6_I]); strcat(TL1Response, ","); } /*S6_I */ } /*S5_I */ } /*S4_I */ } /*S3_I */ } /*S2_I */ } /*S1_I */ /* need if statments in front of these add_to_buffers */ if (is_d_line_present(p_dbl_flags, DR1_I, DR5_I)) { strcat(TL1Response, "\r\n "); add_d_to_buffer(p_dbl_flags, TL1Response, DR1_I); add_d_to_buffer(p_dbl_flags, TL1Response, DR2_I); add_d_to_buffer(p_dbl_flags, TL1Response, DR3_I); add_d_to_buffer(p_dbl_flags, TL1Response, DR4_I); add_d_to_buffer(p_dbl_flags, TL1Response, DR5_I); } if (is_d_line_present(p_dbl_flags, DC1_I, DC5_I)) { strcat(TL1Response, "\r\n "); add_d_to_buffer(p_dbl_flags, TL1Response, DC1_I); add_d_to_buffer(p_dbl_flags, TL1Response, DC2_I); add_d_to_buffer(p_dbl_flags, TL1Response, DC3_I); add_d_to_buffer(p_dbl_flags, TL1Response, DC4_I); add_d_to_buffer(p_dbl_flags, TL1Response, DC5_I); } if (is_d_line_present(p_dbl_flags, AC1_I, AF2_I)) { strcat(TL1Response, "\r\n "); add_d_to_buffer(p_dbl_flags, TL1Response, AC1_I); add_d_to_buffer(p_dbl_flags, TL1Response, AC2_I); add_d_to_buffer(p_dbl_flags, TL1Response, AC3_I); add_d_to_buffer(p_dbl_flags, TL1Response, AF1_I); add_d_to_buffer(p_dbl_flags, TL1Response, AF2_I); } if (is_d_line_present(p_dbl_flags, RG1_I, TH3_I) || is_line_present(RG1_I, RG1_I)) { strcat(TL1Response, "\r\n "); add_d_to_buffer(p_dbl_flags, TL1Response, RG1_I); add_d_to_buffer(p_dbl_flags, TL1Response, RG2_I); add_d_to_buffer(p_dbl_flags, TL1Response, RG3_I); add_d_to_buffer(p_dbl_flags, TL1Response, TH1_I); add_d_to_buffer(p_dbl_flags, TL1Response, TH2_I); add_d_to_buffer(p_dbl_flags, TL1Response, TH3_I); } if (is_d_line_present(p_dbl_flags, CT1_I, LN3_I)) { strcat(TL1Response, "\r\n "); add_d_to_buffer(p_dbl_flags, TL1Response, CT1_I); add_d_to_buffer(p_dbl_flags, TL1Response, CT2_I); add_d_to_buffer(p_dbl_flags, TL1Response, BL1_I); add_d_to_buffer(p_dbl_flags, TL1Response, BL2_I); add_d_to_buffer(p_dbl_flags, TL1Response, LN1_I); add_d_to_buffer(p_dbl_flags, TL1Response, LN2_I); add_d_to_buffer(p_dbl_flags, TL1Response, LN3_I); } if (is_d_line_present(p_dbl_flags, LC1_I, LC2_I)) { strcat(TL1Response, "\r\n "); add_d_to_buffer(p_dbl_flags, TL1Response, LC1_I); add_d_to_buffer(p_dbl_flags, TL1Response, LC2_I); } if (is_d_line_present(p_dbl_flags, AC4_I, AC6_I)) { strcat(TL1Response, "\r\n "); add_d_to_buffer(p_dbl_flags, TL1Response, AC4_I); add_d_to_buffer(p_dbl_flags, TL1Response, AC5_I); add_d_to_buffer(p_dbl_flags, TL1Response, AC6_I); } if (is_d_line_present(p_dbl_flags, NTSAC1_I, NTSAC3_I)) { strcat(TL1Response, "\r\n "); add_d_to_buffer(p_dbl_flags, TL1Response, NTSAC1_I); add_d_to_buffer(p_dbl_flags, TL1Response, NTSAC2_I); add_d_to_buffer(p_dbl_flags, TL1Response, NTSAC3_I); } if (is_d_line_present(p_dbl_flags, NTSAC4_I, NTSAC6_I)) { strcat(TL1Response, "\r\n "); add_d_to_buffer(p_dbl_flags, TL1Response, NTSAC4_I); add_d_to_buffer(p_dbl_flags, TL1Response, NTSAC5_I); add_d_to_buffer(p_dbl_flags, TL1Response, NTSAC6_I); } if (is_d_line_present(p_dbl_flags, NZRAV_I, NZRBE_I)) { strcat(TL1Response, "\r\n "); add_d_to_buffer(p_dbl_flags, TL1Response, NZRAV_I); add_d_to_buffer(p_dbl_flags, TL1Response, NZRAE_I); add_d_to_buffer(p_dbl_flags, TL1Response, NZRBV_I); add_d_to_buffer(p_dbl_flags, TL1Response, NZRBE_I); } if (is_d_line_present(p_dbl_flags, NZRAB_I, NZGNSE_I)) { strcat(TL1Response, "\r\n "); add_d_to_buffer(p_dbl_flags, TL1Response, NZRAB_I); add_d_to_buffer(p_dbl_flags, TL1Response, NZRBA_I); add_d_to_buffer(p_dbl_flags, TL1Response, NZGNSE_I); } if (is_d_line_present(p_dbl_flags, NZVAE_I, NZVAB_I)) { strcat(TL1Response, "\r\n "); add_d_to_buffer(p_dbl_flags, TL1Response, NZVAE_I); add_d_to_buffer(p_dbl_flags, TL1Response, NZVBE_I); add_d_to_buffer(p_dbl_flags, TL1Response, NZVAB_I); } if (is_d_line_present(p_dbl_flags, AN_ORST_I, AN_ILVAL_I)) { strcat(TL1Response, "\r\n "); add_d_to_buffer(p_dbl_flags, TL1Response, AN_ORST_I); add_d_to_buffer(p_dbl_flags, TL1Response, AN_DIALRST_I); add_d_to_buffer(p_dbl_flags, TL1Response, AN_FEEDRST_I); add_d_to_buffer(p_dbl_flags, TL1Response, AN_LOOPRST_I); add_d_to_buffer(p_dbl_flags, TL1Response, AN_VBATVAL_I); add_d_to_buffer(p_dbl_flags, TL1Response, AN_ILVAL_I); } strcat(TL1Response, "\"\r\n;");}/************************************************ *comment: * * determine the summary code * *return summary code * * -1:error * ************************************************/int setSumCode(double test_value, char *test_item, COMPRULEDATA * p){ /*determine the scope of test item */ int i, j, loop_out = 0, vv; char result_str[5]; for (i = 0; i < p->index_head->count; i++) { /* printf("test_item:%s,item_str:%s\n",test_item,(p->index_head->comp_index+i)->item_str); */ if (strcmp(test_item, (p->index_head->comp_index + i)->item_str) == 0) break; } if (i >= p->index_head->count) return -1; j = i;/* printf("count=%d, j=%d, first=%d, last=%d\n",p->index_head->count,i,(p->index_head->comp_index+j)->first,(p->index_head->comp_index+j)->last); */ for (i = (p->index_head->comp_index + j)->first; i <= (p->index_head->comp_index + j)->last; i++) { switch ((p->compare_table + i)->range) { case '2': /* printf("test_value:%f,(p->compare_table+i)->lower=%f\n",test_value,(p->compare_table+i)->lower); */ if (test_value <= (p->compare_table + i)->lower) { strcpy(result_str, (p->compare_table + i)->sumcode); loop_out = 1; } break; case '0': if ((test_value > (p->compare_table + i)->lower) && (test_value <= (p->compare_table + i)->upper)) { strcpy(result_str, (p->compare_table + i)->sumcode); loop_out = 1; } break; case '1': default: if (test_value > (p->compare_table + i)->upper) { strcpy(result_str, (p->compare_table + i)->sumcode); loop_out = 1; } } if (loop_out == 1) break; } /* if(i>(p->index_head->comp_index+j)->last) { return -1; } else */ if (loop_out == 1) { for (i = 0; i < MAX_SUM_CODES; i++) { if (strcmp(result_str, summary_code[i]) == 0) break; } if (i < MAX_SUM_CODES) return i; } return -1;}/******************************************* *comment: * * determine the ver code * *return vercode * * -1:no neccessary vercode * *******************************************/int setVercode(int sum_code, TESTVALUE test_value){ /*argument test_value if for the furture */ if (sum_code >= MAX_SUM_CODES) return -1; if (sum_code == RF1_S) return VER26; if ((sum_code >= RF39_S) && (sum_code <= RF53_S)) return VERN1; if ((sum_code >= RF24_S) && (sum_code <= RF38_S)) return VERP1; if (((sum_code >= RF2_S) && (sum_code <= RF6_S)) || sum_code == QS1_S || sum_code == CO9_S) return VER22; if (((sum_code >= RF7_S) && (sum_code <= RF16_S)) || sum_code == QS2_S || sum_code == QS3_S) return VER21; if ((sum_code >= RF1_S) && (sum_code <= RF53_S) && (sum_code != RF17_S) && (sum_code != RF18_S)) return VER25; if ((sum_code == AF7_S) || (sum_code == AF9_S)) return VER16; if ((sum_code == AF1_S) || (sum_code == AF2_S) || (sum_code == AF8_S)) return VER12; if (sum_code == OP1_S) return VER3; if ((sum_code == OP8_S) || (sum_code == OP2_S) || (sum_code == OP3_S) || (sum_code == OP4_S) || (sum_code == OP11_S) || (sum_code == OP12_S) || (sum_code == QS9_S)) return VER46; if (((sum_code >= BT1_S) && (sum_code <= BT12_S)) || sum_code == QS4_S || sum_code == QS5_S) return VER15; return -1;}struct VERCODES_RESULTS{ int result; int vercode;}vercode_results[] ={ 0, VER0, 1, VER6, 2, VER6, 3, VER08, 4, VER6, 11, VER16, 12, VER15, 13, VERA1, 14, VERA2, 15, VERA3, 16, VERA4, 17, VERA5, 21, VER27, 22, VER46, 23, VER11, 24, VER21, 25, VER13, 26, VER21, 27, VER71, 41, VERRB, -1, 0};int get_vercode_from_result(char *result, char *vername){ int temp; int i; temp = atoi(result); for (i = 0; vercode_results[i].result != -1; ++i) { if (vercode_results[i].result == temp) { strcpy(vername, "V="); strcat(vername, ver_codes[vercode_results[i].vercode]); return (vercode_results[i].vercode); } } return -1;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -