瀏覽代碼

불필요 코드 제거/ DL UL AMP ON OFF 시 Alarm 제거 하도록 수정 /DL Shutdown Alarm 조건 추가

PYJ 4 年之前
父節點
當前提交
5193a2b9dd
共有 1 個文件被更改,包括 49 次插入29 次删除
  1. 49 29
      Bluecell_Src/Bluecell_operate.c

+ 49 - 29
Bluecell_Src/Bluecell_operate.c

@@ -3255,28 +3255,6 @@ uint32_t MBIC_DataSend(uint8_t* data){
3255
         else
3255
         else
3256
             data[MBIC_PAYLOADSTART + i++] = 0;
3256
             data[MBIC_PAYLOADSTART + i++] = 0;
3257
         
3257
         
3258
-#if 0 // PYJ.2020.08.18_BEGIN -- 
3259
-        if(bluecell_Currdatastatus.ALARM_MASK2 != false)
3260
-            data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.ALARM_DLI_Level;
3261
-        else
3262
-            data[MBIC_PAYLOADSTART + i++] = 0;
3263
-
3264
-        if(bluecell_Currdatastatus.ALARM_MASK3 != false)
3265
-            data[MBIC_PAYLOADSTART + i++] = (bluecell_Currdatastatus.ALARM_DLI_AGC_Alarm & 0xF0 )
3266
-                                          | (bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN & 0x0F);
3267
-        else
3268
-            data[MBIC_PAYLOADSTART + i++] = 0;    
3269
-        if(bluecell_Currdatastatus.ALARM_MASK4 != false)                                      
3270
-            data[MBIC_PAYLOADSTART + i++] = bluecell_Currdatastatus.ALARM_ULO_Level;
3271
-        else
3272
-        data[MBIC_PAYLOADSTART + i++] = 0;
3273
-
3274
-        if(bluecell_Currdatastatus.ALARM_MASK5 != false)
3275
-            data[MBIC_PAYLOADSTART + i++] = (bluecell_Currdatastatus.ALARM_ULO_ALC_Alarm & 0xF0)
3276
-                                           |(bluecell_Currdatastatus.ALARM_ULO_SHTUTDOWN & 0x0F);
3277
-        else
3278
-            data[MBIC_PAYLOADSTART + i++] = 0;     
3279
-#else
3280
 //        printf("bluecell_Currdatastatus.ALARM_DLI_Level : %x \r\n",bluecell_Currdatastatus.ALARM_DLI_Level);
3258
 //        printf("bluecell_Currdatastatus.ALARM_DLI_Level : %x \r\n",bluecell_Currdatastatus.ALARM_DLI_Level);
3281
 //        printf("bluecell_Currdatastatus.ALARM_DLI_AGC_Alarm : %x \r\n",bluecell_Currdatastatus.ALARM_DLI_AGC_Alarm);
3259
 //        printf("bluecell_Currdatastatus.ALARM_DLI_AGC_Alarm : %x \r\n",bluecell_Currdatastatus.ALARM_DLI_AGC_Alarm);
3282
 //        printf("bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN : %x \r\n",bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN);
3260
 //        printf("bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN : %x \r\n",bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN);
@@ -3486,7 +3464,6 @@ uint32_t MBIC_DataSend(uint8_t* data){
3486
         }
3464
         }
3487
         
3465
         
3488
 
3466
 
3489
-#endif // PYJ.2020.08.18_END -- 
3490
     }
3467
     }
3491
     /*ALARM BIT MASK*/
3468
     /*ALARM BIT MASK*/
3492
     data[MBIC_PAYLOADSTART + i++] = MBIC_AID;
3469
     data[MBIC_PAYLOADSTART + i++] = MBIC_AID;
@@ -4572,6 +4549,9 @@ void Factory_Set(){
4572
 
4549
 
4573
 }
4550
 }
4574
 
4551
 
