Merge pull request #19 from charithag/master

Add simple and advanced fire alarm agents
application-manager-new
Charitha Goonetilleke 9 years ago
commit a337fefd8d

@ -10,13 +10,13 @@
"overview_url":"http://www.google.lk", "overview_url":"http://www.google.lk",
"setupGuide_guideImage":"virtual_firealarm/guide.png", "setupGuide_guideImage":"virtual_firealarm/guide.png",
"overview_actionLabel":"Create a virtual device", "overview_actionLabel":"Create a virtual device",
"sketches_Sketches":"virtual_firealarm", "sketches_Sketches":["virtual_firealarm","virtual_firealarm_advanced"],
"ingredients_ingredients":[ "ingredients_ingredients":[
"Virtual Agent that simulates an actual firealarm" "Virtual Agent that simulates an actual firealarm. Simple agent demonstrate the basic functionality and Advanced agent consists with advance features like policy management, edge computing etc."
], ],
"overview_description":"Download our Virtual Agent and try-it out for close to real simulation of the FireAlarm Device-Type", "overview_description":"Download our Virtual Agent and try-it out for close to real simulation of the FireAlarm Device-Type",
"setupGuide_description":"Extract the downloaded agent and run startservice.sh to start agent", "setupGuide_description":"Extract the downloaded agent and run start-device.sh to start agent",
"quickStartupSteps_stepDescription":["Download the Virtual Agent","Run the 'startservice.sh' script","Provide the push-interval and network-interface"], "quickStartupSteps_stepDescription":["Download the Virtual Agent","Run the 'start-device.sh' script","Provide the push-interval and network-interface"],
"quickStartupSteps_stepLabel":["1","2","3"], "quickStartupSteps_stepLabel":["1","2","3"],
"images_thumbnail":"virtual_firealarm/virtual_firealarm_thumbnail.png", "images_thumbnail":"virtual_firealarm/virtual_firealarm_thumbnail.png",
"images_banner":"virtual_firealarm/virtual_firealarm_banner.png", "images_banner":"virtual_firealarm/virtual_firealarm_banner.png",

@ -64,15 +64,24 @@
</target> </target>
<target name="build-agent"> <target name="build-agent">
<echo message="Downloading agent source...." /> <echo message="Downloading simple agent source...." />
<exec dir="." executable="sh"> <exec dir="." executable="sh">
<arg line="-c 'svn checkout https://github.com/wso2-incubator/iot-server-agents/trunk/FireAlarmVirtualAgent --non-interactive --trust-server-cert'" /> <arg line="-c 'svn checkout https://github.com/wso2-incubator/iot-server-agents/trunk/FireAlarmVirtualAgent --non-interactive --trust-server-cert'" />
</exec> </exec>
<echo message="building agent from source" /> <echo message="building simple agent from source" />
<exec dir="FireAlarmVirtualAgent" executable="sh"> <exec dir="FireAlarmVirtualAgent" executable="sh">
<arg line="-c 'mvn clean install'" /> <arg line="-c 'mvn clean install'" />
</exec> </exec>
<copy file="FireAlarmVirtualAgent/target/wso2-firealarm-virtual-agent.jar" todir="sketch"/> <copy file="FireAlarmVirtualAgent/target/wso2-firealarm-virtual-agent.jar" todir="sketch"/>
<echo message="Downloading advance agent source...." />
<exec dir="." executable="sh">
<arg line="-c 'svn checkout https://github.com/wso2-incubator/iot-server-agents/trunk/FireAlarmVirtualAgentAdvanced --non-interactive --trust-server-cert'" />
</exec>
<echo message="building advanced agent from source" />
<exec dir="FireAlarmVirtualAgentAdvanced" executable="sh">
<arg line="-c 'mvn clean install'" />
</exec>
<copy file="FireAlarmVirtualAgentAdvanced/target/wso2-firealarm-virtual-agent-advanced.jar" todir="sketch_advanced"/>
</target> </target>
<target name="build-api"> <target name="build-api">
@ -92,6 +101,9 @@
<copy toDir="${target.sketch.dir}/${sample_type}"> <copy toDir="${target.sketch.dir}/${sample_type}">
<fileset dir="sketch"/> <fileset dir="sketch"/>
</copy> </copy>
<copy toDir="${target.sketch.dir}/${sample_type}_advanced">
<fileset dir="sketch_advanced"/>
</copy>
<mkdir dir="${target.sample.device.dir}/${sample_type}"/> <mkdir dir="${target.sample.device.dir}/${sample_type}"/>
<copy toDir="${target.sample.device.dir}/${sample_type}"> <copy toDir="${target.sample.device.dir}/${sample_type}">
<fileset dir="artifact/"/> <fileset dir="artifact/"/>
@ -108,6 +120,7 @@
<target name="clean"> <target name="clean">
<delete file="${target.db.dir}/${data_source}.h2.db"/> <delete file="${target.db.dir}/${data_source}.h2.db"/>
<delete dir="${target.sketch.dir}/${sample_type}"/> <delete dir="${target.sketch.dir}/${sample_type}"/>
<delete dir="${target.sketch.dir}/${sample_type}_advanced"/>
<delete file="${target.page.dir}/${sample_type}.hbs"/> <delete file="${target.page.dir}/${sample_type}.hbs"/>
<delete dir="${target.unit.dir}/${sample_type}"/> <delete dir="${target.unit.dir}/${sample_type}"/>
<delete file="${target.page.dir}/${sample_type}.hbs"/> <delete file="${target.page.dir}/${sample_type}.hbs"/>

