add custom function to get config from machine
This commit is contained in:
@@ -9,9 +9,9 @@ from .components import (
|
||||
ComponentsServoHydraulicMachineLVDT,
|
||||
ComponentsServoHydraulicMachineTemperatureControl,
|
||||
)
|
||||
from .enumeration import Labtest
|
||||
from .enumeration import Labtest, LabtestsEnum
|
||||
from .usermanagement import Organisation
|
||||
|
||||
from bson import ObjectId
|
||||
|
||||
# ??? Labtest: Ist das richtig hier?
|
||||
class Experiment(EmbeddedDocument):
|
||||
@@ -58,6 +58,25 @@ class MachineBase(Document):
|
||||
|
||||
return data
|
||||
|
||||
def get_config(self, org_id: ObjectId, testname: LabtestsEnum):
|
||||
test_id = Labtest.objects(org_id=org_id, test=testname).first()
|
||||
|
||||
if not test_id:
|
||||
return []
|
||||
|
||||
test_id = test_id.id
|
||||
|
||||
machine_data = self.objects(tests__test=test_id).only('tests').first()
|
||||
|
||||
config_array = []
|
||||
for test in machine_data.tests:
|
||||
if test.test.id == test_id:
|
||||
config_array = test.config
|
||||
|
||||
return config_array
|
||||
|
||||
get_config_of_machine(ObjectId('6461eaea71b8a84558df5c58'), pdm.LabtestsEnum.CITTStiffness)
|
||||
|
||||
meta = {
|
||||
'allow_inheritance': True,
|
||||
'index_opts': {},
|
||||
|
||||
Reference in New Issue
Block a user