Added a single label LaTeX creation
This commit is contained in:
parent
91f54d7439
commit
d3a561692c
4 changed files with 231 additions and 8 deletions
|
|
@ -775,16 +775,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 3,
|
"execution_count": 5,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"text/plain": [
|
"text/plain": [
|
||||||
"'00'"
|
"'0'"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"execution_count": 3,
|
"execution_count": 5,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"output_type": "execute_result"
|
"output_type": "execute_result"
|
||||||
}
|
}
|
||||||
|
|
@ -797,9 +797,20 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": 4,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text/plain": [
|
||||||
|
"'00'"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"execution_count": 4,
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "execute_result"
|
||||||
|
}
|
||||||
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"jmk.gloveClass(600,DC=True)"
|
"jmk.gloveClass(600,DC=True)"
|
||||||
]
|
]
|
||||||
|
|
@ -815,13 +826,14 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 1,
|
"execution_count": null,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"from jepl.jepl_templates import *\n",
|
"from jepl.jepl_templates import *\n",
|
||||||
"#af_label(equipment,working_distance,incident_energy,af_boundary,energy_level,voltage,limited_approach,restricted_approach, glove_class,author=\"Jeff MacKinnon\",warning=\"warning\",project=\"Arc Flash Warning Label\",project_num=\"####\")\n",
|
"#af_label(equipment,working_distance,incident_energy,af_boundary,energy_level,voltage, author=\"Jeff MacKinnon\",warning=\"warning\",project=\"Arc Flash Warning Label\",project_num=\"####\",DC=False,fixedElectrode = True, SI=True,project_year=2015)\n",
|
||||||
"af_label(\"equipnum\",\"3 ft\",3,\"36 in\",\"B\",\"480 Vac\",\"10 ft\",\"1 ft\", \"00\",author=\"Jeff MacKinnon\",warning=\"warning\",project=\"Arc Flash Warning Label\",project_num=\"####\")"
|
"af_label(\"equipnum\",\"3 ft\",3,\"36 in\",\"B\",480,author=\"Jeff MacKinnon\",warning=\"warning\",project=\"Arc Flash Warning Label\",test=True)\n",
|
||||||
|
"\n"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
84
jepl/jepl_templates.py
Normal file
84
jepl/jepl_templates.py
Normal file
|
|
@ -0,0 +1,84 @@
|
||||||
|
'''
|
||||||
|
JMK Engineering Inc. Python Library for design and such.
|
||||||
|
by: Jeff MacKinnon
|
||||||
|
|
||||||
|
email: jeff@jmkengineering.com
|
||||||
|
|
||||||
|
Template Generation
|
||||||
|
|
||||||
|
These functions are used to create labels, reports, etc.
|
||||||
|
|
||||||
|
'''
|
||||||
|
from .jepl_safety import *
|
||||||
|
|
||||||
|
def af_label(equipment,working_distance,incident_energy,af_boundary,energy_level,voltage, author="Jeff MacKinnon",warning="warning",project="Arc Flash Warning Label",project_num="2500",DC=False,fixedElectrode = True, SI=True,project_year=2015,test=False):
|
||||||
|
|
||||||
|
'''
|
||||||
|
This function is for printing a single label with all the information in the function above. Include the units (in, Vac, Vdc, ft, m, mm, etc.) in the values. All values are strings.
|
||||||
|
'''
|
||||||
|
|
||||||
|
from datetime import date
|
||||||
|
date = date.today()
|
||||||
|
revdate = date.strftime("%m/%d/%Y")
|
||||||
|
|
||||||
|
if DC == True:
|
||||||
|
voltage_units = " Vdc"
|
||||||
|
else:
|
||||||
|
voltage_units = " Vac"
|
||||||
|
|
||||||
|
label_voltage = str(voltage) + voltage_units
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
glove_class = gloveClass(voltage,DC=DC)
|
||||||
|
limited_approach = limitedApproach(voltage,fixed=fixedElectrode,DC=DC,unitsSI=SI,year=project_year)
|
||||||
|
restricted_approach = restrictedApproach(voltage,DC=DC,unitsSI=SI,year=project_year)
|
||||||
|
|
||||||
|
|
||||||
|
if warning =="warning":
|
||||||
|
warning_colour = '242,85,31'
|
||||||
|
warning_text = '\warning WARNING'
|
||||||
|
elif warning == "danger":
|
||||||
|
warning_colour = '242,85,31' # This colour needs to change
|
||||||
|
warning_text = '\warning DANGER'
|
||||||
|
else:
|
||||||
|
warning_colour = '255,255,255' # This colour needs to change
|
||||||
|
warning_text = ''
|
||||||
|
|
||||||
|
from jinja2 import Environment, FileSystemLoader
|
||||||
|
|
||||||
|
environment = Environment( block_start_string = '\BLOCK{',
|
||||||
|
block_end_string = '}',
|
||||||
|
variable_start_string = '\VAR((',
|
||||||
|
variable_end_string = '))',
|
||||||
|
comment_start_string = '\#{',
|
||||||
|
comment_end_string = '}',
|
||||||
|
line_comment_prefix = '%#',
|
||||||
|
loader=FileSystemLoader("jepl/templates/")
|
||||||
|
)
|
||||||
|
template = environment.get_template("template-label-ArcFlash.tex")
|
||||||
|
|
||||||
|
if test == True:
|
||||||
|
filename = "test"+str(date) + "-"+project_num+"-label-ArcFlash.tex"
|
||||||
|
else:
|
||||||
|
filename = str(date) + "-"+project_num+"-label-ArcFlash.tex"
|
||||||
|
content = template.render(
|
||||||
|
DATE = revdate,
|
||||||
|
EQUIPMENT = equipment,
|
||||||
|
WORKING_DISTANCE = working_distance,
|
||||||
|
INCIDENT_ENERGY = incident_energy,
|
||||||
|
AF_BOUNDARY = af_boundary,
|
||||||
|
ENERGY_LEVEL = energy_level,
|
||||||
|
VOLTAGE = label_voltage,
|
||||||
|
LIMITED_APPROACH = limited_approach,
|
||||||
|
RESTRICTED_APPROACH = restricted_approach,
|
||||||
|
GLOVE_CLASS = glove_class,
|
||||||
|
AUTHOR = author,
|
||||||
|
TITLE = project,
|
||||||
|
WARNING_COLOUR = warning_colour,
|
||||||
|
WARNING_TEXT = warning_text,
|
||||||
|
|
||||||
|
|
||||||
|
)
|
||||||
|
with open(filename, mode="w", encoding="utf-8") as message:
|
||||||
|
message.write(content)
|
||||||
BIN
jepl/templates/static/logo.png
Normal file
BIN
jepl/templates/static/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
127
jepl/templates/template-label-ArcFlash.tex
Normal file
127
jepl/templates/template-label-ArcFlash.tex
Normal file
|
|
@ -0,0 +1,127 @@
|
||||||
|
|
||||||
|
\documentclass[12pt]{article}
|
||||||
|
\pagestyle{empty}
|
||||||
|
|
||||||
|
%\usepackage[utf8]{inputenc}
|
||||||
|
\usepackage{tikz}
|
||||||
|
\usepackage{fourier}
|
||||||
|
\usepackage{geometry}
|
||||||
|
|
||||||
|
\usepackage{anyfontsize}
|
||||||
|
\usepackage{multicol}
|
||||||
|
|
||||||
|
\usepackage[export]{adjustbox}
|
||||||
|
|
||||||
|
|
||||||
|
\usetikzlibrary{calc}
|
||||||
|
|
||||||
|
\geometry{%
|
||||||
|
paperheight=105mm,
|
||||||
|
paperwidth=160mm,
|
||||||
|
top=2mm,
|
||||||
|
bottom=2mm,
|
||||||
|
right=2mm,
|
||||||
|
left=2mm,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
\usepackage{layout}
|
||||||
|
\setlength{\parindent}{1pt}
|
||||||
|
|
||||||
|
|
||||||
|
\title{\VAR((TITLE))}
|
||||||
|
\date{\VAR((DATE))}
|
||||||
|
\author{\VAR((AUTHOR))}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\begin{document}
|
||||||
|
|
||||||
|
%% Header Warning Banner %%
|
||||||
|
\definecolor{warningcolour}{RGB}{\VAR((WARNING_COLOUR))}
|
||||||
|
|
||||||
|
|
||||||
|
% \thispagestyle{empty}
|
||||||
|
\begin{tikzpicture}[overlay, remember picture]%
|
||||||
|
\node[]
|
||||||
|
at ($(current page.north)+(0cm, -13mm)$) {%
|
||||||
|
\begin{tikzpicture}
|
||||||
|
\node[rectangle,
|
||||||
|
draw = white,
|
||||||
|
text = black,
|
||||||
|
minimum width = \textwidth,
|
||||||
|
minimum height = 23mm,
|
||||||
|
fill = warningcolour] (r) at (0,0)
|
||||||
|
{%
|
||||||
|
\fontfamily{phv}\fontsize{36pt}{40pt}\selectfont \textbf{\VAR((WARNING_TEXT))}% This is the warning text
|
||||||
|
};
|
||||||
|
\end{tikzpicture}
|
||||||
|
};
|
||||||
|
% This is the main message
|
||||||
|
\node[%
|
||||||
|
text width=\textwidth,
|
||||||
|
align=center,
|
||||||
|
]
|
||||||
|
at ($(current page.center) + (0cm,18mm)$) {%
|
||||||
|
\fontfamily{phv}
|
||||||
|
\fontsize{20pt}{100pt}\selectfont
|
||||||
|
\textbf{%
|
||||||
|
Arc Flash and Shock Hazard Present \\
|
||||||
|
Appropriate PPE Required
|
||||||
|
}
|
||||||
|
};
|
||||||
|
% This is the study Results
|
||||||
|
\node[text width=\textwidth, align=center]
|
||||||
|
at ($(current page.center) + (5mm,-7mm)$) {%
|
||||||
|
\begin{multicols}{2}
|
||||||
|
\textbf{ARC FLASH PROTECTION} \\
|
||||||
|
\vspace{3mm}
|
||||||
|
|
||||||
|
\begin{tabular}{ l l }
|
||||||
|
Working Distance & \textbf{\VAR((WORKING_DISTANCE))} \\ % Working Distance
|
||||||
|
Incident Energy & \textbf{\VAR((INCIDENT_ENERGY)) cal/cm$^2$} \\ % Incident Energy Value
|
||||||
|
Arc Flash Hazard Boundary & \textbf{\VAR((AF_BOUNDARY))} \\ % Arc Flash Boundary
|
||||||
|
Energy Level & \textbf{Level \VAR((ENERGY_LEVEL))} \\ % Energy Level
|
||||||
|
\end{tabular}
|
||||||
|
|
||||||
|
\columnbreak
|
||||||
|
|
||||||
|
\textbf{SHOCK PROTECTION}\\
|
||||||
|
\vspace{4mm}
|
||||||
|
|
||||||
|
\begin{tabular}{ l l }
|
||||||
|
Shock Hazard & \textbf{\VAR((VOLTAGE))} \\ % Shock voltage
|
||||||
|
Limited Approach & \textbf{\VAR((LIMITED_APPROACH))} \\ % Limited Approach boundary
|
||||||
|
Restricted Approach & \textbf{\VAR((RESTRICTED_APPROACH))} \\ % Restricted Approach boundard
|
||||||
|
Glove Class & \textbf{\VAR((GLOVE_CLASS))} \\ % Glove Class
|
||||||
|
\end{tabular}
|
||||||
|
|
||||||
|
\end{multicols}
|
||||||
|
};
|
||||||
|
% This is the equipment information
|
||||||
|
\node[text width=0.5\textwidth, align=left]
|
||||||
|
at ($(current page.west) + (45mm,-40mm)$) {%
|
||||||
|
\large
|
||||||
|
Equipment: \textbf{\VAR((EQUIPMENT))} \\
|
||||||
|
|
||||||
|
Date: \textbf{\VAR((DATE))} \\
|
||||||
|
\vspace{2mm}
|
||||||
|
\scriptsize
|
||||||
|
Arc flash analysis by \VAR((AUTHOR))
|
||||||
|
|
||||||
|
};
|
||||||
|
% This is the logo
|
||||||
|
\node[text width=0.5\textwidth, align=right]
|
||||||
|
at ($(current page.east) + (-40mm,-4cm)$) {%
|
||||||
|
\includegraphics[width=70mm,left]{jepl/templates/static/logo.png}
|
||||||
|
};
|
||||||
|
|
||||||
|
\end{tikzpicture}
|
||||||
|
|
||||||
|
|
||||||
|
\newpage
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\end{document}
|
||||||
Loading…
Add table
Reference in a new issue