@ -0,0 +1,33 @@
#
# Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
#[Device-Configurations]
owner=${DEVICE_OWNER}
deviceId=${DEVICE_ID}
device-name=${DEVICE_NAME}
controller-context=/virtual_firealarm/controller
https-ep=${HTTPS_EP}
http-ep=${HTTP_EP}
apim-ep=${APIM_EP}
mqtt-ep=${MQTT_EP}
xmpp-ep=${XMPP_EP}
auth-method=token
auth-token=${DEVICE_TOKEN}
refresh-token=${DEVICE_REFRESH_TOKEN}
push-interval=15

@ -0,0 +1,2 @@
templates=deviceConfig.properties
zipfilename=FireAlarmVirtualAgent.zip

@ -0,0 +1,190 @@
#!/bin/bash
echo "----------------------------------------------------------------"
echo "| WSO2 IOT Sample "
echo "| Virtual RaspiAlarm "
echo "| ---------------- "
echo "| ....initializing startup-script "
echo "----------------------------------------------------------------"
#while true; do
# read -p "What is the network-interface of your device that the Agent should use (find from ifconfig. ex: wlan0,en0,eth0..) > " interface
#
# echo "Setting the network-interface to " $interface
# sed s/^network-interface=.*/network-interface=$interface/ deviceConfig.properties > myTmp
# mv -f myTmp deviceConfig.properties
# break;
#done
#
#while true; do
# read -p "Whats the time-interval (in seconds) between successive Data-Pushes to the WSO2-IoT-Server (ex: '60' indicates 1 minute) > " interval
#
# if [ $interval -eq $interval 2>/dev/null ]
# then
# echo "Setting data-push interval to " $interval " seconds."
# sed s/^push-interval=.*/push-interval=$interval/ deviceConfig.properties > myTmp
# mv -f myTmp deviceConfig.properties
# break;
# else
# echo "Input needs to be an integer indicating the number seconds between successive data-pushes."
# fi
#done
java -jar wso2-firealarm-virtual-agent-advanced.jar
#while true; do
# read -p "Do you wish to run 'apt-get update' and continue? [Yes/No] " yn
# case $yn in
# [Yy]* ) sudo apt-get update;
# break;;
# [Nn]* ) echo "Continuing without apt-get update...";
# break;;
# * ) echo "Please answer yes or no.";
# esac
#done
#
#if [ $? -ne 0 ]; then
# echo "apt-get update failed.... Some dependencies may not get installed"
# echo "If an already installed version of the package exists, try running:"
# echo "----------------------------------------------------------------"
# echo "sudo -i"
# echo "cd /var/lib/dpkg/info"
# echo "rm -rf wso2-raspi-alarm*"
# echo "dpkg --remove --force-remove-reinstreq wso2-raspi-alarm"
# echo "exit"
# echo "----------------------------------------------------------------"
# echo "Retry Installation...."
# break;
#fi
#
#echo "Installing 'gdebi' package..."
#sudo apt-get install gdebi # installation of gdebi
#
#
#if [ $? -ne 0 ]; then
# echo "gdebi installation failed.... dependencies will not be installed without gdebi"
# read -p "Do you wish to continue without gdebi? [Yes/No] " yn
# case $yn in
# [Yy]* ) echo "Continueing without gdebi.....";;
# [Nn]* ) echo "Try to resolve errors and re-run the script.";
# exit;;
# * ) exit;;
# esac
#fi
#
#
#for f in ./wso2-raspi-alarm_1.0_armhf.deb; do
# ## Check if the glob gets expanded to existing files.
# ## If not, f here will be exactly the pattern above
# ## and the exists test will evaluate to false.
# # [ -e "$f" ] && echo "'wso2-raspi-alarm_1.0_armhf.deb' file found and installing" || echo "'wso2-raspi-alarm_1.0_armhf.deb' file does not exist in current path"; exit;
# if [ -e "$f" ]; then
# echo "'wso2-raspi-alarm_1.0_armhf.deb' file found and installing now...."
# else
# echo "'wso2-raspi-alarm_1.0_armhf.deb' file does not exist in current path. \nExiting installation...";
# exit;
# fi
# ## This is all we needed to know, so we can break after the first iteration
# break
#done
#
#echo "Installing the 'wso2-raspi-alarm deb package'"
#sudo gdebi wso2-raspi-alarm_1.0_armhf.deb
#
#if [ $? -ne 0 ]; then
# echo "Installation Failed...."
# exit;
#fi
#sudo killall -9 python
#
#for f in ./RaspberryAgent.zip; do
# ## Check if the glob gets expanded to existing files.
# ## If not, f here will be exactly the pattern above
# ## and the exists test will evaluate to false.
# # [ -e "$f" ] && echo "'wso2-raspi-alarm_1.0_armhf.deb' file found and installing" || echo "'wso2-raspi-alarm_1.0_armhf.deb' file does not exist in current path"; exit;
# if [ -e "$f" ]; then
# echo "Agent files found......"
# sudo rm -rf /usr/local/src/RaspberryAgent
# sudo unzip RaspberryAgent.zip -d /usr/local/src/
# else
# echo "'RaspberryAgent.zip' file does not exist in current path. \nInstalling without upgrading agent...";
# fi
# ## This is all we needed to know, so we can break after the first iteration
# break
#done
#
#for f in /usr/local/src/RaspberryAgent/rc.local; do
# ## Check if the glob gets expanded to existing files.
# ## If not, f here will be exactly the pattern above
# ## and the exists test will evaluate to false.
# if [ -e "$f" ]; then
# echo "Copying boot script"
# sudo mv /usr/local/src/RaspberryAgent/rc.local /etc/rc.local
# sudo chmod +x /etc/rc.local
# else
# echo "Unable to set agent statup on boot";
# fi
# ## This is all we needed to know, so we can break after the first iteration
# break
#done
#
#for f in ./deviceConfigs.cfg; do
# ## Check if the glob gets expanded to existing files.
# ## If not, f here will be exactly the pattern above
# ## and the exists test will evaluate to false.
# if [ -e "$f" ]; then
# echo "Configuration file found......"
# else
# echo "'deviceConfigs.cfg' file does not exist in current path. \nExiting installation...";
# exit;
# fi
# ## This is all we needed to know, so we can break after the first iteration
# break
#done
#
#echo "Altering Configuration file"
#sed -i 's|[/,]||g' deviceConfigs.cfg
#
#echo "Copying configurations file to /usr/local/src/RaspberryAgent"
#sudo cp ./deviceConfigs.cfg /usr/local/src/RaspberryAgent/
#
#if [ $? -ne 0 ]; then
# echo "Copying configuration file failed...."
# exit;
#fi
#
#while true; do
# read -p "Whats the time-interval (in seconds) between successive Data-Pushes to the WSO2-DC (ex: '60' indicates 1 minute) > " input
#
# if [ $input -eq $input 2>/dev/null ]
# then
# echo "Setting data-push interval to $input seconds."
# echo $input > /usr/local/src/RaspberryAgent/time-interval
# break;
# else
# echo "Input needs to be an integer indicating the number seconds between successive data-pushes."
# fi
#done
#
#cd /usr/local/src/RaspberryAgent/
#sudo chmod +x RaspberryStats.py
#sudo nohup ./RaspberryStats.py -i $input </dev/null &
#
#if [ $? -ne 0 ]; then
# echo "Could not start the service..."
# exit;
#else
# echo "Running the RaspberryAgent service...."
#fi
#
#echo "--------------------------------------------------------------------------"
#echo "| Successfully Started "
#echo "| -------------------------- "
#echo "| cd to /usr/local/src/RaspberryAgent"
#echo "| run 'sudo nohup ./RaspberryStats.py -i time </dev/null &'to start service manually."
#echo "| Relapce time with the time-interval (in seconds) between successive Data-Pushes to the WSO2-DC (ex: '60' indicates 1 minute)"
#echo "| Find logs at: /usr/local/src/RaspberryAgent/logs/RaspberryStats.log"
#echo "---------------------------------------------------------------------------"
Loading…
Cancel
Save