Compare commits
6 Commits
f32c007b3f
...
0.9.8
Author | SHA1 | Date | |
---|---|---|---|
ef778c3e0a | |||
49eb1522b6 | |||
cdeeceeb55 | |||
64089ce72c | |||
7683ec29e9 | |||
285b3514a8 |
@@ -15,7 +15,7 @@ jobs:
|
|||||||
run: tox
|
run: tox
|
||||||
- name: Upload na pypi
|
- name: Upload na pypi
|
||||||
env:
|
env:
|
||||||
TWINE_USERNAME: ${{ secret.PYPI_USER }}
|
TWINE_USERNAME: ${{ secrets.PYPI_USER }}
|
||||||
TWINE_PASSWORD: ${{ secret.PYPI_PASSWORD }}
|
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
|
||||||
if: github.ref_type == 'tag'
|
if: github.ref_type == 'tag'
|
||||||
run: python3 -m twine upload dist/*
|
run: python3 -m twine upload dist/*
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
name = lmwsip
|
name = lmwsip
|
||||||
version = 0.9.6
|
version = 0.9.8
|
||||||
author = Marcel Nijenhof
|
author = Marcel Nijenhof
|
||||||
author_email = pypi@marceln.org
|
author_email = pypi@marceln.org
|
||||||
description = Interface for the lmw sip protocol
|
description = Interface for the lmw sip protocol
|
||||||
|
@@ -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.9.6'
|
__version__ = '0.9.7'
|
||||||
|
|
||||||
class LmwSip:
|
class LmwSip:
|
||||||
"""Class to connect to the LMW Standard Interface prototcol (sip)
|
"""Class to connect to the LMW Standard Interface prototcol (sip)
|
||||||
@@ -28,8 +28,6 @@ Support for:
|
|||||||
cmd(wn, vw, as)
|
cmd(wn, vw, as)
|
||||||
|
|
||||||
lmwParameters:
|
lmwParameters:
|
||||||
|
|
||||||
Overzicht van de lmw parameters
|
|
||||||
- Type: WN, VW, AS
|
- Type: WN, VW, AS
|
||||||
- Array size: [1-201]
|
- Array size: [1-201]
|
||||||
- Periode: 1, 10
|
- Periode: 1, 10
|
||||||
@@ -600,7 +598,7 @@ Opens the connection and logs in.
|
|||||||
"time_of_day": time.strftime("%H:%M", time.gmtime(now)) }
|
"time_of_day": time.strftime("%H:%M", time.gmtime(now)) }
|
||||||
|
|
||||||
def connect(self):
|
def connect(self):
|
||||||
"""connect()
|
"""Setup the network connection
|
||||||
|
|
||||||
connects to lmw with tcp using the values of the object creation.
|
connects to lmw with tcp using the values of the object creation.
|
||||||
"""
|
"""
|
||||||
@@ -636,7 +634,7 @@ connects to lmw with tcp using the values of the object creation.
|
|||||||
self._socket = None
|
self._socket = None
|
||||||
|
|
||||||
def send(self, sipcmd):
|
def send(self, sipcmd):
|
||||||
"""send(sipcmd)
|
"""Send a sip command to the server
|
||||||
|
|
||||||
send a sip command to the server
|
send a sip command to the server
|
||||||
"""
|
"""
|
||||||
@@ -666,7 +664,7 @@ send a sip command to the server
|
|||||||
raise LmwSipConnectError("LmwSip.telnetheader: Socket connection lost")
|
raise LmwSipConnectError("LmwSip.telnetheader: Socket connection lost")
|
||||||
|
|
||||||
def recv(self):
|
def recv(self):
|
||||||
"""recv()
|
"""Recieve the results
|
||||||
|
|
||||||
recieve a answer from the sip server
|
recieve a answer from the sip server
|
||||||
"""
|
"""
|
||||||
@@ -709,7 +707,7 @@ recieve a answer from the sip server
|
|||||||
return(stringbuf)
|
return(stringbuf)
|
||||||
|
|
||||||
def login(self):
|
def login(self):
|
||||||
"""login()
|
"""Login the sip server
|
||||||
|
|
||||||
Login lmw using the object creation user, password.
|
Login lmw using the object creation user, password.
|
||||||
Raises a LmwLoginFailure exception on failure
|
Raises a LmwLoginFailure exception on failure
|
||||||
@@ -733,7 +731,7 @@ Raises a LmwLoginFailure exception on failure
|
|||||||
self.login()
|
self.login()
|
||||||
|
|
||||||
def reconnectcheck(self):
|
def reconnectcheck(self):
|
||||||
"""reconnectcheck()
|
"""Check if we need to reconnect.
|
||||||
|
|
||||||
Checks if a reconnect is nessecery.
|
Checks if a reconnect is nessecery.
|
||||||
|
|
||||||
@@ -751,7 +749,7 @@ There are two timeouts:
|
|||||||
self.reconnect()
|
self.reconnect()
|
||||||
|
|
||||||
def sendrecv(self, cmd):
|
def sendrecv(self, cmd):
|
||||||
"""sendrecv(cmd)
|
"""Send a a command and recieve the result.
|
||||||
|
|
||||||
send the command and recieve the answer.
|
send the command and recieve the answer.
|
||||||
retry on socket failure.
|
retry on socket failure.
|
||||||
@@ -780,7 +778,7 @@ retry on socket failure.
|
|||||||
return(ret)
|
return(ret)
|
||||||
|
|
||||||
def ti(self):
|
def ti(self):
|
||||||
"""ti()
|
"""Recieve the time from the sipserver.
|
||||||
|
|
||||||
Request the time from lmw and returns the string.
|
Request the time from lmw and returns the string.
|
||||||
|
|
||||||
@@ -792,7 +790,7 @@ Raises a LmwCmdWarn of failure
|
|||||||
|
|
||||||
def cmd(self, process, location, parameter, time_delta, day,
|
def cmd(self, process, location, parameter, time_delta, day,
|
||||||
time_of_day, cmd_type="DATA"):
|
time_of_day, cmd_type="DATA"):
|
||||||
"""cmd(process, location, parameter, time_delta, day, time_of_day)
|
"""Create a sip command from the paramters
|
||||||
|
|
||||||
Send a cmd to LMW and returns the lmw string
|
Send a cmd to LMW and returns the lmw string
|
||||||
|
|
||||||
@@ -824,9 +822,35 @@ Returns:
|
|||||||
raise LmwCmdWarn(cmdstr, d)
|
raise LmwCmdWarn(cmdstr, d)
|
||||||
return (d[2:-1])
|
return (d[2:-1])
|
||||||
|
|
||||||
|
def cmdWrite(self, process, location, parameter, time_delta, day,
|
||||||
|
time_of_day, values):
|
||||||
|
"""Write data to LMW
|
||||||
|
|
||||||
|
process: <WNT|VWT|AST>
|
||||||
|
location: <lmw location (e.g. HOEK)>
|
||||||
|
parameter: <lmw parameter (e.g. H10)>
|
||||||
|
time_delta: <Time windows (max 23:59, e.g. +01:00>
|
||||||
|
day: <Date>
|
||||||
|
time_of_day: <Time>
|
||||||
|
data: Values to be writen (e.g. 33/10;35/10).
|
||||||
|
|
||||||
|
Example:
|
||||||
|
lmw.cmd("WNT", "HOEK", "H10", "+00:20", "13-08-2018", "16:00", "33/10;35/10")
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
The LMW answer string
|
||||||
|
"""
|
||||||
|
cmdstr=process + " " + self.meetnet + "," + location + "," + \
|
||||||
|
parameter + "," + time_delta + "," + day + "," + \
|
||||||
|
time_of_day + "," + values + "\r"
|
||||||
|
d = self.sendrecv(cmdstr)
|
||||||
|
if (d[0] != '!'):
|
||||||
|
raise LmwCmdWarn(cmdstr, d)
|
||||||
|
return (d[2:-1])
|
||||||
|
|
||||||
def valueStr(self, process, location, parameter, day = None,
|
def valueStr(self, process, location, parameter, day = None,
|
||||||
time_of_day = None):
|
time_of_day = None):
|
||||||
"""value(process, location, parameter, [day], [time_of_day]):
|
"""Get string of values from sip
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
process: <WN|VW|AS>
|
process: <WN|VW|AS>
|
||||||
@@ -853,7 +877,7 @@ Returns a single string value with quality
|
|||||||
|
|
||||||
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]):
|
"""Get one value from sip
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
process: <WN|VW|AS>
|
process: <WN|VW|AS>
|
||||||
@@ -897,7 +921,7 @@ Returns a single string value or None
|
|||||||
|
|
||||||
def timeSerie(self, process, location, parameter,
|
def timeSerie(self, process, location, parameter,
|
||||||
startTime, endTime, cmd_type="DATB"):
|
startTime, endTime, cmd_type="DATB"):
|
||||||
"""timeSerie(process, location, parameter, startTime, endTime, cmd_type="DATA")
|
"""Get a python data structure with the results.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
process: <WN|VW|AS>
|
process: <WN|VW|AS>
|
||||||
@@ -966,7 +990,7 @@ Errors:
|
|||||||
return(res)
|
return(res)
|
||||||
|
|
||||||
def logout(self):
|
def logout(self):
|
||||||
"""logout()
|
"""Logut of the sip server,
|
||||||
|
|
||||||
Logs of
|
Logs of
|
||||||
"""
|
"""
|
||||||
@@ -990,7 +1014,7 @@ Note:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, start, delta, values=""):
|
def __init__(self, start, delta, values=""):
|
||||||
"""lmwTimeSerie(start, delta, values)
|
"""lmwTimeSerie init
|
||||||
|
|
||||||
Create a lmwTimeSerie object with:
|
Create a lmwTimeSerie object with:
|
||||||
start: Start time
|
start: Start time
|
||||||
@@ -1003,7 +1027,7 @@ Create a lmwTimeSerie object with:
|
|||||||
self.addvalues(start, values)
|
self.addvalues(start, values)
|
||||||
|
|
||||||
def addvalues(self, start, values):
|
def addvalues(self, start, values):
|
||||||
"""addvalues(start, delta, values)
|
"""Add values
|
||||||
|
|
||||||
Add values to a timeserie
|
Add values to a timeserie
|
||||||
start: Start time
|
start: Start time
|
||||||
|
@@ -77,6 +77,10 @@ class lmwsipTest(unittest.TestCase):
|
|||||||
with self.assertRaises(lmwsip.LmwCmdWarn):
|
with self.assertRaises(lmwsip.LmwCmdWarn):
|
||||||
self.assertEqual(type(self.sip.cmd("NOP", "DUMMY", "H10", "+00:59", "2020-01-01", "00:00")), str)
|
self.assertEqual(type(self.sip.cmd("NOP", "DUMMY", "H10", "+00:59", "2020-01-01", "00:00")), str)
|
||||||
|
|
||||||
|
def test_cmdWrite(self):
|
||||||
|
self.login()
|
||||||
|
self.assertEqual(type(self.sip.cmdWrite("WN", "DUMMY", "H10", "+00:20", "2020-01-01", "00:00", "35/10;33/10")), str)
|
||||||
|
|
||||||
def test_value(self):
|
def test_value(self):
|
||||||
self.login()
|
self.login()
|
||||||
self.assertEqual(type(self.sip.value("WN", "DUMMY", "H10")), str)
|
self.assertEqual(type(self.sip.value("WN", "DUMMY", "H10")), str)
|
||||||
|
Reference in New Issue
Block a user