@ -1,23 +1,27 @@
String Prcss_ALL_Read ( ) {
String str = " " ;
char formattedNumber [ 5 ] ; // 4자리 숫자 + 널 종료 문자
float factor = 1.0f / AI_AVG_SIZE ;
str + = " AI?: " ;
for ( int i = 0 ; i < Size_AI ; i + + ) {
in t sum_AI = 0 ;
floa t sum_AI = 0 ;
for ( int j = 0 ; j < AI_AVG_SIZE ; j + + ) {
sum_AI + = Recent_AI [ i ] [ j ] ;
sum_AI + = ( float ) Recent_AI [ i ] [ j ] * factor ;
}
char formattedNumber [ 5 ] ; // 4자리 숫자 + 널 종료 문자
sum_AI * = 50.0f ; // convert the sum to an integer representation, Transfer data max(0xFFFF): 65,535. Each data max(10bit ADC): 1024. 1024 x 50 = 51,200
unsigned int integer_part = ( unsigned int ) sum_AI ;
//sprintf(formattedNumber, "%04X", Values_AI[i]); // 4자리로 고정된 형식의 문자열 생성
sprintf ( formattedNumber , " %04X " , sum_AI ) ; // 4자리로 고정된 형식의 문자열 생성
sprintf ( formattedNumber , " %04X " , integer_part ) ; // 4자리로 고정된 형식의 문자열 생성
str + = formattedNumber ; // 형식화된 문자열 추가
str + = ' , ' ;
}
str + = RcvOK ;
str + = " DI?: " ;
char formattedNumber [ 5 ] ;
sprintf ( formattedNumber , " %04X " , Values_DI ) ;
str + = formattedNumber ;
str + = ' , ' ;
@ -25,7 +29,6 @@ String Prcss_ALL_Read(){
str + = " PV_1?: " ;
for ( int i = 0 ; i < RS485_1_Rcv_size * 2 ; i + + ) {
char formattedNumber [ 5 ] ;
int rcv = int ( RS485_1_Rcv_PV [ i / RS485_1_Rcv_size ] ) ;
sprintf ( formattedNumber , " %04X " , RS485_1_Values_PV [ i ] * rcv ) ;
@ -37,7 +40,6 @@ String Prcss_ALL_Read(){
str + = " SV_1?: " ;
for ( int i = 0 ; i < RS485_1_Rcv_size * 2 ; i + + ) {
char formattedNumber [ 5 ] ;
int rcv = int ( RS485_1_Rcv_SV [ i / RS485_1_Rcv_size ] ) ;
sprintf ( formattedNumber , " %04X " , RS485_1_Values_SV [ i ] * rcv ) ;
@ -46,6 +48,11 @@ String Prcss_ALL_Read(){
}
str + = RcvOK ;
str + = " INIT?: " ;
sprintf ( formattedNumber , " %04X " , ( ( unsigned int ) ( Init_AO & Init_MC9 ) ) ) ;
str + = formattedNumber ;
str + = ' , ' ;
str + = RcvOK ;
return str + FIN ;
}