-# Copyright (C) 2008-2010 Alberto Gomez-Kasai
-# Fabiano's Benedetti
+# Copyright (C) 2008-2010 Alberto Gomez-Casado
+# Fabrizio Benedetti
# Massimo Sandal <devicerandom@gmail.com>
# W. Trevor King <wking@drexel.edu>
#
import numpy
from ..command import Command, Argument, Failure
+from ..command_stack import CommandStack
from ..curve import Data
from ..engine import CommandMessage
from ..util.calculus import derivative
Notes
-----
`hooke` is intended to attach the selected curve to the local
- playlist, and the returned curve should not be effected by the
+ playlist; the returned curve should not be effected by the
state of `hooke`. This is important for reliable
:class:`~hooke.command_stack.CommandStack`\s.
"""
(e.g. :class:`GetCommand`) to avoid adding themselves to the
stack entirely.
"""
- curve = self._curve(hooke=None, params=params)
- if (len(curve.command_stack) > 0
- and curve.command_stack[-1].command == self.name
- and curve.command_stack[-1].arguments == params):
- pass # no need to place duplicate calls on the stack.
- else:
- curve.command_stack.append(CommandMessage(
- self.name, params))
+ if params['stack'] == True:
+ curve = self._curve(hooke=None, params=params)
+ if (len(curve.command_stack) > 0
+ and curve.command_stack[-1].command == self.name
+ and curve.command_stack[-1].arguments == params):
+ pass # no need to place duplicate calls on the stack.
+ else:
+ curve.command_stack.append(CommandMessage(
+ self.name, params))
class BlockCommand (CurveCommand):
self._commands = [
GetCommand(self), InfoCommand(self), DeltaCommand(self),
ExportCommand(self), DifferenceCommand(self),
- DerivativeCommand(self), PowerSpectrumCommand(self)]
+ DerivativeCommand(self), PowerSpectrumCommand(self),
+ ClearStackCommand(self)]
# Define commands
Argument(name='all', type='bool', default=False, count=1,
help='Get all curve information.'),
]
- self.fields = ['name', 'path', 'experiment', 'driver', 'filetype', 'note',
- 'blocks', 'block sizes']
+ self.fields = ['name', 'path', 'experiment', 'driver', 'filetype',
+ 'note', 'command stack', 'blocks', 'block sizes']
for field in self.fields:
args.append(Argument(
name=field, type='bool', default=False, count=1,
fields = {}
for key in self.fields:
fields[key] = params[key]
- if reduce(lambda x,y: x and y, fields.values()) == False:
+ if reduce(lambda x,y: x or y, fields.values()) == False:
params['all'] = True # No specific fields set, default to 'all'
if params['all'] == True:
for key in self.fields:
def _get_note(self, curve):
return curve.info.get('note', None)
+ def _get_command_stack(self, curve):
+ return curve.command_stack
+
def _get_blocks(self, curve):
return len(curve.data)
return params
+class ClearStackCommand (CurveCommand):
+ """Empty a curve's command stack.
+ """
+ def __init__(self, plugin):
+ super(ClearStackCommand, self).__init__(
+ name='clear curve command stack',
+ help=self.__doc__, plugin=plugin)
+
+ def _run(self, hooke, inqueue, outqueue, params):
+ curve = self._curve(hooke, params)
+ curve.command_stack = CommandStack()
+
+
class OldCruft (object):
def do_forcebase(self,args):