4552
+
4553
+/*When using the shutdown function, you should never use this function to turn onoff
4554
+Because this function initializes Shutdown related Count and alarm.*/
4575
 void DL_Path_OnOff(uint8_t Index,uint8_t value,uint8_t* path,uint8_t* PrevAtten,uint8_t* retrycnt,uint8_t* PrevRetryCnt){
4555
 void DL_Path_OnOff(uint8_t Index,uint8_t value,uint8_t* path,uint8_t* PrevAtten,uint8_t* retrycnt,uint8_t* PrevRetryCnt){
4576
     GPIO_TypeDef *Port = 0;
4556
     GPIO_TypeDef *Port = 0;
4577
     uint16_t Pin = 0;    
4557
     uint16_t Pin = 0;    
@@ -4580,21 +4560,27 @@ void DL_Path_OnOff(uint8_t Index,uint8_t value,uint8_t* path,uint8_t* PrevAtten,
4580
         Port = PATH_EN_DL1_GPIO_Port;
4560
         Port = PATH_EN_DL1_GPIO_Port;
4581
         Pin = PATH_EN_DL1_Pin;
4561
         Pin = PATH_EN_DL1_Pin;
4582
         bluecell_Currdatastatus.DLI_Shutdown_Alarm1 = false;
4562
         bluecell_Currdatastatus.DLI_Shutdown_Alarm1 = false;
4563
+        bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN &= ~ALARM_DLI_SHUTDOWN_P1;
4583
         break;
4564
         break;
4584
         case Path2_OnOff:
4565
         case Path2_OnOff:
4585
         Port = PATH_EN_DL2_GPIO_Port;
4566
         Port = PATH_EN_DL2_GPIO_Port;
4586
         Pin = PATH_EN_DL2_Pin;
4567
         Pin = PATH_EN_DL2_Pin;
4587
 		bluecell_Currdatastatus.DLI_Shutdown_Alarm2 = false;
4568
 		bluecell_Currdatastatus.DLI_Shutdown_Alarm2 = false;
4569
+        bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN &= ~ALARM_DLI_SHUTDOWN_P2;
4588
         break;
4570
         break;
4589
         case Path3_OnOff:
4571
         case Path3_OnOff:
4590
         Port = PATH_EN_DL3_GPIO_Port;
4572
         Port = PATH_EN_DL3_GPIO_Port;
4591
         Pin = PATH_EN_DL3_Pin;
4573
         Pin = PATH_EN_DL3_Pin;
4592
 		bluecell_Currdatastatus.DLI_Shutdown_Alarm3 = false;
4574
 		bluecell_Currdatastatus.DLI_Shutdown_Alarm3 = false;
4575
+        bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN &= ~ALARM_DLI_SHUTDOWN_P3;
4576
+        
4593
         break;
4577
         break;
4594
         case Path4_OnOff:
4578
         case Path4_OnOff:
4595
         Port = PATH_EN_DL4_GPIO_Port;
4579
         Port = PATH_EN_DL4_GPIO_Port;
4596
         Pin = PATH_EN_DL4_Pin;
4580
         Pin = PATH_EN_DL4_Pin;
4597
 		bluecell_Currdatastatus.DLI_Shutdown_Alarm4 = false;
4581
 		bluecell_Currdatastatus.DLI_Shutdown_Alarm4 = false;
4582
+        bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN &= ~ALARM_DLI_SHUTDOWN_P4;
4583
+        
4598
         break;
4584
         break;
4599
     }
4585
     }
4600
     *path = value; 
4586
     *path = value; 
@@ -4613,6 +4599,9 @@ void DL_Path_OnOff(uint8_t Index,uint8_t value,uint8_t* path,uint8_t* PrevAtten,
4613
     CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus);
4599
     CompareAttenData(bluecell_Currdatastatus,bluecell_Prevdatastatus);
4614
 
4600
 
4615
 }
4601
 }
