Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add message UUIDs to OptiMaFlow messages and fix out-of-range error #125

Merged
merged 2 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ void IteratedAuctionAssignmentInitiator::callForProposal() {
auto topic = ability_topic_mapping_[pair.first];

CallForProposal cfp(initiator_connection, pair.second);
solanet::UUID uuid = communicator_->sola.publishMessage(topic, serialize(cfp));
logger_->logCppsMessage(uuid, "TODO log cfp");
communicator_->sola.publishMessage(topic, serialize(cfp));
logger_->logCppsMessage(cfp.getUUID(), "TODO log cfp");
}
}

Expand All @@ -173,8 +173,8 @@ void IteratedAuctionAssignmentInitiator::iterationNotification(
[&](const auto &task) { return task.getUuid(); });

IterationNotification notification(initiator_connection, task_uuids);
solanet::UUID uuid = communicator_->sola.publishMessage(topic, serialize(notification));
logger_->logCppsMessage(uuid, "TODO log iteration notification");
communicator_->sola.publishMessage(topic, serialize(notification));
logger_->logCppsMessage(notification.getUUID(), "TODO log iteration notification");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,12 @@ RoundRobinInitiator::chooseParticipantForTask(const material_flow::Task &task) {
if (possible_candidates.empty()) {
throw std::runtime_error("No AMR matches the task requirements");
}
int random_index = 0;
if (possible_candidates.size() > 1) {
// choose AMR randomly
std::uniform_int_distribution<uint64_t> dist(0, possible_candidates.size());
random_index = dist(daisi::global_random_engine);
}

// choose AMR randomly
std::uniform_int_distribution<uint64_t> dist(0, possible_candidates.size() - 1);
const uint64_t random_index = dist(daisi::global_random_engine);
auto chosen_participant =
std::make_shared<ParticipantInfoRoundRobin>(possible_candidates[random_index]);
std::make_shared<ParticipantInfoRoundRobin>(possible_candidates.at(random_index));

return chosen_participant;
}
Expand Down
10 changes: 10 additions & 0 deletions daisi/src/cpps/logical/message/auction_based/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ target_link_libraries(daisi_cpps_logical_message_auction_based_call_for_proposal
INTERFACE
solanet_serializer
daisi_material_flow_model_task
solanet_uuid
solanet_uuid_generator_sim
)

add_library(daisi_cpps_logical_message_auction_based_bid_submission INTERFACE)
Expand All @@ -18,6 +20,8 @@ target_link_libraries(daisi_cpps_logical_message_auction_based_bid_submission
INTERFACE
solanet_serializer
daisi_cpps_amr_model_amr_static_ability
solanet_uuid
solanet_uuid_generator_sim
)

