Added multipage warning labels.
This commit is contained in:
parent
4d5ccd5367
commit
c2569ed58f
4 changed files with 229 additions and 17 deletions
|
|
@ -2,12 +2,12 @@
|
||||||
"cells": [
|
"cells": [
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 1,
|
"execution_count": 20,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"import jepl.jepl as jmk # import the module. If this file is located further up the file tree it may look like \"resources.JEPL.jepl.jepl\"\n",
|
"import jepl.jepl as jmk # import the module. If this file is located further up the file tree it may look like \"resources.JEPL.jepl.jepl\"\n",
|
||||||
"%run jepl/jeplinit.py jepl/ # This is needed to initialize the databases. Again if you are running this from a different location the run command will look like %run jeplinit.py resources/JEPL/jepl/ "
|
"#%run jepl/jeplinit.py jepl/ # This is needed to initialize the databases. Again if you are running this from a different location the run command will look like %run jeplinit.py resources/JEPL/jepl/ "
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -775,18 +775,19 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 17,
|
"execution_count": 1,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"data": {
|
"ename": "NameError",
|
||||||
"text/plain": [
|
"evalue": "name 'jmk' is not defined",
|
||||||
"'0'"
|
"output_type": "error",
|
||||||
]
|
"traceback": [
|
||||||
},
|
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
||||||
"execution_count": 17,
|
"\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)",
|
||||||
"metadata": {},
|
"Input \u001b[1;32mIn [1]\u001b[0m, in \u001b[0;36m<cell line: 3>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;66;03m#def gloveClass(voltage,DC=False)\u001b[39;00m\n\u001b[1;32m----> 3\u001b[0m \u001b[43mjmk\u001b[49m\u001b[38;5;241m.\u001b[39mgloveClass(\u001b[38;5;241m600\u001b[39m)\n",
|
||||||
"output_type": "execute_result"
|
"\u001b[1;31mNameError\u001b[0m: name 'jmk' is not defined"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"source": [
|
"source": [
|
||||||
|
|
@ -826,14 +827,12 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 19,
|
"execution_count": 3,
|
||||||
"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, author=\"Jeff MacKinnon\",warning=\"warning\",project=\"Arc Flash Warning Label\",project_num=\"####\",DC=False,fixedElectrode = True, SI=True,project_year=2015)\n",
|
"af_labels('testresults_labels.csv')"
|
||||||
"af_label(\"equipnum\",\"3 ft\",3,\"36 in\",\"B\",480,author=\"Jeff MacKinnon\",warning=\"warning\",project=\"Arc Flash Warning Label\",test=True)\n",
|
|
||||||
"\n"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,8 @@ def af_label(equipment,working_distance,incident_energy,af_boundary,energy_level
|
||||||
|
|
||||||
from jinja2 import Environment, FileSystemLoader
|
from jinja2 import Environment, FileSystemLoader
|
||||||
|
|
||||||
environment = Environment( block_start_string = '\BLOCK{',
|
environment = Environment(
|
||||||
|
block_start_string = '\BLOCK{',
|
||||||
block_end_string = '}',
|
block_end_string = '}',
|
||||||
variable_start_string = '\VAR((',
|
variable_start_string = '\VAR((',
|
||||||
variable_end_string = '))',
|
variable_end_string = '))',
|
||||||
|
|
@ -56,7 +57,8 @@ def af_label(equipment,working_distance,incident_energy,af_boundary,energy_level
|
||||||
line_comment_prefix = '%#',
|
line_comment_prefix = '%#',
|
||||||
loader=FileSystemLoader("jepl/templates/")
|
loader=FileSystemLoader("jepl/templates/")
|
||||||
)
|
)
|
||||||
template = environment.get_template("template-label-ArcFlash.tex")
|
#template = environment.get_template("template-label-ArcFlash.tex")
|
||||||
|
template = environment.get_template("template-AF_warning_label.tex")
|
||||||
|
|
||||||
if test == True:
|
if test == True:
|
||||||
filename = "test"+str(date) + "-"+project_num+"-label-ArcFlash.tex"
|
filename = "test"+str(date) + "-"+project_num+"-label-ArcFlash.tex"
|
||||||
|
|
@ -82,3 +84,77 @@ def af_label(equipment,working_distance,incident_energy,af_boundary,energy_level
|
||||||
)
|
)
|
||||||
with open(filename, mode="w", encoding="utf-8") as message:
|
with open(filename, mode="w", encoding="utf-8") as message:
|
||||||
message.write(content)
|
message.write(content)
|
||||||
|
|
||||||
|
def af_labels(results_csv,author="JMK Engineering Inc.",warning="warning",project="Arc Flash Warning Label",project_num="2500",DC=False,fixedElectrode = True, SI=True,project_year=2015,test=False):
|
||||||
|
|
||||||
|
from datetime import date
|
||||||
|
date = date.today()
|
||||||
|
revdate = date.strftime("%m/%d/%Y")
|
||||||
|
|
||||||
|
|
||||||
|
if DC == True:
|
||||||
|
voltage_units = " Vdc"
|
||||||
|
else:
|
||||||
|
voltage_units = " Vac"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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 = ''
|
||||||
|
|
||||||
|
label_info = {'date':date,
|
||||||
|
'title':project,
|
||||||
|
'author':author,
|
||||||
|
'voltage_units':voltage_units,
|
||||||
|
'warning_colour':warning_colour,
|
||||||
|
'warning_text':warning_text,
|
||||||
|
'project':project,
|
||||||
|
'project_num':project_num,
|
||||||
|
|
||||||
|
}
|
||||||
|
import pandas as pd
|
||||||
|
results_af = pd.read_csv(results_csv)
|
||||||
|
|
||||||
|
results = results_af.T.to_dict().values()
|
||||||
|
|
||||||
|
# Need to take this information and add it to the label results dataframe above.
|
||||||
|
# This needs to include working distance, which should actually be selectable from the ETAP results
|
||||||
|
# 'working_distance':'18in' # This needs to change maybe I can get it added to the AF results.
|
||||||
|
|
||||||
|
|
||||||
|
# Then when these values are added to the results CSV we can finish the template results thing
|
||||||
|
|
||||||
|
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-label4x6-base.tex")
|
||||||
|
template = environment.get_template("template-AF_warning_label.tex")
|
||||||
|
#template = environment.get_template("testblock.txt")
|
||||||
|
|
||||||
|
if test == True:
|
||||||
|
filename = "test"+str(date) + "-"+project_num+"-label-ArcFlash.tex"
|
||||||
|
else:
|
||||||
|
filename = str(date) + "-"+project_num+"-label-ArcFlash.tex"
|
||||||
|
|
||||||
|
|
||||||
|
context = {"results":results,"project":label_info}
|
||||||
|
content = template.render(context)
|
||||||
|
|
||||||
|
with open(filename, mode="w", encoding="utf-8") as message:
|
||||||
|
message.write(content)
|
||||||
91
jepl/templates/template-AF_warning_label.tex
Normal file
91
jepl/templates/template-AF_warning_label.tex
Normal file
|
|
@ -0,0 +1,91 @@
|
||||||
|
\BLOCK{ extends "template-label4x6-base.tex" }
|
||||||
|
|
||||||
|
\BLOCK{block document}
|
||||||
|
|
||||||
|
\BLOCK{for result in results }
|
||||||
|
%% Header Warning Banner %%
|
||||||
|
\definecolor{warningcolour}{RGB}{\VAR((project.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((project.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((result.working_distance))} \\ % Working Distance - This needs to be added to the results
|
||||||
|
Incident Energy & \textbf{\VAR((result.energy)) cal/cm$^2$} \\ % Incident Energy Value
|
||||||
|
Arc Flash Hazard Boundary & \textbf{\VAR((result.afb))} \\ % Arc Flash Boundary
|
||||||
|
Energy Level & \textbf{\VAR((result.level))} \\ % Energy Level
|
||||||
|
\end{tabular}
|
||||||
|
|
||||||
|
\columnbreak
|
||||||
|
|
||||||
|
\textbf{SHOCK PROTECTION}\\
|
||||||
|
\vspace{4mm}
|
||||||
|
|
||||||
|
\begin{tabular}{ l l }
|
||||||
|
Shock Hazard & \textbf{\VAR((result.voltage))} \\ % Shock voltage
|
||||||
|
Limited Approach & \textbf{\VAR((result.limited_approach))} \\ % Limited Approach boundary
|
||||||
|
Restricted Approach & \textbf{\VAR((result.restricted_approach))} \\ % Restricted Approach boundard
|
||||||
|
Glove Class & \textbf{\VAR((result.gloveclass))} \\ % 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((result.equipment))} \\
|
||||||
|
|
||||||
|
Date: \textbf{\VAR((project.date))} \\
|
||||||
|
\vspace{2mm}
|
||||||
|
\scriptsize
|
||||||
|
Arc flash analysis by \VAR((project.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
|
||||||
|
\BLOCK{ endfor }
|
||||||
|
|
||||||
|
\BLOCK{endblock document}
|
||||||
46
jepl/templates/template-label4x6-base.tex
Normal file
46
jepl/templates/template-label4x6-base.tex
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
|
||||||
|
\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((project.title))}
|
||||||
|
\date{\VAR((project.date))}
|
||||||
|
\author{\VAR((project.author))}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\begin{document}
|
||||||
|
|
||||||
|
\BLOCK{block document}
|
||||||
|
|
||||||
|
\BLOCK{endblock document}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\end{document}
|
||||||
Loading…
Add table
Reference in a new issue