瀏覽代碼

Version 01.17

1. DL Atten 동작이 기존과 동일합니다. (수정안됨)
-동작 확인 후 수정 완료 하였습니다.
2. UL ALC 동작하지 않습니다. 출력이 계속 올라감
-사이드 이펙트로 다른 증상 해결 후 증상이 해결 되었습니다.
3. UL High Alarm 해제 조건이 High Level -2dB가 아니라, -1.1dB입니다.
-동작 확인 후 수정 완료 하였습니다.
PYJ 4 年之前
父節點
當前提交
15c191ab35
共有 2 個文件被更改,包括 226 次插入105 次删除
  1. 225 104
      Bluecell_Src/Bluecell_operate.c
  2. 1 1
      Src/main.c

+ 225 - 104
Bluecell_Src/Bluecell_operate.c

@@ -6085,8 +6085,10 @@ void DET_LevelAlarmCheck(){
6085
     int16_t LimitData_UL_Shutdown = 0;    
6085
     int16_t LimitData_UL_Shutdown = 0;    
6086
     
6086
     
6087
     double ret = 0;
6087
     double ret = 0;
6088
-    int16_t Res_DL_dBm[DET_Alarm_DL_Index_MAX] = {0,};
6089
-    int16_t Res_UL_dBm[DET_Alarm_UL_Index_MAX] = {0,};    
6088
+    int16_t Res_Up_DL_dBm[DET_Alarm_DL_Index_MAX] = {0,};
6089
+    int16_t Res_Down_DL_dBm[DET_Alarm_DL_Index_MAX] = {0,};
6090
+    int16_t Res_Up_UL_dBm[DET_Alarm_UL_Index_MAX] = {0,};    
6091
+    int16_t Res_Down_UL_dBm[DET_Alarm_UL_Index_MAX] = {0,};    
6090
     
6092
     
6091
 
6093
 
6092
     LimitData_UL_High = ConvertTo2byte(bluecell_Currdatastatus.ULO_Level_High_Threshold_H,bluecell_Currdatastatus.ULO_Level_High_Threshold_L) * 0.1;
6094
     LimitData_UL_High = ConvertTo2byte(bluecell_Currdatastatus.ULO_Level_High_Threshold_H,bluecell_Currdatastatus.ULO_Level_High_Threshold_L) * 0.1;
@@ -6100,19 +6102,19 @@ void DET_LevelAlarmCheck(){
6100
     ret  = bluecell_Currdatastatus.DLI_P1_Level1_H << 8;
6102
     ret  = bluecell_Currdatastatus.DLI_P1_Level1_H << 8;
6101
     ret += bluecell_Currdatastatus.DLI_P1_Level1_L;   
6103
     ret += bluecell_Currdatastatus.DLI_P1_Level1_L;   
6102
     ret *= 0.001;    
6104
     ret *= 0.001;    
6103
-    Res_DL_dBm[DET_Alarm_DL1_Index] 
6105
+    Res_Down_DL_dBm[DET_Alarm_DL1_Index] 
6104
         = bluecell_Currdatastatus.DLI_Level1_H << 8 | bluecell_Currdatastatus.DLI_Level1_L;//(int8_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&Det_DL1.Table_Det5_dBm_H,sizeof(DET_TABLEDL_st)));
6106
         = bluecell_Currdatastatus.DLI_Level1_H << 8 | bluecell_Currdatastatus.DLI_Level1_L;//(int8_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&Det_DL1.Table_Det5_dBm_H,sizeof(DET_TABLEDL_st)));
6105
     ret  = bluecell_Currdatastatus.DLI_P2_Level2_H << 8;
6107
     ret  = bluecell_Currdatastatus.DLI_P2_Level2_H << 8;
6106
     ret += bluecell_Currdatastatus.DLI_P2_Level2_L;   
6108
     ret += bluecell_Currdatastatus.DLI_P2_Level2_L;   
6107
     ret *= 0.001;  
6109
     ret *= 0.001;  
6108
 
6110
 
6109
-    Res_DL_dBm[DET_Alarm_DL2_Index] 
6111
+    Res_Down_DL_dBm[DET_Alarm_DL2_Index] 
6110
         = bluecell_Currdatastatus.DLI_Level2_H << 8 | bluecell_Currdatastatus.DLI_Level2_L;//(int8_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&Det_DL2.Table_Det5_dBm_H,sizeof(DET_TABLEDL_st)));
6112
         = bluecell_Currdatastatus.DLI_Level2_H << 8 | bluecell_Currdatastatus.DLI_Level2_L;//(int8_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&Det_DL2.Table_Det5_dBm_H,sizeof(DET_TABLEDL_st)));
6111
     ret  = bluecell_Currdatastatus.DLI_P3_Level3_H << 8;
6113
     ret  = bluecell_Currdatastatus.DLI_P3_Level3_H << 8;
6112
     ret += bluecell_Currdatastatus.DLI_P3_Level3_L;   
6114
     ret += bluecell_Currdatastatus.DLI_P3_Level3_L;   
6113
     ret *= 0.001;  
6115
     ret *= 0.001;  
6114
 
6116
 
6115
-    Res_DL_dBm[DET_Alarm_DL3_Index] 
6117
+    Res_Down_DL_dBm[DET_Alarm_DL3_Index] 
6116
         = bluecell_Currdatastatus.DLI_Level3_H << 8 | bluecell_Currdatastatus.DLI_Level3_L;//(int8_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&Det_DL3.Table_Det5_dBm_H,sizeof(DET_TABLEDL_st)));
6118
         = bluecell_Currdatastatus.DLI_Level3_H << 8 | bluecell_Currdatastatus.DLI_Level3_L;//(int8_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&Det_DL3.Table_Det5_dBm_H,sizeof(DET_TABLEDL_st)));
6117
 
6119
 
6118
 
6120
 
@@ -6120,50 +6122,35 @@ void DET_LevelAlarmCheck(){
6120
     ret += bluecell_Currdatastatus.DLI_P4_Level4_L;   
6122
     ret += bluecell_Currdatastatus.DLI_P4_Level4_L;   
6121
     ret *= 0.001;  
6123
     ret *= 0.001;  
6122
 
6124
 
6123
-    Res_DL_dBm[DET_Alarm_DL4_Index] 
6125
+    Res_Down_DL_dBm[DET_Alarm_DL4_Index] 
6124
         = bluecell_Currdatastatus.DLI_Level4_H << 8 | bluecell_Currdatastatus.DLI_Level4_L;//(int8_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&Det_DL4.Table_Det5_dBm_H,sizeof(DET_TABLEDL_st)));
6126
         = bluecell_Currdatastatus.DLI_Level4_H << 8 | bluecell_Currdatastatus.DLI_Level4_L;//(int8_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&Det_DL4.Table_Det5_dBm_H,sizeof(DET_TABLEDL_st)));
6125
 
6127
 
6126
 //    printf("Res_DL_dBm[DET_Alarm_DL1_Index] : %d \r\n",Res_DL_dBm[DET_Alarm_DL1_Index]);
6128
 //    printf("Res_DL_dBm[DET_Alarm_DL1_Index] : %d \r\n",Res_DL_dBm[DET_Alarm_DL1_Index]);
6127
     for(int i = 0; i < DET_Alarm_DL_Index_MAX; i++){
6129
     for(int i = 0; i < DET_Alarm_DL_Index_MAX; i++){
6128
-#if 0 // PYJ.2020.10.15_BEGIN -- 
6129
-        if(Res_DL_dBm[DET_Alarm_DL1_Index + i] % 10 != 0){
6130
-            Res_DL_dBm[DET_Alarm_DL1_Index + i] *= 0.1;
6131
-            if(Res_DL_dBm[DET_Alarm_DL1_Index + i] < 0)
6132
-                Res_DL_dBm[DET_Alarm_DL1_Index + i]--;
6133
-            else
6134
-                Res_DL_dBm[DET_Alarm_DL1_Index + i]++;
6135
-        }else{
6136
-            Res_DL_dBm[DET_Alarm_DL1_Index + i] *= 0.1;
6137
-        }
6138
-#else
6139
-    if(Res_DL_dBm[DET_Alarm_DL1_Index + i] > 0){
6140
-        
6141
-        if(Res_DL_dBm[DET_Alarm_DL1_Index + i] % 10 != 0){
6142
-            if(Res_DL_dBm[DET_Alarm_DL1_Index + i] % 10 >= 5){
6143
-                Res_DL_dBm[DET_Alarm_DL1_Index + i] *= 0.1;
6144
-                Res_DL_dBm[DET_Alarm_DL1_Index + i]++;
6145
-            }else{
6146
-                Res_DL_dBm[DET_Alarm_DL1_Index + i] *= 0.1;
6147
-            }
6148
-        }
6149
-        else{
6150
-            Res_DL_dBm[DET_Alarm_DL1_Index + i] *= 0.1;
6151
-        }
6152
-        
6153
-    }else{
6154
-    
6155
-        if(Res_DL_dBm[DET_Alarm_DL1_Index + i] % 10 != 0){
6156
-            if(Res_DL_dBm[DET_Alarm_DL1_Index + i] % 10 <= -5){
6157
-                Res_DL_dBm[DET_Alarm_DL1_Index + i] *= 0.1;
6158
-                Res_DL_dBm[DET_Alarm_DL1_Index + i]--;
6159
-            }else{
6160
-                Res_DL_dBm[DET_Alarm_DL1_Index + i] *= 0.1;
6130
+#if 0 // PYJ.2020.10.16_BEGIN -- 
6131
+        if(Res_DL_dBm[DET_Alarm_DL1_Index + i] > 0){
6132
+            if(Res_DL_dBm[DET_Alarm_DL1_Index + i] % 10 != 0){
6133
+                Res_DL_dBm[DET_Alarm_DL1_Index + i] = Res_DL_dBm[DET_Alarm_DL1_Index + i] + 5;
6161
             }
6134
             }
6162
         }else{
6135
         }else{
6163
-            Res_DL_dBm[DET_Alarm_DL1_Index + i] *= 0.1;
6136
+            if(Res_DL_dBm[DET_Alarm_DL1_Index + i] % 10 != 0){
6137
+                Res_DL_dBm[DET_Alarm_DL1_Index + i] = Res_DL_dBm[DET_Alarm_DL1_Index + i] - 5;
6138
+            }
6164
         }
6139
         }
6140
+        Res_DL_dBm[DET_Alarm_DL1_Index + i] *= 0.1;
6141
+#else
6142
+        Res_Up_DL_dBm[DET_Alarm_DL1_Index + i] = Res_Down_DL_dBm[DET_Alarm_DL1_Index + i];
6143
+        if(Res_Up_DL_dBm[DET_Alarm_DL1_Index + i] < 0) 
6144
+            Res_Up_DL_dBm[DET_Alarm_DL1_Index + i] -= 9;
6145
+        else if(Res_Up_DL_dBm[DET_Alarm_DL1_Index + i] > 0)
6146
+            Res_Up_DL_dBm[DET_Alarm_DL1_Index + i] += 9;
6147
+    
6148
+        Res_Down_DL_dBm[DET_Alarm_DL1_Index + i] *= 0.1; // down 
6149
+        Res_Up_DL_dBm[DET_Alarm_DL1_Index + i] *= 0.1; // Round
6150
+            
6151
+
6165
         
6152
         
6166
-    }
6153
+
6167
 #endif // PYJ.2020.10.15_END -- 
6154
 #endif // PYJ.2020.10.15_END -- 
6168
     }
6155
     }
6169
 //    printf("Res_DL_dBm[DET_Alarm_DL1_Index] : %d \r\n",Res_DL_dBm[DET_Alarm_DL1_Index]);    
6156
 //    printf("Res_DL_dBm[DET_Alarm_DL1_Index] : %d \r\n",Res_DL_dBm[DET_Alarm_DL1_Index]);    
@@ -6176,7 +6163,7 @@ void DET_LevelAlarmCheck(){
6176
     ret += bluecell_Currdatastatus.ULO_P1_Level1_L;   
6163
     ret += bluecell_Currdatastatus.ULO_P1_Level1_L;   
6177
     ret *= 0.001;
6164
     ret *= 0.001;
6178
 
6165
 
6179
-    Res_UL_dBm[DET_Alarm_UL1_Index] 
6166
+    Res_Down_UL_dBm[DET_Alarm_UL1_Index] 
6180
         = bluecell_Currdatastatus.ULO_Level1_H << 8 | bluecell_Currdatastatus.ULO_Level1_L; //(int8_t)Bluecell_TestPro(AutoControl_ADC_Compare(ret,&Det_UL1.Table_Det_15_dBm_H,Det_UL1.Table_Length * 2));
6167
         = bluecell_Currdatastatus.ULO_Level1_H << 8 | bluecell_Currdatastatus.ULO_Level1_L; //(int8_t)Bluecell_TestPro(AutoControl_ADC_Compare(ret,&Det_UL1.Table_Det_15_dBm_H,Det_UL1.Table_Length * 2));
6181
 
6168
 
6182
 
6169
 
@@ -6184,14 +6171,14 @@ void DET_LevelAlarmCheck(){
6184
     ret += bluecell_Currdatastatus.ULO_P2_Level2_L;   
6171
     ret += bluecell_Currdatastatus.ULO_P2_Level2_L;   
6185
     ret *= 0.001;
6172
     ret *= 0.001;
6186
 
6173
 
6187
-    Res_UL_dBm[DET_Alarm_UL2_Index] 
6174
+    Res_Down_UL_dBm[DET_Alarm_UL2_Index] 
6188
         = bluecell_Currdatastatus.ULO_Level2_H << 8 | bluecell_Currdatastatus.ULO_Level2_L;//(int8_t)Bluecell_TestPro(AutoControl_ADC_Compare(ret,&Det_UL2.Table_Det_15_dBm_H,Det_UL2.Table_Length * 2));
6175
         = bluecell_Currdatastatus.ULO_Level2_H << 8 | bluecell_Currdatastatus.ULO_Level2_L;//(int8_t)Bluecell_TestPro(AutoControl_ADC_Compare(ret,&Det_UL2.Table_Det_15_dBm_H,Det_UL2.Table_Length * 2));
6189
 
6176
 
6190
     ret  = bluecell_Currdatastatus.ULO_P3_Level3_H << 8;
6177
     ret  = bluecell_Currdatastatus.ULO_P3_Level3_H << 8;
6191
     ret += bluecell_Currdatastatus.ULO_P3_Level3_L;   
6178
     ret += bluecell_Currdatastatus.ULO_P3_Level3_L;   
6192
     ret *= 0.001;
6179
     ret *= 0.001;
6193
 
6180
 
6194
-    Res_UL_dBm[DET_Alarm_UL3_Index] 
6181
+    Res_Down_UL_dBm[DET_Alarm_UL3_Index] 
6195
         = bluecell_Currdatastatus.ULO_Level3_H << 8 | bluecell_Currdatastatus.ULO_Level3_L;//(int8_t)Bluecell_TestPro(AutoControl_ADC_Compare(ret,&Det_UL3.Table_Det_15_dBm_H,Det_UL3.Table_Length * 2));
6182
         = bluecell_Currdatastatus.ULO_Level3_H << 8 | bluecell_Currdatastatus.ULO_Level3_L;//(int8_t)Bluecell_TestPro(AutoControl_ADC_Compare(ret,&Det_UL3.Table_Det_15_dBm_H,Det_UL3.Table_Length * 2));
6196
 
6183
 
6197
 
6184
 
@@ -6199,13 +6186,13 @@ void DET_LevelAlarmCheck(){
6199
     ret += bluecell_Currdatastatus.ULO_P4_Level4_L;   
6186
     ret += bluecell_Currdatastatus.ULO_P4_Level4_L;   
6200
     ret *= 0.001;
6187
     ret *= 0.001;
6201
 
6188
 
6202
-    Res_UL_dBm[DET_Alarm_UL4_Index] 
6189
+    Res_Down_UL_dBm[DET_Alarm_UL4_Index] 
6203
         = bluecell_Currdatastatus.ULO_Level4_H << 8 | bluecell_Currdatastatus.ULO_Level4_L;//(int8_t)Bluecell_TestPro(AutoControl_ADC_Compare(ret,&Det_UL4.Table_Det_15_dBm_H,Det_UL4.Table_Length * 2));
6190
         = bluecell_Currdatastatus.ULO_Level4_H << 8 | bluecell_Currdatastatus.ULO_Level4_L;//(int8_t)Bluecell_TestPro(AutoControl_ADC_Compare(ret,&Det_UL4.Table_Det_15_dBm_H,Det_UL4.Table_Length * 2));
6204
-
6205
 //    Res_UL_dBm[DET_Alarm_UL1_Index] *= 0.1;
6191
 //    Res_UL_dBm[DET_Alarm_UL1_Index] *= 0.1;
6206
 //    Res_UL_dBm[DET_Alarm_UL2_Index] *= 0.1;
6192
 //    Res_UL_dBm[DET_Alarm_UL2_Index] *= 0.1;
6207
 //    Res_UL_dBm[DET_Alarm_UL3_Index] *= 0.1;
6193
 //    Res_UL_dBm[DET_Alarm_UL3_Index] *= 0.1;
6208
 //    Res_UL_dBm[DET_Alarm_UL4_Index] *= 0.1;
6194
 //    Res_UL_dBm[DET_Alarm_UL4_Index] *= 0.1;
6195
+#if 0 // PYJ.2020.10.16_BEGIN -- 
6209
     for(int i = 0; i < DET_Alarm_UL_Index_MAX; i++){
6196
     for(int i = 0; i < DET_Alarm_UL_Index_MAX; i++){
6210
         if(Res_UL_dBm[DET_Alarm_UL1_Index + i] % 10 != 0){
6197
         if(Res_UL_dBm[DET_Alarm_UL1_Index + i] % 10 != 0){
6211
             Res_UL_dBm[DET_Alarm_UL1_Index + i] *= 0.1;
6198
             Res_UL_dBm[DET_Alarm_UL1_Index + i] *= 0.1;
@@ -6218,22 +6205,72 @@ void DET_LevelAlarmCheck(){
6218
         }
6205
         }
6219
 
6206
 
6220
     }
6207
     }
6208
+#else
6209
+    for(int i = 0; i < DET_Alarm_UL_Index_MAX; i++){
6210
+        Res_Up_UL_dBm[DET_Alarm_UL1_Index + i] = Res_Down_UL_dBm[DET_Alarm_UL1_Index + i];
6211
+
6212
+        Res_Up_UL_dBm[DET_Alarm_UL1_Index + i] -= 9;
6213
+
6214
+
6215
+        Res_Down_UL_dBm[DET_Alarm_UL1_Index + i] *= 0.1; // down 
6216
+        Res_Up_UL_dBm[DET_Alarm_UL1_Index + i] *= 0.1; // Round
6217
+
6218
+    }
6219
+#endif // PYJ.2020.10.16_END -- 
6221
 
6220
 
6222
 
6221
 
6223
     /*
6222
     /*
6224
         DL Level Alarm Check Part
6223
         DL Level Alarm Check Part
6225
     */
6224
     */
6226
 //    printf("======================================================\r\n");
6225
 //    printf("======================================================\r\n");
6226
+    uint8_t* AlarmStatus = &bluecell_Currdatastatus.DLI_Level_Low_Alarm1;
6227
+    uint8_t* Alarm_High_Status = &bluecell_Currdatastatus.DLI_Level_High_Alarm1;
6228
+
6229
+    uint8_t* PathStatus = &bluecell_Currdatastatus.ATT_DL1_PATH;
6230
+
6227
     for(int i = 0 ; i < DET_Alarm_DL_Index_MAX; i++){
6231
     for(int i = 0 ; i < DET_Alarm_DL_Index_MAX; i++){
6228
-        if(LimitData_DL_High <= Res_DL_dBm[DET_Alarm_DL1_Index + i]){
6229
-            ADC_Alarm_DL_High_Set[DET_Alarm_DL1_Index + i] = true;
6230
-//            printf("DL High Threadhold : %d |||| DL Det : %d \r\n",LimitData_DL_High,Res_DL_dBm[DET_Alarm_DL1_Index + i]);
6231
-//            printf("ADC_Alarm_DL_High_Set %d ,Value : %d\r\n",DET_Alarm_UL1_Index + i,ADC_Alarm_DL_High_Set[DET_Alarm_UL1_Index + i]);            
6232
+//        if(i != 0) continue;
6233
+        if( Res_Down_DL_dBm[DET_Alarm_DL1_Index + i] > 0 ){
6234
+            if(LimitData_DL_High <= Res_Down_DL_dBm[DET_Alarm_DL1_Index + i]){
6235
+                ADC_Alarm_DL_High_Set[DET_Alarm_DL1_Index + i] = true;
6236
+//                printf("1DL High Threadhold : %d |||| DL Det : %d \r\n",LimitData_DL_High,Res_Down_DL_dBm[DET_Alarm_DL1_Index + i]);
6237
+//                printf("1ADC_Alarm_DL_High_Set %d ,Value : %d\r\n",DET_Alarm_DL1_Index + i,ADC_Alarm_DL_High_Set[DET_Alarm_DL1_Index + i]);            
6238
+            }
6239
+            else{
6240
+                if(LimitData_DL_High - 2 >= Res_Up_DL_dBm[DET_Alarm_DL1_Index + i])
6241
+                    ADC_Alarm_DL_High_Set[DET_Alarm_DL1_Index + i] = false;
6242
+                else{
6243
+                    if(Alarm_High_Status[DET_Alarm_DL1_Index + i] == true){
6244
+                        ADC_Alarm_DL_High_Set[DET_Alarm_DL1_Index + i] = true;
6245
+                    }else{
6246
+                         ADC_Alarm_DL_High_Set[DET_Alarm_DL1_Index + i] = false;
6247
+                    }
6248
+
6249
+                }
6250
+                
6251
+//                printf("3ADC_Alarm_DL_High_Set %d ,Value : %d\r\n",DET_Alarm_DL1_Index + i,ADC_Alarm_DL_High_Set[DET_Alarm_DL1_Index + i]);            
6252
+            }
6232
         }
6253
         }
6233
         else{
6254
         else{
6234
-            if(LimitData_DL_High - 2 >= Res_DL_dBm[DET_Alarm_DL1_Index + i])
6235
-                ADC_Alarm_DL_High_Set[DET_Alarm_DL1_Index + i] = false;
6236
-//            printf("ADC_Alarm_DL_High_Set %d ,Value : %d\r\n",DET_Alarm_UL1_Index + i,ADC_Alarm_DL_High_Set[DET_Alarm_UL1_Index + i]);            
6255
+            if(LimitData_DL_High <= Res_Up_DL_dBm[DET_Alarm_DL1_Index + i]){
6256
+                ADC_Alarm_DL_High_Set[DET_Alarm_DL1_Index + i] = true;
6257
+//                printf("2DL High Threadhold : %d |||| DL Det : %d \r\n",LimitData_DL_High,Res_Up_DL_dBm[DET_Alarm_DL1_Index + i]);
6258
+//                printf("2ADC_Alarm_DL_High_Set %d ,Value : %d\r\n",DET_Alarm_DL1_Index + i,ADC_Alarm_DL_High_Set[DET_Alarm_DL1_Index + i]);            
6259
+            }
6260
+            else{
6261
+                if(LimitData_DL_High - 2 >= Res_Down_DL_dBm[DET_Alarm_DL1_Index + i])
6262
+                    ADC_Alarm_DL_High_Set[DET_Alarm_DL1_Index + i] = false;
6263
+                else{
6264
+                    if(Alarm_High_Status[DET_Alarm_DL1_Index + i] == true){
6265
+                        ADC_Alarm_DL_High_Set[DET_Alarm_DL1_Index + i] = true;
6266
+                    }else{
6267
+                         ADC_Alarm_DL_High_Set[DET_Alarm_DL1_Index + i] = false;
6268
+                    }
6269
+
6270
+                }                
6271
+//                printf("5Res_Down_DL_dBm[DET_Alarm_DL1_Index + i] : %d ADC_Alarm_DL_High_Set %d ,Value : %d\r\n",Res_Down_DL_dBm[DET_Alarm_DL1_Index + i],DET_Alarm_DL1_Index + i,ADC_Alarm_DL_High_Set[DET_Alarm_UL1_Index + i]);            
6272
+            }
6273
+
6237
         }
6274
         }
6238
 #if 0 // PYJ.2020.06.22_BEGIN -- 
6275
 #if 0 // PYJ.2020.06.22_BEGIN -- 
6239
         printf("LimitData_DL_High: %d Res_DL_dBm [%d] : %d ,Value : %d\r\n",
6276
         printf("LimitData_DL_High: %d Res_DL_dBm [%d] : %d ,Value : %d\r\n",
@@ -6242,11 +6279,6 @@ void DET_LevelAlarmCheck(){
6242
         Res_DL_dBm[DET_Alarm_DL1_Index + i],
6279
         Res_DL_dBm[DET_Alarm_DL1_Index + i],
6243
         ADC_Alarm_DL_High_Set[DET_Alarm_DL1_Index + i]);            
6280
         ADC_Alarm_DL_High_Set[DET_Alarm_DL1_Index + i]);            
6244
 #endif // PYJ.2020.06.22_END -- 
6281
 #endif // PYJ.2020.06.22_END -- 
6245
-
6246
-//        LimitData_DL_Low,
6247
-//        DET_Alarm_UL1_Index + i,
6248
-//        Res_DL_dBm[DET_Alarm_DL1_Index + i],
6249
-//        ADC_Alarm_DL_High_Set[LimitData_DL_High + i]);            
6250
     }    
6282
     }    
6251
     
6283
     
6252
     /*
6284
     /*
@@ -6263,55 +6295,111 @@ void DET_LevelAlarmCheck(){
6263
 
6295
 
6264
 
6296
 
6265
     for(int i = 0 ; i < DET_Alarm_DL_Shutdown_Index_MAX; i++){
6297
     for(int i = 0 ; i < DET_Alarm_DL_Shutdown_Index_MAX; i++){
6266
-        if(DL_PathStatus[DET_Alarm_DL1_Shutdown_Index + i] == true
6267
-            && (LimitData_DL_Shutdown - 2 >= Res_DL_dBm[DET_Alarm_DL1_Shutdown_Index + i])
6268
-            && (MBIC_DL_ShutdownCount[DET_Alarm_DL1_Shutdown_Index + i] > 0)){
6269
-            ADC_Alarm_DL_Normal_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = true;
6270
-            if(DET_DL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i] > MBIC_OFF_MAINTAIN_SEC){
6271
-                if(DL_RetryCount[DET_Alarm_DL1_Shutdown_Index + i] > 0){// Nomal Operate
6272
-                    DL_RetryCount[DET_Alarm_DL1_Shutdown_Index + i] = 0;
6273
-//                    printf("DL%d_PATH : %d Retry Count Initialize Start %d \r\n",i+1,DL_PathStatus[DET_Alarm_DL1_Shutdown_Index + i],bluecell_Currdatastatus.DLO_Shutdown_Retry_Count2);
6298
+        if( Res_Down_DL_dBm[DET_Alarm_DL1_Index + i] > 0 ){
6299
+            if(DL_PathStatus[DET_Alarm_DL1_Shutdown_Index + i] == true
6300
+                && (LimitData_DL_Shutdown - 2 >= Res_Up_DL_dBm[DET_Alarm_DL1_Shutdown_Index + i])
6301
+                && (MBIC_DL_ShutdownCount[DET_Alarm_DL1_Shutdown_Index + i] > 0)){
6302
+                ADC_Alarm_DL_Normal_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = true;
6303
+                if(DET_DL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i] > MBIC_OFF_MAINTAIN_SEC){
6304
+                    if(DL_RetryCount[DET_Alarm_DL1_Shutdown_Index + i] > 0){// Nomal Operate
6305
+                        DL_RetryCount[DET_Alarm_DL1_Shutdown_Index + i] = 0;
6306
+    //                    printf("DL%d_PATH : %d Retry Count Initialize Start %d \r\n",i+1,DL_PathStatus[DET_Alarm_DL1_Shutdown_Index + i],bluecell_Currdatastatus.DLO_Shutdown_Retry_Count2);
6307
+                    }
6274
                 }
6308
                 }
6309
+            }else{
6310
+                ADC_Alarm_DL_Normal_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = false;
6275
             }
6311
             }
6276
-        }else{
6277
-            ADC_Alarm_DL_Normal_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = false;
6312
+        }
6313
+        else{
6314
+            if(DL_PathStatus[DET_Alarm_DL1_Shutdown_Index + i] == true
6315
+                && (LimitData_DL_Shutdown - 2 >= Res_Down_DL_dBm[DET_Alarm_DL1_Shutdown_Index + i])
6316
+                && (MBIC_DL_ShutdownCount[DET_Alarm_DL1_Shutdown_Index + i] > 0)){
6317
+                ADC_Alarm_DL_Normal_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = true;
6318
+                if(DET_DL_Normal_Shutdown_On_AlarmTimerCnt[DET_Alarm_DL1_Shutdown_Index + i] > MBIC_OFF_MAINTAIN_SEC){
6319
+                    if(DL_RetryCount[DET_Alarm_DL1_Shutdown_Index + i] > 0){// Nomal Operate
6320
+                        DL_RetryCount[DET_Alarm_DL1_Shutdown_Index + i] = 0;
6321
+    //                    printf("DL%d_PATH : %d Retry Count Initialize Start %d \r\n",i+1,DL_PathStatus[DET_Alarm_DL1_Shutdown_Index + i],bluecell_Currdatastatus.DLO_Shutdown_Retry_Count2);
6322
+                    }
6323
+                }
6324
+            }else{
6325
+                ADC_Alarm_DL_Normal_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = false;
6326
+            }
6327
+
6278
         }
6328
         }
6279
     }
6329
     }
6280
     for(int i = 0 ; i < DET_Alarm_DL_Shutdown_Index_MAX; i++){
6330
     for(int i = 0 ; i < DET_Alarm_DL_Shutdown_Index_MAX; i++){
6281
-        if(LimitData_DL_Shutdown <= Res_DL_dBm[DET_Alarm_DL1_Shutdown_Index + i]){
6282
-//            if(DL_Atten[DET_Alarm_DL1_Index + i] * 0.1 <= -15)
6283
-                ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = true;
6284
-        }
6285
-        else{
6286
-//             if(LimitData_DL_Shutdown - 2 >= Res_DL_dBm[DET_Alarm_DL1_Shutdown_Index + i])
6287
-              if(MBIC_DL_ShutdownCount[DET_Alarm_DL1_Shutdown_Index + i] > 0)
6288
-                ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = false;
6331
+        if( Res_Down_DL_dBm[DET_Alarm_UL1_Index + i] > 0 ){
6332
+            if(LimitData_DL_Shutdown <= Res_Down_DL_dBm[DET_Alarm_DL1_Shutdown_Index + i]){
6333
+    //            if(DL_Atten[DET_Alarm_DL1_Index + i] * 0.1 <= -15)
6334
+                    ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = true;
6335
+            }
6336
+            else{
6337
+    //             if(LimitData_DL_Shutdown - 2 >= Res_DL_dBm[DET_Alarm_DL1_Shutdown_Index + i])
6338
+                  if(MBIC_DL_ShutdownCount[DET_Alarm_DL1_Shutdown_Index + i] > 0)
6339
+                    ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = false;
6340
+            }
6341
+        }else{
6342
+            if(LimitData_DL_Shutdown <= Res_Up_DL_dBm[DET_Alarm_DL1_Shutdown_Index + i]){
6343
+    //            if(DL_Atten[DET_Alarm_DL1_Index + i] * 0.1 <= -15)
6344
+                    ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = true;
6345
+            }
6346
+            else{
6347
+    //             if(LimitData_DL_Shutdown - 2 >= Res_DL_dBm[DET_Alarm_DL1_Shutdown_Index + i])
6348
+                  if(MBIC_DL_ShutdownCount[DET_Alarm_DL1_Shutdown_Index + i] > 0)
6349
+                    ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = false;
6350
+            }
6351
+
6289
         }
6352
         }
6290
     }
6353
     }
6291
 
6354
 
6292
 //    printf("======================================================\r\n");
6355
 //    printf("======================================================\r\n");
6293
-        uint8_t* AlarmStatus = &bluecell_Currdatastatus.DLI_Level_Low_Alarm1;
6294
-        uint8_t* PathStatus = &bluecell_Currdatastatus.ATT_DL1_PATH;
6356
+        
6295
         for(int i = 0 ; i < DET_Alarm_DL_Index_MAX; i++){
6357
         for(int i = 0 ; i < DET_Alarm_DL_Index_MAX; i++){
6296
-            if(PathStatus[DET_Alarm_DL1_Index + i] == false){
6358
+//            if (i != 0)continue;
6359
+            
6360
+             if(PathStatus[DET_Alarm_DL1_Index + i] == false){
6297
                  ADC_Alarm_DL_Low_Set[DET_Alarm_DL1_Index + i] = false;
6361
                  ADC_Alarm_DL_Low_Set[DET_Alarm_DL1_Index + i] = false;
6298
                  continue;
6362
                  continue;
6299
             }
6363
             }
6300
             if(AlarmStatus[DET_Alarm_DL1_Index + i] == false){
6364
             if(AlarmStatus[DET_Alarm_DL1_Index + i] == false){
6301
-                if(LimitData_DL_Low >= Res_DL_dBm[DET_Alarm_DL1_Index + i])
6302
-                {
6303
-                    ADC_Alarm_DL_Low_Set[DET_Alarm_DL1_Index + i] = true;
6304
-                }
6305
-                if(LimitData_DL_Low + 2 <= Res_DL_dBm[DET_Alarm_DL1_Index + i]){
6306
-                    ADC_Alarm_DL_Low_Set[DET_Alarm_DL1_Index + i] = false;
6365
+                if( Res_Down_DL_dBm[DET_Alarm_DL1_Index + i] > 0 ){
6366
+                    if(LimitData_DL_Low >= Res_Up_DL_dBm[DET_Alarm_DL1_Index + i])
6367
+                    {
6368
+                        ADC_Alarm_DL_Low_Set[DET_Alarm_DL1_Index + i] = true;
6369
+                    }
6370
+                    else if(LimitData_DL_Low < Res_Down_DL_dBm[DET_Alarm_DL1_Index + i]){
6371
+                        ADC_Alarm_DL_Low_Set[DET_Alarm_DL1_Index + i] = false;
6372
+                    }
6373
+                }else{
6374
+                    if(LimitData_DL_Low >= Res_Down_DL_dBm[DET_Alarm_DL1_Index + i])
6375
+                    {
6376
+                        ADC_Alarm_DL_Low_Set[DET_Alarm_DL1_Index + i] = true;
6377
+                    }
6378
+                    else if(LimitData_DL_Low < Res_Up_DL_dBm[DET_Alarm_DL1_Index + i]){
6379
+                        ADC_Alarm_DL_Low_Set[DET_Alarm_DL1_Index + i] = false;
6380
+                    }
6307
                 }
6381
                 }
6308
             }else{
6382
             }else{
6309
-                if(LimitData_DL_Low + 1 >= Res_DL_dBm[DET_Alarm_DL1_Index + i])
6310
-                {
6311
-                    ADC_Alarm_DL_Low_Set[DET_Alarm_DL1_Index + i] = true;
6312
-                }
6313
-                if(LimitData_DL_Low + 2 <= Res_DL_dBm[DET_Alarm_DL1_Index + i]){
6314
-                    ADC_Alarm_DL_Low_Set[DET_Alarm_DL1_Index + i] = false;
6383
+                if(AlarmStatus[DET_Alarm_DL1_Index + i] == true){
6384
+                    if(LimitData_DL_Low + 2 > Res_Up_DL_dBm[DET_Alarm_DL1_Index + i])
6385
+                    {
6386
+                        ADC_Alarm_DL_Low_Set[DET_Alarm_DL1_Index + i] = true;
6387
+                    }
6388
+                    else if(LimitData_DL_Low + 2 <= Res_Up_DL_dBm[DET_Alarm_DL1_Index + i]){
6389
+                          ADC_Alarm_DL_Low_Set[DET_Alarm_DL1_Index + i] = false;
6390
+                    }
6391
+//                    if(LimitData_DL_Low + 2 <= Res_Up_DL_dBm[DET_Alarm_DL1_Index + i]){
6392
+//                        ADC_Alarm_DL_Low_Set[DET_Alarm_DL1_Index + i] = false;
6393
+//                    }
6394
+
6395
+                }else{
6396
+                    if(LimitData_DL_Low + 1 >= Res_Down_DL_dBm[DET_Alarm_DL1_Index + i])
6397
+                    {
6398
+                        ADC_Alarm_DL_Low_Set[DET_Alarm_DL1_Index + i] = true;
6399
+                    }
6400
+                    if(LimitData_DL_Low + 2 <= Res_Up_DL_dBm[DET_Alarm_DL1_Index + i]){
6401
+                        ADC_Alarm_DL_Low_Set[DET_Alarm_DL1_Index + i] = false;
6402
+                    }
6315
                 }
6403
                 }
6316
             }
6404
             }
6317
 
6405
 
@@ -6319,10 +6407,12 @@ void DET_LevelAlarmCheck(){
6319
         
6407
         
6320
 #if 0 // PYJ.2020.06.22_BEGIN -- 
6408
 #if 0 // PYJ.2020.06.22_BEGIN -- 
6321
         printf("=========================================================\r\n");
6409
         printf("=========================================================\r\n");
6322
-        printf("LimitData_DL_Low: %d Res_DL_dBm [%d] : %d ,Value : %d Real Alamr : %d \r\n",
6410
+        printf("LimitData_DL_Low: %d Res_Up_DL_dBm [%d] : %d  Res_Down_DL_dBm [%d] : %d ,Value : %d Real Alamr : %d \r\n",
6323
         LimitData_DL_Low,
6411
         LimitData_DL_Low,
6324
         DET_Alarm_UL1_Index + i,
6412
         DET_Alarm_UL1_Index + i,
6325
-        Res_DL_dBm[DET_Alarm_DL1_Index + i],
6413
+        Res_Up_DL_dBm[DET_Alarm_DL1_Index + i],
6414
+        DET_Alarm_UL1_Index + i,
6415
+        Res_Down_DL_dBm[DET_Alarm_DL1_Index + i],
6326
         ADC_Alarm_DL_Low_Set[DET_Alarm_DL1_Index + i],
6416
         ADC_Alarm_DL_Low_Set[DET_Alarm_DL1_Index + i],
6327
         AlarmStatus[DET_Alarm_DL1_Index + i]);            
6417
         AlarmStatus[DET_Alarm_DL1_Index + i]);            
6328
 #endif // PYJ.2020.06.22_END -- 
6418
 #endif // PYJ.2020.06.22_END -- 
@@ -6341,7 +6431,7 @@ void DET_LevelAlarmCheck(){
6341
 //          if(i != 0)
6431
 //          if(i != 0)
6342
 //                continue;
6432
 //                continue;
6343
         /*UL Shutdown Cnt plus Condition Check */
6433
         /*UL Shutdown Cnt plus Condition Check */
6344
-        if(LimitData_UL_Shutdown <= Res_UL_dBm[DET_Alarm_UL1_Shutdown_Index + i] 
6434
+        if(LimitData_UL_Shutdown <= Res_Up_UL_dBm[DET_Alarm_UL1_Shutdown_Index + i] 
6345
             && UL_PathStatus[DET_Alarm_UL1_Shutdown_Index + i] == true){
6435
             && UL_PathStatus[DET_Alarm_UL1_Shutdown_Index + i] == true){
6346
           
6436
           
6347
 //            printf("UL_PathStatus[%d] %d \r\n",i,UL_PathStatus[DET_Alarm_UL1_Shutdown_Index + i]);
6437
 //            printf("UL_PathStatus[%d] %d \r\n",i,UL_PathStatus[DET_Alarm_UL1_Shutdown_Index + i]);
@@ -6352,7 +6442,7 @@ void DET_LevelAlarmCheck(){
6352
 //            if(i != 0)
6442
 //            if(i != 0)
6353
 //                continue;  
6443
 //                continue;  
6354
             /*UL Shutdown Minus Condition Check */            
6444
             /*UL Shutdown Minus Condition Check */            
6355
-            if(LimitData_UL_Shutdown - 2 >= Res_UL_dBm[DET_Alarm_UL1_Shutdown_Index + i] || UL_PathStatus[DET_Alarm_UL1_Shutdown_Index + i] == false)
6445
+            if(LimitData_UL_Shutdown - 2 >= Res_Down_UL_dBm[DET_Alarm_UL1_Shutdown_Index + i] || UL_PathStatus[DET_Alarm_UL1_Shutdown_Index + i] == false)
6356
                 ADC_Alarm_UL_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index + i] = false;
6446
                 ADC_Alarm_UL_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index + i] = false;
6357
 //                printf("ADC_Alarm_UL_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index + i] =  %d \r\n ",ADC_Alarm_UL_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index ]);
6447
 //                printf("ADC_Alarm_UL_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index + i] =  %d \r\n ",ADC_Alarm_UL_Shutdown_Set[DET_Alarm_UL1_Shutdown_Index ]);
6358
 //            printf("2 Shutdown threas hold : %d | Curr Meas : %d Shutdown UL %d | Alarm OFF Count : %d\r\n",LimitData_UL_Shutdown,Res_UL_dBm[DET_Alarm_UL1_Shutdown_Index + i],i + 1,UL_RetryCount[DET_Alarm_UL1_Shutdown_Index + i] );
6448
 //            printf("2 Shutdown threas hold : %d | Curr Meas : %d Shutdown UL %d | Alarm OFF Count : %d\r\n",LimitData_UL_Shutdown,Res_UL_dBm[DET_Alarm_UL1_Shutdown_Index + i],i + 1,UL_RetryCount[DET_Alarm_UL1_Shutdown_Index + i] );
@@ -6381,15 +6471,17 @@ void DET_LevelAlarmCheck(){
6381
 //    LimitData_UL_High = -27;
6471
 //    LimitData_UL_High = -27;
6382
 //    printf("==========================================================\r\n");
6472
 //    printf("==========================================================\r\n");
6383
     for(int i = 0 ; i < DET_Alarm_UL_Index_MAX; i++){
6473
     for(int i = 0 ; i < DET_Alarm_UL_Index_MAX; i++){
6384
-        if(LimitData_UL_High <= Res_UL_dBm[DET_Alarm_UL1_Index + i]){
6474
+//        if(i != 0)
6475
+//            continue;        
6476
+        if(LimitData_UL_High <= Res_Up_UL_dBm[DET_Alarm_UL1_Index + i]){
6385
             ADC_Alarm_UL_Set[DET_Alarm_UL1_Index + i] = true;
6477
             ADC_Alarm_UL_Set[DET_Alarm_UL1_Index + i] = true;
6386
-//            printf("ON _Limit : %d   UL%d : %d  ADC_Alarm_UL_Set %d ,Value : %d\r\n",LimitData_UL_High,i+1,Res_UL_dBm[DET_Alarm_UL1_Index + i],DET_Alarm_UL1_Index + i,ADC_Alarm_UL_Set[DET_Alarm_UL1_Index + i]);
6478
+//            printf("ON _Limit : %d   UL%d : %d  ADC_Alarm_UL_Set %d ,Value : %d\r\n",LimitData_UL_High,i+1,Res_Up_UL_dBm[DET_Alarm_UL1_Index + i],DET_Alarm_UL1_Index + i,ADC_Alarm_UL_Set[DET_Alarm_UL1_Index + i]);
6387
         }
6479
         }
6388
         else{
6480
         else{
6389
-            if(LimitData_UL_High - 2 >= Res_UL_dBm[DET_Alarm_UL1_Index + i])
6481
+            if(LimitData_UL_High - 2 >= Res_Down_UL_dBm[DET_Alarm_UL1_Index + i])
6390
                 ADC_Alarm_UL_Set[DET_Alarm_UL1_Index + i] = false;
6482
                 ADC_Alarm_UL_Set[DET_Alarm_UL1_Index + i] = false;
6391
             DET_UL_On_AlarmTimerCnt[DET_Alarm_UL1_Index + i] = 0;
6483
             DET_UL_On_AlarmTimerCnt[DET_Alarm_UL1_Index + i] = 0;
6392
-//            printf("OFF _Limit : %d   UL%d : %d  ADC_Alarm_UL_Set %d ,Value : %d\r\n",LimitData_UL_High,i+1,Res_UL_dBm[DET_Alarm_UL1_Index + i],DET_Alarm_UL1_Index + i,ADC_Alarm_UL_Set[DET_Alarm_UL1_Index + i]);            
6484
+//            printf("OFF _Limit : %d   UL%d : %d  ADC_Alarm_UL_Set %d ,Value : %d\r\n",LimitData_UL_High,i+1,Res_Down_UL_dBm[DET_Alarm_UL1_Index + i],DET_Alarm_UL1_Index + i,ADC_Alarm_UL_Set[DET_Alarm_UL1_Index + i]);            
6393
         }
6485
         }
6394
 #if 1 // PYJ.2020.06.22_BEGIN -- 
6486
 #if 1 // PYJ.2020.06.22_BEGIN -- 
6395
 #if 0 // PYJ.2020.06.22_BEGIN --
6487
 #if 0 // PYJ.2020.06.22_BEGIN --
@@ -7672,8 +7764,10 @@ double Bluecell_TestPro(double value )
7672
 #else
7764
 #else
7673
 double Bluecell_TestPro(double value ){
7765
 double Bluecell_TestPro(double value ){
7674
     bool minusset = false;
7766
     bool minusset = false;
7767
+    value *= 0.1;
7675
     uint8_t temp = 0;
7768
     uint8_t temp = 0;
7676
 //    printf("DL1 : %f \r\n", value);
7769
 //    printf("DL1 : %f \r\n", value);
7770
+#if 0 // PYJ.2020.10.16_BEGIN -- 
7677
     if(value < 0){
7771
     if(value < 0){
7678
         value *= -1;
7772
         value *= -1;
7679
         minusset = true;
7773
         minusset = true;
@@ -7690,10 +7784,17 @@ double Bluecell_TestPro(double value ){
7690
     }
7784
     }
7691
 
7785
 
7692
     value = (temp * 0.1);
7786
     value = (temp * 0.1);
7693
-//    printf("round Ret : %f \r\n",value);
7787
+    printf("round Ret : %f \r\n",value);
7694
     if(minusset ==true)
7788
     if(minusset ==true)
7695
        value = value * -1;
7789
        value = value * -1;
7696
-    
7790
+#else
7791
+
7792
+    if(value < 0){
7793
+        value -= 0.5;
7794
+    }else{
7795
+        value += 0.5;
7796
+    }
7797
+#endif // PYJ.2020.10.16_END -- 
7697
     return value;
7798
     return value;
7698
 
7799
 
7699
 }
7800
 }
@@ -8492,6 +8593,7 @@ void AGC_Alarm_Check(uint8_t Path_Index,double AGC_Det,uint8_t* AGC_Table,uint16
8492
 void AGC_Package_Operate(uint8_t* Threshold,uint8_t* DL_MainAtten,uint8_t Tableindex,uint8_t* DLI_ADC_Level,uint8_t* DLI_Level,DET_TABLEDL_st* DL_Table,uint8_t* FRBT){
8593
 void AGC_Package_Operate(uint8_t* Threshold,uint8_t* DL_MainAtten,uint8_t Tableindex,uint8_t* DLI_ADC_Level,uint8_t* DLI_Level,DET_TABLEDL_st* DL_Table,uint8_t* FRBT){
8493
         double ret = 0;
8594
         double ret = 0;
8494
         int16_t ResdBm = 0;
8595
         int16_t ResdBm = 0;
8596
+        
8495
         int16_t CurrAtten = 0;
8597
         int16_t CurrAtten = 0;
8496
         int16_t Levelret = 0;
8598
         int16_t Levelret = 0;
8497
         int i = 0;
8599
         int i = 0;
@@ -8517,7 +8619,7 @@ void AGC_Package_Operate(uint8_t* Threshold,uint8_t* DL_MainAtten,uint8_t Tablei
8517
 
8619
 
8518
         CurrAtten = (int16_t)(DL_MainAtten[DLI_AGC_H] << 8 |  DL_MainAtten[DLI_AGC_L]);
8620
         CurrAtten = (int16_t)(DL_MainAtten[DLI_AGC_H] << 8 |  DL_MainAtten[DLI_AGC_L]);
8519
         CurrAtten *= 0.1;
8621
         CurrAtten *= 0.1;
8520
-        ResdBm = (int16_t)(DLI_Level[DLI_AGC_H] << 8 |  DLI_Level[DLI_AGC_L]);//(int8_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&DL_Table->Table_Det5_dBm_H,DL_Table->Table_Length,AGC_Table));
8622
+        ResdBm = (int16_t)(DLI_Level[DLI_AGC_H] << 8 |  DLI_Level[DLI_AGC_L]) * 10;//(int8_t)Bluecell_TestPro(AGC_AutoControl_ADC_Compare(ret,&DL_Table->Table_Det5_dBm_H,DL_Table->Table_Length,AGC_Table));
8521
         ResdBm = (int16_t)Bluecell_TestPro( ResdBm / 10);
8623
         ResdBm = (int16_t)Bluecell_TestPro( ResdBm / 10);
8522
 //        DLI_Level[DLI_AGC_H] = ((int16_t)ResdBm & 0xFF00) >> 8;
8624
 //        DLI_Level[DLI_AGC_H] = ((int16_t)ResdBm & 0xFF00) >> 8;
8523
 //        DLI_Level[DLI_AGC_L] = ((int16_t)ResdBm & 0x00FF);
8625
 //        DLI_Level[DLI_AGC_L] = ((int16_t)ResdBm & 0x00FF);
@@ -8525,12 +8627,20 @@ void AGC_Package_Operate(uint8_t* Threshold,uint8_t* DL_MainAtten,uint8_t Tablei
8525
             if(AGC_Table[i] == ResdBm)
8627
             if(AGC_Table[i] == ResdBm)
8526
                 break;
8628
                 break;
8527
         }
8629
         }
8528
-        if(bluecell_Currdatastatus.DLI_FRBT_Status != FRBT_IDEL)
8630
+        if(bluecell_Currdatastatus.DLI_FRBT_Status != FRBT_IDEL){
8529
             IwillgiveAtten = AGC_Calc(Limitdata,ResdBm);
8631
             IwillgiveAtten = AGC_Calc(Limitdata,ResdBm);
8632
+
8633
+
8634
+
8635
+        }
8530
         if(bluecell_Currdatastatus.DLI_FRBT_Status == FRBT_IDEL){
8636
         if(bluecell_Currdatastatus.DLI_FRBT_Status == FRBT_IDEL){
8531
             IwillgiveAtten = New_AGC_Calc(Limitdata,ResdBm);
8637
             IwillgiveAtten = New_AGC_Calc(Limitdata,ResdBm);
8638
+            if(Limitdata == ResdBm){
8639
+                IwillgiveAtten = CurrAtten;
8640
+            }
8532
             if(IwillgiveAtten == CurrAtten)
8641
             if(IwillgiveAtten == CurrAtten)
8533
                 IwillgiveAtten = 0;
8642
                 IwillgiveAtten = 0;
8643
+            
8534
         }
8644
         }
8535
         
8645
         
8536
         IwillgiveAtten *= -1;
8646
         IwillgiveAtten *= -1;
@@ -8542,8 +8652,10 @@ void AGC_Package_Operate(uint8_t* Threshold,uint8_t* DL_MainAtten,uint8_t Tablei
8542
         printf("I WILL GIVE YOU ATTEN  : %d\r\n",IwillgiveAtten);
8652
         printf("I WILL GIVE YOU ATTEN  : %d\r\n",IwillgiveAtten);
8543
         printf("AGC  : %d\r\n",Limitdata);
8653
         printf("AGC  : %d\r\n",Limitdata);
8544
 #endif // PYJ.2020.09.14_END -- 
8654
 #endif // PYJ.2020.09.14_END -- 
8545
-        if(bluecell_Currdatastatus.DLI_FRBT_Status != FRBT_IDEL && (CurrAtten) < IwillgiveAtten)
8655
+        if(bluecell_Currdatastatus.DLI_FRBT_Status != FRBT_IDEL && (CurrAtten) < IwillgiveAtten){
8546
             IwillgiveAtten = (CurrAtten );
8656
             IwillgiveAtten = (CurrAtten );
8657
+
8658
+        }
8547
         if(IwillgiveAtten < -15)
8659
         if(IwillgiveAtten < -15)
8548
             IwillgiveAtten = -15;
8660
             IwillgiveAtten = -15;
8549
 
8661
 
@@ -8562,6 +8674,15 @@ void AGC_Package_Operate(uint8_t* Threshold,uint8_t* DL_MainAtten,uint8_t Tablei
8562
                 DL_MainAtten[DLI_AGC_L] = ((((IwillgiveAtten) * 10) & 0x00FF));  
8674
                 DL_MainAtten[DLI_AGC_L] = ((((IwillgiveAtten) * 10) & 0x00FF));  
8563
 //                printf("Apply 2 Curr ATTEN %d \r\n", (int16_t)(DL_MainAtten[DLI_AGC_H] << 8 |  DL_MainAtten[DLI_AGC_L]));
8675
 //                printf("Apply 2 Curr ATTEN %d \r\n", (int16_t)(DL_MainAtten[DLI_AGC_H] << 8 |  DL_MainAtten[DLI_AGC_L]));
8564
                 CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus);            
8676
                 CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus);            
8677
+            }else{
8678
+                if(Limitdata == ResdBm){
8679
+                    IwillgiveAtten = 0;
8680
+                    DL_MainAtten[DLI_AGC_H] = ((((IwillgiveAtten)  * 10) & 0xFF00) >> 8) ;
8681
+                    DL_MainAtten[DLI_AGC_L] = ((((IwillgiveAtten) * 10) & 0x00FF));      
8682
+                    CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus);                       
8683
+                }            
8684
+                
8685
+
8565
             }
8686
             }
8566
         }
8687
         }
8567
         else if(bluecell_Currdatastatus.DLI_FRBT_Status != FRBT_IDEL && (ResdBm + CurrAtten) > Limitdata &&  DL_PrevIwillgiveAtten[Tableindex] > IwillgiveAtten){
8688
         else if(bluecell_Currdatastatus.DLI_FRBT_Status != FRBT_IDEL && (ResdBm + CurrAtten) > Limitdata &&  DL_PrevIwillgiveAtten[Tableindex] > IwillgiveAtten){

+ 1 - 1
Src/main.c

@@ -274,7 +274,7 @@ uint8_t MBICTest_Firmdata[8]  = {1,2,3,4,5,6,7,8};
274
   * @retval int
274
   * @retval int
275
   */
275
   */
276
 int main(void)
276
 int main(void)
277
-  {
277
+{
278
   /* USER CODE BEGIN 1 */
278
   /* USER CODE BEGIN 1 */
279
 
279
 
280
 
280