コード例 #1
0
 def wrapblk(self, noti):
     try:
         node = self._devinfo.finddev(noti["SNID"], DevType.NODE)
         obsblk = Observation(node["id"])
         for k, v in noti["observations"].iteritems():
             sid = self._devinfo.findid(k, DevType.SENSOR, node['children'])
             if sid is None:
                 self._logger.warn("fail to find id. " + str(k))
                 continue
             obsblk.setobservation(sid, [self.getvalue(k, v), StatCode.READY])
         return [obsblk]
     except Exception as ex:
         self._logger.warn("fail to wrap. " + str(ex))
         return None
コード例 #2
0
ファイル: mate_ksx3267.py プロジェクト: superwhyun/farmos
    def sendobservation(self, ndinfo):
        obsblk = Observation(ndinfo["id"])
        obsblk.setobservation(ndinfo["id"], 0, StatCode(ndinfo["nd"]["status"]))
        for devid, info in list(ndinfo["sen"].items()):
            obsblk.setobservation(devid, info["value"], StatCode(info["status"]))
        for devid, info in list(ndinfo["act"].items()):
            obsblk.setobservation(devid, 0, StatCode(info["status"]))

        self.writecb(obsblk)
コード例 #3
0
ファイル: mate_ksx3267v2.py プロジェクト: mrchoi87/IRSOSv3
    def sendobservation(self, ndinfo):
        if StatCode.has_value(ndinfo["nd"]["status"]) == False:
            ndinfo["nd"]["status"] = StatCode.ERROR.value

        obsblk = Observation(ndinfo["id"])
        obsblk.setobservation(ndinfo["id"], 0,
                              StatCode(ndinfo["nd"]["status"]))

        for devid, info in ndinfo["sen"].iteritems():
            if StatCode.has_value(info["status"]) == False:
                info["status"] = StatCode.ERROR.value
            obsblk.setobservation(devid, info["value"],
                                  StatCode(info["status"]))

        # do not send observation for actuator
        #for devid, info in ndinfo["act"].iteritems():
        #    if StatCode.has_value(info["status"]) == False:
        #        info["status"] = StatCode.ERROR.value
        #    obsblk.setobservation(devid, 0, StatCode(info["status"]))

        self.writecb(obsblk)