@@ -52,9 +52,11 @@ FunctionBlockTypePtr MqttPublisherFbImpl::CreateType()
5252 defaultConfig.addProperty (builder.build ());
5353 }
5454 {
55- auto builder = StringPropertyBuilder (PROPERTY_NAME_PUB_TOPIC_NAME, " " )
56- .setDescription (" " )
57- .setVisible (EvalValue (std::string (" $" ) + PROPERTY_NAME_PUB_TOPIC_MODE + " == 1" ));
55+ auto builder =
56+ StringPropertyBuilder (PROPERTY_NAME_PUB_TOPIC_NAME, " " )
57+ .setDescription (
58+ " Topic name for publishing in multiple-topic mode. If left empty, the Publisher's Global ID is used as the topic name." )
59+ .setVisible (EvalValue (std::string (" $" ) + PROPERTY_NAME_PUB_TOPIC_MODE + " == 1" ));
5860 defaultConfig.addProperty (builder.build ());
5961 }
6062 {
@@ -190,6 +192,8 @@ void MqttPublisherFbImpl::initProperties(const PropertyObjectPtr& config)
190192 if (const auto internalProp = prop.asPtrOrNull <IPropertyInternal>(true ); internalProp.assigned ())
191193 {
192194 objPtr.addProperty (internalProp.clone ());
195+ objPtr.getOnPropertyValueWrite (prop.getName ()) +=
196+ [this ](PropertyObjectPtr& obj, PropertyValueEventArgsPtr& args) { propertyChanged (); };
193197 }
194198 }
195199 objPtr.setPropertyValue (propName, prop.getValue ());
@@ -200,7 +204,7 @@ void MqttPublisherFbImpl::initProperties(const PropertyObjectPtr& config)
200204void MqttPublisherFbImpl::readProperties ()
201205{
202206 auto lock = this ->getRecursiveConfigLock ();
203- int tmpTopicMode = readProperty<int , IInteger>(PROPERTY_NAME_PUB_TOPIC_MODE, false );
207+ int tmpTopicMode = readProperty<int , IInteger>(PROPERTY_NAME_PUB_TOPIC_MODE, 0 );
204208 if (tmpTopicMode < static_cast <int >(TopicMode::_count) && tmpTopicMode >= 0 )
205209 config.topicMode = static_cast <TopicMode>(tmpTopicMode);
206210 else
@@ -218,6 +222,14 @@ void MqttPublisherFbImpl::readProperties()
218222 config.topicName = readProperty<std::string, IString>(PROPERTY_NAME_PUB_TOPIC_NAME, DEFAULT_PUB_TOPIC_NAME);
219223}
220224
225+ void MqttPublisherFbImpl::propertyChanged ()
226+ {
227+ auto lock = this ->getRecursiveConfigLock ();
228+ readProperties ();
229+ handler = HandlerFactory::create (this ->config , globalId.toStdString ());
230+ validateInputPorts ();
231+ }
232+
221233template <typename retT, typename intfT>
222234retT MqttPublisherFbImpl::readProperty (const std::string& propertyName, const retT defaultValue)
223235{
0 commit comments