adfasdfa
This commit is contained in:
@ -96,11 +96,11 @@ size_t SendGetData(int shutter)
|
||||
SerialWrite(BufferFortempWrite, lenthforwrite);
|
||||
for (int i=0;i<10;i++)
|
||||
{
|
||||
size_t retunnumber = GetInfoBackFromSensorinTime(GET_DATA_FROM_SENSOR,shutter+2000);
|
||||
if (retunnumber!=OVERTIME ) {
|
||||
size_t retunnumber = GetInfoBackFromSensorinTime(GET_DATA_FROM_SENSOR,2*shutter+2000);
|
||||
if (retunnumber<OVERTIME) {
|
||||
return retunnumber;
|
||||
}
|
||||
if (i%2==0) {
|
||||
if (i%5==0) {
|
||||
printf("send command again\n");
|
||||
SerialWrite(BufferFortempWrite, lenthforwrite);
|
||||
|
||||
@ -196,7 +196,7 @@ size_t GetInfoBackFromSensor(uint8_t Command) // big
|
||||
|
||||
size_t GetInfoBackFromSensorinTime(uint8_t Command,uint32_t waittime) // big <20><>ָ<EFBFBD>ü<EFBFBD><C3BC><EFBFBD><EFBFBD>ֽڱ<D6BD>ʾ<EFBFBD><CABE><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD> <20><>ʱֻ<CAB1><D6BB><EFBFBD>ֲɼ<D6B2><C9BC><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>
|
||||
{
|
||||
delay(1);
|
||||
delay(1);
|
||||
//<2F><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
size_t begintime= get_system_uptime_ms();
|
||||
|
||||
@ -227,6 +227,11 @@ size_t GetInfoBackFromSensorinTime(uint8_t Command,uint32_t waittime) // big
|
||||
// delay(1000);
|
||||
// }
|
||||
}
|
||||
if (BufferForRead[2]==0x40) {
|
||||
printf("warning: sensor busy\n");
|
||||
return SENSORBUSY;
|
||||
|
||||
}
|
||||
int lenth = BufferForRead[3] * 256 + BufferForRead[4];
|
||||
while (TotalIndexNow < lenth + 7)
|
||||
{
|
||||
|
@ -19,6 +19,7 @@
|
||||
#define COMMAND_MULTSET 0x10
|
||||
#define POLYNOMIAL 0xa001 //modbus crc
|
||||
#define OVERTIME 1000000000
|
||||
#define SENSORBUSY 1000000000
|
||||
#include "comon.h"
|
||||
|
||||
|
||||
|
@ -71,4 +71,10 @@ int IS3GetData(uint16_t *outdata, int shuttertime) {
|
||||
// printf("a[0]=%f\n",a[0]);
|
||||
thissensorIS3->SetWeaveLenthCoeff(a,lenth);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void IS3SetShutterOpen(int isopen) {
|
||||
thissensorIS3->SetShutter(isopen);
|
||||
// printf("IS3SetShutterOpen\n");
|
||||
// printf("isopen=%d\n",isopen);
|
||||
}
|
@ -26,7 +26,7 @@ __declspec(dllexport) STRsensorinfo_C IS3Get_SensorInfo();
|
||||
__declspec(dllexport) int IS3OptSnenser(int percent);
|
||||
__declspec(dllexport) int IS3GetData(uint16_t *outdata,int shuttertime);
|
||||
__declspec(dllexport) int IS3SetWeaveLenthCoeff(double *a,int lenth);
|
||||
|
||||
__declspec(dllexport) void IS3SetShutterOpen(int isopen);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -145,6 +145,23 @@ void SensorIS3::SetShutter(int id)
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
switch (id) {
|
||||
|
||||
case 0: {
|
||||
u_char a=1;
|
||||
SendSettingCommand(SET_SHUTTER_CLOSE,1, &a, 1);
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
u_char a=1;
|
||||
//SendSettingCommand(SET_SHUTTER_CLOSE,1, &a, 1);
|
||||
SendSettingCommand(SET_SHUTTER_OPEN,1, &a, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -188,6 +205,7 @@ void SensorIS3::GetOneDate(int msc)
|
||||
}
|
||||
shutternow=msc;
|
||||
size_t retsize= SendGetData(shutternow);
|
||||
|
||||
memcpy(DATABUFF,DataRetrun,515*2);
|
||||
//shortLittletoBiG(DATABUFF, SensorInfo.BandNum*2);
|
||||
|
||||
@ -198,7 +216,7 @@ void SensorIS3::GetOneDate(int msc)
|
||||
|
||||
int SensorIS3::OptSnenser(int persent)
|
||||
{
|
||||
|
||||
long minshuttertime=12;
|
||||
long maxtime = 10000;
|
||||
int maxvalue=SensorInfo.maxValue*1.0*persent / 100;
|
||||
int maxvaluenow = 0;
|
||||
@ -208,6 +226,7 @@ int SensorIS3::OptSnenser(int persent)
|
||||
|
||||
int numberoftry = 0;
|
||||
while (maxvaluenow<maxvalue*0.95 || maxvaluenow>maxvalue) {
|
||||
|
||||
if (maxvaluenow > maxvalue)
|
||||
{
|
||||
shutternow = shutternow *0.7;
|
||||
@ -225,6 +244,11 @@ int SensorIS3::OptSnenser(int persent)
|
||||
shutternow = maxtime;
|
||||
break;
|
||||
}
|
||||
if (shutternow < minshuttertime)
|
||||
{
|
||||
shutternow = minshuttertime;
|
||||
break;
|
||||
}
|
||||
GetOneDate(shutternow);
|
||||
maxvaluenow= Getmaxvalue(DATABUFF, SensorInfo.BandNum);
|
||||
#ifdef ARDUINO
|
||||
|
Reference in New Issue
Block a user