Exemplo n.º 1
0
 def work(self):
     data, addr = self._sock.recvfrom(255)
     node, endpoint, profile, cluster = addr[:4]
     cur_time = time()
     is_data = endpoint == ENDPOINT and profile == PROFILE and cluster == IS_CLUSTER
     node_name = self._resolver.to_name_non_blocking(node, is_data)
     data_name = "t"
     data_text = data
     data_attrs = dict(time=fmt_time(cur_time))
     other_addr = ""
     if endpoint == ENDPOINT and profile == PROFILE and cluster == TTY_CLUSTER:
         updateDataLine(node_name, data, cur_time)
     else:
         data_name = "h"
         data_text = str2hex(data)
         data_attrs["endpoint"] = hh(endpoint, 2)
         data_attrs["profile"] = hh(profile, 4)
         data_attrs["cluster"] = hh(cluster, 2)
         other_addr = " (" + data_attrs["endpoint"] + "," + data_attrs["profile"] + "," + data_attrs["cluster"] + ")"
             
     self.append(node, Element(data_name, data_attrs, data_text))
     print "xgw: Recv ", node_name, other_addr, ": ", repr(data_text)
     if is_data and not is_addr(node_name):
         device_type, product_type = self._resolver.to_product_type_non_blocking(node)
         items = {}
         if product_type == XBeeSensorLTHAdapter:
             items = xbeelth.sample(data)
         print "xgw: Recv ", node_name, " IS sample from ", GetXBeeProductName(product_type), " = ", repr(items)
         updateDataItems(node_name, items, cur_time)    
Exemplo n.º 2
0
from xgw_data import updateDataLine, CURRENT

updateDataLine(
    "CONTROL",
    "[C:1 s1000000+23.8 d-0.08 p21.7 q2.0 w00 i999+0.1 a003+0.0 u02051111]\r\n"
)
updateDataLine("BOILER", "[B: s3 t75 a0007 b0007 c0122 d0691 u01013245]o*\r\n")
updateDataLine("WEATHER", "[4:  22.5 38%    ]\r\n")
updateDataLine("WEATHER", "[P:  24.0 1005.1 ]\r\n")
updateDataLine("WEATHER", "[W:  12  11 SSE  ]\r\n")
updateDataLine("NODE2", "[E1:  806 v229 a 3.7]\r\n")

for k in CURRENT.data:
    print k, CURRENT.data[k]

assert 1 == CURRENT.data["DC"].value
assert 23.8 == CURRENT.data["DCs1"].value
assert -0.08 == CURRENT.data["DCd"].value

assert 3 == CURRENT.data["DBs"].value
assert 75 == CURRENT.data["DBt"].value

assert 22.5 == CURRENT.data["D4"].value
assert 38 == CURRENT.data["D41"].value

assert 24 == CURRENT.data["DP"].value
assert 1005.1 == CURRENT.data["DP1"].value

assert 12 == CURRENT.data["DW"].value
assert 11 == CURRENT.data["DW1"].value
Exemplo n.º 3
0
from xgw_data import updateDataLine, CURRENT

updateDataLine("CONTROL", "[C:1 s1000000+23.8 d-0.08 p21.7 q2.0 w00 i999+0.1 a003+0.0 u02051111]\r\n")
updateDataLine("BOILER", "[B: s3 t75 a0007 b0007 c0122 d0691 u01013245]o*\r\n")
updateDataLine("WEATHER", "[4:  22.5 38%    ]\r\n")
updateDataLine("WEATHER", "[P:  24.0 1005.1 ]\r\n")
updateDataLine("WEATHER", "[W:  12  11 SSE  ]\r\n")
updateDataLine("NODE2", "[E1:  806 v229 a 3.7]\r\n")

for k in CURRENT.data:
    print k, CURRENT.data[k]

assert 1 == CURRENT.data["DC"].value
assert 23.8 == CURRENT.data["DCs1"].value
assert -0.08 == CURRENT.data["DCd"].value

assert 3 == CURRENT.data["DBs"].value
assert 75 == CURRENT.data["DBt"].value

assert 22.5 == CURRENT.data["D4"].value
assert 38 == CURRENT.data["D41"].value

assert 24 == CURRENT.data["DP"].value
assert 1005.1 == CURRENT.data["DP1"].value

assert 12 == CURRENT.data["DW"].value
assert 11 == CURRENT.data["DW1"].value

assert 806 == CURRENT.data["DE1"].value
assert 229 == CURRENT.data["DE1v"].value
assert 3.7 == CURRENT.data["DE1a"].value