IRSOL
C++ code implementing socket server for interacting with Baumer camera.
assignment_input_sequence_length.cpp
Go to the documentation of this file.
2
4#include "irsol/utils.hpp"
5
6namespace irsol {
7namespace server {
8namespace handlers {
13
14std::vector<out_message_t>
16 std::shared_ptr<irsol::server::ClientSession> session,
18{
19 auto& frameListeningState = session->userData().frameListeningState;
20 if(frameListeningState.running()) {
22 session->id(), "Session is already listening to frames. Cannot set a inputSequenceLength.");
23 std::vector<out_message_t> result;
25 message, "Session is already listening to frames. Cannot set a inputSequenceLength."));
26 return result;
27 }
28 const int inputSequenceLength = irsol::utils::toInt(message.value);
29 if(inputSequenceLength <= 0) {
31 session->id(), "inputSequenceLength ({}) must be positive.", inputSequenceLength);
32 std::vector<out_message_t> result;
33 result.emplace_back(
34 irsol::protocol::Error::from(message, "InputSequenceLength must be positive."));
35 return result;
36 }
37 IRSOL_NAMED_LOG_INFO(session->id(), "Setting 'inputSequenceLength' to {}", inputSequenceLength);
38
39 frameListeningState.gisParams.inputSequenceLength = static_cast<uint64_t>(inputSequenceLength);
40 std::vector<out_message_t> result;
42 return result;
43}
44} // namespace handlers
45} // namespace server
46} // namespace irsol
Declaration of the AssignmentInputSequenceLengthHandler class.
AssignmentInputSequenceLengthHandler(std::shared_ptr< Context > ctx)
Constructs the AssignmentInputSequenceLengthHandler.
std::vector< out_message_t > process(std::shared_ptr< irsol::server::ClientSession > session, protocol::Assignment &&message) final override
Processes an assignment message to set the input sequence length.
Generic handler base class for protocol messages.
Definition base.hpp:39
#define IRSOL_NAMED_LOG_INFO(name,...)
Logs an info-level message using a named logger.
Definition logging.hpp:176
#define IRSOL_NAMED_LOG_WARN(name,...)
Logs a warning-level message using a named logger.
Definition logging.hpp:178
constexpr auto makeHandler(std::shared_ptr< Context > ctx, Args &&... args)
Constructs a handler instance of the given type.
Definition factory.hpp:28
int toInt(const irsol::types::protocol_value_t &x)
Converts a protocol value to an integer.
Definition utils.hpp:39
Declaration of the ClientSession class.
Represents an assignment operation in the protocol.
static Error from(const T &msg, const std::string &description)
Creates an error from a specific incoming message type.
Definition error.hpp:63
static Success from(const Assignment &msg, std::optional< irsol::types::protocol_value_t > overrideValue=std::nullopt)
Creates a success message from an Assignment.
Definition success.hpp:75
auto result
General utility functions used throughout the irsol library.