feat: 新增全功率运行时间段(FPO)功能
- bsp.h: LayoutPara_t 新增 FPOTimeStart/FPOTime 字段, 移除BOM, 声明TimeGet - main.h: 声明 IsFullPowerTime - main.c: 新增 IsFullPowerTime() 判断函数(支持跨天), 睡眠条件加FPO检查, AppInit中FPO参数初始化与校验 - SGCP.h: 新增 GWTOMD_CMD_SET_FPO=0x0A, GW_STATUS_SET_FPO 枚举, 声明 ToGWSetFPORes - SGCP.c: 实现 ToGWSetFPORes() 回应帧, GWTOMD_CMD_SET_FPO 接收处理(校验/存Flash), 两个GwRevLoopHandler新增GW_STATUS_SET_FPO case - UartDebug.c: 新增 fpocfg 调试命令(配置后向网关发送0x0A通知), para输出FPO信息, DEBUG_CMD_CNT 17->18 - bsp.c: TimeGet 去除UTC+8偏移(RTC已存本地时间)
This commit is contained in:
+6
-6
@@ -103,7 +103,7 @@
|
||||
<bEvRecOn>1</bEvRecOn>
|
||||
<bSchkAxf>0</bSchkAxf>
|
||||
<bTchkAxf>0</bTchkAxf>
|
||||
<nTsel>12</nTsel>
|
||||
<nTsel>6</nTsel>
|
||||
<sDll></sDll>
|
||||
<sDllPa></sDllPa>
|
||||
<sDlgDll></sDlgDll>
|
||||
@@ -114,7 +114,7 @@
|
||||
<tDlgDll></tDlgDll>
|
||||
<tDlgPa></tDlgPa>
|
||||
<tIfile></tIfile>
|
||||
<pMon>BIN\CMSIS_AGDI.dll</pMon>
|
||||
<pMon>Segger\JL2CM3.dll</pMon>
|
||||
</DebugOpt>
|
||||
<TargetDriverDllRegistry>
|
||||
<SetRegEntry>
|
||||
@@ -135,7 +135,7 @@
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>JL2CM3</Key>
|
||||
<Name>-U4294967295 -O78 -S1 -ZTIFSpeedSel10000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(0BC11477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8027 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD20000000 -FC1000 -FN1 -FF0FlashHC32L17X_128K.FLM -FS00 -FL020000 -FP0($$Device:HC32L170JATA$Flash\FlashHC32L17X_128K.FLM)</Name>
|
||||
<Name>-U12345678 -O78 -S2 -ZTIFSpeedSel5000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(0BC11477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8027 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD20000000 -FC1000 -FN1 -FF0FlashHC32L17X_128K.FLM -FS00 -FL020000 -FP0($$Device:HC32L170JATA$Flash\FlashHC32L17X_128K.FLM)</Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
@@ -411,7 +411,7 @@
|
||||
<bEvRecOn>1</bEvRecOn>
|
||||
<bSchkAxf>0</bSchkAxf>
|
||||
<bTchkAxf>0</bTchkAxf>
|
||||
<nTsel>12</nTsel>
|
||||
<nTsel>6</nTsel>
|
||||
<sDll></sDll>
|
||||
<sDllPa></sDllPa>
|
||||
<sDlgDll></sDlgDll>
|
||||
@@ -422,7 +422,7 @@
|
||||
<tDlgDll></tDlgDll>
|
||||
<tDlgPa></tDlgPa>
|
||||
<tIfile></tIfile>
|
||||
<pMon>BIN\CMSIS_AGDI.dll</pMon>
|
||||
<pMon>Segger\JL2CM3.dll</pMon>
|
||||
</DebugOpt>
|
||||
<TargetDriverDllRegistry>
|
||||
<SetRegEntry>
|
||||
@@ -443,7 +443,7 @@
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>JL2CM3</Key>
|
||||
<Name>-U4294967295 -O78 -S1 -ZTIFSpeedSel10000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(0BC11477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8027 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD20000000 -FC1000 -FN1 -FF0FlashHC32L17X_128K.FLM -FS00 -FL020000 -FP0($$Device:HC32L170JATA$Flash\FlashHC32L17X_128K.FLM)</Name>
|
||||
<Name>-U12345678 -O78 -S2 -ZTIFSpeedSel5000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(0BC11477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8027 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD20000000 -FC1000 -FN1 -FF0FlashHC32L17X_128K.FLM -FS00 -FL020000 -FP0($$Device:HC32L170JATA$Flash\FlashHC32L17X_128K.FLM)</Name>
|
||||
</SetRegEntry>
|
||||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
|
||||
#if (USE_DEBUG != 0)
|
||||
#define DEBUG_CMD_CNT 17
|
||||
#define DEBUG_CMD_CNT 18
|
||||
const DBGFunType DebugFun[DEBUG_CMD_CNT];
|
||||
|
||||
volatile DebugChannel_e gDebugChannel = DBG_CH_RS485_1;//上电默认调试口
|
||||
@@ -214,6 +214,10 @@ static void DebugCmdGetPara(int argc, char *argv[])
|
||||
DBG_LOG("Lora: ch %d, rp %d, fc %d\r\n", App.Para.Lora.ucChannel, App.Para.Lora.RegPreamble, App.Para.Lora.FreqCent);
|
||||
DBG_LOG("LpCfg: CI:%dsec, RI:%dmin, EI:%dmin, ET:%dmin\r\n",
|
||||
App.Para.Layout.CollectTime*30, App.Para.Layout.ReportInterval/2, App.Para.Layout.ERInterval/2, App.Para.Layout.ERTime/2);
|
||||
DBG_LOG("FpoCfg: Start:%02d:00, Dur:%dh, End:%02d:00, %s\r\n",
|
||||
App.Para.Layout.FPOTimeStart, App.Para.Layout.FPOTime,
|
||||
(App.Para.Layout.FPOTimeStart + App.Para.Layout.FPOTime) % 24,
|
||||
(IsFullPowerTime() == true) ? "FullPower" : "LowPower");
|
||||
DBG_LOG("Laser: %s, AutoOff: %dmin\r\n",
|
||||
(SGCP.LaserOnOff == true) ? "ON" : "OFF", SGCP.LaserTimerMinutes);
|
||||
struct tm *stime;
|
||||
@@ -739,6 +743,58 @@ static void DebugCmdLPConfig(int argc, char *argv[])
|
||||
DBG_LOG("The low-power device is configured.\r\n");
|
||||
}
|
||||
/*****************************************************************************************
|
||||
* 函数名称: DebugCmdFPOConfig
|
||||
* 功能描述: 全功率运行时间段配置
|
||||
* 参 数: argc, 输入参数数量
|
||||
argv, 输入参数
|
||||
* 返 回 值: 无
|
||||
*****************************************************************************************/
|
||||
static void DebugCmdFPOConfig(int argc, char *argv[])
|
||||
{
|
||||
DBG_LOG("\r\n");
|
||||
if(argc < 2)
|
||||
return;
|
||||
|
||||
if(strcmp(argv[1], "?") == 0) {
|
||||
DBG_LOG("Debug Cmd: fpocfg arg1 arg2\r\n");
|
||||
DBG_LOG(" brief --> Configure full-power work period.\r\n");
|
||||
DBG_LOG(" arg1 --> Full-power work start hour. (0~23 hour)\r\n");
|
||||
DBG_LOG(" arg2 --> Full-power work duration. (0~24 hour, 0=off)\r\n\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if(argc < 3)
|
||||
return;
|
||||
|
||||
uint8_t FPOTimeStart = (uint8_t)atoi(argv[1]);
|
||||
uint8_t FPOTime = (uint8_t)atoi(argv[2]);
|
||||
if(FPOTimeStart > 23) {
|
||||
DBG_LOG("FPOTimeStart Para Error! (0~23)\r\n");
|
||||
return;
|
||||
}
|
||||
if(FPOTime > 24) {
|
||||
DBG_LOG("FPOTime Para Error! (0~24)\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
App.Para.Layout.FPOTimeStart = FPOTimeStart;
|
||||
App.Para.Layout.FPOTime = FPOTime;
|
||||
SAVE_APP_PARA((uint32_t *)&App.Para);
|
||||
DBG_LOG("The full-power work period is configured. Start:%02d:00, Dur:%dh, End:%02d:00\r\n",
|
||||
App.Para.Layout.FPOTimeStart, App.Para.Layout.FPOTime,
|
||||
(App.Para.Layout.FPOTimeStart + App.Para.Layout.FPOTime) % 24);
|
||||
|
||||
if(SGCP.LoginOk)
|
||||
{
|
||||
ToGWSetFPORes();
|
||||
DBG_LOG("FPO config update sent to gateway.\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG_LOG("Gateway not logged in, skip sending FPO config update.\r\n");
|
||||
}
|
||||
}
|
||||
/*****************************************************************************************
|
||||
* 函数名称: DebugLaserConfig
|
||||
* 功能描述: 激光控制
|
||||
* 参 数: argc, 输入参数数量
|
||||
@@ -1062,6 +1118,16 @@ void DebugCmdHelp(int argc, char *argv[])
|
||||
}
|
||||
DebugCmdLPConfig(argc1, argv1);
|
||||
|
||||
memset(Data, 0x00, 10);
|
||||
len = strlen("fpocfg ?\0");
|
||||
memcpy(Data, "fpocfg ?\0", len);
|
||||
token = strtok(Data, " "); // 假设分隔符是空格
|
||||
for(argc1 = 0; (token != NULL && argc1 < 10); argc1++) {
|
||||
argv1[argc1] = token;
|
||||
token = strtok(NULL, " ");
|
||||
}
|
||||
DebugCmdFPOConfig(argc1, argv1);
|
||||
|
||||
memset(Data, 0x00, 10);
|
||||
len = strlen("laser ?\0");
|
||||
memcpy(Data, "laser ?\0", len);
|
||||
@@ -1134,6 +1200,7 @@ const DBGFunType DebugFun[DEBUG_CMD_CNT] = {
|
||||
"rs485", DebugCmdRS485Ctrl,
|
||||
"lora", DebugLoraConfig,
|
||||
"lpcfg", DebugCmdLPConfig,
|
||||
"fpocfg", DebugCmdFPOConfig,
|
||||
"laser", DebugLaserConfig,
|
||||
"res", DebugCmdRestoreFactory,
|
||||
"dch", DebugCmdChannel,
|
||||
|
||||
+4
-1
@@ -98,6 +98,7 @@ typedef enum {
|
||||
GW_STATUS_CALI,
|
||||
GW_STATUS_READ_SENSOR,
|
||||
GW_STATUS_SET_COL_TIME,
|
||||
GW_STATUS_SET_FPO,//设置全功率运行时间段
|
||||
GW_STATUS_SYNC_TIME,
|
||||
GW_STATUS_UPLOAD_SENSOR,//主动上报模式时会使用该状态
|
||||
GW_STATUS_WAIT_UPLOAD,//主动上报模式时会使用该状态
|
||||
@@ -125,7 +126,8 @@ typedef enum {
|
||||
GWTOMD_CMD_LOGIN = 0x00, //0x00,设备注册
|
||||
GWTOMD_CMD_CALI = 0x01, //0x01, 校准指令
|
||||
GWTOMD_CMD_READ_UPLOAD_SENSOR = 0x02, //0x02,读取数据指令or上传数据指令
|
||||
GWTOMD_CMD_SET_COL_TIME = 0x05, //0x05,设置采集时间间隔
|
||||
GWTOMD_CMD_SET_FPO = 0x0A, //0x0A, 设置全功率运行时间段(低功耗设备)
|
||||
GWTOMD_CMD_SET_COL_TIME = 0x05, //0x05,设置采集时间间隔
|
||||
GWTOMD_CMD_SYNC_TIME = 0x06, //0x06,时间同步
|
||||
GWTOMD_CMD_SET_LASER = 0x08,//打开or关闭激光
|
||||
GWTOMD_CMD_SIGNAL = 0x09,
|
||||
@@ -281,6 +283,7 @@ typedef struct {
|
||||
extern SGCP_t SGCP;
|
||||
|
||||
void SGCP1mSRoutine(void);
|
||||
void ToGWSetFPORes(void);
|
||||
|
||||
void GwRevLoopHandler(void);
|
||||
void MasRevLoopHandler(void);
|
||||
|
||||
+4
-1
@@ -1,4 +1,4 @@
|
||||
#ifndef _BSP_H
|
||||
#ifndef _BSP_H
|
||||
#define _BSP_H
|
||||
|
||||
#include <stdint.h>
|
||||
@@ -225,6 +225,8 @@ typedef struct {
|
||||
uint16_t ReportInterval; //上报时间间隔,设置范围,30*N秒,10<=N<=1440(默认1200秒,N=40)
|
||||
uint8_t ERInterval; //紧急上报时间间隔,设置范围,30*N秒,2<=N<=10(默认120秒,N=4)
|
||||
uint8_t ERTime; //紧急上报时长,设置范围,30*N秒,20<=N<=240(默认1200秒,N=40)
|
||||
uint8_t FPOTimeStart; //每天全功率工作时间起始点时间,设置范围0~23小时整点时间(默认0点整)
|
||||
uint8_t FPOTime; //每天全功率工作时间时长,设置范围0~24小时(默认0小时)
|
||||
uint32_t TimeStamp; //网关返回RTC时间戳
|
||||
}__attribute__((packed))LayoutPara_t,*LayoutPara;//上位机下发的配置参数
|
||||
|
||||
@@ -279,6 +281,7 @@ uint32_t GetSysTick(void);
|
||||
void delay_ms(uint32_t ms);
|
||||
void Delay(uint32_t time);
|
||||
void RTCInit(uint8_t sec);
|
||||
void TimeGet(struct tm *cTime);
|
||||
void LPTimer0_ON(uint16_t _100ms);
|
||||
void LPTimer0_OFF(void);
|
||||
void WakeUpInit(void);
|
||||
|
||||
@@ -107,6 +107,7 @@ extern AppDetect_t App;
|
||||
|
||||
void MainDBGOnOff(bool OnOff);
|
||||
void DataDBGOnOff(bool OnOff);
|
||||
bool IsFullPowerTime(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+140
-23
@@ -652,6 +652,46 @@ SGCP.GWRS485Rx.sCmdMDToGW = (GWTOMD_CMD_M)GFHeader->Cmd;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief 网关设置全功率运行时间段指令回应
|
||||
**
|
||||
** \param 无(回显已配置的 FPOTimeStart 与 FPOTime,与接收格式一致)
|
||||
**
|
||||
** \retval 无
|
||||
******************************************************************************/
|
||||
void ToGWSetFPORes(void)
|
||||
{
|
||||
uint8_t Pack[256];
|
||||
uint16_t Crc16;
|
||||
uint8_t Len;
|
||||
|
||||
GatewayFrameHeader GFHeader = (GatewayFrameHeader)Pack;
|
||||
|
||||
GFHeader->Header = 0x7B;
|
||||
memcpy(&GFHeader->GWAddr[0], &GatewayMAC[0], sizeof(GFHeader->GWAddr));
|
||||
memcpy(&GFHeader->MDAddr[0], &LocalMAC[0], sizeof(GFHeader->MDAddr));
|
||||
GFHeader->Cmd = GWTOMD_CMD_SET_FPO;
|
||||
GFHeader->PayloadLen = 2;
|
||||
|
||||
Len = sizeof(GatewayFrameHeader_t);
|
||||
|
||||
Pack[Len++] = App.Para.Layout.FPOTimeStart;
|
||||
Pack[Len++] = App.Para.Layout.FPOTime;
|
||||
|
||||
Crc16 = CRC_Modbus(CRC16_BASE, Pack, Len);
|
||||
Pack[Len++] = Crc16 & 0x00ff;
|
||||
Pack[Len++] = (Crc16 >> 8) & 0x00ff;
|
||||
|
||||
SGCP.GWRS485Rx.sCmdMDToGW = (GWTOMD_CMD_M)GFHeader->Cmd;
|
||||
#if(SGCP_SELECT == 1 || SGCP_SELECT == 2)
|
||||
Sx1276LoRaSendBuffer(Pack, Len);
|
||||
#endif
|
||||
#if(SGCP_SELECT == 3)
|
||||
LPUart0SendArray(Pack, Len);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief 网关时间同步指令回应
|
||||
@@ -981,29 +1021,69 @@ static void GWRevHandler(void)
|
||||
}
|
||||
else if(PayLoadLen == 10)
|
||||
{
|
||||
App.Para.Layout.CollectTime = LPay->CollectTime/30;
|
||||
App.Para.Layout.ReportInterval = LPay->ReportInterval * 2;
|
||||
App.Para.Layout.ERInterval = LPay->ERInterval * 2;
|
||||
App.Para.Layout.ERTime = LPay->ERTime * 2;
|
||||
App.Para.Layout.TimeStamp = LPay->TimeStamp;
|
||||
|
||||
DBG_LOG("The parameters have been updated. CI:%ds, RI:%dmin, EI:%dmin, ET:%dmin\r\n",
|
||||
LPay->CollectTime,
|
||||
LPay->ReportInterval,
|
||||
LPay->ERInterval,
|
||||
LPay->ERTime);
|
||||
|
||||
int8_t TimeDiff;//时间差
|
||||
int RTCTimes = TimeTs();
|
||||
TimeDiff = App.Para.Layout.TimeStamp - RTCTimes;
|
||||
if(TimeDiff > 1 || TimeDiff < -1)
|
||||
{
|
||||
TimeSync(App.Para.Layout.TimeStamp); //向通讯单元RTC时间寄存器写入时间网关下发的时间
|
||||
}
|
||||
SGCP.UploadOk = true;
|
||||
SGCP.NextGWStatus = GW_STATUS_UPLOAD_SENSOR;
|
||||
App.Para.Layout.CollectTime = LPay->CollectTime/30;
|
||||
App.Para.Layout.ReportInterval = LPay->ReportInterval * 2;
|
||||
App.Para.Layout.ERInterval = LPay->ERInterval * 2;
|
||||
App.Para.Layout.ERTime = LPay->ERTime * 2;
|
||||
App.Para.Layout.TimeStamp = LPay->TimeStamp;
|
||||
|
||||
DBG_LOG("The parameters have been updated. CI:%ds, RI:%dmin, EI:%dmin, ET:%dmin\r\n",
|
||||
LPay->CollectTime,
|
||||
LPay->ReportInterval,
|
||||
LPay->ERInterval,
|
||||
LPay->ERTime);
|
||||
|
||||
int8_t TimeDiff;//时间差
|
||||
int RTCTimes = TimeTs();
|
||||
TimeDiff = App.Para.Layout.TimeStamp - RTCTimes;
|
||||
if(TimeDiff > 1 || TimeDiff < -1)
|
||||
{
|
||||
TimeSync(App.Para.Layout.TimeStamp); //向通讯单元RTC时间寄存器写入时间网关下发的时间
|
||||
}
|
||||
SGCP.UploadOk = true;
|
||||
SGCP.NextGWStatus = GW_STATUS_UPLOAD_SENSOR;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;}
|
||||
|
||||
case GWTOMD_CMD_SET_FPO:{
|
||||
if(SGCP.LoginOk == true)
|
||||
{
|
||||
uint8_t Start = PayLoad[0];
|
||||
uint8_t Duration = PayLoad[1];
|
||||
if(Start > 23)
|
||||
{
|
||||
DBG_LOG("FPOTimeStart Err\r\n");
|
||||
if(SGCP.GWStatus == GW_STATUS_WAIT_UPLOAD)
|
||||
{
|
||||
SGCP.UploadOk = true;
|
||||
SGCP.NextGWStatus = GW_STATUS_IDLE;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(Duration > 24)
|
||||
{
|
||||
DBG_LOG("FPOTime Err\r\n");
|
||||
if(SGCP.GWStatus == GW_STATUS_WAIT_UPLOAD)
|
||||
{
|
||||
SGCP.UploadOk = true;
|
||||
SGCP.NextGWStatus = GW_STATUS_IDLE;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(SGCP.GWStatus == GW_STATUS_WAIT_UPLOAD)
|
||||
{
|
||||
SGCP.UploadOk = true;
|
||||
SGCP.NextGWStatus = GW_STATUS_SET_FPO;
|
||||
}
|
||||
else
|
||||
{
|
||||
SGCP.GWStatus = GW_STATUS_SET_FPO;
|
||||
}
|
||||
App.Para.Layout.FPOTimeStart = Start;
|
||||
App.Para.Layout.FPOTime = Duration;
|
||||
SAVE_APP_PARA((uint32_t *)&App.Para);
|
||||
}
|
||||
break;}
|
||||
|
||||
@@ -1471,6 +1551,25 @@ void GwRevLoopHandler(void)
|
||||
SGCP.GW1mSDelayCnt = 5000;
|
||||
break;}
|
||||
|
||||
case GW_STATUS_SET_FPO:{
|
||||
PrintfMess();
|
||||
if(SGCP.BroadCmd == true)
|
||||
{
|
||||
SGCP.BroadCmd = false;
|
||||
DBG_LOG("Broad FPO Set as %02d:00 ~ %02d:00\r\n", App.Para.Layout.FPOTimeStart,
|
||||
(App.Para.Layout.FPOTimeStart + App.Para.Layout.FPOTime) % 24);
|
||||
}
|
||||
else
|
||||
{
|
||||
ToGWSetFPORes();
|
||||
DBG_LOG("Alone FPO Set as %02d:00 ~ %02d:00\r\n", App.Para.Layout.FPOTimeStart,
|
||||
(App.Para.Layout.FPOTimeStart + App.Para.Layout.FPOTime) % 24);
|
||||
}
|
||||
SGCP.GWStatus = GW_STATUS_WAIT_SUBIDLE;
|
||||
SGCP.NextSubStatus = SUB_STATUS_BROADCAST_SET_COLTIME;
|
||||
SGCP.GW1mSDelayCnt = 5000;
|
||||
break;}
|
||||
|
||||
case GW_STATUS_SYNC_TIME:{
|
||||
PrintfMess();
|
||||
if(SGCP.BroadCmd == true)
|
||||
@@ -1795,6 +1894,24 @@ void GwRevLoopHandler(void)
|
||||
SGCP.GWStatus = GW_STATUS_IDLE;
|
||||
break;}
|
||||
|
||||
case GW_STATUS_SET_FPO:{
|
||||
PrintfMess();
|
||||
if(SGCP.BroadCmd == true)
|
||||
{
|
||||
SGCP.BroadCmd = false;
|
||||
DBG_LOG("Broad FPO Set as %02d:00 ~ %02d:00\r\n", App.Para.Layout.FPOTimeStart,
|
||||
(App.Para.Layout.FPOTimeStart + App.Para.Layout.FPOTime) % 24);
|
||||
}
|
||||
else
|
||||
{
|
||||
ToGWSetFPORes();
|
||||
DBG_LOG("Alone FPO Set as %02d:00 ~ %02d:00\r\n", App.Para.Layout.FPOTimeStart,
|
||||
(App.Para.Layout.FPOTimeStart + App.Para.Layout.FPOTime) % 24);
|
||||
}
|
||||
/*GWRevHandler函数中已经缓存了接收到的全功率运行时间段*/
|
||||
SGCP.GWStatus = GW_STATUS_IDLE;
|
||||
break;}
|
||||
|
||||
case GW_STATUS_SYNC_TIME:{
|
||||
PrintfMess();
|
||||
if(SGCP.BroadCmd == true)
|
||||
@@ -1920,8 +2037,8 @@ void LORA_RxCallBack(uint8_t *rBuff, uint8_t rlen)
|
||||
{
|
||||
if (rlen > 0 && rBuff[0] == 0x7B && memcmp(&rBuff[7],&LocalMAC[0],6) == 0) // 如果接收到了数据,并且设备地址相同则处理接收到的数据
|
||||
{
|
||||
//< 处理接收到的数据
|
||||
memcpy(SGCP.GatewayBuff, rBuff, rlen);
|
||||
//< 处理接收到的数据
|
||||
memcpy(SGCP.GatewayBuff, rBuff, rlen);
|
||||
SGCP.GatewayBuffLen = rlen;
|
||||
GWRevHandler();//网关数据接收处理
|
||||
}
|
||||
|
||||
+1
-1
@@ -647,7 +647,7 @@ void TimeGet(struct tm *cTime)
|
||||
cTime->tm_year = BCDToDec(RtcDateTime.u8Year) + 100;
|
||||
cTime->tm_mon = BCDToDec(RtcDateTime.u8Month) - 1;
|
||||
cTime->tm_mday = BCDToDec(RtcDateTime.u8Day);
|
||||
cTime->tm_hour = BCDToDec(RtcDateTime.u8Hour) + 8;
|
||||
cTime->tm_hour = BCDToDec(RtcDateTime.u8Hour);
|
||||
cTime->tm_min = BCDToDec(RtcDateTime.u8Minute);
|
||||
cTime->tm_sec = BCDToDec(RtcDateTime.u8Second);
|
||||
cTime->tm_isdst = 0;
|
||||
|
||||
+38
-1
@@ -132,6 +132,9 @@ static void AppInit(void)
|
||||
App.Para.Layout.ReportInterval = 40;
|
||||
App.Para.Layout.ERInterval = 4;
|
||||
App.Para.Layout.ERTime = 40;
|
||||
|
||||
App.Para.Layout.FPOTime = 0;
|
||||
App.Para.Layout.FPOTimeStart = 0;
|
||||
}
|
||||
|
||||
if(App.Para.BLPara.LoraFreq < 410000000 || App.Para.BLPara.LoraFreq > 525000000)
|
||||
@@ -157,6 +160,12 @@ static void AppInit(void)
|
||||
if(App.Para.Layout.ERTime > 240 || App.Para.Layout.ERTime < 20) {
|
||||
App.Para.Layout.ERTime = 40;
|
||||
}
|
||||
if(App.Para.Layout.FPOTimeStart > 23 || App.Para.Layout.FPOTimeStart < 0) {
|
||||
App.Para.Layout.FPOTimeStart = 0;
|
||||
}
|
||||
if(App.Para.Layout.FPOTime > 24 || App.Para.Layout.FPOTime < 0) {
|
||||
App.Para.Layout.FPOTime = 0;
|
||||
}
|
||||
if(App.Para.LaserTimerMinutes < 0 || App.Para.LaserTimerMinutes > 240)
|
||||
App.Para.LaserTimerMinutes = 10;
|
||||
SGCP.LaserTimerMinutes = App.Para.LaserTimerMinutes;
|
||||
@@ -316,6 +325,33 @@ static void ReadDataLoopHandler(void)
|
||||
}
|
||||
}
|
||||
|
||||
bool IsFullPowerTime(void)
|
||||
{
|
||||
uint8_t Duration = App.Para.Layout.FPOTime;
|
||||
uint8_t Start = App.Para.Layout.FPOTimeStart;
|
||||
uint8_t Hour;
|
||||
struct tm cTime;
|
||||
|
||||
if(Duration == 0)
|
||||
return false;
|
||||
|
||||
TimeGet(&cTime);
|
||||
Hour = (uint8_t)(cTime.tm_hour % 24);
|
||||
|
||||
if(Start + Duration <= 24)
|
||||
{
|
||||
if(Hour >= Start && Hour < Start + Duration)
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8_t WrapEnd = Start + Duration - 24;
|
||||
if(Hour >= Start || Hour < WrapEnd)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void AppLoopHandler(void)
|
||||
{
|
||||
switch(App.Status) {
|
||||
@@ -385,7 +421,8 @@ static void AppLoopHandler(void)
|
||||
&& App.TD1mSDelayCnt == 0
|
||||
&& App.ReadData1mSDelayCnt == 0
|
||||
&& SGCP.LaserOnOff == false
|
||||
&& App.AttTestMode == false)
|
||||
&& App.AttTestMode == false
|
||||
&& IsFullPowerTime() == false)
|
||||
{
|
||||
//App.Status = APP_STATUS_ACTION;
|
||||
App.Status = APP_STATUS_OFF;
|
||||
|
||||
Reference in New Issue
Block a user