Corrected the format of the AMPL Data File Message

Change-Id: I191d7241a1edff43f2e34995e6d59a5342084b11
This commit is contained in:
Geir Horn 2024-02-08 21:43:17 +01:00
parent 52d2a5626a
commit 294eb0e62f
2 changed files with 15 additions and 13 deletions

View File

@ -373,7 +373,7 @@ AMPLSolver::AMPLSolver( const std::string & TheActorName,
Send( Theron::AMQ::NetworkLayer::TopicSubscription(
Theron::AMQ::NetworkLayer::TopicSubscription::Action::Subscription,
Theron::AMQ::TopicName( DataFileTopic )
Theron::AMQ::TopicName( DataFileMessage::MessageIdentifier )
), GetSessionLayerAddress() );
}
@ -385,7 +385,7 @@ AMPLSolver::~AMPLSolver()
if( HasNetwork() )
Send( Theron::AMQ::NetworkLayer::TopicSubscription(
Theron::AMQ::NetworkLayer::TopicSubscription::Action::CloseSubscription,
Theron::AMQ::TopicName( DataFileTopic )
Theron::AMQ::TopicName( DataFileMessage::MessageIdentifier )
), GetSessionLayerAddress() );
}

View File

@ -174,29 +174,31 @@ private:
// Data file updates
// --------------------------------------------------------------------------
//
// The data files are assumed to be published on a dedicated topic for the
// optimiser
public:
static constexpr std::string_view DataFileTopic
= "eu.nebulouscloud.optimiser.solver.data";
// The message defining the data file is a JSON topic message with the same
// structure as the optimisation problem message: It contains only one
// attribute, which is the name of the data file, and the data file
// content as the value. This content is just saved to the problem file
// directory before it is read back to the AMPL problem definition.
public:
class DataFileMessage
: public Theron::AMQ::JSONTopicMessage
{
public:
// The data files are assumed to be published on a dedicated topic for the
// optimiser
static constexpr std::string_view MessageIdentifier
= "eu.nebulouscloud.optimiser.solver.data";
DataFileMessage( const std::string & TheDataFileName,
const JSON & DataFileContent )
: JSONTopicMessage( std::string( DataFileTopic ),
{ TheDataFileName, DataFileContent } )
: JSONTopicMessage( std::string( MessageIdentifier ),
{ { FileName, TheDataFileName },
{ FileContent, DataFileContent } } )
{}
DataFileMessage( const DataFileMessage & Other )
@ -204,7 +206,7 @@ public:
{}
DataFileMessage()
: JSONTopicMessage( std::string( DataFileTopic ) )
: JSONTopicMessage( std::string( MessageIdentifier ) )
{}
virtual ~DataFileMessage() = default;