1214 lines
40 KiB
C
1214 lines
40 KiB
C
|
|
#include "includes.h"
|
|||
|
|
|
|||
|
|
// <20>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
#define SAMPLE_COUNT (20)
|
|||
|
|
|
|||
|
|
// ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><C9BC>ı<EFBFBD>־
|
|||
|
|
volatile uint8_t Config_Sample_Request = 0;
|
|||
|
|
volatile uint8_t Config_Vacuum_Request = 0;
|
|||
|
|
// <20>õ<EFBFBD><C3B5>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD>ݵ<EFBFBD>֪ͨ
|
|||
|
|
volatile uint8_t GPRS_semSampled = 0;
|
|||
|
|
|
|||
|
|
// ֪ͨ<CDA8>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD>ź<EFBFBD><C5BA><EFBFBD>
|
|||
|
|
SemaphoreHandle_t Sample_Semaphore = NULL; // <20><>ֵ<EFBFBD>ź<EFBFBD><C5BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
// ֪ͨ<CDA8><D6AA>װƥ<D7B0><C6A5><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD><C5BA><EFBFBD>
|
|||
|
|
SemaphoreHandle_t Match_Semaphore = NULL; // <20><>ֵ<EFBFBD>ź<EFBFBD><C5BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|
|||
|
|
// <20><>ǰ<EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD>
|
|||
|
|
volatile uint8_t Sample_phase = 0;
|
|||
|
|
// <20>ɼ<EFBFBD><C9BC>Ƿ<EFBFBD>æ
|
|||
|
|
uint32_t Sample_Busy()
|
|||
|
|
{
|
|||
|
|
return (Sample_phase != 0);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ֪ͨ<CDA8>ɼ<EFBFBD>
|
|||
|
|
void Sample_Notify()
|
|||
|
|
{
|
|||
|
|
if(!Sample_Busy())
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
xSemaphoreGive(Sample_Semaphore);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ֪ͨ<CDA8>ɼ<EFBFBD>
|
|||
|
|
void Sample_NotifyFromISR()
|
|||
|
|
{
|
|||
|
|
BaseType_t xHigherPriorityTaskWoken;
|
|||
|
|
|
|||
|
|
if(!Sample_Busy())
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
xSemaphoreGiveFromISR(Sample_Semaphore, &xHigherPriorityTaskWoken);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>й¶<D0B9><C2B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
void Leak_Handler(void)
|
|||
|
|
{
|
|||
|
|
if(Wakeup_Sleeping)
|
|||
|
|
{
|
|||
|
|
SysTick->CTRL |= (SysTick_CTRL_ENABLE_Msk | SysTick_CTRL_TICKINT_Msk);
|
|||
|
|
delay_ms(10);
|
|||
|
|
|
|||
|
|
Vcc_Enable();
|
|||
|
|
delay_ms(40);
|
|||
|
|
Wakeup_Sleeping = 0;
|
|||
|
|
|
|||
|
|
printf("\n\nWake up by LEAK.\n\n");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
Sample_NotifyFromISR();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20>ɼ<EFBFBD>һ<EFBFBD><D2BB>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD>ܹ<EFBFBD><DCB9>ɼ<EFBFBD>20<32>Σ<EFBFBD>ȡ<EFBFBD>м<EFBFBD>10<31>ε<EFBFBD>ƽ<EFBFBD><C6BD>ֵ
|
|||
|
|
uint32_t Sample_ChannelOne(uint32_t channel)
|
|||
|
|
{
|
|||
|
|
uint32_t i;
|
|||
|
|
uint32_t adc[SAMPLE_COUNT];
|
|||
|
|
|
|||
|
|
LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_1, channel);
|
|||
|
|
for(i = 0; i < SAMPLE_COUNT; i++)
|
|||
|
|
{
|
|||
|
|
LL_ADC_REG_StartConversion(ADC1);
|
|||
|
|
while(LL_ADC_REG_IsConversionOngoing(ADC1));
|
|||
|
|
adc[i] = LL_ADC_REG_ReadConversionData12(ADC1);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
sort(adc, SAMPLE_COUNT);
|
|||
|
|
adc[0] = 0;
|
|||
|
|
for(i = 0; i < (SAMPLE_COUNT / 2); i++)
|
|||
|
|
adc[0] += adc[SAMPLE_COUNT / 4 + i];
|
|||
|
|
|
|||
|
|
i = adc[0] / (SAMPLE_COUNT / 2);
|
|||
|
|
printf("\nchannel %d adc: %d, volt: %dmV\n", channel, i, i * 3000 / 4095);
|
|||
|
|
return i;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void Sample_Init()
|
|||
|
|
{
|
|||
|
|
LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
|
|||
|
|
LL_EXTI_InitTypeDef EXTI_InitStruct = {0};
|
|||
|
|
|
|||
|
|
LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA);
|
|||
|
|
/**ADC1 GPIO Configuration
|
|||
|
|
PA0 ------> ADC1_IN5<EFBFBD><EFBFBD>AD5<EFBFBD><EFBFBD>
|
|||
|
|
PA1 ------> ADC1_IN6 (AD6)
|
|||
|
|
PA5 ------> ADC1_IN10 (AD10)
|
|||
|
|
PA6 ------> ADC1_IN11 (AD11)
|
|||
|
|
PA7 ------> ADC1_IN12 (AD12)
|
|||
|
|
*/
|
|||
|
|
GPIO_InitStruct.Pin = LL_GPIO_PIN_0|LL_GPIO_PIN_1
|
|||
|
|
|LL_GPIO_PIN_5|LL_GPIO_PIN_6|LL_GPIO_PIN_7;
|
|||
|
|
GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
|
|||
|
|
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
|||
|
|
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
|||
|
|
|
|||
|
|
LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB);
|
|||
|
|
/**ADC1 GPIO Configuration
|
|||
|
|
PB0 ------> ADC1_IN15<EFBFBD><EFBFBD>AD_BAT)
|
|||
|
|
*/
|
|||
|
|
GPIO_InitStruct.Pin = LL_GPIO_PIN_0;
|
|||
|
|
GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
|
|||
|
|
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
|||
|
|
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|||
|
|
|
|||
|
|
LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC);
|
|||
|
|
/**ADC1 GPIO Configuration
|
|||
|
|
PC0 ------> ADC1_IN1<EFBFBD><EFBFBD>AD1)
|
|||
|
|
PC1 ------> ADC1_IN2<EFBFBD><EFBFBD>AD2)
|
|||
|
|
PC2 ------> ADC1_IN3<EFBFBD><EFBFBD>AD3)
|
|||
|
|
PC3 ------> ADC1_IN4<EFBFBD><EFBFBD>AD4)
|
|||
|
|
*/
|
|||
|
|
GPIO_InitStruct.Pin = LL_GPIO_PIN_0|LL_GPIO_PIN_1|LL_GPIO_PIN_2|LL_GPIO_PIN_3;
|
|||
|
|
GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
|
|||
|
|
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
|||
|
|
LL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
|||
|
|
|
|||
|
|
// й¶<D0B9><C2B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOE);
|
|||
|
|
|
|||
|
|
/**/
|
|||
|
|
LL_SYSCFG_SetEXTISource(LL_SYSCFG_EXTI_PORTE, LL_SYSCFG_EXTI_LINE8);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD><C5BA><EFBFBD>
|
|||
|
|
if(Sample_Semaphore == NULL)
|
|||
|
|
Sample_Semaphore = xSemaphoreCreateBinary();
|
|||
|
|
if(Match_Semaphore == NULL)
|
|||
|
|
Match_Semaphore = xSemaphoreCreateBinary();
|
|||
|
|
|
|||
|
|
/**/
|
|||
|
|
EXTI_InitStruct.Line_0_31 = LL_EXTI_LINE_8;
|
|||
|
|
EXTI_InitStruct.Line_32_63 = LL_EXTI_LINE_NONE;
|
|||
|
|
EXTI_InitStruct.LineCommand = ENABLE;
|
|||
|
|
EXTI_InitStruct.Mode = LL_EXTI_MODE_IT;
|
|||
|
|
EXTI_InitStruct.Trigger = LL_EXTI_TRIGGER_RISING_FALLING;
|
|||
|
|
LL_EXTI_Init(&EXTI_InitStruct);
|
|||
|
|
|
|||
|
|
/**/
|
|||
|
|
LL_GPIO_SetPinPull(GPIOE, LL_GPIO_PIN_8, LL_GPIO_PULL_DOWN);
|
|||
|
|
|
|||
|
|
/**/
|
|||
|
|
LL_GPIO_SetPinMode(GPIOE, LL_GPIO_PIN_8, LL_GPIO_MODE_INPUT);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void Sample_Open()
|
|||
|
|
{
|
|||
|
|
uint32_t vrefint_cal = *((volatile uint16_t *)(0x1fff75aa));
|
|||
|
|
|
|||
|
|
LL_ADC_InitTypeDef ADC_InitStruct = {0};
|
|||
|
|
LL_ADC_REG_InitTypeDef ADC_REG_InitStruct = {0};
|
|||
|
|
LL_ADC_CommonInitTypeDef ADC_CommonInitStruct = {0};
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ô<EFBFBD><C3B4><EFBFBD><EFBFBD><EFBFBD>״̬
|
|||
|
|
dcBuff.sampleData.vacuum[0].staVacuum = VACUUM_STATUS_COMM_FAULT;
|
|||
|
|
dcBuff.sampleData.leak.staLeak = LEAK_STATUS_COMM_FAULT;
|
|||
|
|
|
|||
|
|
NVIC_SetPriority(EXTI9_5_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),5, 0));
|
|||
|
|
NVIC_EnableIRQ(EXTI9_5_IRQn);
|
|||
|
|
|
|||
|
|
/* Peripheral clock enable */
|
|||
|
|
LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_ADC);
|
|||
|
|
|
|||
|
|
/** Common config
|
|||
|
|
*/
|
|||
|
|
ADC_InitStruct.Resolution = LL_ADC_RESOLUTION_12B;
|
|||
|
|
ADC_InitStruct.DataAlignment = LL_ADC_DATA_ALIGN_RIGHT;
|
|||
|
|
ADC_InitStruct.LowPowerMode = LL_ADC_LP_AUTOWAIT;
|
|||
|
|
LL_ADC_Init(ADC1, &ADC_InitStruct);
|
|||
|
|
ADC_REG_InitStruct.TriggerSource = LL_ADC_REG_TRIG_SOFTWARE;
|
|||
|
|
ADC_REG_InitStruct.SequencerLength = LL_ADC_REG_SEQ_SCAN_DISABLE;
|
|||
|
|
ADC_REG_InitStruct.SequencerDiscont = LL_ADC_REG_SEQ_DISCONT_DISABLE;
|
|||
|
|
ADC_REG_InitStruct.ContinuousMode = LL_ADC_REG_CONV_SINGLE;
|
|||
|
|
ADC_REG_InitStruct.DMATransfer = LL_ADC_REG_DMA_TRANSFER_NONE;
|
|||
|
|
ADC_REG_InitStruct.Overrun = LL_ADC_REG_OVR_DATA_PRESERVED;
|
|||
|
|
LL_ADC_REG_Init(ADC1, &ADC_REG_InitStruct);
|
|||
|
|
LL_ADC_ConfigOverSamplingRatioShift(ADC1, LL_ADC_OVS_RATIO_16, LL_ADC_OVS_SHIFT_RIGHT_4);
|
|||
|
|
LL_ADC_SetOverSamplingDiscont(ADC1, LL_ADC_OVS_REG_CONT);
|
|||
|
|
LL_ADC_DisableIT_EOC(ADC1);
|
|||
|
|
LL_ADC_DisableIT_EOS(ADC1);
|
|||
|
|
LL_ADC_DisableDeepPowerDown(ADC1);
|
|||
|
|
LL_ADC_EnableInternalRegulator(ADC1);
|
|||
|
|
ADC_CommonInitStruct.CommonClock = LL_ADC_CLOCK_SYNC_PCLK_DIV4;
|
|||
|
|
LL_ADC_CommonInit(__LL_ADC_COMMON_INSTANCE(ADC1), &ADC_CommonInitStruct);
|
|||
|
|
/** Configure Regular Channel
|
|||
|
|
*/
|
|||
|
|
LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_1, LL_ADC_SAMPLINGTIME_24CYCLES_5);
|
|||
|
|
LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_1, LL_ADC_SINGLE_ENDED);
|
|||
|
|
LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_2, LL_ADC_SAMPLINGTIME_24CYCLES_5);
|
|||
|
|
LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_2, LL_ADC_SINGLE_ENDED);
|
|||
|
|
LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_3, LL_ADC_SAMPLINGTIME_24CYCLES_5);
|
|||
|
|
LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_3, LL_ADC_SINGLE_ENDED);
|
|||
|
|
LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_4, LL_ADC_SAMPLINGTIME_24CYCLES_5);
|
|||
|
|
LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_4, LL_ADC_SINGLE_ENDED);
|
|||
|
|
LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_5, LL_ADC_SAMPLINGTIME_24CYCLES_5);
|
|||
|
|
LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_5, LL_ADC_SINGLE_ENDED);
|
|||
|
|
LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_6, LL_ADC_SAMPLINGTIME_24CYCLES_5);
|
|||
|
|
LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_6, LL_ADC_SINGLE_ENDED);
|
|||
|
|
LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_10, LL_ADC_SAMPLINGTIME_24CYCLES_5);
|
|||
|
|
LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_10, LL_ADC_SINGLE_ENDED);
|
|||
|
|
LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_11, LL_ADC_SAMPLINGTIME_24CYCLES_5);
|
|||
|
|
LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_11, LL_ADC_SINGLE_ENDED);
|
|||
|
|
LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_12, LL_ADC_SAMPLINGTIME_24CYCLES_5);
|
|||
|
|
LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_12, LL_ADC_SINGLE_ENDED);
|
|||
|
|
LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_15, LL_ADC_SAMPLINGTIME_24CYCLES_5);
|
|||
|
|
LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_15, LL_ADC_SINGLE_ENDED);
|
|||
|
|
|
|||
|
|
Sample_ReOpen();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><DFBB><EFBFBD><EFBFBD>Ժ<EFBFBD><D4BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD>иú<D0B8><C3BA><EFBFBD>
|
|||
|
|
void Sample_ReOpen()
|
|||
|
|
{
|
|||
|
|
// ADCӲ<43><D3B2>У<EFBFBD><D0A3>
|
|||
|
|
VCC_SENSOR_5V_ON();
|
|||
|
|
delay_ms(50);
|
|||
|
|
LL_ADC_StartCalibration(ADC1, LL_ADC_SINGLE_ENDED);
|
|||
|
|
while(LL_ADC_IsCalibrationOnGoing(ADC1));
|
|||
|
|
VCC_SENSOR_5V_OFF();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void Sample_Task(void *p_arg)
|
|||
|
|
{
|
|||
|
|
uint16_t adc1, adc2;
|
|||
|
|
data_dtu_t dtuSample;
|
|||
|
|
data_sample_t sample;
|
|||
|
|
uint32_t sample_time;
|
|||
|
|
// ÿ<><C3BF>8Сʱ<D0A1><CAB1>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>գ<EFBFBD><D5A3>ϵ<EFBFBD><CFB5><EFBFBD>һ<EFBFBD>β<EFBFBD><CEB2>⣩
|
|||
|
|
uint32_t vacuum_seconds = 30, vaccuumTick = 0;
|
|||
|
|
uint8_t lastLeakWarning = 0;
|
|||
|
|
|
|||
|
|
int16_t i;
|
|||
|
|
uint32_t u32Sample;
|
|||
|
|
static uint8_t charging = 0; // <20><>¼<EFBFBD><C2BC>װ״̬
|
|||
|
|
static uint32_t lowest_Sample = 0xFFFFFFFFul; // <20><>¼Һλ<D2BA><CEBB><EFBFBD>͵㣺<CDB5><E3A3BA>ֵΪ<D6B5><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϳ<D0B6>װ<EFBFBD><D7B0>ʼ<EFBFBD><CABC>
|
|||
|
|
static uint32_t highest_Sample = 0; // <20><>¼Һλ<D2BA><CEBB><EFBFBD>ߵ㣺<DFB5><E3A3BA>ֵΪ<D6B5><CEAA>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϳ<D0B6>װ<EFBFBD><D7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
static uint8_t stopGrowCount = 0; // <20><>¼Һλֹͣ<CDA3><D6B9><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>
|
|||
|
|
static uint32_t last_SampleTime = 0; // <20><>¼<EFBFBD><C2BC>װ<EFBFBD>б<EFBFBD><D0B1><EFBFBD>ʱ<EFBFBD>䣨<EFBFBD><E4A3A8><EFBFBD><EFBFBD>ʱ<EFBFBD>䲻<EFBFBD>ܹ<EFBFBD><DCB9>̣<EFBFBD>
|
|||
|
|
uint32_t totalSeconds;
|
|||
|
|
static uint32_t last_volumePct = 0; // <20><>¼<EFBFBD>ϴε<CFB4>Һλ
|
|||
|
|
static uint16_t last_Press = 0;
|
|||
|
|
static int16_t last_Tempr = -300;
|
|||
|
|
static uint16_t last_Vacuum = 0;
|
|||
|
|
S_RTC_TIME_DATA_T sRTC;
|
|||
|
|
|
|||
|
|
// TTSЭ<53><D0AD>
|
|||
|
|
static uint32_t last_spanPct[20] = {0}; // <20><>¼<EFBFBD>ϴα仯<CEB1><E4BBAF><EFBFBD>İٷֱȻ<D6B1><C8BB><EFBFBD>
|
|||
|
|
static uint32_t last_spanTime[20] = {0}; // <20><>¼<EFBFBD>ϴα仯<CEB1><E4BBAF><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
static uint8_t last_spanCount = 0; // <20><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>
|
|||
|
|
uint32_t span;
|
|||
|
|
|
|||
|
|
static uint32_t Match_Time = 0;
|
|||
|
|
|
|||
|
|
static uint8_t first = 1;
|
|||
|
|
|
|||
|
|
uint16_t adDPress_inhibition; // 4~20mA<6D><41><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
static uint16_t last_adDPress = 0; // <20><>¼<EFBFBD><C2BC>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ѹ<EFBFBD>ɼ<EFBFBD>ֵ
|
|||
|
|
|
|||
|
|
// <20><>Զ<EFBFBD><D4B6><EFBFBD>壺<EFBFBD><E5A3BA><EFBFBD><EFBFBD><EFBFBD>жϷ<D0B6><CFB7>ŵ<EFBFBD><C5B5><EFBFBD><EFBFBD><EFBFBD>: <20><><EFBFBD>ŷ<EFBFBD>Ĭ<EFBFBD>ϴ<EFBFBD><CFB4><EFBFBD>
|
|||
|
|
if(dcBuff.powerInfo.hardVer.major == 231)
|
|||
|
|
KZ_VALUE_ENABLE();
|
|||
|
|
|
|||
|
|
while(1)
|
|||
|
|
{
|
|||
|
|
// <20>ȴ<EFBFBD><C8B4>ɼ<EFBFBD><C9BC>ź<EFBFBD>
|
|||
|
|
xSemaphoreTake(Sample_Semaphore, portMAX_DELAY);
|
|||
|
|
|
|||
|
|
// 4~20mA<6D><41><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD>ɼ<EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ɼ<EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̵ġ<CCB5>6<EFBFBD>뷶Χ<EBB7B6>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ɼ<EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD>浱ǰֵ
|
|||
|
|
adDPress_inhibition = (dcBuff.configSensor.sensorDPress.fullValue - dcBuff.configSensor.sensorDPress.zeroValue) / 166;
|
|||
|
|
|
|||
|
|
// <20><>һ<EFBFBD>Σ<D7B6><CEA3>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
Sample_phase = 1;
|
|||
|
|
|
|||
|
|
// <20><>ȡ<EFBFBD><C8A1>ǰʱ<C7B0><CAB1>
|
|||
|
|
RTC_GetDateAndTime(&sRTC);
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>gps<70><73>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
|
sample_time = Calc_SecondsFromYear(INITIAL_YEAR, sRTC.u32Year, sRTC.u32Month, sRTC.u32Day,
|
|||
|
|
sRTC.u32Hour, sRTC.u32Minute, sRTC.u32Second);
|
|||
|
|
|
|||
|
|
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
memset(&sample, 0, sizeof(sample));
|
|||
|
|
memset(&dtuSample, 0, sizeof(dtuSample));
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ô<EFBFBD><C3B4><EFBFBD><EFBFBD><EFBFBD>״̬
|
|||
|
|
sample.staExtPress[0].status = SENSOR_STATUS_NOCONNECT;
|
|||
|
|
sample.staExtPress[1].status = SENSOR_STATUS_NOCONNECT;
|
|||
|
|
sample.staExtPress[2].status = SENSOR_STATUS_NOCONNECT;
|
|||
|
|
sample.staExtTempr[0].status = SENSOR_STATUS_NOCONNECT;
|
|||
|
|
sample.staExtTempr[1].status = SENSOR_STATUS_NOCONNECT;
|
|||
|
|
sample.staExtTempr[2].status = SENSOR_STATUS_NOCONNECT;
|
|||
|
|
// Modbus<75><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD><C4AC>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
sample.vacuum[0] = dcBuff.sampleData.vacuum[0];
|
|||
|
|
sample.leak = dcBuff.sampleData.leak;
|
|||
|
|
sample.flow = dcBuff.sampleData.flow;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|||
|
|
Calculate_Theoretical_Params();
|
|||
|
|
|
|||
|
|
if(!IS_VCC_SENSOR_5V_ON())
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD>ڲɼ<DAB2><C9BC><EFBFBD><EFBFBD>ռƵ<D5BC><C6B5><EFBFBD>ʱ
|
|||
|
|
vaccuumTick = GetDelayTick(15000);
|
|||
|
|
|
|||
|
|
VCC_SENSOR_5V_ON();
|
|||
|
|
// <20><>ʱ1s<31>Ժ<EFBFBD><D4BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD>
|
|||
|
|
osDelay(1000);
|
|||
|
|
if(dcBuff.configDisplay.op_USE_R0SEMOUNT) // <20><>˹<EFBFBD><CBB9><EFBFBD>ش<EFBFBD><D8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ
|
|||
|
|
osDelay(5000);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>ADC
|
|||
|
|
LL_ADC_Enable(ADC1);
|
|||
|
|
while(!LL_ADC_IsActiveFlag_ADRDY(ADC1));
|
|||
|
|
osDelay(10);
|
|||
|
|
|
|||
|
|
// <20>ɼ<EFBFBD><C9BC><EFBFBD>ѹͨ<D1B9><CDA8>
|
|||
|
|
if(!dcBuff.configDisplay.op_DIFF_420MA)
|
|||
|
|
sample.adDPress = Sample_ChannelOne(LL_ADC_CHANNEL_5);
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
sample.adDPress = Sample_ChannelOne(LL_ADC_CHANNEL_10);
|
|||
|
|
// <20>DZ궨<C7B1>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if(!Config_Sample_Request)
|
|||
|
|
{
|
|||
|
|
if(last_adDPress > 0 &&
|
|||
|
|
(sample.adDPress + adDPress_inhibition >= last_adDPress && sample.adDPress <= last_adDPress + adDPress_inhibition))
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>ֵ<EFBFBD><D6B5><EFBFBD>浱ǰֵ
|
|||
|
|
sample.adDPress = last_adDPress;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// <20>Ե<EFBFBD>ǰֵ<C7B0><D6B5>Ϊ<EFBFBD>Ƚϻ<C8BD>
|
|||
|
|
last_adDPress = sample.adDPress;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if(!dcBuff.configDisplay.op_USE_CAPACITY_SENSOR)
|
|||
|
|
{
|
|||
|
|
// <20><>ѹֵ
|
|||
|
|
sample.staDPress.status = ADC_Validate(sample.adDPress,
|
|||
|
|
dcBuff.configSensor.sensorDPress.zeroValue, dcBuff.configSensor.sensorDPress.fullValue);
|
|||
|
|
if(sample.staDPress.status == SENSOR_STATUS_NORMAL)
|
|||
|
|
{
|
|||
|
|
sample.diff = ADC_Calculate(sample.adDPress,
|
|||
|
|
dcBuff.configSensor.sensorDPress.zeroValue, dcBuff.configSensor.sensorDPress.fullValue,
|
|||
|
|
dcBuff.configSensor.sensorDPress.lowRange, dcBuff.configSensor.sensorDPress.highRangeX10)
|
|||
|
|
* (dcBuff.configSensor.sensorDPress.ishighRangeX10 ? 0.1 : 1);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20>ɼ<EFBFBD>ѹ<EFBFBD><D1B9>ͨ<EFBFBD><CDA8>
|
|||
|
|
if(!dcBuff.configDisplay.op_PRESS_420MA)
|
|||
|
|
sample.adPress = Sample_ChannelOne(LL_ADC_CHANNEL_6);
|
|||
|
|
else
|
|||
|
|
sample.adPress = Sample_ChannelOne(LL_ADC_CHANNEL_11);
|
|||
|
|
sample.staPress.status = ADC_Validate(sample.adPress,
|
|||
|
|
dcBuff.configSensor.sensorPress.zeroValue, dcBuff.configSensor.sensorPress.fullValue);
|
|||
|
|
if(sample.staPress.status == SENSOR_STATUS_NORMAL)
|
|||
|
|
{
|
|||
|
|
sample.pressure = ADC_Calculate(sample.adPress,
|
|||
|
|
dcBuff.configSensor.sensorPress.zeroValue, dcBuff.configSensor.sensorPress.fullValue,
|
|||
|
|
dcBuff.configSensor.sensorPress.lowRange, dcBuff.configSensor.sensorPress.highRange);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>չѹ<D5B9><D1B9>ͨ<EFBFBD><CDA8>
|
|||
|
|
if(!dcBuff.configDisplay.op_PRESS_420MA)
|
|||
|
|
sample.adExtPress[0] = Sample_ChannelOne(LL_ADC_CHANNEL_11);
|
|||
|
|
else
|
|||
|
|
sample.adExtPress[0] = Sample_ChannelOne(LL_ADC_CHANNEL_6);
|
|||
|
|
sample.staExtPress[0].status = ADC_Validate(sample.adExtPress[0],
|
|||
|
|
dcBuff.configSensor.sensorEPress[0].zeroValue, dcBuff.configSensor.sensorEPress[0].fullValue);
|
|||
|
|
if(sample.staExtPress[0].status == SENSOR_STATUS_NORMAL)
|
|||
|
|
{
|
|||
|
|
sample.extPressure[0] = ADC_Calculate(sample.adExtPress[0],
|
|||
|
|
dcBuff.configSensor.sensorEPress[0].zeroValue, dcBuff.configSensor.sensorEPress[0].fullValue,
|
|||
|
|
dcBuff.configSensor.sensorEPress[0].lowRange, dcBuff.configSensor.sensorEPress[0].highRange);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(dcBuff.configDisplay.op_USE_PT100_SENSOR)
|
|||
|
|
{
|
|||
|
|
// <20>ɼ<EFBFBD><C9BC>¶<EFBFBD>1
|
|||
|
|
adc1 = Sample_ChannelOne(LL_ADC_CHANNEL_1);
|
|||
|
|
adc2 = Sample_ChannelOne(LL_ADC_CHANNEL_2);
|
|||
|
|
sample.adExtTempr[0] = PT100_CalResit(adc1, adc2);
|
|||
|
|
if(dcBuff.configDisplay.op_LEVEL_SENSOR_ONLY)
|
|||
|
|
sample.staExtTempr[0].status = SENSOR_STATUS_NOCONNECT;
|
|||
|
|
else
|
|||
|
|
sample.staExtTempr[0].status = ADC_Validate(sample.adExtTempr[0],
|
|||
|
|
PT100_Resis[0] * dcBuff.configDisplay.op_PT100_MULTI, PT100_Resis[sizeof(PT100_Resis) / sizeof(float) - 1] * dcBuff.configDisplay.op_PT100_MULTI);
|
|||
|
|
if(sample.staExtTempr[0].status == SENSOR_STATUS_NORMAL)
|
|||
|
|
{
|
|||
|
|
sample.extTempr[0] = PT100_CalTempr(adc1, adc2,
|
|||
|
|
dcBuff.configSensor.sensorPTempr[0].calibrateT, dcBuff.configSensor.sensorPTempr[0].calibrateR);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// <20>ɼ<EFBFBD><C9BC>¶<EFBFBD>1
|
|||
|
|
sample.adExtTempr[0] = Sample_ChannelOne(LL_ADC_CHANNEL_12);
|
|||
|
|
sample.staExtTempr[0].status = ADC_Validate(sample.adExtTempr[0],
|
|||
|
|
dcBuff.configSensor.sensorMTempr[0].zeroValue, dcBuff.configSensor.sensorMTempr[0].fullValue);
|
|||
|
|
if(sample.staExtTempr[0].status == SENSOR_STATUS_NORMAL)
|
|||
|
|
{
|
|||
|
|
sample.extTempr[0] = ADC_Calculate(sample.adExtTempr[0],
|
|||
|
|
dcBuff.configSensor.sensorMTempr[0].zeroValue, dcBuff.configSensor.sensorMTempr[0].fullValue,
|
|||
|
|
dcBuff.configSensor.sensorMTempr[0].lowRange, dcBuff.configSensor.sensorMTempr[0].highRange);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20>ɼ<EFBFBD><C9BC>¶<EFBFBD>2
|
|||
|
|
adc1 = Sample_ChannelOne(LL_ADC_CHANNEL_3);
|
|||
|
|
adc2 = Sample_ChannelOne(LL_ADC_CHANNEL_4);
|
|||
|
|
sample.adExtTempr[1] = PT100_CalResit(adc1, adc2);
|
|||
|
|
if(dcBuff.configDisplay.op_LEVEL_SENSOR_ONLY)
|
|||
|
|
sample.staExtTempr[1].status = SENSOR_STATUS_NOCONNECT;
|
|||
|
|
else
|
|||
|
|
sample.staExtTempr[1].status = ADC_Validate(sample.adExtTempr[1],
|
|||
|
|
PT100_Resis[0] * dcBuff.configDisplay.op_PT100_MULTI, PT100_Resis[sizeof(PT100_Resis) / sizeof(float) - 1] * dcBuff.configDisplay.op_PT100_MULTI);
|
|||
|
|
if(sample.staExtTempr[1].status == SENSOR_STATUS_NORMAL)
|
|||
|
|
{
|
|||
|
|
sample.extTempr[1] = PT100_CalTempr(adc1, adc2,
|
|||
|
|
dcBuff.configSensor.sensorPTempr[1].calibrateT, dcBuff.configSensor.sensorPTempr[1].calibrateR);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD>ص<EFBFBD>ѹͨ<D1B9><CDA8>
|
|||
|
|
// Ϊ<>˱<EFBFBD><CBB1><EFBFBD>ADCģ<43><C4A3><EFBFBD><EFBFBD>ʹ<EFBFBD>ó<EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>ִ<EFBFBD><D6B4>
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ش<EFBFBD><D8B4><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD>ã<EFBFBD><C3A3>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>ص<EFBFBD>ѹ<EFBFBD><D1B9>adcֵ<63><D6B5><EFBFBD><EFBFBD><EFBFBD>ڳ<EFBFBD><DAB3>ش<EFBFBD><D8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
|||
|
|
sample.adWeight = Sample_ChannelOne(LL_ADC_CHANNEL_15);
|
|||
|
|
|
|||
|
|
if(dcBuff.configDisplay.op_USE_O2_LEAK)
|
|||
|
|
{
|
|||
|
|
if(VCC_POWER_STATUS())
|
|||
|
|
{
|
|||
|
|
// <20><>ȡO2Ũ<32>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
Sensor_ReadLeakO2(&sample);
|
|||
|
|
while(!IsTickOut(modbus_outTick))
|
|||
|
|
osDelay(1);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// <20><>ȡй¶<D0B9><C2B6><EFBFBD><EFBFBD>
|
|||
|
|
sample.leak.typeLeak = LEAK_TYPE_SWITCH;
|
|||
|
|
if(VCC_LEAK_STATUS())
|
|||
|
|
{
|
|||
|
|
sample.leak.staLeak = LEAK_STATUS_A2_ALARM;
|
|||
|
|
sample.leak.concentrations = 1;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
sample.leak.staLeak = LEAK_STATUS_OK;
|
|||
|
|
sample.leak.concentrations = 0;
|
|||
|
|
// <20><><EFBFBD><EFBFBD>й¶<D0B9><C2B6><EFBFBD><EFBFBD>
|
|||
|
|
Leak_Alarm_Enabled = 1;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(VCC_POWER_STATUS())
|
|||
|
|
{
|
|||
|
|
// Modbus<75>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
Sensor_ReadFlow(&sample);
|
|||
|
|
while(!IsTickOut(modbus_outTick))
|
|||
|
|
osDelay(1);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20>Ƿɼ<F1B5BDB2>ʱ<EFBFBD>䣨3<E4A3A8><33><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if(Config_Vacuum_Request || sample_time + 3 >= vacuum_seconds)
|
|||
|
|
{
|
|||
|
|
if(Config_Vacuum_Request)
|
|||
|
|
{
|
|||
|
|
// ǿ<>Ʋɼ<C6B2><C9BC><EFBFBD><EFBFBD>ռ<EFBFBD>
|
|||
|
|
Config_Vacuum_Request = 0;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// <20>´<EFBFBD><C2B4>ϴ<EFBFBD>ʱ<EFBFBD>ٲ<EFBFBD>
|
|||
|
|
vacuum_seconds = sample_time + dcBuff.configData.intervalTrans;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ռ<EFBFBD><D5BC><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ
|
|||
|
|
while(vaccuumTick > 0 && !IsTickOut(vaccuumTick))
|
|||
|
|
osDelay(1);
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ磬<CFB5>´βɼ<CEB2><C9BC><EFBFBD><EFBFBD>ռƲ<D5BC><C6B2><EFBFBD><EFBFBD><EFBFBD>ʱ
|
|||
|
|
vaccuumTick = 0;
|
|||
|
|
|
|||
|
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
Sensor_ReadVacuum(0, &sample);
|
|||
|
|
while(!IsTickOut(modbus_outTick))
|
|||
|
|
osDelay(1);
|
|||
|
|
if(sample.vacuum[0].staVacuum == VACUUM_STATUS_COMM_FAULT)
|
|||
|
|
{
|
|||
|
|
Sensor_ReadVacuum(0, &sample);
|
|||
|
|
while(!IsTickOut(modbus_outTick))
|
|||
|
|
osDelay(1);
|
|||
|
|
}
|
|||
|
|
if(sample.vacuum[0].staVacuum == VACUUM_STATUS_COMM_FAULT)
|
|||
|
|
{
|
|||
|
|
Sensor_ReadVacuum(0, &sample);
|
|||
|
|
while(!IsTickOut(modbus_outTick))
|
|||
|
|
osDelay(1);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ⲿ<EFBFBD><E2B2BF><EFBFBD>磬<EFBFBD><E7A3AC><EFBFBD><EFBFBD>̫<EFBFBD><CCAB><EFBFBD>ܵ<EFBFBD><DCB5>ص<EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD>4.5v
|
|||
|
|
if((!dcBuff.configDisplay.op_LOCAL_DISP_1S && !dcBuff.configDisplay.op_USE_R0SEMOUNT) || !VCC_POWER_STATUS() || (dcBuff.configDisplay.op_USE_SOLAR && dcBuff.dtuData.batVoltage <= 4500))
|
|||
|
|
VCC_SENSOR_5V_OFF();
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if(dcBuff.configDisplay.op_USE_CAPACITY_SENSOR && sample.staDPress.status != SENSOR_STATUS_NOCONNECT)
|
|||
|
|
{
|
|||
|
|
if(sample.adDPress == 0xFFFF) // <20><>·
|
|||
|
|
sample.staDPress.status = SENSOR_STATUS_OVERFLOW;
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD>ݵ<DDB5><D7B5>ݡ<EFBFBD><DDA1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>״̬
|
|||
|
|
sample.staDPress.status = ADC_Validate(sample.diff * 10,
|
|||
|
|
dcBuff.configSensor.sensorCap.baseC, dcBuff.configSensor.sensorCap.baseC + dcBuff.configSensor.sensorCap.refC);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ݻ<EFBFBD>
|
|||
|
|
sample.volumeTotal = Theoretical_Param.v;
|
|||
|
|
|
|||
|
|
if(dcBuff.configBottle.measureType == MEASURE_DPRESS && sample.staDPress.status == SENSOR_STATUS_NORMAL)
|
|||
|
|
{
|
|||
|
|
if(!dcBuff.configDisplay.op_USE_CAPACITY_SENSOR)
|
|||
|
|
{
|
|||
|
|
// Һλ
|
|||
|
|
if(!dcBuff.configDisplay.op_USE_HEIGHT_LEVEL && !dcBuff.configDisplay.op_USE_PCT_LEVEL)
|
|||
|
|
sample.height = Diff2Level(sample.diff); // <20><>λmm
|
|||
|
|
else if(!dcBuff.configDisplay.op_USE_PCT_LEVEL)
|
|||
|
|
sample.height = sample.diff; // ֱ<>Ӳ<EFBFBD><D3B2><EFBFBD>Һλ<D2BA>߶ȣ<DFB6><C8A3><EFBFBD>λmm
|
|||
|
|
else
|
|||
|
|
sample.height = sample.diff * 100; // ֱ<>Ӳ<EFBFBD><D3B2><EFBFBD>Һλ<D2BA>ٷֱȣ<D6B1><C8A3><EFBFBD>λ0.01%
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD>ݵ<DDB5><D7B5>ݡ<EFBFBD><DDA1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD>Һλ<D2BA>߶<EFBFBD>
|
|||
|
|
sample.height = Cap_Calculate(sample.diff * 10,
|
|||
|
|
dcBuff.configSensor.sensorCap.baseC, dcBuff.configSensor.sensorCap.refC);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(!dcBuff.configDisplay.op_USE_PCT_LEVEL && dcBuff.configSensor.levelOutMMWC == 0)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD>
|
|||
|
|
sample.volume = Level2Vol(sample.height);
|
|||
|
|
// <20><><EFBFBD><EFBFBD>
|
|||
|
|
sample.weight = Vol2Quantity(sample.volume);
|
|||
|
|
// <20><>װ<EFBFBD><D7B0>
|
|||
|
|
if(sample.volume >= Theoretical_Param.ve)
|
|||
|
|
sample.volumePct = dcBuff.configBottle.chargePct * 100;
|
|||
|
|
else
|
|||
|
|
sample.volumePct = (float) sample.volume / sample.volumeTotal * 10000;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
if(dcBuff.configSensor.levelOutMMWC > 0)
|
|||
|
|
{
|
|||
|
|
// <20><>װ<EFBFBD><D7B0>
|
|||
|
|
if(KPa2mmH2O(sample.diff) >= dcBuff.configSensor.levelOutMMWC)
|
|||
|
|
sample.volumePct = dcBuff.configBottle.chargePct * 100;
|
|||
|
|
else
|
|||
|
|
sample.volumePct = KPa2mmH2O(sample.diff) / dcBuff.configSensor.levelOutMMWC * 10000;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// <20><>װ<EFBFBD><D7B0>
|
|||
|
|
if(sample.diff >= dcBuff.configBottle.chargePct)
|
|||
|
|
sample.volumePct = dcBuff.configBottle.chargePct * 100;
|
|||
|
|
else
|
|||
|
|
sample.volumePct = sample.diff * 100;
|
|||
|
|
}
|
|||
|
|
// <20><><EFBFBD><EFBFBD>
|
|||
|
|
sample.volume = Theoretical_Param.ve * (sample.volumePct / 10000.0);
|
|||
|
|
// <20><><EFBFBD><EFBFBD>
|
|||
|
|
sample.weight = Vol2Quantity(sample.volume);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if(dcBuff.configDisplay.op_ANTI_OVERFILL)
|
|||
|
|
{
|
|||
|
|
if((dcBuff.configBottle.measureType == MEASURE_WEIGHT && sample.staWeight.status == SENSOR_STATUS_NORMAL) ||
|
|||
|
|
(dcBuff.configBottle.measureType == MEASURE_DPRESS && sample.staDPress.status == SENSOR_STATUS_NORMAL))
|
|||
|
|
{
|
|||
|
|
if(dcBuff.configBottle.fullPct > 0 && sample.volumePct >= dcBuff.configBottle.fullPct)
|
|||
|
|
Charge_Enabled = 0;
|
|||
|
|
|
|||
|
|
// <20>κ<EFBFBD><CEBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD><C2A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>Ч
|
|||
|
|
if(Charge_Enabled != last_Charge_Enabled)
|
|||
|
|
{
|
|||
|
|
Charge_Pulse_Time = GetDelayTick(1000);
|
|||
|
|
if(Charge_Enabled)
|
|||
|
|
KZ_CHARGE_ENABLE_HIGH();
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
if(dcBuff.configDisplay.op_ANTI_SINGLE_CTRL)
|
|||
|
|
KZ_CHARGE_ENABLE_LOW();
|
|||
|
|
else
|
|||
|
|
KZ_CHARGE_DISABLE_HIGH();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
// <20><><EFBFBD>浱ǰ<E6B5B1><C7B0>װ<EFBFBD><D7B0><EFBFBD><EFBFBD>״̬
|
|||
|
|
last_Charge_Enabled = Charge_Enabled;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŷ<EFBFBD><C5B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>رգ<D8B1>
|
|||
|
|
if(dcBuff.configDisplay.op_ANTI_NORM_OPEN)
|
|||
|
|
{
|
|||
|
|
if((dcBuff.configBottle.measureType == MEASURE_WEIGHT && sample.staWeight.status == SENSOR_STATUS_NORMAL) ||
|
|||
|
|
(dcBuff.configBottle.measureType == MEASURE_DPRESS && sample.staDPress.status == SENSOR_STATUS_NORMAL))
|
|||
|
|
{
|
|||
|
|
// <20><>Һλ<D2BA><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Һλ֮<CEBB><D6AE>10%<25><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if(dcBuff.configBottle.fullPct > 0 && sample.volumePct < dcBuff.configBottle.fullPct - 10 * 100)
|
|||
|
|
Anti_Enabled = 1;
|
|||
|
|
if(dcBuff.configBottle.fullPct > 0 && sample.volumePct >= dcBuff.configBottle.fullPct)
|
|||
|
|
{
|
|||
|
|
if(Anti_Enabled)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ùر<C3B9>300<30><30>
|
|||
|
|
KZ_NORM_OPEN_DISABLE();
|
|||
|
|
Anti_Pulse_Time = GetDelayTick(300000ul);
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
Anti_Enabled = 0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ⱨ<EFBFBD><E2B1A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if(dcBuff.configDisplay.op_ALARM_OUTPUT)
|
|||
|
|
{
|
|||
|
|
if((dcBuff.configBottle.measureType == MEASURE_WEIGHT && sample.staWeight.status == SENSOR_STATUS_NORMAL) ||
|
|||
|
|
(dcBuff.configBottle.measureType == MEASURE_DPRESS && sample.staDPress.status == SENSOR_STATUS_NORMAL))
|
|||
|
|
{
|
|||
|
|
// <20><>Һλ<D2BA><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Һλ֮<CEBB><D6AE>10%<25><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ⱨ<EFBFBD><E2B1A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
// <20><>Һλ<D2BA><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Һλ֮<CEBB><D6AE>10%<25><><EFBFBD><EFBFBD><EFBFBD>ⱨ<EFBFBD><E2B1A8>״̬<D7B4><CCAC><EFBFBD>䣨һֱ<D2BB><D6B1><EFBFBD><EFBFBD>״̬ <20><> <20>ֶ<EFBFBD><D6B6>ر<EFBFBD>״̬<D7B4><CCAC>
|
|||
|
|
if(dcBuff.configBottle.fullPct > 0 && sample.volumePct < dcBuff.configBottle.fullPct - 10 * 100)
|
|||
|
|
Alarm_Enabled = 1;
|
|||
|
|
|
|||
|
|
// <20><>Һλ<D2BA><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Һλ<D2BA><CEBB><EFBFBD><EFBFBD>δ<EFBFBD>ֶ<EFBFBD><D6B6>رգ<D8B1><D5A3><EFBFBD><EFBFBD><EFBFBD><F2BFAAB1><EFBFBD>
|
|||
|
|
if(dcBuff.configBottle.fullPct > 0 && sample.volumePct >= dcBuff.configBottle.fullPct)
|
|||
|
|
{
|
|||
|
|
if(Alarm_Enabled && VCC_POWER_STATUS() && (!dcBuff.configDisplay.op_USE_SOLAR || dcBuff.dtuData.batVoltage > 4500))
|
|||
|
|
{
|
|||
|
|
KZ_ALARM_ON();
|
|||
|
|
Alarm_Output = 1;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// й¶<D0B9><C2B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if(dcBuff.configDisplay.op_LEAK_ALARM_OUTPUT)
|
|||
|
|
{
|
|||
|
|
if(VCC_POWER_STATUS() && (!dcBuff.configDisplay.op_USE_SOLAR || dcBuff.dtuData.batVoltage > 4500)
|
|||
|
|
&& sample.leak.staLeak == LEAK_STATUS_A2_ALARM)
|
|||
|
|
{
|
|||
|
|
if(Leak_Alarm_Enabled && VCC_POWER_STATUS() && (!dcBuff.configDisplay.op_USE_SOLAR || dcBuff.dtuData.batVoltage > 4500))
|
|||
|
|
{
|
|||
|
|
KZ_ALARM_ON();
|
|||
|
|
Leak_Alarm_Output = 1;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ǿ<>Ƶ<EFBFBD>Һλ<D2BA><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if(dcBuff.configDisplay.op_LOW_ALARM_OUTPUT)
|
|||
|
|
{
|
|||
|
|
if((dcBuff.configBottle.measureType == MEASURE_WEIGHT && sample.staWeight.status == SENSOR_STATUS_NORMAL) ||
|
|||
|
|
(dcBuff.configBottle.measureType == MEASURE_DPRESS && sample.staDPress.status == SENSOR_STATUS_NORMAL))
|
|||
|
|
{
|
|||
|
|
// <20><>Һλ<D2BA><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Һλ֮<CEBB><D6AE>10%<25><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Һλ<D2BA><CEBB><EFBFBD><EFBFBD>ָʾ
|
|||
|
|
// <20><>Һλ<D2BA><CEBB><EFBFBD>ڿ<EFBFBD>Һλ֮<CEBB><D6AE>10%<25><><EFBFBD><EFBFBD>Һλָʾ״̬<D7B4><CCAC><EFBFBD>䣨һֱ<D2BB><D6B1><EFBFBD><EFBFBD>״̬ <20><> <20>ֶ<EFBFBD><D6B6>ر<EFBFBD>״̬<D7B4><CCAC>
|
|||
|
|
if(dcBuff.configBottle.emptyPct > 0 && sample.volumePct >= dcBuff.configBottle.emptyPct + 10 * 100)
|
|||
|
|
Low_Alarm_Enabled = 1;
|
|||
|
|
|
|||
|
|
// <20><>Һλ<D2BA><CEBB><EFBFBD>ڿ<EFBFBD>Һλ<D2BA><CEBB><EFBFBD><EFBFBD>δ<EFBFBD>ֶ<EFBFBD><D6B6>رգ<D8B1><D5A3><EFBFBD><EFBFBD><EFBFBD><F2BFAAB1><EFBFBD>
|
|||
|
|
if(dcBuff.configBottle.emptyPct > 0 && sample.volumePct <= dcBuff.configBottle.emptyPct)
|
|||
|
|
{
|
|||
|
|
if(Low_Alarm_Enabled && VCC_POWER_STATUS() && (!dcBuff.configDisplay.op_USE_SOLAR || dcBuff.dtuData.batVoltage > 4500))
|
|||
|
|
{
|
|||
|
|
KZ_ALARM_ON();
|
|||
|
|
Low_Alarm_Output = 1;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Ĭ<>ϵ<EFBFBD>Һλ<D2BA><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if(!dcBuff.configDisplay.op_ALARM_OUTPUT && !dcBuff.configDisplay.op_LEAK_ALARM_OUTPUT && !dcBuff.configDisplay.op_LOW_ALARM_OUTPUT)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><><EFBFBD><EFBFBD><E2B9A9><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>
|
|||
|
|
if((dcBuff.configBottle.measureType == MEASURE_WEIGHT && sample.staWeight.status == SENSOR_STATUS_NORMAL) ||
|
|||
|
|
(dcBuff.configBottle.measureType == MEASURE_DPRESS && sample.staDPress.status == SENSOR_STATUS_NORMAL))
|
|||
|
|
{
|
|||
|
|
// <20><>Һλ<D2BA><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Һλ֮<CEBB><D6AE>10%<25><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Һλ<D2BA><CEBB><EFBFBD><EFBFBD>ָʾ
|
|||
|
|
// <20><>Һλ<D2BA><CEBB><EFBFBD>ڿ<EFBFBD>Һλ֮<CEBB><D6AE>10%<25><><EFBFBD><EFBFBD>Һλָʾ״̬<D7B4><CCAC><EFBFBD><EFBFBD>
|
|||
|
|
if(dcBuff.configBottle.emptyPct > 0 && sample.volumePct >= dcBuff.configBottle.emptyPct + 10 * 100)
|
|||
|
|
KZ_LOW_ALARM_OFF();
|
|||
|
|
if(dcBuff.configBottle.emptyPct > 0 && sample.volumePct <= dcBuff.configBottle.emptyPct)
|
|||
|
|
{
|
|||
|
|
if(VCC_POWER_STATUS() && (!dcBuff.configDisplay.op_USE_SOLAR || dcBuff.dtuData.batVoltage > 4500))
|
|||
|
|
KZ_LOW_ALARM_ON();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if(dcBuff.configDisplay.op_PRESS_ALARM_OUTPUT)
|
|||
|
|
{
|
|||
|
|
if(sample.staPress.status == SENSOR_STATUS_NORMAL)
|
|||
|
|
{
|
|||
|
|
// <20><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ֮<D6B5><D6AE>0.05Mpa<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָʾ
|
|||
|
|
// <20><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD>ֵ֮<D6B5><D6AE>0.05Mpa<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><EFBFBD>ָʾ״̬<EFBFBD><EFBFBD><EFBFBD>䣨һֱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬ <20><> <20>ֶ<EFBFBD><D6B6>ر<EFBFBD>״̬<D7B4><CCAC>
|
|||
|
|
if(dcBuff.configBottle.warnPressH > 0 && sample.pressure + 50 <= dcBuff.configBottle.warnPressH)
|
|||
|
|
Press_Alarm_Enabled = 1;
|
|||
|
|
|
|||
|
|
// <20><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>δ<EFBFBD>ֶ<EFBFBD><D6B6>رգ<D8B1><D5A3><EFBFBD><EFBFBD><EFBFBD><F2BFAAB1><EFBFBD>
|
|||
|
|
if(dcBuff.configBottle.warnPressH > 0 && sample.pressure >= dcBuff.configBottle.warnPressH)
|
|||
|
|
{
|
|||
|
|
if(Press_Alarm_Enabled && VCC_POWER_STATUS() && (!dcBuff.configDisplay.op_USE_SOLAR || dcBuff.dtuData.batVoltage > 4500))
|
|||
|
|
{
|
|||
|
|
KZ_ALARM_ON();
|
|||
|
|
Press_Alarm_Output = 1;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if(dcBuff.configDisplay.op_LOW_PRESS_ALARM_OUTPUT)
|
|||
|
|
{
|
|||
|
|
if(sample.staPress.status == SENSOR_STATUS_NORMAL)
|
|||
|
|
{
|
|||
|
|
// <20><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ֮<D6B5><D6AE>0.05Mpa<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָʾ
|
|||
|
|
// <20><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD>ֵ֮<D6B5><D6AE>0.05Mpa<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><EFBFBD>ָʾ״̬<EFBFBD><EFBFBD><EFBFBD>䣨һֱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬ <20><> <20>ֶ<EFBFBD><D6B6>ر<EFBFBD>״̬<D7B4><CCAC>
|
|||
|
|
if(dcBuff.configBottle.warnPress > 0 && sample.pressure >= dcBuff.configBottle.warnPress + 50)
|
|||
|
|
Low_Press_Alarm_Enabled = 1;
|
|||
|
|
|
|||
|
|
// <20><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>δ<EFBFBD>ֶ<EFBFBD><D6B6>رգ<D8B1><D5A3><EFBFBD><EFBFBD><EFBFBD><F2BFAAB1><EFBFBD>
|
|||
|
|
if(dcBuff.configBottle.warnPress > 0 && sample.pressure <= dcBuff.configBottle.warnPress)
|
|||
|
|
{
|
|||
|
|
if(Low_Press_Alarm_Enabled && VCC_POWER_STATUS() && (!dcBuff.configDisplay.op_USE_SOLAR || dcBuff.dtuData.batVoltage > 4500))
|
|||
|
|
{
|
|||
|
|
KZ_ALARM_ON();
|
|||
|
|
Low_Press_Alarm_Output = 1;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ˫ѹ<CBAB><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>汾
|
|||
|
|
if(dcBuff.powerInfo.hardVer.major == 232)
|
|||
|
|
{
|
|||
|
|
if(sample.staExtPress[0].status == SENSOR_STATUS_NORMAL)
|
|||
|
|
{
|
|||
|
|
// <20><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ֮<D6B5><D6AE>0.05Mpa<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָʾ
|
|||
|
|
// <20><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD>ֵ֮<D6B5><D6AE>0.05Mpa<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><EFBFBD>ָʾ״̬<EFBFBD><EFBFBD><EFBFBD>䣨һֱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬ <20><> <20>ֶ<EFBFBD><D6B6>ر<EFBFBD>״̬<D7B4><CCAC>
|
|||
|
|
if(sample.extPressure[0] + 50 <= 2500)
|
|||
|
|
ExtPress_Alarm_Enabled = 1;
|
|||
|
|
|
|||
|
|
// <20><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>δ<EFBFBD>ֶ<EFBFBD><D6B6>رգ<D8B1><D5A3><EFBFBD><EFBFBD><EFBFBD><F2BFAAB1><EFBFBD>
|
|||
|
|
if(sample.extPressure[0] >= 2500)
|
|||
|
|
{
|
|||
|
|
if(ExtPress_Alarm_Enabled && VCC_POWER_STATUS() && (!dcBuff.configDisplay.op_USE_SOLAR || dcBuff.dtuData.batVoltage > 4500))
|
|||
|
|
{
|
|||
|
|
KZ_ALARM_ON();
|
|||
|
|
ExtPress_Alarm_Output = 1;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ֮<D6B5><D6AE>0.05Mpa<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָʾ
|
|||
|
|
// <20><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD>ֵ֮<D6B5><D6AE>0.05Mpa<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><EFBFBD>ָʾ״̬<EFBFBD><EFBFBD><EFBFBD>䣨һֱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬ <20><> <20>ֶ<EFBFBD><D6B6>ر<EFBFBD>״̬<D7B4><CCAC>
|
|||
|
|
if(sample.extPressure[0] >= 100 + 50)
|
|||
|
|
Low_ExtPress_Alarm_Enabled = 1;
|
|||
|
|
|
|||
|
|
// <20><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>δ<EFBFBD>ֶ<EFBFBD><D6B6>رգ<D8B1><D5A3><EFBFBD><EFBFBD><EFBFBD><F2BFAAB1><EFBFBD>
|
|||
|
|
if(sample.extPressure[0] <= 100)
|
|||
|
|
{
|
|||
|
|
if(Low_ExtPress_Alarm_Enabled && VCC_POWER_STATUS() && (!dcBuff.configDisplay.op_USE_SOLAR || dcBuff.dtuData.batVoltage > 4500))
|
|||
|
|
{
|
|||
|
|
KZ_ALARM_ON();
|
|||
|
|
Low_ExtPress_Alarm_Output = 1;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>磬<EFBFBD><E7A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ⱨ<EFBFBD><E2B1A8><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>ʼ״̬
|
|||
|
|
if(!VCC_POWER_STATUS() || (dcBuff.configDisplay.op_USE_SOLAR && dcBuff.dtuData.batVoltage <= 4500))
|
|||
|
|
{
|
|||
|
|
KZ_ALARM_OFF();
|
|||
|
|
KZ_LOW_ALARM_OFF();
|
|||
|
|
|
|||
|
|
Alarm_Output = 0;
|
|||
|
|
Low_Alarm_Output = 0;
|
|||
|
|
Leak_Alarm_Output = 0;
|
|||
|
|
Press_Alarm_Output = 0;
|
|||
|
|
Low_Press_Alarm_Output = 0;
|
|||
|
|
ExtPress_Alarm_Output = 0;
|
|||
|
|
Low_ExtPress_Alarm_Output = 0;
|
|||
|
|
|
|||
|
|
Alarm_Enabled = 1;
|
|||
|
|
Low_Alarm_Enabled = 1;
|
|||
|
|
Leak_Alarm_Enabled = 1;
|
|||
|
|
Press_Alarm_Enabled = 1;
|
|||
|
|
Low_Press_Alarm_Enabled = 1;
|
|||
|
|
ExtPress_Alarm_Enabled = 1;
|
|||
|
|
Low_ExtPress_Alarm_Enabled = 1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>Һλָʾ<D6B8><CABE><EFBFBD><EFBFBD>
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><><EFBFBD><EFBFBD><E2B9A9><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>
|
|||
|
|
if(VCC_POWER_STATUS() && (!dcBuff.configDisplay.op_USE_SOLAR || dcBuff.dtuData.batVoltage > 4500)
|
|||
|
|
&& dcBuff.configBottle.emptyPct > 0
|
|||
|
|
&& ((dcBuff.configBottle.measureType == MEASURE_WEIGHT && sample.staWeight.status == SENSOR_STATUS_NORMAL) ||
|
|||
|
|
(dcBuff.configBottle.measureType == MEASURE_DPRESS && sample.staDPress.status == SENSOR_STATUS_NORMAL)))
|
|||
|
|
{
|
|||
|
|
// <20><>Һλ<D2BA><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Һλ֮<CEBB><D6AE>10%<25><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Һλ<D2BA><CEBB><EFBFBD><EFBFBD>ָʾ
|
|||
|
|
// <20><>Һλ<D2BA><CEBB><EFBFBD>ڿ<EFBFBD>Һλ֮<CEBB><D6AE>10%<25><><EFBFBD><EFBFBD>Һλָʾ״̬<D7B4><CCAC><EFBFBD><EFBFBD>
|
|||
|
|
if(sample.volumePct >= dcBuff.configBottle.emptyPct + 10 * 100)
|
|||
|
|
KZ_LOW_LEVEL_OFF();
|
|||
|
|
if(sample.volumePct <= dcBuff.configBottle.emptyPct)
|
|||
|
|
KZ_LOW_LEVEL_ON();
|
|||
|
|
}
|
|||
|
|
else // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָʾ<D6B8><CABE><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>ʼ״̬
|
|||
|
|
KZ_LOW_LEVEL_OFF();
|
|||
|
|
|
|||
|
|
// <20><>Һλָʾ<D6B8><CABE><EFBFBD><EFBFBD>
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><><EFBFBD><EFBFBD><E2B9A9><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>
|
|||
|
|
if(VCC_POWER_STATUS() && (!dcBuff.configDisplay.op_USE_SOLAR || dcBuff.dtuData.batVoltage > 4500)
|
|||
|
|
&& dcBuff.configBottle.fullPct > 0
|
|||
|
|
&& ((dcBuff.configBottle.measureType == MEASURE_WEIGHT && sample.staWeight.status == SENSOR_STATUS_NORMAL) ||
|
|||
|
|
(dcBuff.configBottle.measureType == MEASURE_DPRESS && sample.staDPress.status == SENSOR_STATUS_NORMAL)))
|
|||
|
|
{
|
|||
|
|
// <20><>Һλ<D2BA><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Һλ֮<CEBB><D6AE>10%<25><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Һλ<D2BA><CEBB><EFBFBD><EFBFBD>ָʾ
|
|||
|
|
// <20><>Һλ<D2BA><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Һλ֮<CEBB><D6AE>10%<25><><EFBFBD><EFBFBD>Һλָʾ״̬<D7B4><CCAC><EFBFBD><EFBFBD>
|
|||
|
|
if(sample.volumePct <= dcBuff.configBottle.fullPct - 10 * 100)
|
|||
|
|
KZ_LEVEL_OFF();
|
|||
|
|
if(sample.volumePct >= dcBuff.configBottle.fullPct)
|
|||
|
|
KZ_LEVEL_ON();
|
|||
|
|
}
|
|||
|
|
else // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָʾ<D6B8><CABE><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>ʼ״̬
|
|||
|
|
KZ_LEVEL_OFF();
|
|||
|
|
|
|||
|
|
// <20><>Զ<EFBFBD><D4B6><EFBFBD>壺<EFBFBD><E5A3BA><EFBFBD><EFBFBD><EFBFBD>жϷ<D0B6><CFB7>ŵ<EFBFBD><C5B5><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if(dcBuff.powerInfo.hardVer.major == 231)
|
|||
|
|
{
|
|||
|
|
if(VCC_POWER_STATUS() && (!dcBuff.configDisplay.op_USE_SOLAR || dcBuff.dtuData.batVoltage > 4500)
|
|||
|
|
&& sample.leak.staLeak != LEAK_STATUS_COMM_FAULT && sample.leak.staLeak != LEAK_STATUS_FAULT
|
|||
|
|
&& sample.staExtTempr[0].status == SENSOR_STATUS_NORMAL)
|
|||
|
|
{
|
|||
|
|
if(sample.leak.staLeak == LEAK_STATUS_A2_ALARM || sample.extTempr[0] <= -35)
|
|||
|
|
KZ_VALUE_DISABLE();
|
|||
|
|
else if(sample.leak.staLeak == LEAK_STATUS_OK && sample.extTempr[0] >= -30)
|
|||
|
|
KZ_VALUE_ENABLE();
|
|||
|
|
}
|
|||
|
|
else if(!VCC_POWER_STATUS() || (dcBuff.configDisplay.op_USE_SOLAR && dcBuff.dtuData.batVoltage <= 4500))
|
|||
|
|
KZ_VALUE_DISABLE();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if((dcBuff.configBottle.measureType == MEASURE_WEIGHT && sample.staWeight.status == SENSOR_STATUS_NORMAL)
|
|||
|
|
|| (dcBuff.configBottle.measureType == MEASURE_DPRESS && sample.staDPress.status == SENSOR_STATUS_NORMAL))
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ô<EFBFBD><C3B4><EFBFBD><DEB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>mmWC<57><43>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<DEB5>λ
|
|||
|
|
if(dcBuff.configDisplay.op_DISP_MMWC_ONLY && !dcBuff.configDisplay.op_USE_PCT_LEVEL)
|
|||
|
|
{
|
|||
|
|
if(!dcBuff.configDisplay.op_USE_CAPACITY_SENSOR && !dcBuff.configDisplay.op_USE_HEIGHT_LEVEL)
|
|||
|
|
u32Sample = (uint32_t) KPa2mmH2O(sample.diff);
|
|||
|
|
else
|
|||
|
|
u32Sample = (uint32_t) sample.height;
|
|||
|
|
}
|
|||
|
|
else // <20><>Һ<EFBFBD><D2BA><EFBFBD>ٷֱ<D9B7><D6B1><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<DEB5>λ
|
|||
|
|
u32Sample = sample.volumePct;
|
|||
|
|
|
|||
|
|
// <20>б<EFBFBD>Һλ<D2BA><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if(dcBuff.configBottle.fullPct > 0 &&
|
|||
|
|
last_volumePct < dcBuff.configBottle.fullPct && u32Sample >= dcBuff.configBottle.fullPct)
|
|||
|
|
sample.warnning = 1;
|
|||
|
|
if(dcBuff.configBottle.priPct > 0 &&
|
|||
|
|
last_volumePct > dcBuff.configBottle.priPct && u32Sample <= dcBuff.configBottle.priPct)
|
|||
|
|
sample.warnning = 1;
|
|||
|
|
if(dcBuff.configBottle.orderPct > 0 &&
|
|||
|
|
last_volumePct > dcBuff.configBottle.orderPct && u32Sample <= dcBuff.configBottle.orderPct)
|
|||
|
|
sample.warnning = 1;
|
|||
|
|
if(dcBuff.configBottle.emptyPct > 0 &&
|
|||
|
|
last_volumePct > dcBuff.configBottle.emptyPct && u32Sample <= dcBuff.configBottle.emptyPct)
|
|||
|
|
sample.warnning = 1;
|
|||
|
|
|
|||
|
|
// TTS, <20>б<EFBFBD>Һλ<D2BA>͵<EFBFBD>
|
|||
|
|
if(dcBuff.configBottle.serverVer == 3)
|
|||
|
|
{
|
|||
|
|
// Һλ<D2BA>͵<EFBFBD>
|
|||
|
|
if(dcBuff.configBottle.floorLevel > 0 &&
|
|||
|
|
last_volumePct > dcBuff.configBottle.floorLevel && u32Sample <= dcBuff.configBottle.floorLevel)
|
|||
|
|
sample.warnning = 1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>¼<EFBFBD>ϴβɼ<CEB2><C9BC><EFBFBD>ֵ
|
|||
|
|
last_volumePct = u32Sample;
|
|||
|
|
|
|||
|
|
// <20>б<EFBFBD><D0B1><EFBFBD>װ״̬
|
|||
|
|
RTC_GetDateAndTime(&sRTC);
|
|||
|
|
totalSeconds = Calc_SecondsFromYear(INITIAL_YEAR, sRTC.u32Year, sRTC.u32Month, sRTC.u32Day,
|
|||
|
|
sRTC.u32Hour, sRTC.u32Minute, sRTC.u32Second);
|
|||
|
|
|
|||
|
|
if(last_SampleTime == 0 || totalSeconds + 3 >= last_SampleTime + 300)
|
|||
|
|
{
|
|||
|
|
if(dcBuff.configBottle.measureType == MEASURE_WEIGHT)
|
|||
|
|
u32Sample = sample.weight;
|
|||
|
|
else if(!dcBuff.configDisplay.op_USE_CAPACITY_SENSOR && !dcBuff.configDisplay.op_USE_HEIGHT_LEVEL && !dcBuff.configDisplay.op_USE_PCT_LEVEL)
|
|||
|
|
u32Sample = (uint32_t) KPa2mmH2O(sample.diff);
|
|||
|
|
else
|
|||
|
|
u32Sample = (uint32_t) sample.height;
|
|||
|
|
|
|||
|
|
if(!dcBuff.configDisplay.op_BOX_VER)
|
|||
|
|
{
|
|||
|
|
// <20><><EFBFBD><EFBFBD>Һλ<D2BA><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʷ<EFBFBD><CAB7><EFBFBD>͵<EFBFBD>+60mmWC/kg<6B><67><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>װ<EFBFBD><D7B0><EFBFBD><EFBFBD>ʱ
|
|||
|
|
if(!charging)
|
|||
|
|
{
|
|||
|
|
// <20><>¼Һλ<D2BA><CEBB><EFBFBD>͵<EFBFBD>
|
|||
|
|
if(u32Sample < lowest_Sample)
|
|||
|
|
lowest_Sample = u32Sample;
|
|||
|
|
if(u32Sample >= lowest_Sample + 120)
|
|||
|
|
{
|
|||
|
|
charging = 1;
|
|||
|
|
Wakeup_SetAlarm(1);
|
|||
|
|
sample.warnning = 1;
|
|||
|
|
stopGrowCount = 0;
|
|||
|
|
highest_Sample = u32Sample; // <20><><EFBFBD><EFBFBD>Һλ<D2BA><CEBB><EFBFBD>ߵ<EFBFBD><DFB5><EFBFBD>ֵ
|
|||
|
|
|
|||
|
|
printf("\n*** Charging warnning ***\n");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// <20><>¼Һλ<D2BA><CEBB><EFBFBD>ߵ<EFBFBD>
|
|||
|
|
if(u32Sample > highest_Sample)
|
|||
|
|
{
|
|||
|
|
stopGrowCount = 0;
|
|||
|
|
highest_Sample = u32Sample;
|
|||
|
|
}
|
|||
|
|
// <20><><EFBFBD><EFBFBD>Һλ<D2BA><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Һλ
|
|||
|
|
if(u32Sample <= highest_Sample)
|
|||
|
|
{
|
|||
|
|
stopGrowCount++;
|
|||
|
|
if(stopGrowCount >= 3)
|
|||
|
|
{
|
|||
|
|
charging = 0;
|
|||
|
|
sample.warnning = 1;
|
|||
|
|
lowest_Sample = u32Sample; // <20><><EFBFBD><EFBFBD>Һλ<D2BA><CEBB><EFBFBD>͵<EFBFBD><CDB5><EFBFBD>ֵ
|
|||
|
|
|
|||
|
|
printf("\n*** Stop charging warnning ***\n");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// TTS, <20>б<EFBFBD><D0B1>仯<EFBFBD><E4BBAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if(dcBuff.configBottle.serverVer == 3)
|
|||
|
|
{
|
|||
|
|
// һ<><D2BB>ʱ<EFBFBD><CAB1><EFBFBD>ڵı仯<C4B1><E4BBAF>
|
|||
|
|
if(dcBuff.configBottle.span > 0) // <20>仯<EFBFBD><E4BBAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч
|
|||
|
|
{
|
|||
|
|
for(i = 0; i < last_spanCount; i++)
|
|||
|
|
{
|
|||
|
|
if(totalSeconds <= last_spanTime[i] + dcBuff.configBottle.spanPeriod)
|
|||
|
|
{
|
|||
|
|
if(sample.volumePct >= last_spanPct[i])
|
|||
|
|
span = sample.volumePct - last_spanPct[i];
|
|||
|
|
else
|
|||
|
|
span = last_spanPct[i] - sample.volumePct;
|
|||
|
|
if(span >= dcBuff.configBottle.span * 100)
|
|||
|
|
{
|
|||
|
|
sample.warnning = 1;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if(last_spanCount >= 20)
|
|||
|
|
{
|
|||
|
|
for(i = 0; i < last_spanCount - 1; i++)
|
|||
|
|
{
|
|||
|
|
last_spanPct[i] = last_spanPct[i + 1];
|
|||
|
|
last_spanTime[i] = last_spanTime[i + 1];
|
|||
|
|
}
|
|||
|
|
last_spanCount--;
|
|||
|
|
}
|
|||
|
|
last_spanPct[last_spanCount] = sample.volumePct;
|
|||
|
|
last_spanTime[last_spanCount] = totalSeconds;
|
|||
|
|
last_spanCount++;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>¼<EFBFBD>ж<EFBFBD>ʱ<EFBFBD><CAB1>
|
|||
|
|
last_SampleTime = totalSeconds;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(sample.warnning)
|
|||
|
|
printf("\n*** Level warnning ***\n");
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ó<EFBFBD>װ<EFBFBD><D7B0>־
|
|||
|
|
sample.charging = charging;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20>ж<EFBFBD><D0B6>Ƿ<EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if(!dcBuff.configDisplay.op_LEVEL_SENSOR_ONLY)
|
|||
|
|
{
|
|||
|
|
if(sample.staPress.status == SENSOR_STATUS_NORMAL)
|
|||
|
|
{
|
|||
|
|
if(dcBuff.configBottle.warnPress > 0 && last_Press > dcBuff.configBottle.warnPress && sample.pressure <= dcBuff.configBottle.warnPress)
|
|||
|
|
sample.warnning = 1;
|
|||
|
|
if(dcBuff.configBottle.warnPressH > 0 && last_Press < dcBuff.configBottle.warnPressH && sample.pressure >= dcBuff.configBottle.warnPressH)
|
|||
|
|
sample.warnning = 1;
|
|||
|
|
|
|||
|
|
// <20><>¼<EFBFBD>ɼ<EFBFBD>ֵ
|
|||
|
|
last_Press = sample.pressure;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7>¶ȱ<C2B6><C8B1><EFBFBD>
|
|||
|
|
if(dcBuff.configBottle.serverVer != 3 && !dcBuff.configDisplay.op_LEVEL_SENSOR_ONLY)
|
|||
|
|
{
|
|||
|
|
if(sample.staExtTempr[0].status == SENSOR_STATUS_NORMAL)
|
|||
|
|
{
|
|||
|
|
if(dcBuff.configBottle.warnTempr > -300 && last_Tempr > dcBuff.configBottle.warnTempr && sample.extTempr[0] <= dcBuff.configBottle.warnTempr)
|
|||
|
|
sample.warnning = 1;
|
|||
|
|
if(dcBuff.configBottle.warnTemprH > -300 && last_Tempr < dcBuff.configBottle.warnTemprH && sample.extTempr[0] >= dcBuff.configBottle.warnTemprH)
|
|||
|
|
sample.warnning = 1;
|
|||
|
|
|
|||
|
|
// <20><>¼<EFBFBD>ɼ<EFBFBD>ֵ
|
|||
|
|
last_Tempr = sample.extTempr[0];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>նȱ<D5B6><C8B1><EFBFBD>
|
|||
|
|
if(dcBuff.configBottle.serverVer != 3 && sample.vacuum[0].staVacuum == VACUUM_STATUS_OK)
|
|||
|
|
{
|
|||
|
|
if(dcBuff.configBottle.warnVacuumH > 0 && last_Vacuum < dcBuff.configBottle.warnVacuumH * 0.01 && sample.vacuum[0].vacuum >= dcBuff.configBottle.warnVacuumH * 0.01)
|
|||
|
|
sample.warnning = 1;
|
|||
|
|
|
|||
|
|
// <20><>¼<EFBFBD>ɼ<EFBFBD>ֵ
|
|||
|
|
last_Vacuum = sample.vacuum[0].vacuum;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20>۳<EFBFBD><DBB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5>
|
|||
|
|
if(!dcBuff.configDisplay.op_SEND_GPS_DATA && !dcBuff.configDisplay.op_BOX_VER && RF_initStatus && (charging || Manual_Charing))
|
|||
|
|
{
|
|||
|
|
if((dcBuff.configBottle.measureType == MEASURE_WEIGHT && sample.staWeight.status == SENSOR_STATUS_NORMAL) ||
|
|||
|
|
(dcBuff.configBottle.measureType == MEASURE_DPRESS && sample.staDPress.status == SENSOR_STATUS_NORMAL))
|
|||
|
|
{
|
|||
|
|
if(dcBuff.configBottle.fullPct > 0 && sample.volumePct >= dcBuff.configBottle.fullPct)
|
|||
|
|
Match_Charging = 0;
|
|||
|
|
if(dcBuff.configBottle.fullPct > 0 && sample.volumePct < dcBuff.configBottle.fullPct - 10 * 100)
|
|||
|
|
Match_Charging = 1;
|
|||
|
|
|
|||
|
|
if((Match_Charging == 0 && (!Truck_Matched || Truck_Charging)) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD>ٷ<EFBFBD><D9B7><EFBFBD>
|
|||
|
|
|| (Match_Charging == 1 && totalSeconds + 3 >= Match_Time + 60)) // <20><>װ<EFBFBD>У<EFBFBD><D0A3><EFBFBD>1<EFBFBD><31><EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD>һ<EFBFBD><D2BB>
|
|||
|
|
{
|
|||
|
|
Match_Time = totalSeconds;
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><F1A3ACBD>г<EFBFBD>װƥ<D7B0><C6A5>
|
|||
|
|
xSemaphoreGive(Match_Semaphore);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>dz<EFBFBD>װ״̬<D7B4><CCAC>ƥ<EFBFBD>临λ
|
|||
|
|
if(!dcBuff.configDisplay.op_SEND_GPS_DATA && !dcBuff.configDisplay.op_BOX_VER && RF_initStatus && (!charging && !Manual_Charing))
|
|||
|
|
{
|
|||
|
|
Match_Charging = 1; // <20>س<EFBFBD><D8B3><EFBFBD><EFBFBD>䣬δ<E4A3AC><CEB4><EFBFBD><EFBFBD>
|
|||
|
|
Match_Time = 0;
|
|||
|
|
Truck_Matched = 0;
|
|||
|
|
Truck_Charging = 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// д<><D0B4>ȫ<EFBFBD>ֻ<EFBFBD><D6BB>壨<EFBFBD><E5A3A8><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD>־<EFBFBD><D6BE>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
if(dcBuff.sampleData.warnning)
|
|||
|
|
sample.warnning = 1;
|
|||
|
|
dcBuff.sampleData = sample;
|
|||
|
|
if((dcBuff.sampleData.leak.staLeak == LEAK_STATUS_A2_ALARM) != lastLeakWarning)
|
|||
|
|
{
|
|||
|
|
printf("\n*** Leak warnning: %d ***\n", (dcBuff.sampleData.leak.staLeak == LEAK_STATUS_A2_ALARM));
|
|||
|
|
dcBuff.sampleData.warnning = 1;
|
|||
|
|
// <20>״μ<D7B4><CEBC>й¶<D0B9><C2B6>ֹͣй¶<D0B9><C2B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
DTU_semGPRS = 1;
|
|||
|
|
}
|
|||
|
|
lastLeakWarning = (dcBuff.sampleData.leak.staLeak == LEAK_STATUS_A2_ALARM);
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>չ<EFBFBD>¶ȣ<C2B6><C8A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD><D5BC>¶ȣ<C2B6><C8A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD><D5BC>¶ȴ<C2B6><C8B4><EFBFBD><EFBFBD><EFBFBD>չ<EFBFBD>¶ȣ<C2B6><C8A3><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD>ϴ<EFBFBD><CFB4><EFBFBD>
|
|||
|
|
if(dcBuff.sampleData.staExtTempr[0].status == SENSOR_STATUS_NOCONNECT)
|
|||
|
|
{
|
|||
|
|
if(dcBuff.sampleData.vacuum[0].staVacuum != VACUUM_STATUS_COMM_FAULT && dcBuff.sampleData.vacuum[0].staVacuum != VACUUM_STATUS_FAULT)
|
|||
|
|
{
|
|||
|
|
dcBuff.sampleData.extTempr[0] = dcBuff.sampleData.vacuum[0].tempr;
|
|||
|
|
dcBuff.sampleData.staExtTempr[0].status = SENSOR_STATUS_NORMAL;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD>ص<EFBFBD>ѹ
|
|||
|
|
if(DS2788_ReadBattery(&dtuSample))
|
|||
|
|
{
|
|||
|
|
dcBuff.dtuData.batLow = dtuSample.batLow;
|
|||
|
|
dcBuff.dtuData.batCurrent = dtuSample.batCurrent;
|
|||
|
|
dcBuff.dtuData.batPct = dtuSample.batPct;
|
|||
|
|
dcBuff.dtuData.batCapa = dtuSample.batCapa;
|
|||
|
|
dcBuff.dtuData.batMaxCapa = dtuSample.batMaxCapa;
|
|||
|
|
dcBuff.dtuData.batTempr = dtuSample.batTempr;
|
|||
|
|
dcBuff.dtuData.batVoltage = dtuSample.batVoltage;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><>ֹADC
|
|||
|
|
LL_ADC_Disable(ADC1);
|
|||
|
|
|
|||
|
|
// ֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
GPRS_semSampled = 1;
|
|||
|
|
// ֪ͨ<CDA8><D6AA>ʾ<EFBFBD><CABE><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
Config_Sample_Request = 0;
|
|||
|
|
// ֪ͨ<CDA8><D6AA>ʾ<EFBFBD><CABE>: ˢ<><CBA2>
|
|||
|
|
xSemaphoreGive(Key_Semaphore); //Form_Refresh(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD>⣬<EFBFBD>п<EFBFBD><D0BF>ܳ<EFBFBD>ͻ
|
|||
|
|
// ˢ<>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
DAC7311_Refresh();
|
|||
|
|
|
|||
|
|
/* Get the conversion result */
|
|||
|
|
if(!dcBuff.configDisplay.op_USE_CAPACITY_SENSOR)
|
|||
|
|
printf("\nConversion result of diff: \t\t%02X, %.1f kPa", sample.staDPress.status, sample.diff);
|
|||
|
|
else
|
|||
|
|
printf("\nConversion result of capa: \t\t%02X, %.1f pF", sample.staDPress.status, sample.diff);
|
|||
|
|
// printf("\nConversion result of press: \t\t%02X, %.2f MPa", sample.staPress.status, (float) sample.pressure / 1000);
|
|||
|
|
// for(i = 0; i < 0; i++)
|
|||
|
|
// printf("\nConversion result of extPress[%d]: \t%02X, %.2f MPa", i, sample.staExtPress[i].status, (float) sample.extPressure[i] / 1000);
|
|||
|
|
// for(i = 0; i < 2; i++)
|
|||
|
|
// printf("\nConversion result of extTempr[%d]: \t%02X, %d <20><>", i, sample.staExtTempr[i].status, sample.extTempr[i]);
|
|||
|
|
|
|||
|
|
printf("\nConversion result of height: \t\t%.1f mm", sample.height);
|
|||
|
|
// printf("\nConversion result of volTol: \t\t%u L", sample.volumeTotal);
|
|||
|
|
// printf("\nConversion result of volume: \t\t%u L", sample.volume);
|
|||
|
|
printf("\nConversion result of volPct: \t\t%.2f %%", (float) sample.volumePct / 100);
|
|||
|
|
printf("\nConversion result of charging: \t\t%d", sample.charging);
|
|||
|
|
|
|||
|
|
// printf("\nConversion result of staVacuum: \t%u", sample.vacuum[0].staVacuum);
|
|||
|
|
// printf("\nConversion result of lifeVacuum: \t%u Months", sample.vacuum[0].lifeVacuum);
|
|||
|
|
printf("\nConversion result of vacuum: \t\t%.2f Pa", sample.vacuum[0].vacuum);
|
|||
|
|
// printf("\nConversion result of rateVacuum: \t%.2f Pa.M3/s", sample.vacuum[0].rateVacuum);
|
|||
|
|
// printf("\nConversion result of typeLeak: \t\t%u", sample.leak.typeLeak);
|
|||
|
|
// printf("\nConversion result of staLeak: \t\t%u", sample.leak.staLeak);
|
|||
|
|
printf("\nConversion result of concentrations: \t%u %%", sample.leak.concentrations);
|
|||
|
|
printf("\n");
|
|||
|
|
|
|||
|
|
if(first)
|
|||
|
|
{
|
|||
|
|
first = 0;
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD>ϲɼ<CFB2><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
Config_Vacuum_Request = 1;
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
xSemaphoreGive(Sample_Semaphore);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
Sample_phase = 0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void Match_Task(void *p_arg)
|
|||
|
|
{
|
|||
|
|
uint8_t fail_count = 0;
|
|||
|
|
|
|||
|
|
while(1)
|
|||
|
|
{
|
|||
|
|
// <20>ȴ<EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD>ź<EFBFBD>
|
|||
|
|
xSemaphoreTake(Match_Semaphore, portMAX_DELAY);
|
|||
|
|
|
|||
|
|
RF_PowerOn();
|
|||
|
|
Truck_Matched = rf_charge_match(Match_Charging);
|
|||
|
|
if(Truck_Matched)
|
|||
|
|
{
|
|||
|
|
fail_count = 0;
|
|||
|
|
Truck_Charging = Match_Charging;
|
|||
|
|
if(!Truck_Charging)
|
|||
|
|
Manual_Charing = 0;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
if(++fail_count >= 3)
|
|||
|
|
{
|
|||
|
|
fail_count = 0;
|
|||
|
|
Manual_Charing = 0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
RF_PowerOff();
|
|||
|
|
|
|||
|
|
if(!Manual_Charing)
|
|||
|
|
{
|
|||
|
|
printf("********* Manual_Charing = 0 ****\r\n");
|
|||
|
|
// <20>ָ<EFBFBD><D6B8><EFBFBD>ʼ״̬
|
|||
|
|
Truck_Matched = 0;
|
|||
|
|
Truck_Charging = 0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|