add_library(daisi_cpps_logical_message_auction_based_iteration_notification INTERFACE)
Expand All @@ -28,6 +32,8 @@ target_sources(daisi_cpps_logical_message_auction_based_iteration_notification
target_link_libraries(daisi_cpps_logical_message_auction_based_iteration_notification
INTERFACE
solanet_serializer
solanet_uuid
solanet_uuid_generator_sim
)

add_library(daisi_cpps_logical_message_auction_based_winner_notification INTERFACE)
Expand All @@ -39,6 +45,8 @@ target_link_libraries(daisi_cpps_logical_message_auction_based_winner_notificati
INTERFACE
solanet_serializer
daisi_structure_helpers
solanet_uuid
solanet_uuid_generator_sim
)

add_library(daisi_cpps_logical_message_auction_based_winner_response INTERFACE)
Expand All @@ -49,4 +57,6 @@ target_sources(daisi_cpps_logical_message_auction_based_winner_response
target_link_libraries(daisi_cpps_logical_message_auction_based_winner_response
INTERFACE
solanet_serializer
solanet_uuid
solanet_uuid_generator_sim
)
10 changes: 9 additions & 1 deletion daisi/src/cpps/logical/message/auction_based/bid_submission.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@
#ifndef DAISI_CPPS_LOGICAL_MESSAGE_AUCTION_BASED_BID_SUBMISSION_H_
#define DAISI_CPPS_LOGICAL_MESSAGE_AUCTION_BASED_BID_SUBMISSION_H_

#include <string>

#include "cpps/amr/model/amr_static_ability.h"
#include "cpps/logical/task_management/metrics_composition.h"
#include "solanet/serializer/serialize.h"
#include "solanet/uuid.h"
#include "solanet/uuid_generator.h"

namespace daisi::cpps::logical {

Expand Down Expand Up @@ -60,9 +64,13 @@ class BidSubmission {
return participant_connection_ > other.participant_connection_;
}

SERIALIZE(task_uuid_, participant_connection_, participant_ability_, metrics_composition_)
solanet::UUID getUUID() const { return uuid_; }

SERIALIZE(uuid_, task_uuid_, participant_connection_, participant_ability_, metrics_composition_)

private:
solanet::UUID uuid_ = solanet::generateUUID();

std::string task_uuid_;

std::string participant_connection_;
Expand Down
11 changes: 10 additions & 1 deletion daisi/src/cpps/logical/message/auction_based/call_for_proposal.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@
#ifndef DAISI_CPPS_LOGICAL_MESSAGE_AUCTION_BASED_CALL_FOR_PROPOSAL_H_
#define DAISI_CPPS_LOGICAL_MESSAGE_AUCTION_BASED_CALL_FOR_PROPOSAL_H_

#include <string>
#include <vector>

#include "material_flow/model/task.h"
#include "solanet/serializer/serialize.h"
#include "solanet/uuid.h"
#include "solanet/uuid_generator.h"

namespace daisi::cpps::logical {

Expand All @@ -32,9 +37,13 @@ class CallForProposal {

const std::vector<daisi::material_flow::Task> &getTasks() const { return tasks_; }

SERIALIZE(initiator_connection_, tasks_)
solanet::UUID getUUID() const { return uuid_; }

SERIALIZE(uuid_, initiator_connection_, tasks_)

private:
solanet::UUID uuid_ = solanet::generateUUID();

std::string initiator_connection_;

std::vector<daisi::material_flow::Task> tasks_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
#ifndef DAISI_CPPS_LOGICAL_MESSAGE_AUCTION_BASED_ITERATION_NOTIFICATION_H_
#define DAISI_CPPS_LOGICAL_MESSAGE_AUCTION_BASED_ITERATION_NOTIFICATION_H_

#include <string>
#include <vector>

#include "solanet/serializer/serialize.h"
#include "solanet/uuid.h"
#include "solanet/uuid_generator.h"

namespace daisi::cpps::logical {

Expand All @@ -32,9 +37,13 @@ class IterationNotification {

const std::vector<std::string> &getTaskUuids() const { return task_uuids_; }

solanet::UUID getUUID() const { return uuid_; }

SERIALIZE(initiator_connection_, task_uuids_)

private:
solanet::UUID uuid_ = solanet::generateUUID();

std::string initiator_connection_;

std::vector<std::string> task_uuids_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
#ifndef DAISI_CPPS_LOGICAL_MESSAGE_AUCTION_BASED_WINNER_NOTIFICATION_H_
#define DAISI_CPPS_LOGICAL_MESSAGE_AUCTION_BASED_WINNER_NOTIFICATION_H_

#include <string>

#include "solanet/serializer/serialize.h"
#include "solanet/uuid.h"
#include "solanet/uuid_generator.h"
#include "utils/structure_helpers.h"

namespace daisi::cpps::logical {
Expand All @@ -37,9 +41,13 @@ class WinnerNotification {

const daisi::util::Duration &getLatestFinishTime() const { return latest_finish_time_; }

SERIALIZE(task_uuid_, initiator_connection_, latest_finish_time_)
solanet::UUID getUUID() const { return uuid_; }

SERIALIZE(uuid_, task_uuid_, initiator_connection_, latest_finish_time_)

private:
solanet::UUID uuid_ = solanet::generateUUID();

std::string task_uuid_;

std::string initiator_connection_;
Expand Down
10 changes: 9 additions & 1 deletion daisi/src/cpps/logical/message/auction_based/winner_response.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
#ifndef DAISI_CPPS_LOGICAL_MESSAGE_AUCTION_BASED_WINNER_RESPONSE_H_
#define DAISI_CPPS_LOGICAL_MESSAGE_AUCTION_BASED_WINNER_RESPONSE_H_

#include <string>

#include "solanet/serializer/serialize.h"
#include "solanet/uuid.h"
#include "solanet/uuid_generator.h"

namespace daisi::cpps::logical {

Expand All @@ -35,9 +39,13 @@ class WinnerResponse {

bool doesAccept() const { return accept_; }

SERIALIZE(task_uuid_, accept_, participant_connection_)
solanet::UUID getUUID() const { return uuid_; }

SERIALIZE(uuid_, task_uuid_, accept_, participant_connection_)

private:
solanet::UUID uuid_ = solanet::generateUUID();

std::string task_uuid_;

std::string participant_connection_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ target_link_libraries(daisi_cpps_logical_message_central_allocation_assignment_n
INTERFACE
solanet_serializer
daisi_material_flow_model_task
solanet_uuid
solanet_uuid_generator_sim
)

add_library(daisi_cpps_logical_message_central_allocation_assignment_response INTERFACE)
Expand All @@ -19,6 +21,8 @@ target_link_libraries(daisi_cpps_logical_message_central_allocation_assignment_r
solanet_serializer
daisi_cpps_logical_task_management_metrics_composition
daisi_structure_helpers
solanet_uuid
solanet_uuid_generator_sim
)

add_library(daisi_cpps_logical_message_central_allocation_status_update_request INTERFACE)
Expand All @@ -29,6 +33,8 @@ target_sources(daisi_cpps_logical_message_central_allocation_status_update_reque
target_link_libraries(daisi_cpps_logical_message_central_allocation_status_update_request
INTERFACE
solanet_serializer
solanet_uuid
solanet_uuid_generator_sim
)

add_library(daisi_cpps_logical_message_central_allocation_status_update INTERFACE)
Expand All @@ -41,4 +47,6 @@ target_link_libraries(daisi_cpps_logical_message_central_allocation_status_updat
solanet_serializer
daisi_cpps_logical_task_management_metrics_composition
daisi_structure_helpers
solanet_uuid
solanet_uuid_generator_sim
)
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
#ifndef DAISI_CPPS_LOGICAL_MESSAGE_CENTRAL_ALLOCATION_ASSIGNMENT_NOTIFICATION_H_
#define DAISI_CPPS_LOGICAL_MESSAGE_CENTRAL_ALLOCATION_ASSIGNMENT_NOTIFICATION_H_

#include <string>

#include "material_flow/model/task.h"
#include "solanet/serializer/serialize.h"
#include "solanet/uuid.h"
#include "solanet/uuid_generator.h"

namespace daisi::cpps::logical {

Expand All @@ -33,9 +37,13 @@ class AssignmentNotification {
const material_flow::Task &getTask() const { return task_; }
const std::string &getInitiatorConnection() const { return initiator_connection_; }

SERIALIZE(task_, initiator_connection_)
solanet::UUID getUUID() const { return uuid_; }

SERIALIZE(uuid_, task_, initiator_connection_)

private:
solanet::UUID uuid_ = solanet::generateUUID();

material_flow::Task task_;
std::string initiator_connection_;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@
#ifndef DAISI_CPPS_LOGICAL_MESSAGE_CENTRAL_ALLOCATION_ASSIGNMENT_RESPONSE_H_
#define DAISI_CPPS_LOGICAL_MESSAGE_CENTRAL_ALLOCATION_ASSIGNMENT_RESPONSE_H_

#include <string>

#include "cpps/amr/model/amr_static_ability.h"
#include "cpps/logical/task_management/metrics_composition.h"
#include "solanet/serializer/serialize.h"
#include "solanet/uuid.h"
#include "solanet/uuid_generator.h"

namespace daisi::cpps::logical {

Expand All @@ -42,9 +46,13 @@ class AssignmentResponse {

bool doesAccept() const { return accept_; }

SERIALIZE(task_uuid_, accept_, metrics_, end_position_, participant_connection_)
solanet::UUID getUUID() const { return uuid_; }

SERIALIZE(uuid_, task_uuid_, accept_, metrics_, end_position_, participant_connection_)

private:
solanet::UUID uuid_ = solanet::generateUUID();

std::string task_uuid_;

bool accept_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@
#ifndef DAISI_CPPS_LOGICAL_MESSAGE_CENTRAL_ALLOCATION_STATUS_UPDATE_H_
#define DAISI_CPPS_LOGICAL_MESSAGE_CENTRAL_ALLOCATION_STATUS_UPDATE_H_

#include <string>

#include "cpps/amr/model/amr_static_ability.h"
#include "cpps/logical/task_management/metrics_composition.h"
#include "solanet/serializer/serialize.h"
#include "solanet/uuid.h"
#include "solanet/uuid_generator.h"
#include "utils/structure_helpers.h"

namespace daisi::cpps::logical {
Expand All @@ -39,9 +43,13 @@ class StatusUpdate {
const Metrics &getMetrics() { return metrics_; }
const util::Position getEndPosition() { return end_position_; }

SERIALIZE(participant_connection_, metrics_, end_position_)
solanet::UUID getUUID() const { return uuid_; }

SERIALIZE(uuid_, participant_connection_, metrics_, end_position_)

private:
solanet::UUID uuid_ = solanet::generateUUID();

std::string participant_connection_;
Metrics metrics_;
util::Position end_position_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
#ifndef DAISI_CPPS_LOGICAL_MESSAGE_CENTRAL_ALLOCATION_STATUS_UPDATE_REQUEST_H_
#define DAISI_CPPS_LOGICAL_MESSAGE_CENTRAL_ALLOCATION_STATUS_UPDATE_REQUEST_H_

#include <string>

#include "solanet/serializer/serialize.h"
#include "solanet/uuid.h"
#include "solanet/uuid_generator.h"

namespace daisi::cpps::logical {

Expand All @@ -31,9 +35,13 @@ class StatusUpdateRequest {

const std::string &getInitiatorConnection() const { return initiator_connection_; }

SERIALIZE(initiator_connection_)
solanet::UUID getUUID() const { return uuid_; }

SERIALIZE(uuid_, initiator_connection_)

private:
solanet::UUID uuid_ = solanet::generateUUID();

std::string initiator_connection_;
};
} // namespace daisi::cpps::logical
Expand Down