updated path

This commit is contained in:
Nico Melone
2021-08-12 11:05:44 -05:00
parent 0acf88a1e9
commit 6a7cfe2f1b

View File

@@ -1,4 +1,6 @@
import csv
import os
pwd = os.getcwd()
#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): "))
if not csv_file:
@@ -24,7 +26,7 @@ if csv_file:
reader = csv.reader(tagsFile)
try:
f = open("python-driver/Tags.py", "a")
f = open("Tags.py", "a")
print("writing tags")
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
if(num_channels == 0):
try:
file = open("python-driver/Tags.py", "a")
file = open("Tags.py", "a")
file.write("tags = []")
file.close
print("Wrote no Channels")
@@ -70,7 +73,7 @@ else:
print("Couldn't open file without tags")
elif plc_or_mbs == 1:
try:
file = open("python-driver/Tags.py", "a")
file = open("Tags.py", "a")
file.write("tags = [ \n")
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}}"))
@@ -85,7 +88,8 @@ else:
print("Couldn't open file with tags")
else:
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")
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]))