Created
December 11, 2015 20:31
-
-
Save paladini/7b28f2f50a36f708bc88 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" Translates a ugly data point name (DP_351652) into something uglier (A0numeric0). | |
The translation will be needed while exporting old ScadaBR databases into the new main database. | |
For this class we will assume that: | |
Data point (dp) --> somewhat like "DP_351652" | |
Param --> somewhat like "A0numeric0" | |
Keep that in mind. | |
@author Fernando Paladini <[email protected]> | |
""" | |
class DPTranslator(object): | |
dp_as_input = { | |
"smartroom": { | |
"DP_351652": "A0numeric0", | |
"DP_170127": "A1numeric0", | |
"DP_306287": "A2numeric0", | |
"DP_627756": "B0numeric0", | |
"DP_434890": "B0numeric1", | |
"DP_953705": "B1numeric0", | |
"DP_859338": "B1numeric1", | |
"DP_032376": "A4numeric0", | |
"DP_492786": "A5binary0", | |
"DP_679127": "A6numeric0" | |
}, | |
"smarthome": { | |
"DP_594412": "A0numeric0", | |
"DP_441764": "A1numeric0", | |
"DP_483425": "A2numeric0", | |
"DP_373637": "A3numeric0", | |
"DP_957184": "A4numeric0", | |
"DP_545941": "A5numeric0", | |
"DP_318142": "A6numeric0", | |
"DP_548897": "A7numeric0", | |
"DP_806816": "A8numeric0", | |
"DP_665622": "B0numeric0", | |
"DP_376501": "B0numeric1", | |
"DP_465715": "B1numeric0", | |
"DP_478436": "B1numeric1", | |
"DP_491282": "B2numeric0", | |
"DP_880976": "B2numeric1", | |
"DP_771895": 'B3numeric0', | |
'DP_750041': 'B3numeric1', | |
'DP_160122': 'B4numeric0', | |
'DP_729872': 'B4numeric1', | |
'DP_671000': 'B5numeric0', | |
'DP_509726': 'B5numeric1', | |
'DP_076185': 'B6numeric0', | |
'DP_986160': 'B6numeric1', | |
'DP_053191': 'B7numeric0', | |
'DP_680642': 'B7numeric1', | |
'DP_207151': 'B8numeric0', | |
'DP_650041': 'B8numeric1', | |
'DP_248176': 'B9numeric0', | |
'DP_910988': 'B9numeric1', | |
'DP_110878': 'BAnumeric0', | |
'DP_225771': 'BAnumeric1', | |
'DP_476929': 'BBnumeric0', | |
'DP_012185': 'BBnumeric1', | |
'DP_214276': 'BCnumeric0', | |
'DP_846158': 'BCnumeric1', | |
'DP_009171': 'BDnumeric0', | |
'DP_551298': 'BDnumeric1', | |
'DP_934762': 'BEnumeric0', | |
'DP_400825': 'BEnumeric1', | |
'DP_230745': 'D5numeric0', | |
'DP_145027': 'D6numeric0', | |
'DP_840206': 'D7numeric0', | |
'DP_204579': 'D0binary0', | |
'DP_721813': 'D1binary0', | |
'DP_246999': 'D2binary0', | |
'DP_434607': 'D3binary0', | |
'DP_359405': 'DAnumeric0', | |
'DP_530962': 'DBnumeric0' | |
} | |
} | |
param_as_input = { | |
"smartroom": { | |
'A4numeric0': 'DP_032376', 'B1numeric1': 'DP_859338', 'B1numeric0': 'DP_953705', 'A1numeric0': 'DP_170127', 'A2numeric0': 'DP_306287', 'B0numeric1': 'DP_434890', 'B0numeric0': 'DP_627756', 'A6numeric0': 'DP_679127', 'A5binary0': 'DP_492786', 'A0numeric0': 'DP_351652' | |
}, | |
"smarthome": { | |
'A1numeric0': 'DP_441764', 'BBnumeric1': 'DP_012185', 'BBnumeric0': 'DP_476929', 'B8numeric1': 'DP_650041', 'B8numeric0': 'DP_207151', 'D6numeric0': 'DP_145027', 'A4numeric0': 'DP_957184', 'B2numeric1': 'DP_880976', 'B2numeric0': 'DP_491282', 'D7numeric0': 'DP_840206', 'B6numeric0': 'DP_076185', 'BCnumeric0': 'DP_214276', 'BCnumeric1': 'DP_846158', 'B9numeric0': 'DP_248176', 'B9numeric1': 'DP_910988', 'BEnumeric0': 'DP_934762', 'BEnumeric1': 'DP_400825', 'DAnumeric0': 'DP_359405', 'A3numeric0': 'DP_373637', 'D2binary0': 'DP_246999', 'D1binary0': 'DP_721813', 'A5numeric0': 'DP_545941', 'A6numeric0': 'DP_318142', 'D5numeric0': 'DP_230745', 'B5numeric0': 'DP_671000', 'B5numeric1': 'DP_509726', 'B4numeric1': 'DP_729872', 'B4numeric0': 'DP_160122', 'D3binary0': 'DP_434607', 'DBnumeric0': 'DP_530962', 'BAnumeric0': 'DP_110878', 'BAnumeric1': 'DP_225771', 'A2numeric0': 'DP_483425', 'B3numeric1': 'DP_750041', 'B1numeric0': 'DP_465715', 'B1numeric1': 'DP_478436', 'A7numeric0': 'DP_548897', 'A8numeric0': 'DP_806816', 'B6numeric1': 'DP_986160', 'D0binary0': 'DP_204579', 'BDnumeric1': 'DP_551298', 'BDnumeric0': 'DP_009171', 'B0numeric1': 'DP_376501', 'B0numeric0': 'DP_665622', 'B3numeric0': 'DP_771895', 'B7numeric0': 'DP_053191', 'A0numeric0': 'DP_594412', 'B7numeric1': 'DP_680642' | |
} | |
} | |
@staticmethod | |
def beautify(project, param): | |
if project not in param_as_input or param not in param_as_input[project]: | |
raise Exception('Project or param not existent (or null).') | |
return param_as_input[project][param] | |
@staticmethod | |
def uglify(project, param): | |
if project not in dp_as_input or param not in dp_as_input[project]: | |
raise Exception('Project or param not existent (or null).') | |
return dp_as_input[project][param] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment