-
Notifications
You must be signed in to change notification settings - Fork 0
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
Support more message (all FRBC related) #5
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b80a54e
feat: add FRBC.StorageStatus to message types
ErikDeBruijn ddc9c65
feat: add several more FRBC messages
ErikDeBruijn 77f051d
Gitignore .idea
ErikDeBruijn d85e09a
Include the messages, refactor to schemas and messages
ErikDeBruijn ec038be
Move MessageType to types.rb
bforma a1241c7
Run Rubocop
jankeesvw 0f29c9a
Add ResourceManagerDetails type
jankeesvw 7679b89
Disable cop, generated code contains single letter params
jankeesvw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ | |
/spec/reports/ | ||
/tmp/ | ||
spec/examples.txt | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
module S2 | ||
module Messages | ||
module MessageType | ||
FRBCActuatorStatus = "FRBC.ActuatorStatus" | ||
end | ||
|
||
class FrbcActuatorStatus < Dry::Struct | ||
|
||
# ID of the FRBC.OperationMode that is presently active. | ||
attribute :active_operation_mode_id, Types::String | ||
|
||
# ID of the actuator this messages refers to | ||
attribute :actuator_id, Types::String | ||
|
||
# ID of this message | ||
attribute :message_id, Types::String | ||
|
||
attribute :message_type, Types::MessageType | ||
|
||
# The number indicates the factor with which the FRBC.OperationMode is configured. The | ||
# factor should be greater than or equal than 0 and less or equal to 1. | ||
attribute :operation_mode_factor, Types::Double | ||
|
||
# ID of the FRBC.OperationMode that was active before the present one. This value shall | ||
# always be provided, unless the active FRBC.OperationMode is the first FRBC.OperationMode | ||
# the Resource Manager is aware of. | ||
attribute :previous_operation_mode_id, Types::String.optional | ||
|
||
# Time at which the transition from the previous FRBC.OperationMode to the active | ||
# FRBC.OperationMode was initiated. This value shall always be provided, unless the active | ||
# FRBC.OperationMode is the first FRBC.OperationMode the Resource Manager is aware of. | ||
attribute :transition_timestamp, Types::String.optional | ||
|
||
def self.from_dynamic!(d) | ||
d = Types::Hash[d] | ||
new( | ||
active_operation_mode_id: d.fetch("active_operation_mode_id"), | ||
actuator_id: d.fetch("actuator_id"), | ||
message_id: d.fetch("message_id"), | ||
message_type: d.fetch("message_type"), | ||
operation_mode_factor: d.fetch("operation_mode_factor"), | ||
previous_operation_mode_id: d["previous_operation_mode_id"], | ||
transition_timestamp: d["transition_timestamp"], | ||
) | ||
end | ||
|
||
def self.from_json!(json) | ||
from_dynamic!(JSON.parse(json)) | ||
end | ||
|
||
def to_dynamic | ||
{ | ||
"active_operation_mode_id" => active_operation_mode_id, | ||
"actuator_id" => actuator_id, | ||
"message_id" => message_id, | ||
"message_type" => message_type, | ||
"operation_mode_factor" => operation_mode_factor, | ||
"previous_operation_mode_id" => previous_operation_mode_id, | ||
"transition_timestamp" => transition_timestamp, | ||
} | ||
end | ||
|
||
def to_json(options = nil) | ||
JSON.generate(to_dynamic, options) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
module S2 | ||
module Messages | ||
module MessageType | ||
FRBCFillLevelTargetProfile = "FRBC.FillLevelTargetProfile" | ||
end | ||
|
||
# The target range in which the fill_level must be for the time period during which the | ||
# element is active. The start of the range must be smaller or equal to the end of the | ||
# range. The CEM must take best-effort actions to proactively achieve this target. | ||
class NumberRange < Dry::Struct | ||
|
||
# Number that defines the end of the range | ||
attribute :end_of_range, Types::Double | ||
|
||
# Number that defines the start of the range | ||
attribute :start_of_range, Types::Double | ||
|
||
def self.from_dynamic!(d) | ||
d = Types::Hash[d] | ||
new( | ||
end_of_range: d.fetch("end_of_range"), | ||
start_of_range: d.fetch("start_of_range"), | ||
) | ||
end | ||
|
||
def self.from_json!(json) | ||
from_dynamic!(JSON.parse(json)) | ||
end | ||
|
||
def to_dynamic | ||
{ | ||
"end_of_range" => end_of_range, | ||
"start_of_range" => start_of_range, | ||
} | ||
end | ||
|
||
def to_json(options = nil) | ||
JSON.generate(to_dynamic, options) | ||
end | ||
end | ||
|
||
class FRBCFillLevelTargetProfileElement < Dry::Struct | ||
|
||
# The duration of the element. | ||
attribute :duration, Types::Integer | ||
|
||
# The target range in which the fill_level must be for the time period during which the | ||
# element is active. The start of the range must be smaller or equal to the end of the | ||
# range. The CEM must take best-effort actions to proactively achieve this target. | ||
attribute :fill_level_range, NumberRange | ||
|
||
def self.from_dynamic!(d) | ||
d = Types::Hash[d] | ||
new( | ||
duration: d.fetch("duration"), | ||
fill_level_range: NumberRange.from_dynamic!(d.fetch("fill_level_range")), | ||
) | ||
end | ||
|
||
def self.from_json!(json) | ||
from_dynamic!(JSON.parse(json)) | ||
end | ||
|
||
def to_dynamic | ||
{ | ||
"duration" => duration, | ||
"fill_level_range" => fill_level_range.to_dynamic, | ||
} | ||
end | ||
|
||
def to_json(options = nil) | ||
JSON.generate(to_dynamic, options) | ||
end | ||
end | ||
|
||
module MessageType | ||
FRBCFillLevelTargetProfile = "FRBC.FillLevelTargetProfile" | ||
end | ||
|
||
class FrbcFillLevelTargetProfile < Dry::Struct | ||
|
||
# List of different fill levels that have to be targeted within a given duration. There | ||
# shall be at least one element. Elements must be placed in chronological order. | ||
attribute :elements, Types.Array(FRBCFillLevelTargetProfileElement) | ||
|
||
# ID of this message | ||
attribute :message_id, Types::String | ||
|
||
attribute :message_type, Types::MessageType | ||
|
||
# Time at which the FRBC.FillLevelTargetProfile starts. | ||
attribute :start_time, Types::String | ||
|
||
def self.from_dynamic!(d) | ||
d = Types::Hash[d] | ||
new( | ||
elements: d.fetch("elements").map { |x| FRBCFillLevelTargetProfileElement.from_dynamic!(x) }, | ||
message_id: d.fetch("message_id"), | ||
message_type: d.fetch("message_type"), | ||
start_time: d.fetch("start_time"), | ||
) | ||
end | ||
|
||
def self.from_json!(json) | ||
from_dynamic!(JSON.parse(json)) | ||
end | ||
|
||
def to_dynamic | ||
{ | ||
"elements" => elements.map { |x| x.to_dynamic }, | ||
"message_id" => message_id, | ||
"message_type" => message_type, | ||
"start_time" => start_time, | ||
} | ||
end | ||
|
||
def to_json(options = nil) | ||
JSON.generate(to_dynamic, options) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
module S2 | ||
module Messages | ||
module MessageType | ||
FRBCInstruction = "FRBC.Instruction" | ||
end | ||
|
||
class FrbcInstruction < Dry::Struct | ||
|
||
# Indicates if this is an instruction during an abnormal condition. | ||
attribute :abnormal_condition, Types::Bool | ||
|
||
# ID of the actuator this instruction belongs to. | ||
attribute :actuator_id, Types::String | ||
|
||
# Indicates the moment the execution of the instruction shall start. When the specified | ||
# execution time is in the past, execution must start as soon as possible. | ||
attribute :execution_time, Types::String | ||
|
||
# ID of the instruction. Must be unique in the scope of the Resource Manager, for at least | ||
# the duration of the session between Resource Manager and CEM. | ||
attribute :id, Types::String | ||
|
||
# ID of this message | ||
attribute :message_id, Types::String | ||
|
||
attribute :message_type, Types::MessageType | ||
|
||
# ID of the FRBC.OperationMode that should be activated. | ||
attribute :operation_mode, Types::String | ||
|
||
# The number indicates the factor with which the FRBC.OperationMode should be configured. | ||
# The factor should be greater than or equal to 0 and less or equal to 1. | ||
attribute :operation_mode_factor, Types::Double | ||
|
||
def self.from_dynamic!(d) | ||
d = Types::Hash[d] | ||
new( | ||
abnormal_condition: d.fetch("abnormal_condition"), | ||
actuator_id: d.fetch("actuator_id"), | ||
execution_time: d.fetch("execution_time"), | ||
id: d.fetch("id"), | ||
message_id: d.fetch("message_id"), | ||
message_type: d.fetch("message_type"), | ||
operation_mode: d.fetch("operation_mode"), | ||
operation_mode_factor: d.fetch("operation_mode_factor"), | ||
) | ||
end | ||
|
||
def self.from_json!(json) | ||
from_dynamic!(JSON.parse(json)) | ||
end | ||
|
||
def to_dynamic | ||
{ | ||
"abnormal_condition" => abnormal_condition, | ||
"actuator_id" => actuator_id, | ||
"execution_time" => execution_time, | ||
"id" => id, | ||
"message_id" => message_id, | ||
"message_type" => message_type, | ||
"operation_mode" => operation_mode, | ||
"operation_mode_factor" => operation_mode_factor, | ||
} | ||
end | ||
|
||
def to_json(options = nil) | ||
JSON.generate(to_dynamic, options) | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MinNameLength: 1
werkt ook, dan kan de cop verder aanblijven.