コード例 #1
0
//-------------------------------------------------- Builder / Destructor
SensorSimulatorSunSpot::SensorSimulatorSunSpot(int id, Subject* r, float minL, float maxL, float minT, float maxT, float minM, float maxM) : SensorSimulator(id, EnOceanSensorAPI::ORG_4BS, r), minLum(minL), maxLum(maxL), minTemp(minT), maxTemp(maxT), minMov(minM), maxMov(maxM) {
//	illuminance = rand()%(int)(maxLum-minLum) - minLum;
//	voltage = rand()%(int)(maxV-minV) - minV;
//	pirStatus = false;
//	occupancy = false;
	Patient* patient = dynamic_cast<Patient*>(r);
	if (patient != 0) {
		float t, i, m;
		t = patient->getTemperature();
		i = patient->getRoom()->getLuminosity();
		m = patient->getMovement();
		EnOceanSensorAPI::setIlluminance(&frame, i, minLum, maxLum);
		EnOceanSensorAPI::setTemperature(&frame, t, minT, maxT);
		EnOceanSensorAPI::setMovement(&frame,  m, minM, maxM);
		cout << "<Sensor Simu n°" << id << "> Créé - Sunspot\n";

	} else { subject = NULL; }


} //----- End of SensorSimulatorSunSpot
コード例 #2
0
void SensorSimulatorSunSpot::update() {
//	float voltage = t;
//	if (voltage > maxV) { t = maxV; }
//	else if (voltage < minV) { t = minV; }
	Patient* patient = dynamic_cast<Patient*>(subject);
	if (patient != 0) {
		float t, i, m;
		t = patient->getTemperature();
		if (t > maxTemp) { t = maxTemp; }
		else if (t < minTemp) { t = minTemp; }
		i = patient->getRoom()->getLuminosity();
		if (i > maxLum) { i = maxLum; }
		else if (i < minLum) { i = minLum; }
		m = patient->getMovement();
		if (m > maxMov) { m = maxMov; }
		else if (m < minMov) { m = minMov; }
		EnOceanSensorAPI::setIlluminance(&frame, i, minLum, maxLum);
		EnOceanSensorAPI::setTemperature(&frame, t, minTemp, maxTemp);
		EnOceanSensorAPI::setMovement(&frame,  m, minMov, maxMov);
	}
}