-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathpostproc_setup.py
88 lines (72 loc) · 2.36 KB
/
postproc_setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!usr/bin/env python
"""
Configuration for post processors
"""
import mimic_config
import importlib
importlib.reload(mimic_config)
# Import your processor as private here:
from .ABB.RAPID.rapid \
import SimpleRAPIDProcessor \
as __SimpleRAPIDProcessor
from .KUKA.EntertainTech.entertaintech \
import SimpleEntertainTechProcessor \
as __SimpleEntertainTechProcessor
from .KUKA.KRL.krl \
import SimpleKRLProcessor \
as __SimpleKRLProcessor
from .Staubli.VAL3.val3 \
import SimpleVAL3Processor \
as __SimpleVAL3Processor
from .GENERAL.CSV.comma_separated_vals \
import SimpleCSVProcessor \
as __SimpleCSVProcessor
from .GENERAL.TSV.tab_separated_vals \
import SimpleTSVProcessor \
as __SimpleTSVProcessor
# Add your processor to private list here:
__supported_processors = [
__SimpleRAPIDProcessor,
__SimpleKRLProcessor,
__SimpleVAL3Processor,
__SimpleEntertainTechProcessor,
__SimpleCSVProcessor,
__SimpleTSVProcessor
]
def construct_processor_name(type_robot, type_processor):
"""
Construct the name of a single Post Processor.
:param type_robot: Type of robot.
:param type_processor: Type of processor.
:return:
"""
return '{} {}'.format(type_robot, type_processor)
def get_processor_name(processor):
"""
Get the name from a given Post Processor
:param processor: Processor itself.
:return:
"""
return construct_processor_name(processor.type_robot, processor.type_processor)
def get_processor_names(pref_level=mimic_config.FILE):
"""
Get the names of all processors using existing POST_PROCESSORS dict.
Sorts names alphabetically by default. User-accessible function.
:param pref_level: str - PREFERENCE LEVEL defined in mimic_config module
:return: 'ROBOT_TYPE POSTPROCESSOR_TYPE'
"""
names = list(POST_PROCESSORS.keys())
names.sort()
# Get default from config. This is the processor that should appear first.
default = mimic_config.Prefs.get('DEFAULT_POST_PROCESSOR', pref_level)
if default in names:
names.remove(default)
names.insert(0, default)
return names
# All post processors dict!
POST_PROCESSORS = {}
# Configure the dict (don't touch)
for processor in __supported_processors:
p = processor()
name = construct_processor_name(p.type_robot, p.type_processor)
POST_PROCESSORS[name] = processor