Difference between revisions of "EdgeSense Southbound Service Development"
(.) |
|||
Line 103: | Line 103: | ||
</pre> | </pre> | ||
− | After build is complete, HandlerSample plugin is generated in SRP-Plugin | + | 2. After build is complete, HandlerSample plugin is generated in SRP-Plugin/Release/module folder. |
− | <pre>$ ls -1 Release/module/ | + | <pre>$ ls -1 SRP-Plugin/Release/module/ |
HandlerSample.so | HandlerSample.so | ||
HandlerSample.so.0 | HandlerSample.so.0 | ||
Line 114: | Line 114: | ||
</pre> | </pre> | ||
− | + | 3. Copy HandlerSample to agentlite/prebuilt/module folder. | |
+ | <pre>cp -af HandlerSample.so* agentlite/prebuilt/module | ||
+ | </pre> | ||
+ | |||
+ | 4. Modify agentlite/prebuilt/module/module_config.xml | ||
<pre><ModuleNum>1</ModuleNum> | <pre><ModuleNum>1</ModuleNum> | ||
<ModuleName1>HandlerSample</ModuleName1> | <ModuleName1>HandlerSample</ModuleName1> | ||
Line 121: | Line 125: | ||
</pre> | </pre> | ||
− | + | 5. Modify agentlite/prebuilt/agent_config.xml | |
<pre><DeviceName>HandlerSample</DeviceName> | <pre><DeviceName>HandlerSample</DeviceName> | ||
<DevID>HandlerSample</DevID> | <DevID>HandlerSample</DevID> | ||
Line 130: | Line 134: | ||
</pre> | </pre> | ||
− | + | 6. Run Southbound plug-in. | |
<pre>$ cd agentlite/prebuilt | <pre>$ cd agentlite/prebuilt | ||
$ ./cagent -n | $ ./cagent -n | ||
Line 137: | Line 141: | ||
Then you will see HandlerSample is loaded. | Then you will see HandlerSample is loaded. | ||
<pre>$ ./cagent -n | <pre>$ ./cagent -n | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
HandlerLoader loaded | HandlerLoader loaded | ||
− | |||
DllInitializer | DllInitializer | ||
DllFinalizer | DllFinalizer | ||
Line 152: | Line 147: | ||
GeneralHandler loaded | GeneralHandler loaded | ||
general> Initialize | general> Initialize | ||
− | |||
− | |||
DllInitializer | DllInitializer | ||
Load HandlerSample Successful | Load HandlerSample Successful | ||
HandlerSample> InitializeSADataSync_Initialize() | HandlerSample> InitializeSADataSync_Initialize() | ||
− | |||
− | |||
> HandlerSample StartAgent Initialized | > HandlerSample StartAgent Initialized | ||
Agent_HandlerSample no-service is start successfully! | Agent_HandlerSample no-service is start successfully! | ||
</pre> | </pre> |
Revision as of 09:36, 25 July 2019
Contents
Introduction
You will need SRP-Plugin and Agentlite.
SRP-Plugin is xxx
Agentlite is a run-time collections for Plugin to execute. Plugin have to put in module folder.
Development
Requirement
For Windows development,
- Please install Visual Studio 2008 or above. Visual Studio is available at official website.
For Ubuntu 16.04 development, please install below software,
$ sudo apt install autoconf autotools-dev libtool libmosquitto1 sqlite3 libxml2-dev libcurl4-openssl-dev libx11-dev libxtst-dev libxext-dev libmosquitto-dev libssl-dev
To run Southbound Plugin, need local MQTT Broker, please download and setup.
MQTT Broker For Windows
MQTT Broker for Ubuntu 16.04
$ sudo chmod +x MQTTBrokerSetup-1.0.5-Ubuntu_16.04-x86_64.run $ sudo ./MQTTBrokerSetup-1.0.5-Ubuntu_16.04-x86_64.run
Download SRP-Plugin and Agentlite
Download SRP-Plugin
git clone http://advgitlab.eastasia.cloudapp.azure.com/SRP-Connect/SRP-Plugin.git
Download Agentlite for Windows development
git clone https://github.com/ADVANTECH-Corp/agentlite.git
Download Agentlite for Ubuntu 16.04 development
git clone -b Ubuntu-16.04 https://github.com/ADVANTECH-Corp/agentlite.git
Development for Windows
1. Open SRP-Plugin\SRP-Plugin.sln with Visual Studio.
2. Change Solution Configurations to Release , change Solution Platforms to Win32.
3. In Solution Explorer, choose HandlerSample and build it.
4. After build is completed, HandlerSample plugin is generated in SRP-Plugin\Release\module folder.
5. Copy HandlerSample.dll to agentlite\prebuilt\module folder.
When we download agentlite, it looks like this picture:
Copy HandlerSample.dll to agentlite\prebuilt\module folder.
6. Modify agentlite\prebuilt\module\module_config.xml
<ModuleNum>1</ModuleNum> <ModuleName1>HandlerSample</ModuleName1> <ModulePath1>\module\HandlerSample.dll</ModulePath1> <ModuleEnable1>TRUE</ModuleEnable1>
7. Modify agentlite\prebuilt\agent_config.xml
<DeviceName>HandlerSample</DeviceName> <DevID>HandlerSample</DevID> <SN>HandlerSample</SN> <DevType>Service</DevType> <WorkDir></WorkDir> <ServiceName>Agent_HandlerSample</ServiceName>
8. Run Southbound plug-in.
cd agentlite\prebuilt CAgent.exe -n
Development for Ubuntu 16.04
1. Build SRP-Plugin and HandlerSample plugin
$ cd SRP-Plugin $ sudo ./pre-install_ubuntu.sh $ ./build-srpplugin.sh
2. After build is complete, HandlerSample plugin is generated in SRP-Plugin/Release/module folder.
$ ls -1 SRP-Plugin/Release/module/ HandlerSample.so HandlerSample.so.0 HandlerSample.so.0.0.0 ModbusSample.so ModbusSample.so.0 ModbusSample.so.0.0.0 module_config.xml
3. Copy HandlerSample to agentlite/prebuilt/module folder.
cp -af HandlerSample.so* agentlite/prebuilt/module
4. Modify agentlite/prebuilt/module/module_config.xml
<ModuleNum>1</ModuleNum> <ModuleName1>HandlerSample</ModuleName1> <ModulePath1>/module/HandlerSample.so</ModulePath1> <ModuleEnable1>TRUE</ModuleEnable1>
5. Modify agentlite/prebuilt/agent_config.xml
<DeviceName>HandlerSample</DeviceName> <DevID>HandlerSample</DevID> <SN>HandlerSample</SN> <DevType>Service</DevType> <WorkDir></WorkDir> <ServiceName>Agent_HandlerSample</ServiceName>
6. Run Southbound plug-in.
$ cd agentlite/prebuilt $ ./cagent -n
Then you will see HandlerSample is loaded.
$ ./cagent -n HandlerLoader loaded DllInitializer DllFinalizer DllInitializer GeneralHandler loaded general> Initialize DllInitializer Load HandlerSample Successful HandlerSample> InitializeSADataSync_Initialize() > HandlerSample StartAgent Initialized Agent_HandlerSample no-service is start successfully!