Skip to content

Commit

Permalink
Add Os::Queue FPP models (#2948)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-bc authored Oct 15, 2024
1 parent c531fe7 commit b7c334a
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 27 deletions.
1 change: 1 addition & 0 deletions Os/Models/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ set(SOURCE_FILES
"${CMAKE_CURRENT_LIST_DIR}/FileSystem.fpp"
"${CMAKE_CURRENT_LIST_DIR}/Generic.fpp"
"${CMAKE_CURRENT_LIST_DIR}/RawTime.fpp"
"${CMAKE_CURRENT_LIST_DIR}/Queue.fpp"
"${CMAKE_CURRENT_LIST_DIR}/Models.cpp"
)
register_fprime_module()
32 changes: 16 additions & 16 deletions Os/Models/File.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@
module Os {
@ FPP shadow-enum representing Os::File::Status
enum FileStatus {
OP_OK, @< Operation was successful
DOESNT_EXIST, @< File doesn't exist (for read)
NO_SPACE, @< No space left
NO_PERMISSION, @< No permission to read/write file
BAD_SIZE, @< Invalid size parameter
NOT_OPENED, @< file hasn't been opened yet
FILE_EXISTS, @< file already exist (for CREATE with O_EXCL enabled)
NOT_SUPPORTED, @< Kernel or file system does not support operation
INVALID_MODE, @< Mode for file access is invalid for current operation
OP_OK, @< Operation was successful
DOESNT_EXIST, @< File doesn't exist (for read)
NO_SPACE, @< No space left
NO_PERMISSION, @< No permission to read/write file
BAD_SIZE, @< Invalid size parameter
NOT_OPENED, @< file hasn't been opened yet
FILE_EXISTS, @< file already exist (for CREATE with O_EXCL enabled)
NOT_SUPPORTED, @< Kernel or file system does not support operation
INVALID_MODE, @< Mode for file access is invalid for current operation
INVALID_ARGUMENT, @< Invalid argument passed in
OTHER_ERROR, @< A catch-all for other errors. Have to look in implementation-specific code
OTHER_ERROR, @< A catch-all for other errors. Have to look in implementation-specific code
}
@ FPP shadow-enum representing Os::File::Mode
enum FileMode {
OPEN_NO_MODE, @< File mode not yet selected
OPEN_READ, @< Open file for reading
OPEN_CREATE, @< Open file for writing and truncates file if it exists, ie same flags as creat()
OPEN_WRITE, @< Open file for writing
OPEN_SYNC_WRITE, @< Open file for writing; writes don't return until data is on disk
OPEN_APPEND, @< Open file for appending
OPEN_NO_MODE, @< File mode not yet selected
OPEN_READ, @< Open file for reading
OPEN_CREATE, @< Open file for writing and truncates file if it exists, ie same flags as creat()
OPEN_WRITE, @< Open file for writing
OPEN_SYNC_WRITE, @< Open file for writing; writes don't return until data is on disk
OPEN_APPEND, @< Open file for appending
}
}
31 changes: 31 additions & 0 deletions Os/Models/Models.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@
#include "Os/Models/RawTimeStatusEnumAc.hpp"
#include "Os/Models/FileSystemStatusEnumAc.hpp"
#include "Os/Models/GenericStatusEnumAc.hpp"
#include "Os/Models/QueueStatusEnumAc.hpp"
#include "Os/Models/QueueBlockingTypeEnumAc.hpp"
#include "Os/File.hpp"
#include "Os/Task.hpp"
#include "Os/Mutex.hpp"
#include "Os/Directory.hpp"
#include "Os/FileSystem.hpp"
#include "Os/Os.hpp"
#include "Os/RawTime.hpp"
#include "Os/Queue.hpp"

// Check consistency of every constant in the Os::File::Status enum
static_assert(static_cast<FwIndexType>(Os::File::Status::MAX_STATUS) ==
Expand Down Expand Up @@ -180,6 +183,34 @@ static_assert(static_cast<Os::RawTimeStatus::T>(Os::RawTime::Status::INVALID_PAR
static_assert(static_cast<Os::RawTimeStatus::T>(Os::RawTime::Status::OTHER_ERROR) == Os::RawTimeStatus::T::OTHER_ERROR,
"Generic status enums do not match");

// Check consistency of every constant in the Os::Queue::Status enum
static_assert(static_cast<Os::QueueStatus::T>(Os::Queue::Status::OP_OK) == Os::QueueStatus::T::OP_OK,
"Queue status enums do not match");
static_assert(static_cast<Os::QueueStatus::T>(Os::Queue::Status::ALREADY_CREATED) == Os::QueueStatus::T::ALREADY_CREATED,
"Queue status enums do not match");
static_assert(static_cast<Os::QueueStatus::T>(Os::Queue::Status::EMPTY) == Os::QueueStatus::T::EMPTY,
"Queue status enums do not match");
static_assert(static_cast<Os::QueueStatus::T>(Os::Queue::Status::UNINITIALIZED) == Os::QueueStatus::T::UNINITIALIZED,
"Queue status enums do not match");
static_assert(static_cast<Os::QueueStatus::T>(Os::Queue::Status::SIZE_MISMATCH) == Os::QueueStatus::T::SIZE_MISMATCH,
"Queue status enums do not match");
static_assert(static_cast<Os::QueueStatus::T>(Os::Queue::Status::SEND_ERROR) == Os::QueueStatus::T::SEND_ERROR,
"Queue status enums do not match");
static_assert(static_cast<Os::QueueStatus::T>(Os::Queue::Status::RECEIVE_ERROR) == Os::QueueStatus::T::RECEIVE_ERROR,
"Queue status enums do not match");
static_assert(static_cast<Os::QueueStatus::T>(Os::Queue::Status::INVALID_PRIORITY) == Os::QueueStatus::T::INVALID_PRIORITY,
"Queue status enums do not match");
static_assert(static_cast<Os::QueueStatus::T>(Os::Queue::Status::FULL) == Os::QueueStatus::T::FULL,
"Queue status enums do not match");
static_assert(static_cast<Os::QueueStatus::T>(Os::Queue::Status::UNKNOWN_ERROR) == Os::QueueStatus::T::UNKNOWN_ERROR,
"Queue status enums do not match");

// Check consistency of every constant in the Os::Queue::BlockingType enum
static_assert(static_cast<Os::QueueBlockingType::T>(Os::Queue::BlockingType::BLOCKING) == Os::QueueBlockingType::T::BLOCKING,
"Queue BlockingType enums do not match");
static_assert(static_cast<Os::QueueBlockingType::T>(Os::Queue::BlockingType::NONBLOCKING) == Os::QueueBlockingType::T::NONBLOCKING,
"Queue BlockingType enums do not match");

// Check Generic mappings
static_assert(static_cast<Os::GenericStatus::T>(Os::Generic::Status::OP_OK) == Os::GenericStatus::T::OP_OK,
"Generic status enums do not match");
Expand Down
26 changes: 26 additions & 0 deletions Os/Models/Queue.fpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# ======================================================================
# \title Os/Models/Queue.fpp
# \brief FPP type definitions for Os/Queue.hpp concepts
# ======================================================================

module Os {
@ FPP shadow-enum representing Os::Queue::Status
enum QueueStatus {
OP_OK, @< message sent/received okay
ALREADY_CREATED, @< creating an already created queue
EMPTY, @< If non-blocking, all the messages have been drained.
UNINITIALIZED, @< Queue wasn't initialized successfully
SIZE_MISMATCH, @< attempted to send or receive with buffer too large, too small
SEND_ERROR, @< message send error
RECEIVE_ERROR, @< message receive error
INVALID_PRIORITY, @< invalid priority requested
FULL, @< queue was full when attempting to send a message
UNKNOWN_ERROR @< Unexpected error; can't match with returns
}

@ FPP shadow-enum representing Os::Queue::BlockingType
enum QueueBlockingType {
BLOCKING, @< Message will block until space is available
NONBLOCKING @< Message will return with status when space is unavailable
}
}
22 changes: 11 additions & 11 deletions Os/Models/Task.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
module Os {
@ FPP shadow-enum representing Os::Task::Status
enum TaskStatus {
OP_OK, @< message sent/received okay
INVALID_HANDLE, @< Task handle invalid
INVALID_PARAMS, @< started task with invalid parameters
INVALID_STACK, @< started with invalid stack size
UNKNOWN_ERROR, @< unexpected error return value
INVALID_AFFINITY, @< unable to set the task affinity
DELAY_ERROR, @< error trying to delay the task
JOIN_ERROR, @< error trying to join the task
ERROR_RESOURCES, @< unable to allocate more tasks
ERROR_PERMISSION, @< permissions error setting-up tasks
INVALID_STATE, @< Task is in an invalid state for the operation
OP_OK, @< message sent/received okay
INVALID_HANDLE, @< Task handle invalid
INVALID_PARAMS, @< started task with invalid parameters
INVALID_STACK, @< started with invalid stack size
UNKNOWN_ERROR, @< unexpected error return value
INVALID_AFFINITY, @< unable to set the task affinity
DELAY_ERROR, @< error trying to delay the task
JOIN_ERROR, @< error trying to join the task
ERROR_RESOURCES, @< unable to allocate more tasks
ERROR_PERMISSION, @< permissions error setting-up tasks
INVALID_STATE, @< Task is in an invalid state for the operation
}
}

0 comments on commit b7c334a

Please sign in to comment.