models.py
31 lines
| 768 B
| text/x-python
|
PythonLexer
/ plotter / models.py
r0 | # -*- coding: utf-8 -*- | |||
from django.db import models | ||||
|
r22 | from mongoengine import Document, IntField, FloatField, StringField, DictField, ListField, DateTimeField, ReferenceField | ||
r0 | ||||
class Experiment(Document): | ||||
r2 | code = IntField(unique=True) | |||
name = StringField(max_length=40) | ||||
|
r22 | class ExpDetail(Document): | ||
experiment = ReferenceField(Experiment) | ||||
r0 | date = DateTimeField() | |||
|
r22 | last_time = FloatField() | ||
r0 | ||||
|
r22 | def plots(self): | ||
return PlotMeta.objects(exp_detail=self) | ||||
class PlotMeta(Document): | ||||
exp_detail = ReferenceField(ExpDetail) | ||||
metadata = DictField() | ||||
plot = StringField() | ||||
r0 | ||||
|
r22 | class PlotData(Document): | ||
plot = ReferenceField(PlotMeta) | ||||
r0 | time = FloatField() | |||
|
r22 | data = ListField() | ||
r0 | ||||
meta = { | ||||
|
r22 | 'indexes': ["plot", "+time"] | ||
r0 | } | |||
|
r11 | |||