Skip to content
This repository has been archived by the owner on Jan 17, 2020. It is now read-only.

Commit

Permalink
Merge pull request #9 from foglamp/1.5.0RC
Browse files Browse the repository at this point in the history
1.5.0 Release
  • Loading branch information
praveen-garg authored Feb 22, 2019
2 parents 5001ab1 + 6f6e08e commit 6f0f618
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 122 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
*.idea

# Build
packages/Debian/build/
packages/build/

# Compiled Object files
*.pyc

# Test
.pytest_cache
.pytest_cache
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2018 Dianomic Systems

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions VERSION.south.pt100
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
foglamp_south_pt100_version=1.0.0
foglamp_version>=1.3
foglamp_south_pt100_version=1.5.0
foglamp_version>=1.5
19 changes: 11 additions & 8 deletions make_deb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

##--------------------------------------------------------------------
## Copyright (c) 2018 OSIsoft, LLC
## Copyright (c) 2018 Dianomic Systems
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
Expand All @@ -16,7 +16,7 @@
## limitations under the License.
##--------------------------------------------------------------------
##
## Author: Ivan Zoratti
## Author: Ivan Zoratti, Vaibhav Singhal
##


Expand All @@ -35,21 +35,19 @@ do
case "$i" in
clean)
echo -n "Cleaning the build folder from older versions..."
find "${GIT_ROOT}/packages/Debian/build" -maxdepth 1 | grep '.*\.[0-9][0-9][0-9][0-9]' | xargs rm -rf
find "${GIT_ROOT}/packages/build" -maxdepth 1 | grep '.*\.[0-9][0-9][0-9][0-9]' | xargs rm -rf
echo "Done."
exit 0
shift
;;
cleanall)
if [ -d "${GIT_ROOT}/packages/Debian/build" ]; then
if [ -d "${GIT_ROOT}/packages/build" ]; then
echo -n "Cleaning the build folder..."
rm -rf ${GIT_ROOT}/packages/Debian/build/*
rm -rf ${GIT_ROOT}/packages/build/*
echo "Done."
else
echo "No build folder, skipping cleanall"
fi
exit 0
shift
;;
*)
echo "${usage}"
Expand All @@ -58,10 +56,15 @@ do
esac
done

if [ "$(dpkg --print-architecture)" != "armhf" ]; then
echo "Package building is only supported on armhf architecture!!"
exit 0
fi

architecture="armhf"
version=`cat ${GIT_ROOT}/VERSION.south.pt100 | tr -d ' ' | grep 'foglamp_south_pt100_version=' | head -1 | sed -e 's/\(.*\)=\(.*\)/\2/g'`
foglamp_version=`cat ${GIT_ROOT}/VERSION.south.pt100 | tr -d ' ' | grep 'foglamp_version' | head -1 | sed -e 's/\(.*\)version\(.*\)/\2/g'`
BUILD_ROOT="${GIT_ROOT}/packages/Debian/build"
BUILD_ROOT="${GIT_ROOT}/packages/build"

# Final package name
package_name="foglamp-south-pt100-${version}-${architecture}"
Expand Down
8 changes: 1 addition & 7 deletions packages/Debian/armhf/DEBIAN/postinst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

##--------------------------------------------------------------------
## Copyright (c) 2018 OSIsoft, LLC
## Copyright (c) 2018 Dianomic Systems
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -31,11 +31,5 @@ set_files_ownership () {
chown -R root:root /usr/local/foglamp/python/foglamp/plugins/south/pt100
}

add_service () {
output=$(curl -sX POST http://localhost:8081/foglamp/service -d '{"name": "pt100", "type": "south", "plugin": "pt100", "enabled": true}')
echo $output
}

set_files_ownership
add_service
echo "PT100 plugin is now installed."
57 changes: 0 additions & 57 deletions packages/Debian/armhf/DEBIAN/preinst

This file was deleted.

72 changes: 27 additions & 45 deletions python/foglamp/plugins/south/pt100/pt100.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import datetime
import json
import uuid
import logging
import RPi.GPIO as GPIO

from foglamp.plugins.south.pt100.max31865 import *
Expand All @@ -19,29 +20,34 @@


__author__ = "Ashwin Gopalakrishnan"
__copyright__ = "Copyright (c) 2018 OSIsoft, LLC"
__copyright__ = "Copyright (c) 2018 Dianomic Systems"
__license__ = "Apache 2.0"
__version__ = "${VERSION}"

_DEFAULT_CONFIG = {
'plugin': {
'description': 'PT100 Poll Plugin',
'type': 'string',
'default': 'pt100'
'description': 'PT100 Poll Plugin',
'type': 'string',
'default': 'pt100',
'readonly': 'true'
},
'assetNamePrefix': {
'description': 'Asset prefix',
'type': 'string',
'default': "PT100/",
'order': "1",
'displayName': 'Asset Name Prefix'
},
'pins': {
'description': 'Chip select pins to check',
'type': 'string',
'default': '8'
},
'pollInterval': {
'description': 'The interval between poll calls to the South device poll routine expressed in milliseconds.',
'type': 'integer',
'default': '5000'
},
'default': '8',
'order': "3",
'displayName': 'GPIO Pin'
}
}

_LOGGER = logger.setup(__name__, level=20)
_LOGGER = logger.setup(__name__, level=logging.INFO)


def plugin_info():
Expand All @@ -55,7 +61,7 @@ def plugin_info():

return {
'name': 'PT100 Poll Plugin',
'version': '1.0',
'version': '1.5.0',
'mode': 'poll',
'type': 'south',
'interface': '1.0',
Expand All @@ -67,7 +73,7 @@ def plugin_init(config):
""" Initialise the plugin.
Args:
config: JSON configuration document for the South device configuration category
config: JSON configuration document for the South plugin configuration category
Returns:
handle: JSON object to be used in future calls to the plugin
Raises:
Expand Down Expand Up @@ -97,22 +103,20 @@ def plugin_poll(handle):
DataRetrievalError
"""
probes = handle['probes']
time_stamp = str(datetime.datetime.now(tz=datetime.timezone.utc))
data = list()

try:
for probe in probes:
temperature = probe.readTemp()
time_stamp = str(datetime.datetime.now(tz=datetime.timezone.utc))
data.append({
'asset': 'PT100/temperature{}'.format(probe.csPin),
'timestamp': time_stamp,
'asset': '{}temperature{}'.format(handle['assetNamePrefix']['value'], probe.csPin),
'timestamp': utils.local_timestamp(),
'key': str(uuid.uuid4()),
'readings': {
"temperature": temperature
}
})
except (Exception, RuntimeError, pexpect.exceptions.TIMEOUT) as ex:
except (Exception, RuntimeError) as ex:
_LOGGER.exception("PT100 exception: {}".format(str(ex)))
raise exceptions.DataRetrievalError(ex)

Expand All @@ -123,7 +127,7 @@ def plugin_poll(handle):
def plugin_reconfigure(handle, new_config):
""" Reconfigures the plugin
it should be called when the configuration of the plugin is changed during the operation of the South device service;
it should be called when the configuration of the plugin is changed during the operation of the South service;
The new configuration category should be passed.
Args:
Expand All @@ -134,39 +138,17 @@ def plugin_reconfigure(handle, new_config):
Raises:
"""
_LOGGER.info("Old config for PT100 plugin {} \n new config {}".format(handle, new_config))

# Find diff between old config and new config
diff = utils.get_diff(handle, new_config)

# Plugin should re-initialize and restart if key configuration is changed
if 'pollInterval' in diff:
new_handle = copy.deepcopy(new_config)
new_handle['restart'] = 'no'
else:
new_handle = copy.deepcopy(handle)
new_handle['restart'] = 'no'
new_handle = copy.deepcopy(new_config)
return new_handle


def _plugin_stop(handle):
""" Stops the plugin doing required cleanup, to be called prior to the South device service being shut down.
Args:
handle: handle returned by the plugin initialisation call
Returns:
Raises:
"""
GPIO.cleanup()
_LOGGER.info('PT100 poll plugin stop.')


def plugin_shutdown(handle):
""" Shutdowns the plugin doing required cleanup, to be called prior to the South device service being shut down.
""" Shutdowns the plugin doing required cleanup, to be called prior to the South service being shut down.
Args:
handle: handle returned by the plugin initialisation call
Returns:
Raises:
"""
_plugin_stop(handle)
GPIO.cleanup()
_LOGGER.info('PT100 poll plugin shut down.')

0 comments on commit 6f0f618

Please sign in to comment.