129 lines
No EOL
3.1 KiB
Python
129 lines
No EOL
3.1 KiB
Python
'''
|
|
JMK Engineering Inc. Python Library for design and such.
|
|
by: Jeff MacKinnon
|
|
|
|
email: jeff@jmkengineering.com
|
|
|
|
Electrical Safety
|
|
|
|
These functions are used to calculate boundaries, etc.
|
|
|
|
'''
|
|
|
|
import sqlite3
|
|
|
|
def limitedApproach(voltage,fixed=False,DC=False,unitsSI=True,year=2015):
|
|
|
|
if year == 2015:
|
|
database = "jepl-z46215.db"
|
|
|
|
if DC == True:
|
|
try:
|
|
with sqlite3.connect(database) as con:
|
|
cur = con.cursor()
|
|
|
|
cur.execute('SELECT * FROM "Table1B" WHERE "Voltage" > ? ', (voltage,))
|
|
row = cur.fetchone()
|
|
|
|
except sqlite3.OperationalError as e:
|
|
print(e)
|
|
else:
|
|
try:
|
|
with sqlite3.connect(database) as con:
|
|
cur = con.cursor()
|
|
|
|
cur.execute('SELECT * FROM "Table1A" WHERE "Voltage" > ? ', (voltage,))
|
|
row = cur.fetchone()
|
|
|
|
except sqlite3.OperationalError as e:
|
|
print(e)
|
|
|
|
|
|
if (fixed == False) & (unitsSI == True):
|
|
column = 1
|
|
elif (fixed == False) & (unitsSI == False):
|
|
column = 2
|
|
elif (fixed == True) & (unitsSI == True):
|
|
column = 3
|
|
elif (fixed == True) & (unitsSI == False):
|
|
column = 4
|
|
|
|
distance = row[column]
|
|
return(distance)
|
|
|
|
def restrictedApproach(voltage,DC=False,unitsSI=True,year=2015):
|
|
|
|
if year == 2015:
|
|
database = "jepl-z46215.db"
|
|
|
|
if DC == True:
|
|
try:
|
|
with sqlite3.connect(database) as con:
|
|
cur = con.cursor()
|
|
|
|
cur.execute('SELECT * FROM "Table1B" WHERE "Voltage" > ? ', (voltage,))
|
|
row = cur.fetchone()
|
|
|
|
except sqlite3.OperationalError as e:
|
|
print(e)
|
|
else:
|
|
try:
|
|
with sqlite3.connect(database) as con:
|
|
cur = con.cursor()
|
|
|
|
cur.execute('SELECT * FROM "Table1A" WHERE "Voltage" > ? ', (voltage,))
|
|
row = cur.fetchone()
|
|
|
|
except sqlite3.OperationalError as e:
|
|
print(e)
|
|
|
|
|
|
if (unitsSI == True):
|
|
column = 5
|
|
else:
|
|
column = 6
|
|
|
|
distance = row[column]
|
|
return(distance)
|
|
|
|
|
|
|
|
def gloveClass(voltage,DC=False):
|
|
'''
|
|
The glove class is based on the ASTM standard D120.
|
|
'''
|
|
|
|
if DC == True:
|
|
if voltage <= 750:
|
|
gloveclass = '00'
|
|
elif voltage <= 1500:
|
|
gloveclass = '0'
|
|
elif voltage <= 11250:
|
|
gloveclass = '1'
|
|
elif voltage <= 25500:
|
|
gloveclass = '2'
|
|
elif voltage <= 39750:
|
|
gloveclass = '3'
|
|
elif voltage <= 54000:
|
|
gloveclass = '4'
|
|
else:
|
|
gloveclass = "Voltage too High"
|
|
|
|
|
|
else:
|
|
if voltage <= 500:
|
|
gloveclass = '00'
|
|
elif voltage <= 1000:
|
|
gloveclass = '0'
|
|
elif voltage <= 7500:
|
|
gloveclass = '1'
|
|
elif voltage <= 17000:
|
|
gloveclass = '2'
|
|
elif voltage <= 26500:
|
|
gloveclass = '3'
|
|
elif voltage <= 36000:
|
|
gloveclass = '4'
|
|
else:
|
|
gloveclass = "Voltage too High"
|
|
|
|
return(gloveclass) |