Skip to content

Commit

Permalink
refator(daisi): Rename order to task management
Browse files Browse the repository at this point in the history
  • Loading branch information
jgoedeke committed Sep 21, 2023
1 parent 25a05d2 commit 8a9cb4d
Show file tree
Hide file tree
Showing 36 changed files with 174 additions and 176 deletions.
2 changes: 1 addition & 1 deletion daisi/src/cpps/logical/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ add_subdirectory(algorithms)
add_subdirectory(amr)
add_subdirectory(material_flow)
add_subdirectory(message)
add_subdirectory(order_management)
add_subdirectory(task_management)

add_library(daisi_cpps_logical_logical_agent STATIC)
target_sources(daisi_cpps_logical_logical_agent
Expand Down
4 changes: 2 additions & 2 deletions daisi/src/cpps/logical/algorithms/assignment/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ target_sources(daisi_cpps_logical_algorithms_assignment_iterated_auction_assignm
target_link_libraries(daisi_cpps_logical_algorithms_assignment_iterated_auction_assignment_participant
PUBLIC
daisi_cpps_logical_algorithms_assignment_assignment_participant
daisi_cpps_logical_order_management_auction_based_order_management
daisi_cpps_logical_task_management_auction_based_task_management
daisi_cpps_logical_algorithms_assignment_auction_participant_state
daisi_cpps_common_cpps_communicator
)
Expand Down Expand Up @@ -88,7 +88,7 @@ target_sources(daisi_cpps_logical_algorithms_assignment_auction_participant_stat
target_link_libraries(daisi_cpps_logical_algorithms_assignment_auction_participant_state
PUBLIC
daisi_material_flow_model_material_flow
daisi_cpps_logical_order_management_auction_based_order_management
daisi_cpps_logical_task_management_auction_based_task_management
)

add_library(daisi_cpps_logical_algorithms_assignment_centralized_initiator STATIC)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include "cpps/logical/message/auction_based/bid_submission.h"
#include "cpps/logical/message/auction_based/winner_response.h"
#include "cpps/logical/order_management/auction_based_order_management.h"
#include "cpps/logical/task_management/auction_based_task_management.h"
#include "material_flow/model/task.h"

namespace daisi::cpps::logical {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ namespace daisi::cpps::logical {

CentralizedParticipant::CentralizedParticipant(
daisi::cpps::common::CppsCommunicatorPtr communicator,
std::shared_ptr<SimpleOrderManagement> order_management)
: AssignmentParticipant(communicator), order_management_(std::move((order_management))){};
std::shared_ptr<SimpleOrderManagement> task_management)
: AssignmentParticipant(communicator), task_management_(std::move((task_management))){};

bool CentralizedParticipant::process(const AssignmentNotification &assignment_notification) {
const material_flow::Task assigned_task = assignment_notification.getTask();
if (order_management_->canAddTask(assigned_task)) {
order_management_->addTask(assigned_task);
if (task_management_->canAddTask(assigned_task)) {
task_management_->addTask(assigned_task);
} else {
throw std::runtime_error("The order management should always accept the assigned task.");
throw std::runtime_error("The task management should always accept the assigned task.");
}

// Respond to the central allocator. Send the acception / rejection as well as the current status.
AssignmentResponse response(assigned_task.getUuid(), true, order_management_->getFinalMetrics(),
order_management_->getExpectedEndPosition(),
AssignmentResponse response(assigned_task.getUuid(), true, task_management_->getFinalMetrics(),
task_management_->getExpectedEndPosition(),
communicator_->network.getConnectionString());

std::string initiator_connection = assignment_notification.getInitiatorConnection();
Expand All @@ -43,8 +43,8 @@ bool CentralizedParticipant::process(const AssignmentNotification &assignment_no

bool CentralizedParticipant::process(const StatusUpdateRequest &status_request) {
StatusUpdate update(communicator_->network.getConnectionString(),
order_management_->getFinalMetrics(),
order_management_->getExpectedEndPosition());
task_management_->getFinalMetrics(),
task_management_->getExpectedEndPosition());
std::string initiator_connection = status_request.getInitiatorConnection();
communicator_->network.send({initiator_connection, serialize(update)});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include "assignment_participant.h"
#include "cpps/common/cpps_communicator.h"
#include "cpps/logical/order_management/simple_order_management.h"
#include "cpps/logical/task_management/simple_task_management.h"

namespace daisi::cpps::logical {

Expand All @@ -28,7 +28,7 @@ namespace daisi::cpps::logical {
class CentralizedParticipant : public AssignmentParticipant {
public:
CentralizedParticipant(daisi::cpps::common::CppsCommunicatorPtr communicator,
std::shared_ptr<SimpleOrderManagement> order_management);
std::shared_ptr<SimpleOrderManagement> task_management);
~CentralizedParticipant() override = default;

/// @brief React on new task assignment and respond to it.
Expand All @@ -38,8 +38,8 @@ class CentralizedParticipant : public AssignmentParticipant {
REGISTER_IMPLEMENTATION(StatusUpdateRequest)

private:
/// @brief the AMR's order management. Simply accepts a new task assignment.
std::shared_ptr<SimpleOrderManagement> order_management_;
/// @brief the AMR's task management. Simply accepts a new task assignment.
std::shared_ptr<SimpleOrderManagement> task_management_;
};
} // namespace daisi::cpps::logical

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ namespace daisi::cpps::logical {

IteratedAuctionAssignmentParticipant::IteratedAuctionAssignmentParticipant(
daisi::cpps::common::CppsCommunicatorPtr communicator,
std::shared_ptr<AuctionBasedOrderManagement> order_management, AmrDescription description)
std::shared_ptr<AuctionBasedOrderManagement> task_management, AmrDescription description)
: AssignmentParticipant(communicator),
order_management_(std::move(order_management)),
task_management_(std::move(task_management)),
description_(std::move(description)) {
auto topic = AmrFleet::get().getTopicForAbility(description_.getLoadHandling().getAbility());
communicator_->sola.subscribeTopic(topic);
Expand Down Expand Up @@ -94,8 +94,8 @@ bool IteratedAuctionAssignmentParticipant::process(const WinnerNotification &win

bool accept = false;
if (task_state.isValid() &&
order_management_->canAddTask(task_state.getTask(), task_state.getInsertionPoint())) {
auto result = order_management_->getLatestCalculatedInsertionInfo();
task_management_->canAddTask(task_state.getTask(), task_state.getInsertionPoint())) {
auto result = task_management_->getLatestCalculatedInsertionInfo();
auto metrics_comp = result.first;

if (metrics_comp == task_state.getMetricsComposition()) {
Expand All @@ -105,7 +105,7 @@ bool IteratedAuctionAssignmentParticipant::process(const WinnerNotification &win

std::string participant_connection = communicator_->network.getConnectionString();
if (accept) {
bool success = order_management_->addTask(task_state.getTask(), task_state.getInsertionPoint());
bool success = task_management_->addTask(task_state.getTask(), task_state.getInsertionPoint());

if (!success) {
throw std::runtime_error("Winner accepts, but cannot add the task.");
Expand Down Expand Up @@ -134,9 +134,9 @@ void IteratedAuctionAssignmentParticipant::calculateBids(AuctionParticipantState
for (auto &pair : state.task_state_mapping) {
// Iterating through each task state of this auction process

if (order_management_->canAddTask(pair.second.getTask(), nullptr)) {
if (task_management_->canAddTask(pair.second.getTask(), nullptr)) {
// Setting new calculated information if we can add the task
auto result = order_management_->getLatestCalculatedInsertionInfo();
auto result = task_management_->getLatestCalculatedInsertionInfo();
pair.second.setInformation(result.first, result.second);
} else {
// Setting previous information to invalid because we cannot accept anymore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "assignment_participant.h"
#include "auction_participant_state.h"
#include "cpps/common/cpps_communicator.h"
#include "cpps/logical/order_management/auction_based_order_management.h"
#include "cpps/logical/task_management/auction_based_task_management.h"

namespace daisi::cpps::logical {

Expand All @@ -38,7 +38,7 @@ class IteratedAuctionAssignmentParticipant : public AssignmentParticipant {
public:
explicit IteratedAuctionAssignmentParticipant(
daisi::cpps::common::CppsCommunicatorPtr communicator,
std::shared_ptr<AuctionBasedOrderManagement> order_management, AmrDescription description);
std::shared_ptr<AuctionBasedOrderManagement> task_management, AmrDescription description);

~IteratedAuctionAssignmentParticipant() override = default;

Expand All @@ -53,7 +53,7 @@ class IteratedAuctionAssignmentParticipant : public AssignmentParticipant {
REGISTER_IMPLEMENTATION(IterationNotification)

/// @brief A WinnerNotification means that a task was assigned to us. First, we need to check
/// whether we can still accept the task. If yes, we add the task to the order management and send
/// whether we can still accept the task. If yes, we add the task to the task management and send
/// an acceptance WinnerResponse back to the initiator. Otherwise, we must reject.
REGISTER_IMPLEMENTATION(WinnerNotification)

Expand All @@ -63,9 +63,9 @@ class IteratedAuctionAssignmentParticipant : public AssignmentParticipant {
/// tasks for each auction process, as well as previously calculated bids and insertion infos.
std::unordered_map<std::string, AuctionParticipantState> initiator_auction_state_mapping_;

/// @brief Pointer to the order management of the corresponding AmrLogicalAgent.
/// @brief Pointer to the task management of the corresponding AmrLogicalAgent.
/// We need access to calculate bids and add tasks after receiving WinnerNotifications.
std::shared_ptr<AuctionBasedOrderManagement> order_management_;
std::shared_ptr<AuctionBasedOrderManagement> task_management_;

/// @brief Calculating bids for each open task in a state.
/// @param state Relevant auction state.
Expand Down
6 changes: 3 additions & 3 deletions daisi/src/cpps/logical/amr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ target_link_libraries(daisi_cpps_logical_amr_amr_logical_agent
daisi_cpps_amr_message_serializer
ns3::libcore
daisi_cpps_amr_physical_material_flow_functionality_mapping
daisi_cpps_logical_order_management_order_management
daisi_cpps_logical_order_management_stn_order_management
daisi_cpps_logical_order_management_simple_order_management
daisi_cpps_logical_task_management_task_management
daisi_cpps_logical_task_management_stn_task_management
daisi_cpps_logical_task_management_simple_task_management
daisi_utils
NetworkUDPMessage
PRIVATE
Expand Down
30 changes: 14 additions & 16 deletions daisi/src/cpps/logical/amr/amr_logical_agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#include "cpps/logical/algorithms/assignment/centralized_participant.h"
#include "cpps/logical/algorithms/assignment/iterated_auction_assignment_participant.h"
#include "cpps/logical/message/material_flow_update.h"
#include "cpps/logical/order_management/simple_order_management.h"
#include "cpps/logical/order_management/stn_order_management.h"
#include "cpps/logical/task_management/simple_task_management.h"
#include "cpps/logical/task_management/stn_task_management.h"
#include "cpps/packet.h"
#include "logging/logger_manager.h"
#include "solanet/uuid_generator.h"
Expand Down Expand Up @@ -54,28 +54,26 @@ void AmrLogicalAgent::initAlgorithms() {
for (const auto &algo_type : algorithm_config_.algorithm_types) {
switch (algo_type) {
case AlgorithmType::kIteratedAuctionAssignmentParticipant: {
auto stn_order_management = std::make_shared<StnOrderManagement>(
auto stn_task_management = std::make_shared<StnOrderManagement>(
description_, topology_, daisi::util::Pose{execution_state_.getPosition()});
order_management_ = stn_order_management;
task_management_ = stn_task_management;

algorithms_.push_back(std::make_unique<IteratedAuctionAssignmentParticipant>(
communicator_, stn_order_management, description_));
communicator_, stn_task_management, description_));

order_management_->addNotifyTaskAssignmentCallback(
[this]() { this->notifyTaskAssigned(); });
task_management_->addNotifyTaskAssignmentCallback([this]() { this->notifyTaskAssigned(); });

break;
}
case AlgorithmType::kRoundRobinParticipant: {
auto simple_order_management = std::make_shared<SimpleOrderManagement>(
auto simple_task_management = std::make_shared<SimpleOrderManagement>(
description_, topology_, daisi::util::Pose{execution_state_.getPosition()});
order_management_ = simple_order_management;
task_management_ = simple_task_management;

algorithms_.push_back(
std::make_unique<CentralizedParticipant>(communicator_, simple_order_management));
std::make_unique<CentralizedParticipant>(communicator_, simple_task_management));

order_management_->addNotifyTaskAssignmentCallback(
[this]() { this->notifyTaskAssigned(); });
task_management_->addNotifyTaskAssignmentCallback([this]() { this->notifyTaskAssigned(); });

break;
}
Expand Down Expand Up @@ -144,9 +142,9 @@ void AmrLogicalAgent::processMessageAmrOrderUpdate(const AmrOrderUpdate &order_u
}

void AmrLogicalAgent::sendTaskToPhysical() {
order_management_->setNextTask();
if (order_management_->hasTasks()) {
material_flow::Task task = order_management_->getCurrentTask();
task_management_->setNextTask();
if (task_management_->hasTasks()) {
material_flow::Task task = task_management_->getCurrentTask();
execution_state_.setNextTask(task);

AmrOrderInfo amr_order_info(
Expand All @@ -160,7 +158,7 @@ void AmrLogicalAgent::sendTaskToPhysical() {

void AmrLogicalAgent::checkSendingNextTaskToPhysical() {
if (execution_state_.shouldSendNextTaskToPhysical()) {
if (order_management_) {
if (task_management_) {
sendTaskToPhysical();
}
}
Expand Down
4 changes: 2 additions & 2 deletions daisi/src/cpps/logical/amr/amr_logical_agent.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "cpps/amr/message/amr_state.h"
#include "cpps/amr/message/serializer.h"
#include "cpps/logical/logical_agent.h"
#include "cpps/logical/order_management/order_management.h"
#include "cpps/logical/task_management/task_management.h"
#include "ns3/socket.h"
#include "solanet/network_udp/message.h"
#include "utils/structure_helpers.h"
Expand Down Expand Up @@ -110,7 +110,7 @@ class AmrLogicalAgent : public LogicalAgent {
/// @brief The address of the AmrPhysicalAsset after it connected to AmrLogicalAgent.
ns3::Address physical_address_;

std::shared_ptr<OrderManagement> order_management_;
std::shared_ptr<OrderManagement> task_management_;
};
} // namespace daisi::cpps::logical

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#define DAISI_CPPS_LOGICAL_MESSAGE_AUCTION_BASED_BID_SUBMISSION_H_

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

namespace daisi::cpps::logical {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ target_sources(daisi_cpps_logical_message_central_allocation_assignment_response
target_link_libraries(daisi_cpps_logical_message_central_allocation_assignment_response
INTERFACE
solanet_serializer
daisi_cpps_logical_order_management_metrics_composition
daisi_cpps_logical_task_management_metrics_composition
daisi_structure_helpers
)

Expand All @@ -39,6 +39,6 @@ target_sources(daisi_cpps_logical_message_central_allocation_status_update
target_link_libraries(daisi_cpps_logical_message_central_allocation_status_update
INTERFACE
solanet_serializer
daisi_cpps_logical_order_management_metrics_composition
daisi_cpps_logical_task_management_metrics_composition
daisi_structure_helpers
)
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#define DAISI_CPPS_LOGICAL_MESSAGE_CENTRAL_ALLOCATION_ASSIGNMENT_RESPONSE_H_

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

namespace daisi::cpps::logical {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#define DAISI_CPPS_LOGICAL_MESSAGE_CENTRAL_ALLOCATION_STATUS_UPDATE_H_

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

Expand Down
Loading

0 comments on commit 8a9cb4d

Please sign in to comment.