valueStr added with quality
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -12,7 +12,7 @@ from datetime import datetime, timedelta
|
|||||||
from dateutil import tz
|
from dateutil import tz
|
||||||
|
|
||||||
""" Version info changed by git hook """
|
""" Version info changed by git hook """
|
||||||
__version__ = '0.1.7'
|
__version__ = '0.1.8'
|
||||||
|
|
||||||
class LmwSip:
|
class LmwSip:
|
||||||
"""Class to connect to the LMW Standard Interface prototcol (sip)
|
"""Class to connect to the LMW Standard Interface prototcol (sip)
|
||||||
@@ -812,6 +812,33 @@ Returns:
|
|||||||
raise LmwCmdWarn(cmdstr, d)
|
raise LmwCmdWarn(cmdstr, d)
|
||||||
return (d[2:-1])
|
return (d[2:-1])
|
||||||
|
|
||||||
|
def valueStr(self, process, location, parameter, day = None,
|
||||||
|
time_of_day = None):
|
||||||
|
"""value(process, location, parameter, [day], [time_of_day]):
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
process: <WN|VW|AS>
|
||||||
|
location: <lmw location (e.g. HOEK)>
|
||||||
|
parameter: <lmw parameter (e.g. H10)>
|
||||||
|
day: [date = now()]
|
||||||
|
time_of_day: [time = now()]
|
||||||
|
|
||||||
|
The default returns the last value string including quality.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
lmw.data_string("WN", "HOEK", "H10")
|
||||||
|
|
||||||
|
Returns a single string value with quality
|
||||||
|
"""
|
||||||
|
if (day == None or time_of_day == None):
|
||||||
|
last = self.lasttime(parameter)
|
||||||
|
if (day==None):
|
||||||
|
day=last["day"]
|
||||||
|
if (time_of_day==None):
|
||||||
|
time_of_day=last["time_of_day"]
|
||||||
|
return(self.cmd(process, location, parameter, "+00:00", day,
|
||||||
|
time_of_day, "DATA"))
|
||||||
|
|
||||||
def value(self, process, location, parameter, day = None,
|
def value(self, process, location, parameter, day = None,
|
||||||
time_of_day = None):
|
time_of_day = None):
|
||||||
"""value(process, location, parameter, [day], [time_of_day]):
|
"""value(process, location, parameter, [day], [time_of_day]):
|
||||||
@@ -830,14 +857,7 @@ Example:
|
|||||||
|
|
||||||
Returns a single string value or None
|
Returns a single string value or None
|
||||||
"""
|
"""
|
||||||
if (day == None or time_of_day == None):
|
res = self.valueStr(process, location, parameter, day, time_of_day)
|
||||||
last = self.lasttime(parameter)
|
|
||||||
if (day==None):
|
|
||||||
day=last["day"]
|
|
||||||
if (time_of_day==None):
|
|
||||||
time_of_day=last["time_of_day"]
|
|
||||||
res = self.cmd(process, location, parameter, "+00:00", day,
|
|
||||||
time_of_day, "DATA")
|
|
||||||
value=re.sub("/.*$", "", res)
|
value=re.sub("/.*$", "", res)
|
||||||
if (value == "99999"):
|
if (value == "99999"):
|
||||||
value=""
|
value=""
|
||||||
|
@@ -85,6 +85,10 @@ class lmwsipTest(unittest.TestCase):
|
|||||||
self.login()
|
self.login()
|
||||||
self.assertEqual(type(self.sip.value("WN", "DUMMY", "H1")), str)
|
self.assertEqual(type(self.sip.value("WN", "DUMMY", "H1")), str)
|
||||||
|
|
||||||
|
def test_valueStr(self):
|
||||||
|
self.login()
|
||||||
|
self.assertEqual(type(self.sip.valueStr("WN", "DUMMY", "H10")), str)
|
||||||
|
|
||||||
def test_logout(self):
|
def test_logout(self):
|
||||||
self.login()
|
self.login()
|
||||||
self.assertEqual(self.sip.logout(), None)
|
self.assertEqual(self.sip.logout(), None)
|
||||||
|
2
setup.py
2
setup.py
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
|
|||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name="lmwsip", # Replace with your own username
|
name="lmwsip", # Replace with your own username
|
||||||
version="0.1.7",
|
version="0.1.8",
|
||||||
author="Marcel Nijenhof",
|
author="Marcel Nijenhof",
|
||||||
author_email="pip@marceln.org",
|
author_email="pip@marceln.org",
|
||||||
description="Interface for the lmw sip protocol",
|
description="Interface for the lmw sip protocol",
|
||||||
|
Reference in New Issue
Block a user