1 # Copyright (C) 2010 W. Trevor King <wking@drexel.edu>
3 # This file is part of Hooke.
5 # Hooke is free software: you can redistribute it and/or modify it
6 # under the terms of the GNU Lesser General Public License as
7 # published by the Free Software Foundation, either version 3 of the
8 # License, or (at your option) any later version.
10 # Hooke is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
13 # Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with Hooke. If not, see
17 # <http://www.gnu.org/licenses/>.
22 >>> from hooke.command_stack import CommandStack
23 >>> from hooke.engine import CommandMessage
24 >>> from hooke.hooke import Hooke
27 Setup logging so we can check command output in the doctest.
29 >>> log = logging.getLogger('hooke')
30 >>> stdout_handler = logging.StreamHandler(sys.stdout)
31 >>> log.addHandler(stdout_handler)
33 Setup a playlist to act on.
35 >>> h.run_command('load playlist',
36 ... {'input': 'test/data/vclamp_picoforce/playlist'}) # doctest: +ELLIPSIS
37 engine running internal <CommandMessage load playlist {input: test/data/vclamp_picoforce/playlist}>
38 engine message from load playlist (<class 'hooke.playlist.FilePlaylist'>): <FilePlaylist ...>
39 engine message from load playlist (<class 'hooke.command.Success'>):
40 >>> stack = CommandStack([
41 ... CommandMessage('get curve'),
42 ... CommandMessage('zero surface contact point'),
45 Test `apply command stack to playlist`.
47 >>> h.run_command('apply command stack to playlist',
48 ... {'commands': stack, 'evaluate': True}) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE, +REPORT_UDIFF
49 engine running internal <CommandMessage apply command stack to playlist
50 {commands: [<CommandMessage get curve>,
51 <CommandMessage zero surface contact point>],
53 loading curve 20071120a_i27_t33.100 with driver ...
54 engine running internal <CommandMessage execute command stack {...}>
55 engine running internal <CommandMessage get curve {stack: True}>
56 engine message from get curve (<class 'hooke.curve.Curve'>): <Curve 20071120a_i27_t33.100>
57 engine message from get curve (<class 'hooke.command.Success'>):
58 engine running internal <CommandMessage zero surface contact point {...}>
59 engine message from zero surface contact point (<type 'dict'>): {...}
60 engine message from zero surface contact point (<class 'hooke.command.Success'>):
61 engine message from execute command stack (<class 'hooke.command.Success'>):
62 loading curve 20071120a_i27_t33.101 with driver ...
63 engine running internal <CommandMessage execute command stack {...}>
64 engine running internal <CommandMessage get curve {stack: True}>
65 engine message from get curve (<class 'hooke.curve.Curve'>): <Curve 20071120a_i27_t33.101>
66 engine message from get curve (<class 'hooke.command.Success'>):
67 engine running internal <CommandMessage zero surface contact point {...}>
68 engine message from zero surface contact point (<type 'dict'>): {...}
69 engine message from zero surface contact point (<class 'hooke.command.Success'>):
70 engine message from execute command stack (<class 'hooke.command.Success'>):
71 loading curve 20071120a_i27_t33.102 with driver ...
74 loading curve 20071120a_i27_t33.199 with driver ...
75 engine running internal <CommandMessage execute command stack {...}>
76 engine running internal <CommandMessage get curve {stack: True}>
77 engine message from get curve (<class 'hooke.curve.Curve'>): <Curve 20071120a_i27_t33.199>
78 engine message from get curve (<class 'hooke.command.Success'>):
79 engine running internal <CommandMessage zero surface contact point {...}>
80 engine message from zero surface contact point (<type 'dict'>): {...}
81 engine message from zero surface contact point (<class 'hooke.command.Success'>):
82 engine message from execute command stack (<class 'hooke.command.Success'>):
83 loading curve 0x06130001 with driver ...
84 unloading curve 20071120a_i27_t33.100
85 engine running internal <CommandMessage execute command stack
86 {commands: [<CommandMessage get curve>,
87 <CommandMessage zero surface contact point>],
89 engine running internal <CommandMessage get curve {stack: True}>
91 engine message from apply command stack to playlist (<class 'hooke.command.Success'>):
92 >>> curve = h.playlists.current().current(
93 ... ) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
94 loading curve 20071120a_i27_t33.100 with driver ...
95 engine running internal <CommandMessage zero surface contact point
96 {block: None, curve: <Curve 20071120a_i27_t33.100>, ...}>
97 engine message from zero surface contact point (<type 'dict'>): {...}
98 engine message from zero surface contact point (<class 'hooke.command.Success'>):
99 unloading curve 20071120a_i27_t33.102
101 <Curve 20071120a_i27_t33.100>
102 >>> curve.command_stack # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
103 [<CommandMessage zero surface contact point
104 {block: None, curve: <Curve 20071120a_i27_t33.100>, ...}>]
106 Test `apply command stack to playlist` without evaluating.
108 >>> stack = CommandStack([
109 ... CommandMessage('flat_filter_peaks --block retract --min_points 1'),
111 >>> h.run_command('apply command stack to playlist',
112 ... {'commands': stack, 'evaluate': False}
113 ... ) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE, +REPORT_UDIFF
114 engine running internal
115 <CommandMessage apply command stack to playlist {...}>
116 unloading curve 20071120a_i27_t33.100
117 unloading curve 20071120a_i27_t33.101
118 unloading curve 20071120a_i27_t33.102
120 unloading curve 20071120a_i27_t33.199
121 unloading curve 0x06130001
122 unloading curve 0x07200000
123 engine message from apply command stack to playlist
124 (<class 'hooke.command.Success'>):
125 >>> for c in curve.command_stack:
126 ... print c # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE, +REPORT_UDIFF
127 <CommandMessage zero surface contact point
128 {..., curve: <Curve 20071120a_i27_t33.100>...}>
129 <CommandMessage flat_filter_peaks --block retract --min_points 1>
131 Test `clear curve command stack`.
133 >>> h.run_command('clear curve command stack', arguments={})
134 engine running internal <CommandMessage clear curve command stack>
135 engine message from clear curve command stack (<class 'hooke.command.Success'>):
136 >>> curve.command_stack