Удалить 'Project/rw_device_params.py'
This commit is contained in:
parent
e34a931a37
commit
4f692d3288
@ -1,33 +0,0 @@
|
||||
# Dict for all devices params
|
||||
|
||||
all_params = {'func': 0, 'status': 1, 'name': 2,
|
||||
'id': 3, 'type_of_connection': 4, 'baud_rate': 5}
|
||||
|
||||
# Read device params from .dat device file
|
||||
|
||||
|
||||
def read_device_params(name):
|
||||
file = open('data/{}.dat'.format(name), 'r')
|
||||
params = file.readline().split()
|
||||
file.close()
|
||||
return params
|
||||
|
||||
# Change device params in .dat device file
|
||||
|
||||
|
||||
def write_device_params(name, param, value):
|
||||
|
||||
try:
|
||||
file = open('data/{}.dat'.format(name), 'r+')
|
||||
params = file.readline().split()
|
||||
if value != '':
|
||||
params[all_params[param]] = str(value)
|
||||
else:
|
||||
params[all_params[param]] = 'none'
|
||||
file.seek(0)
|
||||
file.truncate()
|
||||
file.write(' '.join(params))
|
||||
file.close()
|
||||
|
||||
except IndexError:
|
||||
print('ErrorType = FileError: File.dat for this device does not exist')
|
Loading…
Reference in New Issue
Block a user