4602
+/*When using the shutdown function, you should never use this function to turn onoff
4603
+Because this function initializes Shutdown related Count and alarm.*/
4604
+
4616
 void UL_Path_OnOff(uint8_t Index,uint8_t value,uint8_t* path,uint8_t* PrevAtten,uint8_t* retrycnt,uint8_t* PrevRetryCnt){
4605
 void UL_Path_OnOff(uint8_t Index,uint8_t value,uint8_t* path,uint8_t* PrevAtten,uint8_t* retrycnt,uint8_t* PrevRetryCnt){
4617
     GPIO_TypeDef *Port = 0;
4606
     GPIO_TypeDef *Port = 0;
4618
     uint16_t Pin = 0;    
4607
     uint16_t Pin = 0;    
@@ -4622,21 +4611,25 @@ void UL_Path_OnOff(uint8_t Index,uint8_t value,uint8_t* path,uint8_t* PrevAtten,
4622
         Port = PATH_EN_UL1_GPIO_Port;
4611
         Port = PATH_EN_UL1_GPIO_Port;
4623
         Pin = PATH_EN_UL1_Pin;
4612
         Pin = PATH_EN_UL1_Pin;
4624
 		bluecell_Currdatastatus.ULO_Shutdown_Alarm1 = false;
4613
 		bluecell_Currdatastatus.ULO_Shutdown_Alarm1 = false;
4614
+        bluecell_Currdatastatus.ALARM_ULO_SHTUTDOWN &= ~ALARM_ULO_SHUTDOWN_P1;
4625
         break;
4615
         break;
4626
         case Path2_OnOff:
4616
         case Path2_OnOff:
4627
         Port = PATH_EN_UL2_GPIO_Port;
4617
         Port = PATH_EN_UL2_GPIO_Port;
4628
         Pin = PATH_EN_UL2_Pin;
4618
         Pin = PATH_EN_UL2_Pin;
4629
 		bluecell_Currdatastatus.ULO_Shutdown_Alarm2 = false;
4619
 		bluecell_Currdatastatus.ULO_Shutdown_Alarm2 = false;
4620
+        bluecell_Currdatastatus.ALARM_ULO_SHTUTDOWN &= ~ALARM_ULO_SHUTDOWN_P2;        
4630
         break;
4621
         break;
4631
         case Path3_OnOff:
4622
         case Path3_OnOff:
4632
         Port = PATH_EN_UL3_GPIO_Port;
4623
         Port = PATH_EN_UL3_GPIO_Port;
4633
         Pin = PATH_EN_UL3_Pin;
4624
         Pin = PATH_EN_UL3_Pin;
4634
 		bluecell_Currdatastatus.ULO_Shutdown_Alarm3 = false;
4625
 		bluecell_Currdatastatus.ULO_Shutdown_Alarm3 = false;
4626
+        bluecell_Currdatastatus.ALARM_ULO_SHTUTDOWN &= ~ALARM_ULO_SHUTDOWN_P3;        
4635
         break;
4627
         break;
4636
         case Path4_OnOff:
4628
         case Path4_OnOff:
4637
         Port = PATH_EN_UL4_GPIO_Port;
4629
         Port = PATH_EN_UL4_GPIO_Port;
4638
         Pin = PATH_EN_UL4_Pin;
4630
         Pin = PATH_EN_UL4_Pin;
4639
 		bluecell_Currdatastatus.ULO_Shutdown_Alarm4 = false;
4631
 		bluecell_Currdatastatus.ULO_Shutdown_Alarm4 = false;
4632
+        bluecell_Currdatastatus.ALARM_ULO_SHTUTDOWN &= ~ALARM_ULO_SHUTDOWN_P4;        
4640
         break;
4633
         break;
4641
     }
4634
     }
4642
     *path = value; 
4635
     *path = value; 
@@ -6316,6 +6309,11 @@ void DET_LevelAlarmCheck(){
6316
         }
6309
         }
6317
         Res_DL_dBm[DET_Alarm_DL1_Index + i] *= 0.1;
6310
         Res_DL_dBm[DET_Alarm_DL1_Index + i] *= 0.1;
6318
 #else
6311
 #else
6312
+//        if(i == 2){
6313
+//            printf("======================================================\r\n");            
6314
+//            printf("Res_Down_DL_dBm[DET_Alarm_DL1_Index + i] : %d \r\n",Res_Down_DL_dBm[DET_Alarm_DL1_Index + i]);
6315
+//        }
6316
+
6319
         Res_Up_DL_dBm[DET_Alarm_DL1_Index + i] = Res_Down_DL_dBm[DET_Alarm_DL1_Index + i];
6317
         Res_Up_DL_dBm[DET_Alarm_DL1_Index + i] = Res_Down_DL_dBm[DET_Alarm_DL1_Index + i];
6320
         if(Res_Up_DL_dBm[DET_Alarm_DL1_Index + i] < 0) 
6318
         if(Res_Up_DL_dBm[DET_Alarm_DL1_Index + i] < 0) 
6321
             Res_Up_DL_dBm[DET_Alarm_DL1_Index + i] -= 9;
6319
             Res_Up_DL_dBm[DET_Alarm_DL1_Index + i] -= 9;
@@ -6324,6 +6322,7 @@ void DET_LevelAlarmCheck(){
6324
     
6322
     
6325
         Res_Down_DL_dBm[DET_Alarm_DL1_Index + i] *= 0.1; // down 
6323
         Res_Down_DL_dBm[DET_Alarm_DL1_Index + i] *= 0.1; // down 
6326
         Res_Up_DL_dBm[DET_Alarm_DL1_Index + i] *= 0.1; // Round
6324
         Res_Up_DL_dBm[DET_Alarm_DL1_Index + i] *= 0.1; // Round
6325
+        
6327
             
6326
             
6328
 
6327
 
6329
         
6328
         
@@ -6525,13 +6524,18 @@ void DET_LevelAlarmCheck(){
6525
 //                    printf("1Res_Down_DL_dBm : %d \r\n",Res_Down_DL_dBm[DET_Alarm_DL1_Shutdown_Index ]);     
6524
 //                    printf("1Res_Down_DL_dBm : %d \r\n",Res_Down_DL_dBm[DET_Alarm_DL1_Shutdown_Index ]);     
6526
 //                  }
6525
 //                  }
6527
                     ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = true;
6526
                     ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = true;
6528
-//                printf("Shutdown On 1\r\n");
6527
+//                    if(i == 2){    
6528
+////                        printf("Shutdown On 1\r\n");
6529
+//                    }
6529
             }
6530
             }
