Ejemplo n.º 1
0
def annotation(x):
    try:
        entity = x.getString("entity")
        starttime = x.getString("starttime")
        endtime = x.getString("endtime")
    except (pva.FieldNotFound, pva.InvalidRequest):
        return pva.PvString("error")

    str_sec = is_to_unixtime_seconds(starttime)
    end_sec = is_to_unixtime_seconds(endtime)

    time = [(int(end_sec) + int(str_sec)) // 2 * 1000]
    title = [entity]
    tags = ["test1,test2"]
    text = ["test text"]

    vals = {
        "column0": [pva.ULONG],
        "column1": [pva.STRING],
        "column2": [pva.STRING],
        "column3": [pva.STRING]
    }
    table = pva.PvObject({
        "labels": [pva.STRING],
        "value": vals
    }, "epics:nt/NTTable:1.0")
    table.setScalarArray("labels", ["time", "title", "tags", "text"])
    table.setStructure("value", {
        "column0": time,
        "column1": title,
        "column2": tags,
        "column3": text
    })
    return table
Ejemplo n.º 2
0
def search(x):
    try:
        query = x.getString("entity")
        name = x.getString("name")
    except (pva.FieldNotFound, pva.InvalidRequest):
        return pva.PvString("error")

    org_value = ENTITIES if str(name) == "entity" else []

    value = [val for val in org_value if val.startswith(query)]

    pv = pva.PvObject({"value": [pva.STRING]}, "epics:nt/NTScalarArray:1.0")
    pv["value"] = value

    return pv
Ejemplo n.º 3
0
    def search_nturi_style(self, x):
        try:
            query = x.getStructure("query")
        except (pva.FieldNotFound, pva.InvalidRequest):
            return pva.PvString("error")

        q_po = pva.PvObject({
            "entity": pva.STRING,
            "name": pva.STRING,
        })
        q_po.setString("entity", query["entity"])
        q_po.setString("name", query["name"])

        pv = self.search(q_po)

        return pv
Ejemplo n.º 4
0
def get(x):
    try:
        entity = x.getString("entity")
        starttime = x.getString("starttime")
        endtime = x.getString("endtime")
    except (pva.FieldNotFound, pva.InvalidRequest):
        return pva.PvString("error")

    param1 = x.getString("param1") if x.hasField("param1") else None

    str_sec = is_to_unixtime_seconds(starttime)
    end_sec = is_to_unixtime_seconds(endtime)

    if entity == "sine" or entity == "cos":
        data = get_sine_cos(entity, str_sec, end_sec, param1)
    elif entity == "string":
        data = get_string(str_sec, end_sec)
    elif entity == "point3":
        data = get_point3(str_sec, end_sec)
    else:
        data = get_ramp(str_sec, end_sec, param1)

    value = data["value"]
    seconds = data["secondsPastEpoch"]
    nano = data["nano"]
    val_type = data["type"]

    vals = {
        "column0": [val_type],
        "column1": [pva.DOUBLE],
        "column2": [pva.DOUBLE]
    }
    table = pva.PvObject({
        "labels": [pva.STRING],
        "value": vals
    }, "epics:nt/NTTable:1.0")
    table.setScalarArray("labels",
                         ["value", "secondsPastEpoch", "nanoseconds"])
    table.setStructure("value", {
        "column0": value,
        "column1": seconds,
        "column2": nano
    })

    return table
Ejemplo n.º 5
0
    def get_nturi_style(self, x):
        try:
            query = x.getStructure("query")
        except (pva.FieldNotFound, pva.InvalidRequest):
            return pva.PvString("error")

        q_po = pva.PvObject({
            "entity": pva.STRING,
            "starttime": pva.STRING,
            "endtime": pva.STRING,
            "param1": pva.STRING
        })
        q_po.setString("entity", query["entity"])
        q_po.setString("starttime", query["starttime"])
        q_po.setString("endtime", query["endtime"])
        q_po.setString("param1", query["param1"])

        table = self.get(q_po)

        return table
Ejemplo n.º 6
0
    def get(self, x):
        try:
            entity = x.getString("entity")
            starttime = x.getString("starttime")
            endtime = x.getString("endtime")
        except (pva.FieldNotFound, pva.InvalidRequest):
            return pva.PvString("error")

        param1 = int(x.getString("param1")) if x.hasField("param1") else 0

        str_sec = self.is_to_unixtime_seconds(starttime)
        end_sec = self.is_to_unixtime_seconds(endtime)

        if entity == "table":
            table = self.get_table(entity, str_sec, end_sec, param1)
        elif entity == "error":
            table = pva.PvInt(1000)
        else:
            table = self.get_timesrie(entity, str_sec, end_sec, param1)

        return table
Ejemplo n.º 7
0
    def __init__(self):
        pva.PvaServer.__init__(self)
        self.booleanPv = pva.PvBoolean()
        self.addRecord(self.BOOLEAN_CHANNEL_NAME, self.booleanPv)

        self.bytePv = pva.PvByte()
        self.addRecord(self.BYTE_CHANNEL_NAME, self.bytePv)

        self.ubytePv = pva.PvUByte()
        self.addRecord(self.UBYTE_CHANNEL_NAME, self.ubytePv)

        self.shortPv = pva.PvShort()
        self.addRecord(self.SHORT_CHANNEL_NAME, self.shortPv)

        self.ushortPv = pva.PvUShort()
        self.addRecord(self.USHORT_CHANNEL_NAME, self.ushortPv)

        self.intPv = pva.PvInt()
        self.addRecord(self.INT_CHANNEL_NAME, self.intPv)

        self.uintPv = pva.PvUInt()
        self.addRecord(self.UINT_CHANNEL_NAME, self.uintPv)

        self.longPv = pva.PvLong()
        self.addRecord(self.LONG_CHANNEL_NAME, self.longPv)

        self.ulongPv = pva.PvULong()
        self.addRecord(self.ULONG_CHANNEL_NAME, self.ulongPv)

        self.floatPv = pva.PvFloat()
        self.addRecord(self.FLOAT_CHANNEL_NAME, self.floatPv)

        self.doublePv = pva.PvDouble()
        self.addRecord(self.DOUBLE_CHANNEL_NAME, self.doublePv)

        self.stringPv = pva.PvString('')
        self.addRecord(self.STRING_CHANNEL_NAME, self.stringPv)
Ejemplo n.º 8
0
def table(x):
    ntTable = pvaccess.NtTable(x)
    col1 = ntTable.getColumn(1)
    print "server got column 1"
    r = pvaccess.PvString('abcd')
    return r