void ReturnTemperature(int SensorType, unsigned char bitmap) { if (SensorType == 0) //no sensor detected, return FFFB { // putch(0xFF); // putch(0xFB); __delay_ms(10); onewire_sendpacket(0x00,0x10,0xFF); __delay_ms(10); onewire_sendpacket(0x00,0x10,0xFB); } else if (SensorType == 1) //return value from DHT22 { int temperature = GetTemperature(bitmap); if (temperature == 0xFFFE) //check for timeout and try again { temperature = GetTemperature(bitmap); } // putch(temperature >> 8); // putch(temperature); __delay_ms(10); onewire_sendpacket(0x00,0x10,temperature >> 8); __delay_ms(10); onewire_sendpacket(0x00,0x10,temperature); }
bool ANDOR885_Camera::deviceExit() { int errorValue; bool error = false; int temp; //Stop Acquisition; ignore errors AbortIfAcquiring(); //CloseShutter shutterMode = SHUTTERMODE_CLOSE; errorValue = SetShutter(ttl,shutterMode,closeTime,openTime); printError(errorValue, "Shutter error", &error, ANDOR_ERROR); int i = -1; errorValue = IsCoolerOn(&i); printError(errorValue, "Error determing cooler status", &error, ANDOR_ERROR); if (!error) { if (i == 1) { GetTemperature(&temp); if(temp < 5) { coolerSetpt = 10; } errorValue = SetTemperature(coolerSetpt); printError(errorValue, "Error setting cooler temperature", &error, ANDOR_ERROR); } if (!error) { GetTemperature(&temp); while(temp < 5) { std::cerr << "Camera temperature rising...: " << temp << " deg C" << std::endl; Sleep(2000); GetTemperature(&temp); } } if (i == 1){ errorValue=CoolerOFF(); // Switch off cooler (if used) printError(errorValue, "Error switching cooler off", &error, ANDOR_ERROR); if (!error) { coolerStat = ANDOR_OFF; } } } errorValue = ShutDown(); printError(errorValue, "Error shutting down", &error, ANDOR_ERROR); std::cerr << "Shutting down..." << std::endl; initialized = false; return error; }
int ANDOR885_Camera::getCameraTemp() throw(std::exception) { int temp = -999; int errorValue; errorValue = GetTemperature(&temp); switch(errorValue){ case DRV_SUCCESS: case DRV_ACQUIRING: case DRV_TEMP_STABILIZED: case DRV_TEMP_NOT_REACHED: case DRV_TEMP_NOT_STABILIZED: case DRV_TEMP_OFF: cameraTemp = temp; break; case DRV_TEMP_DRIFT: cameraTemp = temp; std::cerr << "Cooler temp is " << temp << " deg C" << std::endl; std::cerr << "Cooler temperature has drifted. Try resetting setpoint" << std::endl; break; default: throw ANDOR885_Exception("Error getting temperature: ANDOR error code is " + STI::Utils::valueToString(errorValue)); break; } return cameraTemp; }
void ControlLine::QueryState() { switch (m_mode) { case DigitalInput: m_state = digitalRead(m_pin); break; //case DigitalOutput: // m_state[0] = RELAY_ACTIVE_LEVEL ? digitalRead(m_pin) : !digitalRead(m_pin); // break; case AnalogInput: // transistor: 524 for water; 838 for short circuit; (100/100/KT3102) // Yusupov: ~650 for water; ~1000 for short circuit; ~1 for air; (2k / 100k) //m_state = analogRead(m_pin); GetPh(); break; //case PWM: // m_state[0] = EEPROM.read(EEPROM_OFFSET + m_idx); // break; case OneWireBus: GetTemperature(); break; //case Ph: // GetPh(); // break; default: break; } }
AtmosphericData Atmosphere::GetAtmosphericData(F32 altitude) { AtmosphericData data; data.temperature = GetTemperature(altitude); data.soundSpeed = GetSoundSpeed(altitude); return data; }
void FGAtmosphere::Calculate(double altitude) { FGPropertyNode* node = PropertyManager->GetNode(); if (!PropertyManager->HasNode("atmosphere/override/temperature")) Temperature = GetTemperature(altitude); else Temperature = node->GetDouble("atmosphere/override/temperature"); if (!PropertyManager->HasNode("atmosphere/override/pressure")) Pressure = GetPressure(altitude); else Pressure = node->GetDouble("atmosphere/override/pressure"); if (!PropertyManager->HasNode("atmosphere/override/density")) Density = Pressure/(Reng*Temperature); else Density = node->GetDouble("atmosphere/override/density"); Soundspeed = sqrt(SHRatio*Reng*(Temperature)); PressureAltitude = altitude; DensityAltitude = altitude; Viscosity = Beta * pow(Temperature, 1.5) / (SutherlandConstant + Temperature); KinematicViscosity = Viscosity / Density; }
double FGStandardAtmosphere::GetDensity(double altitude) const { double P = GetPressure(altitude); double Pa = P - VaporPressure; // Partial pressure of air return (Pa/Reng + Mwater*VaporPressure/Rstar)/GetTemperature(altitude); }
double FGStandardAtmosphere::GetPressure(double altitude) const { double GeoPotAlt = GeopotentialAltitude(altitude); // Iterate through the altitudes to find the current Base Altitude // in the table. That is, if the current altitude (the argument passed in) // is 20000 ft, then the base altitude from the table is 0.0. If the // passed-in altitude is 40000 ft, the base altitude is 36089.2388 ft (and // the index "b" is 2 - the second entry in the table). double BaseAlt = StdAtmosTemperatureTable(1,0); unsigned int numRows = StdAtmosTemperatureTable.GetNumRows(); unsigned int b; for (b=0; b < numRows-2; ++b) { double testAlt = StdAtmosTemperatureTable(b+2,0); if (GeoPotAlt < testAlt) break; BaseAlt = testAlt; } double Tmb = GetTemperature(GeometricAltitude(BaseAlt)); double deltaH = GeoPotAlt - BaseAlt; double Lmb = LapseRates[b]; if (Lmb != 0.0) { double Exp = g0*Mair / (Rstar*Lmb); double factor = Tmb/(Tmb + Lmb*deltaH); return PressureBreakpoints[b]*pow(factor, Exp); } else return PressureBreakpoints[b]*exp(-g0*Mair*deltaH/(Rstar*Tmb)); }
/**************************************************************** CALL: Pressure_Init() INTRO: This routine initializes the Bosch BMP183 pressure sensor. INPUT: nothing OUTPUT: nothing ****************************************************************/ void Pressure_Init( void ) { int iErr; short tempC; BYTE b; // If set to 0xB6, will perform the same sequence as power on reset. //b = 0xB6; //I2C_WriteData( SLAVE_ADDR_BMP180, BMPREG_SOFT_RESET, 1, &b); /*---- verify that pressure sensor can be read ----*/ iErr = i2c_read( SLAVE_ADDR_BMP180, BMPREG_ID, 1, &b ); if( iErr || (b != 0x55) ) { /*---- indicate an error in the status ----*/ if( status.Error[ERROR_PRESSURE] < 255 ) { status.Error[ERROR_PRESSURE]++; } } #ifdef CJC_HACK /*---- configure oversampling rate ----*/ s_oversampling_setting = Oversample_Off; // 0x00; /*---- read all calibration parameters ----*/ iErr = read_calibration(); if( iErr == 0x0) { /*---- make sure to read temp first to initialize temp variable used in pressure calibration ----*/ GetTemperature(&tempC); tempC = (tempC + 5)/ 10; // Round } #endif }
void ProcessClientMessage(){ // listen for incoming clients EthernetClient client = GetAvailableClient(); if (client) { // an http request ends with a blank line boolean currentLineIsBlank = true; while (client.connected()) { if (client.available()) { char c = client.read(); // if you've gotten to the end of the line (received a newline // character) and the line is blank, the http request has ended, // so you can send a reply if (c == '\n' && currentLineIsBlank) { //Magnetic;Noise;Temperature;Vibration;Voltage String data = ""; data += String(GetMagnetic()); data += ";"; data += String(GetTemperature()); data += ";"; data += String(GetVibration()); data += ";"; data += String(GetVoltage()); client.println(data); break; } if (c == '\n') { // you're starting a new line currentLineIsBlank = true; } else if (c != '\r') { // you've gotten a character on the current line currentLineIsBlank = false; } } } // give the web browser time to receive the data delay(10); // close the connection: client.stop(); } }
static gboolean voGetTemperature(gpointer data) { double temperature; char temp[30]; temperature = GetTemperature(); sprintf(temp, "Temperature: %.2f°C", temperature); gtk_label_set_text(GTK_LABEL(data), temp); return 1; }
void FGStandardAtmosphere::SetTemperatureBias(eTemperature unit, double t) { if (unit == eCelsius || unit == eKelvin) t *= 1.80; // If temp delta "t" is given in metric, scale up to English TemperatureBias = t; CalculatePressureBreakpoints(); SLtemperature = GetTemperature(0.0); CalculateSLSoundSpeedAndDensity(); }
/**************************************************************** CALL: Pressure_Update() INTRO: Update (Refresh) Sensor Readings ****************************************************************/ void Pressure_Update() { long pressure = 0L; short tempC = 0; s_dataTable[Pressure_Time]++; // Simple counter for now. if( GetPressure(&pressure) == 0x0 ) s_dataTable[Pressure_Pressure] = (int)pressure; if( GetTemperature(&tempC) == 0x0 ) s_dataTable[Pressure_Temperature] = (int)tempC; }
void GridManager::AddBox(Vector2d p, Vector2d size, GridBox* box) { if(box == nullptr) { std::cout << "[GridManager::AddBox] Cannot add null box." << std::endl; return; } CellConfig def_config; def_config.pressure = GetPressure(); def_config.T = GetTemperature(); def_config.boundary_T = GetTemperature(); Vector2d& cell_size = Config::vCellSize; box->p = Vector2i(p.x() / cell_size.x(), p.y() / cell_size.y()); box->size = Vector2i(size.x() / cell_size.x(), size.y() / cell_size.y()); box->def_config = def_config; boxes_stack_.push_back(box); }
unsigned char IdentifySensor(unsigned char bitmap) { if (GetTemperature(bitmap) == 65534) //check for DHT22 { if (ds_gettemperature(bitmap) == 65534)//check for ds18b20 return 0; //no sensor detected else return 2; //ds18b20 detected } else return 1; //DHT22 detected }
void FGStandardAtmosphere::SetTemperatureGradedDelta(double deltemp, double h, eTemperature unit) { if (unit == eCelsius || unit == eKelvin) deltemp *= 1.80; // If temp delta "t" is given in metric, scale up to English TemperatureDeltaGradient = deltemp/(GradientFadeoutAltitude - GeopotentialAltitude(h)); CalculateLapseRates(); CalculatePressureBreakpoints(); SLtemperature = GetTemperature(0.0); CalculateSLSoundSpeedAndDensity(); }
void FGAtmosphere::Calculate(double altitude) { Temperature = GetTemperature(altitude); Pressure = GetPressure(altitude); Density = Pressure/(Reng*Temperature); Soundspeed = sqrt(SHRatio*Reng*(Temperature)); PressureAltitude = altitude; DensityAltitude = altitude; Viscosity = Beta * pow(Temperature, 1.5) / (SutherlandConstant + Temperature); KinematicViscosity = Viscosity / Density; }
// // Get temperature reading. // // returns the temperature from one DS18S20 in DEG Celsius // float OS_DS18S20::GetCalculatedTemperature() { unsigned short rawValue = GetTemperature(); if (rawValue == 0) { return (float)0; } float tempRead = rawValue; //using two's compliment float TemperatureSum = tempRead / 16; return TemperatureSum; }
void FGStandardAtmosphere::SetTemperature(double t, double h, eTemperature unit) { double targetTemp = ConvertToRankine(t, unit); double GeoPotAlt = GeopotentialAltitude(h); TemperatureBias = targetTemp - GetStdTemperature(h); if (GeoPotAlt <= GradientFadeoutAltitude) TemperatureBias -= TemperatureDeltaGradient * (GradientFadeoutAltitude - GeoPotAlt); CalculatePressureBreakpoints(); SLtemperature = GetTemperature(0.0); CalculateSLSoundSpeedAndDensity(); }
void Temperature_main(void) { char t_value; char t_string[4]; TopDisp = 13; ClearScreen(); Page0Display(); Print(6,20,"ESC to Exit",1); while(TRUE) { t_value = GetTemperature(); sprintf(t_string, (char*)"%dC", (INT8)t_value); Print(3,52,(INT8U*)t_string,1); if(ScanKey() == K_CANCEL) { TopDisp = 12; //´«¸Ð²Ëµ¥ return; } } }
static int gpu_throttle_notifier_call(struct notifier_block *nfb, unsigned long mode, void *cmd) { int retval = NOTIFY_DONE, i = 0; if(private_data.tempctrl_data.temp_ctrl_status == 0) { long temperature = GetTemperature(); if(temperature > tf_table[0].temp) { for(i = private_data.tempctrl_data.count - 1; i >= 0; i--) { if(temperature >= tf_table[i].temp) { DvfsChange(tf_table[i].freq); private_data.max_freq = tf_table[i].freq; break; } } } } return retval; }
double FGAtmosphere::GetDensity(double altitude) const { return GetPressure(altitude)/(Reng * GetTemperature(altitude)); }
// In meters/second F32 Atmosphere::GetSoundSpeed(F32 altitude) { assert(altitude <= m_tempStepAltitudes[m_tempStepAltitudes.size() - 1]); return GetTemperature(altitude) + m_tempSoundOffset; }
void Board_main(void) { uint8_t i; uint16_t flash_flag = 0; uint16_t copy_file_flag = 0; /* RCC system reset(for debug purpose) */ RCC_DeInit(); /* Enable HSE */ RCC_HSEConfig(RCC_HSE_ON); /* Wait till HSE is ready */ HSEStartUpStatus = RCC_WaitForHSEStartUp(); if(HSEStartUpStatus == SUCCESS) { #if 0 /* Enable Prefetch Buffer */ FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable); FLASH_HalfCycleAccessCmd(FLASH_HalfCycleAccess_Disable); /* Flash 2 wait state */ FLASH_SetLatency(FLASH_Latency_2); #else FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable); FLASH_HalfCycleAccessCmd(FLASH_HalfCycleAccess_Enable); /* Flash 2 wait state */ /*FLASH_SetLatency(FLASH_Latency_2);*/ FLASH_SetLatency(FLASH_Latency_0); /*abin@ */ #endif /* HCLK = SYSCLK */ RCC_HCLKConfig(RCC_SYSCLK_Div1); /* PCLK2 = HCLK */ RCC_PCLK2Config(RCC_HCLK_Div1); /* PCLK1 = HCLK/2 */ RCC_PCLK1Config(RCC_HCLK_Div2); #if 0 /* PLLCLK = 8MHz * 9 = 72 MHz */ /*abin:note*/ RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9); // RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_8); /* Enable PLL */ RCC_PLLCmd(ENABLE); /* Wait till PLL is ready */ while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET) { } /* Select PLL as system clock source */ RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK); /* Wait till PLL is used as system clock source */ while(RCC_GetSYSCLKSource() != 0x08) { } #else RCC_PLLCmd(DISABLE); /* Select HSE as system clock source */ RCC_SYSCLKConfig(RCC_SYSCLKSource_HSE); /* Wait till PLL is used as system clock source */ while(RCC_GetSYSCLKSource() != 0x04) { } #endif } /* Enable GPIOA, GPIOB, and AFIO clocks */ RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA |RCC_APB2Periph_GPIOB| RCC_APB2Periph_AFIO, ENABLE); /* Enable DMA1 ,DMA2 clock */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1|RCC_AHBPeriph_DMA2, ENABLE); /* Enable ADC1 ADC2,and GPIOC clock */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1 |RCC_APB2Periph_ADC2| RCC_APB2Periph_GPIOC, ENABLE); /* Enable PWR and BKP clock */ RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE); /* Enable write access to Backup domain */ PWR_BackupAccessCmd(ENABLE); /* Clear Tamper pin Event(TE) pending flag */ BKP_ClearFlag(); #if ABIN_DEBUG USART_InitStructure.USART_BaudRate = 115200; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_No; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; STM_EVAL_COMInit(COM1, &USART_InitStructure); /* Output a message on Hyperterminal using printf function */ //sys_printf("\n\r abin 8M is ok moify flash latency :USART Init end \n\r"); #endif /*------------------- Resources Initialization -----------------------------*/ /* GPIO Configuration */ GPIO_Config(); //sys_printf("\n\r abin mul2 :GPIO_Config \n\r"); #if ABIN_CPU_UPGRADE2HIGHSPEED_OPTION USB_Plugin_State = GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_14); if(USB_Plugin_State == 1) { //sys_printf("\n\r abin switch to high speed !!\n\r"); UpgradeToHighSpeed(); } #endif /* Interrupt Configuration */ InterruptConfig(); /* Configure the systick */ SysTick_Configuration(); /*------------------- Drivers Initialization -------------------------------*/ /* Initialize the Low Power application */ LowPower_Init(); /* Enable WKUP pin */ PWR_WakeUpPinCmd(ENABLE); /* Allow access to BKP Domain */ PWR_BackupAccessCmd(ENABLE); RTC_Init(); /* If HSE is not detected at program startup */ if(HSEStartUpStatus == ERROR) { /* Generate NMI exception */ SCB->ICSR |= SCB_ICSR_NMIPENDSET; } USB_Disconnect_Config(); GPIO_SetBits(USB_DISCONNECT, USB_DISCONNECT_PIN);/*???abin@20100714*/ WakupPin_Init(); //sys_printf("\n\r abin before CheckPowerOnReason\n\r"); CheckPowerOnReason(); //sys_printf("\n\r abin after CheckPowerOnReason\n\r"); Board_ADC_Init(); /*init the flag*/ flash_flag = *(uint16_t *)FLASH_READY_ADDRESS; if( flash_flag != FLAG_FLASH_READY) { //sys_printf("\n\r abin ready to erase flash \n\r"); FLASH_Unlock(); FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR); //Erase the 32 page 32K for(i = 0;i< DATA_PAGES;i++) { //sys_printf("\n\r abin ready to erase aa"); FLASH_ErasePage(DATA_LOGGER_ADDRESS_START + i * 1024);/*数据在Page1...page32存放*/ } FLASH_ErasePage(FLASH_READY_ADDRESS); /*abin@20100715 没添加保护*/ FLASH_ProgramHalfWord(FLASH_READY_ADDRESS , FLAG_FLASH_READY); FLASH_ErasePage(REOCRD_COUNT_ADDRESS); FLASH_ProgramHalfWord(REOCRD_COUNT_ADDRESS , 0x0000); FLASH_Lock(); //sys_printf("\n\r abin mul2 :erase flash end!!!\n\r"); } //sys_printf("\n\r abin ready to erase flash end \n\r"); USB_Plugin_State = GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_14); if(USB_Plugin_State == 0) { record_count = *(uint16_t *)REOCRD_COUNT_ADDRESS; if(record_count >= 15428) { //Write the full flag //Do nothing.... while(1) { //sys_printf("\n\r sample end !!!!!!!!!!!!!!!!!!!!!\n\r"); Led_One_By_One(4); /*应该进入standy 模式 abin@20100715*/ } } else { //sys_printf("\n\r abin ready to add sample count \n\r"); FLASH_Unlock(); FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR); FLASH_ProgramHalfWord(DATA_LOGGER_ADDRESS_START + record_count * 2, GetTemperature()); //Erase first FLASH_ErasePage(REOCRD_COUNT_ADDRESS); //Update the count record_count = record_count + 1; FLASH_ProgramHalfWord(REOCRD_COUNT_ADDRESS , record_count); FLASH_Lock(); //sys_printf("\n\r abin add sample count :end\n\r"); } //sys_printf("\n\r %000\n\r"); GPIO_SetBits(GPIOA, GPIO_Pin_1); #if 0 Delay(25); #else Delay(5); #endif //sys_printf("\n\r %111\n\r"); } else { Enable_SDcard(); /* if there is usb connect, copy the data to sdcard. and start the mass storage */ copy_file_flag = *(uint16_t *)COPY_FILE_ADDRESS; if(copy_file_flag == FLAG_FILE_COPYED) { Write_Copy_File_Flag(FLAG_FILE_NO_COPYED); USB_Disconnect_Config(); GPIO_SetBits(USB_DISCONNECT, USB_DISCONNECT_PIN); Delay(10); GPIO_ResetBits(USB_DISCONNECT, USB_DISCONNECT_PIN); /* Enable and GPIOD clock */ Mass_Storage_Start (); while( bDeviceState != CONFIGURED) { Led_Both(1); } USB_Plugin_State = GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_14); while( USB_Plugin_State == 1)/* U-DISK success ,then CPU Loop in here*/ { USB_Plugin_State = GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_14); Led_One_By_One(1); //sys_printf("\n\r abin :mul2 u disk !!!\n\r"); } PowerOff(); Write_Copy_File_Flag(FLAG_FILE_NO_COPYED); } else { Write_Copy_File_Flag(FLAG_FILE_COPYED); Led_Green_Flink(3); NAND_FAT(); CreateDataLoggerFile(); Write_Copy_File_Flag(FLAG_FILE_COPYED); //sys_printf("\n\r abin :mul2 NAND_FAT!!!\n\r"); } //sys_printf("\n\r abin :mul2 Disable_SDcard!!!\n\r"); Disable_SDcard(); BKP_WriteBackupRegister(BKP_POWER_ON, FLAG_POWER_OFF); PWR_EnterSTANDBYMode(); /* Generate a system reset */ //NVIC_SystemReset(); } //sys_printf("\n\r @111 \n\r"); /* Set the RTC Alarm after 60s */ RTC_SetAlarm(RTC_GetCounter()+ 3); //sys_printf("\n\r @222:RTC_GetCounter()=0x%x \n\r",RTC_GetCounter()); /* Wait until last write operation on RTC registers has finished */ RTC_WaitForLastTask(); //sys_printf("\n\r @333\n\r"); PWR_EnterSTANDBYMode(); }
TGeoMedium* KVSpectroDetector::GetGeoMedium(const Char_t* mat_name){ // By default, return pointer to TGeoMedium corresponding to this KVMaterial. // If argument "mat_name" is given, a pointer to a medium is return for this material. // mat_name = "Vacuum" is a special case: if the "Vacuum" does not exist, we create it. // // Instance of geometry manager class TGeoManager must be created before calling this // method, otherwise 0x0 will be returned. // If the required TGeoMedium is not already available in the TGeoManager, we create // a new TGeoMedium corresponding to the material given in argument. if( !gGeoManager ) return NULL; TString medName, matName; if( !strcmp(mat_name,"") ){ // for gaseous materials, the TGeoMedium/Material name is of the form // gasname_pressure // e.g. C3F8_37.5 for C3F8 gas at 37.5 torr // each gas with different pressure has to have a separate TGeoMaterial/Medium matName = GetName(); KVIonRangeTableMaterial* irmat = KVMaterial::GetRangeTable()->GetMaterial(matName.Data()); if(irmat->IsGas()) medName.Form("%s_%f", matName.Data(), GetPressure()); else medName = GetName(); } else{ matName = mat_name; medName = mat_name; } TGeoMedium* gmed = gGeoManager->GetMedium( medName); if( gmed ) return gmed; TGeoMaterial *gmat = gGeoManager->GetMaterial( medName); if( !gmat ){ if( !strcmp(matName.Data(), "Vacuum") ){ // create material gmat = new TGeoMaterial("Vacuum",0,0,0 ); } else{ // create material gmat = GetRangeTable()->GetTGeoMaterial(matName.Data()); if(!gmat){ Error("GetGeoMedium","Material %s is nowhere to be found in %s" ,matName.Data(),GetRangeTable()->GetName()); return NULL; } gmat->SetPressure( GetPressure() ); gmat->SetTemperature( GetTemperature() ); gmat->SetTransparency(0); } } // For the moment the names of material and medium do not // depend on the temperature of the material. gmat->SetName(medName); gmat->SetTitle(matName); // create medium TGeoMedium* lastmed = (TGeoMedium*)gGeoManager->GetListOfMedia()->Last(); Int_t numed = (lastmed ? lastmed->GetId()+1 : 0); // static counter variable used to number media gmed = new TGeoMedium( medName, numed, gmat ); numed+=1; return gmed; }
//Perform an OligoWalk calculation //usesub = 0 -> no suboptimal; 3 -> heuristic int Oligowalk_object::Oligowalk(const int oligo_length, const bool isDNA, const int option, const double oligo_concentration, const int usesub, const int start, const int stop ) { datatable *enthalpy; thermo *helixstack; int test=-1; char stackf[maxfil],datapath[maxfil]; int error; datatable *dnadata; //use a character array to turn off SHAPE: char shapefile='\0'; int i,j,k,l; Thermodynamics *ddata; rddata *hybriddata,*enthalpyhybrid; char *pointer; //Make sure this is the first (and only allowed call of OligoWalk) if (table!=NULL) return 101; length = oligo_length;//save oligo_length for use in the destructor and for error checking later if (!energyread) { //The thermodynamic data tables have not been read and need to be read now. if (ReadThermodynamic()!=0) return 5;//return non-zero if a problem occurs } //Read the enthalpy data from disk using the underlying thermodynamics class GetEnthalpyData function: enthalpy = GetEnthalpyTable(); //make sure that the thermodynamics parameters could be read from disk if (enthalpy==NULL) { return 5;//5 is the error code that indicates the thermodynamic parameters were not found } //Although prefiltering isn't used in this version of OligoWalk, it needs to be initialized and passed to function. //Note that the true indicates that empirical scores would be used a prefilter = new siPREFILTER(*GetDatatable(),*enthalpy,0,true,GetStructure()->GetSequenceLength() - oligo_length + 2,isDNA); //Allocate the tables needed for storing the results table = new int*[GetStructure()->GetSequenceLength() - oligo_length + 2]; for (i = 0; i < GetStructure()->GetSequenceLength() - oligo_length + 2; i++) { //DHM commented out these lines for now. They need to be restored later. //if (siRNA) table[i] = new int[7]; //else table[i] = new int[6]; table[i] = new int[6]; } //allocate memory of number of suboptimal structures numofsubstructures= new int*[GetStructure()->GetSequenceLength() - oligo_length +2]; for (i = 0; i < GetStructure()->GetSequenceLength() - oligo_length + 2; i++) { numofsubstructures[i]= new int [2]; numofsubstructures[i][0]=0; numofsubstructures[i][1]=0; } //Get the path information for location of data files from $DATAPATH, if available pointer = getenv("DATAPATH"); if (pointer!=NULL) { strcpy(datapath,pointer); strcat(datapath,"/"); } else strcpy(datapath,""); //Allocate helixstack: helixstack = new thermo(pointer); //Now read the DNA parameters if the oligos are DNA: if (isDNA) { ddata = new Thermodynamics(false);//allocate space for DNA parameters //set the temperature for the DNA parameters error = ddata->SetTemperature(GetTemperature()); //Check fo an error if (error!=0) { delete ddata; delete prefilter; delete helixstack; return error; } //Read the dna thermodynamic parameters error = ddata->ReadThermodynamic(); //Check fo an error if (error!=0) { delete ddata; delete prefilter; delete helixstack; return error; } //Read the hybrid data as well hybriddata = new rddata; strcpy(stackf,datapath); strcat (stackf,"stackdr.dat"); //Check for errors if (readrd (hybriddata,stackf)==0) { delete ddata; delete prefilter; delete helixstack; return 5; } if (GetTemperature()<310||GetTemperature()>311) { //The temperature is simgificantly different from 37 dgrees C, so read and use the enthalpy data. strcpy(stackf,datapath); //strcat(stackf,"/"); strcat (stackf,"stackdr.dh"); enthalpyhybrid = new rddata; //Check for errors if (readrd (enthalpyhybrid,stackf)==0) { delete ddata; delete prefilter; delete enthalpyhybrid; delete helixstack; return 5; } for (i=0;i<5;i++) { for (j=0;j<5;j++) { for (k=0;k<5;k++) { for (l=0;l<5;l++) { hybriddata->stack[i][j][k][l]=Tscale(GetTemperature(),hybriddata->stack[i][j][k][l],enthalpyhybrid->stack[i][j][k][l]); } } } } hybriddata->init=Tscale(GetTemperature(),hybriddata->init,enthalpyhybrid->init); delete enthalpyhybrid; } strcpy(helixstack->DH,datapath); //strcat(helixstack->DH,"\\"); strcat(helixstack->DH,"stackdr.dh"); strcpy(helixstack->DS,datapath); //strcat(helixstack->DS,"\\"); strcat(helixstack->DS,"stackdr.ds"); strcpy(helixstack->HELIX,datapath); //strcat(helixstack->HELIX,"\\"); strcat(helixstack->HELIX,"helixdr.dat"); dnadata = ddata->GetDatatable(); } else { dnadata = NULL; } if (helixstack->read()==0) { //This means an error occurred reading the helixstack parameters if (isDNA) delete ddata; delete prefilter; delete helixstack; return 5; } //For now, siRNA is off. //if (siRNA) { // //mask will store whether an oligo meets siRNA design criteria // mask = new bool [ct.numofbases - length + 2]; //} //else mask = NULL; //note that foldsize is temporarilly set to zero so that there is no folding size limit //note that distance is set to zero so that there is no maximum pairping distance //note that test is set to -1 so there is no testing //note that write is set to FALSE to turn off writing olig(isDNA, option, GetStructure(), oligo_length, oligo_concentration, table, numofsubstructures, *GetDatatable(), *dnadata, hybriddata,usesub,GetProgress(),helixstack, start,stop,prefilter, 0, 0, &shapefile,&test,false); //siRNA is off right now //if (oligoobject->siRNA) { // filterbysirna(&oligoobject->ct,oligoobject->table,oligoobject->length,&oligoobject->data,oligoobject->mask,oligoobject->asuf,oligoobject->tofe,oligoobject->fnnfe); //} //note that foldsize is temporarilly set to zero here. //report(oligoobject->outputfile, &oligoobject->ct, oligoobject->table, oligoobject->numofsubstructures, // oligoobject->length, oligoobject->isdna, oligoobject->c, oligoobject->usesub,oligoobject->start,oligoobject->stop,prefilter,0, // oligoobject->mask,oligoobject->asuf,oligoobject->tofe,oligoobject->fnnfe); //Clean up if this is DNA if (isDNA) { delete ddata; } delete helixstack; return 0; }
int main(void) { unsigned char button_val; unsigned char Delta; unsigned char Rawstate; // // Setup the system clock to run at 80 Mhz from PLL with crystal reference // SysCtlClockSet( SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); // // Enable and configure the GPIO port for the LED operation. // SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); GPIOPinTypeGPIOOutput(LED, RED_LED | BLUE_LED | GREEN_LED); GPIOPinWrite(LED, RED_LED | BLUE_LED | GREEN_LED, 0x00); Blink(GREEN_LED | BLUE_LED, 5, 50); ButtonsInit(); UARTInit(); while (1) { SysCtlDelay(100000); button_val = ButtonsPoll(&Delta, &Rawstate); if (BUTTON_PRESSED(LEFT_BUTTON,button_val,Delta)) { if (SendAndCheck("AT", 1)) { Blink(BLUE_LED, 1, 300); } else { Blink(RED_LED, 1, 300); } } if (BUTTON_PRESSED(RIGHT_BUTTON,button_val,Delta)) { break; } } Blink(GREEN_LED, 1, 1000); ADCInit(); InitSonar(); SimInit(); Blink(BLUE_LED, 1, 1000); // // Loop Forever // while (1) { SysCtlDelay(100000); button_val = ButtonsPoll(&Delta, &Rawstate); if (BUTTON_PRESSED(LEFT_BUTTON,button_val,Delta)) { GPIOPinWrite(LED, RED_LED | BLUE_LED | GREEN_LED, GREEN_LED); max_distance = GetDistanceSonar(); GPIOPinWrite(LED, RED_LED | BLUE_LED | GREEN_LED, 0x00); if (SendAndCheck("AT", 1)) { Blink(BLUE_LED, 1, 300); } else { Blink(RED_LED, 1, 300); } } if (BUTTON_PRESSED(RIGHT_BUTTON,button_val,Delta)) { isRunning = !isRunning; } if (isRunning) { tempC = GetTemperature(); if (tempC > 70) { SendData(DATA_TEMP, tempC); Blink(RED_LED, 3, 100); } distance = GetDistanceSonar(); percentage = (int) floor( ((max_distance - distance) * 100.0) / max_distance); if ((percentage >= 0) && (percentage <= 100) && abs(percentage - oldPercentage) > 10) { SendData(DATA_TRASH, percentage); oldPercentage = percentage; } Blink(GREEN_LED, 1, 10); } } }
static ssize_t TempCtrlShow(struct device *dev, struct device_attribute *attr, char *buf) { return sprintf(buf, "sensor: %d, status: %d, temperature: %ld\n", private_data.sensor_num, private_data.tempctrl_data.temp_ctrl_status, GetTemperature()); }
//Perform an OligoScreen calculation. int Oligowalk_object::OligoScreen(const char infilename[], const char outfilename[]) { rddata *hybriddata,*enthalpyhybrid; char *pointer; char stackf[maxfil]; int i,j,k,l; //Check that the inputfilename exists: FILE *check; //check that the file exists. if ((check = fopen(infilename, "r"))== NULL) { //the file is not found //fclose(check); return 1; } fclose(check); if (!energyread) { //The thermodynamic data tables have not been read and need to be read now. if (ReadThermodynamic()!=0) return 5;//return non-zero if a problem occurs } //Now read the RNA-DNA hybrid parameters, if necessary: if (!isrna) { //This is DNA oligos //Get the information from $DATAPATH, if available pointer = getenv("DATAPATH"); if (pointer!=NULL) { strcpy(stackf,pointer); strcat(stackf,"/"); } else strcpy(stackf,""); strcat(stackf,"stackdr.dat"); //check that the datafile exists: if ((check = fopen(stackf, "r")) == NULL) { return 5; } hybriddata = new rddata; readrd(hybriddata,stackf); if (GetTemperature()<310||GetTemperature()>311) { //The temperature has changed. //Read the enthalpy data into a rddata. //Get the information from $DATAPATH, if available pointer = getenv("DATAPATH"); if (pointer!=NULL) { strcpy(stackf,pointer); strcat(stackf,"/"); } else strcpy(stackf,""); strcat(stackf,"stackdr.dh"); //check that the datafile exists: if ((check = fopen(stackf, "r")) == NULL) { delete hybriddata; return 5; } enthalpyhybrid = new rddata; readrd(enthalpyhybrid,stackf); for (i=0;i<5;i++) { for (j=0;j<5;j++) { for (k=0;k<5;k++) { for (l=0;l<5;l++) { hybriddata->stack[i][j][k][l]=Tscale(GetTemperature(),hybriddata->stack[i][j][k][l],enthalpyhybrid->stack[i][j][k][l]); } } } } delete enthalpyhybrid; } } else { //This is RNA oligos hybriddata= NULL; } //call the backend function OligoScreenCalc(infilename, outfilename, data, hybriddata); //cleanup: if (!isrna) { delete hybriddata; } return 0; }
//------------------------------------------------------------------------------ // FUNCTION NAME: InitializeCamera() // // RETURNS: If the function terminates before entering the message loop, // return FALSE. // Otherwise, return the WPARAM value sent by the WM_QUIT // message. // // LAST MODIFIED: PMcK 11/11/98 // // DESCRIPTION: calls initialization function, processes message loop // // Windows recognizes this function by name as the initial // entry point for the program. This function calls the // application initialization routine, if no other instance of // the program is running, and always calls the instance // initialization routine. It then executes a message // retrieval and dispatch loop that is the top-level control // structure for the remainder of execution. The loop is // terminated when a WM_QUIT message is received, at which // time this function exits the application instance by // returning the value passed by PostQuitMessage(). // // If the function must abort before entering the message loop, // it returns the conventional value NULL. // // // ARGUMENTS: hInstance - The handle to the instance of this application // that is currently being executed. // // hPrevInstance - The handle to the instance of this // application that was last executed. If this is the only // instance of this application executing, hPrevInstance is // NULL. In Win32 applications, this parameter is always NULL. // // lpCmdLine - A pointer to a null terminated string specifying // the command line of the application. // // nCmdShow - Specifies how the main window is to be diplayed. //------------------------------------------------------------------------------ bool ANDOR885_Camera::InitializeCamera() { AndorCapabilities caps; char aBuffer[256]; int errorValue; bool errorFlag = false; // int test,test2; //need to pause while camera initializes float speed, STemp, gain; int iSpeed, nAD, nAmp, nPreAmp, index, IsPreAmpAvailable; int i; caps.ulSize = sizeof(AndorCapabilities); long numCameras; GetAvailableCameras(&numCameras); GetCurrentDirectoryA(256,aBuffer);// Look in current working directory // for driver files. Note: had to override usual mapping of GetCurrentDirectory to // GetCurrentDirectoryW because of mismatch of argument types. errorValue=Initialize(aBuffer); // Initialize driver in current directory printError(errorValue, "Initialize error", &errorFlag, ANDOR_ERROR); if (errorFlag) return true; // Get camera capabilities errorValue=GetCapabilities(&caps); printError(errorValue, "Get Andor Capabilities information Error", &errorFlag, ANDOR_ERROR); // Get Head Model errorValue=GetHeadModel(model); printError(errorValue, "Get Head Model information Error", &errorFlag, ANDOR_ERROR); // Get detector information errorValue=GetDetector(&imageWidth,&imageHeight); printError(errorValue, "Get Detector information Error", &errorFlag, ANDOR_ERROR); // Set frame transfer mode errorValue=SetFrameTransferMode((frameTransfer == ANDOR_ON) ? 1 : 0); printError(errorValue, "Set Frame Transfer Mode Error", &errorFlag, ANDOR_ERROR); // Set acquisition mode to required setting specified in xxxxWndw.c errorValue=SetAcquisitionMode(acquisitionMode); printError(errorValue, "Set Acquisition Mode Error", &errorFlag, ANDOR_ERROR); if(caps.ulGetFunctions > 32) { GetEMCCDGain(&EMCCDGain); } if(readMode == READMODE_IMAGE) { // This function only needs to be called when acquiring an image. It sets // the horizontal and vertical binning and the area of the image to be // captured. In this example it is set to 1x1 binning and is acquiring the // whole image SetImage(1,1,1,imageWidth,1,imageHeight); } // Set read mode to required setting specified in xxxxWndw.c errorValue=SetReadMode(readMode); printError(errorValue, "Set Read Mode Error", &errorFlag, ANDOR_ERROR); // Set Vertical speed to max /* STemp = 0; VSnumber = 0; GetNumberVSSpeeds(&index); for(iSpeed=0; iSpeed<index; iSpeed++){ GetVSSpeed(iSpeed, &speed); if(speed > STemp){ STemp = speed; VSnumber = iSpeed; } } errorValue=SetVSSpeed(VSnumber); printError(errorValue, "Set Vertical Speed Error", &errorFlag, ANDOR_ERROR); */ if (!notDestructed){ STemp = 0; GetNumberVSSpeeds(&index); for(iSpeed=0; iSpeed < index; iSpeed++){ GetVSSpeed(iSpeed, &speed); verticalShiftSpeed_t.choices[iSpeed] = STI::Utils::valueToString(speed); if(speed > STemp){ STemp = speed; verticalShiftSpeed = iSpeed; } } verticalShiftSpeed_t.initial = (--verticalShiftSpeed_t.choices.end())->second; } errorValue = SetVSSpeed(verticalShiftSpeed); printError(errorValue, "Set Vertical Speed Error", &errorFlag, ANDOR_ERROR); /* Set Vertical Clock Voltage; note: only the fastest vertical shift speeds will benefit from the higher clock voltage; increasing clock voltage adds noise. */ if (!notDestructed) { index = 0; errorValue = GetNumberVSAmplitudes(&index); if (errorValue == DRV_SUCCESS) { for (i = 0; i < index; i++){ if (i == 0){ verticalClockVoltage_t.choices[i] = "Normal"; } else { verticalClockVoltage_t.choices[i] = STI::Utils::valueToString(i); } } verticalClockVoltage_t.initial = (verticalClockVoltage_t.choices.begin())->second; } } errorValue = SetVSAmplitude(0); printError(errorValue, "Set Vertical Clock Voltage Error", &errorFlag, ANDOR_ERROR); // Set Horizontal Speed to max and check bit depth //(scan over all possible AD channels; although, the 885 has only one 14-bit channel) STemp = 0; // HSnumber = 0; ADnumber = 0; if (!notDestructed) { errorValue = GetNumberADChannels(&nAD); if (errorValue != DRV_SUCCESS){ std::cerr << "Get number AD Channel Error\n"; errorFlag = true; } else if (nAD != 1) { std::cerr << "Expect 1 AD channel for this camera. The following code will miss channels\n"; errorFlag = true; } else { errorValue = GetNumberHSSpeeds(0, 0, &index); if(errorValue == DRV_SUCCESS){ for (iSpeed = 0; iSpeed < index; iSpeed++) { GetHSSpeed(0, 0, iSpeed, &speed); horizontalShiftSpeed_t.choices[iSpeed] = STI::Utils::valueToString(speed); if(speed < STemp){ STemp = speed; horizontalShiftSpeed = iSpeed; } } horizontalShiftSpeed_t.initial = horizontalShiftSpeed_t.choices.find(horizontalShiftSpeed)->second; } //getBitDepth if (DRV_SUCCESS != GetBitDepth(0, &bitDepth)) return true; } errorValue = GetNumberAmp(&nAmp); printError(errorValue, "Get Number Amplifiers Error", &errorFlag, ANDOR_ERROR); errorValue = GetNumberPreAmpGains(&nPreAmp); printError(errorValue, "Get Number Preamplifiers Error", &errorFlag, ANDOR_ERROR); if (nAmp == 1 && nAD == 1) { for (i = 0; i < nPreAmp; i++) { errorValue = GetPreAmpGain(i, &gain); errorValue = IsPreAmpGainAvailable(0,0,horizontalShiftSpeed,i,&IsPreAmpAvailable); if (IsPreAmpAvailable == 1) { preAmpGain_t.choices[i] = STI::Utils::valueToString(gain); } } if (!preAmpGain_t.choices.empty()) { preAmpGain = preAmpGain_t.choices.begin()->first; //preAmpGainPos = 0; preAmpGain_t.initial = (preAmpGain_t.choices.begin())->second; // set the initial condition for the preamplifier gain errorValue = SetPreAmpGain(preAmpGain); printError(errorValue, "Set AD Channel Error", &errorFlag, ANDOR_ERROR); } else { std::cerr << "No gains available at this speed. Weird."; errorFlag = true; } } else { std::cerr << "Unexpected number of A/D's or output amps" << std::endl; std::cerr << "Expected A/D's: 1 \t Measured: " << nAD << std::endl; std::cerr << "Expected output Amps: 1 \t Measured: " << nAmp << std::endl; errorFlag = true; } } else { errorValue = SetPreAmpGain(preAmpGain); printError(errorValue, "Set AD Channel Error", &errorFlag, ANDOR_ERROR); } errorValue=SetADChannel(ADnumber); printError(errorValue, "Set AD Channel Error", &errorFlag, ANDOR_ERROR); errorValue=SetHSSpeed(0,horizontalShiftSpeed); printError(errorValue, "Set Horizontal Speed Error", &errorFlag, ANDOR_ERROR); if(errorFlag) //MessageBox(GetActiveWindow(),aBuffer,"Error!",MB_OK); SMD std::cerr<<aBuffer<<std::endl; // Wait for 2 seconds to allow MCD to calibrate fully before allowing an // acquisition to begin // test=GetTickCount(); // do{ // test2=GetTickCount()-test; // }while(test2<2000); Sleep(2000); errorValue = SetExposureTime(exposureTime); printError(errorValue, "Exposure time error", &errorFlag, ANDOR_ERROR); // It is necessary to get the actual times as the system will calculate the // nearest possible time. eg if you set exposure time to be 0, the system // will use the closest value (around 0.01s) GetAcquisitionTimings(&exposureTime,&accumulateTime,&kineticTime); std::cerr << "Actual Exposure Time is " << exposureTime << " s.\n"; // Set Shutter is made up of ttl level, shutter and open close time //Check Get open close time if(openTime==0) openTime=1; if(closeTime==0) closeTime=1; // Set shutter errorValue=SetShutter(ttl,shutterMode,closeTime,openTime); if(errorValue!=DRV_SUCCESS){ std::cerr << "Shutter error\n"; errorFlag = true; } else std::cerr << "Shutter set to specifications\n"; /*// Determine availability of trigger option and set trigger selection std::map<int,std::string>::iterator it; std::vector<int> triggerKeys; for (it = triggerMode_t.choices.begin(); it != triggerMode_t.choices.end(); it++) { errorValue = SetTriggerMode(it->first); if (errorValue != DRV_SUCCESS) triggerKeys.push_back(it->first); } for (int i = 0; i < triggerKeys.size(); i++) triggerMode_t.choices.erase(triggerKeys.at(i)); if (triggerMode_t.choices.empty()) { std::cerr << "No triggerModes found" << std::endl; return true; } else if (triggerMode_t.choices.find(TRIGGERMODE_EXTERNAL_EXPOSURE) != triggerMode_t.choices.end()) triggerMode = TRIGGERMODE_EXTERNAL_EXPOSURE; else if (triggerMode_t.choices.find(TRIGGERMODE_EXTERNAL) != triggerMode_t.choices.end()) triggerMode = TRIGGERMODE_EXTERNAL; else triggerMode = triggerMode_t.choices.begin()->first; errorValue=SetTriggerMode(triggerMode); printError(errorValue, "Set Trigger Mode Error", &errorFlag, ANDOR_ERROR); triggerMode_t.initial = triggerMode_t.choices.find(triggerMode)->second; */ // Determine availability of trigger option and set trigger selection std::map<int,std::string>::iterator it; std::vector<int> triggerKeys; for (it = triggerMode_t.choices.begin(); it != triggerMode_t.choices.end(); it++) { errorValue = SetTriggerMode(it->first); if (errorValue != DRV_SUCCESS) triggerKeys.push_back(it->first); } for (int i = 0; i < triggerKeys.size(); i++) triggerMode_t.choices.erase(triggerKeys.at(i)); if (triggerMode_t.choices.empty()) { std::cerr << "No triggerModes found" << std::endl; return true; } else if (triggerMode_t.choices.find(TRIGGERMODE_EXTERNAL_EXPOSURE) != triggerMode_t.choices.end()) triggerMode = TRIGGERMODE_EXTERNAL_EXPOSURE; else if (triggerMode_t.choices.find(TRIGGERMODE_EXTERNAL) != triggerMode_t.choices.end()) triggerMode = TRIGGERMODE_EXTERNAL; else triggerMode = triggerMode_t.choices.begin()->first; errorValue=SetTriggerMode(triggerMode); printError(errorValue, "Set Trigger Mode Error", &errorFlag, ANDOR_ERROR); triggerMode_t.initial = triggerMode_t.choices.find(triggerMode)->second; errorValue = GetTemperatureRange(&minTemp, &maxTemp); if (errorValue != DRV_SUCCESS){ std::cerr << "Error finding temperature range or camera is not on" << std::endl; errorFlag = true; } else { std::cerr << "Temperature must be between " << minTemp << " and " << maxTemp << std::endl; std::cerr << "Warning: Water cooling is required for temperatures < -58 deg C" << std::endl; //Set temperature if (coolerSetpt > maxTemp || coolerSetpt < minTemp) { std::cerr << "Chosen temperature out of range." << std::endl; if (coolerSetpt > maxTemp) coolerSetpt = maxTemp; else coolerSetpt = minTemp; std::cerr << "Resetting temp to nearest acceptable value " << std::endl; } errorValue = SetTemperature(coolerSetpt); printError(errorValue, "Error setting cooler temperature", &errorFlag, ANDOR_ERROR); int i; errorValue = IsCoolerOn(&i); if (i == 0) { // if it's off and it's supposed to be on, turn it on if (coolerStat == ANDOR_ON) { std::cerr << "Turning on cooler." << std::endl; errorValue = CoolerON(); printError(errorValue, "Error turning on cooler", &errorFlag, ANDOR_ERROR); } } else if (i == 1) { std::cerr << "Cooler is on." << std::endl; //if it's on and it's supposed to be off, turn it off if (coolerStat == ANDOR_OFF) { errorValue = CoolerOFF(); printError(errorValue, "Error turning off cooler", &errorFlag, ANDOR_ERROR); } else { errorValue = GetTemperature(&i); switch(errorValue){ case DRV_TEMP_STABILIZED: std::cerr << "Cooler temp has stabilized at " << i << " deg C" << std::endl; break; case DRV_TEMP_NOT_REACHED: std::cerr << "Cooler temp is " << i << " deg C" << std::endl; std::cerr << "Cooler setpoint has not been reached." << std::endl; std::cerr << "This may be because water cooling is required for setpoints < -58 deg C" << std::endl; std::cerr << "Either wait or try resetting cooler setpoint" << std::endl; break; case DRV_TEMP_DRIFT: std::cerr << "Cooler temp is " << i << " deg C" << std::endl; std::cerr << "Cooler temperature has drifted. Try resetting setpoint" << std::endl; break; case DRV_TEMP_NOT_STABILIZED: std::cerr << "Cooler temp is " << i << " deg C" << std::endl; std::cerr << "Temperature has been reached, but cooler has not stabilized" << std::endl; std::cerr << "Either wait or try resetting cooler setpoint" << std::endl; break; default: std::cerr << "Unrecognized error sequence. Camera may be off or acquiring" << std::endl; break; } } } if(!errorFlag){ std::cerr << "Cooler temperature set to: " << coolerSetpt << std::endl; } } errorValue = SetSpool(0,0,NULL,10); //Disable spooling printError(errorValue, "Spool mode error", &errorFlag, ANDOR_ERROR); // Returns the value from PostQuitMessage return errorFlag; }