Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lmc-base-classes
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
LOFAR2.0
lmc-base-classes
Commits
e8817164
Commit
e8817164
authored
4 years ago
by
toor
Browse files
Options
Downloads
Patches
Plain Diff
CT-166
: Removed unused module csp_commands.py.
parent
870453f6
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/ska/base/__init__.py
+0
-1
0 additions, 1 deletion
src/ska/base/__init__.py
src/ska/base/csp_commands.py
+0
-139
0 additions, 139 deletions
src/ska/base/csp_commands.py
with
0 additions
and
140 deletions
src/ska/base/__init__.py
+
0
−
1
View file @
e8817164
...
@@ -14,7 +14,6 @@ __all__ = (
...
@@ -14,7 +14,6 @@ __all__ = (
"
SKASubarrayResourceManager
"
,
"
SKASubarrayResourceManager
"
,
"
SKATelState
"
,
"
SKATelState
"
,
"
ObsDeviceStateModel
"
,
"
ObsDeviceStateModel
"
,
"
csp_commands
"
,
"
csp_subelement_state_machine
"
,
"
csp_subelement_state_machine
"
,
"
CspSubElementMaster
"
,
"
CspSubElementMaster
"
,
"
CspSubElementObsDevice
"
,
"
CspSubElementObsDevice
"
,
...
...
This diff is collapsed.
Click to expand it.
src/ska/base/csp_commands.py
deleted
100644 → 0
+
0
−
139
View file @
870453f6
"""
This module provides an abstract base class for a specialized command
derived from the ActionCommand.
This command class implements the validation of the input arguments of a command.
It also provides the possibility to recover the initial state, the one before the
command was invoked, when wrong input parameters are specified.
"""
import
logging
from
ska.base.commands
import
ActionCommand
,
ResultCode
from
ska.base.faults
import
CommandError
,
ResultCodeError
,
StateModelError
module_logger
=
logging
.
getLogger
(
__name__
)
class
InputValidatedCommand
(
ActionCommand
):
"""
Abstract base class for a tango command, which validates
the input args of a command and restores the original observing state
when the validation fails throwing an exception.
"""
def
__init__
(
self
,
target
,
state_model
,
action_hook
,
start_action
=
False
,
logger
=
None
):
"""
Create a new InputValidatedCommand for a device.
:param target: the object that this base command acts upon.
:type target: object
:param action_hook: a hook for the command, used to build
actions that will be sent to the state model; for example,
if the hook is
"
scan
"
, then success of the command will
result in action
"
scan_succeeded
"
being sent to the state
model.
:type action_hook: string
:param start_action: whether the state model supports a start
action (i.e. to put the state model into an transient state
while the command is running); default False
:type start_action: boolean
:param logger: the logger to be used by this Command. If not
provided, then a default module logger will be used.
:type logger: a logger that implements the standard library
logger interface
"""
super
().
__init__
(
target
,
state_model
,
action_hook
,
start_action
,
logger
=
logger
)
# _validation_success: flag to signal if the input argument of a command are valid.
self
.
_validation_success
=
False
self
.
_rejected_hook
=
f
"
{
action_hook
}
_rejected
"
# destination and source machine state: used to re-store the state before the
# command execution, when this fails for bad input arguments.
self
.
_machine_dest
=
"
IDLE
"
self
.
_machine_source
=
"
IDLE
"
def
_call_do
(
self
,
argin
=
None
):
"""
Helper method that ensures the validation of command arguments,
if specified, is performed before the ``do`` method call.
:param argin: the argument passed to the Tango command, if
present
:type argin: ANY
"""
if
argin
is
None
:
(
return_code
,
message
)
=
self
.
do
()
else
:
(
return_code
,
message
)
=
self
.
validate_input
(
argin
)
if
return_code
==
ResultCode
.
FAILED
:
return
(
return_code
,
message
)
self
.
_validation_success
=
True
(
return_code
,
message
)
=
self
.
do
(
argin
=
argin
)
self
.
logger
.
info
(
f
"
Exiting command
{
self
.
name
}
with return_code
{
return_code
!s}
,
"
f
"
message:
'
{
message
}
'"
)
return
(
return_code
,
message
)
def
validate_input
(
self
,
argin
):
"""
Method implementing the validation of the command
arguments.
The class provides stub functionality; subclasses should subclass
this method with their command functionality.
:param argin: the command input parameters
:type argin: ANY
"""
raise
NotImplementedError
(
"
InputValidatedCommand is abstract; validate_input() must be subclassed not called.
"
)
def
_get_rejected_hook
(
self
):
"""
Retrieve the trigger action that restores the observation state as it was
before the command was started.
:return: the trigger name if found, otherwise an empty string.
:rtype: str
"""
obs_state_machine
=
self
.
state_model
.
_observation_state_machine
triggers
=
obs_state_machine
.
get_triggers
(
self
.
_machine_dest
)
for
trigger
in
triggers
:
# get the list with states satisfying the conditions on trigger, dest and source
# skip the trigger starting with 'to_' string.
#if trigger.startswith('to_'):
if
self
.
_rejected_hook
in
trigger
:
state
=
obs_state_machine
.
get_transitions
(
trigger
=
trigger
,
dest
=
self
.
_machine_source
,
source
=
self
.
_machine_dest
)
if
state
:
msg
=
"
Invoke {} action to restore state to {}
"
.
format
(
trigger
,
self
.
_machine_source
)
self
.
logger
.
info
(
msg
)
return
trigger
return
''
def
started
(
self
):
"""
Action to perform upon starting the comand.
Store the source and destination machine states
that can be used to restore the observing state
before the command was invoked.
"""
self
.
_machine_source
=
self
.
state_model
.
_observation_state_machine
.
state
super
().
started
()
self
.
_machine_dest
=
self
.
state_model
.
_observation_state_machine
.
state
self
.
_validation_success
=
False
def
fatal_error
(
self
):
"""
Callback for the failed completion of the command.
If the validation of the command argument fails,
the action to restore the original observing state is called.
"""
action
=
"
fatal_error
"
if
not
self
.
_validation_success
:
_action
=
self
.
_get_rejected_hook
()
if
_action
:
action
=
_action
self
.
_perform_action
(
action
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment