updated path
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
import csv
|
import csv
|
||||||
|
import os
|
||||||
|
pwd = os.getcwd()
|
||||||
#Generate a tag/channel list to be used in the template
|
#Generate a tag/channel list to be used in the template
|
||||||
csv_file = bool(input("Do you have a CSV file yes(1)/no(0): "))
|
csv_file = bool(input("Do you have a CSV file yes(1)/no(0): "))
|
||||||
if not csv_file:
|
if not csv_file:
|
||||||
@@ -24,7 +26,7 @@ if csv_file:
|
|||||||
reader = csv.reader(tagsFile)
|
reader = csv.reader(tagsFile)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
f = open("python-driver/Tags.py", "a")
|
f = open("Tags.py", "a")
|
||||||
print("writing tags")
|
print("writing tags")
|
||||||
f.write("tags = [ \n")
|
f.write("tags = [ \n")
|
||||||
|
|
||||||
@@ -62,7 +64,8 @@ else:
|
|||||||
#Generate a Tags.py file to hold a list of PLCChannels or ModbusChannels to be used in the driver to communicate
|
#Generate a Tags.py file to hold a list of PLCChannels or ModbusChannels to be used in the driver to communicate
|
||||||
if(num_channels == 0):
|
if(num_channels == 0):
|
||||||
try:
|
try:
|
||||||
file = open("python-driver/Tags.py", "a")
|
|
||||||
|
file = open("Tags.py", "a")
|
||||||
file.write("tags = []")
|
file.write("tags = []")
|
||||||
file.close
|
file.close
|
||||||
print("Wrote no Channels")
|
print("Wrote no Channels")
|
||||||
@@ -70,7 +73,7 @@ else:
|
|||||||
print("Couldn't open file without tags")
|
print("Couldn't open file without tags")
|
||||||
elif plc_or_mbs == 1:
|
elif plc_or_mbs == 1:
|
||||||
try:
|
try:
|
||||||
file = open("python-driver/Tags.py", "a")
|
file = open("Tags.py", "a")
|
||||||
file.write("tags = [ \n")
|
file.write("tags = [ \n")
|
||||||
for x in range(num_channels):
|
for x in range(num_channels):
|
||||||
file.write("\tPLCChannel(PLC_IP_ADDRESS, \"{}\",\"{}\",\"{}\", {}, {}, plc_type=\"{}\")".format(mesh_name[x],tags[x],data_type[x],change_thres[x],guaruntee_sec[x],"{{cookiecutter.device_type}}"))
|
file.write("\tPLCChannel(PLC_IP_ADDRESS, \"{}\",\"{}\",\"{}\", {}, {}, plc_type=\"{}\")".format(mesh_name[x],tags[x],data_type[x],change_thres[x],guaruntee_sec[x],"{{cookiecutter.device_type}}"))
|
||||||
@@ -85,7 +88,8 @@ else:
|
|||||||
print("Couldn't open file with tags")
|
print("Couldn't open file with tags")
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
file = open("python-driver/Tags.py", "a")
|
print("Opening 3 {{cookiecutter.driver_name}}/Tags.py")
|
||||||
|
file = open("Tags.py", "a")
|
||||||
file.write("tags = [ \n")
|
file.write("tags = [ \n")
|
||||||
for x in range(num_channels):
|
for x in range(num_channels):
|
||||||
file.write("\tModbusChannel(\"{}\",{},\"{}\", {}, {},channel_size={}, unit_number={})".format(mesh_name[x],register_num[x],data_type[x],change_thres[x],guaruntee_sec[x],channel_size[x],unit_number[x]))
|
file.write("\tModbusChannel(\"{}\",{},\"{}\", {}, {},channel_size={}, unit_number={})".format(mesh_name[x],register_num[x],data_type[x],change_thres[x],guaruntee_sec[x],channel_size[x],unit_number[x]))
|
||||||
|
|||||||
Reference in New Issue
Block a user