6530
             else{
6531
             else{
6531
                 if(LimitData_DL_Shutdown - 2 < Res_Down_DL_dBm[DET_Alarm_DL1_Shutdown_Index + i]
6532
                 if(LimitData_DL_Shutdown - 2 < Res_Down_DL_dBm[DET_Alarm_DL1_Shutdown_Index + i]
6532
                     && MBIC_DL_ShutdownCount[DET_Alarm_DL1_Shutdown_Index + i] > 0 )
6533
                     && MBIC_DL_ShutdownCount[DET_Alarm_DL1_Shutdown_Index + i] > 0 )
6533
                 {
6534
                 {
6534
                     ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = true;
6535
                     ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = true;
6536
+//                    if(i == 2){    
6537
+////                        printf("Shutdown On 1_2\r\n");
6538
+//                    }                    
6535
 //                  if(i == 0){
6539
 //                  if(i == 0){
6536
 //                    printf("2Res_Down_DL_dBm : %d \r\n",Res_Down_DL_dBm[DET_Alarm_DL1_Shutdown_Index ]);     
6540
 //                    printf("2Res_Down_DL_dBm : %d \r\n",Res_Down_DL_dBm[DET_Alarm_DL1_Shutdown_Index ]);     
6537
 //                  }                    
6541
 //                  }                    
@@ -6549,6 +6553,9 @@ void DET_LevelAlarmCheck(){
6549
             if(LimitData_DL_Shutdown < Res_Down_DL_dBm[DET_Alarm_DL1_Shutdown_Index + i]){
6553
             if(LimitData_DL_Shutdown < Res_Down_DL_dBm[DET_Alarm_DL1_Shutdown_Index + i]){
6550
                 //            if(DL_Atten[DET_Alarm_DL1_Index + i] * 0.1 <= -15)
6554
                 //            if(DL_Atten[DET_Alarm_DL1_Index + i] * 0.1 <= -15)
6551
                 ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = true;
6555
                 ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = true;
6556
+//                if(i == 2){    
6557
+////                    printf("Shutdown On 2_1\r\n");
6558
+//                }                
6552
 //                printf("3Res_Down_DL_dBm : %d \r\n",Res_Down_DL_dBm[DET_Alarm_DL1_Shutdown_Index ]);     
6559
 //                printf("3Res_Down_DL_dBm : %d \r\n",Res_Down_DL_dBm[DET_Alarm_DL1_Shutdown_Index ]);     
6553
                 //                    printf("Shutdown On 2\r\n");                      
6560
                 //                    printf("Shutdown On 2\r\n");                      
6554
             }
6561
             }
@@ -6557,21 +6564,33 @@ void DET_LevelAlarmCheck(){
6557
                 && MBIC_DL_ShutdownCount[DET_Alarm_DL1_Shutdown_Index + i] > 0 ){
6564
                 && MBIC_DL_ShutdownCount[DET_Alarm_DL1_Shutdown_Index + i] > 0 ){
6558
 //                    printf("4Res_Down_DL_dBm : %d \r\n",Res_Down_DL_dBm[DET_Alarm_DL1_Shutdown_Index ]);                         
6565
 //                    printf("4Res_Down_DL_dBm : %d \r\n",Res_Down_DL_dBm[DET_Alarm_DL1_Shutdown_Index ]);                         
6559
                     ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = true;
6566
                     ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = true;
6560
-                    //                        printf("Shutdown On 2_1\r\n");
6567
+//                    printf("Shutdown On 2_2\r\n");
6561
                 }
6568
                 }
6569
+                else if(MBIC_DL_ShutdownCount[DET_Alarm_DL1_Shutdown_Index + i] > 0
6570
+                    && LimitData_DL_Shutdown - 2  < Res_Down_DL_dBm[DET_Alarm_DL1_Shutdown_Index + i]){
6571
+                    ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = true;
6572
+//                    if(i == 2){
6573
+////                        printf("Shutdown On 2_3\r\n");                                          
6574
+//                    }
6575
+                }                
6562
                 else if(MBIC_DL_ShutdownCount[DET_Alarm_DL1_Shutdown_Index + i] > 0){
6576
                 else if(MBIC_DL_ShutdownCount[DET_Alarm_DL1_Shutdown_Index + i] > 0){
6563
                     ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = false;
6577
                     ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = false;
6564
-                    //                    printf("Shutdown Off 2\r\n");                                          
6578
+//                    if(i == 2){
6579
+////                        printf("Shutdown Off 2\r\n");                                          
6580
+//                    }
6565
                 }
6581
                 }
6566
                 else if(MBIC_DL_ShutdownCount[DET_Alarm_DL1_Shutdown_Index + i] == 0
6582
                 else if(MBIC_DL_ShutdownCount[DET_Alarm_DL1_Shutdown_Index + i] == 0
6567
                     && LimitData_DL_Shutdown > Res_Up_DL_dBm[DET_Alarm_DL1_Shutdown_Index + i]){
6583
                     && LimitData_DL_Shutdown > Res_Up_DL_dBm[DET_Alarm_DL1_Shutdown_Index + i]){
6568
                     ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = false;
6584
                     ADC_Alarm_DL_Shutdown_Set[DET_Alarm_DL1_Shutdown_Index + i] = false;
6585
+//                    if(i == 2){
6586
+////                        printf("Shutdown Off 3\r\n");                                          
6587
+//                    }                    
6569
                 }
6588
                 }
6570
             }
6589
             }
6571
 
6590
 
6572
         }
6591
         }
