#include"SensorIS11.h" #include "iostream" #ifdef _WIN32 #include #else #include #include #endif bool SensorIS11::initSensor(int id) { DataRetrun=GetDataBufferPTR(); // IS1Sensor.SetPortName(id); SensorInfo=GetSensorInfo(); // pinMode(22,OUTPUT); // pinMode(23,OUTPUT); return true; } STRSensorInfo SensorIS11::GetSensorInfo() { STRSensorInfo setem; if (!isSensorInit()) { return setem; } int retlenth= SendGetSensorInfo((u_char *)GET_SERIAL_NUMBER,sizeof(GET_SERIAL_NUMBER)); char * result=new char[5]; memcpy(result,DataRetrun+3,4); result[4]='\0'; std::cout<maxvalue) { if (maxvaluenow > maxvalue) { shutternow = shutternow *0.7; } else { shutternow = maxvalue * 0.98 / (maxvaluenow * 1.0)*shutternow + 1; } if (shutternow > maxtime) { shutternow = maxtime; break; } GetOneDate(shutternow); maxvaluenow= Getmaxvalue(DATABUFF, SensorInfo.BandNum); #ifdef ARDUINO Serial.print("now Shutter is :"); Serial.print(shutternow); Serial.print(" maxvalue is :"); Serial.println(maxvaluenow); #else std::cout<<"now Shutter is :"< 200) { return maxtime; } if (shutternow == maxtime) { return maxtime; } } #ifdef ARDUINO Serial.print("zi dong value:"); Serial.println(shutternow); #endif if (shutternow<0) { shutternow=maxtime; /* code */ } return shutternow; } void SensorIS11::shortLittletoBiG(unsigned short *data,int lenth) { CoverLittleAndBig((char *)data,lenth); } int SensorIS11::Getmaxvalue(unsigned short *data,int lenth) { int ret=-1; for (int i = 0; i < lenth; ++i) { if (data[i]>ret){ ret=data[i]; } } return ret; } void SensorIS11::TakeOneJob() { SetShutter(1); int shutter=OptSnenser(90); shutterup=shutter; GetOneDate(shutter); // Serial.println("Finish Up ------Green2313123"); if (UpData==nullptr) { UpData=new unsigned short[SensorInfo.BandNum*2]; /* code */ } memcpy(UpData,DATABUFF,SensorInfo.BandNum*2); SetShutter(0); GetOneDate(shutter); for (int i = 0; i < SensorInfo.BandNum; ++i) { // UpData[i]=UpData[i]-DATABUFF[i]; } shutterup=shutter; bool dingbing=false; #ifdef DINBIAO String strout="1 shutteruo is "+String(shutterup)+" Finish Up ------Green change the fiber"; PrintFunc(strout ); digitalWrite(21, LOW); delay(60000); SensorInfo.SensorName=SensorInfo.SensorName+"cali"; Serial.println("begindown"); digitalWrite(21, HIGH); #endif SetShutter(2); shutter=OptSnenser(90); shutterdown=shutter; GetOneDate(shutter); if (DownData==nullptr) { DownData=new unsigned short[SensorInfo.BandNum*2]; /* code */ } memcpy(DownData,DATABUFF,SensorInfo.BandNum*2); SetShutter(0); GetOneDate(shutter); for (int i = 0; i < SensorInfo.BandNum; ++i) { // DownData[i]=DownData[i]-DATABUFF[i]; } shutterdown=shutter; #ifdef DINBIAO String strout1="2 shutterdown is "+String(shutterdown)+" Down Finish ------Blue"; PrintFunc(strout1 ); #endif } SensorIS11::SensorIS11() { shutternow=0; // DataRetrun=GetDataBufferPTR(); }