Пример #1
0
def NewChromatogramStart(request):

    chromatogram = Chromatogram.objects.get(pk=request.POST.get("id", 0))
    for port in request.POST.getlist("portname", ""):
        MicroControllerManager.getinstance()\
            .startacquisition(
            chromatogram,
            port)

    return redirect('/ChromatogramDetails/' + request.POST.get("id", 0) +
                    "?autorefresh=true")
Пример #2
0
def HplcDataSinceTimestamp(request, chromatogramid, timestamp):

    if MicroControllerManager.getinstance().getConnectionForChromatogramID(
            chromatogramid) != None:
        return getCurrentChromatogramData(chromatogramid, timestamp)

    c = Chromatogram.objects.get(pk=chromatogramid)
    # data = HplcData.objects.filter(Chromatogram=c).all()[::1]

    channels = HplcData.objects.raw(
        "SELECT DISTINCT JuHPLC_hplcdata.id,ChannelName from JuHPLC_hplcdata WHERE Chromatogram_id='"
        + str(c.id) + "';")

    # .all() fetches the data from the queryset
    # .values() makes it a dict that is json serializable

    tmp = {}

    for chan in channels:
        tmp[chan.ChannelName] = HplcData.objects.filter(Chromatogram=c).filter(
            Datetime__gt=timestamp).filter(
                ChannelName=chan.ChannelName).order_by(
                    "Datetime").all().values('ChannelName', 'Datetime',
                                             'Value')[::1]

    return JsonResponse({
        "hplcdata": tmp,
        "NextChromatogram": c.NextChromatogram
    })
Пример #3
0
def index(request):

    chromatograms = Chromatogram.objects.all().order_by("-Datetime")

    for i in chromatograms:
        i.data = HplcData.objects.filter(Chromatogram=i).count()>0

    return render(request, "index.html", {
                                            "chromatograms": chromatograms,
                                            "active": MicroControllerManager.getinstance().getactivechromatogramids()
                                        })
Пример #4
0
def NewChromatogramStop(request):

    #checkAccess(request)
    #todo: is own or if is others and can stop others permission

    chromatogram = Chromatogram.objects.get(pk=request.POST.get("id", 0))

    while not (MicroControllerManager.getinstance()\
        .stopacquisitionforchromatogram(
        chromatogram)):
        pass

    return redirect('ChromatogramDetails', id=request.POST.get("id", 0))
Пример #5
0
def ChromatogramDetails(request, id):
    chrom = Chromatogram.objects.get(pk=id)
    running = MicroControllerManager.getinstance(
    ).chromatogramhasactiveacquisition(chrom)

    ports = []

    eluents = Eluent.objects.filter(Chromatogram=chrom).all()
    solvents = []

    for e in eluents:
        for s in Solvent.objects.filter(Eluent=e).all():
            solvents.append(s)

    jc = JSONJuHPLCChromatogram(id)
    jchroma = json.dumps(jc.__dict__)

    hasdata = "Data" in jc.Data and len(jc.Data["Data"]) > 0
    if not hasdata and not running:
        #ports = serial.tools.list_ports.comports()
        ports = []
        for i in JuHPLC.ThinClientConsumers.ThinClientConsumer.clients:
            for j in JuHPLC.ThinClientConsumers.ThinClientConsumer.clients[i]:
                ports.append(i + " - " + j)
        for i in serial.tools.list_ports.comports():
            ports.append(i.device + " - " + i.description)

    if not request.GET._mutable:
        request.GET._mutable = True

    if request.GET.get('export', 'false') == 'false':
        request.GET['nocompress'] = True

    return render(
        request, "ChromatogramDetails.html", {
            "chromatogram": chrom,
            "num": id,
            "ports": ports,
            "isrunning": running,
            "islocalhost": HelperClass.islocalhost(request),
            "eluents": eluents,
            "data": hasdata,
            "solvents": solvents,
            "jsonChromatogram": jchroma,
            "mods": "",
            "rheodyneSwitch": chrom.RheodyneSwitch,
            "useMarker": WebApp.settings.USE_MARKER_IN_CHROMATOGRAM
        })
Пример #6
0
def getCurrentChromatogramData(chromatogramid, timestamp):

    data = MicroControllerManager.getinstance(
    ).getAllConnectionsForChromatogramID(chromatogramid)
    tmp = {}

    for i in data:
        for key, value in i.dataCache.items():
            if key not in tmp:
                tmp[key] = []
            for i in range(int(timestamp) + 1, len(value)):
                tmp[key].append(value[i])

    return JsonResponse({
        "hplcdata": tmp,
    })