You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
544 B
Python
26 lines
544 B
Python
import re
|
|
from DeviceManage import Device
|
|
|
|
def importProject():
|
|
curSlave = 0
|
|
startAddress = 0
|
|
protocolType = None
|
|
devices = []
|
|
with open('program.txt', 'r') as f:
|
|
lines = f.readlines()
|
|
for line in lines:
|
|
if "协议类型选择" in line:
|
|
if line[-3:-2] == '0':
|
|
protocolType = "DP主站"
|
|
elif "-Slave [" in line:
|
|
device = Device()
|
|
pattern = r'\d+'
|
|
slaveIndex = re.findall(pattern, line)[0]
|
|
deviceName = protocolType + slaveIndex
|
|
if slaveIndex == "0":
|
|
device.startAddress = 0
|
|
|
|
|
|
|
|
|
|
importProject() |