Difference between revisions of "AgentLite-Node.js"

From ESS-WIKI
Jump to: navigation, search
Line 17: Line 17:
  
 
== Plugin ==
 
== Plugin ==
 +
 +
=== Internal Function ===
 +
 +
Developer needs to implement these internal functions by your application.
 +
 +
'''var InitPlugin()<br/>'''
 +
 +
*Description: To initialize process of&nbsp;your plugin.
 +
 +
'''var&nbsp;UnInitPlugin()'''
 +
 +
*Description: ​To&nbsp;uninitialize process of&nbsp;your plugin.&nbsp;
 +
 +
'''var AutoReport()'''
 +
 +
*Description: ​system will call this "AutoReport"&nbsp;&nbsp;after trigging auto report. To send auto report data by "g_sendreportcbf".
 +
 +
'''var&nbsp;getSenseData( iCmd, strSessionid, jsRequest )'''
 +
 +
*Description: ​To receive a get control command and&nbsp;call this function to query sensor data in capability cach.
 +
 +
'''var StartMonitorData(iCmd, strSessionid, jsMsg )'''
 +
 +
*Description: ​To receive a get monitor command and&nbsp;register a timer envet to call "MonitorUpdate" function.
 +
 +
'''var MonitorStop(&nbsp;)'''
 +
 +
*Description: ​To stop a timer event of Monitor sensor data.
 +
 +
'''var&nbsp;MonitorUpdate()'''
 +
 +
*Description: ​To upload sensor data by&nbsp;g_sendreplytopiccbf
  
 
=== Callback functions ===
 
=== Callback functions ===
  
=== Export Interfaces ===
+
{| class="wikitable" width="50%"
 +
|-
 +
! Parameter
 +
! Description
 +
|-
 +
| width="40%" | g_sendcbf
 +
| reply action function point
 +
|-
 +
| g_sendreportcbf
 +
| auto report&nbsp;function point
 +
|-
 +
| g_sendcapabilitycbf
 +
| send capability&nbsp;function point
 +
|-
 +
| g_sendeventcbf
 +
| send event message&nbsp;function point
 +
|-
 +
| g_sendreplytopiccbf
 +
| send update data by reply action topic ( Monitor page )&nbsp;function point
 +
|}
 +
 
 +
=== Export Interfaces of Plugin ===
  
 
'''var Handler_Initialize( param )'''
 
'''var Handler_Initialize( param )'''

Revision as of 17:56, 18 December 2018

Introduction

 AgentLite-Node.js is a light weight south-bound agent in Node.js. There are 3 main components of "1. Net-Protocol ( ./lib/WISECore3.3.js)", 2. main program ( AgentLite3.3.js) and 3. plugin module ( ./module/plugin_temp.js). Develop need to develop a plugin.js.

AgentLite-Node.js

Configure

./config/agent_config.json    : in JSON Format

<code>{         
  "ServerIP":"127.0.0.1",    
  "ServerPort": 1883,    
  "DeviceName": "SNMP_Handler",    
  "DevType": "Service",    
  "version": "v1.0.1"
}</code>

Plugin

Internal Function

Developer needs to implement these internal functions by your application.

var InitPlugin()

  • Description: To initialize process of your plugin.

var UnInitPlugin()

  • Description: ​To uninitialize process of your plugin. 

var AutoReport()

  • Description: ​system will call this "AutoReport"  after trigging auto report. To send auto report data by "g_sendreportcbf".

var getSenseData( iCmd, strSessionid, jsRequest )

  • Description: ​To receive a get control command and call this function to query sensor data in capability cach.

var StartMonitorData(iCmd, strSessionid, jsMsg )

  • Description: ​To receive a get monitor command and register a timer envet to call "MonitorUpdate" function.

var MonitorStop( )

  • Description: ​To stop a timer event of Monitor sensor data.

var MonitorUpdate()

  • Description: ​To upload sensor data by g_sendreplytopiccbf

Callback functions

Parameter Description
g_sendcbf reply action function point
g_sendreportcbf auto report function point
g_sendcapabilitycbf send capability function point
g_sendeventcbf send event message function point
g_sendreplytopiccbf send update data by reply action topic ( Monitor page ) function point

Export Interfaces of Plugin

var Handler_Initialize( param )

  • Description: ​Main program calls "Handler_Initialize" to initialize this module.           


Parameter Description
param.sendcbf reply action function point
param.sendreportcbf auto report function point
param.sendcapabilitycbf send capability function point
param.sendeventcbf send event message function point
param.sendreplytopiccbf send update data by reply action topic ( Monitor page ) function point

var Handler_Uninitialize( )

  • Description: ​Main program calls "Handler_Uninitialize" to uninitialize this module.     

void Handler_AutoReportStart( interval )

  • Description: ​Main program calls the "Handler_AutoReportStart" to start auto report.    
Parameter Description
interval report interval in second

var Handler_AutoReportStop()

  • Description: ​Main program calls "'Handler_AutoReportStop'" to stop auto report.    

var Handler_Get_Capability()

  • Description: ​Main program calls "'Handler_AutoReportStop'" to get plugin's capability.

var Handler_Recv( strTopic, strMsg )

  • Description: ​Main program calls "'Handler_Recv'" if receive a control message from others.
Parameter Description
strTopic received mqtt topic 
strMsg received message

Source Code

gitlab http://advgitlab.eastasia.cloudapp.azure.com/EdgeSense/AgentLite-Node.js

How To

Release