V2.0.3
This commit is contained in:
80
Version.txt
Normal file
80
Version.txt
Normal file
@ -0,0 +1,80 @@
|
||||
Version : V2.0.3
|
||||
主要解决问题:
|
||||
描述:光路改成双光纤进入双通道光闸再进入仪器,上下通道存在波长漂移。
|
||||
解决方法:对上下通道进行波长定标后,将下通道的数据重采样到和上通道同一波长,进行数据处理。
|
||||
|
||||
功能:
|
||||
|
||||
1、上下通道需进行波长定标
|
||||
在没有波长定标系数时,一直处于定标模式
|
||||
如何进行波长定标:
|
||||
1、将485接口接上电脑 串口选择对应的COM 波特率115200 打开串口
|
||||
2、在 设置-->工作模式-->高级模式-->设置
|
||||
3、断电重启仪器
|
||||
4、使用SpectralPlot采集上下同道各50条数据
|
||||
5、交给张欣欣处理得到波长系数
|
||||
6、使用SpectralPlot 文件-->高级 -->打开串口 发送json命令
|
||||
a是上通道定标系数
|
||||
b是下通道定标系数
|
||||
{
|
||||
"command": "set_bochangxishu",
|
||||
"bochangxishu": {
|
||||
"a0": -1.37016491e-9,
|
||||
"a1": -0.000052,
|
||||
"a2": 0.440364,
|
||||
"a3": 348.4284,
|
||||
"b0": -1.2597071e-9,
|
||||
"b1": -0.000053,
|
||||
"b2": 0.440609,
|
||||
"b3": 348.3989
|
||||
}
|
||||
}
|
||||
|
||||
如果是重新波长定标 先把波长定标系数设置为0,重启就进入定标模式
|
||||
{
|
||||
"command": "set_bochangxishu",
|
||||
"bochangxishu": {
|
||||
"a0": 0,
|
||||
"a1": 0,
|
||||
"a2": 0,
|
||||
"a3": 0,
|
||||
"b0": 0,
|
||||
"b1": 0,
|
||||
"b2": 0,
|
||||
"b3": 0
|
||||
}
|
||||
}
|
||||
7、断电重启
|
||||
|
||||
2、上下通道进行能量定标
|
||||
能量定标必须先做波长定标后
|
||||
1、使用SpectralPlot 文件-->设置-->定标-->导入灯文件-->设置光照-->采集数据-->计算 在SpectralPlot安装目录下就会有downgain.bin 和 upgain.bin两个文件
|
||||
2、插上USB调试口,不打开
|
||||
2、使用SpectralPlot 文件-->高级 -->打开串口 发送json命令
|
||||
{
|
||||
"command": "USB"
|
||||
}
|
||||
3、等待一会电脑就会将仪器识别为U盘,将两个文件复制到U盘目录中的/calfiles 文件夹下
|
||||
4、断电重启
|
||||
|
||||
3、4G模式
|
||||
开启4G模式后数据会自动上传到服务器
|
||||
同时支持 mqtt 远程通讯控制
|
||||
从服务器自动获取时间配置时间
|
||||
获取GPS信息
|
||||
|
||||
1、使用SpectralPlot 文件-->高级 -->打开串口 发送json命令
|
||||
{
|
||||
"command": "set_4g",
|
||||
"status_4g": "open_4g"
|
||||
}
|
||||
|
||||
2、命令2
|
||||
{
|
||||
"command": "set_work_mode",
|
||||
"work_mode": "4G_mode"
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,17 +1,23 @@
|
||||
float catmullSlope(float x[], float y[], int n, int i)
|
||||
#include "CastumullSpline.h"
|
||||
|
||||
float catmullSlope(float *x, float *y, int n, int i)
|
||||
{
|
||||
if (x[i + 1] == x[i - 1]) return 0;
|
||||
return (y[i + 1] - y[i - 1]) / (x[i + 1] - x[i - 1]);
|
||||
}
|
||||
|
||||
|
||||
float CatmullSpline(float xValues[], float yValues[], int numValues, float pointX, bool trim)
|
||||
float CatmullSpline(float *xValues, float *yValues, int numValues, float pointX, int trim)
|
||||
{
|
||||
if (trim)
|
||||
{
|
||||
if (pointX <= xValues[0]) return yValues[0];
|
||||
if (pointX >= xValues[numValues - 1]) return yValues[numValues - 1];
|
||||
}
|
||||
// if (trim)
|
||||
// {
|
||||
// if (pointX <= xValues[0]) return yValues[0];
|
||||
// if (pointX >= xValues[numValues - 1]) return yValues[numValues - 1];
|
||||
// }
|
||||
|
||||
|
||||
if (pointX <= xValues[0]) return yValues[trim];
|
||||
if (pointX >= xValues[numValues - 1]) return yValues[trim];
|
||||
|
||||
auto i = 0;
|
||||
if (pointX <= xValues[0]) i = 0;
|
||||
@ -55,3 +61,43 @@ float CatmullSpline(float xValues[], float yValues[], int numValues, float point
|
||||
return rst;
|
||||
}
|
||||
|
||||
float LinearSpectrumInterp(const float *wave,const float *data,int n,float targetWave,int count)
|
||||
{
|
||||
|
||||
if(targetWave <= wave[0])
|
||||
{
|
||||
// Serial.printf("count: %d \n",count);
|
||||
// Serial.printf("targetWave: %f \n",targetWave);
|
||||
// Serial.printf("wave: %f \n",wave[0]);
|
||||
return data[count];
|
||||
}
|
||||
|
||||
if(targetWave >= wave[n-1])
|
||||
{
|
||||
// Serial.printf("count: %d \n",count);
|
||||
// Serial.printf("targetWave: %f \n",targetWave);
|
||||
// Serial.printf("wave: %f \n",wave[n-1]);
|
||||
return data[count];
|
||||
}
|
||||
|
||||
|
||||
int left = 0;
|
||||
int right = n - 1;
|
||||
|
||||
|
||||
while(right - left > 1)
|
||||
{
|
||||
int mid = (left + right) >> 1;
|
||||
|
||||
if(wave[mid] > targetWave)
|
||||
right = mid;
|
||||
else
|
||||
left = mid;
|
||||
|
||||
}
|
||||
|
||||
|
||||
float t = (targetWave - wave[left]) / (wave[right] - wave[left]);
|
||||
|
||||
return data[left] + t * (data[right] - data[left]);
|
||||
}
|
||||
@ -2,8 +2,8 @@
|
||||
#define CASTUMULLSPLINE_H
|
||||
|
||||
#include <Arduino.h>
|
||||
float CatmullSpline(float xValues[], float yValues[], int numValues, float pointX, bool trim = true);
|
||||
|
||||
float CatmullSpline(float *xValues, float *yValues, int numValues, float pointX, int trim);
|
||||
float LinearSpectrumInterp(const float *wave,const float *data,int n,float targetWave,int count);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@ -17,34 +17,34 @@ DallasTemperature DS18b20(&oneWire);
|
||||
int temp_number;
|
||||
|
||||
|
||||
uint8_t *p[8] = {sensoraddr[0],sensoraddr[1],sensoraddr[2],sensoraddr[3],sensoraddr[4],sensoraddr[5],sensoraddr[6],sensoraddr[7]};
|
||||
// uint8_t *p[8] = {sensoraddr[0],sensoraddr[1],sensoraddr[2],sensoraddr[3],sensoraddr[4],sensoraddr[5],sensoraddr[6],sensoraddr[7]};
|
||||
|
||||
//冒泡排序 将温度地址 DeviceAddress sensoraddr[30]; 从小到大排序
|
||||
void bubble_sort(DeviceAddress *addr,int n)
|
||||
{
|
||||
uint64_t a1 ,a2;
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
for(uint8_t b = 0 ; b<8;b++)
|
||||
{
|
||||
a1 += addr[i][b];
|
||||
}
|
||||
// void bubble_sort(DeviceAddress *addr,int n)
|
||||
// {
|
||||
// uint64_t a1 ,a2;
|
||||
// for (int i = 0; i < n; i++)
|
||||
// {
|
||||
// for(uint8_t b = 0 ; b<8;b++)
|
||||
// {
|
||||
// a1 += addr[i][b];
|
||||
// }
|
||||
|
||||
for (int j = 0; j < n-i-1; j++)
|
||||
{
|
||||
for(uint8_t c = 0 ; c<8;c++)
|
||||
{
|
||||
a2 += addr[j][c];
|
||||
}
|
||||
if (a1 > a2)
|
||||
{
|
||||
uint8_t *temp = p[i];
|
||||
p[i] = p[j];
|
||||
p[j] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// for (int j = 0; j < n-i-1; j++)
|
||||
// {
|
||||
// for(uint8_t c = 0 ; c<8;c++)
|
||||
// {
|
||||
// a2 += addr[j][c];
|
||||
// }
|
||||
// if (a1 > a2)
|
||||
// {
|
||||
// uint8_t *temp = p[i];
|
||||
// p[i] = p[j];
|
||||
// p[j] = temp;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
uint8_t DS18b20_init()
|
||||
@ -65,17 +65,18 @@ uint8_t DS18b20_init()
|
||||
}
|
||||
i++;
|
||||
}
|
||||
write_log(log_path,"ds18b20 has" + String(temp_number),10);
|
||||
write_log(log_path,"ds18b20 has" + String(temp_number),20);
|
||||
for(size_t i = 0; i < temp_number; i++)
|
||||
{
|
||||
DS18b20.getAddress(sensoraddr[i],i);
|
||||
}
|
||||
bubble_sort(sensoraddr,temp_number);
|
||||
// bubble_sort(sensoraddr,temp_number);
|
||||
return temp_number;
|
||||
}
|
||||
|
||||
|
||||
//温度监测
|
||||
float temp_last[8] = {25,25,25,25,25,25,25,25};
|
||||
void getall_temp(float *temp)
|
||||
{
|
||||
DS18b20.requestTemperatures(); // Send the command to get temperatures
|
||||
@ -83,7 +84,7 @@ void getall_temp(float *temp)
|
||||
|
||||
for(int8_t i =0 ;i<temp_number;i++)
|
||||
{
|
||||
temp[i] = DS18b20.getTempC(p[i]);
|
||||
temp[i] = DS18b20.getTempC(sensoraddr[i]);
|
||||
uint32_t n = 0;
|
||||
while(temp[i] < -110)
|
||||
{
|
||||
@ -91,14 +92,24 @@ void getall_temp(float *temp)
|
||||
// temp[i] = DS18b20.getTempC(p[i]);
|
||||
temp[i] = getone_temp(i);
|
||||
n++;
|
||||
if (n>40)
|
||||
if (n>5)
|
||||
{
|
||||
write_log(log_path,"ds18b20 get temperature failed",10);
|
||||
// return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (temp[i] < -110)
|
||||
{
|
||||
temp[i] = temp_last[i];
|
||||
write_log(log_path,"ds18b20 get temperature failed, use last temperature",10);
|
||||
}
|
||||
else
|
||||
{
|
||||
temp_last[i] = temp[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// write_log(log_path,"get temperatures ok",10);
|
||||
}
|
||||
@ -107,7 +118,7 @@ float getone_temp(uint8_t address)
|
||||
{
|
||||
float temp;
|
||||
DS18b20.requestTemperatures(); // Send the command to get temperatures
|
||||
temp = DS18b20.getTempC(p[address]);
|
||||
temp = DS18b20.getTempC(sensoraddr[address]);
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
@ -273,7 +273,7 @@ int SensorIS11::OptSnenser(int persent)
|
||||
{
|
||||
if (maxvaluenow > maxvalue)
|
||||
{
|
||||
shutternow = shutternow *0.7;
|
||||
shutternow = shutternow *0.7 - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -285,11 +285,10 @@ int SensorIS11::OptSnenser(int persent)
|
||||
shutternow = maxtime;
|
||||
break;
|
||||
}
|
||||
|
||||
GetOneDate(shutternow);
|
||||
maxvaluenow = Getmaxvalue(DATABUFF, SensorInfo.BandNum);
|
||||
#ifdef ARDUINO
|
||||
|
||||
#endif
|
||||
numberoftry++;
|
||||
if (numberoftry > 200)
|
||||
{
|
||||
@ -303,9 +302,9 @@ int SensorIS11::OptSnenser(int persent)
|
||||
}
|
||||
vTaskDelay(1);
|
||||
}
|
||||
#ifdef ARDUINO
|
||||
// #ifdef ARDUINO
|
||||
write_log(log_path,"zi dong value:"+String(shutternow),10);
|
||||
#endif
|
||||
// #endif
|
||||
if (shutternow<0)
|
||||
{
|
||||
shutternow=maxtime;
|
||||
@ -511,92 +510,203 @@ void SensorIS11::TakeOneJob1(bool dingbing)
|
||||
write_log(log_path,"take one job end.",20);
|
||||
}
|
||||
|
||||
// void SensorIS11::TakeOneJob()
|
||||
// {
|
||||
// index++;
|
||||
// ds1302_date.getDateTime(&sys_time);
|
||||
// String time = String(sys_time.year) +"."+ String(sys_time.month) +"."+ String(sys_time.day)+" "+String(sys_time.hour)+":"+String(sys_time.minute)+":"+String(sys_time.second);
|
||||
// write_log(log_path,time + " start take one job",10);
|
||||
// SensorInfo.BandNum = 2048;
|
||||
// work_progress = 0 ;
|
||||
// float temp[8];
|
||||
// getall_temp(temp);
|
||||
// //opt_up opt_down dark_up dn_up dn_down dark_down
|
||||
// // write_log(log_path,"start take one jon",20);
|
||||
// // write_log(log_path,"start",10);
|
||||
|
||||
// //1 opt_up
|
||||
// #if SHUTTER_TYPE == 1
|
||||
// servo_direction(1);
|
||||
// SetShutter(2);
|
||||
// #elif SHUTTER_TYPE == 2
|
||||
// shutter_up();
|
||||
// #endif
|
||||
|
||||
// shutterup=OptSnenser(70);
|
||||
// shutterdown = shutterup;
|
||||
|
||||
|
||||
// #if SHUTTER_TYPE == 1
|
||||
// SetShutter(1);
|
||||
// #elif SHUTTER_TYPE == 2
|
||||
// shutter_off();
|
||||
// #endif
|
||||
// work_progress = 30;
|
||||
|
||||
// //2 dark
|
||||
// //dark_up
|
||||
// #if SHUTTER_TYPE == 1
|
||||
// SetShutter(1);
|
||||
// #elif SHUTTER_TYPE == 2
|
||||
// shutter_up();
|
||||
// #endif
|
||||
|
||||
// GetOneDate(shutterup);
|
||||
// for (int i = 0; i < SensorInfo.BandNum;i++)
|
||||
// {
|
||||
// IS11_datastruct_dark_up.data[i] = DATABUFF[i];
|
||||
// IS11_datastruct_dark_down.data[i] = DATABUFF[i];
|
||||
// }
|
||||
// IS11_datastruct_dark_up.type = 0;
|
||||
// IS11_datastruct_dark_up.direction = 2;
|
||||
// IS11_datastruct_dark_up.tuigan_stat = get_tuigan_status();
|
||||
// IS11_datastruct_dark_up.year = sys_time.year;
|
||||
// IS11_datastruct_dark_up.month = sys_time.month;
|
||||
// IS11_datastruct_dark_up.day = sys_time.day;
|
||||
// IS11_datastruct_dark_up.hour = sys_time.hour;
|
||||
// IS11_datastruct_dark_up.minute = sys_time.minute;
|
||||
// IS11_datastruct_dark_up.second = sys_time.second;
|
||||
// IS11_datastruct_dark_up.shutter_time = shutterup;
|
||||
// IS11_datastruct_dark_up.index = index;
|
||||
// memcpy(IS11_datastruct_dark_up.temprature,temp,8*sizeof(float));
|
||||
|
||||
// // dark_down
|
||||
// IS11_datastruct_dark_down.type = 0;
|
||||
// IS11_datastruct_dark_down.direction = 3;
|
||||
// IS11_datastruct_dark_down.tuigan_stat = get_tuigan_status();
|
||||
// IS11_datastruct_dark_down.year = sys_time.year;
|
||||
// IS11_datastruct_dark_down.month = sys_time.month;
|
||||
// IS11_datastruct_dark_down.day = sys_time.day;
|
||||
// IS11_datastruct_dark_down.hour = sys_time.hour;
|
||||
// IS11_datastruct_dark_down.minute = sys_time.minute;
|
||||
// IS11_datastruct_dark_down.second = sys_time.second;
|
||||
// IS11_datastruct_dark_down.shutter_time = shutterdown;
|
||||
// IS11_datastruct_dark_down.index = index;
|
||||
// memcpy(IS11_datastruct_dark_down.temprature,temp,8*sizeof(float));
|
||||
|
||||
// work_progress = 45;
|
||||
|
||||
// //3 dn_up
|
||||
// #if SHUTTER_TYPE == 1
|
||||
// SetShutter(2);
|
||||
// GetOneDate(shutterup);
|
||||
// SetShutter(1);
|
||||
// #elif SHUTTER_TYPE == 2
|
||||
// shutter_up();
|
||||
// GetOneDate(shutterup);
|
||||
// shutter_off();
|
||||
// #endif
|
||||
|
||||
// for (int i = 0; i < SensorInfo.BandNum;i++)
|
||||
// {
|
||||
// IS11_datastruct_up.data[i] = DATABUFF[i];
|
||||
// }
|
||||
// IS11_datastruct_up.type = 0;
|
||||
// IS11_datastruct_up.direction = 0;
|
||||
// IS11_datastruct_up.tuigan_stat = get_tuigan_status();
|
||||
// IS11_datastruct_up.year = sys_time.year;
|
||||
// IS11_datastruct_up.month = sys_time.month;
|
||||
// IS11_datastruct_up.day = sys_time.day;
|
||||
// IS11_datastruct_up.hour = sys_time.hour;
|
||||
// IS11_datastruct_up.minute = sys_time.minute;
|
||||
// IS11_datastruct_up.second = sys_time.second;
|
||||
// IS11_datastruct_up.shutter_time = shutterup;
|
||||
// IS11_datastruct_up.index = index;
|
||||
// memcpy(IS11_datastruct_up.temprature,temp,8*sizeof(float));
|
||||
// work_progress = 60;
|
||||
|
||||
// //4 dn_down
|
||||
|
||||
// #if SHUTTER_TYPE == 1
|
||||
// servo_direction(0);
|
||||
// SetShutter(2);
|
||||
// GetOneDate(shutterdown);
|
||||
// SetShutter(1);
|
||||
// #elif SHUTTER_TYPE == 2
|
||||
// shutter_down();
|
||||
// GetOneDate(shutterup);
|
||||
// shutter_off();
|
||||
// #endif
|
||||
|
||||
// for (int i = 0; i < SensorInfo.BandNum;i++) {
|
||||
// IS11_datastruct_down.data[i] = DATABUFF[i];
|
||||
// }
|
||||
// IS11_datastruct_down.type = 0;
|
||||
// IS11_datastruct_down.direction = 1;
|
||||
// IS11_datastruct_down.tuigan_stat = get_tuigan_status();
|
||||
// IS11_datastruct_down.year = sys_time.year;
|
||||
// IS11_datastruct_down.month = sys_time.month;
|
||||
// IS11_datastruct_down.day = sys_time.day;
|
||||
// IS11_datastruct_down.hour = sys_time.hour;
|
||||
// IS11_datastruct_down.minute = sys_time.minute;
|
||||
// IS11_datastruct_down.second = sys_time.second;
|
||||
// IS11_datastruct_down.shutter_time = shutterdown;
|
||||
// IS11_datastruct_down.index = index;
|
||||
// memcpy(IS11_datastruct_down.temprature,temp,8*sizeof(float));
|
||||
// servo_off();
|
||||
// work_progress = 75;
|
||||
|
||||
// write_log(log_path,"start SD.",10);
|
||||
// if(!SD_MMC.exists("/guangpu_data/"+ String(sys_time.year)))
|
||||
// {
|
||||
// sdcard::Mkdir("/guangpu_data/"+ String(sys_time.year));
|
||||
// }
|
||||
// if(!SD_MMC.exists("/guangpu_data/"+ String(sys_time.year) + "/" + String(sys_time.month)))
|
||||
// {
|
||||
// sdcard::Mkdir("/guangpu_data/"+ String(sys_time.year) + "/" + String(sys_time.month));
|
||||
// }
|
||||
// if(!SD_MMC.exists("/guangpu_data/"+ String(sys_time.year) + "/" + String(sys_time.month) + "/" + String(sys_time.day)))
|
||||
// {
|
||||
// sdcard::Mkdir("/guangpu_data/"+ String(sys_time.year) + "/" + String(sys_time.month) + "/" + String(sys_time.day));
|
||||
// }
|
||||
// String path1 = "/guangpu_data/"+ String(sys_time.year) + "/" + String(sys_time.month) + "/" + String(sys_time.day);
|
||||
|
||||
// // sdcard::Mkdir(path1);
|
||||
|
||||
// String path2 = path1 + "/" + String(sys_time.hour) + "-" + String(sys_time.minute) + "-" + String(sys_time.second) + ".bin";
|
||||
// File file;
|
||||
// file = SD_MMC.open(path2,"wb");
|
||||
// file.write((uint8_t *)(&IS11_datastruct_up),sizeof(IS11_datastruct));
|
||||
// file.write((uint8_t *)(&IS11_datastruct_dark_up),sizeof(IS11_datastruct));
|
||||
// file.write((uint8_t *)(&IS11_datastruct_down),sizeof(IS11_datastruct));
|
||||
// file.write((uint8_t *)(&IS11_datastruct_dark_down),sizeof(IS11_datastruct));
|
||||
// file.flush();
|
||||
// file.close();
|
||||
// work_progress = 90;
|
||||
|
||||
|
||||
// path2 = "/system/index.bin";
|
||||
// file = SD_MMC.open(path2,"wb");
|
||||
// file.write((uint8_t *) &index,4);
|
||||
// file.flush();
|
||||
// file.close();
|
||||
|
||||
|
||||
// work_progress = 100;
|
||||
// IS11_datastruct_fanshelv.NCa = 0;
|
||||
// write_log(log_path,"take one job end.",10);
|
||||
// }
|
||||
|
||||
void SensorIS11::TakeOneJob()
|
||||
{
|
||||
index++;
|
||||
ds1302_date.getDateTime(&sys_time);
|
||||
String time = String(sys_time.year) +"."+ String(sys_time.month) +"."+ String(sys_time.day)+" "+String(sys_time.hour)+":"+String(sys_time.minute)+":"+String(sys_time.second);
|
||||
write_log(log_path," ",10);
|
||||
write_log(log_path,time + " start take one job",10);
|
||||
SensorInfo.BandNum = 2048;
|
||||
work_progress = 0 ;
|
||||
float temp[8];
|
||||
getall_temp(temp);
|
||||
//opt_up opt_down dark_up dn_up dn_down dark_down
|
||||
// write_log(log_path,"start take one jon",20);
|
||||
// write_log(log_path,"start",10);
|
||||
|
||||
//1 opt_up
|
||||
#if SHUTTER_TYPE == 1
|
||||
servo_direction(1);
|
||||
SetShutter(2);
|
||||
#elif SHUTTER_TYPE == 2
|
||||
//up_opt
|
||||
|
||||
shutter_up();
|
||||
#endif
|
||||
|
||||
shutterup = OptSnenser(70);
|
||||
shutterdown = shutterup;
|
||||
|
||||
|
||||
#if SHUTTER_TYPE == 1
|
||||
SetShutter(1);
|
||||
#elif SHUTTER_TYPE == 2
|
||||
shutter_off();
|
||||
#endif
|
||||
work_progress = 30;
|
||||
|
||||
//2 dark
|
||||
//dark_up
|
||||
#if SHUTTER_TYPE == 1
|
||||
SetShutter(1);
|
||||
#elif SHUTTER_TYPE == 2
|
||||
shutter_up();
|
||||
#endif
|
||||
|
||||
Serial.printf("up_opt shutterup = %d \n",shutterup);
|
||||
//up_dn
|
||||
GetOneDate(shutterup);
|
||||
for (int i = 0; i < SensorInfo.BandNum;i++)
|
||||
{
|
||||
IS11_datastruct_dark_up.data[i] = DATABUFF[i];
|
||||
IS11_datastruct_dark_down.data[i] = DATABUFF[i];
|
||||
}
|
||||
IS11_datastruct_dark_up.type = 0;
|
||||
IS11_datastruct_dark_up.direction = 2;
|
||||
IS11_datastruct_dark_up.tuigan_stat = get_tuigan_status();
|
||||
IS11_datastruct_dark_up.year = sys_time.year;
|
||||
IS11_datastruct_dark_up.month = sys_time.month;
|
||||
IS11_datastruct_dark_up.day = sys_time.day;
|
||||
IS11_datastruct_dark_up.hour = sys_time.hour;
|
||||
IS11_datastruct_dark_up.minute = sys_time.minute;
|
||||
IS11_datastruct_dark_up.second = sys_time.second;
|
||||
IS11_datastruct_dark_up.shutter_time = shutterup;
|
||||
IS11_datastruct_dark_up.index = index;
|
||||
memcpy(IS11_datastruct_dark_up.temprature,temp,8*sizeof(float));
|
||||
|
||||
// dark_down
|
||||
IS11_datastruct_dark_down.type = 0;
|
||||
IS11_datastruct_dark_down.direction = 3;
|
||||
IS11_datastruct_dark_down.tuigan_stat = get_tuigan_status();
|
||||
IS11_datastruct_dark_down.year = sys_time.year;
|
||||
IS11_datastruct_dark_down.month = sys_time.month;
|
||||
IS11_datastruct_dark_down.day = sys_time.day;
|
||||
IS11_datastruct_dark_down.hour = sys_time.hour;
|
||||
IS11_datastruct_dark_down.minute = sys_time.minute;
|
||||
IS11_datastruct_dark_down.second = sys_time.second;
|
||||
IS11_datastruct_dark_down.shutter_time = shutterdown;
|
||||
IS11_datastruct_dark_down.index = index;
|
||||
memcpy(IS11_datastruct_dark_down.temprature,temp,8*sizeof(float));
|
||||
|
||||
work_progress = 45;
|
||||
|
||||
//3 dn_up
|
||||
#if SHUTTER_TYPE == 1
|
||||
SetShutter(2);
|
||||
GetOneDate(shutterup);
|
||||
SetShutter(1);
|
||||
#elif SHUTTER_TYPE == 2
|
||||
shutter_up();
|
||||
GetOneDate(shutterup);
|
||||
shutter_off();
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < SensorInfo.BandNum;i++)
|
||||
{
|
||||
@ -614,24 +724,85 @@ void SensorIS11::TakeOneJob()
|
||||
IS11_datastruct_up.shutter_time = shutterup;
|
||||
IS11_datastruct_up.index = index;
|
||||
memcpy(IS11_datastruct_up.temprature,temp,8*sizeof(float));
|
||||
work_progress = 30;
|
||||
|
||||
//up_dark
|
||||
shutter_off();
|
||||
work_progress = 45;
|
||||
|
||||
GetOneDate(shutterup);
|
||||
for (int i = 0; i < SensorInfo.BandNum;i++)
|
||||
{
|
||||
IS11_datastruct_dark_up.data[i] = DATABUFF[i];
|
||||
}
|
||||
IS11_datastruct_dark_up.type = 0;
|
||||
IS11_datastruct_dark_up.direction = 2;
|
||||
IS11_datastruct_dark_up.tuigan_stat = get_tuigan_status();
|
||||
IS11_datastruct_dark_up.year = sys_time.year;
|
||||
IS11_datastruct_dark_up.month = sys_time.month;
|
||||
IS11_datastruct_dark_up.day = sys_time.day;
|
||||
IS11_datastruct_dark_up.hour = sys_time.hour;
|
||||
IS11_datastruct_dark_up.minute = sys_time.minute;
|
||||
IS11_datastruct_dark_up.second = sys_time.second;
|
||||
IS11_datastruct_dark_up.shutter_time = shutterup;
|
||||
IS11_datastruct_dark_up.index = index;
|
||||
memcpy(IS11_datastruct_dark_up.temprature,temp,8*sizeof(float));
|
||||
|
||||
work_progress = 60;
|
||||
|
||||
//4 dn_down
|
||||
|
||||
#if SHUTTER_TYPE == 1
|
||||
servo_direction(0);
|
||||
SetShutter(2);
|
||||
GetOneDate(shutterdown);
|
||||
SetShutter(1);
|
||||
#elif SHUTTER_TYPE == 2
|
||||
//down_opt
|
||||
shutter_down();
|
||||
GetOneDate(shutterup);
|
||||
shutter_off();
|
||||
#endif
|
||||
shutterdown = OptSnenser(70);
|
||||
Serial.printf("down_opt shutterdown = %d \n",shutterdown);
|
||||
//down_dn
|
||||
GetOneDate(shutterdown);
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool flag = SensorIS11::guangpu_bochang.is_valid;
|
||||
|
||||
if(flag)
|
||||
{
|
||||
write_log(log_path,"guangpu bochang is valid",10);
|
||||
const int numValues = SensorInfo.BandNum;
|
||||
float xValues[2048];
|
||||
float *yValues;
|
||||
|
||||
double b0 = SensorIS11::guangpu_bochang.b0;
|
||||
double b1 = SensorIS11::guangpu_bochang.b1;
|
||||
double b2 = SensorIS11::guangpu_bochang.b2;
|
||||
double b3 = SensorIS11::guangpu_bochang.b3;
|
||||
for (uint32_t i = 0; i < 2048; i++)
|
||||
{
|
||||
xValues[i] = b0 * i * i * i + b1 * i * i + b2 * i+ b3;
|
||||
IS11_datastruct_down.data[i] = DATABUFF[i];
|
||||
|
||||
}
|
||||
yValues = IS11_datastruct_down.data;
|
||||
for (int i = 0; i < SensorInfo.BandNum;i++) {
|
||||
float xValue_target = SensorInfo.a1 * i * i * i + SensorInfo.a2 * i * i + SensorInfo.a3 * i+ SensorInfo.a4;
|
||||
|
||||
IS11_datastruct_down.data[i] = LinearSpectrumInterp(xValues, yValues, numValues, xValue_target , i);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
write_log(log_path,"guangpu bochang is invalid",10);
|
||||
for (uint32_t i = 0; i < 2048; i++)
|
||||
{
|
||||
IS11_datastruct_down.data[i] = DATABUFF[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Serial.printf("down SensorInfo.BandNum = %d \n",SensorInfo.BandNum);
|
||||
// vTaskDelay(10);
|
||||
// for (int i = 0; i < SensorInfo.BandNum;i++)
|
||||
// {
|
||||
// IS11_datastruct_down.data[i] = DATABUFF[i];
|
||||
// }
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
IS11_datastruct_down.type = 0;
|
||||
IS11_datastruct_down.direction = 1;
|
||||
IS11_datastruct_down.tuigan_stat = get_tuigan_status();
|
||||
@ -644,23 +815,43 @@ void SensorIS11::TakeOneJob()
|
||||
IS11_datastruct_down.shutter_time = shutterdown;
|
||||
IS11_datastruct_down.index = index;
|
||||
memcpy(IS11_datastruct_down.temprature,temp,8*sizeof(float));
|
||||
servo_off();
|
||||
|
||||
work_progress = 75;
|
||||
//down_dark
|
||||
shutter_off();
|
||||
GetOneDate(shutterdown);
|
||||
for (int i = 0; i < SensorInfo.BandNum;i++)
|
||||
{
|
||||
IS11_datastruct_dark_down.data[i] = DATABUFF[i];
|
||||
}
|
||||
IS11_datastruct_dark_down.type = 0;
|
||||
IS11_datastruct_dark_down.direction = 3;
|
||||
IS11_datastruct_dark_down.tuigan_stat = get_tuigan_status();
|
||||
IS11_datastruct_dark_down.year = sys_time.year;
|
||||
IS11_datastruct_dark_down.month = sys_time.month;
|
||||
IS11_datastruct_dark_down.day = sys_time.day;
|
||||
IS11_datastruct_dark_down.hour = sys_time.hour;
|
||||
IS11_datastruct_dark_down.minute = sys_time.minute;
|
||||
IS11_datastruct_dark_down.second = sys_time.second;
|
||||
IS11_datastruct_dark_down.shutter_time = shutterdown;
|
||||
IS11_datastruct_dark_down.index = index;
|
||||
memcpy(IS11_datastruct_dark_down.temprature,temp,8*sizeof(float));
|
||||
|
||||
|
||||
write_log(log_path,"start SD.",10);
|
||||
if(!SD_MMC.exists("/guangpu_data/"+ String(sys_time.year)))
|
||||
if(!SD_MMC.exists("/data/"+ String(sys_time.year)))
|
||||
{
|
||||
sdcard::Mkdir("/guangpu_data/"+ String(sys_time.year));
|
||||
sdcard::Mkdir("/data/"+ String(sys_time.year));
|
||||
}
|
||||
if(!SD_MMC.exists("/guangpu_data/"+ String(sys_time.year) + "/" + String(sys_time.month)))
|
||||
if(!SD_MMC.exists("/data/"+ String(sys_time.year) + "/" + String(sys_time.month)))
|
||||
{
|
||||
sdcard::Mkdir("/guangpu_data/"+ String(sys_time.year) + "/" + String(sys_time.month));
|
||||
sdcard::Mkdir("/data/"+ String(sys_time.year) + "/" + String(sys_time.month));
|
||||
}
|
||||
if(!SD_MMC.exists("/guangpu_data/"+ String(sys_time.year) + "/" + String(sys_time.month) + "/" + String(sys_time.day)))
|
||||
if(!SD_MMC.exists("/data/"+ String(sys_time.year) + "/" + String(sys_time.month) + "/" + String(sys_time.day)))
|
||||
{
|
||||
sdcard::Mkdir("/guangpu_data/"+ String(sys_time.year) + "/" + String(sys_time.month) + "/" + String(sys_time.day));
|
||||
sdcard::Mkdir("/data/"+ String(sys_time.year) + "/" + String(sys_time.month) + "/" + String(sys_time.day));
|
||||
}
|
||||
String path1 = "/guangpu_data/"+ String(sys_time.year) + "/" + String(sys_time.month) + "/" + String(sys_time.day);
|
||||
String path1 = "/data/"+ String(sys_time.year) + "/" + String(sys_time.month) + "/" + String(sys_time.day);
|
||||
|
||||
// sdcard::Mkdir(path1);
|
||||
|
||||
@ -685,10 +876,9 @@ void SensorIS11::TakeOneJob()
|
||||
|
||||
work_progress = 100;
|
||||
IS11_datastruct_fanshelv.NCa = 0;
|
||||
shutter_down();
|
||||
write_log(log_path,"take one job end.",10);
|
||||
}
|
||||
|
||||
|
||||
SensorIS11::SensorIS11()
|
||||
{
|
||||
shutternow = 0;
|
||||
@ -817,7 +1007,7 @@ void SensorIS11::send_chongcaiyang(HardwareSerial *wb485Serial,IS11_datastruct
|
||||
uint32_t b = 0;
|
||||
while(xValue_target < xValue_stop)
|
||||
{
|
||||
IS11_datastruct_send.data[b] = CatmullSpline(xValues, yValues, numValues, xValue_target);
|
||||
IS11_datastruct_send.data[b] = LinearSpectrumInterp(xValues, yValues, numValues, xValue_target,b);
|
||||
b++;
|
||||
xValue_target += chongcaiyang_step;
|
||||
}
|
||||
@ -865,6 +1055,45 @@ void SensorIS11::send_chongcaiyang(HardwareSerial *wb485Serial,IS11_datastruct
|
||||
|
||||
|
||||
|
||||
// void SensorIS11::get_fanshelv()
|
||||
// {
|
||||
// IS11_datastruct_fanshelv.type = 0x06;
|
||||
// IS11_datastruct_fanshelv.direction = IS11_datastruct_up.direction;
|
||||
// IS11_datastruct_fanshelv.tuigan_stat = IS11_datastruct_up.tuigan_stat;
|
||||
// IS11_datastruct_fanshelv.year = IS11_datastruct_up.year;
|
||||
// IS11_datastruct_fanshelv.month = IS11_datastruct_up.month;
|
||||
// IS11_datastruct_fanshelv.day = IS11_datastruct_up.day;
|
||||
// IS11_datastruct_fanshelv.minute = IS11_datastruct_up.minute;
|
||||
// IS11_datastruct_fanshelv.hour = IS11_datastruct_up.hour;
|
||||
// IS11_datastruct_fanshelv.second = IS11_datastruct_up.second;
|
||||
// IS11_datastruct_fanshelv.NCa = IS11_datastruct_up.NCa;
|
||||
// IS11_datastruct_fanshelv.NCb = IS11_datastruct_up.NCb;
|
||||
// IS11_datastruct_fanshelv.NCc = IS11_datastruct_up.NCc;
|
||||
// // IS11_datastruct_fanshelv.NCc = 0;
|
||||
// IS11_datastruct_fanshelv.shutter_time = IS11_datastruct_up.shutter_time;
|
||||
// IS11_datastruct_fanshelv.index = IS11_datastruct_up.index;
|
||||
// for(int i = 0; i < 8;i++)
|
||||
// {
|
||||
// IS11_datastruct_fanshelv.temprature[i] = IS11_datastruct_up.temprature[i];
|
||||
// }
|
||||
// for (int i = 0; i < 2048;i++)
|
||||
// {
|
||||
// IS11_datastruct_fanshelv.data[i] = (IS11_datastruct_down.data[i] - IS11_datastruct_dark_down.data[i]) / (IS11_datastruct_up.data[i] - IS11_datastruct_dark_up.data[i]);
|
||||
// if(fanshelv_struct.shutter == 1)
|
||||
// {
|
||||
// IS11_datastruct_fanshelv.data[i] =IS11_datastruct_fanshelv.data[i]*fanshelv_struct.gain[i];
|
||||
// }
|
||||
// // IS11_datastruct_fanshelv.data[i] = IS11_datastruct_up.data[i];
|
||||
// }
|
||||
// // Serial0.println("fanshelv");
|
||||
// // Serial0.printf("fanshelv_struct.shutter = %d \n",fanshelv_struct.shutter);
|
||||
// // Serial0.printf("fanshelv_struct.data[%d] = %f\n",1,IS11_datastruct_fanshelv.data[0]);
|
||||
// // Serial0.printf("fanshelv_struct.data[%d] = %f\n",2047,IS11_datastruct_fanshelv.data[2047]);
|
||||
|
||||
// IS11_datastruct_fanshelv.NCa = 1;
|
||||
// }
|
||||
|
||||
|
||||
void SensorIS11::get_fanshelv()
|
||||
{
|
||||
IS11_datastruct_fanshelv.type = 0x06;
|
||||
@ -886,17 +1115,41 @@ void SensorIS11::get_fanshelv()
|
||||
{
|
||||
IS11_datastruct_fanshelv.temprature[i] = IS11_datastruct_up.temprature[i];
|
||||
}
|
||||
|
||||
// Serial.println("fanshelv");
|
||||
// Serial.printf("radiance_struct_up.shutter = %d \n",radiance_struct_up.shutter);
|
||||
// Serial.printf("radiance_struct_down.shutter = %d \n",radiance_struct_down.shutter);
|
||||
// Serial.printf("IS11_datastruct_up.shutter_time = %d\n",IS11_datastruct_up.shutter_time);
|
||||
// Serial.printf("IS11_datastruct_down.shutter_time = %d\n",IS11_datastruct_down.shutter_time);
|
||||
|
||||
|
||||
if(radiance_struct_up.shutter != 1)
|
||||
{
|
||||
for (int i = 0; i < 2048;i++)
|
||||
{
|
||||
IS11_datastruct_fanshelv.data[i] = (IS11_datastruct_down.data[i] - IS11_datastruct_dark_down.data[i]) / (IS11_datastruct_up.data[i] - IS11_datastruct_dark_up.data[i]);
|
||||
if(fanshelv_struct.shutter == 1)
|
||||
float rad_down = (IS11_datastruct_down.data[i]- IS11_datastruct_dark_down.data[i]) / IS11_datastruct_down.shutter_time *radiance_struct_down.shutter *radiance_struct_down.gain[i] ;
|
||||
float rad_up = (IS11_datastruct_up.data[i] - IS11_datastruct_dark_up.data[i]) / IS11_datastruct_up.shutter_time *radiance_struct_up.shutter *radiance_struct_up.gain[i];
|
||||
IS11_datastruct_fanshelv.data[i] = rad_down / rad_up * PI;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
IS11_datastruct_fanshelv.data[i] =IS11_datastruct_fanshelv.data[i]*fanshelv_struct.gain[i];
|
||||
for (int i = 0; i < 2048;i++)
|
||||
{
|
||||
IS11_datastruct_fanshelv.data[i] = IS11_datastruct_down.data[i];
|
||||
}
|
||||
write_log(log_path,"no califile ",10);
|
||||
}
|
||||
|
||||
// IS11_datastruct_fanshelv.data[i] = IS11_datastruct_up.data[i];
|
||||
|
||||
|
||||
/////////////
|
||||
// Serial0.println("fanshelv");
|
||||
Serial0.printf("fanshelv_struct.data[%d] = %f\n",1,IS11_datastruct_fanshelv.data[0]);
|
||||
Serial0.printf("fanshelv_struct.data[%d] = %f\n",2047,IS11_datastruct_fanshelv.data[2047]);
|
||||
// Serial0.printf("fanshelv_struct.shutter = %d \n",fanshelv_struct.shutter);
|
||||
// Serial0.printf("fanshelv_struct.data[%d] = %f\n",1,IS11_datastruct_fanshelv.data[0]);
|
||||
// Serial0.printf("fanshelv_struct.data[%d] = %f\n",2047,IS11_datastruct_fanshelv.data[2047]);
|
||||
|
||||
IS11_datastruct_fanshelv.NCa = 1;
|
||||
}
|
||||
|
||||
@ -970,8 +1223,8 @@ void SensorIS11::calculation(float bochang1,float bochang2)
|
||||
{
|
||||
xValues[i] = SensorInfo.a1 * i * i * i + SensorInfo.a2 * i * i + SensorInfo.a3 * i+ SensorInfo.a4;
|
||||
}
|
||||
float R1 = CatmullSpline(xValues, yValues, numValues, bochang1);
|
||||
float R2 = CatmullSpline(xValues, yValues, numValues, bochang2);
|
||||
float R1 = LinearSpectrumInterp(xValues, yValues, numValues, bochang1,0);
|
||||
float R2 = LinearSpectrumInterp(xValues, yValues, numValues, bochang2,0);
|
||||
|
||||
calculation_value = (R1 - R2) / (R1 + R2);
|
||||
}
|
||||
@ -1107,17 +1360,25 @@ void SensorIS11::advanced_mode(u_int32_t direction,u_int32_t shutter_time,u_int3
|
||||
switch (direction)
|
||||
{
|
||||
case 0:
|
||||
servo_direction(1);
|
||||
SetShutter(2);
|
||||
// servo_direction(1);
|
||||
// SetShutter(2);
|
||||
|
||||
shutter_up();
|
||||
IS11_datastructure_avn = &IS11_datastruct_up;
|
||||
|
||||
|
||||
// shutter_down();
|
||||
// IS11_datastructure_avn = &IS11_datastruct_up;
|
||||
break;
|
||||
case 1:
|
||||
servo_direction(0);
|
||||
SetShutter(2);
|
||||
// servo_direction(0);
|
||||
// SetShutter(2);
|
||||
shutter_down();
|
||||
IS11_datastructure_avn = &IS11_datastruct_down;
|
||||
break;
|
||||
case 2:
|
||||
SetShutter(1);
|
||||
// SetShutter(1);
|
||||
shutter_off();
|
||||
IS11_datastructure_avn = &IS11_datastruct_dark_up;
|
||||
break;
|
||||
default:
|
||||
@ -1155,9 +1416,10 @@ void SensorIS11::advanced_mode(u_int32_t direction,u_int32_t shutter_time,u_int3
|
||||
{
|
||||
|
||||
// write_log(log_path,"remove_dark",10);
|
||||
SetShutter(1);
|
||||
// SetShutter(1);
|
||||
shutter_off();
|
||||
GetOneDate(shutter_time);
|
||||
SetShutter(2);
|
||||
// SetShutter(2);
|
||||
for (int i = 0; i < SensorInfo.BandNum;i++)
|
||||
{
|
||||
// if (i==1000)
|
||||
@ -1180,16 +1442,209 @@ void SensorIS11::advanced_mode(u_int32_t direction,u_int32_t shutter_time,u_int3
|
||||
aa--;
|
||||
caiji_times++;
|
||||
}
|
||||
|
||||
for (int i = 0; i < SensorInfo.BandNum;i++)
|
||||
{
|
||||
IS11_datastructure_avn->data[i] = IS11_datastructure_avn->data[i] / collect_times;
|
||||
}
|
||||
SetShutter(1);
|
||||
servo_off();
|
||||
|
||||
bool flag = SensorIS11::guangpu_bochang.is_valid;
|
||||
|
||||
if(direction == 1 && flag)
|
||||
{
|
||||
|
||||
// "a0": -1.37016491e-9,
|
||||
// "a1": -0.000052,
|
||||
// "a2": 0.440364,
|
||||
// "a3": 348.4284,
|
||||
|
||||
// "b0": -1.2597071e-9,
|
||||
// "b1": -0.000053,
|
||||
// "b2": 0.440609,
|
||||
// "b3": 348.3989
|
||||
|
||||
const int numValues = SensorInfo.BandNum;
|
||||
float xValues[2048];
|
||||
float *yValues;
|
||||
|
||||
double b0 = SensorIS11::guangpu_bochang.b0;
|
||||
double b1 = SensorIS11::guangpu_bochang.b1;
|
||||
double b2 = SensorIS11::guangpu_bochang.b2;
|
||||
double b3 = SensorIS11::guangpu_bochang.b3;
|
||||
write_log(log_path,"bochang:"+String(b0,4)+" "+String(b1,4)+" "+String(b2,4)+" "+String(b3,4),10);
|
||||
yValues = IS11_datastructure_avn->data;
|
||||
for (uint32_t i = 0; i < 2048; i++)
|
||||
{
|
||||
xValues[i] = b0 * i * i * i + b1 * i * i + b2 * i+ b3;
|
||||
|
||||
// yValues[i] = IS11_datastructure_avn->data[i];
|
||||
}
|
||||
vTaskDelay(1);
|
||||
for (uint32_t i = 0; i < 2048;i++)
|
||||
{
|
||||
float x = i;
|
||||
float xValue_target = SensorInfo.a1 * x * x * x + SensorInfo.a2 * x * x + SensorInfo.a3 * x+ SensorInfo.a4;
|
||||
|
||||
IS11_datastructure_avn->data[i] = LinearSpectrumInterp(xValues, yValues, 2048, xValue_target, i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IS11_datastruct_fanshelv.NCa = 0;
|
||||
work_progress = 100;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// void SensorIS11::advanced_mode(u_int32_t direction,u_int32_t shutter_time,u_int32_t collect_times,u_int32_t remove_dark)
|
||||
// {
|
||||
|
||||
// work_progress = 0;
|
||||
// struct IS11_datastruct *IS11_datastructure_avn = nullptr;
|
||||
// switch (direction)
|
||||
// {
|
||||
// case 0:
|
||||
// // servo_direction(1);
|
||||
// // SetShutter(2);
|
||||
|
||||
// // shutter_up();
|
||||
// // IS11_datastructure_avn = &IS11_datastruct_up;
|
||||
|
||||
// work_progress = 100;
|
||||
// return;
|
||||
// // shutter_down();
|
||||
// // IS11_datastructure_avn = &IS11_datastruct_up;
|
||||
// break;
|
||||
// case 1:
|
||||
// // servo_direction(0);
|
||||
// // SetShutter(2);
|
||||
// shutter_down();
|
||||
// IS11_datastructure_avn = &IS11_datastruct_down;
|
||||
// break;
|
||||
// case 2:
|
||||
// // SetShutter(1);
|
||||
// shutter_off();
|
||||
// IS11_datastructure_avn = &IS11_datastruct_dark_up;
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
|
||||
// int aa = collect_times;
|
||||
// uint32_t caiji_times = 0;
|
||||
// memset(IS11_datastructure_avn->data,0,8192);
|
||||
// getall_temp(IS11_datastructure_avn->temprature);
|
||||
// ds1302_date.getDateTime(&sys_time);
|
||||
// IS11_datastructure_avn->year = sys_time.year;
|
||||
// IS11_datastructure_avn->month = sys_time.month;
|
||||
// IS11_datastructure_avn->day = sys_time.day;
|
||||
// IS11_datastructure_avn->hour = sys_time.hour;
|
||||
// IS11_datastructure_avn->minute = sys_time.minute;
|
||||
// IS11_datastructure_avn->second = sys_time.second;
|
||||
|
||||
// while(aa > 0)
|
||||
// {
|
||||
// work_progress = (caiji_times * 100) / (collect_times * 2) ;
|
||||
|
||||
// shutter_down();
|
||||
// GetOneDate(shutter_time);
|
||||
// for (int i = 0; i < SensorInfo.BandNum;i++)
|
||||
// {
|
||||
// IS11_datastructure_avn->data[i] += DATABUFF[i];
|
||||
// IS11_datastruct_up.data[i] = DATABUFF[i];
|
||||
// }
|
||||
// IS11_datastructure_avn->type = 0;
|
||||
// IS11_datastructure_avn->direction = direction;
|
||||
// IS11_datastructure_avn->tuigan_stat = get_tuigan_status();
|
||||
// IS11_datastructure_avn->shutter_time = shutter_time;
|
||||
// IS11_datastructure_avn->index = index;
|
||||
|
||||
// if(remove_dark == 1 && direction != 2)
|
||||
// {
|
||||
|
||||
// // write_log(log_path,"remove_dark",10);
|
||||
// // SetShutter(1);
|
||||
// shutter_off();
|
||||
// GetOneDate(shutter_time);
|
||||
// // SetShutter(2);
|
||||
// for (int i = 0; i < SensorInfo.BandNum;i++)
|
||||
// {
|
||||
// // if (i==1000)
|
||||
// // {
|
||||
// // write_log(log_path,"or data:"+String(IS11_datastructure_avn->data[i])+ " darkdata:"+String(DATABUFF[i]),10);
|
||||
|
||||
// // /* code */
|
||||
// // }
|
||||
// IS11_datastructure_avn->data[i] -= DATABUFF[i];
|
||||
// IS11_datastruct_up.data[i] -= DATABUFF[i];
|
||||
// IS11_datastruct_dark_up.data[i] = DATABUFF[i];
|
||||
// }
|
||||
|
||||
// IS11_datastruct_dark_up.type = 0;
|
||||
// IS11_datastruct_dark_up.direction = 2;
|
||||
// IS11_datastruct_dark_up.tuigan_stat = get_tuigan_status();
|
||||
// IS11_datastruct_dark_up.shutter_time = shutter_time;
|
||||
// IS11_datastruct_dark_up.index = index;
|
||||
// // getall_temp(IS11_datastruct_dark_up.temprature);
|
||||
// }
|
||||
// aa--;
|
||||
// caiji_times++;
|
||||
// }
|
||||
|
||||
// for (int i = 0; i < SensorInfo.BandNum;i++)
|
||||
// {
|
||||
// IS11_datastructure_avn->data[i] = IS11_datastructure_avn->data[i] / collect_times;
|
||||
// }
|
||||
|
||||
|
||||
// if(direction == 1)
|
||||
// {
|
||||
|
||||
// // "a0": -1.37016491e-9,
|
||||
// // "a1": -0.000052,
|
||||
// // "a2": 0.440364,
|
||||
// // "a3": 348.4284,
|
||||
|
||||
// // "b0": -1.2597071e-9,
|
||||
// // "b1": -0.000053,
|
||||
// // "b2": 0.440609,
|
||||
// // "b3": 348.3989
|
||||
|
||||
// const int numValues = SensorInfo.BandNum;
|
||||
// float xValues[2048];
|
||||
// float *yValues;
|
||||
|
||||
// double b0 = SensorIS11::guangpu_bochang.b0;
|
||||
// double b1 = SensorIS11::guangpu_bochang.b1;
|
||||
// double b2 = SensorIS11::guangpu_bochang.b2;
|
||||
// double b3 = SensorIS11::guangpu_bochang.b3;
|
||||
// write_log(log_path,"bochang:"+String(b0,4)+" "+String(b1,4)+" "+String(b2,4)+" "+String(b3,4),10);
|
||||
// for (uint32_t i = 0; i < 2048; i++)
|
||||
// {
|
||||
// float x = i;
|
||||
// xValues[i] = b0 * x * x * x + b1 * x * x + b2 * x+ b3;
|
||||
|
||||
// }
|
||||
// yValues = IS11_datastructure_avn->data;
|
||||
// vTaskDelay(1);
|
||||
// for (uint32_t a = 0; a < 2048;a++)
|
||||
// {
|
||||
// float i = a;
|
||||
// double xValue_target = SensorInfo.a1 * i * i * i + SensorInfo.a2 * i * i + SensorInfo.a3 * i+ SensorInfo.a4;
|
||||
|
||||
// IS11_datastructure_avn->data[a] = LinearSpectrumInterp(xValues, yValues, 2048, xValue_target, a);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// IS11_datastruct_fanshelv.NCa = 0;
|
||||
// work_progress = 100;
|
||||
// }
|
||||
|
||||
/*
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
opt
|
||||
@ -1202,14 +1657,17 @@ void SensorIS11::opt(u_int32_t direction)
|
||||
{
|
||||
case 0:
|
||||
// servo_direction(1);
|
||||
SetShutter(2);
|
||||
// SetShutter(2);
|
||||
shutter_up();
|
||||
break;
|
||||
case 1:
|
||||
// servo_direction(0);
|
||||
SetShutter(2);
|
||||
// SetShutter(2);
|
||||
shutter_down();
|
||||
break;
|
||||
case 2:
|
||||
SetShutter(1);
|
||||
// SetShutter(1);
|
||||
shutter_off();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -1217,7 +1675,7 @@ void SensorIS11::opt(u_int32_t direction)
|
||||
work_progress = 50;
|
||||
dingbiao_shutter = OptSnenser(70);
|
||||
work_progress = 100;
|
||||
SetShutter(1);
|
||||
// SetShutter(1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -22,6 +22,21 @@ extern struct IS11_datastruct IS11_datastruct_down;
|
||||
extern struct IS11_datastruct IS11_datastruct_dark_up;
|
||||
extern struct IS11_datastruct IS11_datastruct_dark_down;
|
||||
|
||||
struct bochang_struct {
|
||||
bool is_valid;
|
||||
|
||||
double a0;
|
||||
double a1;
|
||||
double a2;
|
||||
double a3;
|
||||
|
||||
double b0;
|
||||
double b1;
|
||||
double b2;
|
||||
double b3;
|
||||
};
|
||||
|
||||
|
||||
class SensorIS11 {
|
||||
public:
|
||||
SensorIS11();
|
||||
@ -79,6 +94,7 @@ public:
|
||||
|
||||
u_char *DataRetrun;
|
||||
|
||||
bochang_struct guangpu_bochang;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ struct STRSensorInfo
|
||||
//double *wavelenth;
|
||||
bool isSensorInit;
|
||||
String serialnumber;
|
||||
float a1,a2,a3,a4;
|
||||
double a1,a2,a3,a4;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -6,34 +6,40 @@ GSMMannger *gsmmanger;
|
||||
PubSubClient *mqtt_client; // 修改为指针类型,避免使用未初始化的对象
|
||||
const char* mqtt_server = "tower.iris-rs.cn"; // 可替换为你自己的Broker地址
|
||||
const uint32_t mqtt_port = 40000;
|
||||
const char *mqtt_client_id = "gaoguangpu_001";
|
||||
// const char *mqtt_client_id = "gaoguangpu_001";
|
||||
const char *mqtt_username = "remotecontroler";
|
||||
const char *mqtt_password = "irishk";
|
||||
// const char *publish_topic = "gaoguangpu/return/IS11_id";
|
||||
// const char *subscribe_topic = "gaoguangpu/command/IS11_id";
|
||||
// SpectraSenorV2/command
|
||||
// SpectraSenorV2/return
|
||||
String str_publish_topic ="SpectraSenorV2/command/";
|
||||
String str_subscribe_topic = "SpectraSenorV2/return/";
|
||||
String str_mqtt_client_id = "";
|
||||
String str_publish_topic ="SpectraSenorV2/return/";
|
||||
String str_subscribe_topic = "SpectraSenorV2/command/";
|
||||
EventGroupHandle_t http_event_group;
|
||||
|
||||
void callback(char* topic, byte* payload, unsigned int length) {
|
||||
// Serial0.print("Message arrived on topic: ");
|
||||
// Serial0.print(topic);
|
||||
// Serial0.print(". Message: ");
|
||||
// Serial.print("Message arrived on topic: ");
|
||||
// Serial.print(topic);
|
||||
// Serial.print("\nMessage: ");
|
||||
// for (int i = 0; i < length; i++) {
|
||||
// Serial0.print((char)payload[i]);
|
||||
// Serial.print((char)payload[i]);
|
||||
// }
|
||||
// Serial0.println();
|
||||
// Serial.println();
|
||||
|
||||
|
||||
uint8_t read_buff[1024 * 10];
|
||||
memcpy(read_buff,payload,length);
|
||||
uint32_t data_length = length;
|
||||
data_length = IRIS_Cut_Befor_Header(read_buff,data_length);
|
||||
|
||||
if (data_length > 0)
|
||||
{
|
||||
receive_command_unpack(read_buff,length,2);
|
||||
}
|
||||
|
||||
// mqtt_write(read_buff,length);
|
||||
|
||||
}
|
||||
|
||||
void reconnect() {
|
||||
@ -42,17 +48,17 @@ void reconnect() {
|
||||
// 重新连接MQTT
|
||||
while (!mqtt_client->connected())
|
||||
{
|
||||
// Serial0.print("Attempting MQTT connection...");
|
||||
// Serial.print("Attempting MQTT connection...");
|
||||
vTaskDelay(10);
|
||||
if (mqtt_client->connect(mqtt_client_id))
|
||||
if (mqtt_client->connect(str_mqtt_client_id.c_str()))
|
||||
{
|
||||
// Serial0.println("connected");
|
||||
// Serial.println("connected");
|
||||
mqtt_client->subscribe(subscribe_topic);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Serial0.print("failed, rc=");
|
||||
// Serial0.print(mqtt_client->state());
|
||||
// Serial.print("failed, rc=");
|
||||
// Serial.print(mqtt_client->state());
|
||||
}
|
||||
// vTaskDelay(100);
|
||||
}
|
||||
@ -62,9 +68,7 @@ void gsmm_mqtt_loop_task(void *pvParameters)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
if (!mqtt_client->connected()) {
|
||||
reconnect();
|
||||
}
|
||||
|
||||
|
||||
EventBits_t uxBits = xEventGroupGetBits(http_event_group);
|
||||
if (uxBits & mqtt_stop_bit)
|
||||
@ -75,6 +79,9 @@ void gsmm_mqtt_loop_task(void *pvParameters)
|
||||
xEventGroupClearBits(http_event_group, mqtt_stop_bit);
|
||||
}
|
||||
|
||||
if (!mqtt_client->connected()) {
|
||||
reconnect();
|
||||
}
|
||||
mqtt_client->loop();
|
||||
gsmmanger->loop();
|
||||
|
||||
@ -97,15 +104,22 @@ UpDateClassByme ggp_UpDate(http);
|
||||
// String str_subscribe_topic = "SpectraSenorV2/return/";
|
||||
void gsmm_mqtt_init(String sensor_id)
|
||||
{
|
||||
str_mqtt_client_id = sensor_id;
|
||||
str_publish_topic = str_publish_topic + sensor_id;
|
||||
str_subscribe_topic = str_subscribe_topic + sensor_id;
|
||||
|
||||
Serial.println("gsmm_mqtt_init");
|
||||
Serial.println("mqtt_client_id: " + str_mqtt_client_id);
|
||||
Serial.println("publish_topic: " + str_publish_topic);
|
||||
Serial.println("subscribe_topic: " + str_subscribe_topic);
|
||||
http_event_group = xEventGroupCreate();
|
||||
// if(http_event_group == NULL)
|
||||
// {
|
||||
// Serial0.println("Failed to create event group");
|
||||
// //Serial.println("Failed to create event group");
|
||||
// }
|
||||
gsmmanger = new GSMMannger(SIMUARTNUMER, SIMUART_RX, SIMUART_TX);
|
||||
mqtt_client = new PubSubClient(*gsmmanger->client); // 初始化 PubSubClient;
|
||||
mqtt_client->setBufferSize(1024);
|
||||
mqtt_client->setServer(mqtt_server, mqtt_port);
|
||||
mqtt_client->setCallback(callback);
|
||||
|
||||
@ -119,12 +133,22 @@ void mqtt_write(uint8_t *data , uint32_t lenth)
|
||||
{
|
||||
const char *publish_topic = str_publish_topic.c_str();
|
||||
bool messageSent = false;
|
||||
// String str_publish_topic =publish_topic + '/' + ;
|
||||
do
|
||||
|
||||
uint32_t cout = 5000;
|
||||
while (cout --)
|
||||
{
|
||||
if(mqtt_client->connected())
|
||||
{
|
||||
messageSent = mqtt_client->publish(publish_topic,data,lenth);
|
||||
if(!messageSent) vTaskDelay(1);
|
||||
} while (!messageSent);
|
||||
}
|
||||
if(messageSent)
|
||||
{
|
||||
write_log(log_path,"mqtt send message successfully",10);
|
||||
return;
|
||||
}
|
||||
vTaskDelay(1);
|
||||
}
|
||||
write_log(log_path,"mqtt send message failed",10);
|
||||
}
|
||||
|
||||
bool UpdateData(String path,uint8_t *data, size_t lenth, String Contenttype )
|
||||
@ -149,6 +173,7 @@ bool UpdateData(String path,uint8_t *data, size_t lenth, String Contenttype )
|
||||
http->sendHeader(HTTP_HEADER_CONTENT_LENGTH, lenth);
|
||||
http->endRequest();
|
||||
int err = http->write((const byte *)data, lenth);
|
||||
// int err = 0;
|
||||
uint32_t len = lenth;
|
||||
while(len)
|
||||
{
|
||||
@ -167,14 +192,14 @@ bool UpdateData(String path,uint8_t *data, size_t lenth, String Contenttype )
|
||||
|
||||
|
||||
vTaskDelay(1000*5);
|
||||
Serial0.print("send date size");
|
||||
Serial0.println(err);
|
||||
//Serial.print("send date size");
|
||||
//Serial.println(err);
|
||||
|
||||
|
||||
int status = http->responseStatusCode();
|
||||
int length = http->contentLength();
|
||||
String body = http->responseBody();
|
||||
Serial0.println("body:"+body);
|
||||
//Serial.println("body:"+body);
|
||||
|
||||
http->stop();
|
||||
|
||||
@ -362,38 +387,38 @@ void Update_firmware(Stream &updateSource, size_t updateSize)
|
||||
{
|
||||
if (Update.begin(updateSize))
|
||||
{
|
||||
Serial0.println("Writes : ");
|
||||
//Serial.println("Writes : ");
|
||||
size_t written = Update.writeStream(updateSource);
|
||||
if (written == updateSize)
|
||||
{
|
||||
Serial0.println("Writes : " + String(written) + " successfully");
|
||||
//Serial.println("Writes : " + String(written) + " successfully");
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial0.println("Written only : " + String(written) + "/" + String(updateSize) + ". Retry?");
|
||||
//Serial.println("Written only : " + String(written) + "/" + String(updateSize) + ". Retry?");
|
||||
}
|
||||
|
||||
if (Update.end())
|
||||
{
|
||||
Serial0.println("OTA finished!");
|
||||
//Serial.println("OTA finished!");
|
||||
if (Update.isFinished())
|
||||
{
|
||||
Serial0.println("Restart ESP device!");
|
||||
//Serial.println("Restart ESP device!");
|
||||
abort();
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial0.println("OTA not fiished");
|
||||
//Serial.println("OTA not fiished");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial0.println("Error occured #: " + String(Update.getError()));
|
||||
//Serial.println("Error occured #: " + String(Update.getError()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial0.println("Cannot beggin update");
|
||||
//Serial.println("Cannot beggin update");
|
||||
}
|
||||
}
|
||||
size_t http_download(String url)
|
||||
@ -402,7 +427,7 @@ size_t http_download(String url)
|
||||
int err = http->get(url.c_str());
|
||||
if (err != 0)
|
||||
{
|
||||
Serial0.println(F("Date failed to connect"));
|
||||
//Serial.println(F("Date failed to connect"));
|
||||
vTaskDelay(10000);
|
||||
return 0;
|
||||
}
|
||||
@ -412,25 +437,25 @@ size_t http_download(String url)
|
||||
vTaskDelay(10000);
|
||||
return 0;
|
||||
}
|
||||
Serial0.print(F("Response status code: "));
|
||||
Serial0.println(status);
|
||||
//Serial.print(F("Response status code: "));
|
||||
//Serial.println(status);
|
||||
// Serial0Mon.println(F("Response Headers:"));
|
||||
size_t count=0;
|
||||
while (http->headerAvailable())
|
||||
{
|
||||
String headerName = http->readHeaderName();
|
||||
String headerValue = http->readHeaderValue();
|
||||
Serial0.println("Date: " + headerName + " : " + headerValue);
|
||||
//Serial.println("Date: " + headerName + " : " + headerValue);
|
||||
if (headerName=="Content-Length")
|
||||
{
|
||||
count=headerValue.toInt();
|
||||
/* code */
|
||||
}
|
||||
}
|
||||
Serial0.println("lenth is "+String(count));
|
||||
//Serial.println("lenth is "+String(count));
|
||||
if (http->isResponseChunked())
|
||||
{
|
||||
Serial0.println(F("Date The response is chunked"));
|
||||
//Serial.println(F("Date The response is chunked"));
|
||||
}
|
||||
char *str=new char[1000];
|
||||
int lent=count/1000;
|
||||
@ -442,8 +467,8 @@ size_t http_download(String url)
|
||||
{
|
||||
http->readBytes(str,1000);
|
||||
file.write((const byte *)str,1000);
|
||||
Serial0.print("download ");
|
||||
Serial0.println(String(i*100/lent));
|
||||
//Serial.print("download ");
|
||||
//Serial.println(String(i*100/lent));
|
||||
/* code */
|
||||
}
|
||||
http->readBytes(str,count%1000);
|
||||
@ -467,8 +492,8 @@ bool check_file_ota(String MD5)
|
||||
md5my.addStream(file,countdownload1);
|
||||
md5my.calculate();
|
||||
String md5com=md5my.toString();
|
||||
Serial0.println("md5 comput is:"+md5my.toString());
|
||||
Serial0.println("md5 should is:"+MD5);
|
||||
//Serial.println("md5 comput is:"+md5my.toString());
|
||||
//Serial.println("md5 should is:"+MD5);
|
||||
file.close();
|
||||
if (MD5 == md5com)
|
||||
{
|
||||
@ -479,7 +504,7 @@ bool check_file_ota(String MD5)
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial0.println("md5 error");
|
||||
//Serial.println("md5 error");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
23
src/log.cpp
23
src/log.cpp
@ -39,34 +39,43 @@ ab+ 读写打开一个二进制文件,允许读或在文件末追加数据。
|
||||
#else
|
||||
SoftwareSerial U0_Serial(19,20,false);
|
||||
#endif
|
||||
volatile bool log_running = true;
|
||||
|
||||
|
||||
void log_init()
|
||||
{
|
||||
// U0_Serial.begin(115200);
|
||||
}
|
||||
|
||||
// void log_stop()
|
||||
// {
|
||||
// // U0_Serial.end();
|
||||
// log_running = false;
|
||||
// }
|
||||
void write_log(String path,String write_data,unsigned char level)
|
||||
{
|
||||
|
||||
if(level <50) {
|
||||
U0_Serial.println(write_data);
|
||||
// Serial0.println(write_data);
|
||||
// U0_Serial.println(write_data);
|
||||
// if(log_running)
|
||||
Serial.println(write_data);
|
||||
}
|
||||
if (level == 20)
|
||||
{
|
||||
// U0_Serial.println(write_data);
|
||||
|
||||
File file;
|
||||
file = SD_MMC.open(path,"ab+");
|
||||
file = SD_MMC.open(path,FILE_APPEND);
|
||||
file.println(write_data);
|
||||
file.flush();
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
void write_log(uint8_t *data,uint32_t size)
|
||||
{
|
||||
// U0_Serial.write(data,size);
|
||||
}
|
||||
// void write_log(uint8_t *data,uint32_t size)
|
||||
// {
|
||||
// // U0_Serial.write(data,size);
|
||||
// }
|
||||
|
||||
void save_data(String path,String write_data)
|
||||
{
|
||||
|
||||
@ -18,9 +18,10 @@
|
||||
|
||||
|
||||
void log_init();
|
||||
// void log_stop();
|
||||
void write_log(String path,String write_data,unsigned char level);
|
||||
void save_data(String path,String write_data);
|
||||
void write_log(uint8_t *data,uint32_t size);
|
||||
// void write_log(uint8_t *data,uint32_t size);
|
||||
// void my_println(String data,int level);
|
||||
|
||||
|
||||
|
||||
394
src/main.cpp
394
src/main.cpp
@ -26,6 +26,9 @@ void Task2(void *pvParameters);
|
||||
任务名:task_4G_mode
|
||||
任务功能:4G模式
|
||||
*/
|
||||
TaskHandle_t A4G_Handler;
|
||||
TaskHandle_t OTA_Handler;
|
||||
|
||||
void task_4G_mode(void *pvParameters);
|
||||
void OTA_task(void *pvParameters);
|
||||
//work_mode 0:手动 1:时间模式 time_mode 2:高级模式 advanced_mode 3:low_power_mode 4:4G_mode
|
||||
@ -38,7 +41,9 @@ void OTA_task(void *pvParameters);
|
||||
//dingbiao_time 0自动曝光 非0使用这个时长曝光
|
||||
//caiji_mode 0;停止 1:单次 2:连续 3:定标 4:高级模式 5:回传数据 6:低功耗模式
|
||||
volatile u_int32_t work_mode = 0,caiji_mode = 0,return_mode = 1,atuo_return = 0,return_data_type = 0x00,time_interval = 60 * 2,caiji_state = 0 ,fengbao_num=0;
|
||||
volatile float start_time = 1.0,stop_time = 20.30,maximum_temperature = 10,Minimum_temperature = 0,bc_b1,bc_b2,bc_b3,bc_b4,sun_latitude,sun_longitude;
|
||||
// volatile float start_time = 1.0,stop_time = 20.30,maximum_temperature = 10,Minimum_temperature = 0,bc_b1,bc_b2,bc_b3,bc_b4,sun_latitude,sun_longitude;
|
||||
volatile float start_time = 1.0,stop_time = 20.30,maximum_temperature = 10,Minimum_temperature = 0,sun_latitude,sun_longitude;
|
||||
|
||||
volatile float calculation_bochang1,calculation_bochang2;
|
||||
// volatile u_int32_t http_flag = 0;
|
||||
|
||||
@ -181,9 +186,9 @@ void setup()
|
||||
//初始化SD卡
|
||||
sdcard::init_sdcard();
|
||||
sdcard::testwriet();
|
||||
sdcard::Mkdir("/guangpu_data");
|
||||
sdcard::Mkdir("/data");
|
||||
sdcard::Mkdir("/log");
|
||||
sdcard::Mkdir("/dingbiao");
|
||||
sdcard::Mkdir("/calfiles");
|
||||
sdcard::Mkdir("/system");
|
||||
|
||||
|
||||
@ -226,13 +231,22 @@ void setup()
|
||||
rtc.init();
|
||||
|
||||
String time = String(now.year)+String(now.month)+String(now.day)+String(now.hour)+String(now.minute)+String(now.second);
|
||||
write_log(log_path," ",20);
|
||||
write_log(log_path,"===============================================================",20);
|
||||
write_log(log_path,time,20);
|
||||
write_log(log_path,"system start",20);
|
||||
|
||||
|
||||
|
||||
|
||||
//初始化74hc595
|
||||
my74hc595_init();
|
||||
// while(1)
|
||||
// {
|
||||
// // shutter_off();
|
||||
// shutter_on();
|
||||
// vTaskDelay(1000 * 5);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
@ -243,16 +257,23 @@ void setup()
|
||||
InitFunction(serialwrite,serialread);
|
||||
is11Sensor = new SensorIS11();
|
||||
STRSensorInfos_structure = is11Sensor->initSensor();
|
||||
Serial0.println("IS_SN :" +STRSensorInfos_structure.serialnumber);
|
||||
//Serial.println("IS_SN :" +STRSensorInfos_structure.serialnumber);
|
||||
|
||||
// is11Sensor->guangpu_bochang.a1 = 0.000000000000000;
|
||||
// is11Sensor->guangpu_bochang.a2 = 0.000000000;
|
||||
|
||||
sys_info_init();
|
||||
|
||||
dingbiao_init("/dingbiao/dingbiao_up_gain.bin");
|
||||
dingbiao_init("/dingbiao/dingbiao_up_offset.bin");
|
||||
dingbiao_init("/dingbiao/dingbiao_down_gain.bin");
|
||||
dingbiao_init("/dingbiao/dingbiao_down_offset.bin");
|
||||
dingbiao_init("/dingbiao/fanshelv_gain.bin");
|
||||
// dingbiao_init("/dingbiao/dingbiao_up_gain.bin");
|
||||
// dingbiao_init("/dingbiao/dingbiao_up_offset.bin");
|
||||
// dingbiao_init("/dingbiao/dingbiao_down_gain.bin");
|
||||
// dingbiao_init("/dingbiao/dingbiao_down_offset.bin");
|
||||
// dingbiao_init("/dingbiao/fanshelv_gain.bin");
|
||||
dingbiao_init("/calfiles/upgain.bin");
|
||||
dingbiao_init("/calfiles/upoffset.bin");
|
||||
dingbiao_init("/calfiles/downgain.bin");
|
||||
dingbiao_init("/calfiles/downoffset.bin");
|
||||
dingbiao_init("/calfiles/fanshelv_gain.bin");
|
||||
|
||||
|
||||
// gsmm_mqtt_init();
|
||||
@ -273,25 +294,45 @@ void setup()
|
||||
Main_EventGroup = xEventGroupCreate();
|
||||
xMutexInventory = xSemaphoreCreateMutex(); //创建MUTEX
|
||||
|
||||
|
||||
|
||||
if(is11Sensor->guangpu_bochang.b3 < 100)
|
||||
{
|
||||
// write_log(log_path,"guangpu_bochang.b3 < 100",10);
|
||||
is11Sensor->guangpu_bochang.is_valid = false;
|
||||
is11Sensor->guangpu_bochang.a0 = is11Sensor->SensorInfo.a1;
|
||||
is11Sensor->guangpu_bochang.a1 = is11Sensor->SensorInfo.a2;
|
||||
is11Sensor->guangpu_bochang.a2 = is11Sensor->SensorInfo.a3;
|
||||
is11Sensor->guangpu_bochang.a3 = is11Sensor->SensorInfo.a4;
|
||||
|
||||
is11Sensor->guangpu_bochang.b0 = is11Sensor->SensorInfo.a1;
|
||||
is11Sensor->guangpu_bochang.b1 = is11Sensor->SensorInfo.a2;
|
||||
is11Sensor->guangpu_bochang.b2 = is11Sensor->SensorInfo.a3;
|
||||
is11Sensor->guangpu_bochang.b3 = is11Sensor->SensorInfo.a4;
|
||||
}
|
||||
else
|
||||
{
|
||||
// write_log(log_path,"guangpu_bochang.b3 >= 100",10);
|
||||
is11Sensor->guangpu_bochang.is_valid = true;
|
||||
is11Sensor->SensorInfo.a1 = is11Sensor->guangpu_bochang.a0;
|
||||
is11Sensor->SensorInfo.a2 = is11Sensor->guangpu_bochang.a1;
|
||||
is11Sensor->SensorInfo.a3 = is11Sensor->guangpu_bochang.a2;
|
||||
is11Sensor->SensorInfo.a4 = is11Sensor->guangpu_bochang.a3;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(sys_sd_doc["status_4g"] == "open_4g")
|
||||
{
|
||||
gsmm_mqtt_init(STRSensorInfos_structure.serialnumber);
|
||||
// while (1)
|
||||
// {
|
||||
|
||||
// ////获取GPS
|
||||
// write_log(log_path,"test gps",10);
|
||||
// gps_struct gps_structure;
|
||||
// String gpsbac = get_GPS(&gps_structure);
|
||||
// write_log(log_path,gpsbac,10);
|
||||
// Serial.printf("time: %d-%d-%d %d:%d:%d\n",gps_structure.year,gps_structure.month,gps_structure.day,gps_structure.hour,gps_structure.minute,gps_structure.second);
|
||||
// Serial.printf("latitude: %d ,longitude : %d\n",gps_structure.latitude,gps_structure.longitude);
|
||||
|
||||
// vTaskDelay(1000);
|
||||
// }
|
||||
|
||||
xTaskCreatePinnedToCore(task_4G_mode, "task_4G_mode",1024*(20),NULL, 1,NULL, 1);
|
||||
xTaskCreatePinnedToCore(OTA_task, "OTA_task",1024*(10),NULL, 1,NULL, 1);
|
||||
xTaskCreatePinnedToCore(task_4G_mode, "task_4G_mode",1024*23,NULL, 1,&A4G_Handler, 1);
|
||||
xTaskCreatePinnedToCore(OTA_task , "OTA_task",1024*10 ,NULL, 1,&OTA_Handler, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
xTaskCreatePinnedToCore(Task0,"Task0",1024 * 23,NULL,2,&Task0_Handler, 0);
|
||||
}
|
||||
|
||||
if (xMutexInventory == NULL)
|
||||
@ -301,10 +342,12 @@ void setup()
|
||||
else
|
||||
{
|
||||
//创建并启动Core1的任务 xTaskCreatePinnedToCore
|
||||
xTaskCreatePinnedToCore(Task0,"Task0",1024 * 10,NULL,2,&Task0_Handler,0);
|
||||
// xTaskCreatePinnedToCore(Task0,"Task0",1024 * 23,NULL,2,&Task0_Handler, 0);
|
||||
xTaskCreatePinnedToCore(Task1,"Task1",1024 * 5, NULL,1,&Task1_Handler, 0);
|
||||
xTaskCreatePinnedToCore(Task2,"Task2",1024 * 30,NULL,5,&Task2_Handler, 1);
|
||||
}
|
||||
|
||||
|
||||
// write_log(log_path,"setup ok",10);
|
||||
}
|
||||
|
||||
@ -435,100 +478,7 @@ void Task1(void *pvParameters)
|
||||
uint32_t count = 10;
|
||||
while(1)
|
||||
{
|
||||
// vTaskDelay(1000);
|
||||
// //获取时间
|
||||
// rtc.getDateTime(&now);
|
||||
|
||||
// //获取温度
|
||||
// // float temp[8];
|
||||
// // getall_temp(temp);
|
||||
// // //平均温度
|
||||
// // float temp_ave = 0;
|
||||
// // for (size_t i = 0; i < 8; i++)
|
||||
// // {
|
||||
// // temp_ave += temp[i];
|
||||
// // }
|
||||
// // temp_ave = temp_ave / 8;
|
||||
// // write_log(log_path,"temp_ave: " + String(temp_ave),log_level);
|
||||
|
||||
// //获取GPS
|
||||
// gps_struct gps_structure;
|
||||
|
||||
// String gpsbac = get_GPS(&gps_structure);
|
||||
//计算日出日落
|
||||
// double transit, sunrise, sunset;
|
||||
// double utc_offset = 8;
|
||||
// if (gpsbac != "-1")
|
||||
// {
|
||||
// calcSunriseSunset(now.year+2000, now.month, now.day,gps_structure.latitude, gps_structure.longitude, transit, sunrise, sunset);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// write_log(log_path,"no gps",10);
|
||||
// }
|
||||
|
||||
// //日出日落控制 太阳升起前推杆缩,太阳落下后推杆伸
|
||||
// write_log(log_path,"now.hour: " + String(now.hour),log_level);
|
||||
// write_log(log_path,"sunrise: " + String((int)sunrise),log_level);
|
||||
// write_log(log_path,"sunset: " + String((int)sunset),log_level);
|
||||
// if (now.hour+1 == (int)sunrise)
|
||||
// {
|
||||
// tuigan(suo);
|
||||
// }
|
||||
// else if (now.hour+1 >= (int)sunset)
|
||||
// {
|
||||
// tuigan(tui);
|
||||
// }
|
||||
|
||||
// if(sys_sd_doc["work_mode"] == "time_mode")
|
||||
// {
|
||||
// float now_time = now.hour + now.minute/100;
|
||||
// if(now_time > start_time && now_time < stop_time)
|
||||
// {
|
||||
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if(xSemaphoreTake(xMutexInventory, timeOut) == pdPASS)
|
||||
// {
|
||||
// caiji_mode = 0;
|
||||
// }
|
||||
// xSemaphoreGive(xMutexInventory);
|
||||
// }
|
||||
// }
|
||||
|
||||
// write_log(log_path,"temp_ave: " + String(temp_ave),log_level);
|
||||
// if(temp_ave < Minimum_temperature)
|
||||
// {
|
||||
// write_log(log_path,"start jiaresi",10);
|
||||
// jiaresi(5,start_jiare);
|
||||
// vTaskDelay(1000 * 10);
|
||||
// }
|
||||
// else if (temp_ave > Minimum_temperature + 5)
|
||||
// {
|
||||
// write_log(log_path,"stop jiaresi",10);
|
||||
// jiaresi(5,stop_jiare);
|
||||
// }
|
||||
// for(int ab ; ab < 10; ab++)
|
||||
// {
|
||||
|
||||
|
||||
// gps_struct gps_structure;
|
||||
// String gpsbac = get_GPS(&gps_structure);
|
||||
// if(gpsbac == "-1")
|
||||
// {
|
||||
// write_log(log_path,"no gps",10);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// sun_latitude = gps_structure.latitude;
|
||||
// sun_longitude = gps_structure.longitude;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//Serial.println("Task1 is running");
|
||||
rtc.getDateTime(&now);
|
||||
write_log(log_path, String(now.year) +"."+ String(now.month) +"."+ String(now.day)+" "+String(now.hour)+":"+String(now.minute)+":"+String(now.second),20);
|
||||
// String path = "/guangpu_data/"+ String(now.year) + "/" + String(now.month) + "/" + String(now.day);
|
||||
@ -564,26 +514,12 @@ void Task1(void *pvParameters)
|
||||
write_log(log_path,"sdcard will full," + String(used_percent * 100) + "%" +"used.",20);
|
||||
}
|
||||
|
||||
if(SD_MMC.exists("/guangpu_data/" + String(now.year - 10) ))
|
||||
{
|
||||
String path = "/guangpu_data/" + String(now.year - 10);
|
||||
rm_dir_or_file(path.c_str());
|
||||
}
|
||||
|
||||
vTaskDelay(1000 * 1);
|
||||
// write_log(log_path,"delete /guangpu_data/0 1111111111",10);
|
||||
|
||||
// if(SD_MMC.exists("/guangpu_data/0"))
|
||||
// if(SD_MMC.exists("/data/" + String(now.year - 10) ))
|
||||
// {
|
||||
// write_log(log_path,"delete /guangpu_data/0 2222222222222222",10);
|
||||
// // sdcard::deleteFolderOrFile("/gaugpu_data/0");
|
||||
// rm_dir_or_file("/guangpu_data/0");
|
||||
// String path = "/data/" + String(now.year - 10);
|
||||
// rm_dir_or_file(path.c_str());
|
||||
// }
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////时间/////////////////////////////////////////
|
||||
//获取RTC时间
|
||||
rtc.getDateTime(&now);
|
||||
|
||||
#ifdef GPS_4G
|
||||
if(now.day != last_day)
|
||||
@ -686,8 +622,9 @@ void Task1(void *pvParameters)
|
||||
write_log(log_path,"tuisuotime: " + String(tuisuotime),20);
|
||||
write_log(log_path,"sunrise: " + String(sunrise),20);
|
||||
write_log(log_path,"sunset: " + String(sunset),20);
|
||||
write_log(log_path,"tui",20);
|
||||
tuigan(tui);
|
||||
write_log(log_path,"suo",20);
|
||||
// tuigan(tui);
|
||||
tuigan(suo);
|
||||
jiaresi(6,start_jiare);
|
||||
}
|
||||
else
|
||||
@ -695,8 +632,9 @@ void Task1(void *pvParameters)
|
||||
write_log(log_path,"tuisuotime: " + String(tuisuotime),20);
|
||||
write_log(log_path,"sunrise: " + String(sunrise),20);
|
||||
write_log(log_path,"sunset: " + String(sunset),20);
|
||||
write_log(log_path,"suo",20);
|
||||
tuigan(suo);
|
||||
write_log(log_path,"tui",20);
|
||||
// tuigan(suo);
|
||||
tuigan(tui);
|
||||
jiaresi(6,stop_jiare);
|
||||
}
|
||||
}
|
||||
@ -707,8 +645,9 @@ void Task1(void *pvParameters)
|
||||
write_log(log_path,"tuisuotime: " + String(tuisuotime),20);
|
||||
write_log(log_path,"sunrise: " + String(sunrise),20);
|
||||
write_log(log_path,"sunset: " + String(sunset),20);
|
||||
write_log(log_path,"tui",20);
|
||||
tuigan(tui);
|
||||
write_log(log_path,"suo",20);
|
||||
// tuigan(tui);
|
||||
tuigan(suo);
|
||||
jiaresi(6,start_jiare);
|
||||
}
|
||||
else
|
||||
@ -716,12 +655,13 @@ void Task1(void *pvParameters)
|
||||
write_log(log_path,"tuisuotime: " + String(tuisuotime),20);
|
||||
write_log(log_path,"sunrise: " + String(sunrise),20);
|
||||
write_log(log_path,"sunset: " + String(sunset),20);
|
||||
write_log(log_path,"suo",20);
|
||||
tuigan(suo);
|
||||
write_log(log_path,"tui",20);
|
||||
// tuigan(suo);
|
||||
tuigan(tui);
|
||||
jiaresi(6,stop_jiare);
|
||||
}
|
||||
}
|
||||
vTaskDelay(1000 * 1);
|
||||
vTaskDelay(100);
|
||||
|
||||
|
||||
float temperature[8];
|
||||
@ -741,7 +681,7 @@ void Task1(void *pvParameters)
|
||||
write_log(log_path,"temperature " + String(n) +":" + String(temperature[n]),10);
|
||||
}
|
||||
|
||||
if(temperature[2] / 2 > maximum_temperature)
|
||||
if(temperature[2] > maximum_temperature)
|
||||
{
|
||||
write_log(log_path,"stop_jiare",20);
|
||||
jiaresi(7,stop_jiare);
|
||||
@ -749,7 +689,7 @@ void Task1(void *pvParameters)
|
||||
|
||||
if( temperature[2] < Minimum_temperature)
|
||||
{
|
||||
if(temperature[2] < -120)
|
||||
if(temperature[2] < -110)
|
||||
{
|
||||
write_log(log_path,"temperature 2 is broken.",20);
|
||||
jiaresi(7,stop_jiare);
|
||||
@ -780,7 +720,7 @@ void Task1(void *pvParameters)
|
||||
// // jiaresi(5,stop_jiare);
|
||||
// }
|
||||
count++;
|
||||
vTaskDelay(1000 * 60 * 1);
|
||||
vTaskDelay(1000 * 60 );
|
||||
}
|
||||
|
||||
}
|
||||
@ -837,10 +777,10 @@ void task_4G_mode(void *pvParameters)
|
||||
{
|
||||
http_data_head http_head;
|
||||
uint8_t *data = new u_char[sizeof(IS11_datastruct) + sizeof(http_head)];
|
||||
|
||||
write_log(log_path,"task 4G mode",10);
|
||||
while (1)
|
||||
{
|
||||
Serial0.println("task_4G_mode 11");
|
||||
Serial.println("task_4G_mode 11");
|
||||
// vTaskDelay(1000 * 10);
|
||||
bool warn_sta = false;
|
||||
float temperature[8];
|
||||
@ -860,7 +800,7 @@ void task_4G_mode(void *pvParameters)
|
||||
|
||||
}
|
||||
float Voltage = adc_read();
|
||||
Serial0.println("Voltage:" + String(Voltage));
|
||||
//Serial.println("Voltage:" + String(Voltage));
|
||||
if(Voltage < 10)
|
||||
{
|
||||
warn_sta = true;
|
||||
@ -886,7 +826,7 @@ void task_4G_mode(void *pvParameters)
|
||||
doc_4G["temperature 7 : "] = temperature[7];
|
||||
break;
|
||||
}
|
||||
Serial.println("uptodate temperature " + String(n) +":" + String(temperature[n]));
|
||||
//Serial.println("uptodate temperature " + String(n) +":" + String(temperature[n]));
|
||||
}
|
||||
if(warn_sta)
|
||||
{
|
||||
@ -896,13 +836,13 @@ void task_4G_mode(void *pvParameters)
|
||||
}
|
||||
|
||||
//获取时间
|
||||
Serial0.println("work_mode = " + String(work_mode) );
|
||||
//Serial.println("work_mode = " + String(work_mode) );
|
||||
if(work_mode == 4)
|
||||
{
|
||||
String time_4g = getnetData();
|
||||
Serial0.println("time_4g " + time_4g);
|
||||
//Serial.println("time_4g " + time_4g);
|
||||
rtc.getDateTime(&now);
|
||||
Serial0.println("rtc time :" + String(now.year) + "-" + String(now.month) + "-" + String(now.day) + " " + String(now.hour) + ":" + String(now.minute) + ":" + String(now.second));
|
||||
//Serial.println("rtc time :" + String(now.year) + "-" + String(now.month) + "-" + String(now.day) + " " + String(now.hour) + ":" + String(now.minute) + ":" + String(now.second));
|
||||
|
||||
|
||||
if(time_4g != "-1")
|
||||
@ -944,8 +884,8 @@ void task_4G_mode(void *pvParameters)
|
||||
xSemaphoreGive(xMutexInventory);
|
||||
}
|
||||
|
||||
Serial.println("gps_structure.latitude " + String(gps_structure.latitude));
|
||||
Serial.println("gps_structure.longitude " + String(gps_structure.longitude));
|
||||
//Serial.println("gps_structure.latitude " + String(gps_structure.latitude));
|
||||
//Serial.println("gps_structure.longitude " + String(gps_structure.longitude));
|
||||
|
||||
// gps_structure.year = gps_structure.year - 2000;
|
||||
// if(now.year != gps_structure.year || now.month != gps_structure.month || now.day != gps_structure.day || now.hour != gps_structure.hour || (fabs(now.minute - net_structure.minute)>5 ))
|
||||
@ -963,9 +903,9 @@ void task_4G_mode(void *pvParameters)
|
||||
}
|
||||
|
||||
float now_time = now.hour + now.minute/100;
|
||||
Serial0.println("now_time " + String(now_time));
|
||||
Serial0.println("start_time " + String(start_time));
|
||||
Serial0.println("stop_time " + String(stop_time));
|
||||
//Serial.println("now_time " + String(now_time));
|
||||
//Serial.println("start_time " + String(start_time));
|
||||
//Serial.println("stop_time " + String(stop_time));
|
||||
// vTaskDelay(1000 * 1);
|
||||
if((now_time >= start_time) && (now_time < stop_time))
|
||||
{
|
||||
@ -984,15 +924,29 @@ void task_4G_mode(void *pvParameters)
|
||||
// doc_4G["a4"] = STRSensorInfos_structure.a4;
|
||||
// http_head.sn
|
||||
String sn = STRSensorInfos_structure.serialnumber;
|
||||
write_log(log_path,"task 4g sn: " + sn,10);
|
||||
memset(&http_head,'\0',sizeof(http_head));
|
||||
String version = sys_sd_doc["version"] ;
|
||||
memcpy(http_head.sn,sn.c_str(),sn.length());
|
||||
memcpy(http_head.version,version.c_str(),version.length());
|
||||
http_head.sn[sn.length()] = '\0';
|
||||
http_head.version[version.length()] = '\0';
|
||||
|
||||
// http_head.sn[0] = 'i';
|
||||
// http_head.sn[1] = 's';
|
||||
// http_head.sn[2] = '1';
|
||||
// http_head.sn[3] = '1';
|
||||
// http_head.sn[4] = '0';
|
||||
// http_head.sn[5] = '0';
|
||||
// http_head.sn[6] = '7';
|
||||
// http_head.sn[7] = '\0';
|
||||
|
||||
http_head.lat = sun_latitude;
|
||||
http_head.lon = sun_longitude;
|
||||
http_head.is3_a1 = STRSensorInfos_structure.a1;
|
||||
http_head.is3_a2 = STRSensorInfos_structure.a2;
|
||||
http_head.is3_a3 = STRSensorInfos_structure.a3;
|
||||
http_head.is3_a4 = STRSensorInfos_structure.a4;
|
||||
http_head.is3_a1 = is11Sensor->SensorInfo.a1;
|
||||
http_head.is3_a2 = is11Sensor->SensorInfo.a2;
|
||||
http_head.is3_a3 = is11Sensor->SensorInfo.a3;
|
||||
http_head.is3_a4 = is11Sensor->SensorInfo.a4;
|
||||
|
||||
xSemaphoreGive(xMutexInventory);
|
||||
}
|
||||
@ -1000,10 +954,11 @@ void task_4G_mode(void *pvParameters)
|
||||
memcpy(data,&http_head,sizeof(http_head));
|
||||
memcpy((data + sizeof(http_head)),&IS11_datastruct_fanshelv,sizeof(IS11_datastruct_fanshelv));
|
||||
vTaskDelay(10);
|
||||
write_log(log_path,"upload data to server",10);
|
||||
UpdateData("/HyperspectralV2/DataUpload.php",data , sizeof(http_head) + sizeof(IS11_datastruct_fanshelv),HTTP_METHOD_POST);
|
||||
}
|
||||
Serial.println("http_head.lat " + String(http_head.lat));
|
||||
Serial.println("http_head.lon " + String(http_head.lon));
|
||||
//Serial.println("http_head.lat " + String(http_head.lat));
|
||||
//Serial.println("http_head.lon " + String(http_head.lon));
|
||||
|
||||
vTaskDelay(1000 * time_interval);
|
||||
}
|
||||
@ -1033,8 +988,18 @@ void receive_command_unpack(uint8_t * read_buf,uint16_t data_length,uint8_t port
|
||||
uint8_t low_power_sta = 1;
|
||||
u_char send_buff[300];
|
||||
|
||||
|
||||
int ret = IRIS_STM32_Protocol_Unpack(read_buf,data_length,&data_type,command_data);
|
||||
|
||||
// write_log(log_path,"receive port_type: " + String(port_type),10);
|
||||
// write_log(log_path,"ret: " + String(ret),10);
|
||||
|
||||
// Serial.println("read_buf: " + String(read_buf,data_length));
|
||||
for (int i = 0; i < data_length; i++)
|
||||
{
|
||||
Serial.printf("%02X ",read_buf[i]);
|
||||
}
|
||||
|
||||
|
||||
if (ret > 0)
|
||||
{
|
||||
@ -1065,7 +1030,7 @@ void receive_command_unpack(uint8_t * read_buf,uint16_t data_length,uint8_t port
|
||||
//保存到sd卡
|
||||
if(command_data[0] == 4)
|
||||
{
|
||||
if(command_data[1] == 0) dingbiao_path = "/dingbiao/dingbiao_up_gain.bin";
|
||||
if(command_data[1] == 0) dingbiao_path = "/dingbiao/upgain.bin";
|
||||
else if(command_data[1] == 1) dingbiao_path = "/dingbiao/dingbiao_up_offset.bin";
|
||||
}
|
||||
else if(command_data[0] == 5)
|
||||
@ -1327,7 +1292,6 @@ command : 1、get_sensor_info
|
||||
23、set_Minimum_temperature
|
||||
24、
|
||||
*/
|
||||
|
||||
/*{"command":"","name":"gaoguangpu","version":"v2.0","SN":"123456","date":"","caiji_mode":"","time_interval":"","return_data_type":"","bochangxishu":""}*/
|
||||
void json_command(uint8_t port_type)
|
||||
{
|
||||
@ -1769,7 +1733,14 @@ void json_command(uint8_t port_type)
|
||||
//command 10
|
||||
else if (doc["command"] == "set_bochangxishu")
|
||||
{
|
||||
float b1=0,b2=0,b3=0,b4=0;
|
||||
double a0=0,a1=0,a2=0,a3=0,a4=0,b1=0,b2=0,b3=0,b4=0;
|
||||
|
||||
a0 = doc["bochangxishu"]["a0"];
|
||||
a1 = doc["bochangxishu"]["a1"];
|
||||
a2 = doc["bochangxishu"]["a2"];
|
||||
a3 = doc["bochangxishu"]["a3"];
|
||||
|
||||
|
||||
b1 = doc["bochangxishu"]["b0"];
|
||||
b2 = doc["bochangxishu"]["b1"];
|
||||
b3 = doc["bochangxishu"]["b2"];
|
||||
@ -1778,10 +1749,30 @@ void json_command(uint8_t port_type)
|
||||
if(b1!=0 && b2 !=0 && b3 != 0 && b4 != 0)
|
||||
{
|
||||
save = true;
|
||||
bc_b1 = doc["bochangxishu"]["b0"];
|
||||
bc_b2 = doc["bochangxishu"]["b1"];
|
||||
bc_b3 = doc["bochangxishu"]["b2"];
|
||||
bc_b4 = doc["bochangxishu"]["b3"];
|
||||
// bc_b1 = doc["bochangxishu"]["b0"];
|
||||
// bc_b2 = doc["bochangxishu"]["b1"];
|
||||
// bc_b3 = doc["bochangxishu"]["b2"];
|
||||
// bc_b4 = doc["bochangxishu"]["b3"];
|
||||
is11Sensor->SensorInfo.a1 = doc["bochangxishu"]["a0"];
|
||||
is11Sensor->SensorInfo.a2 = doc["bochangxishu"]["a1"];
|
||||
is11Sensor->SensorInfo.a3 = doc["bochangxishu"]["a2"];
|
||||
is11Sensor->SensorInfo.a4 = doc["bochangxishu"]["a3"];
|
||||
|
||||
is11Sensor->guangpu_bochang.a0 = doc["bochangxishu"]["a0"];
|
||||
is11Sensor->guangpu_bochang.a1 = doc["bochangxishu"]["a1"];
|
||||
is11Sensor->guangpu_bochang.a2 = doc["bochangxishu"]["a2"];
|
||||
is11Sensor->guangpu_bochang.a3 = doc["bochangxishu"]["a3"];
|
||||
|
||||
is11Sensor->guangpu_bochang.b0 = doc["bochangxishu"]["b0"];
|
||||
is11Sensor->guangpu_bochang.b1 = doc["bochangxishu"]["b1"];
|
||||
is11Sensor->guangpu_bochang.b2 = doc["bochangxishu"]["b2"];
|
||||
is11Sensor->guangpu_bochang.b3 = doc["bochangxishu"]["b3"];
|
||||
|
||||
|
||||
sys_sd_doc["bochangxishu"]["a0"] = doc["bochangxishu"]["a0"];
|
||||
sys_sd_doc["bochangxishu"]["a1"] = doc["bochangxishu"]["a1"];
|
||||
sys_sd_doc["bochangxishu"]["a2"] = doc["bochangxishu"]["a2"];
|
||||
sys_sd_doc["bochangxishu"]["a3"] = doc["bochangxishu"]["a3"];
|
||||
|
||||
sys_sd_doc["bochangxishu"]["b0"] = doc["bochangxishu"]["b0"];
|
||||
sys_sd_doc["bochangxishu"]["b1"] = doc["bochangxishu"]["b1"];
|
||||
@ -2308,10 +2299,10 @@ void json_command(uint8_t port_type)
|
||||
// 导出定标文件
|
||||
else if(doc["command"] == "get_dingbiao")
|
||||
{
|
||||
send_dingbiao("/dingbiao/dingbiao_up_gain.bin");
|
||||
send_dingbiao("/dingbiao/dingbiao_up_offset.bin");
|
||||
send_dingbiao("/dingbiao/dingbiao_down_gain.bin");
|
||||
send_dingbiao("/dingbiao/dingbiao_down_offset.bin");
|
||||
send_dingbiao("/dingbiao/upgain.bin");
|
||||
send_dingbiao("/dingbiao/upoffset.bin");
|
||||
send_dingbiao("/dingbiao/downgain.bin");
|
||||
send_dingbiao("/dingbiao/downoffset.bin");
|
||||
}
|
||||
//command 28
|
||||
//获取电源电压
|
||||
@ -2459,12 +2450,19 @@ void json_command(uint8_t port_type)
|
||||
if(port_type == 1) wb485Serial.write(send_buff,ret);
|
||||
else if(port_type == 2) mqtt_write(send_buff,ret);
|
||||
// myusb_init();
|
||||
|
||||
setupmsc();
|
||||
|
||||
vTaskSuspend(Task0_Handler);
|
||||
vTaskSuspend(Task1_Handler);
|
||||
// vTaskSuspend(Task2_Handler);
|
||||
vTaskSuspend(A4G_Handler);
|
||||
vTaskSuspend(OTA_Handler);
|
||||
}
|
||||
//command 38
|
||||
else if(doc["command"] == "reboot")
|
||||
{
|
||||
// setupmsc();
|
||||
stopmsc();
|
||||
send_str = "";
|
||||
doc["state"] = "success";
|
||||
serializeJson(doc, send_str);
|
||||
@ -2610,15 +2608,33 @@ void sys_info_init()
|
||||
|
||||
|
||||
|
||||
sys_sd_doc["bochangxishu"]["a0"] = STRSensorInfos_structure.a1;
|
||||
sys_sd_doc["bochangxishu"]["a1"] = STRSensorInfos_structure.a2;
|
||||
sys_sd_doc["bochangxishu"]["a2"] = STRSensorInfos_structure.a3;
|
||||
sys_sd_doc["bochangxishu"]["a3"] = STRSensorInfos_structure.a4;
|
||||
// sys_sd_doc["bochangxishu"]["a0"] = STRSensorInfos_structure.a1;
|
||||
// sys_sd_doc["bochangxishu"]["a1"] = STRSensorInfos_structure.a2;
|
||||
// sys_sd_doc["bochangxishu"]["a2"] = STRSensorInfos_structure.a3;
|
||||
// sys_sd_doc["bochangxishu"]["a3"] = STRSensorInfos_structure.a4;
|
||||
|
||||
sys_sd_doc["bochangxishu"]["a0"] = doc["bochangxishu"]["a0"];
|
||||
sys_sd_doc["bochangxishu"]["a1"] = doc["bochangxishu"]["a1"];
|
||||
sys_sd_doc["bochangxishu"]["a2"] = doc["bochangxishu"]["a2"];
|
||||
sys_sd_doc["bochangxishu"]["a3"] = doc["bochangxishu"]["a3"];
|
||||
|
||||
sys_sd_doc["bochangxishu"]["b0"] = doc["bochangxishu"]["b0"];
|
||||
sys_sd_doc["bochangxishu"]["b1"] = doc["bochangxishu"]["b1"];
|
||||
sys_sd_doc["bochangxishu"]["b2"] = doc["bochangxishu"]["b2"];
|
||||
sys_sd_doc["bochangxishu"]["b3"] = doc["bochangxishu"]["b3"];
|
||||
|
||||
is11Sensor->guangpu_bochang.b0 = doc["bochangxishu"]["b0"];
|
||||
is11Sensor->guangpu_bochang.b1 = doc["bochangxishu"]["b1"];
|
||||
is11Sensor->guangpu_bochang.b2 = doc["bochangxishu"]["b2"];
|
||||
is11Sensor->guangpu_bochang.b3 = doc["bochangxishu"]["b3"];
|
||||
|
||||
is11Sensor->guangpu_bochang.a0 = doc["bochangxishu"]["a0"];
|
||||
is11Sensor->guangpu_bochang.a1 = doc["bochangxishu"]["a1"];
|
||||
is11Sensor->guangpu_bochang.a2 = doc["bochangxishu"]["a2"];
|
||||
is11Sensor->guangpu_bochang.a3 = doc["bochangxishu"]["a3"];
|
||||
|
||||
|
||||
|
||||
sys_sd_doc["return_data_type"] = doc["return_data_type"];
|
||||
sys_sd_doc["return_mode"] = doc["return_mode"]; //暂定
|
||||
sys_sd_doc["atuo_return"] = doc["atuo_return"].as<String>();//一会
|
||||
@ -2657,15 +2673,15 @@ void sys_info_init()
|
||||
sys_sd_doc["Minimum_temperature"] = Minimum_temperature;
|
||||
sys_sd_doc["servo_offset_angle"] = 0;
|
||||
|
||||
sys_sd_doc["bochangxishu"]["a0"] = STRSensorInfos_structure.a1;
|
||||
sys_sd_doc["bochangxishu"]["a1"] = STRSensorInfos_structure.a2;
|
||||
sys_sd_doc["bochangxishu"]["a2"] = STRSensorInfos_structure.a3;
|
||||
sys_sd_doc["bochangxishu"]["a3"] = STRSensorInfos_structure.a4;
|
||||
sys_sd_doc["bochangxishu"]["a0"] = is11Sensor->guangpu_bochang.a0;
|
||||
sys_sd_doc["bochangxishu"]["a1"] = is11Sensor->guangpu_bochang.a1;
|
||||
sys_sd_doc["bochangxishu"]["a2"] = is11Sensor->guangpu_bochang.a2;
|
||||
sys_sd_doc["bochangxishu"]["a3"] = is11Sensor->guangpu_bochang.a3;
|
||||
|
||||
sys_sd_doc["bochangxishu"]["b0"] = bc_b1;
|
||||
sys_sd_doc["bochangxishu"]["b1"] = bc_b2;
|
||||
sys_sd_doc["bochangxishu"]["b2"] = bc_b3;
|
||||
sys_sd_doc["bochangxishu"]["b3"] = bc_b4;
|
||||
sys_sd_doc["bochangxishu"]["b0"] = is11Sensor->guangpu_bochang.b0;
|
||||
sys_sd_doc["bochangxishu"]["b1"] = is11Sensor->guangpu_bochang.b1;
|
||||
sys_sd_doc["bochangxishu"]["b2"] = is11Sensor->guangpu_bochang.b2;
|
||||
sys_sd_doc["bochangxishu"]["b3"] = is11Sensor->guangpu_bochang.b3;
|
||||
sys_sd_doc["return_data_type"] = return_data_type;
|
||||
sys_sd_doc["return_mode"] = ""; //暂定
|
||||
sys_sd_doc["atuo_return"] = "no";
|
||||
|
||||
@ -98,11 +98,10 @@ void setupmsc()
|
||||
|
||||
USB.begin();
|
||||
USB.onEvent(usbEventCallback);
|
||||
|
||||
// msc.end();
|
||||
}
|
||||
|
||||
// void loop() {
|
||||
// delay(-1);
|
||||
// }
|
||||
|
||||
void stopmsc()
|
||||
{
|
||||
|
||||
@ -73,22 +73,32 @@ void servo_down()
|
||||
|
||||
void shutter_up()
|
||||
{
|
||||
digitalWrite(Shutter_pin1, HIGH);
|
||||
digitalWrite(Shutter_pin2, LOW);
|
||||
digitalWrite(Shutter_pin1, LOW);
|
||||
digitalWrite(Shutter_pin2, HIGH);
|
||||
vTaskDelay(200);
|
||||
}
|
||||
void shutter_down()
|
||||
{
|
||||
digitalWrite(Shutter_pin2, HIGH);
|
||||
digitalWrite(Shutter_pin1, LOW);
|
||||
digitalWrite(Shutter_pin1, HIGH);
|
||||
digitalWrite(Shutter_pin2, LOW);
|
||||
vTaskDelay(200);
|
||||
}
|
||||
|
||||
void shutter_off()
|
||||
{
|
||||
digitalWrite(Shutter_pin1, LOW);
|
||||
digitalWrite(Shutter_pin2, LOW);
|
||||
vTaskDelay(200);
|
||||
}
|
||||
|
||||
|
||||
void shutter_on()
|
||||
{
|
||||
digitalWrite(Shutter_pin1, HIGH);
|
||||
digitalWrite(Shutter_pin2, HIGH);
|
||||
vTaskDelay(200);
|
||||
}
|
||||
|
||||
/// @brief
|
||||
/// @param dir 0 down 1 up
|
||||
/// @param angle
|
||||
|
||||
@ -18,4 +18,5 @@ void servo_offset(float angle,uint8_t dir);
|
||||
void shutter_up();
|
||||
void shutter_down();
|
||||
void shutter_off();
|
||||
void shutter_on();
|
||||
#endif
|
||||
@ -35,11 +35,11 @@ bool check_tuigan()
|
||||
pinMode(tuigan_chek_pin, INPUT_PULLUP);
|
||||
if(digitalRead(tuigan_chek_pin) == LOW)
|
||||
{
|
||||
tuigan = tui;
|
||||
tuigan = suo;
|
||||
}
|
||||
else
|
||||
{
|
||||
tuigan = suo;
|
||||
tuigan = tui;
|
||||
}
|
||||
|
||||
if(tuigan != tuigan_sta) return false;
|
||||
|
||||
@ -4,37 +4,37 @@ void UpDateClassByme::performUpdate(Stream &updateSource, size_t updateSize)
|
||||
{
|
||||
if (Update.begin(updateSize))
|
||||
{
|
||||
Serial.println("Writes : ");
|
||||
//Serial.println("Writes : ");
|
||||
size_t written = Update.writeStream(updateSource);
|
||||
if (written == updateSize)
|
||||
{
|
||||
Serial.println("Writes : " + String(written) + " successfully");
|
||||
//Serial.println("Writes : " + String(written) + " successfully");
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("Written only : " + String(written) + "/" + String(updateSize) + ". Retry?");
|
||||
//Serial.println("Written only : " + String(written) + "/" + String(updateSize) + ". Retry?");
|
||||
}
|
||||
if (Update.end())
|
||||
{
|
||||
Serial.println("OTA finished!");
|
||||
//Serial.println("OTA finished!");
|
||||
if (Update.isFinished())
|
||||
{
|
||||
Serial.println("Restart ESP device!");
|
||||
//Serial.println("Restart ESP device!");
|
||||
abort();
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("OTA not fiished");
|
||||
//Serial.println("OTA not fiished");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("Error occured #: " + String(Update.getError()));
|
||||
//Serial.println("Error occured #: " + String(Update.getError()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("Cannot beggin update");
|
||||
//Serial.println("Cannot beggin update");
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ size_t UpDateClassByme::DownloadFirmwareForurl(String version)
|
||||
int err = http->get(url.c_str());
|
||||
if (err != 0)
|
||||
{
|
||||
Serial.println(F("Date failed to connect"));
|
||||
//Serial.println(F("Date failed to connect"));
|
||||
vTaskDelay(10000);
|
||||
return 0;
|
||||
}
|
||||
@ -55,15 +55,15 @@ size_t UpDateClassByme::DownloadFirmwareForurl(String version)
|
||||
vTaskDelay(10000);
|
||||
return 0;
|
||||
}
|
||||
Serial.print(F("Response status code: "));
|
||||
Serial.println(status);
|
||||
//Serial.print(F("Response status code: "));
|
||||
//Serial.println(status);
|
||||
// SerialMon.println(F("Response Headers:"));
|
||||
size_t count=0;
|
||||
while (http->headerAvailable())
|
||||
{
|
||||
String headerName = http->readHeaderName();
|
||||
String headerValue = http->readHeaderValue();
|
||||
Serial.println("Date: " + headerName + " : " + headerValue);
|
||||
//Serial.println("Date: " + headerName + " : " + headerValue);
|
||||
if (headerName=="Content-Length")
|
||||
{
|
||||
count=headerValue.toInt();
|
||||
@ -72,10 +72,10 @@ size_t UpDateClassByme::DownloadFirmwareForurl(String version)
|
||||
|
||||
|
||||
}
|
||||
Serial.println("lenth is "+String(count));
|
||||
//Serial.println("lenth is "+String(count));
|
||||
if (http->isResponseChunked())
|
||||
{
|
||||
Serial.println(F("Date The response is chunked"));
|
||||
//Serial.println(F("Date The response is chunked"));
|
||||
}
|
||||
char *str=new char[1000];
|
||||
int lent=count/1000;
|
||||
@ -87,8 +87,8 @@ size_t UpDateClassByme::DownloadFirmwareForurl(String version)
|
||||
{
|
||||
http->readBytes(str,1000);
|
||||
file.write((const byte *)str,1000);
|
||||
Serial.print("download ");
|
||||
Serial.println(String(i*100/lent));
|
||||
//Serial.print("download ");
|
||||
//Serial.println(String(i*100/lent));
|
||||
/* code */
|
||||
}
|
||||
http->readBytes(str,count%1000);
|
||||
@ -99,7 +99,7 @@ size_t UpDateClassByme::DownloadFirmwareForurl(String version)
|
||||
|
||||
|
||||
// http->readBytes
|
||||
Serial.println("adfasdfsadfsdfsd");
|
||||
//Serial.println("adfasdfsadfsdfsd");
|
||||
//Serial.write(str,cout);
|
||||
//Serial.println(body.length());
|
||||
http->stop();
|
||||
@ -124,7 +124,7 @@ bool UpDateClassByme::CheckAndUpdate()
|
||||
return true;
|
||||
|
||||
}
|
||||
Serial.println("targetvesion is:"+Targetversion);
|
||||
//Serial.println("targetvesion is:"+Targetversion);
|
||||
|
||||
//size_t countdownload1=375584;
|
||||
size_t countdownload1=DownloadFirmwareForurl(Targetversion);
|
||||
@ -132,7 +132,7 @@ bool UpDateClassByme::CheckAndUpdate()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Serial.println("count download is:"+String(countdownload1));
|
||||
//Serial.println("count download is:"+String(countdownload1));
|
||||
|
||||
String MD5=GetValueFromNet("/weather/php/GetMD5Value.php",Targetversion);
|
||||
|
||||
@ -153,8 +153,8 @@ bool UpDateClassByme::CheckAndUpdate()
|
||||
md5my.addStream(file,countdownload1);
|
||||
md5my.calculate();
|
||||
String md5com=md5my.toString();
|
||||
Serial.println("md5 comput is:"+md5my.toString());
|
||||
Serial.println("md5 should is:"+MD5);
|
||||
//Serial.println("md5 comput is:"+md5my.toString());
|
||||
//Serial.println("md5 should is:"+MD5);
|
||||
file.close();
|
||||
if (MD5==md5com)
|
||||
{
|
||||
@ -189,8 +189,8 @@ String UpDateClassByme::GetValueFromNet(String url,String Key)
|
||||
http->sendHeader(HTTP_HEADER_CONTENT_LENGTH, Key.length());
|
||||
http->endRequest();
|
||||
int err = http->write((const byte *)Key.c_str(), Key.length());
|
||||
Serial.print("send date size");
|
||||
Serial.println(err);
|
||||
//Serial.print("send date size");
|
||||
//Serial.println(err);
|
||||
|
||||
if (err == 0)
|
||||
{
|
||||
@ -213,7 +213,7 @@ String UpDateClassByme::GetValueFromNet(String url,String Key)
|
||||
}
|
||||
|
||||
String body = http->responseBody();
|
||||
Serial.println("body:"+body);
|
||||
//Serial.println("body:"+body);
|
||||
|
||||
http->stop();
|
||||
return body;
|
||||
|
||||
Reference in New Issue
Block a user