6573
 #if 0 // PYJ.2020.10.23_BEGIN -- 
6592
 #if 0 // PYJ.2020.10.23_BEGIN -- 
6574
-       if(i == 3){
6593
+       if(i == 2){
6575
             printf("======================================================\r\n");
6594
             printf("======================================================\r\n");
6576
             printf("Res_Down_DL_dBm : %d \r\n",Res_Down_DL_dBm[DET_Alarm_DL1_Shutdown_Index + i ]);
6595
             printf("Res_Down_DL_dBm : %d \r\n",Res_Down_DL_dBm[DET_Alarm_DL1_Shutdown_Index + i ]);
6577
             printf("Res_Up_DL_dBm : %d \r\n",Res_Up_DL_dBm[DET_Alarm_DL1_Shutdown_Index + i]);       
6596
             printf("Res_Up_DL_dBm : %d \r\n",Res_Up_DL_dBm[DET_Alarm_DL1_Shutdown_Index + i]);       
@@ -9502,7 +9521,8 @@ void DL_Shutdown_Operate(uint8_t index,uint8_t* path,uint8_t* retrycnt,uint8_t*
9502
         if(DET_DL_Shutdown_Off_AlarmTimerCnt[index] >= MBIC_OFF_MAINTAIN_SEC
9521
         if(DET_DL_Shutdown_Off_AlarmTimerCnt[index] >= MBIC_OFF_MAINTAIN_SEC
9503
             && (*retrycnt) != RETRYCNT_MAX){
9522
             && (*retrycnt) != RETRYCNT_MAX){
9504
             bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN &= ~AlarmFlag;
9523
             bluecell_Currdatastatus.ALARM_DLI_SHTUTDOWN &= ~AlarmFlag;
9505
-            *ShutdownAlarm       = false;            
9524
+            *ShutdownAlarm       = false;         
9525
+            
9506
         }
9526
         }
9507
     } 
9527
     } 
9508
     if((*retrycnt) >= 1){
9528
     if((*retrycnt) >= 1){
@@ -9618,7 +9638,7 @@ void UL_Shutdown_Operate(uint8_t Index,uint8_t* Path,uint8_t* PrevATT,uint8_t* R
9618
         if(DET_UL_Shutdown_Off_AlarmTimerCnt[Index] >= MBIC_OFF_MAINTAIN_SEC
9638
         if(DET_UL_Shutdown_Off_AlarmTimerCnt[Index] >= MBIC_OFF_MAINTAIN_SEC
9619
             && (*RetryCnt) != RETRYCNT_MAX){ 
9639
             && (*RetryCnt) != RETRYCNT_MAX){ 
9620
             bluecell_Currdatastatus.ALARM_ULO_SHTUTDOWN &= ~AlarmFlag;
9640
             bluecell_Currdatastatus.ALARM_ULO_SHTUTDOWN &= ~AlarmFlag;
9621
-            *ShutdownAlarm       = false;            
9641
+            *ShutdownAlarm       = false;      
9622
         }
9642
         }
9623
     } 
9643
     } 
9624
     if((*RetryCnt) >= 1){
9644
     if((*RetryCnt) >= 1){