SACADA.py 1.06 KB
Newer Older
1
from random import random
2
from time import sleep
3
from sacada import SACADA as _SACADA
4
from util.Logger import Logger
5
6

class SACADA(object):
7
8
9
    def __init__(self, location, channels):
        self.logger = Logger()

10
        self.channels = channels
11
12
        logger("[SACADA]", "Opening SACADA at {}".format(location))

13
        self.s = _SACADA(location)
14
        self.s.sendSCPICommand("IN:SCALE A0,V0256")
15
16
17
18
19
        logger("[SACADA]", str(self.s.identify()))
        logger("[SACADA]", "Valor do zero: {}".format(self.s.zero()))

    def read(self, channel):
        if channel["id"] == "TC":
20
            try:
21
                return self.s.readTemperature("A0", channel["type"])
22
23
24
25
26
            except:
                # Should handle value errors better
                return 0
        if channel["id"] == "PWR":
            return self.s.readVoltage("A3") * self.s.readVoltage("A4")
27
        if channel["id"] == "A3":
28
            return self.s.readVoltage("A3") * (400.0/10.0) - 3.0
29
30
31
32
        return self.s.readVoltage(channel["id"])

    def readAll(self):
        return [self.read("TC")]