|
META TOPICPARENT |
name="DpHipe" |
Adding Tools to HIPE |
| compute=ComputeTask()
|
|
< < | To make your task appear in the "Run Tools" view, you need to add the following lines: |
> > | To make your task appear in the "Tasks" view, you need to add the following lines: |
|
|
|
< < | from herschel.ia.task.views import TaskToolFactory
TaskToolFactory.register(compute) |
> > | from herschel.ia.task.views import TaskToolRegistry
toolRegistry = TaskToolRegistry.getInstance()
toolRegistry.register(compute) |
| |
|
< < | For PCSS (PACS' builds) users, this __init__.py file is located at $install_dir/data/toolbox/your_sub_system. |
> > | For PACS users, this __init__.py file is located at $install_dir/data/toolbox/your_sub_system. |
|
You can also specify that your task belongs to one or more Category :
from herschel.ia.gui.kernel.Tool import Category
|
|
< < | TaskToolFactory.register(compute, [Category.IMAGE, Category.PACS])) |
> > | toolRegistry.register(compute, [Category.IMAGE, Category.PACS])) |
|
Your task will now be enabled whenever a session variable is selected which matches the type of the first input parameter within your task! |
|
Task compliance |
|
< < |
- write user documentation (jtags)! That will be automatically picked up whenever a user asks the system for help on your task.
- the name of the task should be a legal variable name in the global name-space. For example your instance of
MyTask should report itself as e.g.: "myTask" and not "This is my task".
- if your prime parameter is not the first parameter in your task, specify the prime parameter using the
setPrimeInput method in the signature
- write a parameter validator for your prime parameter if your task should be listed not only on prime data type but on prime data contents as well.
|
> > |
- Write user documentation (jtags)! That will be automatically picked up whenever a user asks the system for help on your task.
- The name of the task should be a legal variable name in the global name-space. For example your instance of
MyTask should report itself as e.g.: "myTask" and not "This is my task".
- If your prime parameter is not the first parameter in your task, specify the prime parameter using the
setPrimeInput method in the signature
- Write a parameter validator for your prime parameter if your task should be listed not only on prime data type but on prime data contents as well.
|
| |
|
< < | Some Recommendations of use of simple tasks and its limitations |
> > | Recommendations for simple tasks and limitations |
| |
|
< < |
- Use a function that fully initializes TaskParameters: you avoid working with partially initialized data or data with non obvious defaults.
|
> > |
- Use a function that fully initializes TaskParameters: you avoid working with partially initialized data or data with non obvious defaults.
|
|
- Please take care to register your task properly: otherwise it may half-work, which is much worse than not working at all!
|
|
< < |
- Capture exceptions and check your params before trying to properly execute if you want to provide better error reporting than the one provided by default
|
> > |
- Capture exceptions and check your params before trying to properly execute, if you want to provide better error reporting than the one provided by default.
|
|
- You should not do user interaction after you have started execute() (not on EDT).
|
|
< < |
- Validators: you cannot compare multiple parameters, order of execution is not specified, will be executed several times. SO if you need to validate dependent parameters it should be done later.
- Once you are in execute() console has already been updated with the command : Although you can change the value of TaskParameters, this will not be properly reflected on the UI, so don't do it. So once you are on execute() you can check , possibly abort, and properly execute (nothing else).
|
> > |
- Validators: you cannot compare multiple parameters, order of execution is not specified, will be executed several times. So, if you need to validate dependent parameters, it should be done later.
- Once you are in execute() console has already been updated with the command : Although you can change the value of TaskParameters, this will not be properly reflected on the UI, so don't do it. So once you are on execute() you can check , possibly abort, and properly execute (nothing else).
|
|
Adding a Tool that is not a Task |
| "herschel.path.to.MyTool"))
# Register the tool so it is automatically available for the proper variables in HIPE |
|
< < | from herschel.ia.gui.kernel import ToolFactory |
> > | from herschel.ia.gui.kernel import ToolRegistry |
| from herschel.path.to import MyTool |
|
< < | ToolFactory.register(MyTool()) |
> > | ToolRegistry.getInstance().register(MyTool()) |
|
|
| "factory.editor.tool",
"herschel.your.package.ButtonTool")) |
|
< < | from herschel.ia.gui.kernel import ToolFactory |
> > | from herschel.ia.gui.kernel import ToolRegistry |
| from herschel.your.package import ButtonTool |
|
< < | ToolFactory.register(ButtonTool()) |
> > | ToolRegistry().getInstance().register(ButtonTool()) |
|
|
|
Triggering Events |
|
< < | For a full detailed section about triggering events have a look at DpHipeCommonUtilities |
> > | For a full detailed section about triggering events have a look at DpHipeCommonUtilities. |
|
<-- Author: JorgoBakker - 21 Dec 2007 --> |