Files
lmwsip/README.md
Marcel Nijenhof df36ae495c
All checks were successful
continuous-integration/drone/push Build is passing
Aanpassing siprun naar lmwsip.run module
- Splitsing losse run functie
 - Aanpassing documentatie
2020-09-08 13:11:15 +02:00

96 lines
1.9 KiB
Markdown

# lmwsip
## Introduction
lmwsip is a python library for the lmw sip protocol.
## Package
The lmwsip package contains the class LmwSip to connect to the
LMW meetnet using de SIP protocol. The library contains documentation
how to use it.
## Installing
The package is not available on [PyPI](https://pypi.org/).
At the moment the package is hosted at https://marceln.org/download/python.
You can install the package with pip:
```
pip install -i https://marceln.org/download/python lmwsip
```
## Tools
### lmwsip-test
A small test program containing some functions to test the library.
### siprun
A prgram to run SIP command files.
See "siprun -H" for usage information.
#### hoek-h10.sip
A sample sip command file to request the waterlevel at hoek van holland
from the last hour
## Username password
All files contain "USER", "PASS".
These values should be replaced by real credentials.
Otherwise the connection fails.
## Examples
### Library
#### Use send (low level)
``` python
from lmwsip import LmwSip
sip = LmwSip(ssl=True, host="sip-lmw.rws.nl", port=443)
sip.send("LI user,pass\r")
print("< [%s]" % (sip.recv().strip('\r')))
sip.send("TI LMW\r")
print("< [%s]" % (sip.recv().strip('\r')))
sip.send("LO\r")
print("< [%s]" % (sip.recv().strip('\r')))
```
#### Use value
``` python
from lmwsip import LmwSip
sip = LmwSip("USER", "PASS")
print(sip.ti())
print(sip.value("WN", "HOEK", "H10"))
sip.logout()
```
#### Use timeseries
``` python
from lmwsip import LmwSip
from datetime import datetime, timedelta
from pprint import pprint
end = datetime.now()
start = end - timedelta(hours=1)
sip = LmwSip("USER", "PASS")
pprint(sip.timeSerie("WN", "HOEK", "H10", start, end).ts)
```
### lmwsip.run
```
$ python -m lmwsip.run /tmp/hoek-h10.sip
> [LI USER,PASS]
< [! ]
> [TI LMW]
< [! 08-SEP-20 12:03:27]
> [WN LMW,HOEK,H10,-01:00,08-09-2020,11:50,DATA]
< [! -17/50;-21/50;-24/50;-26/50;-27/50;-28/50;-28/50]
> [LO]
< [! ]
```