v2.0.5
This commit is contained in:
@ -774,7 +774,12 @@ void SensorIS11::TakeOneJob()
|
||||
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;
|
||||
// xValues[i] = b0 * i * i * i + b1 * i * i + b2 * i+ b3;
|
||||
double p_up = SensorInfo.a1 * i * i * i + SensorInfo.a2 * i * i + SensorInfo.a3 * i+ SensorInfo.a4;
|
||||
|
||||
// = p_up + (-2.999e-7 * p_up*p_up + 0.0009475 * p_up - 0.48467);
|
||||
|
||||
xValues[i] = p_up + (9.4755e-11*p_up*p_up*p_up - 6.0470e-07*p_up*p_up + 0.0012166*p_up - 0.53644);
|
||||
IS11_datastruct_down.data[i] = DATABUFF[i];
|
||||
|
||||
}
|
||||
@ -1473,11 +1478,20 @@ void SensorIS11::advanced_mode(u_int32_t direction,u_int32_t shutter_time,u_int3
|
||||
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];
|
||||
|
||||
// }
|
||||
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];
|
||||
// xValues[i] = b0 * i * i * i + b1 * i * i + b2 * i+ b3;
|
||||
double p_up = SensorInfo.a1 * i * i * i + SensorInfo.a2 * i * i + SensorInfo.a3 * i+ SensorInfo.a4;
|
||||
// xValues[i] = p_up + (-2.999e-7 * p_up*p_up + 0.0009475 * p_up - 0.48467);
|
||||
xValues[i] = p_up + (9.4755e-11*p_up*p_up*p_up - 6.0470e-07*p_up*p_up + 0.0012166*p_up - 0.53644);
|
||||
IS11_datastruct_down.data[i] = DATABUFF[i];
|
||||
}
|
||||
vTaskDelay(1);
|
||||
for (uint32_t i = 0; i < 2048;i++)
|
||||
|
||||
@ -8,7 +8,7 @@ struct STRSensorInfo
|
||||
long BandNum;
|
||||
String WavelenthStr;
|
||||
float *wavelenthlist;
|
||||
//double *wavelenth;
|
||||
//double * ;
|
||||
bool isSensorInit;
|
||||
String serialnumber;
|
||||
double a1,a2,a3,a4;
|
||||
|
||||
@ -68,8 +68,6 @@ void gsmm_mqtt_loop_task(void *pvParameters)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
|
||||
|
||||
EventBits_t uxBits = xEventGroupGetBits(http_event_group);
|
||||
if (uxBits & mqtt_stop_bit)
|
||||
{
|
||||
@ -404,7 +402,9 @@ void Update_firmware(Stream &updateSource, size_t updateSize)
|
||||
if (Update.isFinished())
|
||||
{
|
||||
//Serial.println("Restart ESP device!");
|
||||
abort();
|
||||
// abort();
|
||||
// ESP.restart();
|
||||
esp_restart();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -430,14 +430,14 @@ size_t http_download(String url)
|
||||
{
|
||||
//Serial.println(F("Date failed to connect"));
|
||||
write_log(log_path,"Date failed to connect",10);
|
||||
vTaskDelay(10000);
|
||||
vTaskDelay(100);
|
||||
return 0;
|
||||
}
|
||||
int status = http->responseStatusCode();
|
||||
if (!status)
|
||||
{
|
||||
write_log(log_path,"http->responseStatusCode false",10);
|
||||
vTaskDelay(10000);
|
||||
vTaskDelay(100);
|
||||
return 0;
|
||||
}
|
||||
//Serial.print(F("Response status code: "));
|
||||
|
||||
85
src/main.cpp
85
src/main.cpp
@ -42,8 +42,8 @@ void OTA_task(void *pvParameters);
|
||||
//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,sun_latitude,sun_longitude;
|
||||
|
||||
volatile float start_time = 0.1,stop_time = 23.59,maximum_temperature = 10,Minimum_temperature = 0,sun_latitude,sun_longitude;
|
||||
volatile float sunrise, sunset;
|
||||
volatile float calculation_bochang1,calculation_bochang2;
|
||||
// volatile u_int32_t http_flag = 0;
|
||||
|
||||
@ -268,14 +268,26 @@ void setup()
|
||||
vTaskDelay(1000 * 2);
|
||||
InitFunction(serialwrite,serialread);
|
||||
is11Sensor = new SensorIS11();
|
||||
|
||||
STRSensorInfos_structure = is11Sensor->initSensor();
|
||||
//Serial.println("IS_SN :" +STRSensorInfos_structure.serialnumber);
|
||||
// if(STRSensorInfos_structure.serialnumber.find("TFNSP") == -1 && STRSensorInfos_structure.serialnumber.find("IS") == -1);
|
||||
// {
|
||||
// STRSensorInfos_structure.serialnumber = "TFNSP44250004";
|
||||
// is11Sensor->SensorInfo.a1 = -1.08988798e-09;
|
||||
// is11Sensor->SensorInfo.a2 = -5.32620063e-05;
|
||||
// is11Sensor->SensorInfo.a3 = 0.441532;
|
||||
// is11Sensor->SensorInfo.a4 = 348.5026;
|
||||
// }
|
||||
|
||||
|
||||
Serial.println("IS_SN :" +STRSensorInfos_structure.serialnumber);
|
||||
|
||||
// is11Sensor->guangpu_bochang.a1 = 0.000000000000000;
|
||||
// is11Sensor->guangpu_bochang.a2 = 0.000000000;
|
||||
|
||||
sys_sd_doc["firmware"] = "V2.0.5";
|
||||
sys_sd_doc["version"] = "V2.0.5";
|
||||
sys_info_init();
|
||||
sys_sd_doc["firmware"] = "V2.0.4";
|
||||
|
||||
// dingbiao_init("/dingbiao/dingbiao_up_gain.bin");
|
||||
// dingbiao_init("/dingbiao/dingbiao_up_offset.bin");
|
||||
// dingbiao_init("/dingbiao/dingbiao_down_gain.bin");
|
||||
@ -310,7 +322,7 @@ void setup()
|
||||
|
||||
if(is11Sensor->guangpu_bochang.b3 < 100)
|
||||
{
|
||||
// write_log(log_path,"guangpu_bochang.b3 < 100",10);
|
||||
write_log(log_path,"guangpu_bochang.b3 false",10);
|
||||
is11Sensor->guangpu_bochang.is_valid = false;
|
||||
is11Sensor->guangpu_bochang.a0 = is11Sensor->SensorInfo.a1;
|
||||
is11Sensor->guangpu_bochang.a1 = is11Sensor->SensorInfo.a2;
|
||||
@ -327,11 +339,10 @@ void setup()
|
||||
sys_sd_doc["bochangxishu"]["a2"] = is11Sensor->guangpu_bochang.a2;
|
||||
sys_sd_doc["bochangxishu"]["a3"] = is11Sensor->guangpu_bochang.a3;
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// write_log(log_path,"guangpu_bochang.b3 >= 100",10);
|
||||
write_log(log_path,"guangpu_bochang.b3 true",10);
|
||||
is11Sensor->guangpu_bochang.is_valid = true;
|
||||
is11Sensor->SensorInfo.a1 = is11Sensor->guangpu_bochang.a0;
|
||||
is11Sensor->SensorInfo.a2 = is11Sensor->guangpu_bochang.a1;
|
||||
@ -619,14 +630,17 @@ void Task1(void *pvParameters)
|
||||
|
||||
// 推杆
|
||||
// 日出日落控制 太阳升起前推杆缩,太阳落下后推杆伸
|
||||
double transit, sunrise, sunset;
|
||||
double transit,sunrise_l,sunset_l;
|
||||
double utc_offset = 8;
|
||||
float tuisuotime = now.hour *100 + now.minute;
|
||||
tuisuotime = tuisuotime /100;
|
||||
calcSunriseSunset(now.year+2000,now.month,now.day,sun_latitude,sun_longitude, transit, sunrise, sunset);
|
||||
calcSunriseSunset(now.year+2000,now.month,now.day,sun_latitude,sun_longitude, transit, sunrise_l, sunset_l);
|
||||
|
||||
sunrise += utc_offset;
|
||||
sunset += utc_offset;
|
||||
sunrise_l += utc_offset;
|
||||
sunset_l += utc_offset;
|
||||
|
||||
sunrise = sunrise_l;
|
||||
sunset = sunset_l;
|
||||
|
||||
write_log(log_path,"now.hour: " + String(now.hour),log_level);
|
||||
write_log(log_path,"sunrise: " + String((int)sunrise),log_level);
|
||||
@ -901,6 +915,9 @@ void task_4G_mode(void *pvParameters)
|
||||
{
|
||||
sun_latitude = gps_structure.latitude;
|
||||
sun_longitude = gps_structure.longitude;
|
||||
|
||||
sys_sd_doc["gps_info"]["latitude"] = sun_latitude;
|
||||
sys_sd_doc["gps_info"]["longitude"] = sun_longitude;
|
||||
xSemaphoreGive(xMutexInventory);
|
||||
}
|
||||
|
||||
@ -927,7 +944,22 @@ void task_4G_mode(void *pvParameters)
|
||||
//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))
|
||||
float start = 7;
|
||||
float stop = 19;
|
||||
if(sys_sd_doc["work_time"] = "gps")
|
||||
{
|
||||
start = sunrise;
|
||||
stop = sunset;
|
||||
write_log(log_path,"work_time gps",10);
|
||||
}
|
||||
else if(sys_sd_doc["work_time"] = "manual")
|
||||
{
|
||||
start = start_time;
|
||||
stop = stop_time;
|
||||
write_log(log_path,"manual",10);
|
||||
}
|
||||
|
||||
if((now_time >= start) && (now_time < stop))
|
||||
{
|
||||
is11Sensor->TakeOneJob();
|
||||
is11Sensor->get_fanshelv();
|
||||
@ -993,15 +1025,16 @@ void OTA_task(void *pvParameters)
|
||||
while (1)
|
||||
{
|
||||
xEventGroupWaitBits(Main_EventGroup, OTA_BIT, pdTRUE, pdFALSE, portMAX_DELAY);
|
||||
write_log(log_path,"ota start",10);
|
||||
vTaskDelay(100);
|
||||
vTaskSuspend(Task0_Handler);
|
||||
vTaskSuspend(Task1_Handler);
|
||||
// vTaskSuspend(Task0_Handler);
|
||||
// vTaskSuspend(Task1_Handler);
|
||||
|
||||
vTaskSuspend(A4G_Handler);
|
||||
|
||||
String url = sys_sd_doc["version_url"];
|
||||
String MD5 = sys_sd_doc["MD5"];
|
||||
write_log(log_path,"ota start",10);
|
||||
// write_log(log_path,"ota start",10);
|
||||
write_log(log_path,"ota url: " + url,10);
|
||||
write_log(log_path,"ota MD5: " + MD5,10);
|
||||
http_OTA(url, MD5);
|
||||
@ -2501,6 +2534,17 @@ void json_command(uint8_t port_type)
|
||||
else if(port_type == 2) mqtt_write(send_buff,ret);
|
||||
esp_restart();
|
||||
}
|
||||
else if(doc["command"] == "set_work_time")
|
||||
{
|
||||
save = true;
|
||||
sys_sd_doc["work_time"] = doc["work_time"];
|
||||
send_str = "";
|
||||
doc["state"] = "success";
|
||||
serializeJson(doc, send_str);
|
||||
ret = IRIS_Protocol_Pack(0x00,(uint16_t)send_str.length(), (uint8_t *)send_str.c_str(),send_buff);
|
||||
if(port_type == 1) wb485Serial.write(send_buff,ret);
|
||||
else if(port_type == 2) mqtt_write(send_buff,ret);
|
||||
}
|
||||
//command error
|
||||
else
|
||||
{
|
||||
@ -2554,7 +2598,7 @@ void sys_info_init()
|
||||
sys_sd_doc["sensor_type"] = "IRIS-IS11";
|
||||
sys_sd_doc["serialnumber"] = STRSensorInfos_structure.serialnumber;
|
||||
// sys_sd_doc["serialnumber"] = "is110008";
|
||||
sys_sd_doc["version"] = doc["version"].as<String>();
|
||||
// sys_sd_doc["version"] = doc["version"].as<String>();
|
||||
sys_sd_doc["date"] = rtcdate_now;
|
||||
|
||||
sys_sd_doc["status_4g"] = doc["status_4g"].as<String>();
|
||||
@ -2676,8 +2720,10 @@ void sys_info_init()
|
||||
{
|
||||
atuo_return = 0;
|
||||
}
|
||||
sys_sd_doc["gps_info"]["latitude"] = gps_structure.latitude;
|
||||
sys_sd_doc["gps_info"]["longitude"] = gps_structure.longitude;
|
||||
sys_sd_doc["gps_info"]["latitude"] = sun_latitude;
|
||||
sys_sd_doc["gps_info"]["longitude"] = sun_longitude;
|
||||
sys_sd_doc["work_time"] = doc["work_time"];
|
||||
|
||||
|
||||
system_info = "";
|
||||
serializeJson(sys_sd_doc, system_info);
|
||||
@ -2717,6 +2763,7 @@ void sys_info_init()
|
||||
sys_sd_doc["atuo_return"] = "no";
|
||||
sys_sd_doc["gps_info"]["latitude"] = gps_structure.latitude;
|
||||
sys_sd_doc["gps_info"]["longitude"] = gps_structure.longitude;
|
||||
sys_sd_doc["work_time"] = "manual";
|
||||
|
||||
serializeJson(sys_sd_doc, system_info);
|
||||
write_log(log_path, system_info,log_level);
|
||||
|
||||
Reference in New Issue
Block a user