Skip to content
Snippets Groups Projects
Commit e07147bc authored by wactbprot's avatar wactbprot
Browse files

validate_task_names, example costobj

parent 412a5366
No related branches found
No related tags found
No related merge requests found
......@@ -41,3 +41,167 @@ install and run
> ./anselm.sh & ./srv.sh
CustomerObject example
======================
.. code-block:: json
{
"_id": "cuob-ctrl-cdg_mks670_gpib",
"CustomerObject": {
"Type": "CDG Controler MKS 670",
"Name": "MKS_CDG670_GPIB",
"Owner": {
"Name": "PTB AG7.54"
},
"Device": {
"Producer": "MKS"
},
"Date": {
"Type": "generated",
"Value": "2018-09-17"
},
"Defaults": {
"@host": "e75416",
"@device": "gpib0,13",
"@unit": "mbar",
"@acc": "VXI11"
},
"Task": [
{
"TaskName": "auto_init_low_range",
"Comment": "Task initializes the X0.01 range",
"Action": "@acc",
"Host": "@host",
"VxiTimeout": 0,
"Device": "@device",
"From": "@fullscale/10000",
"To": "@fullscale/100",
"Value": ":sens:scan(@1):gain X0.01",
"PostProcessing": [
"ToExchange={'@exchpath':_x == null};"
]
},
{
"TaskName": "auto_init_med_range",
"Comment": "Task initializes the X0.01 range",
"Action": "@acc",
"VxiTimeout": 0,
"Host": "@host",
"Device": "@device",
"From": "@fullscale/100",
"To": "@fullscale/10",
"Value": ":sens:scan(@1):gain X0.1",
"PostProcessing": [
"ToExchange={'@exchpath':_x == null};"
]
},
{
"TaskName": "auto_init_high_range",
"Comment": "Task initializes the X0.01 range",
"Action": "@acc",
"VxiTimeout": 0,
"Host": "@host",
"Device": "@device",
"From": "@fullscale/10",
"To": "@fullscale",
"Value": ":sens:scan(@1):gain X1",
"PostProcessing": [
"ToExchange={'@exchpath':_x == null};"
]
},
{
"TaskName": "auto_offset_low_range",
"Comment": "Saves an offset sample in AuxValues",
"Action": "@acc",
"VxiTimeout": 0,
"Host": "@host",
"Device": "@device",
"DocPath": "Calibration.Measurement.AuxValues.Pressure",
"Value": ":meas:func",
"Repeat": "100",
"Wait": "1000",
"PostProcessing": [
"var _vec=_x.map(_.extractMKSCDG).map(parseFloat),",
"Result=[_.vlRes('offset_x0.01',_vec,'@unit')];"
]
},
{
"TaskName": "auto_offset_med_range",
"Comment": "Saves an offset sample in AuxValues",
"Action": "@acc",
"VxiTimeout": 0,
"Host": "@host",
"Device": "@device",
"DocPath": "Calibration.Measurement.AuxValues.Pressure",
"Value": ":meas:func",
"Repeat": "100",
"Wait": "1000",
"PostProcessing": [
"var _vec=_x.map(_.extractMKSCDG).map(parseFloat),",
"Result=[_.vlRes('offset_x0.1',_vec,'@unit')];"
]
},
{
"TaskName": "auto_offset_high_range",
"Comment": "Saves an offset sample in AuxValues",
"Action": "@acc",
"VxiTimeout": 0,
"Host": "@host",
"Device": "@device",
"DocPath": "Calibration.Measurement.AuxValues.Pressure",
"Value": ":meas:func",
"Repeat": "100",
"Wait": "1000",
"PostProcessing": [
"var _vec=_x.map(_.extractMKSCDG).map(parseFloat),",
"Result=[_.vlRes('offset_x1',_vec,'@unit')];"
]
},
{
"TaskName": "offset",
"Action": "@acc",
"VxiTimeout": 0,
"Host": "@host",
"Device": "@device",
"LogPriority": "3",
"DocPath": "Calibration.Mesaurement.Values.Pressure",
"Value": ":meas:func",
"Repeat": "15",
"Wait": "1000",
"PostProcessing": [
"var _last = _x.length - 1;",
"_x = _x.slice(4,_last);",
"_t_start = _t_start.slice(4,_last);",
"_t_stop = _t_stop.slice(4,_last);",
"var _vec=_x.map(_.extractMKSCDG).map(parseFloat),",
"_res = _.vlStat(_.checkNumArr(_vec).Arr),",
"Result=[_.vlRes('ind_offset',_res.mv,'@unit', '',_res.sd, _res.N)];"
]
},
{
"TaskName": "ind",
"Action": "@acc",
"VxiTimeout": 0,
"Host": "@host",
"Device": "@device",
"LogPriority": "3",
"DocPath": "Calibration.Mesaurement.Values.Pressure",
"Value": ":meas:func",
"Repeat": "15",
"Wait": "1000",
"PostProcessing": [
"var _last = _x.length - 1;",
"_x = _x.slice(4,_last);",
"_t_start = _t_start.slice(4,_last);",
"_t_stop = _t_stop.slice(4,_last);",
"var _vec=_x.map(_.extractMKSCDG).map(parseFloat),",
"_res = _.vlStat(_.checkNumArr(_vec).Arr),",
"Result=[_.vlRes('ind',_res.mv,'@unit', '',_res.sd, _res.N)];"
]
}
]
}
}
......@@ -232,18 +232,56 @@ class Anselm(System):
return c
def make_task_combo(self, doc_id, line):
task_names = self.db.get_task_names(doc_id = doc_id)
self.log.debug("found following tasknames {}".format(task_names))
c = self.make_combo(task_names, first_item="select task", last_item=False)
ok = self.validate_task_names(task_names, line)
if ok:
first_item = "tasks ok"
else:
first_item = "task name problem"
c = self.make_combo(task_names, first_item=first_item, last_item=False)
c.currentIndexChanged.connect(lambda: self.task_selected(c, line))
return c
def validate_task_names(self, task_names, line):
offset_all_sequence = []
res = True
for task_name in task_names:
if task_name.startswith('auto_init_'):
self.aset('init_task_names', line, task_name)
sufix = task_name.replace('auto_init_', '')
offset_all_sequence.append(task_name)
related_offset_task = 'auto_offset_{}'.format(sufix)
if related_offset_task in task_names:
offset_all_sequence.append(related_offset_task)
else:
res = False
break
if 'offset' in task_names:
self.aset('offset_task_name', line, task_name)
else:
res = False
break
if 'ind' in task_names:
self.aset('ind_task_name', line, task_name)
else:
res = False
break
return res
def run_selected(self, combo, line):
self.run_task(line)
def task_selected(self, combo, line):
task_name = combo.currentText()
doc_id = self.aget('doc_id', line)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment