Commit aca814c0 authored by Giuseppe Carboni's avatar Giuseppe Carboni Committed by GitHub
Browse files

Merge pull request #385 from discos/stable

Fix #382, reworked Refraction threads syncronization (#383)
parents 24b53076 f08bdc96
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -110,9 +110,10 @@ private:
    double m_pressure;

	/**
	 * Thread sync mutex
	 * Thread sync mutexes
	 */
	BACIMutex m_mutex;
	BACIMutex m_meteoDataMutex;
	BACIMutex m_parametersMutex;

};

+25 −23
Original line number Diff line number Diff line
@@ -100,7 +100,8 @@ void CRefractionCore::execute() throw (ComponentErrors::CouldntGetComponentExImp

void CRefractionCore::cleanUp()
{
	baci::ThreadSyncGuard guard(&m_mutex);
	baci::ThreadSyncGuard guardMeteoData(&m_meteoDataMutex);
	baci::ThreadSyncGuard guardParameters(&m_parametersMutex);
	try {
		m_services->releaseComponent((const char*)m_meteodata->name());
	}
@@ -115,7 +116,7 @@ void CRefractionCore::getCorrection(double obsZenithDistance,double waveLen, dou
{
	AUTO_TRACE("CRefractionCore::getCorrection()");
	//double elevation;
	baci::ThreadSyncGuard guard(&m_mutex);
	baci::ThreadSyncGuard guardParametes(&m_parametersMutex);
	//elevation = 90.0 - obsZenithDistance*DR2D;
	//if (elevation >= 0.0 && elevation <= 90.0) {
	if ((obsZenithDistance>=0.0) && (obsZenithDistance<=(DPI/2.0))) {
@@ -128,8 +129,7 @@ void CRefractionCore::getCorrection(double obsZenithDistance,double waveLen, dou

		slaRefro(obsZenithDistance, hm, tdk, m_pressure, m_humidity, wl, phi, tlr, eps, corZenithDistance);
	}
	else
		corZenithDistance = 0;
	else corZenithDistance = 0;
}

void CRefractionCore::getMeteoParameters()
@@ -141,13 +141,15 @@ void CRefractionCore::getMeteoParameters()
	Weather::parameters pars;

	try {
	// keep the mutex for thread execution to avoid long waits
		// keep the meteoData mutex for thread execution to avoid long waits
		// before to call the getData function from meteo component
	baci::ThreadSyncGuard guard(&m_mutex);
		baci::ThreadSyncGuard guardMeteoData(&m_meteoDataMutex);
		pars=m_meteodata->getData();
		//m_temperature = m_meteodata->getTemperature();
		//m_humidity = (m_meteodata->getHumidity())/100.0; // because slaRefro needs humidity value beetwen 0.0 and 1.0
		//m_pressure = m_meteodata->getPressure();

		baci::ThreadSyncGuard guardParameters(&m_parametersMutex);
		m_temperature=pars.temperature;
		m_humidity=pars.humidity/100.0;
		m_pressure=pars.pressure;