Compare commits

...

5 Commits

7 changed files with 129 additions and 7 deletions

4
.gitignore vendored
View File

@ -3,4 +3,6 @@
*.webm *.webm
*.mkv *.mkv
test_svg test_svg
test_png test_png
draw.sqlite
.env

9
ax.sh Normal file
View File

@ -0,0 +1,9 @@
#!/bin/bash
axicli -f /home/ubuntu/plotter/axidraw_conf_robothouse_a3.py \
--report_time \
--model 2 \
--pen_pos_up 20 \
--pen_pos_down 60 \
--output_file /home/ubuntu/progress.svg \
"${@}"

View File

@ -1,5 +1,35 @@
#!/bin/bash #!/bin/bash
if [ -f ".env" ]; then
source .env
fi
if [[ "${DB_FILE}" != "" ]]; then
FULL_DATABASE=`realpath "${DB_FILE}"`
else
FULL_DATABASE=`realpath "./draw.sqlite"`
fi
db () {
sqlite3 "${FULL_DATABASE}" "${1}"
}
dbSetup () {
cat "./sql/setup.sql" | sqlite3 "${FULL_DATABASE}"
}
hashStr () {
echo -n "${1}" | sha256sum | awk '{print $1}'
}
hashFile () {
sha256sum "${1}" | awk '{print $1}'
}
uuid () {
uuidgen | tr "[:upper:]" "[:lower:]"
}
askContinue () { askContinue () {
echo "${1}" echo "${1}"
echo "Are you ready to continue? (yes/no)" echo "Are you ready to continue? (yes/no)"
@ -10,4 +40,15 @@ askContinue () {
else else
exit 1 exit 1
fi fi
}
axdraw () {
file=$(realpath "${1}")
echo "FILE:${file}"
if [[ "${PEN}" != "" ]]; then
echo "PEN:${PEN}"
fi
echo "START:$(date '+%s')"
ax "${1}"
echo "END:$(date '+%s')"
} }

View File

@ -15,6 +15,8 @@ if [[ "${1}" == "" ]]; then
exit 1 exit 1
fi fi
dbSetup
FRAMES=$(realpath "${1}")/ FRAMES=$(realpath "${1}")/
END=-1 END=-1
@ -48,6 +50,7 @@ for svg in "${FRAMES}"*.svg ; do
i=$((i+1)) i=$((i+1))
continue continue
fi fi
filename=`basename "${svg}"` filename=`basename "${svg}"`
name=`echo "${filename}" | cut -d'.' -f1` name=`echo "${filename}" | cut -d'.' -f1`
num=`echo "${name}" | awk -F'_' '{print $(NF)}'` num=`echo "${name}" | awk -F'_' '{print $(NF)}'`
@ -57,7 +60,7 @@ for svg in "${FRAMES}"*.svg ; do
number=`mktemp`.svg number=`mktemp`.svg
node ./numbers/ -n "${num}" -o "${number}" node ./numbers/ -n "${num}" -o "${number}"
ax "${number}" ax "${number}"
ax "${svg}" axdraw "${svg}" | bash ./log.sh
rm -f "${number}" rm -f "${number}"
bash position.sh reset bash position.sh reset

50
log.sh Normal file
View File

@ -0,0 +1,50 @@
#!/bin/bash
source ./common.sh
loglines="$(cat /dev/stdin)"
id=$(uuid)
file=$(echo "${loglines}" | grep 'FILE:' | awk -F'FILE:' '{print $2}')
starttime=$(echo "${loglines}" | grep 'START:' | awk -F':' '{print $2}')
endtime=$(echo "${loglines}" | grep 'END:' | awk -F':' '{print $2}')
pen=$(echo "${loglines}" | grep 'PEN:' | awk -F':' '{print $2}')
drawn=$(echo "${loglines}" | grep 'Length of path drawn' | awk -F':' '{print $2}' | awk '{print $1}')
moved=$(echo "${loglines}" | grep 'Total distance moved' | awk -F':' '{print $2}' | awk '{print $1}')
hash=$(hashFile "${file}")
info=$(svginfo "${file}")
paths=$(echo "$info" | grep -m 1 'number of paths' | awk -F': ' '{print $2}')
total=$(echo "$info" | grep 'total path length' | awk -F': ' '{print $2}')
ratio=$(echo "$info" | grep 'pen move ratio' | awk -F': ' '{print $2}')
bboxclean=$(echo "$info" | grep 'bbox' | awk -F ')' '{print $1}' | awk -F'(' '{print $2}')
xmin=$(echo "$bboxclean" | awk -F', ' '{print $1}')
xmax=$(echo "$bboxclean" | awk -F', ' '{print $2}')
ymin=$(echo "$bboxclean" | awk -F', ' '{print $3}')
ymax=$(echo "$bboxclean" | awk -F', ' '{print $4}')
if [[ "${pen}" != "" ]]; then
pen="'${pen}'"
else
pen=null
fi
query="INSERT OR IGNORE INTO svg (id, file, drawn, moved, starttime, endtime, pen, hash, paths, total, ratio, xmin, xmax, ymin, ymax) VALUES (\
'$id', \
'$file',\
$drawn,\
$moved,\
$starttime,\
$endtime,\
$pen,\
'$hash',\
$paths,\
$total,\
$ratio,\
$xmin,\
$xmax,\
$ymin,\
$ymax
);"
db "${query}"
echo "${loglines}"

17
sql/setup.sql Normal file
View File

@ -0,0 +1,17 @@
CREATE TABLE IF NOT EXISTS svg (
id TEXT PRIMARY KEY,
file TEXT,
starttime INTEGER,
endtime INTEGER,
drawn REAL,
moved REAL,
paths INTEGER,
total REAL,
ratio REAL,
xmin REAL,
xmax REAL,
ymin REAL,
ymax REAL,
pen TEXT,
hash TEXT
);

View File

@ -28,11 +28,11 @@ mkdir -p "${OUTPUT}"
FRAMERATE=12 FRAMERATE=12
WIDTH=404 WIDTH=404
HEIGHT=374 HEIGHT=374
DOTSIZE=6 DOTSIZE=2
MAXGENERATIONS=50 MAXGENERATIONS=25
MAXPARTICLES=900 MAXPARTICLES=1200
MINDOTSIZE=0.5 MINDOTSIZE=1.5
LINE=0.5 LINE=1.5
FILL=true FILL=true
MODE="stipple" #stipple/tsp MODE="stipple" #stipple/tsp