Difference between revisions of "AgentLite-Node.js"

From ESS-WIKI
Jump to: navigation, search
Line 54: Line 54:
 
=== Internal Function ===
 
=== Internal Function ===
  
Developer needs to implement these internal functions by your application.
+
<span style="color:#FF0000;">Developer needs to implement these functions.</span>
  
 
'''var InitPlugin()'''
 
'''var InitPlugin()'''
Line 85: Line 85:
  
 
=== Export Interfaces of Plugin ===
 
=== Export Interfaces of Plugin ===
 +
 +
<span style="color:#FF0000;">Developers generally do not need to modify</span>
  
 
'''var Handler_Initialize( param )'''
 
'''var Handler_Initialize( param )'''
Line 154: Line 156:
 
|}
 
|}
 
</div>
 
</div>
 +
 
== AdvDataMgt ==
 
== AdvDataMgt ==
  

Revision as of 18:46, 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

   A plugin.js with common interfaces. A main program can load a plugin to send and control its sensor data.

Define and Callback functions

global variable Description
g_strPluginName
Name of plugin
g_jsCapability
Capability of this plugin
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


Internal Function

Developer needs to implement these functions.

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

Export Interfaces of Plugin

Developers generally do not need to modify

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

AdvDataMgt

 It is a librarie help that makes it easy to compose plugin's capability in the Advantech IPSO-like JSON format.

int initialize ( strName, jInfo )

var getCapability ()

int addSensor( strPath, jsSensor, strKey )

int updatebyPath( strPath, value )

int updatebyKey( strKey, value )

var queryKeybyPath( strPath )

var getAllKey()  

var getAllPath()

How To - Sample Code

sample code of Plugin

Release

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