Dear all:
I would like to add the health model to PyACI (`interactive_pyaci.py`),from the SDK 2.0.1 we can know that there is two model in the script:
1. config.py
2. simple_on_off.py
Now,I want to add the health model as the model which has been.
The way I add the new model refer to the config.py ,all the opcode from 'heslth_server.h',and tow
opcode being used for testing:
1. Geting the opcode from heslth_server.h
2.add the health_server.py
3.import the health_server.py into interactive_pyaci.py
there is nothing do with other object
#05/19/2018
from mesh.access import Model, Opcode
import struct
import json
class HealthServerClient(Model):
#_HEALTH_OPCODE_ATTENTION_GET = Opcode(0x8004)
#_HEALTH_OPCODE_ATTENTION_SET = Opcode(0x8005)
#_HEALTH_OPCODE_ATTENTION_SET_UNACKED = Opcode(0x8006)
#_HEALTH_OPCODE_FAULT_CLEAR = Opcode(0x802f)
#_HEALTH_OPCODE_FAULT_CLEAR_UNACKED = Opcode(0x8030)
#_HEALTH_OPCODE_FAULT_GET = Opcode(0x8031)
#_HEALTH_OPCODE_FAULT_TEST = Opcode(0x8032)
#_HEALTH_OPCODE_FAULT_TEST_UNACKED = Opcode(0x8033)
_HEALTH_OPCODE_PERIOD_GET = Opcode(0x8034)
#_HEALTH_OPCODE_PERIOD_SET = Opcode(0x8035)
#_HEALTH_OPCODE_PERIOD_SET_UNACKED = Opcode(0x8036)
#_HEALTH_OPCODE_CURRENT_STATUS = Opcode(0x04)
#_HEALTH_OPCODE_FAULT_STATUS = Opcode(0x05)
#_HEALTH_OPCODE_ATTENTION_STATUS = Opcode(0x8007)
_HEALTH_OPCODE_PERIOD_STATUS = Opcode(0x8037)
def __init__(self,prov_db):
self.opcodes = [
(self._HEALTH_OPCODE_PERIOD_STATUS, self.__health_period_status)]
self.prov_db = prov_db
self.previous_command = None
# FIXME: Hack to retain the virtual label UUID until we get an ack.
self._tmp_address = None
super(HealthServerClient, self).__init__(self.opcodes)
def health_period_status_get(self):
self.send(self._HEALTH_OPCODE_PERIOD_GET)
def __health_period_status(self, opcode, message):
m_handler,FPDivisor,res,steps,p_test,num_test,test_id,company_id,fault,c_fault,att_handle= struct.unpack(
"<HBBBBBBHHHB", message.data)
self.logger.info("Present value is %d fault is %x c_fault is %d att_hand is %d",company_id, fault,c_fault,att_handle)
then went I run the interactive_pyaci.py the result as below
Did I use the wrong approach? or something missing in the process.