Commit 9b104e46 authored by Pavel Vainerman's avatar Pavel Vainerman

(python): Добавил вспомогательные функции для работы с аргументами командной строки

parent 83f6b38b
......@@ -7,7 +7,7 @@
Name: libuniset
Version: 1.6
Release: alt12
Release: alt13
Summary: UniSet - library for building distributed industrial control systems
......@@ -319,6 +319,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
%exclude %_pkgconfigdir/libUniSet.pc
%changelog
* Thu Oct 24 2013 Pavel Vainerman <pv@altlinux.ru> 1.6-alt13
- (python): add getArgParam, getArgInt and checkArg functions for UGlobal.py
* Thu Sep 19 2013 Pavel Vainerman <pv@altlinux.ru> 1.6-alt12
- (Modbus): Added ability to set the sensor mode (modeSensor) for each device
- fixed bug in MTR types: T_Str16 and T_Str8 (tnx ilyap)
......
......@@ -3,6 +3,7 @@
from pyUConnector import *
import time
import sys
def is_id( str_id ):
if str_id.__class__.__name__ == "int":
......@@ -219,3 +220,30 @@ def fcalibrate( raw, rawMin, rawMax, calMin, calMax ):
return 0; # деление на 0!!!
return 1.0 * (raw - rawMin) * (calMax - calMin) / ( rawMax - rawMin ) + calMin;
def getArgParam(param,defval=""):
for i in range(0, len(sys.argv)):
if sys.argv[i] == param:
if i+1 < len(sys.argv):
return sys.argv[i+1]
else:
break;
return defval
def getArgInt(param,defval=0):
for i in range(0, len(sys.argv)):
if sys.argv[i] == param:
if i+1 < len(sys.argv):
return to_int(strsys.argv[i+1])
else:
break;
return defval
def checkArgParam(param,defval=""):
for i in range(0, len(sys.argv)):
if sys.argv[i] == param:
return True
return defval
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment