add custom function to get config from machine
This commit is contained in:
@@ -9,9 +9,9 @@ from .components import (
|
|||||||
ComponentsServoHydraulicMachineLVDT,
|
ComponentsServoHydraulicMachineLVDT,
|
||||||
ComponentsServoHydraulicMachineTemperatureControl,
|
ComponentsServoHydraulicMachineTemperatureControl,
|
||||||
)
|
)
|
||||||
from .enumeration import Labtest
|
from .enumeration import Labtest, LabtestsEnum
|
||||||
from .usermanagement import Organisation
|
from .usermanagement import Organisation
|
||||||
|
from bson import ObjectId
|
||||||
|
|
||||||
# ??? Labtest: Ist das richtig hier?
|
# ??? Labtest: Ist das richtig hier?
|
||||||
class Experiment(EmbeddedDocument):
|
class Experiment(EmbeddedDocument):
|
||||||
@@ -57,6 +57,25 @@ class MachineBase(Document):
|
|||||||
data = mongo_to_dict(data)
|
data = mongo_to_dict(data)
|
||||||
|
|
||||||
return data
|
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 = {
|
meta = {
|
||||||
'allow_inheritance': True,
|
'allow_inheritance': True,
|
||||||
|
|||||||
Reference in New Issue
Block a user