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
|
||||
|
||||
""" Version info changed by git hook """
|
||||
__version__ = '0.1.7'
|
||||
__version__ = '0.1.8'
|
||||
|
||||
class LmwSip:
|
||||
"""Class to connect to the LMW Standard Interface prototcol (sip)
|
||||
@@ -812,6 +812,33 @@ Returns:
|
||||
raise LmwCmdWarn(cmdstr, d)
|
||||
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,
|
||||
time_of_day = None):
|
||||
"""value(process, location, parameter, [day], [time_of_day]):
|
||||
@@ -830,14 +857,7 @@ Example:
|
||||
|
||||
Returns a single string value or None
|
||||
"""
|
||||
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"]
|
||||
res = self.cmd(process, location, parameter, "+00:00", day,
|
||||
time_of_day, "DATA")
|
||||
res = self.valueStr(process, location, parameter, day, time_of_day)
|
||||
value=re.sub("/.*$", "", res)
|
||||
if (value == "99999"):
|
||||
value=""
|
||||
|
@@ -85,6 +85,10 @@ class lmwsipTest(unittest.TestCase):
|
||||
self.login()
|
||||
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):
|
||||
self.login()
|
||||
self.assertEqual(self.sip.logout(), None)
|
||||
|
Reference in New Issue
Block a user