@@ -25,6 +25,8 @@ CProfile_A5_20_01::CProfile_A5_20_01(const std::string& deviceId,
2525 m_externalSensorTemperature, m_summerMode
2626 })
2727{
28+ // We always must send a command as answer, init first command
29+ updatePendingCommand ();
2830}
2931
3032const std::string& CProfile_A5_20_01::profile () const
@@ -92,20 +94,6 @@ std::vector<boost::shared_ptr<const yApi::historization::IHistorizable>> CProfil
9294 m_actuatorObstructed->set (aco);
9395 m_internalSensorTemperature->set (byteToCelciusDegrees (tmp));
9496
95- if (m_pendingCommand.empty ())
96- {
97- // We always must send a command as answer. Init first command from received message.
98- m_pendingCommand.resize (4 * 8 );
99-
100- bitset_insert (m_pendingCommand, 0 , 8 , 50 ); // Valve default position to 50%
101- bitset_insert (m_pendingCommand, 21 , 1 , false ); // Set Point Selection (false = valve position)
102- bitset_insert (m_pendingCommand, 8 , 8 , 0 ); // Use internal sensor
103- bitset_insert (m_pendingCommand, 20 , 1 , false ); // Summer bit (false = not in summer mode)
104- bitset_insert (m_pendingCommand, 22 , 1 , false ); // Set Point inversed (false = not inversed)
105-
106- bitset_insert (m_pendingCommand, 28 , 1 , true ); // Data telegram
107- }
108-
10997 message::CMessageHelpers::sendMessage (CRorgs::k4BS_Telegram,
11098 messageHandler,
11199 senderId,
@@ -114,14 +102,14 @@ std::vector<boost::shared_ptr<const yApi::historization::IHistorizable>> CProfil
114102 " send command" );
115103
116104 YADOMS_LOG (trace) << " Message sent to " + m_deviceId + " (A5-20-01) :" ;
117- YADOMS_LOG (trace) << " - SP , Valve Position or Temperature Set Point: " << bitset_extract (m_pendingCommand, 0 , 8 ) << " => " <<
105+ YADOMS_LOG (trace) << " - SP , Valve Position or Temperature Set Point: " << bitset_extract (m_pendingCommand, 0 , 8 ) << " => " <<
118106 (bitset_extract (m_pendingCommand, 21 , 1 )
119107 ? (std::to_string (byteToCelciusDegrees (bitset_extract (m_pendingCommand, 0 , 8 ))) + " °C" )
120108 : (std::to_string (bitset_extract (m_pendingCommand, 0 , 8 )) + " %" ));
121109 YADOMS_LOG (trace) << " - TMP , Temperature from RCU : " << bitset_extract (m_pendingCommand, 8 , 8 ) << " => " <<
122110 (bitset_extract (m_pendingCommand, 8 , 8 ) == 0
123111 ? " Internal sensor used"
124- : (std::to_string (byteToCelciusDegrees (bitset_extract (m_pendingCommand, 8 , 8 ))) + " °C" ));
112+ : (std::to_string (byteToCelciusDegrees (255 - bitset_extract (m_pendingCommand, 8 , 8 ))) + " °C" ));
125113 YADOMS_LOG (trace) << " - SB , Summer bit : " << (bitset_extract (m_pendingCommand, 20 , 1 ) ? true : false );
126114 YADOMS_LOG (trace) << " - SPS , SetPoint Selection : " << (bitset_extract (m_pendingCommand, 21 , 1 ) ? true : false ) << " => " <<
127115 (bitset_extract (m_pendingCommand, 21 , 1 )
@@ -155,8 +143,23 @@ void CProfile_A5_20_01::sendCommand(const std::string& keyword,
155143 if (keyword == m_summerMode->getKeyword ())
156144 m_summerMode->setCommand (commandBody);
157145
146+ updatePendingCommand ();
147+ }
148+
149+ void CProfile_A5_20_01::sendConfiguration (const shared::CDataContainer& deviceConfiguration,
150+ const std::string& senderId,
151+ boost::shared_ptr<IMessageHandler> messageHandler)
152+ {
153+ m_useInternalSensor = deviceConfiguration.get <std::string>(" useInternalSensor" ) == " internal" ;
154+ m_setPointInverse = deviceConfiguration.get <bool >(" setPointInverse" );
155+
156+ updatePendingCommand ();
157+ }
158+
159+ void CProfile_A5_20_01::updatePendingCommand ()
160+ {
161+ std::lock_guard<std::mutex> guard (m_pendingCommandMutex);
158162
159- // Create message to send at next device wakeup
160163 m_pendingCommand.resize (4 * 8 );
161164 m_pendingCommand.reset ();
162165
@@ -174,14 +177,6 @@ void CProfile_A5_20_01::sendCommand(const std::string& keyword,
174177 bitset_insert (m_pendingCommand, 28 , 1 , true ); // Data telegram
175178}
176179
177- void CProfile_A5_20_01::sendConfiguration (const shared::CDataContainer& deviceConfiguration,
178- const std::string& senderId,
179- boost::shared_ptr<IMessageHandler> messageHandler)
180- {
181- m_useInternalSensor = deviceConfiguration.get <std::string>(" useInternalSensor" ) == " internal" ;
182- m_setPointInverse = deviceConfiguration.get <bool >(" setPointInverse" );
183- }
184-
185180double CProfile_A5_20_01::byteToCelciusDegrees (const unsigned int byte)
186181{
187182 // Rounded to 1 decimal
0 commit comments