void datenAuswerten(uint8_t *daten) { int temp_daten; // Convert the uint8_t to one uint32_t temp_daten = (int)(daten[1]<<8)|daten[0]; setTemp((int) temp_daten, k); }
task main () { nxtDisplayCenteredTextLine(3, "Roaming"); nxtDisplayCenteredTextLine(5, "This is a test"); while(nextEmptyCell<numLocalCells) { alive(); char lastCellNum = nextEmptyCell; nSyncedMotors = synchBC; nSyncedTurnRatio = 101; nMotorEncoderTarget[motorB] = 200; motor[motorB] =60; while(nMotorRunState[motorB] != runStateIdle) {} setTemp(); checkLocalCell(); doTurn(); if(lastCellNum != nextEmptyCell) { AddToDatalog(1); } else { AddToDatalog(0); } // wait1Msec(200); } SaveNxtDatalog(); StarWars(); }
void LoaderTest::createConfigTest() { auto pwmFan = m_loader->pwmFan(0, 1); pwmFan->setTemp(m_loader->temp(1, 1)); pwmFan->setMinTemp(20); pwmFan->setMaxTemp(60); pwmFan->setMaxPwm(200); pwmFan->setMinPwm(100); pwmFan->setMinStart(120); pwmFan->setMinStop(80); pwmFan = m_loader->pwmFan(1, 2); pwmFan->setTemp(m_loader->temp(1, 3)); pwmFan->setMinTemp(30); pwmFan->setMaxTemp(70); pwmFan->setMaxPwm(255); pwmFan->setMinPwm(120); pwmFan->setMinStart(110); pwmFan->setMinStop(75); m_loader->setInterval(5); auto config = m_loader->createConfig(); QString expectedConfig = "# This file was created by Fancontrol-GUI\n" "INTERVAL=5\n" "DEVPATH=hwmon0= hwmon1= \n" "DEVNAME=hwmon0=radeon hwmon1=coretemp \n" "FCTEMPS=hwmon0/pwm1=hwmon1/temp1_input hwmon1/pwm2=hwmon1/temp3_input \n" "FCFANS=hwmon0/pwm1=hwmon0/fan1_input hwmon1/pwm2=hwmon1/fan2_input \n" "MINTEMP=hwmon0/pwm1=20 hwmon1/pwm2=30 \n" "MAXTEMP=hwmon0/pwm1=60 hwmon1/pwm2=70 \n" "MINSTART=hwmon0/pwm1=120 hwmon1/pwm2=110 \n" "MINSTOP=hwmon0/pwm1=80 hwmon1/pwm2=75 \n" "MINPWM=hwmon0/pwm1=100 hwmon1/pwm2=120 \n" "MAXPWM=hwmon0/pwm1=200 hwmon1/pwm2=255 \n"; auto expectedLines = expectedConfig.split(QChar(QChar::LineFeed)); auto configLines = config.split(QChar(QChar::LineFeed)); QCOMPARE(configLines.size(), expectedLines.size()); for (auto i=0; i<configLines.size(); i++) QCOMPARE(configLines.at(i), expectedLines.at(i)); }
//----main----// task main () { nxtDisplayCenteredTextLine(3, "Roaming"); nxtDisplayCenteredTextLine(5, "This is a test"); initialisePose(); //set up iterate(stepSize); //run excitation etc currentDirection = 0; //set initial currentTheta = 0; setTemp(); //get local view checkLocalCell(); //create first association displayMax(); nxtDisplayTextLine(2, "Num Act.: %3d",numActive); nxtDisplayTextLine(3, "Direction: %3d", currentDirection); nxtDisplayTextLine(4, "changeTheta:%3d", changeTheta); while(nextEmptyCell<numLocalCells) { alive(); //stop NXT from sleeping //eraseDisplay(); //nxtDisplayCenteredTextLine(2, "Num Active: - %4d",numActive); char lastCellNum = nextEmptyCell; drive(100,180,50); pose3D(changeTheta,0.5); setTemp(); checkLocalCell(); doTurn(); displayMax(); nxtDisplayTextLine(2, "Num Act.: %3d",numActive); nxtDisplayTextLine(3, "Direction: %3d", currentDirection); nxtDisplayTextLine(4, "changeTheta:%3d", changeTheta); //store data clearEncoders(); //clear encoder count changeTheta=0; // wait1Msec(200); } }
//----main----// task main () { Delete(sFileName1, nIoResult); Delete(sFileName2, nIoResult); nxtDisplayCenteredTextLine(3, "Roaming"); nxtDisplayCenteredTextLine(5, "This is a test"); initialisePose(); //set up iterate(stepSize); //run excitation etc currentDirection = 0; //set initial currentTheta = 0; setTemp(); //get local view checkLocalCell(); //create first association datalogging(); sumPoseStruct(); while(1) { alive(); //stop NXT from sleeping float centreSonarValue = SensorValue(centreSonar); if(centreSonarValue<19) { doTurn(); pose3D(changeTheta,0); } else { drive(100,180,50); pose3D(changeTheta,0.5); } sumPoseStruct(); setTemp(); checkLocalCell(); //store data datalogging(); clearEncoders(); //clear encoder count changeTheta=0; } SaveNxtDatalog(); PlaySound(soundException); while(bSoundActive){} }
void climate_setState(DateTime theDate) // // Input: theDate = simulation date // Output: none // Purpose: sets climate variables for current date. // { if ( Fclimate.mode == USE_FILE ) updateFileValues(theDate); if ( Temp.dataSource != NO_TEMP ) setTemp(theDate); setEvap(theDate); setWind(theDate); }
void climate_setState(DateTime theDate) // // Input: theDate = simulation date // Output: none // Purpose: sets climate variables for current date. // { if ( Fclimate.mode == USE_FILE ) updateFileValues(theDate); if ( Temp.dataSource != NO_TEMP ) setTemp(theDate); setEvap(theDate); setWind(theDate); Adjust.rainFactor = Adjust.rain[datetime_monthOfYear(theDate)-1]; //(5.1.007) Adjust.hydconFactor = Adjust.hydcon[datetime_monthOfYear(theDate)-1]; //(5.1.008) setNextEvapDate(theDate); //(5.1.008) }
void baseObsData::set(time_t _tm, int _stn, float ws, float wd, float tmp, // required fields float wg, float dp, // optional fields float spress) { setWS(ws); setWD(wd); setTemp(tmp); if (wg >= 0.0) setWG(wg); if (dp != -9999.0) setDP(dp); if (spress > 0.0) setSPress(spress); setTm(_tm); setStn(_stn); valid = true; }
int main(int argc, char ** argv) { // define 2 pumps PumpPtr A = newPump(1, 3, "Chiller Pump"); PumpPtr B = newPump(2, 4, "Mash Pump"); // create a temp sensor TempSensorPtr hltTempSensor = newTempSensor(HLT_TEMP_SENSOR, "HLT Temp Sensor", HLT_TEMP_SENSOR_ID); setTemp(hltTempSensor, 54.2); // set the value of that sensor //create 2 valves; valvePtr hltInletValve = newValve(5, 2, "HLT inlet valve"); valvePtr hltOutletValve = newValve(5, 3, "HLT outlet valve"); // create a new HLT and assign a temp sensor and 2 valves. hltPtr H = newHlt(HLT_PORT, HLT_PIN, hltTempSensor, hltInletValve, hltOutletValve); printf("The temperature of the HLT is %f\r\n", getHltTemp(H)); heatHlt(H, 76.3); runPump(B); runPump(A); printPump(A); printPump(B); stopPump(A); stopPump(B); printTempSensorAddress(hltTempSensor); destroyPump(A); destroyPump(B); destroyTempSensor(hltTempSensor); destroyValve(hltInletValve); destroyValve(hltOutletValve); destroyHlt(H); return 0; }
bool Tracks::getTemp() { setTemp(); int start; std::string output; getData(4); usleep(_delay); while(ros::ok()) { readData(output,1); if(output[0]==0x00) break; } this->readData(output, 5 + 5*sensor_used); output.insert(output.begin(),0x00); std::string buff; float value; buff = output.substr(0,4); value = dataToFloat32(buff); std::string payload = output.substr(0,sensor_used*5+4); unsigned short crc = (unsigned short)output[sensor_used*5+4]<<8; crc +=output[sensor_used*5+5]; unsigned short crc_cal = getCRC16(payload); if(crc!=crc_cal) return false; printf("crc: %x %x ",crc,crc_cal); //int cast = reinterpret_cast<int>(value); printf("Temp : %x %x %x %x \n",(unsigned char)buff[0],(unsigned char)buff[1],(unsigned char)buff[2],(unsigned char)buff[3]); int j=temp; for(start = 4;start<(sensor_used*5+1);start+=5) { buff = output.substr(start,5); value = dataToFloat32(buff); printf("%x %x %x %x %x\t\t",(unsigned char)buff[0],(unsigned char)buff[1],(unsigned char)buff[2],(unsigned char)buff[3],(unsigned char)buff[4]); std::cout<<value<<"\n"; _data.data[j++]=value; } std::cout<<std::endl; return true; }
void SimulatedCar::decTemp(void) { setTemp(getTemp()-SIMULATION_TEMP_STEP); }
void SimulatedCar::incTemp(void) { setTemp(getTemp()+SIMULATION_TEMP_STEP); }
// POST set params as "fanmode=1" void HVAC::setVar(String sCmd, int val) { if(m_EE.bLock) return; switch( CmdIdx( sCmd, cSCmds ) ) { case 0: // fanmode if(val == 2) // "freshen" { if(m_bRunning || m_furnaceFan || m_bFanMode) // don't run if system or fan is running break; m_fanPostTimer = m_EE.fanCycleTime; // use the post fan timer to shut off fanSwitch(true); } else setFan( (val) ? true:false); break; case 1: // mode setMode( val ); break; case 2: // heatmode setHeatMode( val ); break; case 3: // resettotal resetTotal(); break; case 4: resetFilter(); break; case 5: // fanpostdelay m_EE.fanPostDelay[digitalRead(P_REV)] = constrain(val, 0, 60*5); // Limit 0 to 5 minutes break; case 6: // cyclemin m_EE.cycleMin = constrain(val, 60, 60*20); // Limit 1 to 20 minutes break; case 7: // cyclemax m_EE.cycleMax = constrain(val, 60*2, 60*60); // Limit 2 to 60 minutes break; case 8: // idlemin m_EE.idleMin = constrain(val, 60, 60*30); // Limit 1 to 30 minutes break; case 9: // cyclethresh m_EE.cycleThresh = constrain(val, 5, 50); // Limit 0.5 to 5.0 degrees break; case 10: // cooltempl setTemp(Mode_Cool, val, 0); m_bRecheck = true; // faster update break; case 11: // cooltemph setTemp(Mode_Cool, val, 1); m_bRecheck = true; break; case 12: // heattempl setTemp(Mode_Heat, val, 0); m_bRecheck = true; break; case 13: // heattemph setTemp(Mode_Heat, val, 1); m_bRecheck = true; break; case 14: // eheatthresh m_EE.eHeatThresh = constrain(val, 5, 50); // Limit 5 to 50 degrees F break; case 15: // override if(val == 0) // cancel { m_ovrTemp = 0; m_overrideTimer = 0; } else { m_ovrTemp = constrain(val, -90, 90); // Limit to -9.0 to +9.0 degrees F m_overrideTimer = m_EE.overrideTime; } m_bRecheck = true; break; case 16: // overridetime m_EE.overrideTime = constrain(val, 60*1, 60*60*6); // Limit 1 min to 6 hours break; case 17: // humidmode m_EE.humidMode = constrain(val, HM_Off, HM_Auto2); break; case 18: // humidl m_EE.rhLevel[0] = constrain(val, 300, 900); // no idea really break; case 19: // humidh m_EE.rhLevel[1] = constrain(val, 300, 900); break; case 20: // adj m_EE.adj = constrain(val, -30, 30); // calibrate can only be +/-3.0 break; case 21: // fanPretime m_EE.fanPreTime[m_EE.Mode == Mode_Heat] = constrain(val, 0, 60*5); // Limit 0 to 5 minutes break; case 22: // fancycletime m_EE.fanCycleTime = val; break; case 23: // rmtflgs 0xC=(RF_RL|RF_RH) = use remote, 0x3=(RFML|RF_MH)= use main, 0xF = use both averaged m_RemoteFlags = val; break; case 24: // awaytime m_EE.awayTime = val; // no limit break; case 25: // awaydelta if(m_EE.Mode == Mode_Heat) m_EE.awayDelta[1] = constrain(val, -150, 0); // Limit to -15 degrees (heat away) target is constrained in calcTargetTemp else m_EE.awayDelta[0] = constrain(val, 0, 150); // Limit +15 degrees (cool away) break; case 26: // away (uses the override feature) if(val) // away { m_overrideTimer = m_EE.awayTime * 60; // convert minutes to seconds m_ovrTemp = m_EE.awayDelta[m_EE.Mode == Mode_Heat]; m_bAway = true; } else // back { m_ovrTemp = 0; m_overrideTimer = 0; m_bAway = false; } break; } }
void BoltzmannInfoWidget::refresh(int temp, int velocity) { setTemp(temp); setVel(velocity); this->update(); }
void measureRunFunction(void *dataptr) { static tBoolean onFirstRun = true; static int rate; MeasureData *mData = (MeasureData *) dataptr; if (onFirstRun) { initializeMeasureTask(); rate = *(int*) cbGet(mData->pulseRateRaw); onFirstRun = false; } // capture pulse rate if (IS_PULSE_CYCLE) { // Divide by two so raw pulse rate matches frequency rate = pulseRate/2; pulseRate = 0; } // only run on major cycle short measureSelect = *(mData->measureSelect); if(measureSelect == 0 || measureSelect == 1) { setTemp(mData->temperatureRaw); } if(measureSelect == 0 || measureSelect == 2) { setBloodPress(mData->systolicPressRaw, mData->diastolicPressRaw); } if(measureSelect == 0 || measureSelect == 3) { int prev = *(int*) cbGet(mData->pulseRateRaw); // Only save if +- 15% if (rate < prev*0.85 || rate > prev*1.15) { cbAdd(mData->pulseRateRaw, (void *)&rate); } } if(measureSelect == 0 || measureSelect == 4) { vTaskResume(ekgCaptureHandle); } else { vTaskSuspend(ekgCaptureHandle); } vTaskResume(computeHandle); // run the compute task #if DEBUG_MEASURE char num[30]; int temp = *(int *)cbGet(mData->temperatureRaw); int sys = *(int *)cbGet(mData->systolicPressRaw); int dia = *(int *)cbGet(mData->diastolicPressRaw); int pulse = *(int *)cbGet(mData->pulseRateRaw); int batt = global.batteryState; usnprintf(num, 30, "<-- MEASURE DEBUG -->"); RIT128x96x4StringDraw(num, 0, 0, 15); usnprintf(num, 30, "Raw temp: %d ", temp); RIT128x96x4StringDraw(num, 0, 10, 15); usnprintf(num, 30, "Raw Syst: %d ", sys); RIT128x96x4StringDraw(num, 0, 20, 15); usnprintf(num, 30, "Raw Dia: %d ", dia); RIT128x96x4StringDraw(num, 0, 30, 15); usnprintf(num, 30, "Raw Pulse: %d ", pulse); RIT128x96x4StringDraw(num, 0, 40, 15); usnprintf(num, 30, "Raw Batt: %d ", batt); RIT128x96x4StringDraw(num, 0, 50, 15); #endif }