Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf69c4500d | ||
|
|
c7c6a08748 | ||
|
|
c9c4066331 | ||
|
|
835b973bdc | ||
|
|
bf6a32907c | ||
|
|
2b7885c3f8 | ||
|
|
749af60796 | ||
|
|
87ddcac2fc | ||
|
|
e3383fe4c1 | ||
|
|
292856e1bd | ||
|
|
3dacaaf03a | ||
|
|
6307b765e3 | ||
|
|
eb2561175d | ||
|
|
a30e41f0b4 | ||
|
|
51341f6722 | ||
|
|
fb15751703 | ||
|
|
a0105bcb2f | ||
|
|
103e0796b7 | ||
|
|
363b23d6e3 | ||
|
|
52ad02a08a | ||
|
|
977cf3c383 | ||
|
|
827ea36d72 | ||
|
|
46b0367335 | ||
|
|
596afddfb6 | ||
|
|
68e4fca347 | ||
|
|
256c2dfdbe | ||
|
|
0737ee65bd | ||
|
|
05ac02770b | ||
|
|
25dc81a5d2 | ||
|
|
9e27744a05 | ||
|
|
77df620237 | ||
|
|
8998be66eb | ||
|
|
1180cac147 | ||
|
|
270231a004 | ||
|
|
c2f0f6c7c4 | ||
|
|
c7afae38a8 | ||
|
|
873a825e57 | ||
|
|
dc2318f404 | ||
|
|
699ed1da4d | ||
|
|
d8b95f845c | ||
|
|
014d39c11d | ||
|
|
a544a852f2 | ||
|
|
3311a48e3a | ||
|
|
5ac908afd4 | ||
|
|
12a3e659b1 | ||
|
|
b0780af7fa | ||
|
|
2ec31c7521 | ||
|
|
f2562500a3 | ||
|
|
85a567bdab | ||
|
|
11c415fd17 | ||
|
|
d67ea41032 | ||
|
|
66357ebe7e | ||
|
|
8dbde90a93 | ||
|
|
d2910de121 | ||
|
|
c5be9908c5 | ||
|
|
f7f70108bc | ||
|
|
bd08eadac9 | ||
|
|
a2314a9ab3 | ||
|
|
e1b071c0d8 | ||
|
|
aba8a57fa5 | ||
|
|
5784ab82ef | ||
|
|
636e79672a | ||
|
|
b935e96448 | ||
|
|
56ad5b97b6 | ||
|
|
dcead7361f | ||
|
|
ef314340fa | ||
|
|
a149cdc4f5 | ||
|
|
fc777e69e2 | ||
|
|
2ea1b9df6c | ||
|
|
05e54fa0c6 | ||
|
|
0203e6da31 | ||
|
|
93a852e6ea | ||
|
|
985b0970f1 | ||
|
|
e844d42275 | ||
|
|
a56ddb9ebe | ||
|
|
1957d2bb58 | ||
|
|
e55f11c5b9 | ||
|
|
07133b79e5 | ||
|
|
183a8feed4 | ||
|
|
e3253fce16 | ||
|
|
acd6f729f0 | ||
|
|
ec85cccc75 | ||
|
|
f3f640c24f | ||
|
|
9c2b42caa2 | ||
|
|
a677ffc90e | ||
|
|
254145da22 | ||
|
|
fec51ebc8e | ||
|
|
9d66aea843 | ||
|
|
50895a662a | ||
|
|
048ad78778 | ||
|
|
e9beffc799 | ||
|
|
fe9dd5ef28 | ||
|
|
468e4b6d55 | ||
|
|
b48ac505fd | ||
|
|
a0a6f958d9 | ||
|
|
16d156b530 | ||
|
|
420226b6c0 | ||
|
|
da8e72b0d6 | ||
|
|
ef13cbecfd | ||
|
|
947de33b5a | ||
|
|
4b9cd490ab | ||
|
|
784688a9da | ||
|
|
71bb760ce5 | ||
|
|
98a46e8caa | ||
|
|
5910bba30e | ||
|
|
19ba3b1f99 | ||
|
|
23bc6b8df7 | ||
|
|
69bea0f5b0 | ||
|
|
3c53394f4b | ||
|
|
8741053dfc | ||
|
|
8752f70ff3 | ||
|
|
2b66df39b6 | ||
|
|
17bb0e693d | ||
|
|
94e5b5fdaf | ||
|
|
497ec5c6b2 | ||
|
|
eaeae8d5ec | ||
|
|
3a05a2653b | ||
|
|
0ca63017c7 | ||
|
|
ea3416693c | ||
|
|
dcdbd3652a | ||
|
|
c35b7a66b0 | ||
|
|
6dc56af3fa | ||
|
|
af297c2031 | ||
|
|
024cf81238 | ||
|
|
5ec02e2f18 | ||
|
|
9709b97adf | ||
|
|
3be039b1a9 | ||
|
|
21bd664edf | ||
|
|
a31c422537 | ||
|
|
e5299d96ad | ||
|
|
5675f32a19 | ||
|
|
9d5a500b25 | ||
|
|
4bab1975c8 | ||
|
|
eae4153158 | ||
|
|
c207578f14 | ||
|
|
16801ad3e1 | ||
|
|
a92aa96623 | ||
|
|
ccf0ab3b51 | ||
|
|
7259c1c2ef | ||
|
|
d66675c672 | ||
|
|
38483b0c67 | ||
|
|
25cfed949d | ||
|
|
eacfcab187 | ||
|
|
9e014eba1f | ||
|
|
9692b709aa | ||
|
|
5acb04c180 | ||
|
|
ff96e2e4d6 | ||
|
|
19de4053fe | ||
|
|
2e96fa9e1e | ||
|
|
87234bda05 | ||
|
|
d0ff6d1579 | ||
|
|
105b68c807 | ||
|
|
97a6d8a15e | ||
|
|
26fa3df4aa | ||
|
|
9a336336d7 | ||
|
|
047d7f5046 | ||
|
|
4fc561dab5 | ||
|
|
785ac07de9 | ||
|
|
41c6978880 | ||
|
|
f7ebc4ec11 | ||
|
|
c06e8f47f0 | ||
|
|
dceb5dccd3 | ||
|
|
7a50138ae3 | ||
|
|
ca6364e5d4 | ||
|
|
43cead8249 | ||
|
|
62667de4a8 | ||
|
|
8492944fb5 | ||
|
|
f8955c0d1b | ||
|
|
0aac7813e4 | ||
|
|
44cc9e7db8 | ||
|
|
644329c0b8 | ||
|
|
ff97fba0f0 | ||
|
|
ce67e28f96 | ||
|
|
f7433de2bf | ||
|
|
bbd46fd3a6 | ||
|
|
077486c838 | ||
|
|
baedab5931 | ||
|
|
e149689249 | ||
|
|
b79d5e670a | ||
|
|
c23cb378cd | ||
|
|
a185685f0c | ||
|
|
b4699825d6 | ||
|
|
118a4f7097 | ||
|
|
7acb0657a7 | ||
|
|
021ce44673 | ||
|
|
9a7733c9a3 | ||
|
|
7150f5b536 | ||
|
|
753b9e8d7a | ||
|
|
6e62ecc8c1 | ||
|
|
0ab5369635 | ||
|
|
a274b769bd | ||
|
|
6e4d35777b | ||
|
|
776e6aa498 | ||
|
|
b7a21dd322 | ||
|
|
71d73c6562 | ||
|
|
6732710d6f | ||
|
|
90618723d4 | ||
|
|
084ca956fb | ||
|
|
44109f9d8f | ||
|
|
606efd3da1 | ||
|
|
2d76aa029a | ||
|
|
1acbbbaf6c | ||
|
|
8864884c67 | ||
|
|
a332b71463 | ||
|
|
10d76ae7a4 | ||
|
|
cd973adedf | ||
|
|
af94b770f9 | ||
|
|
62a51bb061 | ||
|
|
01ab61b8b1 | ||
|
|
c55d8c0bdf | ||
|
|
7336ed6eff | ||
|
|
60ca95e9b2 | ||
|
|
89b43a42c4 | ||
|
|
197be925b8 | ||
|
|
d49cd209e1 | ||
|
|
d60ab8cd9e | ||
|
|
7840ff0d7c | ||
|
|
a7144e57e1 | ||
|
|
50eac58493 | ||
|
|
4ef58b56e6 | ||
|
|
c1f0c76d17 | ||
|
|
079116fdf8 | ||
|
|
45e6385963 | ||
|
|
3ca0458d65 | ||
|
|
d5edec2cd0 | ||
|
|
ce9c9bea6a | ||
|
|
36c8f25fd1 | ||
|
|
b3050f1058 | ||
|
|
a04a61f61b | ||
|
|
58204248bb | ||
|
|
a47740ae28 | ||
|
|
604c2a0bdd | ||
|
|
1c19bb4dfc | ||
|
|
858d87a732 | ||
|
|
ea28900913 | ||
|
|
192e606fea | ||
|
|
8e4152e567 | ||
|
|
9e9da5355c | ||
|
|
26e9a17c6b | ||
|
|
fa43600cd9 | ||
|
|
3aca55205e | ||
|
|
3a0aac3c36 | ||
|
|
fe34bdc656 | ||
|
|
e69c1e8e93 | ||
|
|
1c0721f179 | ||
|
|
6f37968670 | ||
|
|
d1c34a9c88 | ||
|
|
65263a8b74 | ||
|
|
5cd6ab9335 | ||
|
|
56b1705df4 | ||
|
|
08e4c05129 | ||
|
|
b5b0ea5980 | ||
|
|
803e17f3a3 | ||
|
|
75017d7ac6 | ||
|
|
80486d644d | ||
|
|
1bdc167f7a | ||
|
|
3f2fdb0b14 | ||
|
|
ac186f89f1 | ||
|
|
fdccfd166f | ||
|
|
272a71f3d5 | ||
|
|
3621879d38 | ||
|
|
4661990cfe | ||
|
|
7db63b10e8 | ||
|
|
428ea89f62 | ||
|
|
60e0ed911e | ||
|
|
e1366ef90f | ||
|
|
85c170712a | ||
|
|
33bf487a1c | ||
|
|
227810db75 | ||
|
|
48d6a27fad | ||
|
|
6171c76199 | ||
|
|
45c1958d83 | ||
|
|
e51d9439c5 | ||
|
|
a48b5deb29 | ||
|
|
212f40cd1a | ||
|
|
18952c57ff | ||
|
|
4296b49570 | ||
|
|
95f084fb36 | ||
|
|
0b237a2469 | ||
|
|
8c34a4fd0a | ||
|
|
f970594c28 | ||
|
|
02c8a1703a | ||
|
|
590d2f2661 | ||
|
|
425f6f7c0b | ||
|
|
c229dc1548 | ||
|
|
e4cc84b771 | ||
|
|
9b3569be50 | ||
|
|
a8e9c5aaf2 | ||
|
|
5ffcd78f27 | ||
|
|
de9dd77b50 | ||
|
|
661302f698 | ||
|
|
854387b2d0 | ||
|
|
7a305b5a5c | ||
|
|
9f463707ee | ||
|
|
e1bcbae975 | ||
|
|
e77efde503 | ||
|
|
4583128c02 | ||
|
|
35b1232b0a | ||
|
|
bc8fe527f7 | ||
|
|
2943343003 | ||
|
|
4e061ef385 | ||
|
|
571cf9c5d9 | ||
|
|
22bde81712 | ||
|
|
a9736b96c0 | ||
|
|
0adbef9696 | ||
|
|
53e52c841b | ||
|
|
b78bb9e970 | ||
|
|
d6959f64c3 | ||
|
|
c5dbc71db3 | ||
|
|
fbd9440711 | ||
|
|
a439dc4cd8 | ||
|
|
fe3a47f2d5 | ||
|
|
9509c8027b | ||
|
|
519429cebb | ||
|
|
4aee779385 | ||
|
|
7903119cb4 | ||
|
|
ef1f96f382 | ||
|
|
af9a6a8a6e | ||
|
|
51c77be7a2 | ||
|
|
f98563cbe9 | ||
|
|
dffa00dc5e | ||
|
|
6c5b32d92b | ||
|
|
7d5c55fc95 | ||
|
|
017654852d | ||
|
|
9e2e616e1b | ||
|
|
0d5d28e4a6 | ||
|
|
90e50db189 | ||
|
|
e9a7cad202 | ||
|
|
60cf0b1099 | ||
|
|
aefb72f7cc | ||
|
|
4d434d36be | ||
|
|
f69abdcc14 | ||
|
|
ee36c31637 | ||
|
|
e0a064a0fa | ||
|
|
568fcbf547 | ||
|
|
7028bbfbfd | ||
|
|
c552e9e9be | ||
|
|
f8e8914f7d | ||
|
|
f195af017e | ||
|
|
6474f25253 | ||
|
|
6d2851e742 | ||
|
|
11fb18f598 | ||
|
|
c026d7d248 | ||
|
|
e0b33799d5 | ||
|
|
17d3d9deb7 | ||
|
|
02212bde21 | ||
|
|
86c6cda79a | ||
|
|
488eb1fac3 | ||
|
|
3eab5503f1 | ||
|
|
61f84302f3 | ||
|
|
5dc0333580 | ||
|
|
f2092ee89c | ||
|
|
d4e7c2e1b1 | ||
|
|
9d69951faa | ||
|
|
2d68b6e589 | ||
|
|
b4af85f405 | ||
|
|
e9ca09da87 | ||
|
|
d770c20b5a | ||
|
|
1ef9c617b3 | ||
|
|
48dc27e106 | ||
|
|
8aab0ee318 | ||
|
|
f9d1086062 | ||
|
|
5e8a04e54d | ||
|
|
32a38af4f7 | ||
|
|
8c8059db30 | ||
|
|
be99c59725 | ||
|
|
f6e2a59008 | ||
|
|
fa586426fa | ||
|
|
60a1bf0d43 | ||
|
|
f7f7d5c4f0 | ||
|
|
85fc2b2666 | ||
|
|
65624ed77e | ||
|
|
6a3241fa0b | ||
|
|
ff22ab0026 | ||
|
|
907f5051e1 | ||
|
|
76a9e94aed | ||
|
|
772ebd198a | ||
|
|
de7808d42b | ||
|
|
55b24c6a45 | ||
|
|
603f667f93 | ||
|
|
18162cf110 | ||
|
|
f693f26ffc | ||
|
|
4cc1dc405f | ||
|
|
12a4cbef46 | ||
|
|
f9a9a405cd | ||
|
|
285f464b43 | ||
|
|
585bfba850 | ||
|
|
fa564c6029 | ||
|
|
fd632fc63b | ||
|
|
d8f1387703 | ||
|
|
522eb40808 | ||
|
|
587053b26c | ||
|
|
fa8d4eff0f | ||
|
|
666a9ef0fa | ||
|
|
014ea3eadc | ||
|
|
f7e1b39af9 | ||
|
|
33005ea243 | ||
|
|
651a9d30ce | ||
|
|
0bd6005cb9 | ||
|
|
3ee745d79c | ||
|
|
a48f194350 | ||
|
|
ec508f5224 | ||
|
|
78f0ec94ea | ||
|
|
44f9e756da | ||
|
|
1b9523f700 | ||
|
|
3d992d56cd | ||
|
|
72f7b4627f | ||
|
|
ee31808522 | ||
|
|
5c1f165079 | ||
|
|
95755ba515 | ||
|
|
7414c921f3 | ||
|
|
791e4e26a9 | ||
|
|
4d61963894 | ||
|
|
d1d6e8e11c | ||
|
|
778f9039fb | ||
|
|
4904c184f7 | ||
|
|
5622a9c565 | ||
|
|
2e5069d5a1 | ||
|
|
4cd692e061 | ||
|
|
cbde819e07 | ||
|
|
3d6cb623f0 | ||
|
|
47cfcd7b12 | ||
|
|
244128c7ed | ||
|
|
9c9b98dde4 | ||
|
|
36d1522f01 | ||
|
|
536e17eac4 | ||
|
|
7bba1dc944 | ||
|
|
59c859fb17 | ||
|
|
887ec45b6b | ||
|
|
faa0521428 | ||
|
|
8886b20c01 | ||
|
|
4810aec10d | ||
|
|
deb1979ea9 | ||
|
|
4739c71ee0 | ||
|
|
216a88c00c | ||
|
|
030ffe6dce | ||
|
|
da19ad7943 | ||
|
|
e7088ef06c | ||
|
|
92c7f886df | ||
|
|
59727875db | ||
|
|
98063422de | ||
|
|
4ce4786a58 | ||
|
|
3eb9714e68 | ||
|
|
ee64dc38f6 | ||
|
|
6146c7e450 | ||
|
|
deb38f8455 | ||
|
|
73f0b9dabd | ||
|
|
9ab4fa608a | ||
|
|
bf9d5efe43 | ||
|
|
7b56b36564 | ||
|
|
6e107e6368 | ||
|
|
1a7a468eb6 | ||
|
|
13e6070dd9 | ||
|
|
8cc8e45afd | ||
|
|
e373cde4f7 | ||
|
|
072079df05 | ||
|
|
22614f09a0 | ||
|
|
c858c8f75b | ||
|
|
eb80aaf96d | ||
|
|
ba7d0a60e4 | ||
|
|
b266dc24d7 | ||
|
|
619fe9a0e7 | ||
|
|
10f1917589 | ||
|
|
50cf776e70 | ||
|
|
64dacc7c70 | ||
|
|
f7c75442e7 | ||
|
|
293611287e | ||
|
|
6a2a1da5f9 | ||
|
|
7ebbf5911c | ||
|
|
254c3814d5 | ||
|
|
44c1920d9b | ||
|
|
109372d10b | ||
|
|
94847b846b | ||
|
|
3746332eb5 | ||
|
|
54b01d30da | ||
|
|
0509eb3f0a | ||
|
|
d7e37cf658 | ||
|
|
b81a4b6d5e | ||
|
|
b3b11174be | ||
|
|
bdade99837 | ||
|
|
29be139803 | ||
|
|
ca8779676c | ||
|
|
ee03d62997 | ||
|
|
e068012cfb | ||
|
|
8fbb30437c | ||
|
|
9396ed765c | ||
|
|
d7f2075b1d | ||
|
|
e5ac94a16f | ||
|
|
2be05d4f9a | ||
|
|
f3ee2d2bfd | ||
|
|
f580acaf70 | ||
|
|
d5e2bf546e | ||
|
|
27322a971f | ||
|
|
8b5d6c9367 | ||
|
|
f09d44d8a0 | ||
|
|
9b031ff9d3 | ||
|
|
de59e8aa56 | ||
|
|
850aa5b797 | ||
|
|
9107fd839b | ||
|
|
89cae22b91 | ||
|
|
82ee48b166 | ||
|
|
17f3c5777e | ||
|
|
2cb787f816 | ||
|
|
feba135cac | ||
|
|
45c9e75e4e | ||
|
|
586a7a85e3 | ||
|
|
f844bd99c7 | ||
|
|
0747336c0f | ||
|
|
ace102e1c1 | ||
|
|
b976461c29 | ||
|
|
ad7243844e | ||
|
|
4a6a458cdd | ||
|
|
197d46b511 | ||
|
|
26f7d6e517 | ||
|
|
cf25d3d7be | ||
|
|
036e0af960 | ||
|
|
b7b2e99ab1 | ||
|
|
b115b6f66c | ||
|
|
592f3dce9a | ||
|
|
bcef0dd2c5 | ||
|
|
3f86272913 | ||
|
|
322834b762 | ||
|
|
04ddf30167 | ||
|
|
1935cc4841 | ||
|
|
bd96571d8a | ||
|
|
aa253bf53e | ||
|
|
b8a59097c2 | ||
|
|
a630b74fa8 | ||
|
|
3f7b222b92 | ||
|
|
f1575f75c7 | ||
|
|
0966b231e8 | ||
|
|
00e1a1962b | ||
|
|
c5c382ade6 | ||
|
|
858873dfa0 | ||
|
|
7231acc236 | ||
|
|
adea84e123 | ||
|
|
565757580b | ||
|
|
620d7de02f | ||
|
|
bba625a68f | ||
|
|
b282a18f6b | ||
|
|
417487e195 | ||
|
|
fba48b1d90 | ||
|
|
78f62847a3 | ||
|
|
3bfaa33c58 | ||
|
|
d0cb119bb0 | ||
|
|
3fc6b1e8cf | ||
|
|
ae06af9bc5 | ||
|
|
260a378e8c | ||
|
|
94e052af83 | ||
|
|
d56ab9b79b | ||
|
|
ad556e7413 | ||
|
|
b9f49a83e0 | ||
|
|
ebec2c95c0 | ||
|
|
d62627c8a5 | ||
|
|
96d2c7fad9 | ||
|
|
3aac75f5b5 | ||
|
|
908d39ad39 | ||
|
|
084ffb0dc1 | ||
|
|
cec2bdb805 | ||
|
|
a0374cb4ea | ||
|
|
538338abfe | ||
|
|
097e398efc | ||
|
|
0fd9b3354a | ||
|
|
765b941472 | ||
|
|
64084bb628 | ||
|
|
df269eb4f7 | ||
|
|
722b03dca8 | ||
|
|
3ddfc93c1b | ||
|
|
5eb70fa57d | ||
|
|
eccc9d6fbd | ||
|
|
049ed723a7 | ||
|
|
b6cdc5803b | ||
|
|
792299537d | ||
|
|
7b01e72a9b | ||
|
|
755549a745 | ||
|
|
1c39555255 | ||
|
|
ff5aba9a51 | ||
|
|
467d012bce | ||
|
|
09bed4e74f | ||
|
|
7a8e71b837 | ||
|
|
90336277a7 | ||
|
|
2b856e4508 | ||
|
|
ac75ee9831 | ||
|
|
0b662b7211 | ||
|
|
9f7fc73441 | ||
|
|
677d33e448 | ||
|
|
1dd0aba8f5 | ||
|
|
1b4a7c7896 | ||
|
|
5b8126ae17 | ||
|
|
a1350c9344 | ||
|
|
84012d1232 | ||
|
|
0199599880 | ||
|
|
2f3c3c0c20 | ||
|
|
e690053fd4 | ||
|
|
ae3e474c92 | ||
|
|
297d101f5f | ||
|
|
4d2213544e | ||
|
|
895d077d85 | ||
|
|
35b010b059 | ||
|
|
204128e1ca | ||
|
|
fdfa433243 | ||
|
|
aa69d181bf | ||
|
|
e9f218208d | ||
|
|
8ca3baee04 | ||
|
|
3c68353c57 | ||
|
|
fe37ab3cd8 | ||
|
|
f2b0bfb7dc | ||
|
|
f7f8c09a77 | ||
|
|
37c949e83b | ||
|
|
b35258fad6 | ||
|
|
1a6030c737 | ||
|
|
9008a2fb7f | ||
|
|
47f8ab24d9 | ||
|
|
4b41a47f93 | ||
|
|
5d69ee8abc | ||
|
|
edd801aa7b | ||
|
|
ef8787acf9 | ||
|
|
29a9ee40d5 | ||
|
|
4094d28c07 | ||
|
|
3b56cdaaa3 | ||
|
|
079806f11c | ||
|
|
69052d7670 | ||
|
|
4581722bbe | ||
|
|
2afd715f77 | ||
|
|
8d78104be8 | ||
|
|
076c6764a0 | ||
|
|
8ff48ed88d | ||
|
|
00501f0913 | ||
|
|
4b05f125a0 | ||
|
|
df05a80201 | ||
|
|
6b2912b0e2 | ||
|
|
4ea2345eda | ||
|
|
a7477e0184 | ||
|
|
6492ab66b0 | ||
|
|
78972b1d40 | ||
|
|
51ae782f02 | ||
|
|
a87541c354 | ||
|
|
4fbb8f1164 | ||
|
|
32b2c1e2e7 | ||
|
|
242e552f4d | ||
|
|
d7e6d51cc2 | ||
|
|
708c12ddbe | ||
|
|
21d16c8ba0 | ||
|
|
51b0df5c1f | ||
|
|
f07305ae4f | ||
|
|
b352078917 | ||
|
|
79f379a868 | ||
|
|
520c856c57 | ||
|
|
7a4bb8b94e | ||
|
|
4b7300c2e8 | ||
|
|
a7b7f26da5 | ||
|
|
26ebfe3e1f | ||
|
|
8212f28b90 | ||
|
|
2421824535 | ||
|
|
8e500b78aa | ||
|
|
70b2325de0 | ||
|
|
58cbad1828 | ||
|
|
aef0322617 | ||
|
|
d4bb75a2ee | ||
|
|
43cd85b8e4 | ||
|
|
f574267746 | ||
|
|
b2d715f041 | ||
|
|
2831ab0727 | ||
|
|
1f3160571c | ||
|
|
4c1fc14ac5 | ||
|
|
6d703d236a | ||
|
|
de635ae25f | ||
|
|
8dff6d6750 | ||
|
|
1e1e72c9c2 | ||
|
|
f51f4ad5cd | ||
|
|
711d18d9ad | ||
|
|
3cadbbeb85 | ||
|
|
d7fe15d635 | ||
|
|
d6b172c744 | ||
|
|
40650f1bde | ||
|
|
87edcc4966 | ||
|
|
09fa9bc28d | ||
|
|
280d8e8405 | ||
|
|
0eeca11838 | ||
|
|
281ad0f046 |
No files matched your search
@@ -0,0 +1 @@
|
||||
src/octoprint/_version.py export-subst
|
||||
@@ -4,9 +4,21 @@
|
||||
*.pyc
|
||||
*.zip
|
||||
*.exe
|
||||
*.swp
|
||||
darwin-Cura-*
|
||||
win32-Cura-*
|
||||
linux-Cura-*
|
||||
*.iml
|
||||
Printrun
|
||||
=======
|
||||
.idea
|
||||
.DS_Store
|
||||
Cura/current_profile.ini
|
||||
Cura/preferences.ini
|
||||
build
|
||||
dist
|
||||
pypy
|
||||
OctoPrint.egg-info
|
||||
*.orig
|
||||
|
||||
*.codekit
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
|
||||
language: python
|
||||
python:
|
||||
- "2.7"
|
||||
install:
|
||||
- pip install -r requirements.txt
|
||||
script:
|
||||
- nosetests
|
||||
@@ -0,0 +1,8 @@
|
||||
[main]
|
||||
host = https://www.transifex.com
|
||||
|
||||
[octoprint.messages]
|
||||
file_filter = src/octoprint/translations/<lang>/LC_MESSAGES/messages.po
|
||||
source_file = src/octoprint/translations/messages.pot
|
||||
source_lang = en
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
# Configuration file for the versioneer lookup, manually mapping tags based on branches
|
||||
#
|
||||
# Format is
|
||||
#
|
||||
# <branch-regex> <tag> <reference commit>
|
||||
#
|
||||
# The file is processed from top to bottom, the first matching line wins. If <tag> or <reference commit> are left out,
|
||||
# the lookup table does not apply to the matched branches
|
||||
|
||||
# master and staging shall not use the lookup table
|
||||
master
|
||||
staging
|
||||
|
||||
# fix/ branches are fixes for master, so we don't handle those either
|
||||
fix/.*
|
||||
|
||||
# every other branch is a development branch and thus gets resolved to 1.2.0-dev for now
|
||||
.* 1.2.0-dev 50cf776e70b9
|
||||
@@ -0,0 +1,213 @@
|
||||
# OctoPrint Changelog
|
||||
|
||||
## 1.2.0 (Unreleased)
|
||||
|
||||
### New Features
|
||||
|
||||
* Added internationalization of UI. Translations of OctoPrint are being crowd sourced via [Transifex](https://www.transifex.com/projects/p/octoprint/).
|
||||
The following translations are already available with more in the works:
|
||||
- Dutch (nl)
|
||||
- German (de)
|
||||
- French (fr)
|
||||
- Hebrew (he)
|
||||
- Norwegian (no)
|
||||
- Romanian (ro)
|
||||
* New file list: Pagination is gone, no more (mobile incompatible) pop overs, instead scrollable and with instant
|
||||
search
|
||||
* You can now define a folder (default: `~/.octoprint/watched`) to be watched for newly added GCODE (or -- if slicing
|
||||
support is enabled -- STL) files to automatically add.
|
||||
* OctoPrint now has a [plugin system](http://docs.octoprint.org/en/devel/plugins/index.html) which allows extending its
|
||||
core functionality.
|
||||
* New type of API key: [App Session Keys](http://docs.octoprint.org/en/devel/api/apps.html) for trusted applications
|
||||
* Printer Profiles: Printer properties like print volume, extruder offsets etc are now managed via Printer Profiles. A
|
||||
connection to a printer will always have a printer profile associated.
|
||||
* OctoPrint now supports `action:...` commands received via debug messages (`// action:...`) from the printer. Currently supported are
|
||||
- `action:pause`: Pauses the current job in OctoPrint
|
||||
- `action:resume`: Resumes the current job in OctoPrint
|
||||
- `action:disconnect`: Disconnects OctoPrint from the printer
|
||||
|
||||
### Improvements
|
||||
|
||||
* Logging is now configurable via config file
|
||||
* Added last print time to additional GCODE file information
|
||||
* Better error handling for capture issues during timelapse creation & more robust handling of missing images during
|
||||
timelapse creation
|
||||
* Start counting the layers at 1 instead of 0 in the GCODE viewer
|
||||
* Upgraded [Font Awesome](https://fortawesome.github.io/Font-Awesome/) to version 3.2.1
|
||||
* Better error reporting for timelapse rendering and system commands
|
||||
* Custom control can now be defined so that they show a Confirm dialog with configurable text before executing
|
||||
([#532](https://github.com/foosel/OctoPrint/issues/532) and [#590](https://github.com/foosel/OctoPrint/pull/590))
|
||||
* Slicing has been greatly improved:
|
||||
* It now allows for a definition of slicing profiles to use for slicing plus overrides which can be defined per slicing
|
||||
job (defining overrides is not yet part of the UI but it's on the roadmap).
|
||||
* A new slicing dialog has been added which allows (re-)slicing uploaded STL files (which are now displayed in the file list
|
||||
as well). This dialog also allows specifying which action to take after slicing has been completed (none, selecting the
|
||||
sliced GCODE for printing or starting to print it directly)
|
||||
* Slicers themselves are integrated into the system via ``SlicingPlugins``.
|
||||
* The [Cura integration](https://github.com/daid/Cura) has changed in such a way that OctoPrint now calls the
|
||||
[CuraEngine](https://github.com/Ultimaker/CuraEngine) directly instead of depending on the full Cura installation. See
|
||||
[the wiki](https://github.com/foosel/OctoPrint/wiki/Plugin:-Cura) for instructions on how to change your setup to
|
||||
accommodate the new integration.
|
||||
* The "Slicing done" notification is now colored green ([#558](https://github.com/foosel/OctoPrint/issues/558)).
|
||||
* The slicing API allows positioning the model to slice on the print bed (Note: this is not yet available in the UI).
|
||||
* File management now supports STL files as first class citizens (including UI adjustments to allow management of
|
||||
uploaded STL files including removal and reslicing) and also allows folders (not yet supported by UI)
|
||||
* Also interpret lines starting with "!!" as errors
|
||||
* Added deletion of pyc files to the `python setup.py clean` command
|
||||
* Settings now show a QRCode for the API Key ([#637](https://github.com/foosel/OctoPrint/pull/637))
|
||||
* Username in login dialog is not automatically capitalized on mobile devices anymore ([#639](https://github.com/foosel/OctoPrint/pull/639))
|
||||
* "Slicing Done" and "Streaming Done" notifications now have a green background ([#558](https://github.com/foosel/OctoPrint/issues/558))
|
||||
* Files that are currently in use, be it for slicing, printing or whatever, are now tracked and can not be deleted as
|
||||
long as they are in use
|
||||
* Settings in UI get refreshed when opening settings dialog
|
||||
* New event "SettingsUpdated"
|
||||
* "Print time left" is now not displayed until it becomes somewhat stable. Display in web interface now also happens
|
||||
in a fuzzy way instead of the format hh:mm:ss, to not suggest a high accuracy anymore where the can't be one. Additionally
|
||||
OctoPrint will use data from prior prints to enhance the initial print time estimation.
|
||||
* Added handler for uncaught exceptions to make sure those get logged, should make the logs even more useful for analysing
|
||||
bug reports
|
||||
* The server now tracks the modification date of the configuration file and reloads it prior to saving the config if
|
||||
it has been changed during runtime by external editing, hence no config settings added manually while the server
|
||||
was running should be overwritten anymore.
|
||||
* Automatically hard-reload the UI if upon reconnecting to the server a new version is detected.
|
||||
* Better handling of errors on the websocket - no more logging of the full stack trace to the log, only a warning
|
||||
message for now.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* [#435](https://github.com/foosel/OctoPrint/issues/435) - Always interpret negative duration (e.g. for print time left)
|
||||
as 0
|
||||
* [#633](https://github.com/foosel/OctoPrint/issues/633) - Correctly interpret temperature lines from multi extruder
|
||||
setups under Smoothieware
|
||||
* [#556](https://github.com/foosel/OctoPrint/issues/556) - Allow login of the same user from multiple browsers without
|
||||
side effects
|
||||
* [#680](https://github.com/foosel/OctoPrint/issues/680) - Don't accidentally include a newline from the MIME headers
|
||||
in the parsed multipart data from file uploads
|
||||
* Various fixes of bugs in newly introduced features and improvements:
|
||||
* [#625](https://github.com/foosel/OctoPrint/pull/625) - Newly added GCODE files were not being added to the analysis
|
||||
queue
|
||||
* [#664](https://github.com/foosel/OctoPrint/issues/664) - Fixed jog controls again
|
||||
* [#677](https://github.com/foosel/OctoPrint/issues/677) - Fixed extruder offsets not being properly editable in
|
||||
printer profiles
|
||||
* [#683](https://github.com/foosel/OctoPrint/issues/683) - Fixed heated bed option not being properly displayed in
|
||||
printer profiles
|
||||
* Various fixes without tickets:
|
||||
* GCODE viewer now doesn't stumble over completely extrusionless GCODE files
|
||||
* Do not deliver the API key on settings API unless user has admin rights
|
||||
* Don't hiccup on slic3r filament_diameter comments in GCODE generated for multi extruder setups
|
||||
|
||||
## 1.1.2 (Unreleased)
|
||||
|
||||
### Improvements
|
||||
|
||||
* Added deletion of `*.pyc` files to `python setup.py clean` command, should help tremendously when switching branches (backported
|
||||
from [9e014eb](https://github.com/foosel/OctoPrint/commit/9e014eba1feffde11ed0601d9c911b8cac9f3fb0))
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* [#634](https://github.com/foosel/OctoPrint/pull/634) - Fixed missing `branch` fields in version dicts generated
|
||||
by versioneer
|
||||
* [IRC] - Don't hiccup on slic3r filament_diameter comments generated for multi extruder setups
|
||||
* [ML] - Fixed relative URL to sockjs endpoint, wasn't yet using the proper base url
|
||||
* [unreported] & [#698](https://github.com/foosel/OctoPrint/issues/698) - Generated URLs now take X-Forwarded-Host header
|
||||
sent by proxies into account for included host and port, also fixed [#698](https://github.com/foosel/OctoPrint/issues/698)
|
||||
introduced by this
|
||||
* Small fixes for timelapse creation:
|
||||
- [#344](https://github.com/foosel/OctoPrint/issues/344) - Made timelapses capable of coping with missing captures in between by decrementing the image counter again if there
|
||||
was an error fetching the latest image from the snapshot URL (backport of [1a7a468](https://github.com/foosel/OctoPrint/commit/1a7a468eb65fdf2a13b4c7a7723280e822c9c34b)
|
||||
and [bf9d5ef](https://github.com/foosel/OctoPrint/commit/bf9d5efe43a1e57aacd8512125082ddca06b4efc))
|
||||
- [#693](https://github.com/foosel/OctoPrint/issues/693) - Try not to capture an image if image counter is still unset
|
||||
- [unreported] Synchronize image counter decrementing as well as incrementing to prevent rare race conditions when generating the
|
||||
image file names
|
||||
|
||||
## 1.1.1 (2014-10-27)
|
||||
|
||||
### Improvements
|
||||
|
||||
* The API is now enabled by default and the API key -- if not yet set -- will be automatically generated on first
|
||||
server start and written back into ``config.yaml``
|
||||
* Event subscriptions are now enabled by default (it was an accident that they weren't)
|
||||
* Generate the key used for session hashing individually for each server instance
|
||||
* Generate the salt used for hashing user passwords individually for each server instance
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* [#580](https://github.com/foosel/OctoPrint/issues/580) - Properly unset job data when instructed so by callers
|
||||
* [#604](https://github.com/foosel/OctoPrint/issues/604) - Properly initialize settings basedir on server startup
|
||||
* [IRC] Also allow downloading .g files via Tornado
|
||||
|
||||
([Commits](https://github.com/foosel/OctoPrint/compare/1.1.0...1.1.1))
|
||||
|
||||
## 1.1.0 (2014-09-03)
|
||||
|
||||
### New Features
|
||||
|
||||
* New REST API, including User API Keys additionally to the global API key. Please note that **this will break existing
|
||||
API clients** as it replaces the old API (same endpoint). You can find the documentation of the new API at
|
||||
[docs.octoprint.org](http://docs.octoprint.org/en/1.1.0/api/index.html).
|
||||
* New Event structure allows more flexibility regarding payload data, configuration files will be migrated automatically.
|
||||
You can find the documentation of the new event format and its usage at [docs.octoprint.org](http://docs.octoprint.org/en/1.1.0/events/index.html).
|
||||
* Support for multi extruder setups. With this OctoPrint now in theory supports an unlimited amount of extruders, however
|
||||
for now it's artificially limited to 9.
|
||||
* Log files can be accessed from within the browser via the Settings dialog ([#361](https://github.com/foosel/OctoPrint/pull/361))
|
||||
* Timelapses can now have a post-roll duration configured which will be rendered into the video too to not let it
|
||||
end so abruptly ([#384](https://github.com/foosel/OctoPrint/issues/384))
|
||||
* The terminal tab now has a command history ([#388](https://github.com/foosel/OctoPrint/pull/388))
|
||||
|
||||
### Improvements
|
||||
|
||||
* Stopping the application via Ctrl-C produces a less scary message ([#277](https://github.com/foosel/OctoPrint/pull/277))
|
||||
* Webcam stream is disabled when control tab is not in focus, reduces bandwidth ([#316](https://github.com/foosel/OctoPrint/issues/316))
|
||||
* M and G commands entered in Terminal tab are automatically converted to uppercase
|
||||
* GCODE viewer now only loads automatically if GCODE file size is beneath certain threshold (different ones for desktop
|
||||
and mobile devices), only actually loads file if user acknowledges that this might be too much for his browser
|
||||
* Added time needed for printing file to PrintDone event's payload ([#333](https://github.com/foosel/OctoPrint/issues/333))
|
||||
* Also provide the filename (basename without the path) in print events
|
||||
* Support for circular beds in the GCODE viewer ([#407](https://github.com/foosel/OctoPrint/pull/407))
|
||||
* The dimensions of the print bed can now be configured via the Settings ([#396](https://github.com/foosel/OctoPrint/pull/396))
|
||||
* Target temperature reporting format of Repetier Firmware is now supported as well ([360](https://github.com/foosel/OctoPrint/issues/360))
|
||||
* Version tracking now based on git tagging and [versioneer](https://github.com/warner/python-versioneer/). Version number,
|
||||
git commit and branch get reported in the format `<version tag>-<commits since then>-g<commit hash> (<branch> branch)`,
|
||||
e.g. `1.2.0-dev-172-ga48b5de (devel branch)`.
|
||||
* Made "Center viewport on model" and "Zoom in on model" in the GCODE viewer automatically deselect and de-apply if
|
||||
viewport gets manipulated by the user ([#398](https://github.com/foosel/OctoPrint/issues/398))
|
||||
* GCODE viewer now interprets inverted axes for printer control and mirrors print bed accordingly ([#431](https://github.com/foosel/OctoPrint/issues/431))
|
||||
* Added `clean` command to `setup.py`, removes old build artifacts (mostly interesting for developers)
|
||||
* Added version resource on API which reports application and API version
|
||||
* Made the navbar static instead of fixed to improve usability on mobile devices ([#257](https://github.com/foosel/OctoPrint/issues/257))
|
||||
* Switch to password field upon enter in username field, submit login form upon enter in password field
|
||||
* Changed default path to OctoPrint executable in included init-script to `/usr/local/bin/octoprint` (the default when
|
||||
installing via `python setup.py install`)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Properly calculate time deltas (forgot to factor in days)
|
||||
* [#35](https://github.com/foosel/OctoPrint/issues/35) - GCODE viewer has been modularized, options are now functional
|
||||
* [#337](https://github.com/foosel/OctoPrint/issues/337) - Also recognize `--iknowwhatimdoing` when running as daemon
|
||||
* [#357](https://github.com/foosel/OctoPrint/issues/357) - Do not run GCODE analyzer when a print is ongoing
|
||||
* [#381](https://github.com/foosel/OctoPrint/issues/381) - Only list those SD files that have an ASCII filename
|
||||
* Fixed a race condition that could occur when pressing "Print" (File not opened yet, but attempt to read from it)
|
||||
* [#398](https://github.com/foosel/OctoPrint/issues/398) - Fixed interfering options in GCODE viewer
|
||||
* [#399](https://github.com/foosel/OctoPrint/issues/399) & [360](https://github.com/foosel/OctoPrint/issues/360) - Leave
|
||||
bed temperature unset when not detected (instead of dying a horrible death)
|
||||
* [#492](https://github.com/foosel/OctoPrint/issues/492) - Fixed a race condition which could lead to an attempt to read
|
||||
from an already closed serial port, causing an error to be displayed to the user
|
||||
* [#257](https://github.com/foosel/OctoPrint/issues/257) - Logging in on mobile devices should now work
|
||||
* [#476](https://github.com/foosel/OctoPrint/issues/476) - Also update the metadata correctly when an analysis finishes
|
||||
* Various fixes of bugs in newly introduced features and improvements:
|
||||
- [#314](https://github.com/foosel/OctoPrint/issues/314) - Use G28 for homing (G1 was copy and paste error)
|
||||
- [#317](https://github.com/foosel/OctoPrint/issues/317) - Fixed "load and print" function
|
||||
- [#326](https://github.com/foosel/OctoPrint/issues/326) - Fixed refresh of SD file list
|
||||
- [#338](https://github.com/foosel/OctoPrint/issues/338) - Refetch file list when deleting a file
|
||||
- [#339](https://github.com/foosel/OctoPrint/issues/339) - More error resilience when handling temperature offset data from the backend
|
||||
- [#345](https://github.com/foosel/OctoPrint/issues/345) - Also recognize such temperature reports that do not contain a `T:` but a `T0:`
|
||||
- [#377](https://github.com/foosel/OctoPrint/pull/377) - URLs in API examples fixed
|
||||
- [#378](https://github.com/foosel/OctoPrint/pull/378) - Fixed crash of API call when `getStartTime()` returns None
|
||||
- [#379](https://github.com/foosel/OctoPrint/pull/379) - Corrected response code for connection success
|
||||
- [#414](https://github.com/foosel/OctoPrint/pull/414) - Fix style attribute for Actual column header
|
||||
|
||||
([Commits](https://github.com/foosel/OctoPrint/compare/1.0.0...1.1.0))
|
||||
|
||||
## 1.0.0 (2014-06-22)
|
||||
|
||||
First release with new versioning scheme.
|
||||
@@ -0,0 +1,22 @@
|
||||
Issues, Tickets, however you may call them
|
||||
------------------------------------------
|
||||
|
||||
Read the following short instructions **fully** and **follow them** if you want your ticket to be taken care of and not closed again directly!
|
||||
|
||||
- Always create **one ticket for one purpose**. So don't mix two or more feature requests, support requests, bugs etc into one ticket. If you do, your ticket will be treated as if only describing the first purpose, the others will be ignored!
|
||||
- If you want to report a bug, **READ AND FOLLOW [How to file a bug report](https://github.com/foosel/OctoPrint/wiki/How-to-file-a-bug-report)!** Tickets will be automatically checked if they comply with the requirements outlined in that wiki node! Other then what's written in there (**and really EVERYTHING that is written in there!**) you don't have to do anything special with your ticket.
|
||||
- If you want to post a **request** of any kind (feature request, documentation request, ...), **add [Request] to your issue's title!**
|
||||
- If you need **support** with a problem of your installation (e.g. if you have problems getting the webcam to work), **add [Support] to your issue's title!**. Note that for problems like these, the [Mailinglist](https://groups.google.com/group/octoprint) or the [Google+ Community](https://plus.google.com/communities/102771308349328485741) will probably get you help faster!
|
||||
- If you have a general **question**, **add [Question] to your issue's title!**. Note that for problems like these, the [Mailinglist](https://groups.google.com/group/octoprint) or the [Google+ Community](https://plus.google.com/communities/102771308349328485741) will probably get you help faster!
|
||||
- If you have another reason for creating a ticket that doesn't fit any of the above categories, think hard if it might not be something better suited for the [Mailinglist](https://groups.google.com/group/octoprint) or the [Google+ Community](https://plus.google.com/communities/102771308349328485741). If you are sure it needs to be reported here, **add [Misc] to your issue's title!**
|
||||
|
||||
Following these guidelines (**especially EVERYTHING mentioned in ["How to file a bug report"](https://github.com/foosel/OctoPrint/wiki/How-to-file-a-bug-report)**) is necessary so the tickets stay manageable - you are not the only one with an open issue, so please respect that you have to **play by the rules** so that your problem can be taken care of. Tickets not playing by the rules **will be closed without further investigation!**.
|
||||
|
||||
Pull Requests
|
||||
-------------
|
||||
|
||||
1. Please create all pull requests against the `devel` branch.
|
||||
2. Create **one pull request per feature/bug fix**.
|
||||
3. Create a custom branch for your feature/bug fix and use that as base for your pull request. Pull requests directly against your version of `devel` will be closed.
|
||||
4. In your pull request's description, state what your pull request is doing, as in, what feature does it implement, what bug does it fix.
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
recursive-include octoprint/static *
|
||||
recursive-include octoprint/templates *
|
||||
recursive-include src/octoprint/static *
|
||||
recursive-include src/octoprint/templates *
|
||||
include versioneer.py
|
||||
include src/octoprint/_version.py
|
||||
@@ -8,59 +8,66 @@ and released under the [GNU Affero General Public License V3](http://www.gnu.org
|
||||
|
||||
Its website can be found at [octoprint.org](http://octoprint.org).
|
||||
|
||||
Reporting bugs
|
||||
--------------
|
||||
Contributing
|
||||
------------
|
||||
|
||||
OctoPrint's issue tracker can be found [on Github](https://github.com/foosel/OctoPrint/issues). **Before opening a new
|
||||
ticket please take a look at [this guide on how to file a bug report with OctoPrint](https://github.com/foosel/OctoPrint/wiki/How-to-file-a-bug-report).**
|
||||
Please see the project's [Contribution Guidelines](https://github.com/foosel/OctoPrint/blob/master/CONTRIBUTING.md).
|
||||
|
||||
Sending pull requests
|
||||
---------------------
|
||||
Installation
|
||||
------------
|
||||
|
||||
Please create all pull requests against the [devel branch](https://github.com/foosel/OctoPrint/tree/devel) of OctoPrint, as that one is used for developing new
|
||||
features and then merged against master when those features are deemed mature enough for general consumption. In case
|
||||
of bug fixes I'll take care to cherry pick them against master if the bugs they are fixing are critical.
|
||||
Installation instructions for installing from source for different operating systems can be found [on the wiki](https://github.com/foosel/OctoPrint/wiki#assorted-guides).
|
||||
|
||||
If you want to run OctoPrint on a Raspberry Pi you might want to take a look at [OctoPi](https://github.com/guysoft/OctoPi)
|
||||
which is a custom SD card image that includes OctoPrint plus dependencies.
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
OctoPrint depends on a couple of python modules to do its job. Those are listed in requirements.txt and can be
|
||||
installed using `pip`:
|
||||
OctoPrint depends on a couple of python modules to do its job. Those are automatically installed when installing
|
||||
OctoPrint via `setup.py`:
|
||||
|
||||
pip install -r requirements.txt
|
||||
python setup.py install
|
||||
|
||||
You should also do this after pulling from the repository, since the dependencies might have changed.
|
||||
You should also do this every time after pulling from the repository, since the dependencies might have changed.
|
||||
|
||||
OctoPrint currently only supports Python 2.7.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
Just start the server via
|
||||
Running the `setup.py` script installs the `octoprint` script in your Python installation's scripts folder
|
||||
(which depending on whether you installed OctoPrint globally or into a virtual env will be on your `PATH` or not). The
|
||||
following usage examples assume that said `octoprint` script is on your `PATH`.
|
||||
|
||||
./run
|
||||
You can start the server via
|
||||
|
||||
octoprint
|
||||
|
||||
By default it binds to all interfaces on port 5000 (so pointing your browser to `http://127.0.0.1:5000`
|
||||
will do the trick). If you want to change that, use the additional command line parameters `host` and `port`,
|
||||
which accept the host ip to bind to and the numeric port number respectively. If for example you want the server
|
||||
to only listen on the local interface on port 8080, the command line would be
|
||||
|
||||
./run --host=127.0.0.1 --port=8080
|
||||
octoprint --host=127.0.0.1 --port=8080
|
||||
|
||||
Alternatively, the host and port on which to bind can be defined via the configuration.
|
||||
|
||||
If you want to run OctoPrint as a daemon (only supported on Linux), use
|
||||
|
||||
./run --daemon {start|stop|restart} [--pid PIDFILE]
|
||||
octoprint --daemon {start|stop|restart} [--pid PIDFILE]
|
||||
|
||||
If you do not supply a custom pidfile location via `--pid PIDFILE`, it will be created at `/tmp/octoprint.pid`.
|
||||
|
||||
You can also specify the configfile or the base directory (for basing off the `uploads`, `timelapse` and `logs` folders),
|
||||
e.g.:
|
||||
|
||||
./run --config /path/to/another/config.yaml --basedir /path/to/my/basedir
|
||||
octoprint --config /path/to/another/config.yaml --basedir /path/to/my/basedir
|
||||
|
||||
See `run --help` for further information.
|
||||
See `octoprint --help` for further information.
|
||||
|
||||
OctoPrint also ships with a `run` script in its source directory. You can also invoke that to start up the server, it
|
||||
takes the same command line arguments as the `octoprint` script.
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
@@ -70,9 +77,5 @@ which is located at `~/.octoprint` on Linux, at `%APPDATA%/OctoPrint` on Windows
|
||||
at `~/Library/Application Support/OctoPrint` on MacOS.
|
||||
|
||||
A comprehensive overview of all available configuration settings can be found
|
||||
[on the wiki](https://github.com/foosel/OctoPrint/wiki/Configuration).
|
||||
|
||||
Setup on a Raspberry Pi running Raspbian
|
||||
----------------------------------------
|
||||
|
||||
A comprehensive setup guide can be found [on the wiki](https://github.com/foosel/OctoPrint/wiki/Setup-on-a-Raspberry-Pi-running-Raspbian).
|
||||
[on the wiki](https://github.com/foosel/OctoPrint/wiki/Configuration). Please note that the most commonly used
|
||||
configuration settings can also easily be edited from OctoPrint's settings dialog.
|
||||
@@ -0,0 +1,6 @@
|
||||
[python: src/octoprint/**.py]
|
||||
[jinja2: src/octoprint/templates/**.jinja2]
|
||||
extensions=jinja2.ext.autoescape, jinja2.ext.with_
|
||||
|
||||
[javascript: src/octoprint/static/js/app/**.js]
|
||||
extract_messages = gettext, ngettext
|
||||
@@ -0,0 +1,177 @@
|
||||
# Makefile for Sphinx documentation
|
||||
#
|
||||
|
||||
# You can set these variables from the command line.
|
||||
SPHINXOPTS =
|
||||
SPHINXBUILD = sphinx-build
|
||||
PAPER =
|
||||
BUILDDIR = _build
|
||||
|
||||
# User-friendly check for sphinx-build
|
||||
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
|
||||
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
|
||||
endif
|
||||
|
||||
# Internal variables.
|
||||
PAPEROPT_a4 = -D latex_paper_size=a4
|
||||
PAPEROPT_letter = -D latex_paper_size=letter
|
||||
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
|
||||
# the i18n builder cannot share the environment and doctrees with the others
|
||||
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
|
||||
|
||||
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
|
||||
|
||||
help:
|
||||
@echo "Please use \`make <target>' where <target> is one of"
|
||||
@echo " html to make standalone HTML files"
|
||||
@echo " dirhtml to make HTML files named index.html in directories"
|
||||
@echo " singlehtml to make a single large HTML file"
|
||||
@echo " pickle to make pickle files"
|
||||
@echo " json to make JSON files"
|
||||
@echo " htmlhelp to make HTML files and a HTML help project"
|
||||
@echo " qthelp to make HTML files and a qthelp project"
|
||||
@echo " devhelp to make HTML files and a Devhelp project"
|
||||
@echo " epub to make an epub"
|
||||
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
|
||||
@echo " latexpdf to make LaTeX files and run them through pdflatex"
|
||||
@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
|
||||
@echo " text to make text files"
|
||||
@echo " man to make manual pages"
|
||||
@echo " texinfo to make Texinfo files"
|
||||
@echo " info to make Texinfo files and run them through makeinfo"
|
||||
@echo " gettext to make PO message catalogs"
|
||||
@echo " changes to make an overview of all changed/added/deprecated items"
|
||||
@echo " xml to make Docutils-native XML files"
|
||||
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
|
||||
@echo " linkcheck to check all external links for integrity"
|
||||
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILDDIR)/*
|
||||
|
||||
html:
|
||||
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
|
||||
@echo
|
||||
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
|
||||
|
||||
dirhtml:
|
||||
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
|
||||
@echo
|
||||
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
|
||||
|
||||
singlehtml:
|
||||
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
|
||||
@echo
|
||||
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
|
||||
|
||||
pickle:
|
||||
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
|
||||
@echo
|
||||
@echo "Build finished; now you can process the pickle files."
|
||||
|
||||
json:
|
||||
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
|
||||
@echo
|
||||
@echo "Build finished; now you can process the JSON files."
|
||||
|
||||
htmlhelp:
|
||||
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
|
||||
@echo
|
||||
@echo "Build finished; now you can run HTML Help Workshop with the" \
|
||||
".hhp project file in $(BUILDDIR)/htmlhelp."
|
||||
|
||||
qthelp:
|
||||
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
|
||||
@echo
|
||||
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
|
||||
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
|
||||
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/OctoPrint.qhcp"
|
||||
@echo "To view the help file:"
|
||||
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/OctoPrint.qhc"
|
||||
|
||||
devhelp:
|
||||
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
|
||||
@echo
|
||||
@echo "Build finished."
|
||||
@echo "To view the help file:"
|
||||
@echo "# mkdir -p $$HOME/.local/share/devhelp/OctoPrint"
|
||||
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/OctoPrint"
|
||||
@echo "# devhelp"
|
||||
|
||||
epub:
|
||||
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
|
||||
@echo
|
||||
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
|
||||
|
||||
latex:
|
||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||
@echo
|
||||
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
|
||||
@echo "Run \`make' in that directory to run these through (pdf)latex" \
|
||||
"(use \`make latexpdf' here to do that automatically)."
|
||||
|
||||
latexpdf:
|
||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||
@echo "Running LaTeX files through pdflatex..."
|
||||
$(MAKE) -C $(BUILDDIR)/latex all-pdf
|
||||
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
|
||||
|
||||
latexpdfja:
|
||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||
@echo "Running LaTeX files through platex and dvipdfmx..."
|
||||
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
|
||||
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
|
||||
|
||||
text:
|
||||
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
|
||||
@echo
|
||||
@echo "Build finished. The text files are in $(BUILDDIR)/text."
|
||||
|
||||
man:
|
||||
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
|
||||
@echo
|
||||
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
|
||||
|
||||
texinfo:
|
||||
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
|
||||
@echo
|
||||
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
|
||||
@echo "Run \`make' in that directory to run these through makeinfo" \
|
||||
"(use \`make info' here to do that automatically)."
|
||||
|
||||
info:
|
||||
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
|
||||
@echo "Running Texinfo files through makeinfo..."
|
||||
make -C $(BUILDDIR)/texinfo info
|
||||
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
|
||||
|
||||
gettext:
|
||||
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
|
||||
@echo
|
||||
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
|
||||
|
||||
changes:
|
||||
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
|
||||
@echo
|
||||
@echo "The overview file is in $(BUILDDIR)/changes."
|
||||
|
||||
linkcheck:
|
||||
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
|
||||
@echo
|
||||
@echo "Link check complete; look for any errors in the above output " \
|
||||
"or in $(BUILDDIR)/linkcheck/output.txt."
|
||||
|
||||
doctest:
|
||||
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
|
||||
@echo "Testing of doctests in the sources finished, look at the " \
|
||||
"results in $(BUILDDIR)/doctest/output.txt."
|
||||
|
||||
xml:
|
||||
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
|
||||
@echo
|
||||
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
|
||||
|
||||
pseudoxml:
|
||||
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
|
||||
@echo
|
||||
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
|
||||
@@ -0,0 +1,170 @@
|
||||
.. _sec-api-apps:
|
||||
|
||||
****
|
||||
Apps
|
||||
****
|
||||
|
||||
.. contents::
|
||||
|
||||
.. _sec-api-apps-sessionkey:
|
||||
|
||||
Session Keys
|
||||
============
|
||||
|
||||
OctoPrint offers a special API key type for apps to use, the so called App Session Key. These keys have a time based
|
||||
validity and are generated by OctoPrint for requesting apps.
|
||||
|
||||
Obtaining those keys is based on a handshake procedure backed by cryptographic signatures using RSA. OctoPrint needs to
|
||||
be aware of apps and their associated public keys (this can be achieved either via entries in ``config.yaml`` or by
|
||||
installing app specific plugins which implement the ``AppPlugin`` type).
|
||||
|
||||
Apps can be registered within OctoPrint via ``config.yaml`` by adding them to the ``api`` > ``apps`` section, using the
|
||||
application's id concatenated with its version as key, with the public key provided as item ``pubkey`` (stripped of the
|
||||
``BEGIN RSA PUBLIC KEY`` and ``END RSA PUBLIC KEY`` separators and also newlines) and optionally also whether the app is
|
||||
enabled or not (defaults to enabled, so can be left out if it's not to be set to disabled explicitly).
|
||||
|
||||
Example:
|
||||
|
||||
.. sourcecode:: yaml
|
||||
|
||||
api:
|
||||
apps:
|
||||
"com.example.my_octoprint_app:0.9":
|
||||
pubkey: MEgCQQDYkr5Fv/YXK5ZL1uwRN4A61IagZaYLGqJ5JJGFo8wDrmpAMRqE9kK4+5hIDblC5DzfEr5oP7OA3tRO48Rf5yInAgMBAAE=
|
||||
enabled: false
|
||||
"com.example.my_octoprint_app:1.0":
|
||||
pubkey: MEgCQQCIWfi7Nc8bcnfZJJtA6a4RyMC+sKBlMOb25OVNNB4L2v0TiGO72jVKR4osvb4oztlbRW5GkdiY0T2LJcfDYvkJAgMBAAE=
|
||||
|
||||
In the example, the app ``com.example.my_octoprint_app`` in version 0.9 has been disabled (e.g. due to the key having
|
||||
leaked) whereas version 1.0 is fully registered with OctoPrint and may verify app session keys.
|
||||
|
||||
|
||||
.. _sec-api-apps-sessionkey-workflow:
|
||||
|
||||
Workflow
|
||||
--------
|
||||
|
||||
Apps perform the handshake by first requesting a temporary key with very limited validity,
|
||||
then sending a message back to OctoPrint containing their id, version, the temporary key and a signature created with their
|
||||
private key over these three pieces of data. OctoPrint then tries to verify the signature and if successful unlocks the
|
||||
key to be used as a fully recognized API key.
|
||||
|
||||
For performing the handshake a special API exists within OctoPrint for which no API key is needed which is described below.
|
||||
|
||||
.. _sec-api-apps-sessionkey-get:
|
||||
|
||||
Obtaining a temporary session key
|
||||
---------------------------------
|
||||
|
||||
.. http:get:: /apps/auth
|
||||
|
||||
Retrieve a temporary session key with a minimum validity. It can only be used as a proper API key after having been
|
||||
:ref:`verified <sec-api-apps-sessionkey-verify>`.
|
||||
|
||||
Returns the temporary session key and the timestamp until it's valid.
|
||||
|
||||
**Example**:
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
GET /apps/auth HTTP/1.1
|
||||
Host: example.com
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"unverifiedKey": "F43A844750F74AD080FE9F438D47B33C",
|
||||
"validUntil": 1416220357.011
|
||||
}
|
||||
|
||||
:statuscode 200: No error
|
||||
|
||||
.. _sec-api-apps-sessionkey-verify:
|
||||
|
||||
Verifying a temporary session key
|
||||
---------------------------------
|
||||
|
||||
.. http:post:: /apps/auth
|
||||
|
||||
Verify a formerly :ref:`retrieved <sec-api-apps-sessionkey-get>` temporary session key by providing credentials and a
|
||||
cryptographic signature over these credentials and the temporary key.
|
||||
|
||||
Returns the now verified session key and the new validity.
|
||||
|
||||
**Example**:
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /apps/auth HTTP/1.1
|
||||
Host: example.com
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"appid": "com.example.my_octoprint_app",
|
||||
"appversion": "1.0",
|
||||
"key": "F43A844750F74AD080FE9F438D47B33C",
|
||||
"_sig": "LGVCiolQWDc4AVn1DOcWljY0cFQxWF4pldVveUjjmL9JhiL0LnCKBbGwZ/CwKBWswFAxPaxQ0kDusVdOmCUa/w=="
|
||||
}
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"key": "F43A844750F74AD080FE9F438D47B33C",
|
||||
"validUntil": 1416227497.011
|
||||
}
|
||||
|
||||
.. _sec-api-apps-sessionkey-signature:
|
||||
|
||||
Creating the signature
|
||||
----------------------
|
||||
|
||||
The signature is created by concatenating the ``appid``, ``appversion`` and ``key`` fields, separated by a ``:`` (colon),
|
||||
signing the result with the app's private key using SHA-1 and then BASE64-encoding the result, stripping newlines.
|
||||
|
||||
Example for signature generation using Python and the `Python RSA library <https://pypi.python.org/pypi/rsa>`_:
|
||||
|
||||
.. sourcecode:: python
|
||||
|
||||
import base64
|
||||
import rsa
|
||||
|
||||
appid = "com.example.my_octoprint_app"
|
||||
version = "1.0"
|
||||
unverified_key = "F43A844750F74AD080FE9F438D47B33C"
|
||||
message_to_sign = appid + ":" + version + ":" + unverified_key
|
||||
// => "com.example.my_octoprint_app:1.0:F43A844750F74AD080FE9F438D47B33C"
|
||||
|
||||
private_key = rsa.PrivateKey.load_pkcs1("...")
|
||||
signature = base64.encodestring(rsa.sign(message_to_sign, private_key, "SHA-1")).replace("\n", "")
|
||||
// => "LGVCiolQWDc4AVn1DOcWljY0cFQxWF4pldVveUjjmL9JhiL0LnCKBbGwZ/CwKBWswFAxPaxQ0kDusVdOmCUa/w=="
|
||||
|
||||
|
||||
.. _sec-api-apps-sessionkey-testing:
|
||||
|
||||
Testing your implementation
|
||||
---------------------------
|
||||
|
||||
If you want to use app session keys, here is the key pair with which the above examples were created, in order for you
|
||||
to verify your signature implementation::
|
||||
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIBPQIBAAJBAIhZ+Ls1zxtyd9kkm0DprhHIwL6woGUw5vbk5U00Hgva/ROIY7va
|
||||
NUpHiiy9vijO2VtFbkaR2JjRPYslx8Ni+QkCAwEAAQJARK4lFo+FEcs3yR2iQjEy
|
||||
p+yaAbNQJ4hZXlVvltLAYICzOM3kyKx53/eKU59NjskLz9q6QxfleymYPWAgl4NW
|
||||
fQIjAJVH8MjwNcaAquTM9z2OiFi3OC8WgaKOi5W/T+r2+B70wG8CHwDp08dqOZ/u
|
||||
xcBiy4Wzpcme9bckqoVuS3gWMm+YqgcCIwCMFU07kkY0NyumtzxPdIA4F/7OGSWf
|
||||
IHqWFEfvasAddHlbAh8A5UgkB3Zf7Bt+7aFSBnlvve6FWm/XDPL12xYztYgrAiIa
|
||||
W3miN6FjIm+8TDowrk+nyYXG2GZefeY7QXOjYr6tlDn0
|
||||
-----END RSA PRIVATE KEY-----
|
||||
|
||||
-----BEGIN RSA PUBLIC KEY-----
|
||||
MEgCQQCIWfi7Nc8bcnfZJJtA6a4RyMC+sKBlMOb25OVNNB4L2v0TiGO72jVKR4os
|
||||
vb4oztlbRW5GkdiY0T2LJcfDYvkJAgMBAAE=
|
||||
-----END RSA PUBLIC KEY-----
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
.. _sec-api-connection:
|
||||
|
||||
*******************
|
||||
Connection handling
|
||||
*******************
|
||||
|
||||
.. contents::
|
||||
|
||||
.. _sec-api-connection-current:
|
||||
|
||||
Get connection settings
|
||||
=======================
|
||||
|
||||
.. http:get:: /api/connection
|
||||
|
||||
Retrieve the current connection settings, including information regarding the available baudrates and
|
||||
serial ports and the current connection state.
|
||||
|
||||
**Example**
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
GET /api/connection HTTP/1.1
|
||||
Host: example.com
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"current": {
|
||||
"state": "Operational",
|
||||
"port": "/dev/ttyACM0",
|
||||
"baudrate": 250000,
|
||||
"printerProfile": "_default"
|
||||
},
|
||||
"options": {
|
||||
"ports": ["/dev/ttyACM0", "VIRTUAL"],
|
||||
"baudrates": [250000, 230400, 115200, 57600, 38400, 19200, 9600],
|
||||
"printerProfiles": [{"name": "Default", id: "_default"}],
|
||||
"portPreference": "/dev/ttyACM0",
|
||||
"baudratePreference": 250000,
|
||||
"printerProfilePreference": "_default",
|
||||
"autoconnect": true
|
||||
}
|
||||
}
|
||||
|
||||
:statuscode 200: No error
|
||||
|
||||
.. _sec-api-connection-command:
|
||||
|
||||
Issue a connection command
|
||||
==========================
|
||||
|
||||
.. http:post:: /api/connection
|
||||
|
||||
Issue a connection command. Currently available command are:
|
||||
|
||||
connect
|
||||
Instructs OctoPrint to connect to the printer. Additional parameters are:
|
||||
|
||||
* ``port``: Optional, specific port to connect to. If not set the current ``portPreference`` will be used, or if
|
||||
no preference is available auto detection will be attempted.
|
||||
* ``baudrate``: Optional, specific baudrate to connect with. If not set the current ``baudratePreference`` will
|
||||
be used, or if no preference is available auto detection will be attempted.
|
||||
* ``printerProfile`` Optional, specific printer profile to use for connection. If not set the current default printer
|
||||
profile will be used.
|
||||
* ``save``: Optional, whether to save the request's ``port`` and ``baudrate`` settings as new preferences. Defaults
|
||||
to ``false`` if not set.
|
||||
* ``autoconnect``: Optional, whether to automatically connect to the printer on OctoPrint's startup in the future.
|
||||
If not set no changes will be made to the current configuration.
|
||||
|
||||
disconnect
|
||||
Instructs OctoPrint to disconnect from the printer.
|
||||
|
||||
**Example Connect Request**
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/connection HTTP/1.1
|
||||
Host: example.com
|
||||
Content-Type: application/json
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
{
|
||||
"command": "connect",
|
||||
"port": "/dev/ttyACM0",
|
||||
"baudrate": 115200,
|
||||
"printerProfile": "my_printer_profile",
|
||||
"save": true,
|
||||
"autoconnect": true
|
||||
}
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
**Example Disconnect Request**
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/connection HTTP/1.1
|
||||
Host: example.com
|
||||
Content-Type: application/json
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
{
|
||||
"command": "disconnect"
|
||||
}
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
:json string command: The command to issue, either ``connect`` or ``disconnect``
|
||||
:json string port: ``connect`` command: The port to connect to. If left out either the existing ``portPreference``
|
||||
will be used, or if that is not available OctoPrint will attempt auto detection. Must be part
|
||||
of the available ports.
|
||||
:json number baudrate: ``connect`` command: The baudrate to connect with. If left out either the existing
|
||||
``baudratePreference`` will be used, or if that is not available OctoPrint will attempt
|
||||
autodetection. Must be part of the available baudrates.
|
||||
:json string printerProfile: ``connect`` command: The id of the printer profile to use for the connection. If left out the current
|
||||
default printer profile will be used. Must be part of the available printer profiles.
|
||||
:json boolean save: ``connect`` command: Whether to save the supplied connection settings as the new preference.
|
||||
Defaults to ``false`` if not set.
|
||||
:json boolean autoconnect: ``connect`` command: Whether to attempt to automatically connect to the printer on server
|
||||
startup. If not set no changes will be made to the current setting.
|
||||
:statuscode 204: No error
|
||||
:statuscode 400: If the selected `port` or `baudrate` for a ``connect`` command are not part of the available
|
||||
options.
|
||||
@@ -0,0 +1,352 @@
|
||||
.. _sec-api-datamodel:
|
||||
|
||||
*****************
|
||||
Common data model
|
||||
*****************
|
||||
|
||||
.. contents::
|
||||
|
||||
.. _sec-api-datamodel-printer:
|
||||
|
||||
Printer related
|
||||
===============
|
||||
|
||||
.. _sec-api-datamodel-printer-state:
|
||||
|
||||
Printer State
|
||||
-------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``text``
|
||||
- 1
|
||||
- String
|
||||
- A textual representation of the current state of the printer, e.g. "Operational" or "Printing"
|
||||
* - ``flags``
|
||||
- 1
|
||||
- Printer state flags
|
||||
- A couple of boolean printer state flags
|
||||
* - ``flags.operational``
|
||||
- 1
|
||||
- Boolean
|
||||
- ``true`` if the printer is operational, ``false`` otherwise
|
||||
* - ``flags.paused``
|
||||
- 1
|
||||
- Boolean
|
||||
- ``true`` if the printer is currently paused, ``false`` otherwise
|
||||
* - ``flags.printing``
|
||||
- 1
|
||||
- Boolean
|
||||
- ``true`` if the printer is currently printing, ``false`` otherwise
|
||||
* - ``flags.sdReady``
|
||||
- 1
|
||||
- Boolean
|
||||
- ``true`` if the printer's SD card is available and initialized, ``false`` otherwise. This is redundant information
|
||||
to :ref:`the SD State <sec-api-printer-datamodel-sdstate>`.
|
||||
* - ``flags.error``
|
||||
- 1
|
||||
- Boolean
|
||||
- ``true`` if an unrecoverable error occurred, ``false`` otherwise
|
||||
* - ``flags.ready``
|
||||
- 1
|
||||
- Boolean
|
||||
- ``true`` if the printer is operational and no data is currently being streamed to SD, so ready to receive instructions
|
||||
* - ``flags.closedOrError``
|
||||
- 1
|
||||
- Boolean
|
||||
- ``true`` if the printer is disconnected (possibly due to an error), ``false`` otherwise
|
||||
|
||||
.. _sec-api-datamodel-printer-tempdata:
|
||||
|
||||
Temperature Data
|
||||
----------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``actual``
|
||||
- 1
|
||||
- Number
|
||||
- Current temperature
|
||||
* - ``target``
|
||||
- 1
|
||||
- Number
|
||||
- Target temperature, may be ``null`` if no target temperature is set.
|
||||
* - ``offset``
|
||||
- 0..1
|
||||
- Number
|
||||
- Currently configured temperature offset to apply, will be left out for historic temperature information.
|
||||
|
||||
.. _sec-api-datamodel-printer-temphistory:
|
||||
|
||||
Historic Temperature Data Point
|
||||
-------------------------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``time``
|
||||
- 1
|
||||
- Unix Timestamp
|
||||
- Timestamp of this data point
|
||||
* - ``tool{n}``
|
||||
- 0..*
|
||||
- :ref:`Temperature Data <sec-api-datamodel-printer-tempdata>`
|
||||
- Temperature stats for tool *n*. Enumeration starts at 0 for the first tool. Not included if querying only
|
||||
bed state.
|
||||
* - ``bed``
|
||||
- 0..*
|
||||
- :ref:`Temperature Data <sec-api-datamodel-printer-tempdata>`
|
||||
- Temperature stats for the printer's heated bed. Not included if querying only tool state.
|
||||
|
||||
.. _sec-api-datamodel-printer-tempoffset:
|
||||
|
||||
Temperature offset
|
||||
------------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``tool{n}``
|
||||
- 0..1
|
||||
- Number
|
||||
- Temperature offset for tool *n*. Enumeration starts at 0 for the first tool.
|
||||
* - ``bed``
|
||||
- 0..1
|
||||
- Number
|
||||
- Temperature offset for the printer's heated bed.
|
||||
|
||||
|
||||
.. _sec-api-datamodel-jobs:
|
||||
|
||||
Job related
|
||||
===========
|
||||
|
||||
.. _sec-api-datamodel-jobs-job:
|
||||
|
||||
Job information
|
||||
---------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``file``
|
||||
- 1
|
||||
- :ref:`File information (abridged) <sec-api-datamodel-files-file>`
|
||||
- The file that is the target of the current print job
|
||||
* - ``estimatedPrintTime``
|
||||
- 0..1
|
||||
- Integer
|
||||
- The estimated print time for the file, in seconds.
|
||||
* - ``lastPrintTime``
|
||||
- 0..1
|
||||
- Integer
|
||||
- The print time of the last print of the file, in seconds.
|
||||
* - ``filament``
|
||||
- 0..1
|
||||
- Object
|
||||
- Information regarding the estimated filament usage of the print job
|
||||
* - ``filament.length``
|
||||
- 0..1
|
||||
- Integer
|
||||
- Length of filament used, in mm
|
||||
* - ``filament.volume``
|
||||
- 0..1
|
||||
- Float
|
||||
- Volume of filament used, in cm³
|
||||
|
||||
.. _sec-api-datamodel-jobs-progress:
|
||||
|
||||
Progress information
|
||||
--------------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``completion``
|
||||
- 1
|
||||
- Float
|
||||
- Percentage of completion of the current print job
|
||||
* - ``filepos``
|
||||
- 1
|
||||
- Integer
|
||||
- Current position in the file being printed, in bytes from the beginning
|
||||
* - ``printTime``
|
||||
- 1
|
||||
- Integer
|
||||
- Time already spent printing, in seconds
|
||||
* - ``printTimeLeft``
|
||||
- 1
|
||||
- Integer
|
||||
- Estimate of time left to print, in seconds
|
||||
|
||||
.. _sec-api-datamodel-files:
|
||||
|
||||
File related
|
||||
============
|
||||
|
||||
.. _sec-api-datamodel-files-file:
|
||||
|
||||
File information
|
||||
----------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``name``
|
||||
- 1
|
||||
- String
|
||||
- The name of the file
|
||||
* - ``size``
|
||||
- 0..1
|
||||
- Number
|
||||
- The size of the file in bytes. Only available for ``local`` files.
|
||||
* - ``date``
|
||||
- 0..1
|
||||
- Unix timestamp
|
||||
- The timestamp when this file was uploaded. Only available for ``local`` files.
|
||||
* - ``origin``
|
||||
- 1
|
||||
- String, either ``local`` or ``sdcard``
|
||||
- The origin of the file, ``local`` when stored in OctoPrint's ``uploads`` folder, ``sdcard`` when stored on the
|
||||
printer's SD card (if available)
|
||||
* - ``refs``
|
||||
- 0..1
|
||||
- :ref:`sec-api-datamodel-files-ref`
|
||||
- References relevant to this file, left out in abridged version
|
||||
* - ``gcodeAnalysis``
|
||||
- 0..1
|
||||
- :ref:`GCODE analysis information <sec-api-datamodel-files-gcodeanalysis>`
|
||||
- Information from the analysis of the GCODE file, if available. Left out in abridged version.
|
||||
* - ``prints``
|
||||
- 0..1
|
||||
- :ref:`Print history <sec-api-datamodel-files-prints>`
|
||||
- Information regarding prints of this file, if available. Left out in abridged version.
|
||||
|
||||
.. _sec-api-datamodel-files-gcodeanalysis:
|
||||
|
||||
GCODE analysis information
|
||||
--------------------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``estimatedPrintTime``
|
||||
- 0..1
|
||||
- Integer
|
||||
- The estimated print time of the file, in seconds
|
||||
* - ``filament``
|
||||
- 0..1
|
||||
- Object
|
||||
- The estimated usage of filament
|
||||
* - ``filament.length``
|
||||
- 0..1
|
||||
- Integer
|
||||
- The length of filament used, in mm
|
||||
* - ``filament.volume``
|
||||
- 0..1
|
||||
- Float
|
||||
- The volume of filament used, in cm³
|
||||
|
||||
|
||||
.. _sec-api-datamodel-files-prints:
|
||||
|
||||
Print history
|
||||
-------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``failure``
|
||||
- 1
|
||||
- Number
|
||||
- The number of failed prints on record for the file
|
||||
* - ``success``
|
||||
- 1
|
||||
- Number
|
||||
- The number of successful prints on record for the file
|
||||
* - ``last``
|
||||
- 0..1
|
||||
- Object
|
||||
- Information regarding the last print on record for the file
|
||||
* - ``last.date``
|
||||
- 1
|
||||
- Unix timestamp
|
||||
- Timestamp when this file was printed last
|
||||
* - ``last.success``
|
||||
- 1
|
||||
- Boolean
|
||||
- Whether the last print on record was a success (``true``) or not (``false``)
|
||||
|
||||
.. _sec-api-datamodel-files-ref:
|
||||
|
||||
References
|
||||
----------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``resource``
|
||||
- 1
|
||||
- URL
|
||||
- The resource that represents the file (e.g. for issuing commands to or for deleting)
|
||||
* - ``download``
|
||||
- 0..1
|
||||
- URL
|
||||
- The download URL for the file
|
||||
* - ``model``
|
||||
- 0..1
|
||||
- URL
|
||||
- The model from which this file was generated (e.g. an STL, currently not used)
|
||||
|
||||
@@ -0,0 +1,505 @@
|
||||
.. _sec-api-fileops:
|
||||
|
||||
***************
|
||||
File operations
|
||||
***************
|
||||
|
||||
.. contents::
|
||||
|
||||
.. _sec-api-fileops-retrieveall:
|
||||
|
||||
Retrieve all files
|
||||
==================
|
||||
|
||||
.. http:get:: /api/files
|
||||
|
||||
Retrieve information regarding all files currently available and regarding the disk space still available
|
||||
locally in the system.
|
||||
|
||||
Returns a :ref:`Retrieve response <sec-api-fileops-datamodel-retrieveresponse>`.
|
||||
|
||||
**Example**:
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
GET /api/files HTTP/1.1
|
||||
Host: example.com
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"files": [
|
||||
{
|
||||
"name": "whistle_v2.gcode",
|
||||
"size": 1468987,
|
||||
"date": 1378847754,
|
||||
"origin": "local",
|
||||
"refs": {
|
||||
"resource": "http://example.com/api/files/local/whistle_v2.gcode",
|
||||
"download": "http://example.com/downloads/files/local/whistle_v2.gcode"
|
||||
},
|
||||
"gcodeAnalysis": {
|
||||
"estimatedPrintTime": 1188,
|
||||
"filament": {
|
||||
"length": 810,
|
||||
"volume": 5.36
|
||||
}
|
||||
},
|
||||
"print": {
|
||||
"failure": 4,
|
||||
"success": 23,
|
||||
"last": {
|
||||
"date": 1387144346,
|
||||
"success": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "whistle_.gco",
|
||||
"origin": "sdcard",
|
||||
"refs": {
|
||||
"resource": "http://example.com/api/files/sdcard/whistle_.gco"
|
||||
}
|
||||
}
|
||||
],
|
||||
"free": "3.2GB"
|
||||
}
|
||||
|
||||
:statuscode 200: No error
|
||||
|
||||
.. _sec-api-fileops-retrievelocation:
|
||||
|
||||
Retrieve files from specific location
|
||||
=====================================
|
||||
|
||||
.. http:get:: /api/files/(string:location)
|
||||
|
||||
Retrieve information regarding the files currently available on the selected `location` and -- if targeting
|
||||
the ``local`` location -- regarding the disk space still available locally in the system.
|
||||
|
||||
Returns a :ref:`Retrieve response <sec-api-fileops-datamodel-retrieveresponse>`.
|
||||
|
||||
**Example**:
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
GET /api/files/local HTTP/1.1
|
||||
Host: example.com
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"files": [
|
||||
{
|
||||
"name": "whistle_v2.gcode",
|
||||
"size": 1468987,
|
||||
"date": 1378847754,
|
||||
"origin": "local",
|
||||
"refs": {
|
||||
"resource": "http://example.com/api/files/local/whistle_v2.gcode",
|
||||
"download": "http://example.com/downloads/files/local/whistle_v2.gcode"
|
||||
},
|
||||
"gcodeAnalysis": {
|
||||
"estimatedPrintTime": 1188,
|
||||
"filament": {
|
||||
"length": 810,
|
||||
"volume": 5.36
|
||||
}
|
||||
},
|
||||
"print": {
|
||||
"failure": 4,
|
||||
"success": 23,
|
||||
"last": {
|
||||
"date": 1387144346,
|
||||
"success": true
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"free": "3.2GB"
|
||||
}
|
||||
|
||||
:param location: The origin location from which to retrieve the files. Currently only ``local`` and ``sdcard`` are
|
||||
supported, with ``local`` referring to files stored in OctoPrint's ``uploads`` folder and ``sdcard``
|
||||
referring to files stored on the printer's SD card (if available).
|
||||
:statuscode 200: No error
|
||||
:statuscode 404: If `location` is neither ``local`` nor ``sdcard``
|
||||
|
||||
.. _sec-api-fileops-uploadfile:
|
||||
|
||||
Upload file
|
||||
===========
|
||||
|
||||
.. http:post:: /api/files/(string:location)
|
||||
|
||||
Upload a file to the selected `location`.
|
||||
|
||||
Other than most of the other requests on OctoPrint's API which are expected as JSON, this request is expected as
|
||||
``Content-Type: multipart/form-data`` due to the included file upload.
|
||||
|
||||
Returns a :http:statuscode:`201` response with a ``Location`` header set to the management URL of the uploaded
|
||||
file and an :ref:`Upload Response <sec-api-fileops-datamodel-uploadresponse>` as the body upon successful completion.
|
||||
|
||||
**Example**
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/files/sdcard HTTP/1.1
|
||||
Host: example.com
|
||||
X-Api-Key: abcdef...
|
||||
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryDeC2E3iWbTv1PwMC
|
||||
|
||||
------WebKitFormBoundaryDeC2E3iWbTv1PwMC
|
||||
Content-Disposition: form-data; name="file"; filename="whistle_v2.gcode"
|
||||
Content-Type: application/octet-stream
|
||||
|
||||
;Generated with Cura_SteamEngine 13.11.2
|
||||
M109 T0 S220.000000
|
||||
T0
|
||||
;Sliced at: Wed 11-12-2013 16:53:12
|
||||
;Basic settings: Layer height: 0.2 Walls: 0.8 Fill: 20
|
||||
;Print time: #P_TIME#
|
||||
;Filament used: #F_AMNT#m #F_WGHT#g
|
||||
;Filament cost: #F_COST#
|
||||
;M190 S70 ;Uncomment to add your own bed temperature line
|
||||
;M109 S220 ;Uncomment to add your own temperature line
|
||||
G21 ;metric values
|
||||
G90 ;absolute positioning
|
||||
...
|
||||
------WebKitFormBoundaryDeC2E3iWbTv1PwMC
|
||||
Content-Disposition: form-data; name="select"
|
||||
|
||||
true
|
||||
------WebKitFormBoundaryDeC2E3iWbTv1PwMC
|
||||
Content-Disposition: form-data; name="print"
|
||||
|
||||
true
|
||||
------WebKitFormBoundaryDeC2E3iWbTv1PwMC--
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
Location: http://example.com/api/files/sdcard/whistle_.gcode
|
||||
|
||||
{
|
||||
"files": {
|
||||
"local": {
|
||||
"name": "whistle_v2.gcode",
|
||||
"origin": "local",
|
||||
"refs": {
|
||||
"resource": "http://example.com/api/files/local/whistle_v2.gcode",
|
||||
"download": "http://example.com/downloads/files/local/whistle_v2.gcode"
|
||||
}
|
||||
},
|
||||
"sdcard": {
|
||||
"name": "whistle_.gco",
|
||||
"origin": "sdcard",
|
||||
"refs": {
|
||||
"resource": "http://example.com/api/files/sdcard/whistle_.gco"
|
||||
}
|
||||
}
|
||||
},
|
||||
"done": true
|
||||
}
|
||||
|
||||
:param location: The target location to which to upload the file. Currently only ``local`` and ``sdcard`` are supported
|
||||
here, with ``local`` referring to OctoPrint's ``uploads`` folder and ``sdcard`` referring to
|
||||
the printer's SD card. If an upload targets the SD card, it will also be stored locally first.
|
||||
:form file: The file to upload, including a valid ``filename``.
|
||||
:form select: Whether to select the file directly after upload (``true``) or not (``false``). Optional, defaults
|
||||
to ``false``.
|
||||
:form print: Whether to start printing the file directly after upload (``true``) or not (``false``). If set, `select`
|
||||
is implicitely ``true`` as well. Optional, defaults to ``false``.
|
||||
:statuscode 201: No error
|
||||
:statuscode 400: If no `file` is included in the request, or the request is otherwise invalid.
|
||||
:statuscode 404: If `location` is neither ``local`` nor ``sdcard`` or trying to upload to SD card and SD card support
|
||||
is disabled
|
||||
:statuscode 409: If the upload of the file would override the file that is currently being printed or if an upload
|
||||
to SD card was requested and the printer is either not operational or currently busy with a print job.
|
||||
:statuscode 415: If the file is neither a ``gcode`` nor an ``stl`` file (or it is an ``stl`` file but slicing support
|
||||
is disabled)
|
||||
:statuscode 500: If the upload failed internally
|
||||
|
||||
.. _sec-api-fileops-retrievefileinfo:
|
||||
|
||||
Retrieve a specific file's information
|
||||
======================================
|
||||
|
||||
.. http:get:: /api/files/(string:location)/(path:filename)
|
||||
|
||||
Retrieves the selected file's information.
|
||||
|
||||
If the file is unknown, a :http:statuscode:`404` is returned.
|
||||
|
||||
On success, a :http:statuscode:`200` is returned, with a :ref:`file information item <sec-api-datamodel-files-file>`
|
||||
as the response body.
|
||||
|
||||
**Example**
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
GET /api/files/local/whistle_v2.gcode HTTP/1.1
|
||||
Host: example.com
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"name": "whistle_v2.gcode",
|
||||
"size": 1468987,
|
||||
"date": 1378847754,
|
||||
"origin": "local",
|
||||
"refs": {
|
||||
"resource": "http://example.com/api/files/local/whistle_v2.gcode",
|
||||
"download": "http://example.com/downloads/files/local/whistle_v2.gcode"
|
||||
},
|
||||
"gcodeAnalysis": {
|
||||
"estimatedPrintTime": 1188,
|
||||
"filament": {
|
||||
"length": 810,
|
||||
"volume": 5.36
|
||||
}
|
||||
},
|
||||
"print": {
|
||||
"failure": 4,
|
||||
"success": 23,
|
||||
"last": {
|
||||
"date": 1387144346,
|
||||
"success": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:param location: The location of the file for which to retrieve the information, either ``local`` or ``sdcard``.
|
||||
:param filename: The filename of the file for which to retrieve the information
|
||||
:statuscode 200: No error
|
||||
:statuscode 404: If `target` is neither ``local`` nor ``sdcard``, ``sdcard`` but SD card support is disabled or the
|
||||
requested file was not found
|
||||
|
||||
.. _sec-api-fileops-filecommand:
|
||||
|
||||
Issue a file command
|
||||
====================
|
||||
|
||||
.. http:post:: /api/files/(string:target)/(path:filename)
|
||||
|
||||
Issue a file command to an existing file. Currently supported commands are:
|
||||
|
||||
select
|
||||
Selects a file for printing. Additional parameters are:
|
||||
|
||||
* ``print``: Optional, if set to ``true`` the file will start printing directly after selection. If the printer
|
||||
is not operational when this parameter is present and set to ``true``, the request will fail with a response
|
||||
of ``409 Conflict``.
|
||||
|
||||
slice
|
||||
Slices an STL file into GCODE. Note that this is an asynchronous operation that will take place in the background
|
||||
after the response has been sent back to the client. Additional parameters are:
|
||||
|
||||
* ``slicer``: The slicing engine to use, defaults to ``cura`` if not set, which is also the only supported slicer right now.
|
||||
* ``gcode``: Name of the GCODE file to generated, in the same location as the STL file. Defaults to the STL file name
|
||||
with extension ``.gco`` if not set.
|
||||
* ``position``: Position of the object-to-slice's center on the print bed. A dictionary containing both ``x`` and ``y``
|
||||
coordinate in mm is expected
|
||||
* ``printerProfile``: Name of the printer profile to use, if not set the default printer profile will be used.
|
||||
* ``profile``: Name of the slicing profile to use, if not set the default slicing profile of the slicer will be used.
|
||||
* ``profile.*``: Override parameters, the ``profile.`` prefix will be stripped and the matching profile key will
|
||||
be overridden with the supplied value. Use this if you want to specify things that change often like a different
|
||||
temperature, filament diameter or infill percentage. Profile keys are slicer specific.
|
||||
* ``select``: Optional, if set to ``true`` the file be selected for printing right after the slicing has finished. If the
|
||||
printer is not operational or already printing when this parameter is present and set to ``true``, the request will
|
||||
fail with a response of ``409 Conflict``
|
||||
* ``print``: Optional, if set to ``true`` the file be selected and start printing right after the slicing has finished.
|
||||
If the printer is not operational or already printing when this parameter is present and set to ``true``, the request
|
||||
will fail with a response of ``409 Conflict``. Note that if this parameter is set, the parameter ``select`` does not
|
||||
need to be set, it is automatically assumed to be ``true`` too, otherwise no printing would be possible.
|
||||
|
||||
If consecutive slicing calls are made targeting the same GCODE filename (that also holds true if the default is used),
|
||||
the slicing job already running in the background will be cancelled before the new one is started. Note that this will
|
||||
also mean that if it was supposed to be directly selected and start printing after the slicing finished, this will not
|
||||
take place anymore and whether this will happen with the new sliced file depends entirely on the new request!
|
||||
|
||||
Upon success, a status code of :http:statuscode:`204` and an empty body is returned, unless specified otherwise.
|
||||
|
||||
**Example Select Request**
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/files/local/whistle_v2.gcode HTTP/1.1
|
||||
Host: example.com
|
||||
Content-Type: application/json
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
{
|
||||
"command": "select",
|
||||
"print": true
|
||||
}
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
**Example Slice Request**
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/files/local/some_model.stl HTTP/1.1
|
||||
Host: example.com
|
||||
Content-Type: application/json
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
{
|
||||
"command": "slice",
|
||||
"slicer": "cura",
|
||||
"gcode": "some_model.first_try.gcode",
|
||||
"printerProfile": "my_custom_reprap",
|
||||
"profile": "high_quality",
|
||||
"profile.infill": 75,
|
||||
"profile.fill_density": 15,
|
||||
"position": {"x": 100, "y": 100},
|
||||
"print": true
|
||||
}
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 202 Accepted
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"origin": "local",
|
||||
"name": "some_model.first_try.gcode",
|
||||
"refs": {
|
||||
"download": "http://example.com/downloads/files/local/some_model.first_try.gcode",
|
||||
"resource": "http://example.com/api/files/local/some_model.first_try.gcode"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
:param target: The target location on which to delete the file, either ``local`` (for OctoPrint's ``uploads``
|
||||
folder) or ``sdcard`` for the printer's SD card (if available)
|
||||
:param filename: The filename of the file for which to issue the command
|
||||
:json string command: The command to issue for the file, currently only ``select`` is supported
|
||||
:json boolean print: ``select`` and ``slice`` command: Optional, whether to start printing the file directly after selection
|
||||
or slicing, defaults to ``false``.
|
||||
:json string slicer: ``slice`` command: The slicer to use, defaults to the default slicer.
|
||||
:json string gcode: ``slice`` command: The name of the gcode file to create, defaults to the targeted stl's file name
|
||||
with its extension changed to ``.gco`` (e.g. "test.stl" will be sliced to "test.gco" if not specified
|
||||
otherwise)
|
||||
:json string profile: ``slice`` command: The slicing profile to use, defaults to the selected slicer's default profile.
|
||||
:json string profile.*: ``slice`` command: Overrides for the selected slicing profile, e.g. to specify a different temperature
|
||||
or filament diameter.
|
||||
:json string printerProfile: ``slice`` command: The printer profile to use, defaults to the default printer profile.
|
||||
:json boolean select: ``slice`` command: Optional, whether to select the file for printing directly after slicing,
|
||||
defaults to ``false``
|
||||
:statuscode 200: No error for a ``select`` command.
|
||||
:statuscode 202: No error for a ``slice`` command.
|
||||
:statuscode 400: If the ``command`` is unknown or the request is otherwise invalid
|
||||
:statuscode 415: If a ``slice`` command was issued against something other than an STL file.
|
||||
:statuscode 404: If `target` is neither ``local`` nor ``sdcard`` or the requested file was not found
|
||||
:statuscode 409: If a selected file is supposed to start printing directly but the printer is not operational or
|
||||
if a file to be sliced is supposed to be selected or start printing directly but the printer
|
||||
is not operational or already printing.
|
||||
|
||||
.. _sec-api-fileops-delete:
|
||||
|
||||
Delete file
|
||||
===========
|
||||
|
||||
.. http:delete:: /api/files/(string:target)/(path:filename)
|
||||
|
||||
Delete the selected `filename` on the selected `target`.
|
||||
|
||||
If the file to be deleted is currently being printed, a :http:statuscode:`409` will be returned.
|
||||
|
||||
Returns a :http:statuscode:`204` after successful deletion.
|
||||
|
||||
**Example Request**
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
DELETE /api/files/local/whistle_v2.gcode HTTP/1.1
|
||||
Host: example.com
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
:param target: The target location on which to delete the file, either ``local`` (for OctoPrint's ``uploads``
|
||||
folder) or ``sdcard`` for the printer's SD card (if available)
|
||||
:param filename: The filename of the file to delete
|
||||
:statuscode 204: No error
|
||||
:statuscode 404: If `target` is neither ``local`` nor ``sdcard`` or the requested file was not found
|
||||
:statuscode 409: If the file to be deleted is currently being printed
|
||||
|
||||
.. _sec-api-fileops-datamodel:
|
||||
|
||||
Datamodel
|
||||
=========
|
||||
|
||||
.. _sec-api-fileops-datamodel-retrieveresponse:
|
||||
|
||||
Retrieve response
|
||||
-----------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``files``
|
||||
- 0..*
|
||||
- Array of :ref:`File information items <sec-api-datamodel-files-file>`
|
||||
- The list of requested files. Might be an empty list if no files are available
|
||||
* - ``free``
|
||||
- 0..1
|
||||
- String
|
||||
- The amount of disk space in bytes available in the local disk space (refers to OctoPrint's ``uploads`` folder). Only
|
||||
returned if file list was requested for origin ``local`` or all origins.
|
||||
|
||||
.. _sec-api-fileops-datamodel-uploadresponse:
|
||||
|
||||
Upload response
|
||||
---------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``files``
|
||||
- 1
|
||||
- Object
|
||||
- Abridged information regarding the file that was just uploaded. If only uploaded to ``local`` this will only
|
||||
contain the ``local`` property. If uploaded to SD card, this will contain both ``local`` and ``sdcard`` properties.
|
||||
* - ``files.local``
|
||||
- 1
|
||||
- :ref:`sec-api-datamodel-files-file`
|
||||
- The information regarding the file that was just uploaded to the local storage (only the fields ``name``,
|
||||
``origin`` and ``refs`` will be set).
|
||||
* - ``files.sdcard``
|
||||
- 0..1
|
||||
- :ref:`sec-api-datamodel-files-file`
|
||||
- The information regarding the file that was just uploaded to the printer's SD card (only the fields ``name``,
|
||||
``origin`` and ``refs`` will be set).
|
||||
* - ``done``
|
||||
- 1
|
||||
- Boolean
|
||||
- Whether the file processing after upload has already finished (``true``) or not, e.g. due to first needing
|
||||
to perform a slicing step (``false``). Clients may use this information to direct progress displays related to
|
||||
the upload.
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
.. _sec-api-general:
|
||||
|
||||
*******************
|
||||
General information
|
||||
*******************
|
||||
|
||||
.. contents::
|
||||
|
||||
.. _sec-api-general-authorization:
|
||||
|
||||
Authorization
|
||||
=============
|
||||
|
||||
OctoPrint's API expects an API key to be supplied with each request. This API key can be either the globally
|
||||
configured one, a user specific one if "Access Control" is enabled or an ref:`App Session Key <sec-api-apps-sessionkey>`.
|
||||
Users are able to generate and revoke their custom API key via the "Change password" dialog.
|
||||
|
||||
The API key must be supplied in the custom HTTP header ``X-Api-Key``, e.g.
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
GET /api/files HTTP/1.1
|
||||
Host: example.com
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
If it is missing or included but invalid, OctoPrint will directly return a response with status :http:statuscode:`401`.
|
||||
|
||||
For testing purposes it is also possible to supply the API key via a query parameter ``apikey``, e.g.
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
GET /api/files?apikey=abcdef... HTTP/1.1
|
||||
Host: example.com
|
||||
|
||||
Please be advised that clients should use the header field variant if at all possible.
|
||||
|
||||
.. _fig-api-general-globalapikey:
|
||||
.. figure:: ../images/settings-global-api-key.png
|
||||
:align: center
|
||||
:alt: Global API key in the API settings
|
||||
|
||||
The global API key can be found in the "API" settings
|
||||
|
||||
.. _fig-api-general-userapikey:
|
||||
.. figure:: ../images/settings-user-api-key.png
|
||||
:align: center
|
||||
:alt: User specific API key location in user list
|
||||
|
||||
The user list in the "Access Control" settings shows the API key for users (if available)
|
||||
|
||||
.. _fig-api-general-changepassword:
|
||||
.. figure:: ../images/change-password-api-key.png
|
||||
:align: center
|
||||
:alt: API key options in "Change password" dialog
|
||||
|
||||
The API key options in the "Change password" dialog. Users can generate and revoke their custom API key here.
|
||||
|
||||
.. note::
|
||||
OctoPrint's web interface uses a custom API key that is freshly generated on every server start. This key is not
|
||||
intended to be used by any other client and would not be very useful in any case, since it basically represents
|
||||
a completely anonymous client.
|
||||
|
||||
.. _sec-api-general-contenttype:
|
||||
|
||||
Content Type
|
||||
============
|
||||
|
||||
If not otherwise stated OctoPrint's API expects request bodies and issues response bodies as ``Content-Type: application/json``.
|
||||
|
||||
.. _sec-api-general-encoding:
|
||||
|
||||
Encoding
|
||||
========
|
||||
|
||||
OctoPrint uses UTF-8 as charset.
|
||||
|
||||
.. _sec-api-cross-origin:
|
||||
|
||||
Cross-origin requests
|
||||
=====================
|
||||
|
||||
To make use of the OctoPrint API from websites other than the OctoPrint web interface,
|
||||
cross-origin resource sharing (`CORS <http://en.wikipedia.org/wiki/Cross-origin_resource_sharing>`_) must be enabled.
|
||||
This is the case even when the website in question is served from a different port on the same machine and on localhost.
|
||||
|
||||
To enable this feature, set the ``allowCrossOrigin`` key of the ``api`` section in ``config.yml`` to ``true`` or
|
||||
check the corresponding checkbox in the API settings dialog.
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
api:
|
||||
enabled: true
|
||||
key: ...
|
||||
allowCrossOrigin: true
|
||||
|
||||
.. _fig-api-general-apicors:
|
||||
.. figure:: ../images/settings-api-cors.png
|
||||
:align: center
|
||||
:alt: CORS configuration in the API settings
|
||||
|
||||
Support for CORS can be enabled in the "API" settings
|
||||
|
||||
.. note::
|
||||
This means any browser page can send requests to the OctoPrint API. Authorization is still required however.
|
||||
|
||||
If CORS is not enabled you will get errors like the following::
|
||||
|
||||
XMLHttpRequest cannot load http://localhost:8081/api/files. No 'Access-Control-Allow-Origin'
|
||||
header is present on the requested resource.
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
.. _sec-api:
|
||||
|
||||
#################
|
||||
API Documentation
|
||||
#################
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
general.rst
|
||||
version.rst
|
||||
apps.rst
|
||||
fileops.rst
|
||||
connection.rst
|
||||
printer.rst
|
||||
printerprofiles.rst
|
||||
job.rst
|
||||
logs.rst
|
||||
slicing.rst
|
||||
push.rst
|
||||
datamodel.rst
|
||||
@@ -0,0 +1,183 @@
|
||||
.. _sec-api-jobs:
|
||||
|
||||
**************
|
||||
Job operations
|
||||
**************
|
||||
|
||||
.. contents::
|
||||
|
||||
.. _sec-api-jobs-command:
|
||||
|
||||
Issue a job command
|
||||
===================
|
||||
|
||||
.. http:post:: /api/job
|
||||
|
||||
Job commands allow starting, pausing and cancelling print jobs. Available commands are:
|
||||
|
||||
start
|
||||
Starts the print of the currently selected file. For selecting a file, see :ref:`Issue a file command <sec-api-fileops-filecommand>`.
|
||||
If a print job is already active, a :http:statuscode:`409` will be returned.
|
||||
|
||||
restart
|
||||
Restart the print of the currently selected file from the beginning. There must be an active print job for this to work
|
||||
and the print job must currently be paused. If either is not the case, a :http:statuscode:`409` will be returned.
|
||||
|
||||
pause
|
||||
Pauses/unpauses the current print job. If no print job is active (either paused or printing), a :http:statuscode:`409`
|
||||
will be returned.
|
||||
|
||||
cancel
|
||||
Cancels the current print job. If no print job is active (either paused or printing), a :http:statuscode:`409`
|
||||
will be returned.
|
||||
|
||||
Upon success, a status code of :http:statuscode:`204` and an empty body is returned.
|
||||
|
||||
**Example Start Request**
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/control/job HTTP/1.1
|
||||
Host: example.com
|
||||
Content-Type: application/json
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
{
|
||||
"command": "start"
|
||||
}
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
**Example Restart Request**
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/control/job HTTP/1.1
|
||||
Host: example.com
|
||||
Content-Type: application/json
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
{
|
||||
"command": "restart"
|
||||
}
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
**Example Pause Request**
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/control/job HTTP/1.1
|
||||
Host: example.com
|
||||
Content-Type: application/json
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
{
|
||||
"command": "pause"
|
||||
}
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
**Example Cancel Request**
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/control/job HTTP/1.1
|
||||
Host: example.com
|
||||
Content-Type: application/json
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
{
|
||||
"command": "cancel"
|
||||
}
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
:json string command: The command to issue, either ``start``, ``restart``, ``pause`` or ``cancel``
|
||||
:statuscode 204: No error
|
||||
:statuscode 409: If the printer is not operational or the current print job state does not match the preconditions
|
||||
for the command.
|
||||
|
||||
.. _sec-api-job-information:
|
||||
|
||||
Retrieve information about the current job
|
||||
==========================================
|
||||
|
||||
.. http:get:: /api/job
|
||||
|
||||
Retrieve information about the current job (if there is one).
|
||||
|
||||
Returns a :http:statuscode:`200` with a :ref:`sec-api-job-datamodel-response` in the body.
|
||||
|
||||
**Example**
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
GET /api/job HTTP/1.1
|
||||
Host: example.com
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"job": {
|
||||
"file": {
|
||||
"name": "whistle_v2.gcode",
|
||||
"origin": "local",
|
||||
"size": 1468987,
|
||||
"date": 1378847754
|
||||
},
|
||||
"estimatedPrintTime": 8811,
|
||||
"filament": {
|
||||
"length": 810,
|
||||
"volume": 5.36
|
||||
}
|
||||
},
|
||||
"progress": {
|
||||
"completion": 0.2298468264184775,
|
||||
"filepos": 337942,
|
||||
"printTime": 276,
|
||||
"printTimeLeft": 912
|
||||
}
|
||||
}
|
||||
|
||||
:statuscode 200: No error
|
||||
|
||||
.. _sec-api-job-datamodel:
|
||||
|
||||
Datamodel
|
||||
=========
|
||||
|
||||
.. _sec-api-job-datamodel-response:
|
||||
|
||||
Job information response
|
||||
------------------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``job``
|
||||
- 1
|
||||
- :ref:`sec-api-datamodel-jobs-job`
|
||||
- Information regarding the target of the current print job
|
||||
* - ``progress``
|
||||
- 1
|
||||
- :ref:`sec-api-datamodel-jobs-progress`
|
||||
- Information regarding the progress of the current print job
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
.. _sec-api-logs:
|
||||
|
||||
*******************
|
||||
Log file management
|
||||
*******************
|
||||
|
||||
.. note::
|
||||
|
||||
All log file management operations require admin rights.
|
||||
|
||||
.. contents::
|
||||
|
||||
.. _sec-api-logs-list:
|
||||
|
||||
Retrieve a list of available log files
|
||||
======================================
|
||||
|
||||
.. http:post:: /api/logs
|
||||
|
||||
Retrieve information regarding all log files currently available and regarding the disk space still available
|
||||
in the system on the location the log files are being stored.
|
||||
|
||||
Returns a :ref:`Logfile Retrieve response <sec-api-logs-datamodel-retrieveresponse>`.
|
||||
|
||||
**Example**
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
GET /api/logs HTTP/1.1
|
||||
Host: example.com
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"files" : [
|
||||
{
|
||||
"date" : 1393158814,
|
||||
"name" : "octoprint.log",
|
||||
"size" : 43712,
|
||||
"refs": {
|
||||
"resource": "http://example.com/api/logs/octoprint.log",
|
||||
"download": "http://example.com/downloads/logs/octoprint.log"
|
||||
}
|
||||
},
|
||||
{
|
||||
"date" : 1392628936,
|
||||
"name" : "octoprint.log.2014-02-17",
|
||||
"size" : 13205,
|
||||
"refs": {
|
||||
"resource": "http://example.com/api/logs/octoprint.log.2014-02-17",
|
||||
"download": "http://example.com/downloads/logs/octoprint.log.2014-02-17"
|
||||
}
|
||||
},
|
||||
{
|
||||
"date" : 1393158814,
|
||||
"name" : "serial.log",
|
||||
"size" : 1798419,
|
||||
"refs": {
|
||||
"resource": "http://example.com/api/logs/serial.log",
|
||||
"download": "http://example.com/downloads/logs/serial.log"
|
||||
}
|
||||
}
|
||||
],
|
||||
"free": 12237201408
|
||||
}
|
||||
|
||||
:statuscode 200: No error
|
||||
:statuscode 403: If the given API token did not have admin rights associated with it
|
||||
|
||||
.. _sec-api-logs-delete:
|
||||
|
||||
Delete a specific logfile
|
||||
=========================
|
||||
|
||||
.. http:delete:: /api/logs/(path:filename)
|
||||
|
||||
Delete the selected log file with name `filename`.
|
||||
|
||||
Returns a :http:statuscode:`204` after successful deletion.
|
||||
|
||||
**Example Request**
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
DELETE /api/logs/octoprint.log.2014-02-17 HTTP/1.1
|
||||
Host: example.com
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
:param filename: The filename of the log file to delete
|
||||
:statuscode 204: No error
|
||||
:statuscode 403: If the given API token did not have admin rights associated with it
|
||||
:statuscode 404: If the file was not found
|
||||
|
||||
.. _sec-api-logs-datamodel:
|
||||
|
||||
Datamodel
|
||||
=========
|
||||
|
||||
.. _sec-api-logs-datamodel-retrieveresponse:
|
||||
|
||||
Logfile Retrieve Response
|
||||
-------------------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``files``
|
||||
- 0..*
|
||||
- Array of :ref:`File information items <sec-api-logs-datamodel-fileinfo>`
|
||||
- The list of requested files. Might be an empty list if no files are available
|
||||
* - ``free``
|
||||
- 1
|
||||
- String
|
||||
- The amount of disk space in bytes available in the local disk space (refers to OctoPrint's ``logs`` folder).
|
||||
|
||||
.. _sec-api-logs-datamodel-fileinfo:
|
||||
|
||||
File information
|
||||
----------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``name``
|
||||
- 1
|
||||
- String
|
||||
- The name of the file
|
||||
* - ``size``
|
||||
- 1
|
||||
- Number
|
||||
- The size of the file in bytes.
|
||||
* - ``date``
|
||||
- 1
|
||||
- Unix timestamp
|
||||
- The timestamp when this file was last modified.
|
||||
* - ``refs``
|
||||
- 1
|
||||
- :ref:`sec-api-logs-datamodel-ref`
|
||||
- References relevant to this file
|
||||
|
||||
.. _sec-api-logs-datamodel-ref:
|
||||
|
||||
References
|
||||
----------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``resource``
|
||||
- 1
|
||||
- URL
|
||||
- The resource that represents the file (e.g. for deleting)
|
||||
* - ``download``
|
||||
- 1
|
||||
- URL
|
||||
- The download URL for the file
|
||||
@@ -0,0 +1,909 @@
|
||||
.. _sec-api-printer:
|
||||
|
||||
******************
|
||||
Printer operations
|
||||
******************
|
||||
|
||||
.. warning::
|
||||
|
||||
This part of the API is still heavily in development, especially anything that has to do with temperature control.
|
||||
If you happen to want to develop against it, you should drop me an email to make sure I can give you a heads-up when
|
||||
something changes.
|
||||
|
||||
.. contents::
|
||||
|
||||
Printer control is mostly achieved through the use of commands, issued to resources reflecting components of the
|
||||
printer. OctoPrint currently knows the following components:
|
||||
|
||||
Print head
|
||||
Print head commands allow jogging and homing the print head in all three axes. Querying the resource is currently
|
||||
not supported.
|
||||
See :ref:`sec-api-printer-printheadcommand`.
|
||||
Tool
|
||||
Tool commands allow setting the temperature and temperature offsets for the printer's hotends/tools. Querying the
|
||||
corresponding resource returns temperature information including an optional history.
|
||||
See :ref:`sec-api-printer-toolcommand`.
|
||||
Bed
|
||||
Bed commands allow setting the temperature and temperature offset for the printer's heated bed. Querying the
|
||||
corresponding resource returns temperature information including an optional history.
|
||||
See :ref:`sec-api-printer-bedcommand`.
|
||||
SD card
|
||||
SD commands allow initialization, refresh and release of the printer's SD card (if available). Querying the
|
||||
corresponding resource returns the current SD card state.
|
||||
See :ref:`sec-api-printer-sdcommand`.
|
||||
|
||||
Besides that, OctoPrint also provides a :ref:`full state report of the printer <sec-api-printer-state>`.
|
||||
|
||||
.. _sec-api-printer-state:
|
||||
|
||||
Retrieve the current printer state
|
||||
==================================
|
||||
|
||||
.. http:get:: /api/printer
|
||||
|
||||
Retrieves the current state of the printer. Returned information includes:
|
||||
|
||||
* temperature information (see also :ref:`Retrieve the current tool state <sec-api-printer-toolstate>` and
|
||||
:ref:`Retrieve the current bed state <sec-api-printer-bedstate>`)
|
||||
* sd state (if available, see also :ref:`Retrieve the current SD state <sec-api-printer-sdstate>`)
|
||||
* general printer state
|
||||
|
||||
Temperature information can also be made to include the printer's temperature history by supplying the ``history``
|
||||
query parameter. The amount of data points to return here can be limited using the ``limit`` query parameter.
|
||||
|
||||
Clients can specific a list of attributes to not return in the response (e.g. if they don't need it) via the
|
||||
``exclude`` query parameter.
|
||||
|
||||
Returns a :http:statuscode:`200` with a :ref:`Full State Response <sec-api-printer-datamodel-fullstate>` in the
|
||||
body upon success.
|
||||
|
||||
**Example 1**
|
||||
|
||||
Include temperature history data, but limit it to two entries.
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
GET /api/printer?history=true&limit=2 HTTP/1.1
|
||||
Host: example.com
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"temperature": {
|
||||
"tool0": {
|
||||
"actual": 214.8821,
|
||||
"target": 220.0,
|
||||
"offset": 0
|
||||
},
|
||||
"tool1": {
|
||||
"actual": 25.3,
|
||||
"target": null,
|
||||
"offset": 0
|
||||
},
|
||||
"bed": {
|
||||
"actual": 50.221,
|
||||
"target": 70.0,
|
||||
"offset": 5
|
||||
},
|
||||
"history": [
|
||||
{
|
||||
"time": 1395651928,
|
||||
"tool0": {
|
||||
"actual": 214.8821,
|
||||
"target": 220.0
|
||||
},
|
||||
"tool1": {
|
||||
"actual": 25.3,
|
||||
"target": null
|
||||
},
|
||||
"bed": {
|
||||
"actual": 50.221,
|
||||
"target": 70.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"time": 1395651926,
|
||||
"tool0": {
|
||||
"actual": 212.32,
|
||||
"target": 220.0
|
||||
},
|
||||
"tool1": {
|
||||
"actual": 25.1,
|
||||
"target": null
|
||||
},
|
||||
"bed": {
|
||||
"actual": 49.1123,
|
||||
"target": 70.0
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"sd": {
|
||||
"ready": true
|
||||
},
|
||||
"state": {
|
||||
"text": "Operational",
|
||||
"flags": {
|
||||
"operational": true,
|
||||
"paused": false,
|
||||
"printing": false,
|
||||
"sdReady": true,
|
||||
"error": false,
|
||||
"ready": true,
|
||||
"closedOrError": false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
**Example 2**
|
||||
|
||||
Exclude temperature and sd data.
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
GET /api/printer?exclude=temperature,sd HTTP/1.1
|
||||
Host: example.com
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"state": {
|
||||
"text": "Operational",
|
||||
"flags": {
|
||||
"operational": true,
|
||||
"paused": false,
|
||||
"printing": false,
|
||||
"sdReady": true,
|
||||
"error": false,
|
||||
"ready": true,
|
||||
"closedOrError": false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:query exclude: An optional comma-separated list of fields to exclude from the response (e.g. if not needed by
|
||||
the client). Valid values to supply here are ``temperature``, ``sd`` and ``state``.
|
||||
:query history: If set to ``true`` (or: ``yes``, ``y``, ``1``), history information will be included in the response
|
||||
too. If no ``limit`` parameter is given, all available temperature history data will be returned.
|
||||
:query limit: If set to an integer (``n``), only the last ``n`` data points from the printer's temperature history
|
||||
will be returned. Will be ignored if ``history`` is not enabled.
|
||||
:statuscode 200: No error
|
||||
:statuscode 409: If the printer is not operational.
|
||||
|
||||
.. _sec-api-printer-printheadcommand:
|
||||
|
||||
Issue a print head command
|
||||
==========================
|
||||
|
||||
.. http:post:: /api/printer/printhead
|
||||
|
||||
Print head commands allow jogging and homing the print head in all three axes. Available commands are:
|
||||
|
||||
jog
|
||||
Jogs the print head (relatively) by a defined amount in one or more axes. Additional parameters are:
|
||||
|
||||
* ``x``: Optional. Amount to jog print head on x axis, must be a valid number corresponding to the distance to travel in mm.
|
||||
* ``y``: Optional. Amount to jog print head on y axis, must be a valid number corresponding to the distance to travel in mm.
|
||||
* ``z``: Optional. Amount to jog print head on z axis, must be a valid number corresponding to the distance to travel in mm.
|
||||
|
||||
home
|
||||
Homes the print head in all of the given axes. Additional parameters are:
|
||||
|
||||
* ``axes``: A list of axes which to home, valid values are one or more of ``x``, ``y``, ``z``.
|
||||
|
||||
All of these commands may only be sent if the printer is currently operational and not printing. Otherwise a
|
||||
:http:statuscode:`409` is returned.
|
||||
|
||||
Upon success, a status code of :http:statuscode:`204` and an empty body is returned.
|
||||
|
||||
**Example Jog Request**
|
||||
|
||||
Jog the print head by 10mm in X, -5mm in Y and 0.02mm in Z.
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/printer/printhead HTTP/1.1
|
||||
Host: example.com
|
||||
Content-Type: application/json
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
{
|
||||
"command": "jog",
|
||||
"x": 10,
|
||||
"y": -5,
|
||||
"z": 0.02
|
||||
}
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
**Example Home Request**
|
||||
|
||||
Home the X and Y axes.
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/printer/printhead HTTP/1.1
|
||||
Host: example.com
|
||||
Content-Type: application/json
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
{
|
||||
"command": "home",
|
||||
"axes": ["x", "y"]
|
||||
}
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
:json string command: The command to issue, either ``jog`` or ``home``.
|
||||
:json number x: ``jog`` command: The amount to travel on the X axis in mm.
|
||||
:json number y: ``jog`` command: The amount to travel on the Y axis in mm.
|
||||
:json number z: ``jog`` command: The amount to travel on the Z axis in mm.
|
||||
:json array axes: ``home`` command: The axes which to home, valid values are one or more of ``x``, ``y`` and ``z``.
|
||||
:statuscode 204: No error
|
||||
:statuscode 400: Invalid axis specified, invalid value for travel amount for a jog command or otherwise invalid
|
||||
request.
|
||||
:statuscode 409: If the printer is not operational or currently printing.
|
||||
|
||||
.. _sec-api-printer-toolcommand:
|
||||
|
||||
Issue a tool command
|
||||
====================
|
||||
|
||||
.. http:post:: /api/printer/tool
|
||||
|
||||
Tool commands allow setting the temperature and temperature offsets for the printer's tools (hotends), selecting
|
||||
the current tool and extruding/retracting from the currently selected tool. Available commands are:
|
||||
|
||||
target
|
||||
Sets the given target temperature on the printer's tools. Additional parameters:
|
||||
|
||||
* ``targets``: Target temperature(s) to set, properties must match the format ``tool{n}`` with ``n`` being the
|
||||
tool's index starting with 0.
|
||||
|
||||
offset
|
||||
Sets the given temperature offset on the printer's tools. Additional parameters:
|
||||
|
||||
* ``offsets``: Offset(s) to set, properties must match the format ``tool{n}`` with ``n`` being the tool's index
|
||||
starting with 0.
|
||||
|
||||
select
|
||||
Selects the printer's current tool. Additional parameters:
|
||||
|
||||
* ``tool``: Tool to select, format ``tool{n}`` with ``n`` being the tool's index starting with 0.
|
||||
|
||||
extrude
|
||||
Extrudes the given amount of filament from the currently selected tool. Additional parameters:
|
||||
|
||||
* ``amount``: The amount of filament to extrude in mm. May be negative to retract.
|
||||
|
||||
|
||||
All of these commands may only be sent if the printer is currently operational and -- in case of ``select`` and
|
||||
``extrude`` -- not printing. Otherwise a :http:statuscode:`409` is returned.
|
||||
|
||||
Upon success, a status code of :http:statuscode:`204` and an empty body is returned.
|
||||
|
||||
**Example Target Temperature Request**
|
||||
|
||||
Set the target temperature for the printer's first hotend to 220°C and the printer's second extruder to 205°C.
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/printer/tool HTTP/1.1
|
||||
Host: example.com
|
||||
Content-Type: application/json
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
{
|
||||
"command": "target",
|
||||
"targets": {
|
||||
"tool0": 220,
|
||||
"tool1": 205
|
||||
}
|
||||
}
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
**Example Offset Temperature Request**
|
||||
|
||||
Set the offset for temperatures on ``tool0`` to +10°C and on ``tool1`` to -5°C.
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/printer/tool HTTP/1.1
|
||||
Host: example.com
|
||||
Content-Type: application/json
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
{
|
||||
"command": "offset",
|
||||
"offsets": {
|
||||
"tool0": 10,
|
||||
"tool1": -5
|
||||
}
|
||||
}
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
**Example Tool Select Request**
|
||||
|
||||
Select the second hotend of the printer for any following ``extrude`` commands.
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/printer/tool HTTP/1.1
|
||||
Host: example.com
|
||||
Content-Type: application/json
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
{
|
||||
"command": "select",
|
||||
"tool": "tool1"
|
||||
}
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
**Example Extrude Request**
|
||||
|
||||
Extrude 5mm on the currently selected tool.
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/printer/tool HTTP/1.1
|
||||
Host: example.com
|
||||
Content-Type: application/json
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
{
|
||||
"command": "extrude",
|
||||
"amount": 5
|
||||
}
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
**Example Retract Request**
|
||||
|
||||
Retract 3mm of filament on the currently selected tool.
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/printer/tool HTTP/1.1
|
||||
Host: example.com
|
||||
Content-Type: application/json
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
{
|
||||
"command": "extrude",
|
||||
"amount": -3
|
||||
}
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
:json string command: The command to issue, either ``target``, ``offset``, ``select`` or ``extrude``.
|
||||
:json object targets: ``target`` command: The target temperatures to set. Valid properties have to match the format ``tool{n}``.
|
||||
:json object offsets: ``offset`` command: The offset temperature to set. Valid properties have to match the format ``tool{n}``.
|
||||
:json object tool: ``select`` command: The tool to select, value has to match the format ``tool{n}``.
|
||||
:json object amount: ``extrude`` command: The amount of filament to extrude from the currently selected tool.
|
||||
:statuscode 204: No error
|
||||
:statuscode 400: If ``targets`` or ``offsets`` contains a property or ``tool`` contains a value not matching the format
|
||||
``tool{n}``, the target/offset temperature or extrusion amount is not a valid number or outside of
|
||||
the supported range, or if the request is otherwise invalid.
|
||||
:statuscode 409: If the printer is not operational or -- in case of ``select`` or ``extrude`` -- currently printing.
|
||||
|
||||
.. _sec-api-printer-toolstate:
|
||||
|
||||
Retrieve the current tool state
|
||||
===============================
|
||||
|
||||
.. http:get:: /api/printer/tool
|
||||
|
||||
Retrieves the current temperature data (actual, target and offset) plus optionally a (limited) history (actual, target,
|
||||
timestamp) for all of the printer's available tools.
|
||||
|
||||
It's also possible to retrieve the temperature history by supplying the ``history`` query parameter set to ``true``. The
|
||||
amount of returned history data points can be limited using the ``limit`` query parameter.
|
||||
|
||||
Returns a :http:statuscode:`200` with a Temperature Response in the body upon success.
|
||||
|
||||
.. note::
|
||||
If you want both tool and bed temperature information at the same time, take a look at
|
||||
:ref:`Retrieve the current printer state <sec-api-printer-state>`.
|
||||
|
||||
**Example**
|
||||
|
||||
Query the tool temperature data and also include the temperature history but limit it to two entries.
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
GET /api/printer/tool?history=true&limit=2 HTTP/1.1
|
||||
Host: example.com
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"tool0": {
|
||||
"actual": 214.8821,
|
||||
"target": 220.0,
|
||||
"offset": 0
|
||||
},
|
||||
"tool1": {
|
||||
"actual": 25.3,
|
||||
"target": null,
|
||||
"offset": 0
|
||||
},
|
||||
"history": [
|
||||
{
|
||||
"time": 1395651928,
|
||||
"tool0": {
|
||||
"actual": 214.8821,
|
||||
"target": 220.0
|
||||
},
|
||||
"tool1": {
|
||||
"actual": 25.3,
|
||||
"target": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"time": 1395651926,
|
||||
"tool0": {
|
||||
"actual": 212.32,
|
||||
"target": 220.0
|
||||
},
|
||||
"tool1": {
|
||||
"actual": 25.1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
:query history: If set to ``true`` (or: ``yes``, ``y``, ``1``), history information will be included in the response
|
||||
too. If no ``limit`` parameter is given, all available temperature history data will be returned.
|
||||
:query limit: If set to an integer (``n``), only the last ``n`` data points from the printer's temperature history
|
||||
will be returned. Will be ignored if ``history`` is not enabled.
|
||||
:statuscode 200: No error
|
||||
:statuscode 409: If the printer is not operational.
|
||||
|
||||
.. _sec-api-printer-bedcommand:
|
||||
|
||||
Issue a bed command
|
||||
===================
|
||||
|
||||
.. http:post:: /api/printer/bed
|
||||
|
||||
Bed commands allow setting the temperature and temperature offsets for the printer's heated bed. Available commands
|
||||
are:
|
||||
|
||||
target
|
||||
Sets the given target temperature on the printer's tools. Additional parameters:
|
||||
|
||||
* ``target``: Target temperature to set.
|
||||
|
||||
offset
|
||||
Sets the given temperature offset on the printer's tools. Additional parameters:
|
||||
|
||||
* ``offset``: Offset to set.
|
||||
|
||||
All of these commands may only be sent if the printer is currently operational. Otherwise a :http:statuscode:`409`
|
||||
is returned.
|
||||
|
||||
Upon success, a status code of :http:statuscode:`204` and an empty body is returned.
|
||||
|
||||
**Example Target Temperature Request**
|
||||
|
||||
Set the target temperature for the printer's heated bed to 75°C.
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/printer/bed HTTP/1.1
|
||||
Host: example.com
|
||||
Content-Type: application/json
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
{
|
||||
"command": "target",
|
||||
"target": 75
|
||||
}
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
**Example Offset Temperature Request**
|
||||
|
||||
Set the temperature offset for the heated bed to -5°C.
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/printer/bed HTTP/1.1
|
||||
Host: example.com
|
||||
Content-Type: application/json
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
{
|
||||
"command": "offset",
|
||||
"offset": -5
|
||||
}
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
:json string command: The command to issue, either ``target`` or ``offset``.
|
||||
:json object target: ``target`` command: The target temperature to set.
|
||||
:json object offset: ``offset`` command: The offset temperature to set.
|
||||
:statuscode 204: No error
|
||||
:statuscode 400: If ``target`` or ``offset`` is not a valid number or outside of the supported range, or if the
|
||||
request is otherwise invalid.
|
||||
:statuscode 409: If the printer is not operational.
|
||||
|
||||
.. _sec-api-printer-bedstate:
|
||||
|
||||
Retrieve the current bed state
|
||||
==============================
|
||||
|
||||
.. http:get:: /api/printer/bed
|
||||
|
||||
Retrieves the current temperature data (actual, target and offset) plus optionally a (limited) history (actual, target,
|
||||
timestamp) for the printer's heated bed.
|
||||
|
||||
It's also possible to retrieve the temperature history by supplying the ``history`` query parameter set to ``true``. The
|
||||
amount of returned history data points can be limited using the ``limit`` query parameter.
|
||||
|
||||
Returns a :http:statuscode:`200` with a Temperature Response in the body upon success.
|
||||
|
||||
.. note::
|
||||
If you want both tool and bed temperature information at the same time, take a look at
|
||||
:ref:`Retrieve the current printer state <sec-api-printer-state>`.
|
||||
|
||||
**Example**
|
||||
|
||||
Query the bed temperature data and also include the temperature history but limit it to two entries.
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
GET /api/printer/bed?history=true&limit=2 HTTP/1.1
|
||||
Host: example.com
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"bed": {
|
||||
"actual": 50.221,
|
||||
"target": 70.0,
|
||||
"offset": 5
|
||||
},
|
||||
"history": [
|
||||
{
|
||||
"time": 1395651928,
|
||||
"bed": {
|
||||
"actual": 50.221,
|
||||
"target": 70.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"time": 1395651926,
|
||||
"bed": {
|
||||
"actual": 49.1123,
|
||||
"target": 70.0
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
:query history: If set to ``true`` (or: ``yes``, ``y``, ``1``), history information will be included in the response
|
||||
too. If no ``limit`` parameter is given, all available temperature history data will be returned.
|
||||
:query limit: If set to an integer (``n``), only the last ``n`` data points from the printer's temperature history
|
||||
will be returned. Will be ignored if ``history`` is not enabled.
|
||||
:statuscode 200: No error
|
||||
:statuscode 409: If the printer is not operational.
|
||||
|
||||
.. _sec-api-printer-sdcommand:
|
||||
|
||||
Issue an SD command
|
||||
===================
|
||||
|
||||
.. http:post:: /api/printer/sd
|
||||
|
||||
SD commands allow initialization, refresh and release of the printer's SD card (if available).
|
||||
|
||||
Available commands are:
|
||||
|
||||
init
|
||||
Initializes the printer's SD card, making it available for use. This also includes an initial retrieval of the
|
||||
list of files currently stored on the SD card, so after issueing that command a :ref:`retrieval of the files
|
||||
on SD card <sec-api-fileops-retrievelocation>` will return a successful result.
|
||||
|
||||
.. note::
|
||||
If OctoPrint detects the availability of a SD card on the printer during connection, it will automatically attempt
|
||||
to initialize it.
|
||||
|
||||
refresh
|
||||
Refreshes the list of files stored on the printer's SD card. Will return a :http:statuscode:`409` if the card
|
||||
has not been initialized yet (see the ``init`` command and :ref:`SD state <sec-api-printer-sdstate>`).
|
||||
|
||||
release
|
||||
Releases the SD card from the printer. The reverse operation to ``init``. After issuing this command, the SD
|
||||
card won't be available anymore, hence and operations targeting files stored on it will fail. Will return a :http:statuscode:`409`
|
||||
if the card has not been initialized yet (see the ``init`` command and :ref:`SD state <sec-api-printer-sdstate>`).
|
||||
|
||||
Upon success, a status code of :http:statuscode:`204` and an empty body is returned.
|
||||
|
||||
**Example Init Request**
|
||||
|
||||
Initialize the SD card.
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/printer/sd HTTP/1.1
|
||||
Host: example.com
|
||||
Content-Type: application/json
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
{
|
||||
"command": "init"
|
||||
}
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
**Example Refresh Request**
|
||||
|
||||
Refresh the file list of the SD card
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/printer/sd HTTP/1.1
|
||||
Host: example.com
|
||||
Content-Type: application/json
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
{
|
||||
"command": "refresh"
|
||||
}
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
**Example Release Request**
|
||||
|
||||
Release the SD card
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/printer/sd HTTP/1.1
|
||||
Host: example.com
|
||||
Content-Type: application/json
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
{
|
||||
"command": "release"
|
||||
}
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
:json string command: The command to issue, either ``init``, ``refresh`` or ``release``.
|
||||
:statuscode 204: No error
|
||||
:statuscode 409: If a ``refresh`` or ``release`` command is issued but the SD card has not been initialized (e.g.
|
||||
via ``init``.
|
||||
|
||||
.. _sec-api-printer-sdstate:
|
||||
|
||||
Retrieve the current SD state
|
||||
=============================
|
||||
|
||||
.. http:get:: /api/printer/sd
|
||||
|
||||
Retrieves the current state of the printer's SD card. For this request no authentication is needed.
|
||||
|
||||
If SD support has been disabled in OctoPrint's settings, a :http:statuscode:`404` is returned.
|
||||
|
||||
Returns a :http:statuscode:`200` with an :ref:`SD State Response <sec-api-printer-datamodel-sdstate>` in the body
|
||||
upon success.
|
||||
|
||||
**Example**
|
||||
|
||||
Read the current state of the SD card.
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
GET /api/printer/sd HTTP/1.1
|
||||
Host: example.com
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"ready": true
|
||||
}
|
||||
|
||||
:statuscode 200: No error
|
||||
:statuscode 404: If SD support has been disabled in OctoPrint's config.
|
||||
|
||||
.. _sec-api-printer-arbcommand:
|
||||
|
||||
Send an arbitrary command to the printer
|
||||
========================================
|
||||
|
||||
.. http:post:: /api/printer/command
|
||||
|
||||
Sends any command to the printer via the serial interface. Should be used with some care as some commands can interfere with
|
||||
or even stop a running print job.
|
||||
|
||||
Expects a :ref:`Arbitrary Command Request <sec-api-printer-datamodel-arbcommand>` as the request's body.
|
||||
|
||||
If successful returns a :http:statuscode:`204` and an empty body.
|
||||
|
||||
**Example for sending a single command**
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/printer/command HTTP/1.1
|
||||
Host: example.com
|
||||
Content-Type: application/json
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
{
|
||||
"command": "M106"
|
||||
}
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
**Example for sending multiple commands**
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
POST /api/printer/command HTTP/1.1
|
||||
Host: example.com
|
||||
Content-Type: application/json
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
{
|
||||
"commands": [
|
||||
"M18",
|
||||
"M106 S0"
|
||||
]
|
||||
}
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 204 No Content
|
||||
|
||||
:json string command: Single command to send to the printer, mutually exclusive with ``commands``.
|
||||
:json string commands: List of commands to send to the printer, mutually exclusive with ``command``.
|
||||
:statuscode 204: No error
|
||||
|
||||
.. _sec-api-printer-datamodel:
|
||||
|
||||
Datamodel
|
||||
=========
|
||||
|
||||
.. _sec-api-printer-datamodel-fullstate:
|
||||
|
||||
Full State Response
|
||||
-------------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``temperature``
|
||||
- 0..1
|
||||
- :ref:`Temperature State <sec-api-printer-datamodel-temps>`
|
||||
- The printer's temperature state data
|
||||
* - ``sd``
|
||||
- 0..1
|
||||
- :ref:`SD State <sec-api-printer-datamodel-sdstate>`
|
||||
- The printer's sd state data
|
||||
* - ``state``
|
||||
- 0..1
|
||||
- :ref:`Printer State <sec-api-datamodel-printer-state>`
|
||||
- The printer's general state
|
||||
|
||||
.. _sec-api-printer-datamodel-temps:
|
||||
|
||||
Temperature State
|
||||
-----------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``tool{n}``
|
||||
- 0..*
|
||||
- :ref:`Temperature Data <sec-api-datamodel-printer-tempdata>`
|
||||
- Current temperature stats for tool *n*. Enumeration starts at 0 for the first tool. Not included if querying
|
||||
only bed state.
|
||||
* - ``bed``
|
||||
- 0..1
|
||||
- :ref:`Temperature Data <sec-api-datamodel-printer-tempdata>`
|
||||
- Current temperature stats for the printer's heated bed. Not included if querying only tool state.
|
||||
* - ``history``
|
||||
- 0..1
|
||||
- List of :ref:`Historic Temperature Datapoint <sec-api-datamodel-printer-temphistory>`
|
||||
- Temperature history
|
||||
|
||||
.. _sec-api-printer-datamodel-sdstate:
|
||||
|
||||
SD State
|
||||
--------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``ready``
|
||||
- 1
|
||||
- Boolean
|
||||
- Whether the SD card has been initialized (``true``) or not (``false``).
|
||||
|
||||
.. _sec-api-printer-datamodel-arbcommand:
|
||||
|
||||
Arbitrary Command Request
|
||||
-------------------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``command``
|
||||
- 0..1
|
||||
- String
|
||||
- Single command to send to the printer, mutually exclusive with ``commands``.
|
||||
* - ``commands``
|
||||
- 0..*
|
||||
- Array of String
|
||||
- Multiple commands to send to the printer (in the given order), mutually exclusive with ``command``.
|
||||
@@ -0,0 +1,190 @@
|
||||
.. _sec-api-printerprofiles:
|
||||
|
||||
**************************
|
||||
Printer profile operations
|
||||
**************************
|
||||
|
||||
.. contents::
|
||||
|
||||
OctoPrint allows the management of Printer profiles that define a printer's physical properties (such as print volume,
|
||||
whether a heated bed is available, maximum speeds on its axes etc). The data stored within these profiles is used
|
||||
for both slicing and gcode visualization.
|
||||
|
||||
.. _sec-api-printerprofiles-retrieve:
|
||||
|
||||
Retrieve all printer profiles
|
||||
=============================
|
||||
|
||||
.. http:get:: /api/printerprofiles
|
||||
|
||||
.. _sec-api-printerprofiles-add:
|
||||
|
||||
Add a new printer profile
|
||||
=========================
|
||||
|
||||
.. http:post:: /api/printerprofiles
|
||||
|
||||
.. _sec-api-printerporfiles-update:
|
||||
|
||||
Update an existing printer profile
|
||||
==================================
|
||||
|
||||
.. http:patch:: /api/printerprofiles/(string:profile)
|
||||
|
||||
.. _sec-api-printerprofiles-delete:
|
||||
|
||||
Remove an existing printer profile
|
||||
==================================
|
||||
|
||||
.. http:delete:: /api/printerprofiles/(string:profile)
|
||||
|
||||
.. _sec-api-printerprofiles-datamodel:
|
||||
|
||||
Datamodel
|
||||
=========
|
||||
|
||||
.. _sec-api-printerprofiles-datamodel-profilelist:
|
||||
|
||||
Profile list
|
||||
------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``profiles``
|
||||
- 1
|
||||
- Object
|
||||
- Collection of all printer profiles available in the system
|
||||
* - ``profiles.<profile id>``
|
||||
- 0..1
|
||||
- :ref:`Profile <sec-api-slicing-datamodel-profile>`
|
||||
- Information about a profile stored in the system.
|
||||
|
||||
.. _sec-api-slicing-datamodel-update:
|
||||
|
||||
Add or update request
|
||||
---------------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``profiles``
|
||||
- 1
|
||||
- :ref:`Profile <sec-api-slicing-datamodel-profile>`
|
||||
- Information about the profile being added/updated. For adding new profiles, all fields must be populated. For updating
|
||||
and existing profile, only the values to be overwritten need to be supplied.
|
||||
|
||||
.. _sec-api-slicing-datamodel-profile:
|
||||
|
||||
Profile
|
||||
-------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``id``
|
||||
- 0..1
|
||||
- ``string``
|
||||
- Identifier of the profile. Will always be
|
||||
returned in responses but can be left out of save/update requests.
|
||||
* - ``name``
|
||||
- 0..1
|
||||
- ``string``
|
||||
- Display name of the profile. Will always be
|
||||
returned in responses but can be left out of save/update requests.
|
||||
* - ``color``
|
||||
- 0..1
|
||||
- ``string``
|
||||
- The color to associate with this profile (used in the UI's title bar). Valid values are "default", "red", "orange",
|
||||
"yellow", "green", "blue", "black". Will always be
|
||||
returned in responses but can be left out of save/update requests.
|
||||
* - ``model``
|
||||
- 0..1
|
||||
- ``string``
|
||||
- Printer model of the profile. Will always be
|
||||
returned in responses but can be left out of save/update requests.
|
||||
* - ``default``
|
||||
- 0..1
|
||||
- ``boolean``
|
||||
- Whether this is the default profile to be used with new connections (``true``) or not (``false``). Will always be
|
||||
returned in responses but can be left out of save/update requests.
|
||||
* - ``current``
|
||||
- 0..1
|
||||
- ``boolean``
|
||||
- Whether this is the profile currently active. Will always be returned in responses but ignored in save/update
|
||||
requests.
|
||||
* - ``resource``
|
||||
- 0..1
|
||||
- ``URL``
|
||||
- Resource URL of the profile, will always be returned in responses but can be left out of save/update requests.
|
||||
* - ``volume``
|
||||
- 0..1
|
||||
- Object
|
||||
- The print volume, will always be returned in responses but can be left out of save/update requests.
|
||||
* - ``volume.formFactor``
|
||||
- 0..1
|
||||
- ``string``
|
||||
- The form factor of the printer's bed, valid values are "rectangular" and "circular"
|
||||
* - ``volume.width``
|
||||
- 0..1
|
||||
- ``float``
|
||||
- The width of the print volume
|
||||
* - ``volume.depth``
|
||||
- 0..1
|
||||
- ``float``
|
||||
- The depth of the print volume
|
||||
* - ``volume.height``
|
||||
- 0..1
|
||||
- ``float``
|
||||
- The height of the print volume
|
||||
* - ``heatedBed``
|
||||
- 0..1
|
||||
- ``boolean``
|
||||
- Whether the printer has a heated bed (``true``) or not (``false``)
|
||||
* - ``axes``
|
||||
- 0..1
|
||||
- Object
|
||||
- Description of the printer's axes properties, one entry each for ``x``, ``y``, ``z`` and ``e`` holding maxium speed
|
||||
and whether this axis is inverted or not.
|
||||
* - ``axes.{axis}.speed``
|
||||
- 0..1
|
||||
- ``int``
|
||||
- Maximum speed of the axis in mm/s.
|
||||
* - ``axes.{axis}.inverted``
|
||||
- 0..1
|
||||
- ``boolean``
|
||||
- Whether the axis is inverted or not.
|
||||
* - ``extruder``
|
||||
- 0..1
|
||||
- Object
|
||||
- Information about the printer's extruders
|
||||
* - ``extruder.nozzleDiameter``
|
||||
- 0..1
|
||||
- ``float``
|
||||
- The diameter of the printer's nozzle(s) in mm.
|
||||
* - ``extruder.count``
|
||||
- 0..1
|
||||
- ``int``
|
||||
- Count of extruders on the printer (defaults to 1)
|
||||
* - ``extruder.offsets``
|
||||
- 0..1
|
||||
- Array of ``float`` tuples
|
||||
- Tuple of (x, y) values describing the offsets of the other extruders relative to the first extruder. E.g. for a
|
||||
printer with two extruders, if the second extruder is offset by 20mm in the X and 25mm in the Y direction, this
|
||||
array will read ``[ [0.0, 0.0], [20.0, 25.0] ]``
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
.. _sec-api-push:
|
||||
|
||||
************
|
||||
Push updates
|
||||
************
|
||||
|
||||
.. warning::
|
||||
|
||||
The interface documented here is the status quo that might be changed while the interfaces are streamlined for
|
||||
a more general consumption. If you happen to want to develop against it, you should drop me an email to make sure I can give you a heads-up when
|
||||
something changes.
|
||||
|
||||
.. contents::
|
||||
|
||||
To enable real time information exchange between client and server, OctoPrint uses
|
||||
`SockJS <https://github.com/sockjs/sockjs-protocol>`_ to push
|
||||
status updates, temperature changes etc to connected web interface instances.
|
||||
|
||||
Each pushed message consists of a simple JSON object that follows this basic structure:
|
||||
|
||||
.. sourcecode:: javascript
|
||||
|
||||
{
|
||||
"<type>": <payload>
|
||||
}
|
||||
|
||||
``type`` indicates the type of message being pushed to the client, the attached ``payload`` is message specific. The
|
||||
following message types are currently available for usage by 3rd party clients:
|
||||
|
||||
* ``current``: Rate limited general state update, payload contains information about the printer's state, job progress,
|
||||
accumulated temperature points and log lines since last update. OctoPrint will send these updates when new information
|
||||
is available, but not more often than twice per second in order to not flood the client with messages (e.g.
|
||||
during printing). See :ref:`the payload data model <sec-api-push-datamodel-currentandhistory>`.
|
||||
* ``history``: Current state, temperature and log history, sent upon initial connect to get the client up to date. Same
|
||||
payload data model as ``current``, see :ref:`below <sec-api-push-datamodel-currentandhistory>`.
|
||||
* ``event``: Events triggered within OctoPrint, such as e.g. ``PrintFailed`` or ``MovieRenderDone``. Payload is the event
|
||||
type and payload, see :ref:`below <sec-api-push-datamodel-event>`. Sent when an event is triggered internally.
|
||||
* ``slicingProgress``: Progress updates from an active slicing background job, payload contains information about the
|
||||
model being sliced, the target file, the slicer being used and the progress as a percentage.
|
||||
See :ref:`the payload data model <sec-api-push-datamodel-slicingprogress>`.
|
||||
|
||||
Clients must ignore any unknown messages.
|
||||
|
||||
The data model of the attached payloads is described further below.
|
||||
|
||||
.. _sec-api-push-datamodel:
|
||||
|
||||
Datamodel
|
||||
=========
|
||||
|
||||
.. _sec-api-push-datamodel-currentandhistory:
|
||||
|
||||
``current`` and ``history`` payload
|
||||
-----------------------------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``state``
|
||||
- 1
|
||||
- :ref:`State information <sec-api-datamodel-printer-state>`
|
||||
- Information about the current machine state
|
||||
* - ``job``
|
||||
- 1
|
||||
- :ref:`Job information <sec-api-datamodel-jobs-job>`
|
||||
- Information about the currently active print job
|
||||
* - ``progress``
|
||||
- 1
|
||||
- :ref:`Progress information <sec-api-datamodel-jobs-progress>`
|
||||
- Information about the current print/streaming progress
|
||||
* - ``currentZ``
|
||||
- 1
|
||||
- Float
|
||||
- Current height of the Z-Axis (= current height of model) during printing from a local file
|
||||
* - ``offsets``
|
||||
- 0..1
|
||||
- :ref:`Temperature offsets <sec-api-datamodel-printer-tempoffset>`
|
||||
- Currently configured temperature offsets
|
||||
* - ``temps``
|
||||
- 0..*
|
||||
- List of :ref:`Temperature Data Points <sec-api-datamodel-printer-temphistory>`
|
||||
- Temperature data points for plotting
|
||||
* - ``logs``
|
||||
- 0..*
|
||||
- List of String
|
||||
- Lines for the serial communication log (send/receive)
|
||||
* - ``messages``
|
||||
- 0..*
|
||||
- List of String
|
||||
- Lines for the serial communication log (special messages)
|
||||
|
||||
.. _sec-api-push-datamodel-event:
|
||||
|
||||
``event`` payload
|
||||
-----------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``type``
|
||||
- 1
|
||||
- String
|
||||
- Name of the event
|
||||
* - ``payload``
|
||||
- 1
|
||||
- Object
|
||||
- Payload associated with the event
|
||||
|
||||
.. _sec-api-push-datamodel-slicingprogress:
|
||||
|
||||
``slicingProgress`` payload
|
||||
---------------------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``slicer``
|
||||
- 1
|
||||
- String
|
||||
- Name of the slicer used
|
||||
* - ``source_location``
|
||||
- 1
|
||||
- String
|
||||
- Location of the source file being sliced, at the moment either ``local`` or ``sdcard``
|
||||
* - ``source_path``
|
||||
- 1
|
||||
- String
|
||||
- Path of the source file being sliced (e.g. an STL file)
|
||||
* - ``dest_location``
|
||||
- 1
|
||||
- String
|
||||
- Location of the destination file being created, at the moment either ``local`` or ``sdcard``
|
||||
* - ``dest_path``
|
||||
- 1
|
||||
- String
|
||||
- Path of the destination file being sliced (e.g. a GCODE file)
|
||||
* - ``progress``
|
||||
- 1
|
||||
- Number (Float)
|
||||
- Percentage of slicing job already completed
|
||||
@@ -0,0 +1,336 @@
|
||||
.. _sec-api-slicing:
|
||||
|
||||
*******
|
||||
Slicing
|
||||
*******
|
||||
|
||||
.. warning::
|
||||
|
||||
The interface documented here is the status quo that might be changed while the interfaces are streamlined for
|
||||
a more general consumption. If you happen to want to develop against it, you should drop me an email to make sure I can give you a heads-up when
|
||||
something changes.
|
||||
|
||||
.. contents::
|
||||
|
||||
The Slicing API on one hand offers methods for managing slicing profiles stored within OctoPrint, on the other hand
|
||||
it will be extended in the future to also allow for multi extruder slicing (which currently is not possible with the
|
||||
``slice`` command of the :ref:`File operations API <sec-api-fileops-filecommand>` and other things.
|
||||
|
||||
.. _sec-api-slicing-listall:
|
||||
|
||||
List All Slicers and Slicing Profiles
|
||||
=====================================
|
||||
|
||||
.. http:get:: /api/slicing
|
||||
|
||||
Returns a list of all available slicing profiles for all registered slicers in the system.
|
||||
|
||||
Returns a :http:statuscode:`200` response with a :ref:`Slicer list <sec-api-slicing-datamodel-slicerlist>`
|
||||
as the body upon successful completion.
|
||||
|
||||
**Example**
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
GET /api/slicing/profiles HTTP/1.1
|
||||
Host: example.com
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"cura": {
|
||||
"key": "cura",
|
||||
"displayName": "CuraEngine",
|
||||
"default": true,
|
||||
"profiles": {
|
||||
"high_quality": {
|
||||
"key": "high_quality",
|
||||
"displayName": "High Quality",
|
||||
"default": false,
|
||||
"resource": "http://example.com/api/slicing/cura/profiles/high_quality"
|
||||
},
|
||||
"medium_quality": {
|
||||
"key": "medium_quality",
|
||||
"displayName": "Medium Quality",
|
||||
"default": true,
|
||||
"resource": "http://example.com/api/slicing/cura/profiles/medium_quality"
|
||||
},
|
||||
...
|
||||
}
|
||||
},
|
||||
...
|
||||
}
|
||||
|
||||
:statuscode 200: No error
|
||||
|
||||
.. _sec-api-slicing-list:
|
||||
|
||||
List Slicing Profiles of a Specific Slicer
|
||||
==========================================
|
||||
|
||||
.. http:get:: /api/slicing/(string:slicer)/profiles
|
||||
|
||||
Returns a list of all available slicing profiles for the requested slicer.
|
||||
|
||||
Returns a :http:statuscode:`200` response with a :ref:`Profile list <sec-api-slicing-datamodel-profilelist>`
|
||||
as the body upon successful completion.
|
||||
|
||||
**Example**
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
GET /api/slicing/cura/profiles HTTP/1.1
|
||||
Host: example.com
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"high_quality": {
|
||||
"key": "high_quality",
|
||||
"displayName": "High Quality",
|
||||
"default": false,
|
||||
"resource": "http://example.com/api/slicing/cura/profiles/high_quality"
|
||||
},
|
||||
"medium_quality": {
|
||||
"key": "medium_quality",
|
||||
"displayName": "Medium Quality",
|
||||
"default": true,
|
||||
"resource": "http://example.com/api/slicing/cura/profiles/medium_quality"
|
||||
},
|
||||
...
|
||||
}
|
||||
|
||||
:param slicer: The identifying key of the slicer for which to list the available profiles.
|
||||
:statuscode 200: No error
|
||||
:statuscode 404: If the ``slicer`` was unknown to the system.
|
||||
|
||||
.. _sec-api-slicing-listspecific:
|
||||
|
||||
Retrieve Specific Profile
|
||||
=========================
|
||||
|
||||
.. http:get:: /api/slicing/(string:slicer)/profiles/(string:key)
|
||||
|
||||
Retrieves the specified profile from the system.
|
||||
|
||||
Returns a :http:statuscode:`200` response with a :ref:`full Profile <sec-api-slicing-datamodel-profile>`
|
||||
as the body upon successful completion.
|
||||
|
||||
**Example**
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
GET /api/slicing/cura/profiles/quick_test HTTP/1.1
|
||||
Host: example.com
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"displayName": "Just a test",
|
||||
"description": "This is just a test",
|
||||
"resource": "http://example.com/api/slicing/cura/profiles/quick_test",
|
||||
"data": {
|
||||
"bottom_layer_speed": 20.0,
|
||||
"bottom_thickness": 0.3,
|
||||
"brim_line_count": 20,
|
||||
"cool_head_lift": false,
|
||||
"cool_min_feedrate": 10.0,
|
||||
"cool_min_layer_time": 5.0,
|
||||
...
|
||||
}
|
||||
}
|
||||
|
||||
:param slicer: The identifying key of the slicer for which to list the available profiles.
|
||||
:param name: The identifying key of the profile to retrieve
|
||||
:statuscode 200: No error
|
||||
:statuscode 404: If the ``slicer`` or the profile was unknown to the system.
|
||||
|
||||
.. _sec-api-slicing-add:
|
||||
|
||||
Add Slicing Profile
|
||||
===================
|
||||
|
||||
.. http:put:: /api/slicing/(string:slicer)/profiles/(string:key)
|
||||
|
||||
Adds a new slicing profile for the given ``slicer`` to the system. If the profile identified by ``key`` already exists,
|
||||
it will be overwritten.
|
||||
|
||||
Expects a :ref:`Profile <sec-api-slicing-datamodel-profile>` as body.
|
||||
|
||||
Returns a :http:statuscode:`201` and an :ref:`abridged Profile <sec-api-slicing-datamodel-profile>` in the body
|
||||
upon successful completion.
|
||||
|
||||
**Example**
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
PUT /api/slicing/cura/profiles/quick_test HTTP/1.1
|
||||
Host: example.com
|
||||
X-Api-Key: abcdef...
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"displayName": "Just a test",
|
||||
"description": "This is just a test to show how to create a cura profile with a different layer height and skirt count",
|
||||
"data": {
|
||||
"layer_height": 0.2,
|
||||
"skirt_line_count": 3
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 201 Created
|
||||
Content-Type: application/json
|
||||
Location: http://example.com/api/slicing/cura/profiles/quick_test
|
||||
|
||||
{
|
||||
"displayName": "Just a test",
|
||||
"description": "This is just a test to show how to create a cura profile with a different layer height and skirt count",
|
||||
"resource": "http://example.com/api/slicing/cura/profiles/quick_test"
|
||||
}
|
||||
|
||||
:param slicer: The identifying key of the slicer for which to add the profile
|
||||
:param key: The identifying key of the new profile
|
||||
:statuscode 201: No error
|
||||
:statuscode 404: If the ``slicer`` was unknown to the system.
|
||||
|
||||
.. _sec-api-slicing-delete:
|
||||
|
||||
Delete Slicing Profile
|
||||
======================
|
||||
|
||||
.. http:delete:: /api/slicing/(string:slicer)/profiles/(string:key)
|
||||
|
||||
Delete the slicing profile identified by ``key`` for the slicer ``slicer``.
|
||||
|
||||
:param slicer: The identifying key of the slicer for which to delete the profile
|
||||
:param key: The identifying key of the profile to delete
|
||||
:statuscode 204: No error
|
||||
:statuscode 404: If the ``slicer`` was unknown to the system.
|
||||
|
||||
.. _sec-api-slicing-datamodel:
|
||||
|
||||
Datamodel
|
||||
=========
|
||||
|
||||
.. _sec-api-slicing-datamodel-slicerlist:
|
||||
|
||||
Slicer list
|
||||
-----------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``<slicer key>``
|
||||
- 0..*
|
||||
- :ref:`Slicer <sec-api-slicing-datamodel-slicer>`
|
||||
- Information about a slicer registered in the system, incl. stored profiles without ``data``.
|
||||
|
||||
.. _sec-api-slicing-datamodel-slicer:
|
||||
|
||||
Slicer
|
||||
------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``key``
|
||||
- 1
|
||||
- ``string``
|
||||
- Identifier of the slicer
|
||||
* - ``displayName``
|
||||
- 0..1
|
||||
- ``string``
|
||||
- Display name of the slicer
|
||||
* - ``default``
|
||||
- 1
|
||||
- ``boolean``
|
||||
- Whether the slicer is the default slicer to use (``true``) or not (``false``).
|
||||
* - ``profiles``
|
||||
- 0..*
|
||||
- :ref:`Profile list <sec-api-slicing-datamodel-profilelist>`
|
||||
- Slicing profiles available for this slicer, mapped by their ``key``
|
||||
|
||||
.. _sec-api-slicing-datamodel-profilelist:
|
||||
|
||||
Profile list
|
||||
------------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``<profile key>``
|
||||
- 0..1
|
||||
- :ref:`Profile <sec-api-slicing-datamodel-profile>`
|
||||
- Information about a profile stored in the system, ``data`` field will be left out.
|
||||
|
||||
.. _sec-api-slicing-datamodel-profile:
|
||||
|
||||
Profile
|
||||
-------
|
||||
|
||||
.. list-table::
|
||||
:widths: 15 5 10 30
|
||||
:header-rows: 1
|
||||
|
||||
* - Name
|
||||
- Multiplicity
|
||||
- Type
|
||||
- Description
|
||||
* - ``key``
|
||||
- 1
|
||||
- ``string``
|
||||
- Identifier of the profile
|
||||
* - ``displayName``
|
||||
- 0..1
|
||||
- ``string``
|
||||
- Display name of the profile
|
||||
* - ``description``
|
||||
- 0..1
|
||||
- ``string``
|
||||
- Description of the profile
|
||||
* - ``default``
|
||||
- 0..1
|
||||
- ``boolean``
|
||||
- Whether this is the default profile to be used with this slicer (``true``) or not (``false``). Will always be
|
||||
returned in responses but can be left out of save/update requests.
|
||||
* - ``resource``
|
||||
- 0..1
|
||||
- ``URL``
|
||||
- Resource URL of the profile, will always be returned in responses but can be left out of save/update requests.
|
||||
* - ``data``
|
||||
- 0..1
|
||||
- Object
|
||||
- The actual profile data, including any default values if the profile was retrieved from the server. May contain
|
||||
only the keys differing from the defaults when saving/updating a profile. The keys to be found in here a slicer
|
||||
specific. Will be left out for list responses.
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
.. _sec-api-version:
|
||||
|
||||
*******************
|
||||
Version information
|
||||
*******************
|
||||
|
||||
.. http:get:: /api/version
|
||||
|
||||
Retrieve information regarding server and API version. Returns a JSON object with two keys, ``api`` containing
|
||||
the API version, ``server`` containing the server version.
|
||||
|
||||
**Example Request**
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
GET /api/version HTTP/1.1
|
||||
Host: example.com
|
||||
X-Api-Key: abcdef...
|
||||
|
||||
**Example Response**
|
||||
|
||||
.. sourcecode:: http
|
||||
|
||||
HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"api": "0.1",
|
||||
"server": "1.1.0"
|
||||
}
|
||||
|
||||
:statuscode 200: No error
|
||||
@@ -0,0 +1,263 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# OctoPrint documentation build configuration file, created by
|
||||
# sphinx-quickstart on Mon Dec 02 17:08:50 2013.
|
||||
#
|
||||
# This file is execfile()d with the current directory set to its containing dir.
|
||||
#
|
||||
# Note that not all possible configuration values are present in this
|
||||
# autogenerated file.
|
||||
#
|
||||
# All configuration values have a default; values that are commented out
|
||||
# serve to show the default.
|
||||
|
||||
import sys, os
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
sys.path.insert(0, os.path.abspath('../src/'))
|
||||
|
||||
import octoprint._version
|
||||
from datetime import date
|
||||
|
||||
year_since = 2013
|
||||
year_current = date.today().year
|
||||
|
||||
# -- General configuration -----------------------------------------------------
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
#needs_sphinx = '1.0'
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be extensions
|
||||
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||
extensions = ['sphinx.ext.todo', 'sphinx.ext.autodoc', 'sphinxcontrib.httpdomain']
|
||||
todo_include_todos = True
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
|
||||
# The suffix of source filenames.
|
||||
source_suffix = '.rst'
|
||||
|
||||
# The encoding of source files.
|
||||
#source_encoding = 'utf-8-sig'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
project = u'OctoPrint'
|
||||
copyright = u'%d-%d, Gina Häußge' % (year_since, year_current) if year_current > year_since else u'%d, Gina Häußge' % year_since
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = octoprint._version.get_versions()["version"]
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = version
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
#language = None
|
||||
|
||||
# There are two options for replacing |today|: either, you set today to some
|
||||
# non-false value, then it is used:
|
||||
#today = ''
|
||||
# Else, today_fmt is used as the format for a strftime call.
|
||||
#today_fmt = '%B %d, %Y'
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
exclude_patterns = ['_build']
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all documents.
|
||||
#default_role = None
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
#add_function_parentheses = True
|
||||
|
||||
# If true, the current module name will be prepended to all description
|
||||
# unit titles (such as .. function::).
|
||||
#add_module_names = True
|
||||
|
||||
# If true, sectionauthor and moduleauthor directives will be shown in the
|
||||
# output. They are ignored by default.
|
||||
#show_authors = False
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
|
||||
# A list of ignored prefixes for module index sorting.
|
||||
#modindex_common_prefix = []
|
||||
|
||||
# If true, keep warnings as "system message" paragraphs in the built documents.
|
||||
#keep_warnings = False
|
||||
|
||||
|
||||
# -- Options for HTML output ---------------------------------------------------
|
||||
|
||||
# on_rtd is whether we are on readthedocs.org, this line of code grabbed from docs.readthedocs.org
|
||||
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
|
||||
|
||||
if not on_rtd: # only import and set the theme if we're building docs locally
|
||||
import sphinx_rtd_theme
|
||||
html_theme = 'sphinx_rtd_theme'
|
||||
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
#html_theme = "sphinx_rtd_theme"
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
# documentation.
|
||||
#html_theme_options = {}
|
||||
|
||||
# Add any paths that contain custom themes here, relative to this directory.
|
||||
#html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
|
||||
|
||||
# The name for this set of Sphinx documents. If None, it defaults to
|
||||
# "<project> v<release> documentation".
|
||||
#html_title = None
|
||||
|
||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
||||
#html_short_title = None
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top
|
||||
# of the sidebar.
|
||||
#html_logo = None
|
||||
|
||||
# The name of an image file (within the static path) to use as favicon of the
|
||||
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||
# pixels large.
|
||||
#html_favicon = None
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
||||
|
||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||
# using the given strftime format.
|
||||
#html_last_updated_fmt = '%b %d, %Y'
|
||||
|
||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
||||
# typographically correct entities.
|
||||
#html_use_smartypants = True
|
||||
|
||||
# Custom sidebar templates, maps document names to template names.
|
||||
#html_sidebars = {}
|
||||
|
||||
# Additional templates that should be rendered to pages, maps page names to
|
||||
# template names.
|
||||
#html_additional_pages = {}
|
||||
|
||||
# If false, no module index is generated.
|
||||
#html_domain_indices = True
|
||||
|
||||
# If false, no index is generated.
|
||||
#html_use_index = True
|
||||
|
||||
# If true, the index is split into individual pages for each letter.
|
||||
#html_split_index = False
|
||||
|
||||
# If true, links to the reST sources are added to the pages.
|
||||
#html_show_sourcelink = True
|
||||
|
||||
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
|
||||
#html_show_sphinx = True
|
||||
|
||||
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
|
||||
#html_show_copyright = True
|
||||
|
||||
# If true, an OpenSearch description file will be output, and all pages will
|
||||
# contain a <link> tag referring to it. The value of this option must be the
|
||||
# base URL from which the finished HTML is served.
|
||||
#html_use_opensearch = ''
|
||||
|
||||
# This is the file name suffix for HTML files (e.g. ".xhtml").
|
||||
#html_file_suffix = None
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'OctoPrintdoc'
|
||||
|
||||
|
||||
# -- Options for LaTeX output --------------------------------------------------
|
||||
|
||||
latex_elements = {
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#'papersize': 'letterpaper',
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#'pointsize': '10pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#'preamble': '',
|
||||
}
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title, author, documentclass [howto/manual]).
|
||||
latex_documents = [
|
||||
('index', 'OctoPrint.tex', u'OctoPrint Documentation',
|
||||
u'Gina Häußge', 'manual'),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
# the title page.
|
||||
#latex_logo = None
|
||||
|
||||
# For "manual" documents, if this is true, then toplevel headings are parts,
|
||||
# not chapters.
|
||||
#latex_use_parts = False
|
||||
|
||||
# If true, show page references after internal links.
|
||||
#latex_show_pagerefs = False
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#latex_show_urls = False
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#latex_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#latex_domain_indices = True
|
||||
|
||||
|
||||
# -- Options for manual page output --------------------------------------------
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
('index', 'octoprint', u'OctoPrint Documentation',
|
||||
[u'Gina Häußge'], 1)
|
||||
]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#man_show_urls = False
|
||||
|
||||
|
||||
# -- Options for Texinfo output ------------------------------------------------
|
||||
|
||||
# Grouping the document tree into Texinfo files. List of tuples
|
||||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
('index', 'OctoPrint', u'OctoPrint Documentation',
|
||||
u'Gina Häußge', 'OctoPrint', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
]
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#texinfo_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#texinfo_domain_indices = True
|
||||
|
||||
# How to display URL addresses: 'footnote', 'no', or 'inline'.
|
||||
#texinfo_show_urls = 'footnote'
|
||||
|
||||
# If true, do not generate a @detailmenu in the "Top" node's menu.
|
||||
#texinfo_no_detailmenu = False
|
||||
@@ -0,0 +1,368 @@
|
||||
.. _sec-events:
|
||||
|
||||
####################
|
||||
Events Documentation
|
||||
####################
|
||||
|
||||
.. contents::
|
||||
|
||||
With release of OctoPrint 1.1.0, the payload data has been harmonized, it is now a key-value-map for all events.
|
||||
Additionally, the format of the placeholders in both system command and gcode command triggers has been changed to
|
||||
accommodate for this new format. Last but not least, the way of specifying event hooks has changed, OctoPrint no longer
|
||||
separates hooks into two sections (gcodeCommandTrigger and systemCommandTrigger) but instead event hooks are now typed
|
||||
to indicate what to do with the command contained.
|
||||
|
||||
.. _sec-events-configuration:
|
||||
|
||||
Configuration
|
||||
=============
|
||||
|
||||
Event hooks are configured via OctoPrint's configuration file ``config.yaml``. There they are contained in a
|
||||
``subscriptions`` list located directly under the ``events`` node. The ``command`` node accepts either a single string
|
||||
or a list of strings so that multiple commands can be executed in one go. Each hook carries an additional node type that
|
||||
must be either ``gcode`` (for GCODE commands to be sent to the printer based on the event) or ``system`` (for commands to be
|
||||
executed on the system OctoPrint is running on).
|
||||
|
||||
All event hooks can be disabled completely by setting ``event > enabled`` to ``false``. You can also disable individual
|
||||
hooks by setting the (optional) node ``enabled`` to false, see the example below.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
.. sourcecode:: yaml
|
||||
|
||||
events:
|
||||
enabled: True
|
||||
subscriptions:
|
||||
- event: Disconnected
|
||||
command: python ~/growl.py -t mygrowlserver -d "Lost connection to printer" -a OctoPrint -i http://raspi/Octoprint_logo.png
|
||||
type: system
|
||||
enabled: false
|
||||
- event: PrintStarted
|
||||
command: python ~/growl.py -t mygrowlserver -d "Starting {file}" -a OctoPrint -i http://raspi/Octoprint_logo.png
|
||||
type: system
|
||||
- event: PrintDone
|
||||
command: python ~/growl.py -t mygrowlserver -d "Completed {file}" -a OctoPrint -i http://raspi/Octoprint_logo.png
|
||||
type: system
|
||||
- event: Connected
|
||||
command:
|
||||
- M115
|
||||
- M117 printer connected!
|
||||
- G28
|
||||
type: gcode
|
||||
|
||||
.. _sec-events-placeholders:
|
||||
|
||||
Placeholders
|
||||
============
|
||||
|
||||
You can use the following generic placeholders in your events:
|
||||
|
||||
* ``{__currentZ}``: the current Z position of the head if known, -1 if not available
|
||||
* ``{__filename}``: filename of the currently selected file, "NO FILE" if not available
|
||||
* ``{__progress}``: the progress of the print in percent, 0 if not available
|
||||
* ``{__data}``: a string representation of the payload
|
||||
* ``{__now}``: the date and time of the event in ISO 8601
|
||||
|
||||
Additionally, all data from the payload can be accessed by its key. Example: If the payload happens to be defined
|
||||
something like this:
|
||||
|
||||
* ``file``: the file's name
|
||||
* ``origin``: the origin of the file, either ``local`` or ``sdcard``
|
||||
|
||||
then you'll be able to access the filename via the placeholder ``{file}`` and the origin via the placeholder ``{origin}``.
|
||||
|
||||
|
||||
.. _sec-events-available_events:
|
||||
|
||||
Available Events
|
||||
================
|
||||
|
||||
Server
|
||||
------
|
||||
|
||||
Startup
|
||||
The server has started
|
||||
|
||||
ClientOpened
|
||||
A client has connected to the web server.
|
||||
|
||||
Payload:
|
||||
|
||||
* ``remoteAddress``: the remote address (IP) of the client that connected
|
||||
|
||||
**Note:** Name changed in version 1.1.0
|
||||
|
||||
ClientClosed
|
||||
A client has disconnected from the webserver
|
||||
|
||||
Payload:
|
||||
|
||||
* ``remoteAddress``: the remote address (IP) of the client that disconnected
|
||||
|
||||
Printer communication
|
||||
---------------------
|
||||
|
||||
Connected
|
||||
The server has connected to the printer.
|
||||
|
||||
Payload:
|
||||
|
||||
* ``port``: the connected serial port
|
||||
* ``baudrate``: the baud rate
|
||||
|
||||
Disconnected
|
||||
The server has disconnected from the printer
|
||||
|
||||
Error
|
||||
An error has occurred in the printer communication.
|
||||
|
||||
Payload:
|
||||
|
||||
* ``error``: the error string
|
||||
|
||||
File handling
|
||||
-------------
|
||||
|
||||
Upload
|
||||
A file has been uploaded.
|
||||
|
||||
Payload:
|
||||
* ``file``: the file's name
|
||||
* ``target``: the target to which the file was uploaded, either ``local`` or ``sdcard``
|
||||
|
||||
UpdatedFiles
|
||||
A file list was modified.
|
||||
|
||||
Payload:
|
||||
|
||||
* ``type``: the type of file list that was modified. Currently only ``printables`` and ``gcode`` (DEPRECATED) are supported here.
|
||||
|
||||
.. note::
|
||||
|
||||
The type ``gcode`` has been renamed to ``printables`` with the introduction of a new file management layer that
|
||||
supports STL files as first class citizens as well. For reasons of backwards compatibility the ``UpdatedFiles``
|
||||
event for printable files will be fired twice, once with ``type`` set to ``gcode``, once set to ``printables``.
|
||||
Support for the ``gcode`` type will be removed in the next release after version 1.2.0.
|
||||
|
||||
MetadataAnalysisStarted
|
||||
The metadata analysis of a GCODE file has started.
|
||||
|
||||
Payload:
|
||||
|
||||
* ``file``: the file's name
|
||||
|
||||
MetadataAnalaysisFinished
|
||||
The metadata analysis of a GCODE file has finished.
|
||||
|
||||
Payload:
|
||||
|
||||
* ``file``: the file's name
|
||||
* ``result``: the analysis result -- this is a python object currently only available for internal use
|
||||
|
||||
FileSelected
|
||||
A GCODE file has been selected for printing.
|
||||
|
||||
Payload:
|
||||
|
||||
* ``file``: the file's name
|
||||
* ``origin``: the origin of the file, either ``local`` or ``sdcard``
|
||||
|
||||
FileDeselected
|
||||
No file is selected any more for printing.
|
||||
|
||||
TransferStarted
|
||||
A GCODE file transfer to SD has started.
|
||||
|
||||
Payload:
|
||||
|
||||
* ``local``: the file's name as stored locally
|
||||
* ``remote``: the file's name as stored on SD
|
||||
|
||||
**Note:** Name changed in version 1.1.0
|
||||
|
||||
TransferDone
|
||||
A GCODE file transfer to SD has finished.
|
||||
|
||||
Payload:
|
||||
|
||||
* ``time``: the time it took for the transfer to complete in seconds
|
||||
* ``local``: the file's name as stored locally
|
||||
* ``remote``: the file's name as stored on SD
|
||||
|
||||
Printing
|
||||
--------
|
||||
|
||||
PrintStarted
|
||||
A print has started.
|
||||
|
||||
Payload:
|
||||
|
||||
* ``file``: the file's name
|
||||
* ``origin``: the origin of the file, either ``local`` or ``sdcard``
|
||||
|
||||
PrintFailed
|
||||
A print failed.
|
||||
|
||||
Payload:
|
||||
|
||||
* ``file``: the file's name
|
||||
* ``origin``: the origin of the file, either ``local`` or ``sdcard``
|
||||
|
||||
PrintDone
|
||||
A print completed successfully.
|
||||
|
||||
Payload:
|
||||
|
||||
* ``file``: the file's name
|
||||
* ``origin``: the origin of the file, either ``local`` or ``sdcard``
|
||||
* ``time``: the time needed for the print, in seconds (float)
|
||||
|
||||
PrintCancelled
|
||||
The print has been cancelled via the cancel button.
|
||||
|
||||
Payload:
|
||||
|
||||
* ``file``: the file's name
|
||||
* ``origin``: the origin of the file, either ``local`` or ``sdcard``
|
||||
|
||||
PrintPaused
|
||||
The print has been paused.
|
||||
|
||||
Payload:
|
||||
|
||||
* ``file``: the file's name
|
||||
* ``origin``: the origin of the file, either ``local`` or ``sdcard``
|
||||
|
||||
PrintResumed
|
||||
The print has been resumed.
|
||||
|
||||
Payload:
|
||||
|
||||
* ``file``: the file's name
|
||||
* ``origin``: the origin of the file, either ``local`` or ``sdcard``
|
||||
|
||||
GCODE processing
|
||||
----------------
|
||||
|
||||
PowerOn
|
||||
The GCode has turned on the printer power via M80
|
||||
|
||||
PowerOff
|
||||
The GCODE has turned on the printer power via M81
|
||||
|
||||
Home
|
||||
The head has gone home via G28
|
||||
|
||||
ZChange
|
||||
The printer's Z-Height has changed (new layer)
|
||||
|
||||
Paused
|
||||
The print has been paused
|
||||
|
||||
Waiting
|
||||
The print is paused due to a gcode wait command
|
||||
|
||||
Cooling
|
||||
The GCODE has enabled the platform cooler via M245
|
||||
|
||||
Alert
|
||||
The GCODE has issued a user alert (beep) via M300
|
||||
|
||||
Conveyor
|
||||
The GCODE has enabled the conveyor belt via M240
|
||||
|
||||
Eject
|
||||
The GCODE has enabled the part ejector via M40
|
||||
|
||||
EStop
|
||||
The GCODE has issued a panic stop via M112
|
||||
|
||||
Timelapses
|
||||
----------
|
||||
|
||||
CaptureStart
|
||||
A timelapse image has started to be captured.
|
||||
|
||||
Payload:
|
||||
|
||||
* ``file``: the name of the image file to be saved
|
||||
|
||||
CaptureDone
|
||||
A timelapse image has completed being captured.
|
||||
|
||||
Payload:
|
||||
* ``file``: the name of the image file that was saved
|
||||
|
||||
MovieRendering
|
||||
The timelapse movie has started rendering.
|
||||
|
||||
Payload:
|
||||
|
||||
* ``gcode``: the GCODE file for which the timelapse would have been created (only the filename without the path)
|
||||
* ``movie``: the movie file that is being created (full path)
|
||||
* ``movie_basename``: the movie file that is being created (only the file name without the path)
|
||||
|
||||
MovieDone
|
||||
The timelapse movie is completed.
|
||||
|
||||
Payload:
|
||||
|
||||
* ``gcode``: the GCODE file for which the timelapse would have been created (only the filename without the path)
|
||||
* ``movie``: the movie file that has been created (full path)
|
||||
* ``movie_basename``: the movie file that has been created (only the file name without the path)
|
||||
|
||||
MovieFailed
|
||||
There was an error while rendering the timelapse movie.
|
||||
|
||||
Payload:
|
||||
|
||||
* ``gcode``: the GCODE file for which the timelapse would have been created (only the filename without the path)
|
||||
* ``movie``: the movie file that would have been created (full path)
|
||||
* ``movie_basename``: the movie file that would have been created (only the file name without the path)
|
||||
* ``returncode``: the return code of ``ffmpeg`` that indicates the error that occurred
|
||||
|
||||
Slicing
|
||||
-------
|
||||
|
||||
SlicingStarted
|
||||
The slicing of a file has started.
|
||||
|
||||
Payload:
|
||||
|
||||
* ``stl``: the STL's filename
|
||||
* ``gcode``: the sliced GCODE's filename
|
||||
* ``progressAvailable``: true if progress information via the ``slicingProgress`` push update will be available, false if not
|
||||
|
||||
SlicingDone
|
||||
The slicing of a file has completed.
|
||||
|
||||
Payload:
|
||||
|
||||
* ``stl``: the STL's filename
|
||||
* ``gcode``: the sliced GCODE's filename
|
||||
* ``time``: the time needed for slicing, in seconds (float)
|
||||
|
||||
SlicingCancelled
|
||||
The slicing of a file has been cancelled. This will happen if a second slicing job
|
||||
targeting the same GCODE file has been started by the user.
|
||||
|
||||
Payload:
|
||||
|
||||
* ``stl``: the STL's filename
|
||||
* ``gcode``: the sliced GCODE's filename
|
||||
|
||||
SlicingFailed
|
||||
The slicing of a file has failed.
|
||||
|
||||
Payload:
|
||||
|
||||
* ``stl``: the STL's filename
|
||||
* ``gcode``: the sliced GCODE's filename
|
||||
* ``reason``: the reason for the slicing having failed
|
||||
|
||||
Settings
|
||||
--------
|
||||
|
||||
SettingsUpdated
|
||||
The internal settings were updated.
|
||||
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 22 KiB |
@@ -0,0 +1,22 @@
|
||||
#####################################
|
||||
Welcome to OctoPrint's documentation!
|
||||
#####################################
|
||||
|
||||
.. image:: images/octoprint-logo.png
|
||||
:alt: The OctoPrint Logo
|
||||
:align: right
|
||||
|
||||
This is a work in progress. The goal is to document OctoPrint's REST API, event system, configuration etc in a way that
|
||||
allows different documentation per development branch in Git, which so far did not scale well with the Github-Wiki-based
|
||||
approach.
|
||||
|
||||
Contents
|
||||
========
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
api/index.rst
|
||||
events/index.rst
|
||||
plugins/index.rst
|
||||
|
||||
@@ -0,0 +1,242 @@
|
||||
@ECHO OFF
|
||||
|
||||
REM Command file for Sphinx documentation
|
||||
|
||||
if "%SPHINXBUILD%" == "" (
|
||||
set SPHINXBUILD=sphinx-build
|
||||
)
|
||||
set BUILDDIR=_build
|
||||
set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
|
||||
set I18NSPHINXOPTS=%SPHINXOPTS% .
|
||||
if NOT "%PAPER%" == "" (
|
||||
set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
|
||||
set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
|
||||
)
|
||||
|
||||
if "%1" == "" goto help
|
||||
|
||||
if "%1" == "help" (
|
||||
:help
|
||||
echo.Please use `make ^<target^>` where ^<target^> is one of
|
||||
echo. html to make standalone HTML files
|
||||
echo. dirhtml to make HTML files named index.html in directories
|
||||
echo. singlehtml to make a single large HTML file
|
||||
echo. pickle to make pickle files
|
||||
echo. json to make JSON files
|
||||
echo. htmlhelp to make HTML files and a HTML help project
|
||||
echo. qthelp to make HTML files and a qthelp project
|
||||
echo. devhelp to make HTML files and a Devhelp project
|
||||
echo. epub to make an epub
|
||||
echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
|
||||
echo. text to make text files
|
||||
echo. man to make manual pages
|
||||
echo. texinfo to make Texinfo files
|
||||
echo. gettext to make PO message catalogs
|
||||
echo. changes to make an overview over all changed/added/deprecated items
|
||||
echo. xml to make Docutils-native XML files
|
||||
echo. pseudoxml to make pseudoxml-XML files for display purposes
|
||||
echo. linkcheck to check all external links for integrity
|
||||
echo. doctest to run all doctests embedded in the documentation if enabled
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "clean" (
|
||||
for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
|
||||
del /q /s %BUILDDIR%\*
|
||||
goto end
|
||||
)
|
||||
|
||||
|
||||
%SPHINXBUILD% 2> nul
|
||||
if errorlevel 9009 (
|
||||
echo.
|
||||
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
||||
echo.installed, then set the SPHINXBUILD environment variable to point
|
||||
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
||||
echo.may add the Sphinx directory to PATH.
|
||||
echo.
|
||||
echo.If you don't have Sphinx installed, grab it from
|
||||
echo.http://sphinx-doc.org/
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
if "%1" == "html" (
|
||||
%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The HTML pages are in %BUILDDIR%/html.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "dirhtml" (
|
||||
%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "singlehtml" (
|
||||
%SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "pickle" (
|
||||
%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished; now you can process the pickle files.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "json" (
|
||||
%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished; now you can process the JSON files.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "htmlhelp" (
|
||||
%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished; now you can run HTML Help Workshop with the ^
|
||||
.hhp project file in %BUILDDIR%/htmlhelp.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "qthelp" (
|
||||
%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished; now you can run "qcollectiongenerator" with the ^
|
||||
.qhcp project file in %BUILDDIR%/qthelp, like this:
|
||||
echo.^> qcollectiongenerator %BUILDDIR%\qthelp\OctoPrint.qhcp
|
||||
echo.To view the help file:
|
||||
echo.^> assistant -collectionFile %BUILDDIR%\qthelp\OctoPrint.ghc
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "devhelp" (
|
||||
%SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "epub" (
|
||||
%SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The epub file is in %BUILDDIR%/epub.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "latex" (
|
||||
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "latexpdf" (
|
||||
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
|
||||
cd %BUILDDIR%/latex
|
||||
make all-pdf
|
||||
cd %BUILDDIR%/..
|
||||
echo.
|
||||
echo.Build finished; the PDF files are in %BUILDDIR%/latex.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "latexpdfja" (
|
||||
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
|
||||
cd %BUILDDIR%/latex
|
||||
make all-pdf-ja
|
||||
cd %BUILDDIR%/..
|
||||
echo.
|
||||
echo.Build finished; the PDF files are in %BUILDDIR%/latex.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "text" (
|
||||
%SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The text files are in %BUILDDIR%/text.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "man" (
|
||||
%SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The manual pages are in %BUILDDIR%/man.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "texinfo" (
|
||||
%SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "gettext" (
|
||||
%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "changes" (
|
||||
%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.The overview file is in %BUILDDIR%/changes.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "linkcheck" (
|
||||
%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Link check complete; look for any errors in the above output ^
|
||||
or in %BUILDDIR%/linkcheck/output.txt.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "doctest" (
|
||||
%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Testing of doctests in the sources finished, look at the ^
|
||||
results in %BUILDDIR%/doctest/output.txt.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "xml" (
|
||||
%SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The XML files are in %BUILDDIR%/xml.
|
||||
goto end
|
||||
)
|
||||
|
||||
if "%1" == "pseudoxml" (
|
||||
%SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml
|
||||
if errorlevel 1 exit /b 1
|
||||
echo.
|
||||
echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml.
|
||||
goto end
|
||||
)
|
||||
|
||||
:end
|
||||
@@ -0,0 +1,19 @@
|
||||
.. _sec-plugins-developing:
|
||||
|
||||
******************
|
||||
Developing Plugins
|
||||
******************
|
||||
|
||||
.. todo::
|
||||
|
||||
A section on how to develop plugins yourself, including a tutorial creating an exemplary plugin as well as
|
||||
a documentation of the plugin API, will be added in the near future.
|
||||
|
||||
.. _sec-plugins-developing-types:
|
||||
|
||||
Available plugin types
|
||||
======================
|
||||
|
||||
.. automodule:: octoprint.plugin.types
|
||||
:members:
|
||||
:undoc-members:
|
||||
@@ -0,0 +1,60 @@
|
||||
.. _sec-plugins:
|
||||
|
||||
#####################
|
||||
Plugins Documentation
|
||||
#####################
|
||||
|
||||
Starting with OctoPrint 1.2.0, there's now a plugin system in place which allows to individually
|
||||
extend OctoPrint's functionality.
|
||||
|
||||
Right now plugins can be used to extend OctoPrint's settings dialog, to execute specific tasks on server startup and
|
||||
shutdown, to provide custom (API) endpoints with special functionality, to react on system events or to add support for
|
||||
additional slicers. More plugin types are planned for the future.
|
||||
|
||||
.. _sec-plugins-installation:
|
||||
|
||||
Installing Plugins
|
||||
==================
|
||||
|
||||
Plugins can be installed either by unpacking them into one of the configured plugin folders (regularly those are
|
||||
``<octoprint-root>/plugins`` and ``~/.octoprint/plugins`` or by installing them as regular python modules via ``pip``.
|
||||
Please refer to the documentation of the plugin for installations instructions.
|
||||
|
||||
The latter is the more common case since all currently published plugins not bundled with OctoPrint can and should be installed
|
||||
this way.
|
||||
|
||||
For a plugin available on the Python Package Index (PyPi), the process is as simple as issuing a
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
pip install <plugin_name>
|
||||
|
||||
For plugins not available on PyPi, you'll have to give ``pip`` an URL from which to install the package (e.g. the URL to
|
||||
a ZIP file of the current master branch of a Github repository hosting a plugin, or even a ``git+https`` URL), example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
pip install https://github.com/OctoPrint/OctoPrint-Growl/archive/master.zip
|
||||
|
||||
See `the pip install documentation <http://pip.readthedocs.org/en/latest/reference/pip_install.html>`_ for what URL
|
||||
types are possible.
|
||||
|
||||
.. _sec-plugins-available:
|
||||
|
||||
Available Plugins
|
||||
=================
|
||||
|
||||
Currently there's no such thing as a centralized plugin repository for available plugins.
|
||||
|
||||
Plugins may be found in the lists provided in `the OctoPrint wiki <https://github.com/foosel/OctoPrint/wiki#plugins>`_
|
||||
and on the `OctoPrint organization Github page <https://github.com/OctoPrint>`_.
|
||||
|
||||
Developing Plugins
|
||||
==================
|
||||
|
||||
Please see the following sub topics for information on how to develop your own OctoPrint plugins.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
developing.rst
|
||||
@@ -0,0 +1,2 @@
|
||||
sphinxcontrib-httpdomain
|
||||
sphinx_rtd_theme
|
||||
@@ -1,49 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copy this script to /etc/init.d/octoprint and adjust the variables
|
||||
# at the top to match your installation (should be okay for a Raspian
|
||||
# setup). Then link it to the correct run levels. On Debian/Rasbian
|
||||
# just call 'sudo update-rc.d octoprint defaults'
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: octoprint
|
||||
# Required-Start: $local_fs networking
|
||||
# Required-Stop:
|
||||
# Should-Start:
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Run octoprint
|
||||
# Description: Octoprint provides a responsive web interface for
|
||||
# controlling a 3D printer
|
||||
### END INIT INFO
|
||||
|
||||
|
||||
# OctoPrint's run script
|
||||
DAEMON=/home/pi/OctoPrint/run
|
||||
|
||||
# Port to use
|
||||
PORT=5000
|
||||
|
||||
# Run as this user
|
||||
RUNAS=pi
|
||||
|
||||
# Exit if the run script is not found
|
||||
[ -x "$DAEMON" ] || exit 0
|
||||
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
su $RUNAS -c "$DAEMON --port=$PORT --daemon start"
|
||||
;;
|
||||
stop)
|
||||
su $RUNAS -c "$DAEMON --port=$PORT --daemon stop"
|
||||
;;
|
||||
restart)
|
||||
su $RUNAS -c "$DAEMON --port=$PORT --daemon restart"
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart}" >&2
|
||||
;;
|
||||
esac
|
||||
|
||||
:
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
@@ -1,246 +0,0 @@
|
||||
# coding=utf-8
|
||||
|
||||
__author__ = "Lars Norpchen"
|
||||
__author__ = "Gina Häußge <osd@foosel.net>"
|
||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||
|
||||
import datetime
|
||||
import logging
|
||||
import subprocess
|
||||
|
||||
from octoprint.settings import settings
|
||||
|
||||
# singleton
|
||||
_instance = None
|
||||
|
||||
def eventManager():
|
||||
global _instance
|
||||
if _instance is None:
|
||||
_instance = EventManager()
|
||||
return _instance
|
||||
|
||||
class EventManager(object):
|
||||
"""
|
||||
Handles receiving events and dispatching them to subscribers
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self._registeredListeners = {}
|
||||
self._logger = logging.getLogger(__name__)
|
||||
|
||||
def fire(self, event, payload=None):
|
||||
"""
|
||||
Fire an event to anyone subscribed to it
|
||||
|
||||
Any object can generate an event and any object can subscribe to the event's name as a string (arbitrary, but
|
||||
case sensitive) and any extra payload data that may pertain to the event.
|
||||
|
||||
Callbacks must implement the signature "callback(event, payload)", with "event" being the event's name and
|
||||
payload being a payload object specific to the event.
|
||||
"""
|
||||
|
||||
if not event in self._registeredListeners.keys():
|
||||
return
|
||||
self._logger.debug("Firing event: %s (Payload: %r)" % (event, payload))
|
||||
|
||||
eventListeners = self._registeredListeners[event]
|
||||
for listener in eventListeners:
|
||||
self._logger.debug("Sending action to %r" % listener)
|
||||
try:
|
||||
listener(event, payload)
|
||||
except:
|
||||
self._logger.exception("Got an exception while sending event %s (Payload: %r) to %s" % (event, payload, listener))
|
||||
|
||||
|
||||
def subscribe(self, event, callback):
|
||||
"""
|
||||
Subscribe a listener to an event -- pass in the event name (as a string) and the callback object
|
||||
"""
|
||||
|
||||
if not event in self._registeredListeners.keys():
|
||||
self._registeredListeners[event] = []
|
||||
|
||||
if callback in self._registeredListeners[event]:
|
||||
# callback is already subscribed to the event
|
||||
return
|
||||
|
||||
self._registeredListeners[event].append(callback)
|
||||
self._logger.debug("Subscribed listener %r for event %s" % (callback, event))
|
||||
|
||||
def unsubscribe (self, event, callback):
|
||||
if not event in self._registeredListeners:
|
||||
# no callback registered for callback, just return
|
||||
return
|
||||
|
||||
if not callback in self._registeredListeners[event]:
|
||||
# callback not subscribed to event, just return
|
||||
return
|
||||
|
||||
self._registeredListeners[event].remove(callback)
|
||||
self._logger.debug("Unsubscribed listener %r for event %s" % (callback, event))
|
||||
|
||||
class GenericEventListener(object):
|
||||
"""
|
||||
The GenericEventListener can be subclassed to easily create custom event listeners.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self._logger = logging.getLogger(__name__)
|
||||
|
||||
def subscribe(self, events):
|
||||
"""
|
||||
Subscribes the eventCallback method for all events in the given list.
|
||||
"""
|
||||
|
||||
for event in events:
|
||||
eventManager().subscribe(event, self.eventCallback)
|
||||
|
||||
def unsubscribe(self, events):
|
||||
"""
|
||||
Unsubscribes the eventCallback method for all events in the given list
|
||||
"""
|
||||
|
||||
for event in events:
|
||||
eventManager().unsubscribe(event, self.eventCallback)
|
||||
|
||||
def eventCallback(self, event, payload):
|
||||
"""
|
||||
Actual event callback called with name of event and optional payload. Not implemented here, override in
|
||||
child classes.
|
||||
"""
|
||||
pass
|
||||
|
||||
class DebugEventListener(GenericEventListener):
|
||||
def __init__(self):
|
||||
GenericEventListener.__init__(self)
|
||||
|
||||
events = ["Startup", "Connected", "Disconnected", "ClientOpen", "ClientClosed", "PowerOn", "PowerOff", "Upload",
|
||||
"FileSelected", "TransferStarted", "TransferDone", "PrintStarted", "PrintDone", "PrintFailed",
|
||||
"Cancelled", "Home", "ZChange", "Paused", "Waiting", "Cooling", "Alert", "Conveyor", "Eject",
|
||||
"CaptureStart", "CaptureDone", "MovieDone", "EStop", "Error"]
|
||||
self.subscribe(events)
|
||||
|
||||
def eventCallback(self, event, payload):
|
||||
GenericEventListener.eventCallback(self, event, payload)
|
||||
self._logger.debug("Received event: %s (Payload: %r)" % (event, payload))
|
||||
|
||||
class CommandTrigger(GenericEventListener):
|
||||
def __init__(self, triggerType, printer):
|
||||
GenericEventListener.__init__(self)
|
||||
self._printer = printer
|
||||
self._subscriptions = {}
|
||||
|
||||
self._initSubscriptions(triggerType)
|
||||
|
||||
def _initSubscriptions(self, triggerType):
|
||||
"""
|
||||
Subscribes all events as defined in "events > $triggerType > subscriptions" in the settings with their
|
||||
respective commands.
|
||||
"""
|
||||
if not settings().get(["events", triggerType]):
|
||||
return
|
||||
|
||||
if not settings().getBoolean(["events", triggerType, "enabled"]):
|
||||
return
|
||||
|
||||
eventsToSubscribe = []
|
||||
for subscription in settings().get(["events", triggerType, "subscriptions"]):
|
||||
if not "event" in subscription.keys() or not "command" in subscription.keys():
|
||||
self._logger.info("Invalid %s, missing either event or command: %r" % (triggerType, subscription))
|
||||
continue
|
||||
|
||||
event = subscription["event"]
|
||||
command = subscription["command"]
|
||||
|
||||
if not event in self._subscriptions.keys():
|
||||
self._subscriptions[event] = []
|
||||
self._subscriptions[event].append(command)
|
||||
|
||||
if not event in eventsToSubscribe:
|
||||
eventsToSubscribe.append(event)
|
||||
|
||||
self.subscribe(eventsToSubscribe)
|
||||
|
||||
def eventCallback(self, event, payload):
|
||||
"""
|
||||
Event callback, iterates over all subscribed commands for the given event, processes the command
|
||||
string and then executes the command via the abstract executeCommand method.
|
||||
"""
|
||||
|
||||
GenericEventListener.eventCallback(self, event, payload)
|
||||
|
||||
if not event in self._subscriptions:
|
||||
return
|
||||
|
||||
for command in self._subscriptions[event]:
|
||||
processedCommand = self._processCommand(command, payload)
|
||||
self.executeCommand(processedCommand)
|
||||
|
||||
def executeCommand(self, command):
|
||||
"""
|
||||
Not implemented, override in child classes
|
||||
"""
|
||||
pass
|
||||
|
||||
def _processCommand(self, command, payload):
|
||||
"""
|
||||
Performs string substitutions in the command string based on a couple of current parameters.
|
||||
|
||||
The following substitutions are currently supported:
|
||||
|
||||
- %(currentZ)s : current Z position of the print head, or -1 if not available
|
||||
- %(filename)s : current selected filename, or "NO FILE" if no file is selected
|
||||
- %(progress)s : current print progress in percent, 0 if no print is in progress
|
||||
- %(data)s : the string representation of the event's payload
|
||||
- %(now)s : ISO 8601 representation of the current date and time
|
||||
"""
|
||||
|
||||
params = {
|
||||
"currentZ": "-1",
|
||||
"filename": "NO FILE",
|
||||
"progress": "0",
|
||||
"data": str(payload),
|
||||
"now": datetime.datetime.now().isoformat()
|
||||
}
|
||||
|
||||
currentData = self._printer.getCurrentData()
|
||||
|
||||
if "currentZ" in currentData.keys() and currentData["currentZ"] is not None:
|
||||
params["currentZ"] = str(currentData["currentZ"])
|
||||
|
||||
if "job" in currentData.keys() and currentData["job"] is not None:
|
||||
params["filename"] = currentData["job"]["filename"]
|
||||
if "progress" in currentData.keys() and currentData["progress"] is not None \
|
||||
and "progress" in currentData["progress"].keys() and currentData["progress"]["progress"] is not None:
|
||||
params["progress"] = str(round(currentData["progress"]["progress"] * 100))
|
||||
|
||||
return command % params
|
||||
|
||||
class SystemCommandTrigger(CommandTrigger):
|
||||
"""
|
||||
Performs configured system commands for configured events.
|
||||
"""
|
||||
|
||||
def __init__(self, printer):
|
||||
CommandTrigger.__init__(self, "systemCommandTrigger", printer)
|
||||
|
||||
def executeCommand(self, command):
|
||||
try:
|
||||
self._logger.info("Executing system command: %s" % command)
|
||||
subprocess.Popen(command, shell=True)
|
||||
except subprocess.CalledProcessError, e:
|
||||
self._logger.warn("Command failed with return code %i: %s" % (e.returncode, e.message))
|
||||
except Exception, ex:
|
||||
self._logger.exception("Command failed")
|
||||
|
||||
class GcodeCommandTrigger(CommandTrigger):
|
||||
"""
|
||||
Sends configured GCODE commands to the printer for configured events.
|
||||
"""
|
||||
|
||||
def __init__(self, printer):
|
||||
CommandTrigger.__init__(self, "gcodeCommandTrigger", printer)
|
||||
|
||||
def executeCommand(self, command):
|
||||
self._logger.debug("Executing GCode command: %s" % command)
|
||||
self._printer.commands(command.split(","))
|
||||
@@ -1,399 +0,0 @@
|
||||
# coding=utf-8
|
||||
__author__ = "Gina Häußge <osd@foosel.net>"
|
||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||
|
||||
import os
|
||||
import Queue
|
||||
import threading
|
||||
import datetime
|
||||
import yaml
|
||||
import time
|
||||
import logging
|
||||
import octoprint.util as util
|
||||
import octoprint.util.gcodeInterpreter as gcodeInterpreter
|
||||
from octoprint.settings import settings
|
||||
|
||||
from werkzeug.utils import secure_filename
|
||||
|
||||
SUPPORTED_EXTENSIONS=["gcode", "gco"]
|
||||
|
||||
class GcodeManager:
|
||||
def __init__(self):
|
||||
self._logger = logging.getLogger(__name__)
|
||||
|
||||
self._uploadFolder = settings().getBaseFolder("uploads")
|
||||
|
||||
self._callbacks = []
|
||||
|
||||
self._metadata = {}
|
||||
self._metadataDirty = False
|
||||
self._metadataFile = os.path.join(self._uploadFolder, "metadata.yaml")
|
||||
self._metadataFileAccessMutex = threading.Lock()
|
||||
|
||||
self._metadataAnalyzer = MetadataAnalyzer(getPathCallback=self.getAbsolutePath, loadedCallback=self._onMetadataAnalysisFinished)
|
||||
|
||||
self._loadMetadata()
|
||||
self._processAnalysisBacklog()
|
||||
|
||||
def _processAnalysisBacklog(self):
|
||||
for osFile in os.listdir(self._uploadFolder):
|
||||
filename = self._getBasicFilename(osFile)
|
||||
absolutePath = self.getAbsolutePath(filename)
|
||||
if absolutePath is None:
|
||||
continue
|
||||
|
||||
fileData = self.getFileData(filename)
|
||||
if fileData is not None and "gcodeAnalysis" in fileData.keys():
|
||||
continue
|
||||
|
||||
self._metadataAnalyzer.addFileToBacklog(filename)
|
||||
|
||||
def _onMetadataAnalysisFinished(self, filename, gcode):
|
||||
if filename is None or gcode is None:
|
||||
return
|
||||
|
||||
basename = os.path.basename(filename)
|
||||
|
||||
absolutePath = self.getAbsolutePath(basename)
|
||||
if absolutePath is None:
|
||||
return
|
||||
|
||||
analysisResult = {}
|
||||
dirty = False
|
||||
if gcode.totalMoveTimeMinute:
|
||||
analysisResult["estimatedPrintTime"] = util.getFormattedTimeDelta(datetime.timedelta(minutes=gcode.totalMoveTimeMinute))
|
||||
dirty = True
|
||||
if gcode.extrusionAmount:
|
||||
analysisResult["filament"] = "%.2fm" % (gcode.extrusionAmount / 1000)
|
||||
if gcode.calculateVolumeCm3():
|
||||
analysisResult["filament"] += " / %.2fcm³" % gcode.calculateVolumeCm3()
|
||||
dirty = True
|
||||
|
||||
if dirty:
|
||||
metadata = self.getFileMetadata(basename)
|
||||
metadata["gcodeAnalysis"] = analysisResult
|
||||
self._metadata[basename] = metadata
|
||||
self._metadataDirty = True
|
||||
self._saveMetadata()
|
||||
|
||||
def _loadMetadata(self):
|
||||
if os.path.exists(self._metadataFile) and os.path.isfile(self._metadataFile):
|
||||
with self._metadataFileAccessMutex:
|
||||
with open(self._metadataFile, "r") as f:
|
||||
self._metadata = yaml.safe_load(f)
|
||||
if self._metadata is None:
|
||||
self._metadata = {}
|
||||
|
||||
def _saveMetadata(self, force=False):
|
||||
if not self._metadataDirty and not force:
|
||||
return
|
||||
|
||||
with self._metadataFileAccessMutex:
|
||||
with open(self._metadataFile, "wb") as f:
|
||||
yaml.safe_dump(self._metadata, f, default_flow_style=False, indent=" ", allow_unicode=True)
|
||||
self._metadataDirty = False
|
||||
self._loadMetadata()
|
||||
self._sendUpdateTrigger("gcodeFiles")
|
||||
|
||||
def _getBasicFilename(self, filename):
|
||||
if filename.startswith(self._uploadFolder):
|
||||
return filename[len(self._uploadFolder + os.path.sep):]
|
||||
else:
|
||||
return filename
|
||||
|
||||
#~~ callback handling
|
||||
|
||||
def registerCallback(self, callback):
|
||||
self._callbacks.append(callback)
|
||||
|
||||
def unregisterCallback(self, callback):
|
||||
if callback in self._callbacks:
|
||||
self._callbacks.remove(callback)
|
||||
|
||||
def _sendUpdateTrigger(self, type):
|
||||
for callback in self._callbacks:
|
||||
try: callback.sendUpdateTrigger(type)
|
||||
except: pass
|
||||
|
||||
#~~ file handling
|
||||
|
||||
def addFile(self, file):
|
||||
if not file:
|
||||
return None
|
||||
|
||||
absolutePath = self.getAbsolutePath(file.filename, mustExist=False)
|
||||
if absolutePath is None:
|
||||
return None
|
||||
|
||||
basename = self._getBasicFilename(absolutePath)
|
||||
if basename in self._metadata.keys():
|
||||
# delete existing metadata entry, since the file is going to get overwritten
|
||||
del self._metadata[basename]
|
||||
self._metadataDirty = True
|
||||
self._saveMetadata()
|
||||
file.save(absolutePath)
|
||||
self._metadataAnalyzer.addFileToQueue(basename)
|
||||
return basename
|
||||
|
||||
def getFutureFilename(self, file):
|
||||
if not file:
|
||||
return None
|
||||
|
||||
absolutePath = self.getAbsolutePath(file.filename, mustExist=False)
|
||||
if absolutePath is None:
|
||||
return None
|
||||
|
||||
return self._getBasicFilename(absolutePath)
|
||||
|
||||
def removeFile(self, filename):
|
||||
filename = self._getBasicFilename(filename)
|
||||
absolutePath = self.getAbsolutePath(filename)
|
||||
if absolutePath is None:
|
||||
return
|
||||
|
||||
os.remove(absolutePath)
|
||||
if filename in self._metadata.keys():
|
||||
del self._metadata[filename]
|
||||
self._metadataDirty = True
|
||||
self._saveMetadata()
|
||||
|
||||
def getAbsolutePath(self, filename, mustExist=True):
|
||||
"""
|
||||
Returns the absolute path of the given filename in the gcode upload folder.
|
||||
|
||||
Ensures that the file
|
||||
<ul>
|
||||
<li>has the extension ".gcode"</li>
|
||||
<li>exists and is a file (not a directory) if "mustExist" is set to True</li>
|
||||
</ul>
|
||||
|
||||
@param filename the name of the file for which to determine the absolute path
|
||||
@param mustExist if set to true, the method also checks if the file exists and is a file
|
||||
@return the absolute path of the file or None if the file is not valid
|
||||
"""
|
||||
filename = self._getBasicFilename(filename)
|
||||
|
||||
if not util.isAllowedFile(filename.lower(), set(SUPPORTED_EXTENSIONS)):
|
||||
return None
|
||||
|
||||
secure = os.path.join(self._uploadFolder, secure_filename(self._getBasicFilename(filename)))
|
||||
if mustExist and (not os.path.exists(secure) or not os.path.isfile(secure)):
|
||||
return None
|
||||
|
||||
return secure
|
||||
|
||||
def getAllFileData(self):
|
||||
files = []
|
||||
for osFile in os.listdir(self._uploadFolder):
|
||||
fileData = self.getFileData(osFile)
|
||||
if fileData is not None:
|
||||
files.append(fileData)
|
||||
return files
|
||||
|
||||
def getFileData(self, filename):
|
||||
filename = self._getBasicFilename(filename)
|
||||
absolutePath = self.getAbsolutePath(filename)
|
||||
if absolutePath is None:
|
||||
return None
|
||||
|
||||
statResult = os.stat(absolutePath)
|
||||
fileData = {
|
||||
"name": filename,
|
||||
"size": util.getFormattedSize(statResult.st_size),
|
||||
"bytes": statResult.st_size,
|
||||
"date": util.getFormattedDateTime(datetime.datetime.fromtimestamp(statResult.st_ctime))
|
||||
}
|
||||
|
||||
# enrich with additional metadata from analysis if available
|
||||
if filename in self._metadata.keys():
|
||||
for key in self._metadata[filename].keys():
|
||||
if key == "prints":
|
||||
val = self._metadata[filename][key]
|
||||
formattedLast = None
|
||||
if val["last"] is not None:
|
||||
formattedLast = {
|
||||
"date": util.getFormattedDateTime(datetime.datetime.fromtimestamp(val["last"]["date"])),
|
||||
"success": val["last"]["success"]
|
||||
}
|
||||
formattedPrints = {
|
||||
"success": val["success"],
|
||||
"failure": val["failure"],
|
||||
"last": formattedLast
|
||||
}
|
||||
fileData["prints"] = formattedPrints
|
||||
else:
|
||||
fileData[key] = self._metadata[filename][key]
|
||||
|
||||
return fileData
|
||||
|
||||
def getFileMetadata(self, filename):
|
||||
filename = self._getBasicFilename(filename)
|
||||
if filename in self._metadata.keys():
|
||||
return self._metadata[filename]
|
||||
else:
|
||||
return {
|
||||
"prints": {
|
||||
"success": 0,
|
||||
"failure": 0,
|
||||
"last": None
|
||||
}
|
||||
}
|
||||
|
||||
def setFileMetadata(self, filename, metadata):
|
||||
filename = self._getBasicFilename(filename)
|
||||
self._metadata[filename] = metadata
|
||||
self._metadataDirty = True
|
||||
|
||||
#~~ print job data
|
||||
|
||||
def printSucceeded(self, filename):
|
||||
filename = self._getBasicFilename(filename)
|
||||
absolutePath = self.getAbsolutePath(filename)
|
||||
if absolutePath is None:
|
||||
return
|
||||
|
||||
metadata = self.getFileMetadata(filename)
|
||||
metadata["prints"]["success"] += 1
|
||||
metadata["prints"]["last"] = {
|
||||
"date": time.time(),
|
||||
"success": True
|
||||
}
|
||||
self.setFileMetadata(filename, metadata)
|
||||
self._saveMetadata()
|
||||
|
||||
def printFailed(self, filename):
|
||||
filename = self._getBasicFilename(filename)
|
||||
absolutePath = self.getAbsolutePath(filename)
|
||||
if absolutePath is None:
|
||||
return
|
||||
|
||||
metadata = self.getFileMetadata(filename)
|
||||
metadata["prints"]["failure"] += 1
|
||||
metadata["prints"]["last"] = {
|
||||
"date": time.time(),
|
||||
"success": False
|
||||
}
|
||||
self.setFileMetadata(filename, metadata)
|
||||
self._saveMetadata()
|
||||
|
||||
def changeLastPrintSuccess(self, filename, succeeded):
|
||||
filename = self._getBasicFilename(filename)
|
||||
absolutePath = self.getAbsolutePath(filename)
|
||||
if absolutePath is None:
|
||||
return
|
||||
|
||||
metadata = self.getFileMetadata(filename)
|
||||
if metadata is None:
|
||||
return
|
||||
|
||||
if "prints" in metadata.keys():
|
||||
if "last" in metadata.keys() and metadata["prints"]["last"] is not None:
|
||||
currentSucceeded = metadata["prints"]["last"]["success"]
|
||||
if currentSucceeded != succeeded:
|
||||
metadata["prints"]["last"]["success"] = succeeded
|
||||
if currentSucceeded:
|
||||
# last print job was counted as success but actually failed
|
||||
metadata["prints"]["success"] -= 1
|
||||
metadata["prints"]["failure"] += 1
|
||||
else:
|
||||
# last print job was counted as a failure but actually succeeded
|
||||
metadata["prints"]["success"] += 1
|
||||
metadata["prints"]["failure"] -= 1
|
||||
self.setFileMetadata(filename, metadata)
|
||||
self._saveMetadata()
|
||||
|
||||
#~~ analysis control
|
||||
|
||||
def pauseAnalysis(self):
|
||||
self._metadataAnalyzer.pause()
|
||||
|
||||
def resumeAnalysis(self):
|
||||
self._metadataAnalyzer.resume()
|
||||
|
||||
class MetadataAnalyzer:
|
||||
def __init__(self, getPathCallback, loadedCallback):
|
||||
self._logger = logging.getLogger(__name__)
|
||||
|
||||
self._getPathCallback = getPathCallback
|
||||
self._loadedCallback = loadedCallback
|
||||
|
||||
self._active = threading.Event()
|
||||
self._active.set()
|
||||
|
||||
self._currentFile = None
|
||||
self._currentProgress = None
|
||||
|
||||
self._queue = Queue.PriorityQueue()
|
||||
self._gcode = None
|
||||
|
||||
self._worker = threading.Thread(target=self._work)
|
||||
self._worker.daemon = True
|
||||
self._worker.start()
|
||||
|
||||
def addFileToQueue(self, filename):
|
||||
self._logger.debug("Adding file %s to analysis queue (high priority)" % filename)
|
||||
self._queue.put((0, filename))
|
||||
|
||||
def addFileToBacklog(self, filename):
|
||||
self._logger.debug("Adding file %s to analysis backlog (low priority)" % filename)
|
||||
self._queue.put((100, filename))
|
||||
|
||||
def working(self):
|
||||
return self.isActive() and not (self._queue.empty() and self._currentFile is None)
|
||||
|
||||
def isActive(self):
|
||||
return self._active.is_set()
|
||||
|
||||
def pause(self):
|
||||
self._logger.debug("Pausing Gcode analyzer")
|
||||
self._active.clear()
|
||||
if self._gcode is not None:
|
||||
self._logger.debug("Aborting running analysis, will restart when Gcode analyzer is resumed")
|
||||
self._gcode.abort()
|
||||
|
||||
def resume(self):
|
||||
self._logger.debug("Resuming Gcode analyzer")
|
||||
self._active.set()
|
||||
|
||||
def _work(self):
|
||||
aborted = None
|
||||
while True:
|
||||
self._active.wait()
|
||||
|
||||
if aborted is not None:
|
||||
filename = aborted
|
||||
aborted = None
|
||||
self._logger.debug("Got an aborted analysis job for file %s, processing this instead of first item in queue" % filename)
|
||||
else:
|
||||
(priority, filename) = self._queue.get()
|
||||
self._logger.debug("Processing file %s from queue (priority %d)" % (filename, priority))
|
||||
|
||||
try:
|
||||
self._analyzeGcode(filename)
|
||||
self._queue.task_done()
|
||||
except gcodeInterpreter.AnalysisAborted:
|
||||
aborted = filename
|
||||
self._logger.debug("Running analysis of file %s aborted" % filename)
|
||||
|
||||
def _analyzeGcode(self, filename):
|
||||
path = self._getPathCallback(filename)
|
||||
if path is None:
|
||||
return
|
||||
|
||||
self._currentFile = filename
|
||||
self._currentProgress = 0
|
||||
|
||||
try:
|
||||
self._logger.debug("Starting analysis of file %s" % filename)
|
||||
self._gcode = gcodeInterpreter.gcode()
|
||||
self._gcode.progressCallback = self._onParsingProgress
|
||||
self._gcode.load(path)
|
||||
self._logger.debug("Analysis of file %s finished, notifying callback" % filename)
|
||||
self._loadedCallback(self._currentFile, self._gcode)
|
||||
finally:
|
||||
self._gcode = None
|
||||
self._currentProgress = None
|
||||
self._currentFile = None
|
||||
|
||||
def _onParsingProgress(self, progress):
|
||||
self._currentProgress = progress
|
||||
@@ -1,660 +0,0 @@
|
||||
# coding=utf-8
|
||||
__author__ = "Gina Häußge <osd@foosel.net>"
|
||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||
|
||||
import time
|
||||
import datetime
|
||||
import threading
|
||||
import copy
|
||||
import os
|
||||
|
||||
#import logging, logging.config
|
||||
|
||||
import octoprint.util.comm as comm
|
||||
import octoprint.util as util
|
||||
|
||||
from octoprint.settings import settings
|
||||
from octoprint.events import eventManager
|
||||
|
||||
def getConnectionOptions():
|
||||
"""
|
||||
Retrieves the available ports, baudrates, prefered port and baudrate for connecting to the printer.
|
||||
"""
|
||||
return {
|
||||
"ports": comm.serialList(),
|
||||
"baudrates": comm.baudrateList(),
|
||||
"portPreference": settings().get(["serial", "port"]),
|
||||
"baudratePreference": settings().getInt(["serial", "baudrate"]),
|
||||
"autoconnect": settings().getBoolean(["serial", "autoconnect"])
|
||||
}
|
||||
|
||||
class Printer():
|
||||
def __init__(self, gcodeManager):
|
||||
from collections import deque
|
||||
|
||||
self._gcodeManager = gcodeManager
|
||||
self._gcodeManager.registerCallback(self)
|
||||
|
||||
# state
|
||||
self._temp = None
|
||||
self._bedTemp = None
|
||||
self._targetTemp = None
|
||||
self._targetBedTemp = None
|
||||
self._temps = {
|
||||
"actual": deque([], 300),
|
||||
"target": deque([], 300),
|
||||
"actualBed": deque([], 300),
|
||||
"targetBed": deque([], 300)
|
||||
}
|
||||
self._tempBacklog = []
|
||||
|
||||
self._latestMessage = None
|
||||
self._messages = deque([], 300)
|
||||
self._messageBacklog = []
|
||||
|
||||
self._latestLog = None
|
||||
self._log = deque([], 300)
|
||||
self._logBacklog = []
|
||||
|
||||
self._state = None
|
||||
|
||||
self._currentZ = None
|
||||
|
||||
self._progress = None
|
||||
self._printTime = None
|
||||
self._printTimeLeft = None
|
||||
|
||||
self._printAfterSelect = False
|
||||
|
||||
# sd handling
|
||||
self._sdPrinting = False
|
||||
self._sdStreaming = False
|
||||
self._sdFilelistAvailable = threading.Event()
|
||||
|
||||
self._selectedFile = None
|
||||
|
||||
# comm
|
||||
self._comm = None
|
||||
|
||||
# callbacks
|
||||
self._callbacks = []
|
||||
self._lastProgressReport = None
|
||||
|
||||
self._stateMonitor = StateMonitor(
|
||||
ratelimit=0.5,
|
||||
updateCallback=self._sendCurrentDataCallbacks,
|
||||
addTemperatureCallback=self._sendAddTemperatureCallbacks,
|
||||
addLogCallback=self._sendAddLogCallbacks,
|
||||
addMessageCallback=self._sendAddMessageCallbacks
|
||||
)
|
||||
self._stateMonitor.reset(
|
||||
state={"state": None, "stateString": self.getStateString(), "flags": self._getStateFlags()},
|
||||
jobData={"filename": None, "filesize": None, "estimatedPrintTime": None, "filament": None},
|
||||
progress={"progress": None, "filepos": None, "printTime": None, "printTimeLeft": None},
|
||||
currentZ=None
|
||||
)
|
||||
|
||||
#~~ callback handling
|
||||
|
||||
def registerCallback(self, callback):
|
||||
self._callbacks.append(callback)
|
||||
self._sendInitialStateUpdate(callback)
|
||||
|
||||
def unregisterCallback(self, callback):
|
||||
if callback in self._callbacks:
|
||||
self._callbacks.remove(callback)
|
||||
|
||||
def _sendAddTemperatureCallbacks(self, data):
|
||||
for callback in self._callbacks:
|
||||
try: callback.addTemperature(data)
|
||||
except: pass
|
||||
|
||||
def _sendAddLogCallbacks(self, data):
|
||||
for callback in self._callbacks:
|
||||
try: callback.addLog(data)
|
||||
except: pass
|
||||
|
||||
def _sendAddMessageCallbacks(self, data):
|
||||
for callback in self._callbacks:
|
||||
try: callback.addMessage(data)
|
||||
except: pass
|
||||
|
||||
def _sendCurrentDataCallbacks(self, data):
|
||||
for callback in self._callbacks:
|
||||
try: callback.sendCurrentData(copy.deepcopy(data))
|
||||
except: pass
|
||||
|
||||
def _sendTriggerUpdateCallbacks(self, type):
|
||||
for callback in self._callbacks:
|
||||
try: callback.sendUpdateTrigger(type)
|
||||
except: pass
|
||||
|
||||
def _sendFeedbackCommandOutput(self, name, output):
|
||||
for callback in self._callbacks:
|
||||
try: callback.sendFeedbackCommandOutput(name, output)
|
||||
except: pass
|
||||
|
||||
#~~ callback from gcodemanager
|
||||
|
||||
def sendUpdateTrigger(self, type):
|
||||
if type == "gcodeFiles" and self._selectedFile:
|
||||
self._setJobData(self._selectedFile["filename"],
|
||||
self._selectedFile["filesize"],
|
||||
self._selectedFile["sd"])
|
||||
|
||||
#~~ printer commands
|
||||
|
||||
def connect(self, port=None, baudrate=None):
|
||||
"""
|
||||
Connects to the printer. If port and/or baudrate is provided, uses these settings, otherwise autodetection
|
||||
will be attempted.
|
||||
"""
|
||||
if self._comm is not None:
|
||||
self._comm.close()
|
||||
self._comm = comm.MachineCom(port, baudrate, callbackObject=self)
|
||||
|
||||
def disconnect(self):
|
||||
"""
|
||||
Closes the connection to the printer.
|
||||
"""
|
||||
if self._comm is not None:
|
||||
self._comm.close()
|
||||
self._comm = None
|
||||
eventManager().fire("Disconnected")
|
||||
|
||||
def command(self, command):
|
||||
"""
|
||||
Sends a single gcode command to the printer.
|
||||
"""
|
||||
self.commands([command])
|
||||
|
||||
def commands(self, commands):
|
||||
"""
|
||||
Sends multiple gcode commands (provided as a list) to the printer.
|
||||
"""
|
||||
if self._comm is None:
|
||||
return
|
||||
|
||||
for command in commands:
|
||||
self._comm.sendCommand(command)
|
||||
|
||||
def setTemperatureOffset(self, extruder, bed):
|
||||
if self._comm is None:
|
||||
return
|
||||
|
||||
self._comm.setTemperatureOffset(extruder, bed)
|
||||
self._stateMonitor.setTempOffsets(extruder, bed)
|
||||
|
||||
def selectFile(self, filename, sd, printAfterSelect=False):
|
||||
if self._comm is None or (self._comm.isBusy() or self._comm.isStreaming()):
|
||||
return
|
||||
|
||||
self._printAfterSelect = printAfterSelect
|
||||
self._comm.selectFile(filename, sd)
|
||||
self._setProgressData(0, None, None, None)
|
||||
self._setCurrentZ(None)
|
||||
|
||||
def unselectFile(self):
|
||||
if self._comm is not None and (self._comm.isBusy() or self._comm.isStreaming()):
|
||||
return
|
||||
|
||||
self._comm.unselectFile()
|
||||
self._setProgressData(0, None, None, None)
|
||||
self._setCurrentZ(None)
|
||||
|
||||
def startPrint(self):
|
||||
"""
|
||||
Starts the currently loaded print job.
|
||||
Only starts if the printer is connected and operational, not currently printing and a printjob is loaded
|
||||
"""
|
||||
if self._comm is None or not self._comm.isOperational() or self._comm.isPrinting():
|
||||
return
|
||||
if self._selectedFile is None:
|
||||
return
|
||||
|
||||
self._setCurrentZ(None)
|
||||
self._comm.startPrint()
|
||||
|
||||
def togglePausePrint(self):
|
||||
"""
|
||||
Pause the current printjob.
|
||||
"""
|
||||
if self._comm is None:
|
||||
return
|
||||
|
||||
self._comm.setPause(not self._comm.isPaused())
|
||||
|
||||
def cancelPrint(self, disableMotorsAndHeater=True):
|
||||
"""
|
||||
Cancel the current printjob.
|
||||
"""
|
||||
if self._comm is None:
|
||||
return
|
||||
|
||||
self._comm.cancelPrint()
|
||||
|
||||
if disableMotorsAndHeater:
|
||||
self.commands(["M84", "M104 S0", "M140 S0", "M106 S0"]) # disable motors, switch off heaters and fan
|
||||
|
||||
# reset progress, height, print time
|
||||
self._setCurrentZ(None)
|
||||
self._setProgressData(None, None, None, None)
|
||||
|
||||
# mark print as failure
|
||||
if self._selectedFile is not None:
|
||||
self._gcodeManager.printFailed(self._selectedFile["filename"])
|
||||
eventManager().fire("PrintFailed", self._selectedFile["filename"])
|
||||
|
||||
#~~ state monitoring
|
||||
|
||||
def _setCurrentZ(self, currentZ):
|
||||
self._currentZ = currentZ
|
||||
|
||||
formattedCurrentZ = None
|
||||
if self._currentZ:
|
||||
formattedCurrentZ = "%.2f mm" % (self._currentZ)
|
||||
self._stateMonitor.setCurrentZ(formattedCurrentZ)
|
||||
|
||||
def _setState(self, state):
|
||||
self._state = state
|
||||
self._stateMonitor.setState({"state": self._state, "stateString": self.getStateString(), "flags": self._getStateFlags()})
|
||||
|
||||
def _addLog(self, log):
|
||||
self._log.append(log)
|
||||
self._stateMonitor.addLog(log)
|
||||
|
||||
def _addMessage(self, message):
|
||||
self._messages.append(message)
|
||||
self._stateMonitor.addMessage(message)
|
||||
|
||||
def _setProgressData(self, progress, filepos, printTime, printTimeLeft):
|
||||
self._progress = progress
|
||||
self._printTime = printTime
|
||||
self._printTimeLeft = printTimeLeft
|
||||
|
||||
formattedPrintTime = None
|
||||
if (self._printTime):
|
||||
formattedPrintTime = util.getFormattedTimeDelta(datetime.timedelta(seconds=self._printTime))
|
||||
|
||||
formattedPrintTimeLeft = None
|
||||
if (self._printTimeLeft):
|
||||
formattedPrintTimeLeft = util.getFormattedTimeDelta(datetime.timedelta(minutes=self._printTimeLeft))
|
||||
|
||||
formattedFilePos = None
|
||||
if (filepos):
|
||||
formattedFilePos = util.getFormattedSize(filepos)
|
||||
|
||||
self._stateMonitor.setProgress({"progress": self._progress, "filepos": formattedFilePos, "printTime": formattedPrintTime, "printTimeLeft": formattedPrintTimeLeft})
|
||||
|
||||
def _addTemperatureData(self, temp, bedTemp, targetTemp, bedTargetTemp):
|
||||
currentTimeUtc = int(time.time() * 1000)
|
||||
|
||||
self._temps["actual"].append((currentTimeUtc, temp))
|
||||
self._temps["target"].append((currentTimeUtc, targetTemp))
|
||||
self._temps["actualBed"].append((currentTimeUtc, bedTemp))
|
||||
self._temps["targetBed"].append((currentTimeUtc, bedTargetTemp))
|
||||
|
||||
self._temp = temp
|
||||
self._bedTemp = bedTemp
|
||||
self._targetTemp = targetTemp
|
||||
self._targetBedTemp = bedTargetTemp
|
||||
|
||||
self._stateMonitor.addTemperature({"currentTime": currentTimeUtc, "temp": self._temp, "bedTemp": self._bedTemp, "targetTemp": self._targetTemp, "targetBedTemp": self._targetBedTemp})
|
||||
|
||||
def _setJobData(self, filename, filesize, sd):
|
||||
if filename is not None:
|
||||
self._selectedFile = {
|
||||
"filename": filename,
|
||||
"filesize": filesize,
|
||||
"sd": sd
|
||||
}
|
||||
else:
|
||||
self._selectedFile = None
|
||||
|
||||
formattedFilename = None
|
||||
formattedFilesize = None
|
||||
estimatedPrintTime = None
|
||||
fileMTime = None
|
||||
filament = None
|
||||
if filename:
|
||||
formattedFilename = os.path.basename(filename)
|
||||
|
||||
# Use a string for mtime because it could be float and the
|
||||
# javascript needs to exact match
|
||||
if not sd:
|
||||
fileMTime = str(os.stat(filename).st_mtime)
|
||||
|
||||
if filesize:
|
||||
formattedFilesize = util.getFormattedSize(filesize)
|
||||
|
||||
fileData = self._gcodeManager.getFileData(filename)
|
||||
if fileData is not None and "gcodeAnalysis" in fileData.keys():
|
||||
if "estimatedPrintTime" in fileData["gcodeAnalysis"].keys():
|
||||
estimatedPrintTime = fileData["gcodeAnalysis"]["estimatedPrintTime"]
|
||||
if "filament" in fileData["gcodeAnalysis"].keys():
|
||||
filament = fileData["gcodeAnalysis"]["filament"]
|
||||
|
||||
self._stateMonitor.setJobData({"filename": formattedFilename, "filesize": formattedFilesize, "estimatedPrintTime": estimatedPrintTime, "filament": filament, "sd": sd, "mtime": fileMTime})
|
||||
|
||||
def _sendInitialStateUpdate(self, callback):
|
||||
try:
|
||||
data = self._stateMonitor.getCurrentData()
|
||||
# convert the dict of deques to a dict of lists
|
||||
temps = {k: list(v) for (k,v) in self._temps.iteritems()}
|
||||
data.update({
|
||||
"temperatureHistory": temps,
|
||||
"logHistory": list(self._log),
|
||||
"messageHistory": list(self._messages)
|
||||
})
|
||||
callback.sendHistoryData(data)
|
||||
except Exception, err:
|
||||
import sys
|
||||
sys.stderr.write("ERROR: %s\n" % str(err))
|
||||
pass
|
||||
|
||||
def _getStateFlags(self):
|
||||
if not settings().getBoolean(["feature", "sdSupport"]) or self._comm is None:
|
||||
sdReady = False
|
||||
else:
|
||||
sdReady = self._comm.isSdReady()
|
||||
|
||||
return {
|
||||
"operational": self.isOperational(),
|
||||
"printing": self.isPrinting(),
|
||||
"closedOrError": self.isClosedOrError(),
|
||||
"error": self.isError(),
|
||||
"paused": self.isPaused(),
|
||||
"ready": self.isReady(),
|
||||
"sdReady": sdReady
|
||||
}
|
||||
|
||||
def getCurrentData(self):
|
||||
return self._stateMonitor.getCurrentData()
|
||||
|
||||
#~~ callbacks triggered from self._comm
|
||||
|
||||
def mcLog(self, message):
|
||||
"""
|
||||
Callback method for the comm object, called upon log output.
|
||||
"""
|
||||
self._addLog(message)
|
||||
|
||||
def mcTempUpdate(self, temp, bedTemp, targetTemp, bedTargetTemp):
|
||||
self._addTemperatureData(temp, bedTemp, targetTemp, bedTargetTemp)
|
||||
|
||||
def mcStateChange(self, state):
|
||||
"""
|
||||
Callback method for the comm object, called if the connection state changes.
|
||||
"""
|
||||
oldState = self._state
|
||||
|
||||
# forward relevant state changes to gcode manager
|
||||
if self._comm is not None and oldState == self._comm.STATE_PRINTING:
|
||||
if self._selectedFile is not None:
|
||||
if state == self._comm.STATE_OPERATIONAL:
|
||||
self._gcodeManager.printSucceeded(self._selectedFile["filename"])
|
||||
elif state == self._comm.STATE_CLOSED or state == self._comm.STATE_ERROR or state == self._comm.STATE_CLOSED_WITH_ERROR:
|
||||
self._gcodeManager.printFailed(self._selectedFile["filename"])
|
||||
self._gcodeManager.resumeAnalysis() # printing done, put those cpu cycles to good use
|
||||
elif self._comm is not None and state == self._comm.STATE_PRINTING:
|
||||
self._gcodeManager.pauseAnalysis() # do not analyse gcode while printing
|
||||
|
||||
self._setState(state)
|
||||
|
||||
def mcMessage(self, message):
|
||||
"""
|
||||
Callback method for the comm object, called upon message exchanges via serial.
|
||||
Stores the message in the message buffer, truncates buffer to the last 300 lines.
|
||||
"""
|
||||
self._addMessage(message)
|
||||
|
||||
def mcProgress(self):
|
||||
"""
|
||||
Callback method for the comm object, called upon any change in progress of the printjob.
|
||||
Triggers storage of new values for printTime, printTimeLeft and the current progress.
|
||||
"""
|
||||
|
||||
self._setProgressData(self._comm.getPrintProgress(), self._comm.getPrintFilepos(), self._comm.getPrintTime(), self._comm.getPrintTimeRemainingEstimate())
|
||||
|
||||
def mcZChange(self, newZ):
|
||||
"""
|
||||
Callback method for the comm object, called upon change of the z-layer.
|
||||
"""
|
||||
oldZ = self._currentZ
|
||||
if newZ != oldZ:
|
||||
# we have to react to all z-changes, even those that might "go backward" due to a slicer's retraction or
|
||||
# anti-backlash-routines. Event subscribes should individually take care to filter out "wrong" z-changes
|
||||
eventManager().fire("ZChange", newZ)
|
||||
|
||||
self._setCurrentZ(newZ)
|
||||
|
||||
def mcSdStateChange(self, sdReady):
|
||||
self._stateMonitor.setState({"state": self._state, "stateString": self.getStateString(), "flags": self._getStateFlags()})
|
||||
|
||||
def mcSdFiles(self, files):
|
||||
self._sendTriggerUpdateCallbacks("gcodeFiles")
|
||||
self._sdFilelistAvailable.set()
|
||||
|
||||
def mcFileSelected(self, filename, filesize, sd):
|
||||
self._setJobData(filename, filesize, sd)
|
||||
self._stateMonitor.setState({"state": self._state, "stateString": self.getStateString(), "flags": self._getStateFlags()})
|
||||
|
||||
if self._printAfterSelect:
|
||||
self.startPrint()
|
||||
|
||||
def mcPrintjobDone(self):
|
||||
self._setProgressData(1.0, self._selectedFile["filesize"], self._comm.getPrintTime(), 0)
|
||||
self._stateMonitor.setState({"state": self._state, "stateString": self.getStateString(), "flags": self._getStateFlags()})
|
||||
|
||||
def mcFileTransferStarted(self, filename, filesize):
|
||||
self._sdStreaming = True
|
||||
|
||||
self._setJobData(filename, filesize, True)
|
||||
self._setProgressData(0.0, 0, 0, None)
|
||||
self._stateMonitor.setState({"state": self._state, "stateString": self.getStateString(), "flags": self._getStateFlags()})
|
||||
|
||||
def mcFileTransferDone(self):
|
||||
self._sdStreaming = False
|
||||
|
||||
self._setCurrentZ(None)
|
||||
self._setJobData(None, None, None)
|
||||
self._setProgressData(None, None, None, None)
|
||||
self._stateMonitor.setState({"state": self._state, "stateString": self.getStateString(), "flags": self._getStateFlags()})
|
||||
|
||||
def mcReceivedRegisteredMessage(self, command, output):
|
||||
self._sendFeedbackCommandOutput(command, output)
|
||||
|
||||
#~~ sd file handling
|
||||
|
||||
def getSdFiles(self):
|
||||
if self._comm is None or not self._comm.isSdReady():
|
||||
return []
|
||||
return self._comm.getSdFiles()
|
||||
|
||||
def addSdFile(self, filename, path):
|
||||
if not self._comm or self._comm.isBusy() or not self._comm.isSdReady():
|
||||
return
|
||||
|
||||
self.refreshSdFiles(blocking=True)
|
||||
existingSdFiles = self._comm.getSdFiles()
|
||||
|
||||
sdFilename = util.getDosFilename(filename, existingSdFiles)
|
||||
self._comm.startFileTransfer(path, sdFilename)
|
||||
|
||||
def deleteSdFile(self, filename):
|
||||
if not self._comm or not self._comm.isSdReady():
|
||||
return
|
||||
self._comm.deleteSdFile(filename)
|
||||
|
||||
def initSdCard(self):
|
||||
if not self._comm or self._comm.isSdReady():
|
||||
return
|
||||
self._comm.initSdCard()
|
||||
|
||||
def releaseSdCard(self):
|
||||
if not self._comm or not self._comm.isSdReady():
|
||||
return
|
||||
self._comm.releaseSdCard()
|
||||
|
||||
def refreshSdFiles(self, blocking=False):
|
||||
"""
|
||||
Refreshs the list of file stored on the SD card attached to printer (if available and printer communication
|
||||
available). Optional blocking parameter allows making the method block (max 10s) until the file list has been
|
||||
received (and can be accessed via self._comm.getSdFiles()). Defaults to a asynchronous operation.
|
||||
"""
|
||||
if not self._comm or not self._comm.isSdReady():
|
||||
return
|
||||
self._sdFilelistAvailable.clear()
|
||||
self._comm.refreshSdFiles()
|
||||
if blocking:
|
||||
self._sdFilelistAvailable.wait(10000)
|
||||
|
||||
#~~ state reports
|
||||
|
||||
def getStateString(self):
|
||||
"""
|
||||
Returns a human readable string corresponding to the current communication state.
|
||||
"""
|
||||
if self._comm is None:
|
||||
return "Offline"
|
||||
else:
|
||||
return self._comm.getStateString()
|
||||
|
||||
def getCurrentData(self):
|
||||
return self._stateMonitor.getCurrentData()
|
||||
|
||||
def getCurrentJob(self):
|
||||
currentData = self._stateMonitor.getCurrentData()
|
||||
return currentData["job"]
|
||||
|
||||
def getCurrentTemperatures(self):
|
||||
if self._comm is not None:
|
||||
(tempOffset, bedTempOffset) = self._comm.getOffsets()
|
||||
else:
|
||||
tempOffset = 0
|
||||
bedTempOffset = 0
|
||||
|
||||
return {
|
||||
"extruder": {
|
||||
"current": self._temp,
|
||||
"target": self._targetTemp,
|
||||
"offset": tempOffset
|
||||
},
|
||||
"bed": {
|
||||
"current": self._bedTemp,
|
||||
"target": self._targetBedTemp,
|
||||
"offset": bedTempOffset
|
||||
}
|
||||
}
|
||||
|
||||
def isClosedOrError(self):
|
||||
return self._comm is None or self._comm.isClosedOrError()
|
||||
|
||||
def isOperational(self):
|
||||
return self._comm is not None and self._comm.isOperational()
|
||||
|
||||
def isPrinting(self):
|
||||
return self._comm is not None and self._comm.isPrinting()
|
||||
|
||||
def isPaused(self):
|
||||
return self._comm is not None and self._comm.isPaused()
|
||||
|
||||
def isError(self):
|
||||
return self._comm is not None and self._comm.isError()
|
||||
|
||||
def isReady(self):
|
||||
return self.isOperational() and not self._comm.isStreaming()
|
||||
|
||||
def isLoading(self):
|
||||
return self._gcodeLoader is not None
|
||||
|
||||
class StateMonitor(object):
|
||||
def __init__(self, ratelimit, updateCallback, addTemperatureCallback, addLogCallback, addMessageCallback):
|
||||
self._ratelimit = ratelimit
|
||||
self._updateCallback = updateCallback
|
||||
self._addTemperatureCallback = addTemperatureCallback
|
||||
self._addLogCallback = addLogCallback
|
||||
self._addMessageCallback = addMessageCallback
|
||||
|
||||
self._state = None
|
||||
self._jobData = None
|
||||
self._gcodeData = None
|
||||
self._sdUploadData = None
|
||||
self._currentZ = None
|
||||
self._progress = None
|
||||
|
||||
self._tempOffset = 0
|
||||
self._bedTempOffset = 0
|
||||
|
||||
self._changeEvent = threading.Event()
|
||||
|
||||
self._lastUpdate = time.time()
|
||||
self._worker = threading.Thread(target=self._work)
|
||||
self._worker.daemon = True
|
||||
self._worker.start()
|
||||
|
||||
def reset(self, state=None, jobData=None, progress=None, currentZ=None):
|
||||
self.setState(state)
|
||||
self.setJobData(jobData)
|
||||
self.setProgress(progress)
|
||||
self.setCurrentZ(currentZ)
|
||||
|
||||
def addTemperature(self, temperature):
|
||||
self._addTemperatureCallback(temperature)
|
||||
self._changeEvent.set()
|
||||
|
||||
def addLog(self, log):
|
||||
self._addLogCallback(log)
|
||||
self._changeEvent.set()
|
||||
|
||||
def addMessage(self, message):
|
||||
self._addMessageCallback(message)
|
||||
self._changeEvent.set()
|
||||
|
||||
def setCurrentZ(self, currentZ):
|
||||
self._currentZ = currentZ
|
||||
self._changeEvent.set()
|
||||
|
||||
def setState(self, state):
|
||||
self._state = state
|
||||
self._changeEvent.set()
|
||||
|
||||
def setJobData(self, jobData):
|
||||
self._jobData = jobData
|
||||
self._changeEvent.set()
|
||||
|
||||
def setProgress(self, progress):
|
||||
self._progress = progress
|
||||
self._changeEvent.set()
|
||||
|
||||
def setTempOffsets(self, tempOffset, bedTempOffset):
|
||||
if tempOffset is not None:
|
||||
self._tempOffset = tempOffset
|
||||
if bedTempOffset is not None:
|
||||
self._bedTempOffset = bedTempOffset
|
||||
self._changeEvent.set()
|
||||
|
||||
def _work(self):
|
||||
while True:
|
||||
self._changeEvent.wait()
|
||||
|
||||
now = time.time()
|
||||
delta = now - self._lastUpdate
|
||||
additionalWaitTime = self._ratelimit - delta
|
||||
if additionalWaitTime > 0:
|
||||
time.sleep(additionalWaitTime)
|
||||
|
||||
data = self.getCurrentData()
|
||||
self._updateCallback(data)
|
||||
self._lastUpdate = time.time()
|
||||
self._changeEvent.clear()
|
||||
|
||||
def getCurrentData(self):
|
||||
return {
|
||||
"state": self._state,
|
||||
"job": self._jobData,
|
||||
"currentZ": self._currentZ,
|
||||
"progress": self._progress,
|
||||
"offsets": (self._tempOffset, self._bedTempOffset)
|
||||
}
|
||||
|
||||
@@ -1,406 +0,0 @@
|
||||
# coding=utf-8
|
||||
__author__ = "Gina Häußge <osd@foosel.net>"
|
||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||
|
||||
import sys
|
||||
import os
|
||||
import yaml
|
||||
import logging
|
||||
import re
|
||||
import uuid
|
||||
|
||||
APPNAME="OctoPrint"
|
||||
|
||||
instance = None
|
||||
|
||||
def settings(init=False, configfile=None, basedir=None):
|
||||
global instance
|
||||
if instance is None:
|
||||
if init:
|
||||
instance = Settings(configfile, basedir)
|
||||
else:
|
||||
raise ValueError("Settings not initialized yet")
|
||||
return instance
|
||||
|
||||
default_settings = {
|
||||
"serial": {
|
||||
"port": None,
|
||||
"baudrate": None,
|
||||
"autoconnect": False,
|
||||
"log": False,
|
||||
"timeout": {
|
||||
"detection": 0.5,
|
||||
"connection": 2,
|
||||
"communication": 5
|
||||
},
|
||||
"additionalPorts": []
|
||||
},
|
||||
"server": {
|
||||
"host": "0.0.0.0",
|
||||
"port": 5000,
|
||||
"firstRun": True
|
||||
},
|
||||
"webcam": {
|
||||
"stream": None,
|
||||
"snapshot": None,
|
||||
"ffmpeg": None,
|
||||
"bitrate": "5000k",
|
||||
"watermark": True,
|
||||
"flipH": False,
|
||||
"flipV": False,
|
||||
"timelapse": {
|
||||
"type": "off",
|
||||
"options": {}
|
||||
}
|
||||
},
|
||||
"feature": {
|
||||
"gCodeVisualizer": True,
|
||||
"temperatureGraph": True,
|
||||
"waitForStartOnConnect": False,
|
||||
"alwaysSendChecksum": False,
|
||||
"sdSupport": True,
|
||||
"swallowOkAfterResend": True
|
||||
},
|
||||
"folder": {
|
||||
"uploads": None,
|
||||
"timelapse": None,
|
||||
"timelapse_tmp": None,
|
||||
"logs": None,
|
||||
"virtualSd": None
|
||||
},
|
||||
"temperature": {
|
||||
"profiles":
|
||||
[
|
||||
{"name": "ABS", "extruder" : 210, "bed" : 100 },
|
||||
{"name": "PLA", "extruder" : 180, "bed" : 60 }
|
||||
]
|
||||
},
|
||||
"printerParameters": {
|
||||
"movementSpeed": {
|
||||
"x": 6000,
|
||||
"y": 6000,
|
||||
"z": 200,
|
||||
"e": 300
|
||||
},
|
||||
"pauseTriggers": []
|
||||
},
|
||||
"appearance": {
|
||||
"name": "",
|
||||
"color": "default"
|
||||
},
|
||||
"controls": [],
|
||||
"system": {
|
||||
"actions": []
|
||||
},
|
||||
"accessControl": {
|
||||
"enabled": True,
|
||||
"userManager": "octoprint.users.FilebasedUserManager",
|
||||
"userfile": None,
|
||||
"autologinLocal": False,
|
||||
"localNetworks": ["127.0.0.0/8"],
|
||||
"autologinAs": None
|
||||
},
|
||||
"events": {
|
||||
"systemCommandTrigger": {
|
||||
"enabled": False
|
||||
},
|
||||
"gcodeCommandTrigger": {
|
||||
"enabled": False
|
||||
}
|
||||
},
|
||||
"api": {
|
||||
"enabled": False,
|
||||
"key": ''.join('%02X' % ord(z) for z in uuid.uuid4().bytes)
|
||||
},
|
||||
"terminalFilters": [
|
||||
{ "name": "Suppress M105 requests/responses", "regex": "(Send: M105)|(Recv: ok T:)" },
|
||||
{ "name": "Suppress M27 requests/responses", "regex": "(Send: M27)|(Recv: SD printing byte)" }
|
||||
],
|
||||
"devel": {
|
||||
"virtualPrinter": {
|
||||
"enabled": False,
|
||||
"okAfterResend": False,
|
||||
"forceChecksum": False,
|
||||
"okWithLinenumber": False
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
valid_boolean_trues = ["true", "yes", "y", "1"]
|
||||
|
||||
class Settings(object):
|
||||
|
||||
def __init__(self, configfile=None, basedir=None):
|
||||
self._logger = logging.getLogger(__name__)
|
||||
|
||||
self.settings_dir = None
|
||||
|
||||
self._config = None
|
||||
self._dirty = False
|
||||
|
||||
self._init_settings_dir(basedir)
|
||||
|
||||
if configfile is not None:
|
||||
self._configfile = configfile
|
||||
else:
|
||||
self._configfile = os.path.join(self.settings_dir, "config.yaml")
|
||||
self.load()
|
||||
|
||||
def _init_settings_dir(self, basedir):
|
||||
if basedir is not None:
|
||||
self.settings_dir = basedir
|
||||
else:
|
||||
self.settings_dir = _resolveSettingsDir(APPNAME)
|
||||
|
||||
def _getDefaultFolder(self, type):
|
||||
folder = default_settings["folder"][type]
|
||||
if folder is None:
|
||||
folder = os.path.join(self.settings_dir, type.replace("_", os.path.sep))
|
||||
return folder
|
||||
|
||||
#~~ load and save
|
||||
|
||||
def load(self):
|
||||
if os.path.exists(self._configfile) and os.path.isfile(self._configfile):
|
||||
with open(self._configfile, "r") as f:
|
||||
self._config = yaml.safe_load(f)
|
||||
# chamged from else to handle cases where the file exists, but is empty / 0 bytes
|
||||
if not self._config:
|
||||
self._config = {}
|
||||
|
||||
def save(self, force=False):
|
||||
if not self._dirty and not force:
|
||||
return
|
||||
|
||||
with open(self._configfile, "wb") as configFile:
|
||||
yaml.safe_dump(self._config, configFile, default_flow_style=False, indent=" ", allow_unicode=True)
|
||||
self._dirty = False
|
||||
self.load()
|
||||
|
||||
#~~ getter
|
||||
|
||||
def get(self, path):
|
||||
if len(path) == 0:
|
||||
return None
|
||||
|
||||
config = self._config
|
||||
defaults = default_settings
|
||||
|
||||
while len(path) > 1:
|
||||
key = path.pop(0)
|
||||
if key in config.keys() and key in defaults.keys():
|
||||
config = config[key]
|
||||
defaults = defaults[key]
|
||||
elif key in defaults.keys():
|
||||
config = {}
|
||||
defaults = defaults[key]
|
||||
else:
|
||||
return None
|
||||
|
||||
k = path.pop(0)
|
||||
if not isinstance(k, (list, tuple)):
|
||||
keys = [k]
|
||||
else:
|
||||
keys = k
|
||||
|
||||
results = []
|
||||
for key in keys:
|
||||
if key in config.keys():
|
||||
results.append(config[key])
|
||||
elif key in defaults:
|
||||
results.append(defaults[key])
|
||||
else:
|
||||
results.append(None)
|
||||
|
||||
if not isinstance(k, (list, tuple)):
|
||||
return results.pop()
|
||||
else:
|
||||
return results
|
||||
|
||||
def getInt(self, path):
|
||||
value = self.get(path)
|
||||
if value is None:
|
||||
return None
|
||||
|
||||
try:
|
||||
return int(value)
|
||||
except ValueError:
|
||||
self._logger.warn("Could not convert %r to a valid integer when getting option %r" % (value, path))
|
||||
return None
|
||||
|
||||
def getFloat(self, path):
|
||||
value = self.get(path)
|
||||
if value is None:
|
||||
return None
|
||||
|
||||
try:
|
||||
return float(value)
|
||||
except ValueError:
|
||||
self._logger.warn("Could not convert %r to a valid integer when getting option %r" % (value, path))
|
||||
return None
|
||||
|
||||
def getBoolean(self, path):
|
||||
value = self.get(path)
|
||||
if value is None:
|
||||
return None
|
||||
if isinstance(value, bool):
|
||||
return value
|
||||
return value.lower() in valid_boolean_trues
|
||||
|
||||
def getBaseFolder(self, type):
|
||||
if type not in default_settings["folder"].keys():
|
||||
return None
|
||||
|
||||
folder = self.get(["folder", type])
|
||||
if folder is None:
|
||||
folder = self._getDefaultFolder(type)
|
||||
|
||||
if not os.path.isdir(folder):
|
||||
os.makedirs(folder)
|
||||
|
||||
return folder
|
||||
|
||||
def getFeedbackControls(self):
|
||||
feedbackControls = []
|
||||
for control in self.get(["controls"]):
|
||||
feedbackControls.extend(self._getFeedbackControls(control))
|
||||
return feedbackControls
|
||||
|
||||
def _getFeedbackControls(self, control=None):
|
||||
if control["type"] == "feedback_command" or control["type"] == "feedback":
|
||||
pattern = control["regex"]
|
||||
try:
|
||||
matcher = re.compile(pattern)
|
||||
return [(control["name"], matcher, control["template"])]
|
||||
except:
|
||||
# invalid regex or something like this, we'll just skip this entry
|
||||
pass
|
||||
elif control["type"] == "section":
|
||||
result = []
|
||||
for c in control["children"]:
|
||||
result.extend(self._getFeedbackControls(c))
|
||||
return result
|
||||
else:
|
||||
return []
|
||||
|
||||
def getPauseTriggers(self):
|
||||
triggers = {
|
||||
"enable": [],
|
||||
"disable": [],
|
||||
"toggle": []
|
||||
}
|
||||
for trigger in self.get(["printerParameters", "pauseTriggers"]):
|
||||
try:
|
||||
regex = trigger["regex"]
|
||||
type = trigger["type"]
|
||||
if type in triggers.keys():
|
||||
# make sure regex is valid
|
||||
re.compile(regex)
|
||||
# add to type list
|
||||
triggers[type].append(regex)
|
||||
except:
|
||||
# invalid regex or something like this, we'll just skip this entry
|
||||
pass
|
||||
|
||||
result = {}
|
||||
for type in triggers.keys():
|
||||
if len(triggers[type]) > 0:
|
||||
result[type] = re.compile("|".join(map(lambda x: "(%s)" % x, triggers[type])))
|
||||
return result
|
||||
|
||||
#~~ setter
|
||||
|
||||
def set(self, path, value, force=False):
|
||||
if len(path) == 0:
|
||||
return
|
||||
|
||||
config = self._config
|
||||
defaults = default_settings
|
||||
|
||||
while len(path) > 1:
|
||||
key = path.pop(0)
|
||||
if key in config.keys() and key in defaults.keys():
|
||||
config = config[key]
|
||||
defaults = defaults[key]
|
||||
elif key in defaults.keys():
|
||||
config[key] = {}
|
||||
config = config[key]
|
||||
defaults = defaults[key]
|
||||
else:
|
||||
return
|
||||
|
||||
key = path.pop(0)
|
||||
if not force and key in defaults.keys() and key in config.keys() and defaults[key] == value:
|
||||
del config[key]
|
||||
self._dirty = True
|
||||
elif force or (not key in config.keys() and defaults[key] != value) or (key in config.keys() and config[key] != value):
|
||||
if value is None:
|
||||
del config[key]
|
||||
else:
|
||||
config[key] = value
|
||||
self._dirty = True
|
||||
|
||||
def setInt(self, path, value, force=False):
|
||||
if value is None:
|
||||
self.set(path, None, force)
|
||||
return
|
||||
|
||||
try:
|
||||
intValue = int(value)
|
||||
except ValueError:
|
||||
self._logger.warn("Could not convert %r to a valid integer when setting option %r" % (value, path))
|
||||
return
|
||||
|
||||
self.set(path, intValue, force)
|
||||
|
||||
def setFloat(self, path, value, force=False):
|
||||
if value is None:
|
||||
self.set(path, None, force)
|
||||
return
|
||||
|
||||
try:
|
||||
floatValue = float(value)
|
||||
except ValueError:
|
||||
self._logger.warn("Could not convert %r to a valid integer when setting option %r" % (value, path))
|
||||
return
|
||||
|
||||
self.set(path, floatValue, force)
|
||||
|
||||
def setBoolean(self, path, value, force=False):
|
||||
if value is None or isinstance(value, bool):
|
||||
self.set(path, value, force)
|
||||
elif value.lower() in valid_boolean_trues:
|
||||
self.set(path, True, force)
|
||||
else:
|
||||
self.set(path, False, force)
|
||||
|
||||
def setBaseFolder(self, type, path, force=False):
|
||||
if type not in default_settings["folder"].keys():
|
||||
return None
|
||||
|
||||
currentPath = self.getBaseFolder(type)
|
||||
defaultPath = self._getDefaultFolder(type)
|
||||
if (path is None or path == defaultPath) and "folder" in self._config.keys() and type in self._config["folder"].keys():
|
||||
del self._config["folder"][type]
|
||||
if not self._config["folder"]:
|
||||
del self._config["folder"]
|
||||
self._dirty = True
|
||||
elif (path != currentPath and path != defaultPath) or force:
|
||||
if not "folder" in self._config.keys():
|
||||
self._config["folder"] = {}
|
||||
self._config["folder"][type] = path
|
||||
self._dirty = True
|
||||
|
||||
def _resolveSettingsDir(applicationName):
|
||||
# taken from http://stackoverflow.com/questions/1084697/how-do-i-store-desktop-application-data-in-a-cross-platform-way-for-python
|
||||
if sys.platform == "darwin":
|
||||
from AppKit import NSSearchPathForDirectoriesInDomains
|
||||
# http://developer.apple.com/DOCUMENTATION/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Functions/Reference/reference.html#//apple_ref/c/func/NSSearchPathForDirectoriesInDomains
|
||||
# NSApplicationSupportDirectory = 14
|
||||
# NSUserDomainMask = 1
|
||||
# True for expanding the tilde into a fully qualified path
|
||||
return os.path.join(NSSearchPathForDirectoriesInDomains(14, 1, True)[0], applicationName)
|
||||
elif sys.platform == "win32":
|
||||
return os.path.join(os.environ["APPDATA"], applicationName)
|
||||
else:
|
||||
return os.path.expanduser(os.path.join("~", "." + applicationName.lower()))
|
||||
@@ -1,33 +0,0 @@
|
||||
/*!
|
||||
* Font Awesome 3.0.2
|
||||
* the iconic font designed for use with Twitter Bootstrap
|
||||
* -------------------------------------------------------
|
||||
* The full suite of pictographic icons, examples, and documentation
|
||||
* can be found at: http://fortawesome.github.com/Font-Awesome/
|
||||
*
|
||||
* License
|
||||
* -------------------------------------------------------
|
||||
* - The Font Awesome font is licensed under the SIL Open Font License - http://scripts.sil.org/OFL
|
||||
* - Font Awesome CSS, LESS, and SASS files are licensed under the MIT License -
|
||||
* http://opensource.org/licenses/mit-license.html
|
||||
* - The Font Awesome pictograms are licensed under the CC BY 3.0 License - http://creativecommons.org/licenses/by/3.0/
|
||||
* - Attribution is no longer required in Font Awesome 3.0, but much appreciated:
|
||||
* "Font Awesome by Dave Gandy - http://fortawesome.github.com/Font-Awesome"
|
||||
|
||||
* Contact
|
||||
* -------------------------------------------------------
|
||||
* Email: dave@davegandy.com
|
||||
* Twitter: http://twitter.com/fortaweso_me
|
||||
* Work: Lead Product Designer @ http://kyruus.com
|
||||
*/
|
||||
|
||||
@font-face{
|
||||
font-family:'FontAwesome';
|
||||
src:url('../font/fontawesome-webfont.eot?v=3.0.1');
|
||||
src:url('../font/fontawesome-webfont.eot?#iefix&v=3.0.1') format('embedded-opentype'),
|
||||
url('../font/fontawesome-webfont.woff?v=3.0.1') format('woff'),
|
||||
url('../font/fontawesome-webfont.ttf?v=3.0.1') format('truetype');
|
||||
font-weight:normal;
|
||||
font-style:normal }
|
||||
|
||||
[class^="icon-"],[class*=" icon-"]{font-family:FontAwesome;font-weight:normal;font-style:normal;text-decoration:inherit;-webkit-font-smoothing:antialiased;display:inline;width:auto;height:auto;line-height:normal;vertical-align:baseline;background-image:none;background-position:0 0;background-repeat:repeat;margin-top:0}.icon-white,.nav-pills>.active>a>[class^="icon-"],.nav-pills>.active>a>[class*=" icon-"],.nav-list>.active>a>[class^="icon-"],.nav-list>.active>a>[class*=" icon-"],.navbar-inverse .nav>.active>a>[class^="icon-"],.navbar-inverse .nav>.active>a>[class*=" icon-"],.dropdown-menu>li>a:hover>[class^="icon-"],.dropdown-menu>li>a:hover>[class*=" icon-"],.dropdown-menu>.active>a>[class^="icon-"],.dropdown-menu>.active>a>[class*=" icon-"],.dropdown-submenu:hover>a>[class^="icon-"],.dropdown-submenu:hover>a>[class*=" icon-"]{background-image:none}[class^="icon-"]:before,[class*=" icon-"]:before{text-decoration:inherit;display:inline-block;speak:none}a [class^="icon-"],a [class*=" icon-"]{display:inline-block}.icon-large:before{vertical-align:-10%;font-size:1.3333333333333333em}.btn [class^="icon-"],.nav [class^="icon-"],.btn [class*=" icon-"],.nav [class*=" icon-"]{display:inline}.btn [class^="icon-"].icon-large,.nav [class^="icon-"].icon-large,.btn [class*=" icon-"].icon-large,.nav [class*=" icon-"].icon-large{line-height:.9em}.btn [class^="icon-"].icon-spin,.nav [class^="icon-"].icon-spin,.btn [class*=" icon-"].icon-spin,.nav [class*=" icon-"].icon-spin{display:inline-block}.nav-tabs [class^="icon-"],.nav-pills [class^="icon-"],.nav-tabs [class*=" icon-"],.nav-pills [class*=" icon-"],.nav-tabs [class^="icon-"].icon-large,.nav-pills [class^="icon-"].icon-large,.nav-tabs [class*=" icon-"].icon-large,.nav-pills [class*=" icon-"].icon-large{line-height:.9em}li [class^="icon-"],.nav li [class^="icon-"],li [class*=" icon-"],.nav li [class*=" icon-"]{display:inline-block;width:1.25em;text-align:center}li [class^="icon-"].icon-large,.nav li [class^="icon-"].icon-large,li [class*=" icon-"].icon-large,.nav li [class*=" icon-"].icon-large{width:1.5625em}ul.icons{list-style-type:none;text-indent:-0.75em}ul.icons li [class^="icon-"],ul.icons li [class*=" icon-"]{width:.75em}.icon-muted{color:#eee}.icon-border{border:solid 1px #eee;padding:.2em .25em .15em;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.icon-2x{font-size:2em}.icon-2x.icon-border{border-width:2px;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.icon-3x{font-size:3em}.icon-3x.icon-border{border-width:3px;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.icon-4x{font-size:4em}.icon-4x.icon-border{border-width:4px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.pull-right{float:right}.pull-left{float:left}[class^="icon-"].pull-left,[class*=" icon-"].pull-left{margin-right:.3em}[class^="icon-"].pull-right,[class*=" icon-"].pull-right{margin-left:.3em}.btn [class^="icon-"].pull-left.icon-2x,.btn [class*=" icon-"].pull-left.icon-2x,.btn [class^="icon-"].pull-right.icon-2x,.btn [class*=" icon-"].pull-right.icon-2x{margin-top:.18em}.btn [class^="icon-"].icon-spin.icon-large,.btn [class*=" icon-"].icon-spin.icon-large{line-height:.8em}.btn.btn-small [class^="icon-"].pull-left.icon-2x,.btn.btn-small [class*=" icon-"].pull-left.icon-2x,.btn.btn-small [class^="icon-"].pull-right.icon-2x,.btn.btn-small [class*=" icon-"].pull-right.icon-2x{margin-top:.25em}.btn.btn-large [class^="icon-"],.btn.btn-large [class*=" icon-"]{margin-top:0}.btn.btn-large [class^="icon-"].pull-left.icon-2x,.btn.btn-large [class*=" icon-"].pull-left.icon-2x,.btn.btn-large [class^="icon-"].pull-right.icon-2x,.btn.btn-large [class*=" icon-"].pull-right.icon-2x{margin-top:.05em}.btn.btn-large [class^="icon-"].pull-left.icon-2x,.btn.btn-large [class*=" icon-"].pull-left.icon-2x{margin-right:.2em}.btn.btn-large [class^="icon-"].pull-right.icon-2x,.btn.btn-large [class*=" icon-"].pull-right.icon-2x{margin-left:.2em}.icon-spin{display:inline-block;-moz-animation:spin 2s infinite linear;-o-animation:spin 2s infinite linear;-webkit-animation:spin 2s infinite linear;animation:spin 2s infinite linear}@-moz-keyframes spin{0%{-moz-transform:rotate(0deg)}100%{-moz-transform:rotate(359deg)}}@-webkit-keyframes spin{0%{-webkit-transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg)}}@-o-keyframes spin{0%{-o-transform:rotate(0deg)}100%{-o-transform:rotate(359deg)}}@-ms-keyframes spin{0%{-ms-transform:rotate(0deg)}100%{-ms-transform:rotate(359deg)}}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(359deg)}}@-moz-document url-prefix(){.icon-spin{height:.9em}.btn .icon-spin{height:auto}.icon-spin.icon-large{height:1.25em}.btn .icon-spin.icon-large{height:.75em}}.icon-glass:before{content:"\f000"}.icon-music:before{content:"\f001"}.icon-search:before{content:"\f002"}.icon-envelope:before{content:"\f003"}.icon-heart:before{content:"\f004"}.icon-star:before{content:"\f005"}.icon-star-empty:before{content:"\f006"}.iconLine truncated
|
||||
@@ -1,83 +0,0 @@
|
||||
/*
|
||||
Document : jquery.pnotify.default.css
|
||||
Created on : Nov 23, 2009, 3:14:10 PM
|
||||
Author : Hunter Perrin
|
||||
Version : 1.2.0
|
||||
Link : http://pinesframework.org/pnotify/
|
||||
Description:
|
||||
Default styling for Pines Notify jQuery plugin.
|
||||
*/
|
||||
/* -- Notice */
|
||||
.ui-pnotify {
|
||||
top: 25px;
|
||||
right: 25px;
|
||||
position: absolute;
|
||||
height: auto;
|
||||
/* Ensures notices are above everything */
|
||||
z-index: 9999;
|
||||
}
|
||||
/* Hides position: fixed from IE6 */
|
||||
html > body .ui-pnotify {
|
||||
position: fixed;
|
||||
}
|
||||
.ui-pnotify .ui-pnotify-shadow {
|
||||
-webkit-box-shadow: 0px 2px 10px rgba(50, 50, 50, 0.5);
|
||||
-moz-box-shadow: 0px 2px 10px rgba(50, 50, 50, 0.5);
|
||||
box-shadow: 0px 2px 10px rgba(50, 50, 50, 0.5);
|
||||
}
|
||||
.ui-pnotify-container {
|
||||
background-position: 0 0;
|
||||
padding: .8em;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
.ui-pnotify-sharp {
|
||||
-webkit-border-radius: 0;
|
||||
-moz-border-radius: 0;
|
||||
border-radius: 0;
|
||||
}
|
||||
.ui-pnotify-closer, .ui-pnotify-sticker {
|
||||
float: right;
|
||||
margin-left: .2em;
|
||||
}
|
||||
.ui-pnotify-title {
|
||||
display: block;
|
||||
margin-bottom: .4em;
|
||||
}
|
||||
.ui-pnotify-text {
|
||||
display: block;
|
||||
}
|
||||
.ui-pnotify-icon, .ui-pnotify-icon span {
|
||||
display: block;
|
||||
float: left;
|
||||
margin-right: .2em;
|
||||
}
|
||||
/* -- History Pulldown */
|
||||
.ui-pnotify-history-container {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 18px;
|
||||
width: 70px;
|
||||
border-top: none;
|
||||
padding: 0;
|
||||
-webkit-border-top-left-radius: 0;
|
||||
-moz-border-top-left-radius: 0;
|
||||
border-top-left-radius: 0;
|
||||
-webkit-border-top-right-radius: 0;
|
||||
-moz-border-top-right-radius: 0;
|
||||
border-top-right-radius: 0;
|
||||
/* Ensures history container is above notices. */
|
||||
z-index: 10000;
|
||||
}
|
||||
.ui-pnotify-history-container .ui-pnotify-history-header {
|
||||
padding: 2px;
|
||||
}
|
||||
.ui-pnotify-history-container button {
|
||||
cursor: pointer;
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
.ui-pnotify-history-container .ui-pnotify-history-pulldown {
|
||||
display: block;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
Before Width: | Height: | Size: 890 B |
|
Before Width: | Height: | Size: 251 B |
|
Before Width: | Height: | Size: 212 B |
|
Before Width: | Height: | Size: 119 B |
|
Before Width: | Height: | Size: 131 B |
|
Before Width: | Height: | Size: 124 B |
|
Before Width: | Height: | Size: 103 B |
|
Before Width: | Height: | Size: 118 B |
|
Before Width: | Height: | Size: 104 B |
|
Before Width: | Height: | Size: 119 B |
|
Before Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 112 B |
@@ -1,458 +0,0 @@
|
||||
/*! jQuery UI - v1.9.0 - 2012-10-21
|
||||
* http://jqueryui.com
|
||||
* Includes: jquery.ui.core.css, jquery.ui.resizable.css, jquery.ui.selectable.css, jquery.ui.accordion.css, jquery.ui.autocomplete.css, jquery.ui.button.css, jquery.ui.datepicker.css, jquery.ui.dialog.css, jquery.ui.menu.css, jquery.ui.progressbar.css, jquery.ui.slider.css, jquery.ui.spinner.css, jquery.ui.tabs.css, jquery.ui.tooltip.css
|
||||
* To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Lucida%20Grande%2CLucida%20Sans%2CArial%2Csans-serif&fwDefault=bold&fsDefault=1.1em&cornerRadius=6px&bgColorHeader=deedf7&bgTextureHeader=03_highlight_soft.png&bgImgOpacityHeader=100&borderColorHeader=aed0ea&fcHeader=222222&iconColorHeader=72a7cf&bgColorContent=f2f5f7&bgTextureContent=04_highlight_hard.png&bgImgOpacityContent=100&borderColorContent=dddddd&fcContent=362b36&iconColorContent=72a7cf&bgColorDefault=d7ebf9&bgTextureDefault=02_glass.png&bgImgOpacityDefault=80&borderColorDefault=aed0ea&fcDefault=2779aa&iconColorDefault=3d80b3&bgColorHover=e4f1fb&bgTextureHover=02_glass.png&bgImgOpacityHover=100&borderColorHover=74b2e2&fcHover=0070a3&iconColorHover=2694e8&bgColorActive=3baae3&bgTextureActive=02_glass.png&bgImgOpacityActive=50&borderColorActive=2694e8&fcActive=ffffff&iconColorActive=ffffff&bgColorHighlight=ffef8f&bgTextureHighlight=03_highlight_soft.png&bgImgOpacityHighlight=25&borderColorHighlight=f9dd34&fcHighlight=363636&iconColorHighlight=2e83ff&bgColorError=cd0a0a&bgTextureError=01_flat.png&bgImgOpacityError=15&borderColorError=cd0a0a&fcError=ffffff&iconColorError=ffffff&bgColorOverlay=eeeeee&bgTextureOverlay=08_diagonals_thick.png&bgImgOpacityOverlay=90&opacityOverlay=80&bgColorShadow=000000&bgTextureShadow=04_highlight_hard.png&bgImgOpacityShadow=70&opacityShadow=30&thicknessShadow=7px&offsetTopShadow=-7px&offsetLeftShadow=-7px&cornerRadiusShadow=8px
|
||||
* Copyright (c) 2012 jQuery Foundation and other contributors Licensed MIT */
|
||||
|
||||
/* Layout helpers
|
||||
----------------------------------*/
|
||||
.ui-helper-hidden { display: none; }
|
||||
.ui-helper-hidden-accessible { position: absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px,1px,1px,1px); }
|
||||
.ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; }
|
||||
.ui-helper-clearfix:before, .ui-helper-clearfix:after { content: ""; display: table; }
|
||||
.ui-helper-clearfix:after { clear: both; }
|
||||
.ui-helper-clearfix { zoom: 1; }
|
||||
.ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); }
|
||||
|
||||
|
||||
/* Interaction Cues
|
||||
----------------------------------*/
|
||||
.ui-state-disabled { cursor: default !important; }
|
||||
|
||||
|
||||
/* Icons
|
||||
----------------------------------*/
|
||||
|
||||
/* states and images */
|
||||
.ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; }
|
||||
|
||||
|
||||
/* Misc visuals
|
||||
----------------------------------*/
|
||||
|
||||
/* Overlays */
|
||||
.ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
|
||||
.ui-resizable { position: relative;}
|
||||
.ui-resizable-handle { position: absolute;font-size: 0.1px; display: block; }
|
||||
.ui-resizable-disabled .ui-resizable-handle, .ui-resizable-autohide .ui-resizable-handle { display: none; }
|
||||
.ui-resizable-n { cursor: n-resize; height: 7px; width: 100%; top: -5px; left: 0; }
|
||||
.ui-resizable-s { cursor: s-resize; height: 7px; width: 100%; bottom: -5px; left: 0; }
|
||||
.ui-resizable-e { cursor: e-resize; width: 7px; right: -5px; top: 0; height: 100%; }
|
||||
.ui-resizable-w { cursor: w-resize; width: 7px; left: -5px; top: 0; height: 100%; }
|
||||
.ui-resizable-se { cursor: se-resize; width: 12px; height: 12px; right: 1px; bottom: 1px; }
|
||||
.ui-resizable-sw { cursor: sw-resize; width: 9px; height: 9px; left: -5px; bottom: -5px; }
|
||||
.ui-resizable-nw { cursor: nw-resize; width: 9px; height: 9px; left: -5px; top: -5px; }
|
||||
.ui-resizable-ne { cursor: ne-resize; width: 9px; height: 9px; right: -5px; top: -5px;}.ui-selectable-helper { position: absolute; z-index: 100; border:1px dotted black; }
|
||||
.ui-accordion .ui-accordion-header { display: block; cursor: pointer; position: relative; margin-top: 2px; padding: .5em .5em .5em .7em; zoom: 1; }
|
||||
.ui-accordion .ui-accordion-icons { padding-left: 2.2em; }
|
||||
.ui-accordion .ui-accordion-noicons { padding-left: .7em; }
|
||||
.ui-accordion .ui-accordion-icons .ui-accordion-icons { padding-left: 2.2em; }
|
||||
.ui-accordion .ui-accordion-header .ui-accordion-header-icon { position: absolute; left: .5em; top: 50%; margin-top: -8px; }
|
||||
.ui-accordion .ui-accordion-content { padding: 1em 2.2em; border-top: 0; overflow: auto; zoom: 1; }
|
||||
.ui-autocomplete { position: absolute; cursor: default; }
|
||||
|
||||
/* workarounds */
|
||||
* html .ui-autocomplete { width:1px; } /* without this, the menu expands to 100% in IE6 */
|
||||
.ui-button { display: inline-block; position: relative; padding: 0; margin-right: .1em; cursor: pointer; text-align: center; zoom: 1; overflow: visible; } /* the overflow property removes extra width in IE */
|
||||
.ui-button, .ui-button:link, .ui-button:visited, .ui-button:hover, .ui-button:active { text-decoration: none; }
|
||||
.ui-button-icon-only { width: 2.2em; } /* to make room for the icon, a width needs to be set here */
|
||||
button.ui-button-icon-only { width: 2.4em; } /* button elements seem to need a little more width */
|
||||
.ui-button-icons-only { width: 3.4em; }
|
||||
button.ui-button-icons-only { width: 3.7em; }
|
||||
|
||||
/*button text element */
|
||||
.ui-button .ui-button-text { display: block; line-height: 1.4; }
|
||||
.ui-button-text-only .ui-button-text { padding: .4em 1em; }
|
||||
.ui-button-icon-only .ui-button-text, .ui-button-icons-only .ui-button-text { padding: .4em; text-indent: -9999999px; }
|
||||
.ui-button-text-icon-primary .ui-button-text, .ui-button-text-icons .ui-button-text { padding: .4em 1em .4em 2.1em; }
|
||||
.ui-button-text-icon-secondary .ui-button-text, .ui-button-text-icons .ui-button-text { padding: .4em 2.1em .4em 1em; }
|
||||
.ui-button-text-icons .ui-button-text { padding-left: 2.1em; padding-right: 2.1em; }
|
||||
/* no icon support for input elements, provide padding by default */
|
||||
input.ui-button { padding: .4em 1em; }
|
||||
|
||||
/*button icon element(s) */
|
||||
.ui-button-icon-only .ui-icon, .ui-button-text-icon-primary .ui-icon, .ui-button-text-icon-secondary .ui-icon, .ui-button-text-icons .ui-icon, .ui-button-icons-only .ui-icon { position: absolute; top: 50%; margin-top: -8px; }
|
||||
.ui-button-icon-only .ui-icon { left: 50%; margin-left: -8px; }
|
||||
.ui-button-text-icon-primary .ui-button-icon-primary, .ui-button-text-icons .ui-button-icon-primary, .ui-button-icons-only .ui-button-icon-primary { left: .5em; }
|
||||
.ui-button-text-icon-secondary .ui-button-icon-secondary, .ui-button-text-icons .ui-button-icon-secondary, .ui-button-icons-only .ui-button-icon-secondary { right: .5em; }
|
||||
.ui-button-text-icons .ui-button-icon-secondary, .ui-button-icons-only .ui-button-icon-secondary { right: .5em; }
|
||||
|
||||
/*button sets*/
|
||||
.ui-buttonset { margin-right: 7px; }
|
||||
.ui-buttonset .ui-button { margin-left: 0; margin-right: -.3em; }
|
||||
|
||||
/* workarounds */
|
||||
button.ui-button::-moz-focus-inner { border: 0; padding: 0; } /* reset extra padding in Firefox */
|
||||
.ui-datepicker { width: 17em; padding: .2em .2em 0; display: none; }
|
||||
.ui-datepicker .ui-datepicker-header { position:relative; padding:.2em 0; }
|
||||
.ui-datepicker .ui-datepicker-prev, .ui-datepicker .ui-datepicker-next { position:absolute; top: 2px; width: 1.8em; height: 1.8em; }
|
||||
.ui-datepicker .ui-datepicker-prev-hover, .ui-datepicker .ui-datepicker-next-hover { top: 1px; }
|
||||
.ui-datepicker .ui-datepicker-prev { left:2px; }
|
||||
.ui-datepicker .ui-datepicker-next { right:2px; }
|
||||
.ui-datepicker .ui-datepicker-prev-hover { left:1px; }
|
||||
.ui-datepicker .ui-datepicker-next-hover { right:1px; }
|
||||
.ui-datepicker .ui-datepicker-prev span, .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px; }
|
||||
.ui-datepicker .ui-datepicker-title { margin: 0 2.3em; line-height: 1.8em; text-align: center; }
|
||||
.ui-datepicker .ui-datepicker-title select { font-size:1em; margin:1px 0; }
|
||||
.ui-datepicker select.ui-datepicker-month-year {width: 100%;}
|
||||
.ui-datepicker select.ui-datepicker-month,
|
||||
.ui-datepicker select.ui-datepicker-year { width: 49%;}
|
||||
.ui-datepicker table {width: 100%; font-size: .9em; border-collapse: collapse; margin:0 0 .4em; }
|
||||
.ui-datepicker th { padding: .7em .3em; text-align: center; font-weight: bold; border: 0; }
|
||||
.ui-datepicker td { border: 0; padding: 1px; }
|
||||
.ui-datepicker td span, .ui-datepicker td a { display: block; padding: .2em; text-align: right; text-decoration: none; }
|
||||
.ui-datepicker .ui-datepicker-buttonpane { background-image: none; margin: .7em 0 0 0; padding:0 .2em; border-left: 0; border-right: 0; border-bottom: 0; }
|
||||
.ui-datepicker .ui-datepicker-buttonpane button { float: right; margin: .5em .2em .4em; cursor: pointer; padding: .2em .6em .3em .6em; width:auto; overflow:visible; }
|
||||
.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { float:left; }
|
||||
|
||||
/* with multiple calendars */
|
||||
.ui-datepicker.ui-datepicker-multi { width:auto; }
|
||||
.ui-datepicker-multi .ui-datepicker-group { float:left; }
|
||||
.ui-datepicker-multi .ui-datepicker-group table { width:95%; margin:0 auto .4em; }
|
||||
.ui-datepicker-multi-2 .ui-datepicker-group { width:50%; }
|
||||
.ui-datepicker-multi-3 .ui-datepicker-group { width:33.3%; }
|
||||
.ui-datepicker-multi-4 .ui-datepicker-group { width:25%; }
|
||||
.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header { border-left-width:0; }
|
||||
.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header { border-left-width:0; }
|
||||
.ui-datepicker-multi .ui-datepicker-buttonpane { clear:left; }
|
||||
.ui-datepicker-row-break { clear:both; width:100%; font-size:0em; }
|
||||
|
||||
/* RTL support */
|
||||
.ui-datepicker-rtl { direction: rtl; }
|
||||
.ui-datepicker-rtl .ui-datepicker-prev { right: 2px; left: auto; }
|
||||
.ui-datepicker-rtl .ui-datepicker-next { left: 2px; right: auto; }
|
||||
.ui-datepicker-rtl .ui-datepicker-prev:hover { right: 1px; left: auto; }
|
||||
.ui-datepicker-rtl .ui-datepicker-next:hover { left: 1px; right: auto; }
|
||||
.ui-datepicker-rtl .ui-datepicker-buttonpane { clear:right; }
|
||||
.ui-datepicker-rtl .ui-datepicker-buttonpane button { float: left; }
|
||||
.ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current { float:right; }
|
||||
.ui-datepicker-rtl .ui-datepicker-group { float:right; }
|
||||
.ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header { border-right-width:0; border-left-width:1px; }
|
||||
.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header { border-right-width:0; border-left-width:1px; }
|
||||
|
||||
/* IE6 IFRAME FIX (taken from datepicker 1.5.3 */
|
||||
.ui-datepicker-cover {
|
||||
position: absolute; /*must have*/
|
||||
z-index: -1; /*must have*/
|
||||
filter: mask(); /*must have*/
|
||||
top: -4px; /*must have*/
|
||||
left: -4px; /*must have*/
|
||||
width: 200px; /*must have*/
|
||||
height: 200px; /*must have*/
|
||||
}.ui-dialog { position: absolute; padding: .2em; width: 300px; overflow: hidden; }
|
||||
.ui-dialog .ui-dialog-titlebar { padding: .4em 1em; position: relative; }
|
||||
.ui-dialog .ui-dialog-title { float: left; margin: .1em 16px .1em 0; }
|
||||
.ui-dialog .ui-dialog-titlebar-close { position: absolute; right: .3em; top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height: 18px; }
|
||||
.ui-dialog .ui-dialog-titlebar-close span { display: block; margin: 1px; }
|
||||
.ui-dialog .ui-dialog-titlebar-close:hover, .ui-dialog .ui-dialog-titlebar-close:focus { padding: 0; }
|
||||
.ui-dialog .ui-dialog-content { position: relative; border: 0; padding: .5em 1em; background: none; overflow: auto; zoom: 1; }
|
||||
.ui-dialog .ui-dialog-buttonpane { text-align: left; border-width: 1px 0 0 0; background-image: none; margin: .5em 0 0 0; padding: .3em 1em .5em .4em; }
|
||||
.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset { float: right; }
|
||||
.ui-dialog .ui-dialog-buttonpane button { margin: .5em .4em .5em 0; cursor: pointer; }
|
||||
.ui-dialog .ui-resizable-se { width: 14px; height: 14px; right: 3px; bottom: 3px; }
|
||||
.ui-draggable .ui-dialog-titlebar { cursor: move; }
|
||||
.ui-menu { list-style:none; padding: 2px; margin: 0; display:block; outline: none; }
|
||||
.ui-menu .ui-menu { margin-top: -3px; position: absolute; }
|
||||
.ui-menu .ui-menu-item { margin: 0; padding: 0; zoom: 1; width: 100%; }
|
||||
.ui-menu .ui-menu-divider { margin: 5px -2px 5px -2px; height: 0; font-size: 0; line-height: 0; border-width: 1px 0 0 0; }
|
||||
.ui-menu .ui-menu-item a { text-decoration: none; display: block; padding: 2px .4em; line-height: 1.5; zoom: 1; font-weight: normal; }
|
||||
.ui-menu .ui-menu-item a.ui-state-focus,
|
||||
.ui-menu .ui-menu-item a.ui-state-active { font-weight: normal; margin: -1px; }
|
||||
|
||||
.ui-menu .ui-state-disabled { font-weight: normal; margin: .4em 0 .2em; line-height: 1.5; }
|
||||
.ui-menu .ui-state-disabled a { cursor: default; }
|
||||
|
||||
/* icon support */
|
||||
.ui-menu-icons { position: relative; }
|
||||
.ui-menu-icons .ui-menu-item a { position: relative; padding-left: 2em; }
|
||||
|
||||
/* left-aligned */
|
||||
.ui-menu .ui-icon { position: absolute; top: .2em; left: .2em; }
|
||||
|
||||
/* right-aligned */
|
||||
.ui-menu .ui-menu-icon { position: static; float: right; }
|
||||
.ui-progressbar { height:2em; text-align: left; overflow: hidden; }
|
||||
.ui-progressbar .ui-progressbar-value {margin: -1px; height:100%; }.ui-slider { position: relative; text-align: left; }
|
||||
.ui-slider .ui-slider-handle { position: absolute; z-index: 2; width: 1.2em; height: 1.2em; cursor: default; }
|
||||
.ui-slider .ui-slider-range { position: absolute; z-index: 1; font-size: .7em; display: block; border: 0; background-position: 0 0; }
|
||||
|
||||
.ui-slider-horizontal { height: .8em; }
|
||||
.ui-slider-horizontal .ui-slider-handle { top: -.3em; margin-left: -.6em; }
|
||||
.ui-slider-horizontal .ui-slider-range { top: 0; height: 100%; }
|
||||
.ui-slider-horizontal .ui-slider-range-min { left: 0; }
|
||||
.ui-slider-horizontal .ui-slider-range-max { right: 0; }
|
||||
|
||||
.ui-slider-vertical { width: .8em; height: 100px; }
|
||||
.ui-slider-vertical .ui-slider-handle { left: -.3em; margin-left: 0; margin-bottom: -.6em; }
|
||||
.ui-slider-vertical .ui-slider-range { left: 0; width: 100%; }
|
||||
.ui-slider-vertical .ui-slider-range-min { bottom: 0; }
|
||||
.ui-slider-vertical .ui-slider-range-max { top: 0; }.ui-spinner { position:relative; display: inline-block; overflow: hidden; padding: 0; vertical-align: middle; }
|
||||
.ui-spinner-input { border: none; background: none; padding: 0; margin: .2em 0; vertical-align: middle; margin-left: .4em; margin-right: 22px; }
|
||||
.ui-spinner-button { width: 16px; height: 50%; font-size: .5em; padding: 0; margin: 0; z-index: 100; text-align: center; position: absolute; cursor: default; display: block; overflow: hidden; right: 0; }
|
||||
.ui-spinner a.ui-spinner-button { border-top: none; border-bottom: none; border-right: none; } /* more specificity required here to overide default borders */
|
||||
.ui-spinner .ui-icon { position: absolute; margin-top: -8px; top: 50%; left: 0; } /* vertical centre icon */
|
||||
.ui-spinner-up { top: 0; }
|
||||
.ui-spinner-down { bottom: 0; }
|
||||
|
||||
/* TR overrides */
|
||||
span.ui-spinner { background: none; }
|
||||
.ui-spinner .ui-icon-triangle-1-s {
|
||||
/* need to fix icons sprite */
|
||||
background-position:-65px -16px;
|
||||
}
|
||||
.ui-tabs { position: relative; padding: .2em; zoom: 1; } /* position: relative prevents IE scroll bug (element with position: relative inside container with overflow: auto appear as "fixed") */
|
||||
.ui-tabs .ui-tabs-nav { margin: 0; padding: .2em .2em 0; }
|
||||
.ui-tabs .ui-tabs-nav li { list-style: none; float: left; position: relative; top: 0; margin: 1px .2em 0 0; border-bottom: 0; padding: 0; white-space: nowrap; }
|
||||
.ui-tabs .ui-tabs-nav li a { float: left; padding: .5em 1em; text-decoration: none; }
|
||||
.ui-tabs .ui-tabs-nav li.ui-tabs-active { margin-bottom: -1px; padding-bottom: 1px; }
|
||||
.ui-tabs .ui-tabs-nav li.ui-tabs-active a, .ui-tabs .ui-tabs-nav li.ui-state-disabled a, .ui-tabs .ui-tabs-nav li.ui-tabs-loading a { cursor: text; }
|
||||
.ui-tabs .ui-tabs-nav li a, .ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-active a { cursor: pointer; } /* first selector in group seems obsolete, but required to overcome bug in Opera applying cursor: text overall if defined elsewhere... */
|
||||
.ui-tabs .ui-tabs-panel { display: block; border-width: 0; padding: 1em 1.4em; background: none; }
|
||||
.ui-tooltip {
|
||||
padding:8px;
|
||||
position:absolute;
|
||||
z-index:9999;
|
||||
-o-box-shadow: 0 0 5px #aaa;
|
||||
-moz-box-shadow: 0 0 5px #aaa;
|
||||
-webkit-box-shadow: 0 0 5px #aaa;
|
||||
box-shadow: 0 0 5px #aaa;
|
||||
}
|
||||
/* Fades and background-images don't work well together in IE6, drop the image */
|
||||
* html .ui-tooltip {
|
||||
background-image: none;
|
||||
}
|
||||
body .ui-tooltip { border-width:2px; }
|
||||
|
||||
/* Component containers
|
||||
----------------------------------*/
|
||||
.ui-widget { font-family: Lucida Grande,Lucida Sans,Arial,sans-serif; font-size: 1em; }
|
||||
.ui-widget .ui-widget { font-size: 1em; }
|
||||
.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: Lucida Grande,Lucida Sans,Arial,sans-serif; font-size: 1em; }
|
||||
.ui-widget-content { border: 1px solid #dddddd; background: #f2f5f7 url(images/ui-bg_highlight-hard_100_f2f5f7_1x100.png) 50% top repeat-x; color: #362b36; }
|
||||
.ui-widget-content a { color: #362b36; }
|
||||
.ui-widget-header { border: 1px solid #aed0ea; background: #deedf7 url(images/ui-bg_highlight-soft_100_deedf7_1x100.png) 50% 50% repeat-x; color: #222222; font-weight: bold; }
|
||||
.ui-widget-header a { color: #222222; }
|
||||
|
||||
/* Interaction states
|
||||
----------------------------------*/
|
||||
.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #aed0ea; background: #d7ebf9 url(images/ui-bg_glass_80_d7ebf9_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #2779aa; }
|
||||
.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #2779aa; text-decoration: none; }
|
||||
.ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus { border: 1px solid #74b2e2; background: #e4f1fb url(images/ui-bg_glass_100_e4f1fb_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #0070a3; }
|
||||
.ui-state-hover a, .ui-state-hover a:hover { color: #0070a3; text-decoration: none; }
|
||||
.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active { border: 1px solid #2694e8; background: #3baae3 url(images/ui-bg_glass_50_3baae3_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #ffffff; }
|
||||
.ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited { color: #ffffff; text-decoration: none; }
|
||||
|
||||
/* Interaction Cues
|
||||
----------------------------------*/
|
||||
.ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight {border: 1px solid #f9dd34; background: #ffef8f url(images/ui-bg_highlight-soft_25_ffef8f_1x100.png) 50% top repeat-x; color: #363636; }
|
||||
.ui-state-highlight a, .ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a { color: #363636; }
|
||||
.ui-state-error, .ui-widget-content .ui-state-error, .ui-widget-header .ui-state-error {border: 1px solid #cd0a0a; background: #cd0a0a url(images/ui-bg_flat_15_cd0a0a_40x100.png) 50% 50% repeat-x; color: #ffffff; }
|
||||
.ui-state-error a, .ui-widget-content .ui-state-error a, .ui-widget-header .ui-state-error a { color: #ffffff; }
|
||||
.ui-state-error-text, .ui-widget-content .ui-state-error-text, .ui-widget-header .ui-state-error-text { color: #ffffff; }
|
||||
.ui-priority-primary, .ui-widget-content .ui-priority-primary, .ui-widget-header .ui-priority-primary { font-weight: bold; }
|
||||
.ui-priority-secondary, .ui-widget-content .ui-priority-secondary, .ui-widget-header .ui-priority-secondary { opacity: .7; filter:Alpha(Opacity=70); font-weight: normal; }
|
||||
.ui-state-disabled, .ui-widget-content .ui-state-disabled, .ui-widget-header .ui-state-disabled { opacity: .35; filter:Alpha(Opacity=35); background-image: none; }
|
||||
|
||||
/* Icons
|
||||
----------------------------------*/
|
||||
|
||||
/* states and images */
|
||||
.ui-icon { width: 16px; height: 16px; background-image: url(images/ui-icons_72a7cf_256x240.png); }
|
||||
.ui-widget-content .ui-icon {background-image: url(images/ui-icons_72a7cf_256x240.png); }
|
||||
.ui-widget-header .ui-icon {background-image: url(images/ui-icons_72a7cf_256x240.png); }
|
||||
.ui-state-default .ui-icon { background-image: url(images/ui-icons_3d80b3_256x240.png); }
|
||||
.ui-state-hover .ui-icon, .ui-state-focus .ui-icon {background-image: url(images/ui-icons_2694e8_256x240.png); }
|
||||
.ui-state-active .ui-icon {background-image: url(images/ui-icons_ffffff_256x240.png); }
|
||||
.ui-state-highlight .ui-icon {background-image: url(images/ui-icons_2e83ff_256x240.png); }
|
||||
.ui-state-error .ui-icon, .ui-state-error-text .ui-icon {background-image: url(images/ui-icons_ffffff_256x240.png); }
|
||||
|
||||
/* positioning */
|
||||
.ui-icon-carat-1-n { background-position: 0 0; }
|
||||
.ui-icon-carat-1-ne { background-position: -16px 0; }
|
||||
.ui-icon-carat-1-e { background-position: -32px 0; }
|
||||
.ui-icon-carat-1-se { background-position: -48px 0; }
|
||||
.ui-icon-carat-1-s { background-position: -64px 0; }
|
||||
.ui-icon-carat-1-sw { background-position: -80px 0; }
|
||||
.ui-icon-carat-1-w { background-position: -96px 0; }
|
||||
.ui-icon-carat-1-nw { background-position: -112px 0; }
|
||||
.ui-icon-carat-2-n-s { background-position: -128px 0; }
|
||||
.ui-icon-carat-2-e-w { background-position: -144px 0; }
|
||||
.ui-icon-triangle-1-n { background-position: 0 -16px; }
|
||||
.ui-icon-triangle-1-ne { background-position: -16px -16px; }
|
||||
.ui-icon-triangle-1-e { background-position: -32px -16px; }
|
||||
.ui-icon-triangle-1-se { background-position: -48px -16px; }
|
||||
.ui-icon-triangle-1-s { background-position: -64px -16px; }
|
||||
.ui-icon-triangle-1-sw { background-position: -80px -16px; }
|
||||
.ui-icon-triangle-1-w { background-position: -96px -16px; }
|
||||
.ui-icon-triangle-1-nw { background-position: -112px -16px; }
|
||||
.ui-icon-triangle-2-n-s { background-position: -128px -16px; }
|
||||
.ui-icon-triangle-2-e-w { background-position: -144px -16px; }
|
||||
.ui-icon-arrow-1-n { background-position: 0 -32px; }
|
||||
.ui-icon-arrow-1-ne { background-position: -16px -32px; }
|
||||
.ui-icon-arrow-1-e { background-position: -32px -32px; }
|
||||
.ui-icon-arrow-1-se { background-position: -48px -32px; }
|
||||
.ui-icon-arrow-1-s { background-position: -64px -32px; }
|
||||
.ui-icon-arrow-1-sw { background-position: -80px -32px; }
|
||||
.ui-icon-arrow-1-w { background-position: -96px -32px; }
|
||||
.ui-icon-arrow-1-nw { background-position: -112px -32px; }
|
||||
.ui-icon-arrow-2-n-s { background-position: -128px -32px; }
|
||||
.ui-icon-arrow-2-ne-sw { background-position: -144px -32px; }
|
||||
.ui-icon-arrow-2-e-w { background-position: -160px -32px; }
|
||||
.ui-icon-arrow-2-se-nw { background-position: -176px -32px; }
|
||||
.ui-icon-arrowstop-1-n { background-position: -192px -32px; }
|
||||
.ui-icon-arrowstop-1-e { background-position: -208px -32px; }
|
||||
.ui-icon-arrowstop-1-s { background-position: -224px -32px; }
|
||||
.ui-icon-arrowstop-1-w { background-position: -240px -32px; }
|
||||
.ui-icon-arrowthick-1-n { background-position: 0 -48px; }
|
||||
.ui-icon-arrowthick-1-ne { background-position: -16px -48px; }
|
||||
.ui-icon-arrowthick-1-e { background-position: -32px -48px; }
|
||||
.ui-icon-arrowthick-1-se { background-position: -48px -48px; }
|
||||
.ui-icon-arrowthick-1-s { background-position: -64px -48px; }
|
||||
.ui-icon-arrowthick-1-sw { background-position: -80px -48px; }
|
||||
.ui-icon-arrowthick-1-w { background-position: -96px -48px; }
|
||||
.ui-icon-arrowthick-1-nw { background-position: -112px -48px; }
|
||||
.ui-icon-arrowthick-2-n-s { background-position: -128px -48px; }
|
||||
.ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; }
|
||||
.ui-icon-arrowthick-2-e-w { background-position: -160px -48px; }
|
||||
.ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; }
|
||||
.ui-icon-arrowthickstop-1-n { background-position: -192px -48px; }
|
||||
.ui-icon-arrowthickstop-1-e { background-position: -208px -48px; }
|
||||
.ui-icon-arrowthickstop-1-s { background-position: -224px -48px; }
|
||||
.ui-icon-arrowthickstop-1-w { background-position: -240px -48px; }
|
||||
.ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; }
|
||||
.ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; }
|
||||
.ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; }
|
||||
.ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; }
|
||||
.ui-icon-arrowreturn-1-w { background-position: -64px -64px; }
|
||||
.ui-icon-arrowreturn-1-n { background-position: -80px -64px; }
|
||||
.ui-icon-arrowreturn-1-e { background-position: -96px -64px; }
|
||||
.ui-icon-arrowreturn-1-s { background-position: -112px -64px; }
|
||||
.ui-icon-arrowrefresh-1-w { background-position: -128px -64px; }
|
||||
.ui-icon-arrowrefresh-1-n { background-position: -144px -64px; }
|
||||
.ui-icon-arrowrefresh-1-e { background-position: -160px -64px; }
|
||||
.ui-icon-arrowrefresh-1-s { background-position: -176px -64px; }
|
||||
.ui-icon-arrow-4 { background-position: 0 -80px; }
|
||||
.ui-icon-arrow-4-diag { background-position: -16px -80px; }
|
||||
.ui-icon-extlink { background-position: -32px -80px; }
|
||||
.ui-icon-newwin { background-position: -48px -80px; }
|
||||
.ui-icon-refresh { background-position: -64px -80px; }
|
||||
.ui-icon-shuffle { background-position: -80px -80px; }
|
||||
.ui-icon-transfer-e-w { background-position: -96px -80px; }
|
||||
.ui-icon-transferthick-e-w { background-position: -112px -80px; }
|
||||
.ui-icon-folder-collapsed { background-position: 0 -96px; }
|
||||
.ui-icon-folder-open { background-position: -16px -96px; }
|
||||
.ui-icon-document { background-position: -32px -96px; }
|
||||
.ui-icon-document-b { background-position: -48px -96px; }
|
||||
.ui-icon-note { background-position: -64px -96px; }
|
||||
.ui-icon-mail-closed { background-position: -80px -96px; }
|
||||
.ui-icon-mail-open { background-position: -96px -96px; }
|
||||
.ui-icon-suitcase { background-position: -112px -96px; }
|
||||
.ui-icon-comment { background-position: -128px -96px; }
|
||||
.ui-icon-person { background-position: -144px -96px; }
|
||||
.ui-icon-print { background-position: -160px -96px; }
|
||||
.ui-icon-trash { background-position: -176px -96px; }
|
||||
.ui-icon-locked { background-position: -192px -96px; }
|
||||
.ui-icon-unlocked { background-position: -208px -96px; }
|
||||
.ui-icon-bookmark { background-position: -224px -96px; }
|
||||
.ui-icon-tag { background-position: -240px -96px; }
|
||||
.ui-icon-home { background-position: 0 -112px; }
|
||||
.ui-icon-flag { background-position: -16px -112px; }
|
||||
.ui-icon-calendar { background-position: -32px -112px; }
|
||||
.ui-icon-cart { background-position: -48px -112px; }
|
||||
.ui-icon-pencil { background-position: -64px -112px; }
|
||||
.ui-icon-clock { background-position: -80px -112px; }
|
||||
.ui-icon-disk { background-position: -96px -112px; }
|
||||
.ui-icon-calculator { background-position: -112px -112px; }
|
||||
.ui-icon-zoomin { background-position: -128px -112px; }
|
||||
.ui-icon-zoomout { background-position: -144px -112px; }
|
||||
.ui-icon-search { background-position: -160px -112px; }
|
||||
.ui-icon-wrench { background-position: -176px -112px; }
|
||||
.ui-icon-gear { background-position: -192px -112px; }
|
||||
.ui-icon-heart { background-position: -208px -112px; }
|
||||
.ui-icon-star { background-position: -224px -112px; }
|
||||
.ui-icon-link { background-position: -240px -112px; }
|
||||
.ui-icon-cancel { background-position: 0 -128px; }
|
||||
.ui-icon-plus { background-position: -16px -128px; }
|
||||
.ui-icon-plusthick { background-position: -32px -128px; }
|
||||
.ui-icon-minus { background-position: -48px -128px; }
|
||||
.ui-icon-minusthick { background-position: -64px -128px; }
|
||||
.ui-icon-close { background-position: -80px -128px; }
|
||||
.ui-icon-closethick { background-position: -96px -128px; }
|
||||
.ui-icon-key { background-position: -112px -128px; }
|
||||
.ui-icon-lightbulb { background-position: -128px -128px; }
|
||||
.ui-icon-scissors { background-position: -144px -128px; }
|
||||
.ui-icon-clipboard { background-position: -160px -128px; }
|
||||
.ui-icon-copy { background-position: -176px -128px; }
|
||||
.ui-icon-contact { background-position: -192px -128px; }
|
||||
.ui-icon-image { background-position: -208px -128px; }
|
||||
.ui-icon-video { background-position: -224px -128px; }
|
||||
.ui-icon-script { background-position: -240px -128px; }
|
||||
.ui-icon-alert { background-position: 0 -144px; }
|
||||
.ui-icon-info { background-position: -16px -144px; }
|
||||
.ui-icon-notice { background-position: -32px -144px; }
|
||||
.ui-icon-help { background-position: -48px -144px; }
|
||||
.ui-icon-check { background-position: -64px -144px; }
|
||||
.ui-icon-bullet { background-position: -80px -144px; }
|
||||
.ui-icon-radio-on { background-position: -96px -144px; }
|
||||
.ui-icon-radio-off { background-position: -112px -144px; }
|
||||
.ui-icon-pin-w { background-position: -128px -144px; }
|
||||
.ui-icon-pin-s { background-position: -144px -144px; }
|
||||
.ui-icon-play { background-position: 0 -160px; }
|
||||
.ui-icon-pause { background-position: -16px -160px; }
|
||||
.ui-icon-seek-next { background-position: -32px -160px; }
|
||||
.ui-icon-seek-prev { background-position: -48px -160px; }
|
||||
.ui-icon-seek-end { background-position: -64px -160px; }
|
||||
.ui-icon-seek-start { background-position: -80px -160px; }
|
||||
/* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */
|
||||
.ui-icon-seek-first { background-position: -80px -160px; }
|
||||
.ui-icon-stop { background-position: -96px -160px; }
|
||||
.ui-icon-eject { background-position: -112px -160px; }
|
||||
.ui-icon-volume-off { background-position: -128px -160px; }
|
||||
.ui-icon-volume-on { background-position: -144px -160px; }
|
||||
.ui-icon-power { background-position: 0 -176px; }
|
||||
.ui-icon-signal-diag { background-position: -16px -176px; }
|
||||
.ui-icon-signal { background-position: -32px -176px; }
|
||||
.ui-icon-battery-0 { background-position: -48px -176px; }
|
||||
.ui-icon-battery-1 { background-position: -64px -176px; }
|
||||
.ui-icon-battery-2 { background-position: -80px -176px; }
|
||||
.ui-icon-battery-3 { background-position: -96px -176px; }
|
||||
.ui-icon-circle-plus { background-position: 0 -192px; }
|
||||
.ui-icon-circle-minus { background-position: -16px -192px; }
|
||||
.ui-icon-circle-close { background-position: -32px -192px; }
|
||||
.ui-icon-circle-triangle-e { background-position: -48px -192px; }
|
||||
.ui-icon-circle-triangle-s { background-position: -64px -192px; }
|
||||
.ui-icon-circle-triangle-w { background-position: -80px -192px; }
|
||||
.ui-icon-circle-triangle-n { background-position: -96px -192px; }
|
||||
.ui-icon-circle-arrow-e { background-position: -112px -192px; }
|
||||
.ui-icon-circle-arrow-s { background-position: -128px -192px; }
|
||||
.ui-icon-circle-arrow-w { background-position: -144px -192px; }
|
||||
.ui-icon-circle-arrow-n { background-position: -160px -192px; }
|
||||
.ui-icon-circle-zoomin { background-position: -176px -192px; }
|
||||
.ui-icon-circle-zoomout { background-position: -192px -192px; }
|
||||
.ui-icon-circle-check { background-position: -208px -192px; }
|
||||
.ui-icon-circlesmall-plus { background-position: 0 -208px; }
|
||||
.ui-icon-circlesmall-minus { background-position: -16px -208px; }
|
||||
.ui-icon-circlesmall-close { background-position: -32px -208px; }
|
||||
.ui-icon-squaresmall-plus { background-position: -48px -208px; }
|
||||
.ui-icon-squaresmall-minus { background-position: -64px -208px; }
|
||||
.ui-icon-squaresmall-close { background-position: -80px -208px; }
|
||||
.ui-icon-grip-dotted-vertical { background-position: 0 -224px; }
|
||||
.ui-icon-grip-dotted-horizontal { background-position: -16px -224px; }
|
||||
.ui-icon-grip-solid-vertical { background-position: -32px -224px; }
|
||||
.ui-icon-grip-solid-horizontal { background-position: -48px -224px; }
|
||||
.ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; }
|
||||
.ui-icon-grip-diagonal-se { background-position: -80px -224px; }
|
||||
|
||||
|
||||
/* Misc visuals
|
||||
----------------------------------*/
|
||||
|
||||
/* Corner radius */
|
||||
.ui-corner-all, .ui-corner-top, .ui-corner-left, .ui-corner-tl { -moz-border-radius-topleft: 6px; -webkit-border-top-left-radius: 6px; -khtml-border-top-left-radius: 6px; border-top-left-radius: 6px; }
|
||||
.ui-corner-all, .ui-corner-top, .ui-corner-right, .ui-corner-tr { -moz-border-radius-topright: 6px; -webkit-border-top-right-radius: 6px; -khtml-border-top-right-radius: 6px; border-top-right-radius: 6px; }
|
||||
.ui-corner-all, .ui-corner-bottom, .ui-corner-left, .ui-corner-bl { -moz-border-radius-bottomleft: 6px; -webkit-border-bottom-left-radius: 6px; -khtml-border-bottom-left-radius: 6px; border-bottom-left-radius: 6px; }
|
||||
.ui-corner-all, .ui-corner-bottom, .ui-corner-right, .ui-corner-br { -moz-border-radius-bottomright: 6px; -webkit-border-bottom-right-radius: 6px; -khtml-border-bottom-right-radius: 6px; border-bottom-right-radius: 6px; }
|
||||
|
||||
/* Overlays */
|
||||
.ui-widget-overlay { background: #eeeeee url(images/ui-bg_diagonals-thick_90_eeeeee_40x40.png) 50% 50% repeat; opacity: .8;filter:Alpha(Opacity=80); }
|
||||
.ui-widget-shadow { margin: -7px 0 0 -7px; padding: 7px; background: #000000 url(images/ui-bg_highlight-hard_70_000000_1x100.png) 50% top repeat-x; opacity: .3;filter:Alpha(Opacity=30); -moz-border-radius: 8px; -khtml-border-radius: 8px; -webkit-border-radius: 8px; border-radius: 8px; }
|
||||
@@ -1,5 +0,0 @@
|
||||
/*! jQuery UI - v1.9.0 - 2012-10-21
|
||||
* http://jqueryui.com
|
||||
* Includes: jquery.ui.core.css, jquery.ui.resizable.css, jquery.ui.selectable.css, jquery.ui.accordion.css, jquery.ui.autocomplete.css, jquery.ui.button.css, jquery.ui.datepicker.css, jquery.ui.dialog.css, jquery.ui.menu.css, jquery.ui.progressbar.css, jquery.ui.slider.css, jquery.ui.spinner.css, jquery.ui.tabs.css, jquery.ui.tooltip.css
|
||||
* To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Lucida%20Grande%2CLucida%20Sans%2CArial%2Csans-serif&fwDefault=bold&fsDefault=1.1em&cornerRadius=6px&bgColorHeader=deedf7&bgTextureHeader=03_highlight_soft.png&bgImgOpacityHeader=100&borderColorHeader=aed0ea&fcHeader=222222&iconColorHeader=72a7cf&bgColorContent=f2f5f7&bgTextureContent=04_highlight_hard.png&bgImgOpacityContent=100&borderColorContent=dddddd&fcContent=362b36&iconColorContent=72a7cf&bgColorDefault=d7ebf9&bgTextureDefault=02_glass.png&bgImgOpacityDefault=80&borderColorDefault=aed0ea&fcDefault=2779aa&iconColorDefault=3d80b3&bgColorHover=e4f1fb&bgTextureHover=02_glass.png&bgImgOpacityHover=100&borderColorHover=74b2e2&fcHover=0070a3&iconColorHover=2694e8&bgColorActive=3baae3&bgTextureActive=02_glass.png&bgImgOpacityActive=50&borderColorActive=2694e8&fcActive=ffffff&iconColorActive=ffffff&bgColorHighlight=ffef8f&bgTextureHighlight=03_highlight_soft.png&bgImgOpacityHighlight=25&borderColorHighlight=f9dd34&fcHighlight=363636&iconColorHighlight=2e83ff&bgColorError=cd0a0a&bgTextureError=01_flat.png&bgImgOpacityError=15&borderColorError=cd0a0a&fcError=ffffff&iconColorError=ffffff&bgColorOverlay=eeeeee&bgTextureOverlay=08_diagonals_thick.png&bgImgOpacityOverlay=90&opacityOverlay=80&bgColorShadow=000000&bgTextureShadow=04_highlight_hard.png&bgImgOpacityShadow=70&opacityShadow=30&thicknessShadow=7px&offsetTopShadow=-7px&offsetLeftShadow=-7px&cornerRadiusShadow=8px
|
||||
* Copyright (c) 2012 jQuery Foundation and other contributors Licensed MIT */.ui-helper-hidden{display:none}.ui-helper-hidden-accessible{position:absolute!important;clip:rect(1px);clip:rect(1px,1px,1px,1px)}.ui-helper-reset{margin:0;padding:0;border:0;outline:0;line-height:1.3;text-decoration:none;font-size:100%;list-style:none}.ui-helper-clearfix:before,.ui-helper-clearfix:after{content:"";display:table}.ui-helper-clearfix:after{clear:both}.ui-helper-clearfix{zoom:1}.ui-helper-zfix{width:100%;height:100%;top:0;left:0;position:absolute;opacity:0;filter:Alpha(Opacity=0)}.ui-state-disabled{cursor:default!important}.ui-icon{display:block;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat}.ui-widget-overlay{position:absolute;top:0;left:0;width:100%;height:100%}.ui-resizable{position:relative}.ui-resizable-handle{position:absolute;font-size:0.1px;display:block}.ui-resizable-disabled .ui-resizable-handle,.ui-resizable-autohide .ui-resizable-handle{display:none}.ui-resizable-n{cursor:n-resize;height:7px;width:100%;top:-5px;left:0}.ui-resizable-s{cursor:s-resize;height:7px;width:100%;bottom:-5px;left:0}.ui-resizable-e{cursor:e-resize;width:7px;right:-5px;top:0;height:100%}.ui-resizable-w{cursor:w-resize;width:7px;left:-5px;top:0;height:100%}.ui-resizable-se{cursor:se-resize;width:12px;height:12px;right:1px;bottom:1px}.ui-resizable-sw{cursor:sw-resize;width:9px;height:9px;left:-5px;bottom:-5px}.ui-resizable-nw{cursor:nw-resize;width:9px;height:9px;left:-5px;top:-5px}.ui-resizable-ne{cursor:ne-resize;width:9px;height:9px;right:-5px;top:-5px}.ui-selectable-helper{position:absolute;z-index:100;border:1px dotted black}.ui-accordion .ui-accordion-header{display:block;cursor:pointer;position:relative;margin-top:2px;padding:.5em .5em .5em .7em;zoom:1}.ui-accordion .ui-accordion-icons{padding-left:2.2em}.ui-accordion .ui-accordion-noicons{padding-left:.7em}.ui-accordion .ui-accordion-icons .ui-accordion-icons{padding-left:2.2em}.ui-accordion .ui-accordion-header .ui-accordion-header-icon{position:absolute;left:.5em;top:50%;margin-top:-8px}.ui-accordion .ui-accordion-content{padding:1em 2.2em;border-top:0;overflow:auto;zoom:1}.ui-autocomplete{position:absolute;cursor:default}* html .ui-autocomplete{width:1px}.ui-button{display:inline-block;position:relative;padding:0;margin-right:.1em;cursor:pointer;text-align:center;zoom:1;overflow:visible}.ui-button,.ui-button:link,.ui-button:visited,.ui-button:hover,.ui-button:active{text-decoration:none}.ui-button-icon-only{width:2.2em}button.ui-button-icon-only{width:2.4em}.ui-button-icons-only{width:3.4em}button.ui-button-icons-only{width:3.7em}.ui-button .ui-button-text{display:block;line-height:1.4}.ui-button-text-only .ui-button-text{padding:.4em 1em}.ui-button-icon-only .ui-button-text,.ui-button-icons-only .ui-button-text{padding:.4em;text-indent:-9999999px}.ui-button-text-icon-primary .ui-button-text,.ui-button-text-icons .ui-button-text{padding:.4em 1em .4em 2.1em}.ui-button-text-icon-secondary .ui-button-text,.ui-button-text-icons .ui-button-text{padding:.4em 2.1em .4em 1em}.ui-button-text-icons .ui-button-text{padding-left:2.1em;padding-right:2.1em}input.ui-button{padding:.4em 1em}.ui-button-icon-only .ui-icon,.ui-button-text-icon-primary .ui-icon,.ui-button-text-icon-secondary .ui-icon,.ui-button-text-icons .ui-icon,.ui-button-icons-only .ui-icon{position:absolute;top:50%;margin-top:-8px}.ui-button-icon-only .ui-icon{left:50%;margin-left:-8px}.ui-button-text-icon-primary .ui-button-icon-primary,.ui-button-text-icons .ui-button-icon-primary,.ui-button-icons-only .ui-button-icon-primary{left:.5em}.ui-button-text-icon-secondary .ui-button-icon-secondary,.ui-button-text-icons .ui-button-icon-secondary,.ui-button-icons-only .ui-button-icon-secondary{right:.5em}.ui-button-text-icons .ui-button-icon-secondary,.ui-button-icons-only .ui-button-icon-secondary{right:.5em}.ui-buttonset{margin-right:7px}.ui-buttonset .ui-button{margin-left:0;margin-right:-.3em}button.ui-button::-moz-focus-inner{border:0;padding:0}.ui-datepicker{width:17em;padding:.2em .2em 0;display:none}.ui-datepicker .ui-datepicker-header{position:relative;padding:.2em 0}.ui-datepicker .ui-datepicker-prev,.ui-datepicker .ui-datepicker-next{position:absolute;top:2px;width:1.8em;height:1.8em}.ui-datepicker .ui-datepicker-prev-hover,.ui-datepicker .ui-datepicker-next-hover{top:1px}.ui-datepicker .ui-datepicker-prev{left:2px}.ui-datepicker .ui-datepicker-next{right:2px}.ui-datepicker .ui-datepicker-prev-hover{left:1px}.ui-datepicker .ui-datepicker-next-hover{right:1px}.ui-datepicker .ui-datepicker-prev span,.ui-datepicker .ui-datepicker-next span{display:block;position:absolute;left:50%;margin-left:-8px;top:50%;margin-top:-8px}.ui-datepicker .ui-datepicker-title{margin:0 2.3em;line-height:1.8em;text-align:center}.ui-datepicker .ui-datepicker-title select{font-size:1em;margin:1px 0}.ui-datepicker select.ui-datepicker-month-year{width:100%}.ui-datepicker select.ui-datepicker-month,.ui-datepicker select.ui-datepLine truncated
|
||||
@@ -1,161 +0,0 @@
|
||||
/*body,*/
|
||||
/*#wrap {*/
|
||||
/*width:1000px;*/
|
||||
/*height: 680px;*/
|
||||
/*position: absolute;*/
|
||||
/*top: 50%;*/
|
||||
/*margin-top: -350px;*/
|
||||
/*left: 50%;*/
|
||||
/*margin-left: -500px;*/
|
||||
/**/
|
||||
/*background:#ffffff;*/
|
||||
/*border: 5px outset #bbb;*/
|
||||
/*-moz-border-radius: 5px;*/
|
||||
/*-webkit-border-radius: 5px;*/
|
||||
/*border-radius: 5px;*/
|
||||
/*}*/
|
||||
/*#control {*/
|
||||
/*float:left;*/
|
||||
/*width:300px;*/
|
||||
/*margin-top: 10px;*/
|
||||
/*margin-left: 10px;*/
|
||||
/*background:#ffffff;*/
|
||||
/*margin-right: 10px;*/
|
||||
/*height: 680px;*/
|
||||
/*}*/
|
||||
#file_block {
|
||||
/*margin-top: 20px;*/
|
||||
/*margin-left: 20px;*/
|
||||
}
|
||||
|
||||
#control_bottom {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
width: 300px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
#options{
|
||||
float: left;
|
||||
margin-left: 5px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
/*#gcode {
|
||||
background: #ffffff;
|
||||
float:right;
|
||||
width: 680px;
|
||||
height: 680px;
|
||||
border-width: 2px;
|
||||
border-style: none none none solid;
|
||||
}*/
|
||||
|
||||
#canvas{
|
||||
/*float: left;*/
|
||||
clear:none;
|
||||
}
|
||||
|
||||
#drop_zone {
|
||||
border: 2px dashed #bbb;
|
||||
-moz-border-radius: 5px;
|
||||
-webkit-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
padding: 40px;
|
||||
margin: 5px;
|
||||
text-align: center;
|
||||
font: 20pt bold;
|
||||
color: #bbb
|
||||
}
|
||||
#slider-vertical {
|
||||
/*position: absolute;*/
|
||||
/*right: 0;*/
|
||||
/*top: 0;*/
|
||||
height: 580px;
|
||||
width: 10px;
|
||||
float: right;
|
||||
}
|
||||
#slider-horizontal {
|
||||
height: 10px;
|
||||
width: 570px;
|
||||
/*position: absolute;*/
|
||||
/*bottom: 0;*/
|
||||
}
|
||||
|
||||
#main_button_block {
|
||||
/*float: right;*/
|
||||
margin-bottom: 5px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
#gcode .mbut{
|
||||
height:60px;
|
||||
width: 250px;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
#tabs-min {
|
||||
height: 680px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
#gcode .mtab{
|
||||
background: transparent;
|
||||
border: none;
|
||||
font-weight: normal;
|
||||
font-size: 0.5em;
|
||||
}
|
||||
|
||||
#gcode .mtab-defstate{
|
||||
background: transparent;
|
||||
border: none;
|
||||
|
||||
}
|
||||
|
||||
#gcode .mtab-content{
|
||||
background: #ffffff;
|
||||
background-image: none;
|
||||
border: 0px none #dddddd;
|
||||
border-bottom-style: none;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
#gcode .bar {
|
||||
-webkit-transition: width 0s linear !important;
|
||||
-moz-transition: width 0s linear !important;
|
||||
-o-transition: width 0s linear !important;
|
||||
transition: width 0s linear !important;
|
||||
}
|
||||
|
||||
#gcode .nav {
|
||||
margin-bottom: 0px !important;
|
||||
}
|
||||
|
||||
#gcode .tab-content {
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
#gcode .aboutpage {
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
#accordion_top .ui-accordion-content{
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
#tabs-min .ui-tabs-panel {
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
#progressBlock {
|
||||
margin-left: 10px;
|
||||
margin-right: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
#gcode .colorBox {
|
||||
width: 50px;
|
||||
height: 15px;
|
||||
border: 1px solid #000000;
|
||||
float:left;
|
||||
}
|
||||
|
||||
#gcode .activeline {background: #fff0b6 !important;}
|
||||
|
||||
@@ -1,473 +0,0 @@
|
||||
/**
|
||||
* User: hudbrog (hudbrog@gmail.com)
|
||||
* Date: 10/24/12
|
||||
* Time: 12:18 PM
|
||||
*/
|
||||
|
||||
var gcode;
|
||||
var firstReport;
|
||||
var z_heights = {};
|
||||
var model = [];
|
||||
var gCodeOptions = {
|
||||
sortLayers: false,
|
||||
purgeEmptyLayers: true,
|
||||
analyzeModel: false
|
||||
};
|
||||
var max = {x: undefined, y: undefined, z: undefined};
|
||||
var min = {x: undefined, y: undefined, z: undefined};
|
||||
var modelSize = {x: undefined, y: undefined, z: undefined};
|
||||
var filamentByLayer = {};
|
||||
var totalFilament=0;
|
||||
var printTime=0;
|
||||
var printTimeByLayer = {};
|
||||
var layerHeight=0;
|
||||
var layerCnt = 0;
|
||||
var speeds = {extrude: [], retract: [], move: []};
|
||||
var speedsByLayer = {extrude: {}, retract: {}, move: {}};
|
||||
|
||||
|
||||
|
||||
var sendLayerToParent = function(layerNum, z, progress){
|
||||
self.postMessage({
|
||||
"cmd": "returnLayer",
|
||||
"msg": {
|
||||
cmds: model[layerNum],
|
||||
layerNum: layerNum,
|
||||
zHeightObject: {zValue: z, layer: z_heights[z]},
|
||||
isEmpty: false,
|
||||
progress: progress
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var sendMultiLayerToParent = function(layerNum, z, progress){
|
||||
var tmpModel = [];
|
||||
var tmpZHeight = {};
|
||||
|
||||
for(var i=0;i<layerNum.length;i++){
|
||||
tmpModel[layerNum[i]] = model[layerNum[i]];
|
||||
tmpZHeight[layerNum[i]] = z_heights[z[i]];
|
||||
}
|
||||
|
||||
self.postMessage({
|
||||
"cmd": "returnMultiLayer",
|
||||
"msg": {
|
||||
model: tmpModel,
|
||||
layerNum: layerNum,
|
||||
zHeightObject: {zValue: z, layer: tmpZHeight},
|
||||
isEmpty: false,
|
||||
progress: progress
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
var sendSizeProgress = function(progress){
|
||||
self.postMessage({
|
||||
"cmd": "analyzeProgress",
|
||||
"msg": {
|
||||
progress: progress,
|
||||
printTime: printTime
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var sendAnalyzeDone = function(){
|
||||
self.postMessage({
|
||||
"cmd": "analyzeDone",
|
||||
"msg": {
|
||||
max: max,
|
||||
min: min,
|
||||
modelSize: modelSize,
|
||||
totalFilament:totalFilament,
|
||||
filamentByLayer: filamentByLayer,
|
||||
printTime: printTime,
|
||||
layerHeight: layerHeight,
|
||||
layerCnt: layerCnt,
|
||||
layerTotal: model.length,
|
||||
speeds: speeds,
|
||||
speedsByLayer: speedsByLayer,
|
||||
printTimeByLayer: printTimeByLayer
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var purgeLayers = function(){
|
||||
var purge=true;
|
||||
for(var i=0;i<model.length;i++){
|
||||
purge=true;
|
||||
if(!model[i])purge=true;
|
||||
else {
|
||||
for(var j=0;j<model[i].length;j++){
|
||||
if(model[i][j].extrude)purge=false;
|
||||
}
|
||||
}
|
||||
if(!purge){
|
||||
layerCnt+=1;
|
||||
}
|
||||
}
|
||||
// self.postMessage('LayerCnt: ' + layerCnt);
|
||||
};
|
||||
|
||||
|
||||
var analyzeModel = function(){
|
||||
var i,j;
|
||||
var x_ok=false, y_ok=false;
|
||||
var cmds;
|
||||
var tmp1= 0, tmp2=0;
|
||||
var speedIndex=0;
|
||||
var type;
|
||||
var printTimeAdd=0;
|
||||
// var moveTime=0;
|
||||
|
||||
for(i=0;i<model.length;i++){
|
||||
cmds = model[i];
|
||||
if(!cmds)continue;
|
||||
for(j=0;j<cmds.length;j++){
|
||||
x_ok=false;
|
||||
y_ok=false;
|
||||
if(typeof(cmds[j].x) !== 'undefined'&&typeof(cmds[j].prevX) !== 'undefined'&&typeof(cmds[j].extrude) !== 'undefined'&&cmds[j].extrude&&!isNaN(cmds[j].x))
|
||||
{
|
||||
max.x = parseFloat(max.x)>parseFloat(cmds[j].x)?parseFloat(max.x):parseFloat(cmds[j].x);
|
||||
max.x = parseFloat(max.x)>parseFloat(cmds[j].prevX)?parseFloat(max.x):parseFloat(cmds[j].prevX);
|
||||
min.x = parseFloat(min.x)<parseFloat(cmds[j].x)?parseFloat(min.x):parseFloat(cmds[j].x);
|
||||
min.x = parseFloat(min.x)<parseFloat(cmds[j].prevX)?parseFloat(min.x):parseFloat(cmds[j].prevX);
|
||||
x_ok=true;
|
||||
}
|
||||
|
||||
if(typeof(cmds[j].y) !== 'undefined'&&typeof(cmds[j].prevY) !== 'undefined'&&typeof(cmds[j].extrude) !== 'undefined'&&cmds[j].extrude&&!isNaN(cmds[j].y)){
|
||||
max.y = parseFloat(max.y)>parseFloat(cmds[j].y)?parseFloat(max.y):parseFloat(cmds[j].y);
|
||||
max.y = parseFloat(max.y)>parseFloat(cmds[j].prevY)?parseFloat(max.y):parseFloat(cmds[j].prevY);
|
||||
min.y = parseFloat(min.y)<parseFloat(cmds[j].y)?parseFloat(min.y):parseFloat(cmds[j].y);
|
||||
min.y = parseFloat(min.y)<parseFloat(cmds[j].prevY)?parseFloat(min.y):parseFloat(cmds[j].prevY);
|
||||
y_ok=true;
|
||||
}
|
||||
|
||||
if(typeof(cmds[j].prevZ) !== 'undefined'&&typeof(cmds[j].extrude) !== 'undefined'&&cmds[j].extrude&&!isNaN(cmds[j].prevZ)){
|
||||
max.z = parseFloat(max.z)>parseFloat(cmds[j].prevZ)?parseFloat(max.z):parseFloat(cmds[j].prevZ);
|
||||
min.z = parseFloat(min.z)<parseFloat(cmds[j].prevZ)?parseFloat(min.z):parseFloat(cmds[j].prevZ);
|
||||
}
|
||||
|
||||
if(typeof(cmds[j].extrude) !== 'undefined'||cmds[j].retract!=0){
|
||||
totalFilament+=cmds[j].extrusion;
|
||||
if(!filamentByLayer[cmds[j].prevZ])filamentByLayer[cmds[j].prevZ]=0;
|
||||
filamentByLayer[cmds[j].prevZ]+=cmds[j].extrusion;
|
||||
}
|
||||
|
||||
if(x_ok&&y_ok){
|
||||
printTimeAdd = Math.sqrt(Math.pow(parseFloat(cmds[j].x)-parseFloat(cmds[j].prevX),2)+Math.pow(parseFloat(cmds[j].y)-parseFloat(cmds[j].prevY),2))/(cmds[j].speed/60);
|
||||
}else if(cmds[j].retract===0&&cmds[j].extrusion!==0){
|
||||
tmp1 = Math.sqrt(Math.pow(parseFloat(cmds[j].x)-parseFloat(cmds[j].prevX),2)+Math.pow(parseFloat(cmds[j].y)-parseFloat(cmds[j].prevY),2))/(cmds[j].speed/60);
|
||||
tmp2 = Math.abs(parseFloat(cmds[j].extrusion)/(cmds[j].speed/60));
|
||||
printTimeAdd = tmp1>=tmp2?tmp1:tmp2;
|
||||
}else if(cmds[j].retract!==0){
|
||||
printTimeAdd = Math.abs(parseFloat(cmds[j].extrusion)/(cmds[j].speed/60));
|
||||
}
|
||||
|
||||
printTime += printTimeAdd;
|
||||
if(typeof(printTimeByLayer[cmds[j].prevZ])==='undefined'){printTimeByLayer[cmds[j].prevZ]=0;}
|
||||
printTimeByLayer[cmds[j].prevZ] += printTimeAdd;
|
||||
|
||||
if(cmds[j].extrude&&cmds[j].retract===0){
|
||||
type = 'extrude';
|
||||
}else if(cmds[j].retract!==0){
|
||||
type = 'retract';
|
||||
}else if(!cmds[j].extrude&&cmds[j].retract===0){
|
||||
type = 'move';
|
||||
// if(cmds[j].prevZ == '17.1'){
|
||||
// self.postMessage({cmd: 'Got speed ' + cmds[j].speed + 'with line ' + cmds[j].gcodeLine});
|
||||
// }
|
||||
}else {
|
||||
self.postMessage({cmd: 'unknown type of move'});
|
||||
type = 'unknown';
|
||||
}
|
||||
speedIndex = speeds[type].indexOf(cmds[j].speed);
|
||||
if (speedIndex === -1) {
|
||||
speeds[type].push(cmds[j].speed);
|
||||
speedIndex = speeds[type].indexOf(cmds[j].speed);
|
||||
}
|
||||
if(typeof(speedsByLayer[type][cmds[j].prevZ]) === 'undefined'){
|
||||
speedsByLayer[type][cmds[j].prevZ] = [];
|
||||
}
|
||||
if(speedsByLayer[type][cmds[j].prevZ].indexOf(cmds[j].speed) === -1){
|
||||
speedsByLayer[type][cmds[j].prevZ][speedIndex] = cmds[j].speed;
|
||||
}
|
||||
|
||||
}
|
||||
sendSizeProgress(i/model.length*100);
|
||||
|
||||
}
|
||||
purgeLayers();
|
||||
|
||||
modelSize.x = Math.abs(max.x - min.x);
|
||||
modelSize.y = Math.abs(max.y - min.y);
|
||||
modelSize.z = Math.abs(max.z - min.z);
|
||||
layerHeight = (max.z-min.z)/(layerCnt-1);
|
||||
|
||||
sendAnalyzeDone();
|
||||
};
|
||||
|
||||
var doParse = function(){
|
||||
var argChar, numSlice;
|
||||
model=[];
|
||||
var sendLayer = undefined;
|
||||
var sendLayerZ = 0;
|
||||
var sendMultiLayer = [];
|
||||
var sendMultiLayerZ = [];
|
||||
var lastSend = 0;
|
||||
// console.time("parseGCode timer");
|
||||
var reg = new RegExp(/^(?:G0|G1)\s/i);
|
||||
var comment = new RegExp()
|
||||
var j, layer= 0, extrude=false, prevRetract= 0, retract=0, x, y, z=0, f, prevZ=0, prevX, prevY,lastF=4000, prev_extrude = {a: undefined, b: undefined, c: undefined, e: undefined, abs: undefined}, extrudeRelative=false;
|
||||
var dcExtrude=false;
|
||||
var assumeNonDC = false;
|
||||
|
||||
for(var i=0;i<gcode.length;i++){
|
||||
x=undefined;
|
||||
y=undefined;
|
||||
z=undefined;
|
||||
retract = 0;
|
||||
|
||||
var line = gcode[i].line;
|
||||
var percentage = gcode[i].percentage;
|
||||
|
||||
extrude=false;
|
||||
line = line.split(/[\(;]/)[0];
|
||||
|
||||
if(reg.test(line)){
|
||||
var args = line.split(/\s/);
|
||||
for(j=0;j<args.length;j++){
|
||||
switch(argChar = args[j].charAt(0).toLowerCase()){
|
||||
case 'x':
|
||||
x=args[j].slice(1);
|
||||
break;
|
||||
case 'y':
|
||||
y=args[j].slice(1);
|
||||
break;
|
||||
case 'z':
|
||||
z=args[j].slice(1);
|
||||
z = Number(z);
|
||||
if(z == prevZ) continue;
|
||||
if(z_heights.hasOwnProperty(z)){
|
||||
layer = z_heights[z];
|
||||
}else{
|
||||
layer = model.length;
|
||||
z_heights[z] = layer;
|
||||
}
|
||||
sendLayer = layer;
|
||||
sendLayerZ = z;
|
||||
prevZ = z;
|
||||
break;
|
||||
case 'e':
|
||||
case 'a':
|
||||
case 'b':
|
||||
case 'c':
|
||||
assumeNonDC = true;
|
||||
numSlice = parseFloat(args[j].slice(1)).toFixed(3);
|
||||
|
||||
if(!extrudeRelative){
|
||||
// absolute extrusion positioning
|
||||
prev_extrude["abs"] = parseFloat(numSlice)-parseFloat(prev_extrude[argChar]);
|
||||
|
||||
}else{
|
||||
prev_extrude["abs"] = parseFloat(numSlice);
|
||||
}
|
||||
extrude = prev_extrude["abs"]>0;
|
||||
if(prev_extrude["abs"]<0){
|
||||
prevRetract = -1;
|
||||
retract = -1;
|
||||
}
|
||||
else if(prev_extrude["abs"]==0){
|
||||
retract = 0;
|
||||
}else if(prev_extrude["abs"]>0&&prevRetract < 0){
|
||||
prevRetract = 0;
|
||||
retract = 1;
|
||||
} else {
|
||||
retract = 0;
|
||||
}
|
||||
prev_extrude[argChar] = numSlice;
|
||||
|
||||
break;
|
||||
case 'f':
|
||||
numSlice = args[j].slice(1);
|
||||
lastF = numSlice;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(dcExtrude&&!assumeNonDC){
|
||||
extrude = true;
|
||||
prev_extrude["abs"] = Math.sqrt((prevX-x)*(prevX-x)+(prevY-y)*(prevY-y));
|
||||
}
|
||||
if(!model[layer])model[layer]=[];
|
||||
if(typeof(x) !== 'undefined' || typeof(y) !== 'undefined' ||typeof(z) !== 'undefined'||retract!=0) model[layer][model[layer].length] = {x: Number(x), y: Number(y), z: Number(z), extrude: extrude, retract: Number(retract), noMove: false, extrusion: (extrude||retract)?Number(prev_extrude["abs"]):0, prevX: Number(prevX), prevY: Number(prevY), prevZ: Number(prevZ), speed: Number(lastF), gcodeLine: Number(i), percentage: percentage};
|
||||
//{x: x, y: y, z: z, extrude: extrude, retract: retract, noMove: false, extrusion: (extrude||retract)?prev_extrude["abs"]:0, prevX: prevX, prevY: prevY, prevZ: prevZ, speed: lastF, gcodeLine: i};
|
||||
if(typeof(x) !== 'undefined') prevX = x;
|
||||
if(typeof(y) !== 'undefined') prevY = y;
|
||||
} else if(line.match(/^(?:M82)/i)){
|
||||
extrudeRelative = false;
|
||||
}else if(line.match(/^(?:G91)/i)){
|
||||
extrudeRelative=true;
|
||||
}else if(line.match(/^(?:G90)/i)){
|
||||
extrudeRelative=false;
|
||||
}else if(line.match(/^(?:M83)/i)){
|
||||
extrudeRelative=true;
|
||||
}else if(line.match(/^(?:M101)/i)){
|
||||
dcExtrude=true;
|
||||
}else if(line.match(/^(?:M103)/i)){
|
||||
dcExtrude=false;
|
||||
}else if(line.match(/^(?:G92)/i)){
|
||||
var args = line.split(/\s/);
|
||||
for(j=0;j<args.length;j++){
|
||||
switch(argChar = args[j].charAt(0).toLowerCase()){
|
||||
case 'x':
|
||||
x=args[j].slice(1);
|
||||
break;
|
||||
case 'y':
|
||||
y=args[j].slice(1);
|
||||
break;
|
||||
case 'z':
|
||||
z=args[j].slice(1);
|
||||
prevZ = z;
|
||||
break;
|
||||
case 'e'||'a'||'b'||'c':
|
||||
numSlice = args[j].slice(1);
|
||||
if(!extrudeRelative)
|
||||
prev_extrude[argChar] = 0;
|
||||
else {
|
||||
prev_extrude[argChar] = numSlice;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!model[layer])model[layer]=[];
|
||||
if(typeof(x) !== 'undefined' || typeof(y) !== 'undefined' ||typeof(z) !== 'undefined') model[layer][model[layer].length] = {x: parseFloat(x), y: parseFloat(y), z: parseFloat(z), extrude: extrude, retract: parseFloat(retract), noMove: true, extrusion: (extrude||retract)?parseFloat(prev_extrude["abs"]):0, prevX: parseFloat(prevX), prevY: parseFloat(prevY), prevZ: parseFloat(prevZ), speed: parseFloat(lastF),gcodeLine: parseFloat(i), percentage: percentage};
|
||||
}else if(line.match(/^(?:G28)/i)){
|
||||
var args = line.split(/\s/);
|
||||
for(j=0;j<args.length;j++){
|
||||
switch(argChar = args[j].charAt(0).toLowerCase()){
|
||||
case 'x':
|
||||
x=args[j].slice(1);
|
||||
break;
|
||||
case 'y':
|
||||
y=args[j].slice(1);
|
||||
break;
|
||||
case 'z':
|
||||
z=args[j].slice(1);
|
||||
z = Number(z);
|
||||
if(z === prevZ)continue;
|
||||
sendLayer = layer;
|
||||
sendLayerZ = z;//}
|
||||
if(z_heights.hasOwnProperty(z)){
|
||||
layer = z_heights[z];
|
||||
}else{
|
||||
layer = model.length;
|
||||
z_heights[z] = layer;
|
||||
}
|
||||
prevZ = z;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
// G28 with no arguments
|
||||
if(args.length == 1){
|
||||
//need to init values to default here
|
||||
}
|
||||
// if it's the first layer and G28 was without
|
||||
if(layer==0&&typeof(z) === 'undefined'){
|
||||
z=0;
|
||||
if(z_heights.hasOwnProperty(z)){
|
||||
layer = z_heights[z];
|
||||
}else{
|
||||
layer = model.length;
|
||||
z_heights[z] = layer;
|
||||
}
|
||||
prevZ = z;
|
||||
}
|
||||
|
||||
if(!model[layer])model[layer]=[];
|
||||
if(typeof(x) !== 'undefined' || typeof(y) !== 'undefined' ||typeof(z) !== 'undefined'||retract!=0) model[layer][model[layer].length] = {x: Number(x), y: Number(y), z: Number(z), extrude: extrude, retract: Number(retract), noMove: false, extrusion: (extrude||retract)?Number(prev_extrude["abs"]):0, prevX: Number(prevX), prevY: Number(prevY), prevZ: Number(prevZ), speed: Number(lastF), gcodeLine: Number(i), percentage: percentage};
|
||||
}
|
||||
if(typeof(sendLayer) !== "undefined"){
|
||||
|
||||
if(i-lastSend > gcode.length*0.02 && sendMultiLayer.length != 0){
|
||||
lastSend = i;
|
||||
sendMultiLayerToParent(sendMultiLayer, sendMultiLayerZ, i/gcode.length*100);
|
||||
sendMultiLayer = [];
|
||||
sendMultiLayerZ = [];
|
||||
}
|
||||
sendMultiLayer[sendMultiLayer.length] = sendLayer;
|
||||
sendMultiLayerZ[sendMultiLayerZ.length] = sendLayerZ;
|
||||
sendLayer = undefined;
|
||||
sendLayerZ = undefined;
|
||||
}
|
||||
}
|
||||
sendMultiLayerToParent(sendMultiLayer, sendMultiLayerZ, i/gcode.length*100);
|
||||
};
|
||||
|
||||
|
||||
var parseGCode = function(message){
|
||||
gcode = message.gcode;
|
||||
firstReport = message.options.firstReport;
|
||||
|
||||
|
||||
doParse();
|
||||
gcode = [];
|
||||
self.postMessage({
|
||||
"cmd": "returnModel",
|
||||
"msg": {
|
||||
// model: model
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
var runAnalyze = function(message){
|
||||
analyzeModel();
|
||||
model = [];
|
||||
z_heights = [];
|
||||
gcode = undefined;
|
||||
firstReport = undefined;
|
||||
z_heights = {};
|
||||
model = [];
|
||||
max = {x: undefined, y: undefined, z: undefined};
|
||||
min = {x: undefined, y: undefined, z: undefined};
|
||||
modelSize = {x: undefined, y: undefined, z: undefined};
|
||||
filamentByLayer = {};
|
||||
totalFilament=0;
|
||||
printTime=0;
|
||||
printTimeByLayer = {};
|
||||
layerHeight=0;
|
||||
layerCnt = 0;
|
||||
speeds = {extrude: [], retract: [], move: []};
|
||||
speedsByLayer = {extrude: {}, retract: {}, move: {}};
|
||||
};
|
||||
var setOption = function(options){
|
||||
for(var opt in options){
|
||||
gCodeOptions[opt] = options[opt];
|
||||
}
|
||||
};
|
||||
|
||||
onmessage = function (e){
|
||||
var data = e.data;
|
||||
// for some reason firefox doesn't garbage collect when something inside closures is deleted, so we delete and recreate whole object eaech time
|
||||
switch (data.cmd) {
|
||||
case 'parseGCode':
|
||||
parseGCode(data.msg);
|
||||
break;
|
||||
case 'setOption':
|
||||
setOption(data.msg);
|
||||
break;
|
||||
case 'analyzeModel':
|
||||
runAnalyze(data.msg);
|
||||
break;
|
||||
|
||||
default:
|
||||
self.postMessage('Unknown command: ' + data.msg);
|
||||
}
|
||||
|
||||
};
|
||||
@@ -1,417 +0,0 @@
|
||||
/**
|
||||
* User: hudbrog (hudbrog@gmail.com)
|
||||
* Date: 10/20/12
|
||||
* Time: 1:36 PM
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
|
||||
|
||||
GCODE.renderer = (function(){
|
||||
// ***** PRIVATE ******
|
||||
var canvas;
|
||||
var ctx;
|
||||
var zoomFactor= 2.8, zoomFactorDelta = 0.4;
|
||||
var gridSizeX=200,gridSizeY=200,gridStep=10;
|
||||
var ctxHeight, ctxWidth;
|
||||
var prevX=0, prevY=0;
|
||||
|
||||
// var colorGrid="#bbbbbb", colorLine="#000000";
|
||||
var sliderHor, sliderVer;
|
||||
var layerNumStore, progressStore={from: 0, to: -1};
|
||||
var lastX, lastY;
|
||||
var dragStart,dragged;
|
||||
var scaleFactor = 1.1;
|
||||
var model;
|
||||
var initialized=false;
|
||||
var renderOptions = {
|
||||
showMoves: true,
|
||||
showRetracts: true,
|
||||
colorGrid: "#bbbbbb",
|
||||
extrusionWidth: 1,
|
||||
// colorLine: ["#000000", "#aabb88", "#ffe7a0", "#6e7700", "#331a00", "#44ba97", "#08262f", "#db0e00", "#ff9977"],
|
||||
colorLine: ["#000000", "#45c7ba", "#a9533a", "#ff44cc", "#dd1177", "#eeee22", "#ffbb55", "#ff5511", "#777788"],
|
||||
colorMove: "#00ff00",
|
||||
colorRetract: "#ff0000",
|
||||
colorRestart: "#0000ff",
|
||||
sizeRetractSpot: 2,
|
||||
modelCenter: {x: 0, y: 0},
|
||||
moveModel: true,
|
||||
differentiateColors: true,
|
||||
showNextLayer: false
|
||||
};
|
||||
|
||||
var offsetModelX=0, offsetModelY=0;
|
||||
var speeds = [];
|
||||
var speedsByLayer = {};
|
||||
|
||||
|
||||
var reRender = function(){
|
||||
var p1 = ctx.transformedPoint(0,0);
|
||||
var p2 = ctx.transformedPoint(canvas.width,canvas.height);
|
||||
ctx.clearRect(p1.x,p1.y,p2.x-p1.x,p2.y-p1.y);
|
||||
drawGrid();
|
||||
if(renderOptions['showNextLayer'] && layerNumStore < model.length - 1) {
|
||||
drawLayer(layerNumStore+1, 0, GCODE.renderer.getLayerNumSegments(layerNumStore+1), true);
|
||||
}
|
||||
drawLayer(layerNumStore, progressStore.from, progressStore.to);
|
||||
};
|
||||
|
||||
function trackTransforms(ctx){
|
||||
var svg = document.createElementNS("http://www.w3.org/2000/svg",'svg');
|
||||
var xform = svg.createSVGMatrix();
|
||||
ctx.getTransform = function(){ return xform; };
|
||||
|
||||
var savedTransforms = [];
|
||||
var save = ctx.save;
|
||||
ctx.save = function(){
|
||||
savedTransforms.push(xform.translate(0,0));
|
||||
return save.call(ctx);
|
||||
};
|
||||
var restore = ctx.restore;
|
||||
ctx.restore = function(){
|
||||
xform = savedTransforms.pop();
|
||||
return restore.call(ctx);
|
||||
};
|
||||
|
||||
var scale = ctx.scale;
|
||||
ctx.scale = function(sx,sy){
|
||||
xform = xform.scaleNonUniform(sx,sy);
|
||||
return scale.call(ctx,sx,sy);
|
||||
};
|
||||
var rotate = ctx.rotate;
|
||||
ctx.rotate = function(radians){
|
||||
xform = xform.rotate(radians*180/Math.PI);
|
||||
return rotate.call(ctx,radians);
|
||||
};
|
||||
var translate = ctx.translate;
|
||||
ctx.translate = function(dx,dy){
|
||||
xform = xform.translate(dx,dy);
|
||||
return translate.call(ctx,dx,dy);
|
||||
};
|
||||
var transform = ctx.transform;
|
||||
ctx.transform = function(a,b,c,d,e,f){
|
||||
var m2 = svg.createSVGMatrix();
|
||||
m2.a=a; m2.b=b; m2.c=c; m2.d=d; m2.e=e; m2.f=f;
|
||||
xform = xform.multiply(m2);
|
||||
return transform.call(ctx,a,b,c,d,e,f);
|
||||
};
|
||||
var setTransform = ctx.setTransform;
|
||||
ctx.setTransform = function(a,b,c,d,e,f){
|
||||
xform.a = a;
|
||||
xform.b = b;
|
||||
xform.c = c;
|
||||
xform.d = d;
|
||||
xform.e = e;
|
||||
xform.f = f;
|
||||
return setTransform.call(ctx,a,b,c,d,e,f);
|
||||
};
|
||||
var pt = svg.createSVGPoint();
|
||||
ctx.transformedPoint = function(x,y){
|
||||
pt.x=x; pt.y=y;
|
||||
return pt.matrixTransform(xform.inverse());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var startCanvas = function() {
|
||||
canvas = document.getElementById('canvas');
|
||||
|
||||
// Проверяем понимает ли браузер canvas
|
||||
if (!canvas.getContext) {
|
||||
throw "exception";
|
||||
}
|
||||
|
||||
ctx = canvas.getContext('2d'); // Получаем 2D контекст
|
||||
ctxHeight = canvas.height;
|
||||
ctxWidth = canvas.width;
|
||||
lastX = ctxWidth/2;
|
||||
lastY = ctxHeight/2;
|
||||
ctx.lineWidth = 2;
|
||||
ctx.lineCap = 'round';
|
||||
trackTransforms(ctx);
|
||||
|
||||
canvas.addEventListener('mousedown',function(evt){
|
||||
document.body.style.mozUserSelect = document.body.style.webkitUserSelect = document.body.style.userSelect = 'none';
|
||||
lastX = evt.offsetX || (evt.pageX - canvas.offsetLeft);
|
||||
lastY = evt.offsetY || (evt.pageY - canvas.offsetTop);
|
||||
dragStart = ctx.transformedPoint(lastX,lastY);
|
||||
dragged = false;
|
||||
},false);
|
||||
canvas.addEventListener('mousemove',function(evt){
|
||||
lastX = evt.offsetX || (evt.pageX - canvas.offsetLeft);
|
||||
lastY = evt.offsetY || (evt.pageY - canvas.offsetTop);
|
||||
dragged = true;
|
||||
if (dragStart){
|
||||
var pt = ctx.transformedPoint(lastX,lastY);
|
||||
ctx.translate(pt.x-dragStart.x,pt.y-dragStart.y);
|
||||
reRender();
|
||||
}
|
||||
},false);
|
||||
canvas.addEventListener('mouseup',function(evt){
|
||||
dragStart = null;
|
||||
if (!dragged) zoom(evt.shiftKey ? -1 : 1 );
|
||||
},false);
|
||||
var zoom = function(clicks){
|
||||
var pt = ctx.transformedPoint(lastX,lastY);
|
||||
ctx.translate(pt.x,pt.y);
|
||||
var factor = Math.pow(scaleFactor,clicks);
|
||||
ctx.scale(factor,factor);
|
||||
ctx.translate(-pt.x,-pt.y);
|
||||
reRender();
|
||||
};
|
||||
var handleScroll = function(evt){
|
||||
var delta;
|
||||
if(evt.detail<0 || evt.wheelDelta>0)delta=zoomFactorDelta;
|
||||
else delta=-1*zoomFactorDelta;
|
||||
if (delta) zoom(delta);
|
||||
return evt.preventDefault() && false;
|
||||
};
|
||||
canvas.addEventListener('DOMMouseScroll',handleScroll,false);
|
||||
canvas.addEventListener('mousewheel',handleScroll,false);
|
||||
|
||||
};
|
||||
|
||||
var drawGrid = function() {
|
||||
var i;
|
||||
ctx.strokeStyle = renderOptions["colorGrid"];
|
||||
ctx.lineWidth = 1;
|
||||
var offsetX=0, offsetY=0;
|
||||
if(renderOptions["moveModel"]){
|
||||
offsetX = offsetModelX;
|
||||
offsetY = offsetModelY;
|
||||
}
|
||||
|
||||
ctx.beginPath();
|
||||
for(i=0;i<=gridSizeX;i+=gridStep){
|
||||
ctx.moveTo(i*zoomFactor-offsetX, 0-offsetY);
|
||||
ctx.lineTo(i*zoomFactor-offsetX, -gridSizeY*zoomFactor-offsetY);
|
||||
}
|
||||
ctx.stroke();
|
||||
|
||||
ctx.beginPath();
|
||||
for(i=0;i<=gridSizeY;i+=gridStep){
|
||||
ctx.moveTo(0-offsetX, -i*zoomFactor-offsetY);
|
||||
ctx.lineTo(gridSizeX*zoomFactor-offsetX, -i*zoomFactor-offsetY);
|
||||
}
|
||||
ctx.stroke();
|
||||
|
||||
};
|
||||
|
||||
var drawLayer = function(layerNum, fromProgress, toProgress, isNextLayer){
|
||||
var i, speedIndex= 0, prevZ = 0;
|
||||
isNextLayer = typeof isNextLayer !== 'undefined' ? isNextLayer : false;
|
||||
if(!isNextLayer){
|
||||
layerNumStore=layerNum;
|
||||
progressStore = {from: fromProgress, to: toProgress};
|
||||
}
|
||||
if(!model||!model[layerNum])return;
|
||||
|
||||
var cmds = model[layerNum];
|
||||
var x, y;
|
||||
|
||||
// if(toProgress === -1){
|
||||
// toProgress=cmds.length;
|
||||
// }
|
||||
|
||||
if(fromProgress>0){
|
||||
prevX = cmds[fromProgress-1].x*zoomFactor;
|
||||
prevY = -cmds[fromProgress-1].y*zoomFactor;
|
||||
}else if(fromProgress===0 && layerNum==0){
|
||||
if(model[0]&&model[0].x !== undefined &&model[0].y !== undefined){
|
||||
prevX = model[0].x*zoomFactor;
|
||||
prevY = -model[0].y*zoomFactor;
|
||||
}else {
|
||||
prevX = 0;
|
||||
prevY = 0;
|
||||
}
|
||||
}else if(typeof(cmds[0].prevX) !== 'undefined' && typeof(cmds[0].prevY) !== 'undefined'){
|
||||
prevX = cmds[0].prevX*zoomFactor;
|
||||
prevY = -cmds[0].prevY*zoomFactor;
|
||||
}else{
|
||||
if(model[layerNum-1]){
|
||||
prevX=undefined;
|
||||
prevY=undefined;
|
||||
for(i=model[layerNum-1].length-1;i>=0;i--){
|
||||
if(prevX === undefined && model[layerNum-1][i].x!==undefined)prevX=model[layerNum-1][i].x*zoomFactor;
|
||||
if(prevY === undefined && model[layerNum-1][i].y!==undefined)prevY=-model[layerNum-1][i].y*zoomFactor;
|
||||
}
|
||||
if(prevX === undefined)prevX=0;
|
||||
if(prevY === undefined)prevY=0;
|
||||
}else{
|
||||
prevX=0;
|
||||
prevY=0;
|
||||
}
|
||||
}
|
||||
|
||||
prevZ = GCODE.renderer.getZ(layerNum);
|
||||
|
||||
// ctx.strokeStyle = renderOptions["colorLine"];
|
||||
for(i=fromProgress;i<=toProgress;i++){
|
||||
ctx.lineWidth = 1;
|
||||
|
||||
if(typeof(cmds[i]) === 'undefined')continue;
|
||||
|
||||
if(typeof(cmds[i].prevX) !== 'undefined' && typeof(cmds[i].prevY) !== 'undefined'){
|
||||
prevX = cmds[i].prevX*zoomFactor;
|
||||
prevY = -cmds[i].prevY*zoomFactor;
|
||||
}
|
||||
// console.log(cmds[i]);
|
||||
if(typeof(cmds[i].x)==='undefined'||isNaN(cmds[i].x))x=prevX/zoomFactor;
|
||||
else x = cmds[i].x;
|
||||
if(typeof(cmds[i].y) === 'undefined'||isNaN(cmds[i].y))y=prevY/zoomFactor;
|
||||
else y = -cmds[i].y;
|
||||
if(renderOptions["differentiateColors"]&&!renderOptions['showNextLayer']){
|
||||
// if(speedsByLayer['extrude'][prevZ]){
|
||||
speedIndex = speeds['extrude'].indexOf(cmds[i].speed);
|
||||
// speedIndex = GCODE.ui.ArrayIndexOf(speedsByLayer['extrude'][prevZ], function(obj) {return obj.speed === cmds[i].speed;});
|
||||
// } else {
|
||||
// speedIndex = -1;
|
||||
// }
|
||||
if(speedIndex === -1){
|
||||
speedIndex = 0;
|
||||
}else if(speedIndex > renderOptions["colorLine"].length -1){
|
||||
speedIndex = speedIndex % (renderOptions["colorLine"].length-1);
|
||||
// console.log("Too much colors");
|
||||
}
|
||||
}else if(renderOptions['showNextLayer']&&isNextLayer){
|
||||
speedIndex=3;
|
||||
}else{
|
||||
speedIndex=0;
|
||||
}
|
||||
|
||||
|
||||
if(!cmds[i].extrude&&!cmds[i].noMove){
|
||||
// ctx.stroke();
|
||||
if(cmds[i].retract == -1){
|
||||
if(renderOptions["showRetracts"]){
|
||||
|
||||
ctx.strokeStyle = renderOptions["colorRetract"];
|
||||
ctx.fillStyle = renderOptions["colorRetract"];
|
||||
ctx.beginPath();
|
||||
ctx.arc(prevX, prevY, renderOptions["sizeRetractSpot"], 0, Math.PI*2, true);
|
||||
ctx.stroke();
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
if(renderOptions["showMoves"]){
|
||||
ctx.strokeStyle = renderOptions["colorMove"];
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(prevX, prevY);
|
||||
ctx.lineTo(x*zoomFactor,y*zoomFactor);
|
||||
ctx.stroke();
|
||||
}
|
||||
// ctx.strokeStyle = renderOptions["colorLine"][0];
|
||||
// ctx.beginPath();
|
||||
// console.log("moveto: "+cmds[i].x+":"+cmds[i].y)
|
||||
// ctx.moveTo(cmds[i].x*zoomFactor,cmds[i].y*zoomFactor);
|
||||
}
|
||||
else if(cmds[i].extrude){
|
||||
if(cmds[i].retract==0){
|
||||
ctx.strokeStyle = renderOptions["colorLine"][speedIndex];
|
||||
ctx.lineWidth = renderOptions['extrusionWidth'];
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(prevX, prevY);
|
||||
ctx.lineTo(x*zoomFactor,y*zoomFactor);
|
||||
ctx.stroke();
|
||||
}else {
|
||||
if(renderOptions["showRetracts"]){
|
||||
// ctx.stroke();
|
||||
ctx.strokeStyle = renderOptions["colorRestart"];
|
||||
ctx.fillStyle = renderOptions["colorRestart"];
|
||||
ctx.beginPath();
|
||||
ctx.arc(prevX, prevY, renderOptions["sizeRetractSpot"], 0, Math.PI*2, true);
|
||||
ctx.stroke();
|
||||
ctx.fill();
|
||||
// ctx.strokeStyle = renderOptions["colorLine"][0];
|
||||
// ctx.beginPath();
|
||||
}
|
||||
}
|
||||
}
|
||||
prevX = x*zoomFactor;
|
||||
prevY = y*zoomFactor;
|
||||
}
|
||||
ctx.stroke();
|
||||
};
|
||||
|
||||
|
||||
// ***** PUBLIC *******
|
||||
return {
|
||||
init: function(){
|
||||
startCanvas();
|
||||
initialized = true;
|
||||
ctx.translate(10,gridSizeY*zoomFactor+20);
|
||||
},
|
||||
setOption: function(options){
|
||||
for(var opt in options){
|
||||
if(options.hasOwnProperty(opt))renderOptions[opt] = options[opt];
|
||||
};
|
||||
|
||||
if(initialized)reRender();
|
||||
},
|
||||
getOptions: function(){
|
||||
return renderOptions;
|
||||
},
|
||||
debugGetModel: function(){
|
||||
return model;
|
||||
},
|
||||
render: function(layerNum, fromProgress, toProgress){
|
||||
if(!initialized)this.init();
|
||||
if(!model){
|
||||
drawGrid();
|
||||
}else{
|
||||
if(layerNum < model.length){
|
||||
var p1 = ctx.transformedPoint(0,0);
|
||||
var p2 = ctx.transformedPoint(canvas.width,canvas.height);
|
||||
ctx.clearRect(p1.x,p1.y,p2.x-p1.x,p2.y-p1.y);
|
||||
drawGrid();
|
||||
// ctx.globalAlpha = 0.5;
|
||||
if(renderOptions['showNextLayer'] && layerNum < model.length - 1) {
|
||||
drawLayer(layerNum+1, 0, this.getLayerNumSegments(layerNum+1), true);
|
||||
}
|
||||
drawLayer(layerNum, fromProgress, toProgress);
|
||||
}else{
|
||||
console.log("Got request to render non-existent layer!!");
|
||||
}
|
||||
}
|
||||
},
|
||||
getModelNumLayers: function(){
|
||||
return model?model.length:1;
|
||||
},
|
||||
getLayerNumSegments: function(layer){
|
||||
if(model){
|
||||
return model[layer]?model[layer].length:1;
|
||||
}else{
|
||||
return 1;
|
||||
}
|
||||
},
|
||||
doRender: function(mdl, layerNum){
|
||||
var mdlInfo;
|
||||
model = mdl;
|
||||
prevX=0;
|
||||
prevY=0;
|
||||
if(!initialized)this.init();
|
||||
|
||||
mdlInfo = GCODE.gCodeReader.getModelInfo();
|
||||
speeds = mdlInfo.speeds;
|
||||
speedsByLayer = mdlInfo.speedsByLayer;
|
||||
// console.log(speeds);
|
||||
// console.log(mdlInfo.min.x + ' ' + mdlInfo.modelSize.x);
|
||||
offsetModelX = (gridSizeX/2-(mdlInfo.min.x+mdlInfo.modelSize.x/2))*zoomFactor;
|
||||
offsetModelY = (mdlInfo.min.y+mdlInfo.modelSize.y/2)*zoomFactor-gridSizeY/2*zoomFactor;
|
||||
if(ctx)ctx.translate(offsetModelX, offsetModelY);
|
||||
|
||||
this.render(layerNum, 0, model[layerNum].length);
|
||||
},
|
||||
getZ: function(layerNum){
|
||||
if(!model&&!model[layerNum]){
|
||||
return '-1';
|
||||
}
|
||||
var cmds = model[layerNum];
|
||||
for(var i=0;i<cmds.length;i++){
|
||||
if(cmds[i].prevZ!==undefined)return cmds[i].prevZ;
|
||||
}
|
||||
return '-1';
|
||||
}
|
||||
|
||||
}
|
||||
}());
|
||||
@@ -1,345 +0,0 @@
|
||||
/**
|
||||
* User: hudbrog (hudbrog@gmail.com)
|
||||
* Date: 10/21/12
|
||||
* Time: 7:45 AM
|
||||
*/
|
||||
|
||||
var GCODE = {};
|
||||
|
||||
GCODE.ui = (function(){
|
||||
var reader;
|
||||
var myCodeMirror;
|
||||
var sliderVer;
|
||||
var sliderHor;
|
||||
var gCodeLines = {first: 0, last: 0};
|
||||
var showGCode = false;
|
||||
|
||||
var setProgress = function(id, progress){
|
||||
$('#'+id).width(parseInt(progress)+'%');
|
||||
$('#'+id).text(parseInt(progress)+'%');
|
||||
|
||||
};
|
||||
|
||||
var chooseAccordion = function(id){
|
||||
// debugger;
|
||||
$('#'+id).collapse("show");
|
||||
};
|
||||
|
||||
var setLinesColor = function(toggle){
|
||||
// var i=0;
|
||||
// for(i=gCodeLines.first;i<gCodeLines.last; i++){
|
||||
// if(toggle){
|
||||
// myCodeMirror.setLineClass(Number(i), null, "activeline");
|
||||
// }else{
|
||||
// myCodeMirror.setLineClass(Number(i), null, null);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
var printLayerInfo = function(layerNum){
|
||||
var z = GCODE.renderer.getZ(layerNum);
|
||||
var segments = GCODE.renderer.getLayerNumSegments(layerNum);
|
||||
var filament = GCODE.gCodeReader.getLayerFilament(z);
|
||||
var layerSpeeds = GCODE.gCodeReader.getModelInfo().speedsByLayer;
|
||||
var renderOptions = GCODE.renderer.getOptions();
|
||||
var colors = renderOptions["colorLine"];
|
||||
var speedIndex = 0;
|
||||
var keys, type;
|
||||
var showMove=false;
|
||||
var i = 0;
|
||||
var output = [];
|
||||
output.push("Layer number: " + layerNum);
|
||||
output.push("Layer height (mm): " + z);
|
||||
output.push("GCODE commands in layer: " + segments);
|
||||
output.push("Filament used by layer (mm): " + filament.toFixed(2));
|
||||
output.push("Print time for layer: " + parseFloat(GCODE.gCodeReader.getModelInfo().printTimeByLayer[z]).toFixed(1) + "sec");
|
||||
output.push("Extrude speeds:");
|
||||
for(i=0;i<layerSpeeds['extrude'][z].length;i++){
|
||||
if(typeof(layerSpeeds['extrude'][z][i])==='undefined'){continue;}
|
||||
speedIndex = i;
|
||||
if(speedIndex > colors.length -1){speedIndex = speedIndex % (colors.length-1);}
|
||||
output.push("<div id='colorBox"+i+"' class='colorBox' style='background-color: "+colors[speedIndex] + "'></div> = " + (parseFloat(layerSpeeds['extrude'][z][i])/60).toFixed(2)+"mm/s");
|
||||
}
|
||||
if(typeof(layerSpeeds['move'][z]) !== 'undefined'){
|
||||
output.push("Move speeds:");
|
||||
for(i=0;i<layerSpeeds['move'][z].length;i++){
|
||||
if(typeof(layerSpeeds['move'][z][i])==='undefined'){continue;}
|
||||
speedIndex = i;
|
||||
if(speedIndex > colors.length -1){speedIndex = speedIndex % (colors.length-1);}
|
||||
output.push("<div id='colorBox"+i+"' class='colorBox' style='background-color: "+renderOptions['colorMove'] + "'></div> = " + (parseFloat(layerSpeeds['move'][z][i])/60).toFixed(2)+"mm/s");
|
||||
}
|
||||
}
|
||||
if(typeof(layerSpeeds['retract'][z]) !== 'undefined'){
|
||||
output.push("Retract speeds:");
|
||||
for(i=0;i<layerSpeeds['retract'][z].length;i++){
|
||||
if(typeof(layerSpeeds['retract'][z][i])==='undefined'){continue;}
|
||||
speedIndex = i;
|
||||
if(speedIndex > colors.length -1){speedIndex = speedIndex % (colors.length-1);}
|
||||
output.push("<span style='color: " + renderOptions['colorRetract'] +"'>●</span> <span style='color: " + renderOptions['colorRestart'] +"'>●</span> = " +(parseFloat(layerSpeeds['retract'][z][i])/60).toFixed(2)+"mm/s");
|
||||
}
|
||||
}
|
||||
|
||||
$('#layerInfo').html(output.join('<br>'));
|
||||
// chooseAccordion('layerAccordionTab');
|
||||
};
|
||||
|
||||
var handleFileSelect = function(evt) {
|
||||
// console.log("handleFileSelect");
|
||||
evt.stopPropagation();
|
||||
evt.preventDefault();
|
||||
|
||||
var files = evt.dataTransfer?evt.dataTransfer.files:evt.target.files; // FileList object.
|
||||
|
||||
var output = [];
|
||||
for (var i = 0, f; f = files[i]; i++) {
|
||||
if(f.name.toLowerCase().match(/^.*\.(?:gcode|g|txt)$/)){
|
||||
output.push('<li>File extensions suggests GCODE</li>');
|
||||
}else{
|
||||
output.push('<li><strong>You should only upload *.gcode files! I will not work with this one!</strong></li>');
|
||||
document.getElementById('errorList').innerHTML = '<ul>' + output.join('') + '</ul>';
|
||||
return;
|
||||
}
|
||||
|
||||
reader = new FileReader();
|
||||
reader.onload = function(theFile){
|
||||
chooseAccordion('progressAccordionTab');
|
||||
setProgress('loadProgress', 0);
|
||||
setProgress('analyzeProgress', 0);
|
||||
// myCodeMirror.setValue(theFile.target.result);
|
||||
GCODE.gCodeReader.loadFile(theFile);
|
||||
if(showGCode){
|
||||
myCodeMirror.setValue(theFile.target.result);
|
||||
}else{
|
||||
myCodeMirror.setValue("GCode view is disabled. You can enable it in 'GCode analyzer options' section.")
|
||||
}
|
||||
|
||||
};
|
||||
reader.readAsText(f);
|
||||
}
|
||||
};
|
||||
|
||||
var handleDragOver = function(evt) {
|
||||
evt.stopPropagation();
|
||||
evt.preventDefault();
|
||||
evt.target.dropEffect = 'copy'; // Explicitly show this is a copy.
|
||||
};
|
||||
|
||||
var initSliders = function(){
|
||||
var prevX=0;
|
||||
var prevY=0;
|
||||
var handle;
|
||||
sliderVer = $( "#slider-vertical" );
|
||||
sliderHor = $( "#slider-horizontal" );
|
||||
|
||||
var onLayerChange = function(val){
|
||||
var progress = GCODE.renderer.getLayerNumSegments(val)-1;
|
||||
GCODE.renderer.render(val,0, progress);
|
||||
sliderHor.slider({max: progress, values: [0,progress]});
|
||||
setLinesColor(false); //clear current selection
|
||||
gCodeLines = GCODE.gCodeReader.getGCodeLines(val, sliderHor.slider("values",0), sliderHor.slider("values",1));
|
||||
setLinesColor(true); // highlight lines
|
||||
printLayerInfo(val);
|
||||
};
|
||||
|
||||
sliderVer.slider({
|
||||
orientation: "vertical",
|
||||
range: "min",
|
||||
min: 0,
|
||||
max: GCODE.renderer.getModelNumLayers()-1,
|
||||
value: 0,
|
||||
slide: function( event, ui ) {
|
||||
onLayerChange(ui.value);
|
||||
}
|
||||
});
|
||||
|
||||
//this stops slider reacting to arrow keys, since we do it below manually
|
||||
$( "#slider-vertical .ui-slider-handle" ).unbind('keydown');
|
||||
|
||||
sliderHor.slider({
|
||||
orientation: "horizontal",
|
||||
range: "min",
|
||||
min: 0,
|
||||
max: GCODE.renderer.getLayerNumSegments(0)-1,
|
||||
values: [0,GCODE.renderer.getLayerNumSegments(0)-1],
|
||||
slide: function( event, ui ) {
|
||||
setLinesColor(false); //clear current selection
|
||||
gCodeLines = GCODE.gCodeReader.getGCodeLines(sliderVer.slider("value"),ui.values[0], ui.values[1]);
|
||||
setLinesColor(true); // highlight lines
|
||||
GCODE.renderer.render(sliderVer.slider("value"), ui.values[0], ui.values[1]);
|
||||
}
|
||||
});
|
||||
|
||||
window.onkeydown = function (event){
|
||||
if(event.keyCode === 38 || event.keyCode === 33){
|
||||
if(sliderVer.slider('value') < sliderVer.slider('option', 'max')){
|
||||
sliderVer.slider('value', sliderVer.slider('value')+1);
|
||||
onLayerChange(sliderVer.slider('value'));
|
||||
}
|
||||
}else if(event.keyCode === 40 || event.keyCode === 34){
|
||||
if(sliderVer.slider('value') > 0){
|
||||
sliderVer.slider('value', sliderVer.slider('value')-1);
|
||||
onLayerChange(sliderVer.slider('value'));
|
||||
}
|
||||
}
|
||||
event.stopPropagation()
|
||||
}
|
||||
};
|
||||
|
||||
var processMessage = function(e){
|
||||
var data = e.data;
|
||||
switch (data.cmd) {
|
||||
case 'returnModel':
|
||||
setProgress('loadProgress', 100);
|
||||
worker.postMessage({
|
||||
"cmd":"analyzeModel",
|
||||
"msg":{
|
||||
}
|
||||
}
|
||||
);
|
||||
break;
|
||||
case 'analyzeDone':
|
||||
var resultSet = [];
|
||||
|
||||
setProgress('analyzeProgress',100);
|
||||
GCODE.gCodeReader.processAnalyzeModelDone(data.msg);
|
||||
GCODE.gCodeReader.passDataToRenderer();
|
||||
initSliders();
|
||||
resultSet.push("Model size is: " + data.msg.modelSize.x.toFixed(2) + 'x' + data.msg.modelSize.y.toFixed(2) + 'x' + data.msg.modelSize.z.toFixed(2)+'mm<br>');
|
||||
resultSet.push("Total filament used: " + data.msg.totalFilament.toFixed(2) + "mm<br>");
|
||||
resultSet.push("Estimated print time: " + parseInt(parseFloat(data.msg.printTime)/60/60) + ":" + parseInt((parseFloat(data.msg.printTime)/60)%60) + ":" + parseInt(parseFloat(data.msg.printTime)%60) + "<br>");
|
||||
resultSet.push("Estimated layer height: " + data.msg.layerHeight.toFixed(2) + "mm<br>");
|
||||
resultSet.push("Layer count: " + data.msg.layerCnt.toFixed(0) + "printed, " + data.msg.layerTotal.toFixed(0) + 'visited<br>');
|
||||
document.getElementById('list').innerHTML = resultSet.join('');
|
||||
chooseAccordion('infoAccordionTab');
|
||||
$('#myTab a[href="#tab2d"]').tab('show');
|
||||
break;
|
||||
case 'returnLayer':
|
||||
GCODE.gCodeReader.processLayerFromWorker(data.msg);
|
||||
setProgress('loadProgress',data.msg.progress);
|
||||
break;
|
||||
case 'returnMultiLayer':
|
||||
GCODE.gCodeReader.processMultiLayerFromWorker(data.msg);
|
||||
setProgress('loadProgress',data.msg.progress);
|
||||
break;
|
||||
case "analyzeProgress":
|
||||
setProgress('analyzeProgress',data.msg.progress);
|
||||
break;
|
||||
default:
|
||||
console.log("default msg received" + data.cmd);
|
||||
}
|
||||
};
|
||||
|
||||
var checkCapabilities = function(){
|
||||
var warnings = [];
|
||||
var fatal = [];
|
||||
|
||||
Modernizr.addTest('filereader', function () {
|
||||
return !!(window.File && window.FileList && window.FileReader);
|
||||
});
|
||||
|
||||
if(!Modernizr.canvas)fatal.push("<li>Your browser doesn't seem to support HTML5 Canvas, this application won't work without it.</li>");
|
||||
//if(!Modernizr.filereader)fatal.push("<li>Your browser doesn't seem to support HTML5 File API, this application won't work without it.</li>");
|
||||
if(!Modernizr.webworkers)fatal.push("<li>Your browser doesn't seem to support HTML5 Web Workers, this application won't work without it.</li>");
|
||||
if(!Modernizr.svg)fatal.push("<li>Your browser doesn't seem to support HTML5 SVG, this application won't work without it.</li>");
|
||||
|
||||
if(fatal.length>0){
|
||||
document.getElementById('errorList').innerHTML = '<ul>' + fatal.join('') + '</ul>';
|
||||
console.log("Initialization failed: unsupported browser.")
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!Modernizr.webgl && GCODE.renderer3d){
|
||||
warnings.push("<li>Your browser doesn't seem to support HTML5 Web GL, 3d mode is not recommended, going to be SLOW!</li>");
|
||||
GCODE.renderer3d.setOption({rendererType: "canvas"});
|
||||
}
|
||||
if(!Modernizr.draganddrop)warnings.push("<li>Your browser doesn't seem to support HTML5 Drag'n'Drop, Drop area will not work.</li>");
|
||||
|
||||
if(warnings.length>0){
|
||||
document.getElementById('errorList').innerHTML = '<ul>' + wanings.join('') + '</ul>';
|
||||
console.log("Initialization succeeded with warnings.")
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
return {
|
||||
worker: undefined,
|
||||
initHandlers: function(){
|
||||
var capabilitiesResult = checkCapabilities();
|
||||
if(!capabilitiesResult){
|
||||
return;
|
||||
}
|
||||
|
||||
setProgress('loadProgress', 0);
|
||||
setProgress('analyzeProgress', 0);
|
||||
|
||||
worker = new Worker('static/gcodeviewer/js/Worker.js');
|
||||
|
||||
worker.addEventListener('message', processMessage, false);
|
||||
|
||||
GCODE.ui.processOptions();
|
||||
GCODE.renderer.render(0,0);
|
||||
|
||||
console.log("Application initialized");
|
||||
|
||||
},
|
||||
|
||||
ArrayIndexOf: function(a, fnc) {
|
||||
if (!fnc || typeof (fnc) != 'function') {
|
||||
return -1;
|
||||
}
|
||||
if (!a || !a.length || a.length < 1) return -1;
|
||||
for (var i = 0; i < a.length; i++) {
|
||||
if(!a[i]) continue;
|
||||
if (fnc(a[i])) return i;
|
||||
}
|
||||
return -1;
|
||||
},
|
||||
updateLayerInfo: function(layerNum){
|
||||
printLayerInfo(layerNum);
|
||||
},
|
||||
|
||||
processOptions: function(){
|
||||
if(document.getElementById('sortLayersCheckbox').checked)GCODE.gCodeReader.setOption({sortLayers: true});
|
||||
else GCODE.gCodeReader.setOption({sortLayers: false});
|
||||
|
||||
if(document.getElementById('purgeEmptyLayersCheckbox').checked)GCODE.gCodeReader.setOption({purgeEmptyLayers: true});
|
||||
else GCODE.gCodeReader.setOption({purgeEmptyLayers: false});
|
||||
|
||||
if(document.getElementById('showGCodeCheckbox').checked)showGCode = true;
|
||||
else showGCode = false;
|
||||
|
||||
|
||||
// if(document.getElementById('sortLayersCheckbox').checked) worker.postMessage({"cmd":"setOption", "msg":{sortLayers: true}});
|
||||
// else worker.postMessage({"cmd":"setOption", "msg":{sortLayers: false}});
|
||||
//
|
||||
// if(document.getElementById('purgeEmptyLayersCheckbox').checked)worker.postMessage({"cmd":"setOption", "msg":{purgeEmptyLayers: true}});
|
||||
// else worker.postMessage({"cmd":"setOption", "msg":{purgeEmptyLayers: false}});
|
||||
|
||||
// if(document.getElementById('analyzeModelCheckbox').checked)worker.postMessage({"cmd":"setOption", "msg":{analyzeModel: true}});
|
||||
// else worker.postMessage({"cmd":"setOption", "msg":{analyzeModel: false}});
|
||||
|
||||
|
||||
if(document.getElementById('moveModelCheckbox').checked)GCODE.renderer.setOption({moveModel: true});
|
||||
else GCODE.renderer.setOption({moveModel: false});
|
||||
|
||||
if(document.getElementById('showMovesCheckbox').checked)GCODE.renderer.setOption({showMoves: true});
|
||||
else GCODE.renderer.setOption({showMoves: false});
|
||||
|
||||
if(document.getElementById('showRetractsCheckbox').checked)GCODE.renderer.setOption({showRetracts: true});
|
||||
else GCODE.renderer.setOption({showRetracts: false});
|
||||
|
||||
if(document.getElementById('differentiateColorsCheckbox').checked)GCODE.renderer.setOption({differentiateColors: true});
|
||||
else GCODE.renderer.setOption({differentiateColors: false});
|
||||
|
||||
var widthMod = 2;
|
||||
if(Number($('#widthModifier').attr('value'))) {widthMod = Number($('#widthModifier').attr('value'));}
|
||||
if(document.getElementById('thickExtrusionCheckbox').checked)GCODE.renderer.setOption({extrusionWidth: widthMod});
|
||||
else GCODE.renderer.setOption({extrusionWidth: 1});
|
||||
|
||||
if(document.getElementById('showNextLayer').checked)GCODE.renderer.setOption({showNextLayer: true});
|
||||
else GCODE.renderer.setOption({showNextLayer: false});
|
||||
}
|
||||
}
|
||||
}());
|
||||
@@ -1,123 +0,0 @@
|
||||
function DataUpdater(loginStateViewModel, connectionViewModel, printerStateViewModel, temperatureViewModel, controlViewModel, terminalViewModel, gcodeFilesViewModel, timelapseViewModel, gcodeViewModel) {
|
||||
var self = this;
|
||||
|
||||
self.loginStateViewModel = loginStateViewModel;
|
||||
self.connectionViewModel = connectionViewModel;
|
||||
self.printerStateViewModel = printerStateViewModel;
|
||||
self.temperatureViewModel = temperatureViewModel;
|
||||
self.controlViewModel = controlViewModel;
|
||||
self.terminalViewModel = terminalViewModel;
|
||||
self.gcodeFilesViewModel = gcodeFilesViewModel;
|
||||
self.timelapseViewModel = timelapseViewModel;
|
||||
self.gcodeViewModel = gcodeViewModel;
|
||||
|
||||
self._socket = undefined;
|
||||
self._autoReconnecting = false;
|
||||
self._autoReconnectTrial = 0;
|
||||
self._autoReconnectTimeouts = [1, 1, 2, 3, 5, 8, 13, 20, 40, 100];
|
||||
|
||||
self.connect = function() {
|
||||
var options = {};
|
||||
if (SOCKJS_DEBUG) {
|
||||
options["debug"] = true;
|
||||
}
|
||||
|
||||
self._socket = new SockJS(SOCKJS_URI, undefined, options);
|
||||
self._socket.onopen = self._onconnect;
|
||||
self._socket.onclose = self._onclose;
|
||||
self._socket.onmessage = self._onmessage;
|
||||
}
|
||||
|
||||
self.reconnect = function() {
|
||||
delete self._socket;
|
||||
self.connect();
|
||||
}
|
||||
|
||||
self._onconnect = function() {
|
||||
self._autoReconnecting = false;
|
||||
self._autoReconnectTrial = 0;
|
||||
|
||||
if ($("#offline_overlay").is(":visible")) {
|
||||
$("#offline_overlay").hide();
|
||||
self.timelapseViewModel.requestData();
|
||||
$("#webcam_image").attr("src", CONFIG_WEBCAM_STREAM + "?" + new Date().getTime());
|
||||
self.loginStateViewModel.requestData();
|
||||
self.gcodeFilesViewModel.requestData();
|
||||
}
|
||||
}
|
||||
|
||||
self._onclose = function() {
|
||||
$("#offline_overlay_message").html(
|
||||
"The server appears to be offline, at least I'm not getting any response from it. I'll try to reconnect " +
|
||||
"automatically <strong>over the next couple of minutes</strong>, however you are welcome to try a manual reconnect " +
|
||||
"anytime using the button below."
|
||||
);
|
||||
if (!$("#offline_overlay").is(":visible"))
|
||||
$("#offline_overlay").show();
|
||||
|
||||
if (self._autoReconnectTrial < self._autoReconnectTimeouts.length) {
|
||||
var timeout = self._autoReconnectTimeouts[self._autoReconnectTrial];
|
||||
console.log("Reconnect trial #" + self._autoReconnectTrial + ", waiting " + timeout + "s");
|
||||
setTimeout(self.reconnect, timeout * 1000);
|
||||
self._autoReconnectTrial++;
|
||||
} else {
|
||||
self._onreconnectfailed();
|
||||
}
|
||||
}
|
||||
|
||||
self._onreconnectfailed = function() {
|
||||
$("#offline_overlay_message").html(
|
||||
"The server appears to be offline, at least I'm not getting any response from it. I <strong>could not reconnect automatically</strong>, " +
|
||||
"but you may try a manual reconnect using the button below."
|
||||
);
|
||||
}
|
||||
|
||||
self._onmessage = function(e) {
|
||||
for (var prop in e.data) {
|
||||
var payload = e.data[prop];
|
||||
|
||||
switch (prop) {
|
||||
case "history": {
|
||||
self.connectionViewModel.fromHistoryData(payload);
|
||||
self.printerStateViewModel.fromHistoryData(payload);
|
||||
self.temperatureViewModel.fromHistoryData(payload);
|
||||
self.controlViewModel.fromHistoryData(payload);
|
||||
self.terminalViewModel.fromHistoryData(payload);
|
||||
self.timelapseViewModel.fromHistoryData(payload);
|
||||
self.gcodeViewModel.fromHistoryData(payload);
|
||||
self.gcodeFilesViewModel.fromCurrentData(payload);
|
||||
break;
|
||||
}
|
||||
case "current": {
|
||||
self.connectionViewModel.fromCurrentData(payload);
|
||||
self.printerStateViewModel.fromCurrentData(payload);
|
||||
self.temperatureViewModel.fromCurrentData(payload);
|
||||
self.controlViewModel.fromCurrentData(payload);
|
||||
self.terminalViewModel.fromCurrentData(payload);
|
||||
self.timelapseViewModel.fromCurrentData(payload);
|
||||
self.gcodeViewModel.fromCurrentData(payload);
|
||||
self.gcodeFilesViewModel.fromCurrentData(payload);
|
||||
break;
|
||||
}
|
||||
case "updateTrigger": {
|
||||
if (payload == "gcodeFiles") {
|
||||
gcodeFilesViewModel.requestData();
|
||||
} else if (payload == "timelapseFiles") {
|
||||
timelapseViewModel.requestData();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "feedbackCommandOutput": {
|
||||
self.controlViewModel.fromFeedbackCommandData(payload);
|
||||
break;
|
||||
}
|
||||
case "timelapse": {
|
||||
self.printerStateViewModel.fromTimelapseData(payload);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.connect();
|
||||
}
|
||||
@@ -1,333 +0,0 @@
|
||||
$(function() {
|
||||
|
||||
//~~ Initialize view models
|
||||
var loginStateViewModel = new LoginStateViewModel();
|
||||
var usersViewModel = new UsersViewModel(loginStateViewModel);
|
||||
var settingsViewModel = new SettingsViewModel(loginStateViewModel, usersViewModel);
|
||||
var connectionViewModel = new ConnectionViewModel(loginStateViewModel, settingsViewModel);
|
||||
var timelapseViewModel = new TimelapseViewModel(loginStateViewModel);
|
||||
var printerStateViewModel = new PrinterStateViewModel(loginStateViewModel, timelapseViewModel);
|
||||
var appearanceViewModel = new AppearanceViewModel(settingsViewModel);
|
||||
var temperatureViewModel = new TemperatureViewModel(loginStateViewModel, settingsViewModel);
|
||||
var controlViewModel = new ControlViewModel(loginStateViewModel, settingsViewModel);
|
||||
var terminalViewModel = new TerminalViewModel(loginStateViewModel, settingsViewModel);
|
||||
var gcodeFilesViewModel = new GcodeFilesViewModel(printerStateViewModel, loginStateViewModel);
|
||||
var gcodeViewModel = new GcodeViewModel(loginStateViewModel);
|
||||
var navigationViewModel = new NavigationViewModel(loginStateViewModel, appearanceViewModel, settingsViewModel, usersViewModel);
|
||||
|
||||
var dataUpdater = new DataUpdater(
|
||||
loginStateViewModel,
|
||||
connectionViewModel,
|
||||
printerStateViewModel,
|
||||
temperatureViewModel,
|
||||
controlViewModel,
|
||||
terminalViewModel,
|
||||
gcodeFilesViewModel,
|
||||
timelapseViewModel,
|
||||
gcodeViewModel
|
||||
);
|
||||
|
||||
// work around a stupid iOS6 bug where ajax requests get cached and only work once, as described at
|
||||
// http://stackoverflow.com/questions/12506897/is-safari-on-ios-6-caching-ajax-results
|
||||
$.ajaxSetup({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" }
|
||||
});
|
||||
|
||||
//~~ Show settings - to ensure centered
|
||||
$('#navbar_show_settings').click(function() {
|
||||
$('#settings_dialog').modal()
|
||||
.css({
|
||||
width: 'auto',
|
||||
'margin-left': function() { return -($(this).width() /2); }
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
//~~ Temperature
|
||||
|
||||
$('#tabs a[data-toggle="tab"]').on('shown', function (e) {
|
||||
temperatureViewModel.updatePlot();
|
||||
terminalViewModel.updateOutput();
|
||||
});
|
||||
|
||||
//~~ Gcode upload
|
||||
|
||||
function gcode_upload_done(e, data) {
|
||||
gcodeFilesViewModel.fromResponse(data.result);
|
||||
$("#gcode_upload_progress .bar").css("width", "0%");
|
||||
$("#gcode_upload_progress").removeClass("progress-striped").removeClass("active");
|
||||
$("#gcode_upload_progress .bar").text("");
|
||||
}
|
||||
|
||||
function gcode_upload_fail(e, data) {
|
||||
$.pnotify({
|
||||
title: "Upload failed",
|
||||
text: "<p>Could not upload the file. Make sure it is a GCODE file and has one of the following extensions: .gcode, .gco</p><p>Server reported: <pre>" + data.jqXHR.responseText + "</pre></p>",
|
||||
type: "error",
|
||||
hide: false
|
||||
});
|
||||
$("#gcode_upload_progress .bar").css("width", "0%");
|
||||
$("#gcode_upload_progress").removeClass("progress-striped").removeClass("active");
|
||||
$("#gcode_upload_progress .bar").text("");
|
||||
}
|
||||
|
||||
function gcode_upload_progress(e, data) {
|
||||
var progress = parseInt(data.loaded / data.total * 100, 10);
|
||||
$("#gcode_upload_progress .bar").css("width", progress + "%");
|
||||
$("#gcode_upload_progress .bar").text("Uploading ...");
|
||||
if (progress >= 100) {
|
||||
$("#gcode_upload_progress").addClass("progress-striped").addClass("active");
|
||||
$("#gcode_upload_progress .bar").text("Saving ...");
|
||||
}
|
||||
}
|
||||
|
||||
function enable_local_dropzone() {
|
||||
$("#gcode_upload").fileupload({
|
||||
dataType: "json",
|
||||
dropZone: localTarget,
|
||||
formData: {target: "local"},
|
||||
done: gcode_upload_done,
|
||||
fail: gcode_upload_fail,
|
||||
progressall: gcode_upload_progress
|
||||
});
|
||||
}
|
||||
|
||||
function disable_local_dropzone() {
|
||||
$("#gcode_upload").fileupload({
|
||||
dataType: "json",
|
||||
dropZone: null,
|
||||
formData: {target: "local"},
|
||||
done: gcode_upload_done,
|
||||
fail: gcode_upload_fail,
|
||||
progressall: gcode_upload_progress
|
||||
});
|
||||
}
|
||||
|
||||
function enable_sd_dropzone() {
|
||||
$("#gcode_upload_sd").fileupload({
|
||||
dataType: "json",
|
||||
dropZone: $("#drop_sd"),
|
||||
formData: {target: "sd"},
|
||||
done: gcode_upload_done,
|
||||
fail: gcode_upload_fail,
|
||||
progressall: gcode_upload_progress
|
||||
});
|
||||
}
|
||||
|
||||
function disable_sd_dropzone() {
|
||||
$("#gcode_upload_sd").fileupload({
|
||||
dataType: "json",
|
||||
dropZone: null,
|
||||
formData: {target: "sd"},
|
||||
done: gcode_upload_done,
|
||||
fail: gcode_upload_fail,
|
||||
progressall: gcode_upload_progress
|
||||
});
|
||||
}
|
||||
|
||||
var localTarget;
|
||||
if (CONFIG_SD_SUPPORT) {
|
||||
localTarget = $("#drop_locally");
|
||||
} else {
|
||||
localTarget = $("#drop");
|
||||
}
|
||||
|
||||
loginStateViewModel.isUser.subscribe(function(newValue) {
|
||||
if (newValue === true) {
|
||||
enable_local_dropzone();
|
||||
} else {
|
||||
disable_local_dropzone();
|
||||
}
|
||||
});
|
||||
|
||||
if (loginStateViewModel.isUser()) {
|
||||
enable_local_dropzone();
|
||||
} else {
|
||||
disable_local_dropzone();
|
||||
}
|
||||
|
||||
if (CONFIG_SD_SUPPORT) {
|
||||
printerStateViewModel.isSdReady.subscribe(function(newValue) {
|
||||
if (newValue === true && loginStateViewModel.isUser()) {
|
||||
enable_sd_dropzone();
|
||||
} else {
|
||||
disable_sd_dropzone();
|
||||
}
|
||||
});
|
||||
|
||||
loginStateViewModel.isUser.subscribe(function(newValue) {
|
||||
if (newValue === true && printerStateViewModel.isSdReady()) {
|
||||
enable_sd_dropzone();
|
||||
} else {
|
||||
disable_sd_dropzone();
|
||||
}
|
||||
});
|
||||
|
||||
if (printerStateViewModel.isSdReady() && loginStateViewModel.isUser()) {
|
||||
enable_sd_dropzone();
|
||||
} else {
|
||||
disable_sd_dropzone();
|
||||
}
|
||||
}
|
||||
|
||||
$(document).bind("dragover", function (e) {
|
||||
var dropOverlay = $("#drop_overlay");
|
||||
var dropZone = $("#drop");
|
||||
var dropZoneLocal = $("#drop_locally");
|
||||
var dropZoneSd = $("#drop_sd");
|
||||
var dropZoneBackground = $("#drop_background");
|
||||
var dropZoneLocalBackground = $("#drop_locally_background");
|
||||
var dropZoneSdBackground = $("#drop_sd_background");
|
||||
var timeout = window.dropZoneTimeout;
|
||||
|
||||
if (!timeout) {
|
||||
dropOverlay.addClass('in');
|
||||
} else {
|
||||
clearTimeout(timeout);
|
||||
}
|
||||
|
||||
var foundLocal = false;
|
||||
var foundSd = false;
|
||||
var found = false
|
||||
var node = e.target;
|
||||
do {
|
||||
if (dropZoneLocal && node === dropZoneLocal[0]) {
|
||||
foundLocal = true;
|
||||
break;
|
||||
} else if (dropZoneSd && node === dropZoneSd[0]) {
|
||||
foundSd = true;
|
||||
break;
|
||||
} else if (dropZone && node === dropZone[0]) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
node = node.parentNode;
|
||||
} while (node != null);
|
||||
|
||||
if (foundLocal) {
|
||||
dropZoneLocalBackground.addClass("hover");
|
||||
dropZoneSdBackground.removeClass("hover");
|
||||
} else if (foundSd && printerStateViewModel.isSdReady()) {
|
||||
dropZoneSdBackground.addClass("hover");
|
||||
dropZoneLocalBackground.removeClass("hover");
|
||||
} else if (found) {
|
||||
dropZoneBackground.addClass("hover");
|
||||
} else {
|
||||
if (dropZoneLocalBackground) dropZoneLocalBackground.removeClass("hover");
|
||||
if (dropZoneSdBackground) dropZoneSdBackground.removeClass("hover");
|
||||
if (dropZoneBackground) dropZoneBackground.removeClass("hover");
|
||||
}
|
||||
|
||||
window.dropZoneTimeout = setTimeout(function () {
|
||||
window.dropZoneTimeout = null;
|
||||
dropOverlay.removeClass("in");
|
||||
if (dropZoneLocal) dropZoneLocalBackground.removeClass("hover");
|
||||
if (dropZoneSd) dropZoneSdBackground.removeClass("hover");
|
||||
if (dropZone) dropZoneBackground.removeClass("hover");
|
||||
}, 100);
|
||||
});
|
||||
|
||||
//~~ Offline overlay
|
||||
$("#offline_overlay_reconnect").click(function() {dataUpdater.reconnect()});
|
||||
|
||||
//~~ knockout.js bindings
|
||||
|
||||
ko.bindingHandlers.popover = {
|
||||
init: function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
|
||||
var val = ko.utils.unwrapObservable(valueAccessor());
|
||||
|
||||
var options = {
|
||||
title: val.title,
|
||||
animation: val.animation,
|
||||
placement: val.placement,
|
||||
trigger: val.trigger,
|
||||
delay: val.delay,
|
||||
content: val.content,
|
||||
html: val.html
|
||||
};
|
||||
$(element).popover(options);
|
||||
}
|
||||
}
|
||||
|
||||
ko.applyBindings(connectionViewModel, document.getElementById("connection_accordion"));
|
||||
ko.applyBindings(printerStateViewModel, document.getElementById("state_accordion"));
|
||||
ko.applyBindings(gcodeFilesViewModel, document.getElementById("files_accordion"));
|
||||
ko.applyBindings(temperatureViewModel, document.getElementById("temp"));
|
||||
ko.applyBindings(controlViewModel, document.getElementById("control"));
|
||||
ko.applyBindings(terminalViewModel, document.getElementById("term"));
|
||||
var gcode = document.getElementById("gcode");
|
||||
if (gcode) {
|
||||
ko.applyBindings(gcodeViewModel, gcode);
|
||||
}
|
||||
ko.applyBindings(settingsViewModel, document.getElementById("settings_dialog"));
|
||||
ko.applyBindings(navigationViewModel, document.getElementById("navbar"));
|
||||
ko.applyBindings(appearanceViewModel, document.getElementsByTagName("head")[0]);
|
||||
ko.applyBindings(printerStateViewModel, document.getElementById("drop_overlay"));
|
||||
|
||||
var timelapseElement = document.getElementById("timelapse");
|
||||
if (timelapseElement) {
|
||||
ko.applyBindings(timelapseViewModel, timelapseElement);
|
||||
}
|
||||
var gCodeVisualizerElement = document.getElementById("gcode");
|
||||
if (gCodeVisualizerElement) {
|
||||
gcodeViewModel.initialize();
|
||||
}
|
||||
|
||||
//~~ startup commands
|
||||
|
||||
loginStateViewModel.requestData();
|
||||
connectionViewModel.requestData();
|
||||
controlViewModel.requestData();
|
||||
gcodeFilesViewModel.requestData();
|
||||
timelapseViewModel.requestData();
|
||||
|
||||
loginStateViewModel.subscribe(function(change, data) {
|
||||
if ("login" == change) {
|
||||
$("#gcode_upload").fileupload("enable");
|
||||
|
||||
settingsViewModel.requestData();
|
||||
if (data.admin) {
|
||||
usersViewModel.requestData();
|
||||
}
|
||||
} else {
|
||||
$("#gcode_upload").fileupload("disable");
|
||||
}
|
||||
});
|
||||
|
||||
//~~ UI stuff
|
||||
|
||||
$(".accordion-toggle[href='#files']").click(function() {
|
||||
if ($("#files").hasClass("in")) {
|
||||
$("#files").removeClass("overflow_visible");
|
||||
} else {
|
||||
setTimeout(function() {
|
||||
$("#files").addClass("overflow_visible");
|
||||
}, 1000);
|
||||
}
|
||||
})
|
||||
|
||||
$.pnotify.defaults.history = false;
|
||||
|
||||
$.fn.modal.defaults.maxHeight = function(){
|
||||
// subtract the height of the modal header and footer
|
||||
return $(window).height() - 165;
|
||||
}
|
||||
|
||||
// Fix input element click problem on login dialog
|
||||
$(".dropdown input, .dropdown label").click(function(e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
$(document).bind("drop dragover", function (e) {
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
if (CONFIG_FIRST_RUN) {
|
||||
var firstRunViewModel = new FirstRunViewModel();
|
||||
ko.applyBindings(firstRunViewModel, document.getElementById("first_run_dialog"));
|
||||
firstRunViewModel.showDialog();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
function AppearanceViewModel(settingsViewModel) {
|
||||
var self = this;
|
||||
|
||||
self.name = settingsViewModel.appearance_name;
|
||||
self.color = settingsViewModel.appearance_color;
|
||||
|
||||
self.brand = ko.computed(function() {
|
||||
if (self.name())
|
||||
return "OctoPrint: " + self.name();
|
||||
else
|
||||
return "OctoPrint";
|
||||
})
|
||||
|
||||
self.title = ko.computed(function() {
|
||||
if (self.name())
|
||||
return self.name() + " [OctoPrint]";
|
||||
else
|
||||
return "OctoPrint";
|
||||
})
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
function GcodeViewModel(loginStateViewModel) {
|
||||
var self = this;
|
||||
|
||||
self.loginState = loginStateViewModel;
|
||||
|
||||
self.loadedFilename = undefined;
|
||||
self.loadedFileMTime = undefined;
|
||||
self.status = 'idle';
|
||||
self.enabled = false;
|
||||
|
||||
self.errorCount = 0;
|
||||
|
||||
self.initialize = function(){
|
||||
self.enabled = true;
|
||||
GCODE.ui.initHandlers();
|
||||
}
|
||||
|
||||
self.loadFile = function(filename, mtime){
|
||||
if (self.status == 'idle' && self.errorCount < 3) {
|
||||
self.status = 'request';
|
||||
$.ajax({
|
||||
url: "/downloads/gcode/" + filename,
|
||||
data: { "mtime": mtime },
|
||||
type: "GET",
|
||||
success: function(response, rstatus) {
|
||||
if(rstatus === 'success'){
|
||||
self.showGCodeViewer(response, rstatus);
|
||||
self.loadedFilename=filename;
|
||||
self.loadedFileMTime=mtime;
|
||||
self.status = 'idle';
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
self.status = 'idle';
|
||||
self.errorCount++;
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
self.showGCodeViewer = function(response, rstatus) {
|
||||
var par = {};
|
||||
par.target = {};
|
||||
par.target.result = response;
|
||||
GCODE.gCodeReader.loadFile(par);
|
||||
}
|
||||
|
||||
self.fromHistoryData = function(data) {
|
||||
self._processData(data);
|
||||
}
|
||||
|
||||
self.fromCurrentData = function(data) {
|
||||
self._processData(data);
|
||||
}
|
||||
|
||||
self._processData = function(data) {
|
||||
if (!self.enabled) return;
|
||||
if (!data.job.filename) return;
|
||||
|
||||
if(self.loadedFilename && self.loadedFilename == data.job.filename &&
|
||||
self.loadedFileMTime == data.job.mtime) {
|
||||
if (data.state.flags && (data.state.flags.printing || data.state.flags.paused)) {
|
||||
var cmdIndex = GCODE.gCodeReader.getCmdIndexForPercentage(data.progress.progress * 100);
|
||||
if(cmdIndex){
|
||||
GCODE.renderer.render(cmdIndex.layer, 0, cmdIndex.cmd);
|
||||
GCODE.ui.updateLayerInfo(cmdIndex.layer);
|
||||
}
|
||||
}
|
||||
self.errorCount = 0
|
||||
} else if (data.job.filename) {
|
||||
self.loadFile(data.job.filename, data.job.mtime);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,202 +0,0 @@
|
||||
function GcodeFilesViewModel(printerStateViewModel, loginStateViewModel) {
|
||||
var self = this;
|
||||
|
||||
self.printerState = printerStateViewModel;
|
||||
self.loginState = loginStateViewModel;
|
||||
|
||||
self.isErrorOrClosed = ko.observable(undefined);
|
||||
self.isOperational = ko.observable(undefined);
|
||||
self.isPrinting = ko.observable(undefined);
|
||||
self.isPaused = ko.observable(undefined);
|
||||
self.isError = ko.observable(undefined);
|
||||
self.isReady = ko.observable(undefined);
|
||||
self.isLoading = ko.observable(undefined);
|
||||
self.isSdReady = ko.observable(undefined);
|
||||
|
||||
self.freeSpace = ko.observable(undefined);
|
||||
|
||||
// initialize list helper
|
||||
self.listHelper = new ItemListHelper(
|
||||
"gcodeFiles",
|
||||
{
|
||||
"name": function(a, b) {
|
||||
// sorts ascending
|
||||
if (a["name"].toLocaleLowerCase() < b["name"].toLocaleLowerCase()) return -1;
|
||||
if (a["name"].toLocaleLowerCase() > b["name"].toLocaleLowerCase()) return 1;
|
||||
return 0;
|
||||
},
|
||||
"upload": function(a, b) {
|
||||
// sorts descending
|
||||
if (b["date"] === undefined || a["date"] > b["date"]) return -1;
|
||||
if (a["date"] < b["date"]) return 1;
|
||||
return 0;
|
||||
},
|
||||
"size": function(a, b) {
|
||||
// sorts descending
|
||||
if (b["bytes"] === undefined || a["bytes"] > b["bytes"]) return -1;
|
||||
if (a["bytes"] < b["bytes"]) return 1;
|
||||
return 0;
|
||||
}
|
||||
},
|
||||
{
|
||||
"printed": function(file) {
|
||||
return !(file["prints"] && file["prints"]["success"] && file["prints"]["success"] > 0);
|
||||
},
|
||||
"sd": function(file) {
|
||||
return file["origin"] && file["origin"] == "sd";
|
||||
},
|
||||
"local": function(file) {
|
||||
return !(file["origin"] && file["origin"] == "sd");
|
||||
}
|
||||
},
|
||||
"name",
|
||||
[],
|
||||
[["sd", "local"]],
|
||||
CONFIG_GCODEFILESPERPAGE
|
||||
);
|
||||
|
||||
self.isLoadActionPossible = ko.computed(function() {
|
||||
return self.loginState.isUser() && !self.isPrinting() && !self.isPaused() && !self.isLoading();
|
||||
});
|
||||
|
||||
self.isLoadAndPrintActionPossible = ko.computed(function() {
|
||||
return self.loginState.isUser() && self.isOperational() && self.isLoadActionPossible();
|
||||
});
|
||||
|
||||
self.printerState.filename.subscribe(function(newValue) {
|
||||
self.highlightFilename(newValue);
|
||||
});
|
||||
|
||||
self.highlightFilename = function(filename) {
|
||||
if (filename == undefined) {
|
||||
self.listHelper.selectNone();
|
||||
} else {
|
||||
self.listHelper.selectItem(function(item) {
|
||||
return item.name == filename;
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
self.fromCurrentData = function(data) {
|
||||
self._processStateData(data.state);
|
||||
}
|
||||
|
||||
self.fromHistoryData = function(data) {
|
||||
self._processStateData(data.state);
|
||||
}
|
||||
|
||||
self._processStateData = function(data) {
|
||||
self.isErrorOrClosed(data.flags.closedOrError);
|
||||
self.isOperational(data.flags.operational);
|
||||
self.isPaused(data.flags.paused);
|
||||
self.isPrinting(data.flags.printing);
|
||||
self.isError(data.flags.error);
|
||||
self.isReady(data.flags.ready);
|
||||
self.isLoading(data.flags.loading);
|
||||
self.isSdReady(data.flags.sdReady);
|
||||
}
|
||||
|
||||
self.requestData = function() {
|
||||
$.ajax({
|
||||
url: AJAX_BASEURL + "gcodefiles",
|
||||
method: "GET",
|
||||
dataType: "json",
|
||||
success: function(response) {
|
||||
self.fromResponse(response);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
self.fromResponse = function(response) {
|
||||
self.listHelper.updateItems(response.files);
|
||||
|
||||
if (response.filename) {
|
||||
// got a file to scroll to
|
||||
self.listHelper.switchToItem(function(item) {return item.name == response.filename});
|
||||
}
|
||||
|
||||
self.freeSpace(response.free);
|
||||
|
||||
self.highlightFilename(self.printerState.filename());
|
||||
}
|
||||
|
||||
self.loadFile = function(filename, printAfterLoad) {
|
||||
var file = self.listHelper.getItem(function(item) {return item.name == filename});
|
||||
if (!file) return;
|
||||
|
||||
$.ajax({
|
||||
url: AJAX_BASEURL + "gcodefiles/load",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: {filename: filename, print: printAfterLoad, target: file.origin}
|
||||
})
|
||||
}
|
||||
|
||||
self.removeFile = function(filename) {
|
||||
var file = self.listHelper.getItem(function(item) {return item.name == filename});
|
||||
if (!file) return;
|
||||
|
||||
$.ajax({
|
||||
url: AJAX_BASEURL + "gcodefiles/delete",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: {filename: filename, target: file.origin},
|
||||
success: self.fromResponse
|
||||
})
|
||||
}
|
||||
|
||||
self.initSdCard = function() {
|
||||
self._sendSdCommand("init");
|
||||
}
|
||||
|
||||
self.releaseSdCard = function() {
|
||||
self._sendSdCommand("release");
|
||||
}
|
||||
|
||||
self.refreshSdFiles = function() {
|
||||
self._sendSdCommand("refresh");
|
||||
}
|
||||
|
||||
self._sendSdCommand = function(command) {
|
||||
$.ajax({
|
||||
url: AJAX_BASEURL + "control/sd",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: {command: command}
|
||||
});
|
||||
}
|
||||
|
||||
self.getPopoverContent = function(data) {
|
||||
var output = "<p><strong>Uploaded:</strong> " + data["date"] + "</p>";
|
||||
if (data["gcodeAnalysis"]) {
|
||||
output += "<p>";
|
||||
output += "<strong>Filament:</strong> " + data["gcodeAnalysis"]["filament"] + "<br>";
|
||||
output += "<strong>Estimated Print Time:</strong> " + data["gcodeAnalysis"]["estimatedPrintTime"];
|
||||
output += "</p>";
|
||||
}
|
||||
if (data["prints"] && data["prints"]["last"]) {
|
||||
output += "<p>";
|
||||
output += "<strong>Last Print:</strong> <span class=\"" + (data["prints"]["last"]["success"] ? "text-success" : "text-error") + "\">" + data["prints"]["last"]["date"] + "</span>";
|
||||
output += "</p>";
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
self.getSuccessClass = function(data) {
|
||||
if (!data["prints"] || !data["prints"]["last"]) {
|
||||
return "";
|
||||
}
|
||||
return data["prints"]["last"]["success"] ? "text-success" : "text-error";
|
||||
}
|
||||
|
||||
self.enableRemove = function(data) {
|
||||
return self.loginState.isUser() && !(self.listHelper.isSelected(data) && (self.isPrinting() || self.isPaused()));
|
||||
}
|
||||
|
||||
self.enableSelect = function(data, printAfterSelect) {
|
||||
var isLoadActionPossible = self.loginState.isUser() && self.isOperational() && !(self.isPrinting() || self.isPaused() || self.isLoading());
|
||||
return isLoadActionPossible && !self.listHelper.isSelected(data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
function NavigationViewModel(loginStateViewModel, appearanceViewModel, settingsViewModel, usersViewModel) {
|
||||
var self = this;
|
||||
|
||||
self.loginState = loginStateViewModel;
|
||||
self.appearance = appearanceViewModel;
|
||||
self.systemActions = settingsViewModel.system_actions;
|
||||
self.users = usersViewModel;
|
||||
|
||||
self.triggerAction = function(action) {
|
||||
var callback = function() {
|
||||
$.ajax({
|
||||
url: AJAX_BASEURL + "system",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: "action=" + action.action,
|
||||
success: function() {
|
||||
$.pnotify({title: "Success", text: "The command \""+ action.name +"\" executed successfully", type: "success"});
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
$.pnotify({title: "Error", text: "<p>The command \"" + action.name + "\" could not be executed.</p><p>Reason: <pre>" + jqXHR.responseText + "</pre></p>", type: "error"});
|
||||
}
|
||||
})
|
||||
}
|
||||
if (action.confirm) {
|
||||
$("#confirmation_dialog .confirmation_dialog_message").text(action.confirm);
|
||||
$("#confirmation_dialog .confirmation_dialog_acknowledge").unbind("click");
|
||||
$("#confirmation_dialog .confirmation_dialog_acknowledge").bind("click", function(e) {
|
||||
e.preventDefault();
|
||||
$("#confirmation_dialog").modal("hide");
|
||||
callback();
|
||||
});
|
||||
$("#confirmation_dialog").modal("show");
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,153 +0,0 @@
|
||||
function PrinterStateViewModel(loginStateViewModel) {
|
||||
var self = this;
|
||||
|
||||
self.loginState = loginStateViewModel;
|
||||
|
||||
self.stateString = ko.observable(undefined);
|
||||
self.isErrorOrClosed = ko.observable(undefined);
|
||||
self.isOperational = ko.observable(undefined);
|
||||
self.isPrinting = ko.observable(undefined);
|
||||
self.isPaused = ko.observable(undefined);
|
||||
self.isError = ko.observable(undefined);
|
||||
self.isReady = ko.observable(undefined);
|
||||
self.isLoading = ko.observable(undefined);
|
||||
self.isSdReady = ko.observable(undefined);
|
||||
|
||||
self.filename = ko.observable(undefined);
|
||||
self.progress = ko.observable(undefined);
|
||||
self.filesize = ko.observable(undefined);
|
||||
self.filepos = ko.observable(undefined);
|
||||
self.printTime = ko.observable(undefined);
|
||||
self.printTimeLeft = ko.observable(undefined);
|
||||
self.sd = ko.observable(undefined);
|
||||
self.timelapse = ko.observable(undefined);
|
||||
|
||||
self.filament = ko.observable(undefined);
|
||||
self.estimatedPrintTime = ko.observable(undefined);
|
||||
|
||||
self.currentHeight = ko.observable(undefined);
|
||||
|
||||
self.byteString = ko.computed(function() {
|
||||
if (!self.filesize())
|
||||
return "-";
|
||||
var filepos = self.filepos() ? self.filepos() : "-";
|
||||
return filepos + " / " + self.filesize();
|
||||
});
|
||||
self.heightString = ko.computed(function() {
|
||||
if (!self.currentHeight())
|
||||
return "-";
|
||||
return self.currentHeight();
|
||||
})
|
||||
self.progressString = ko.computed(function() {
|
||||
if (!self.progress())
|
||||
return 0;
|
||||
return self.progress();
|
||||
});
|
||||
self.pauseString = ko.computed(function() {
|
||||
if (self.isPaused())
|
||||
return "Continue";
|
||||
else
|
||||
return "Pause";
|
||||
});
|
||||
|
||||
self.timelapseString = ko.computed(function() {
|
||||
var timelapse = self.timelapse();
|
||||
|
||||
if (!timelapse || !timelapse.hasOwnProperty("type"))
|
||||
return "-";
|
||||
|
||||
var type = timelapse["type"];
|
||||
if (type == "zchange") {
|
||||
return "On Z Change";
|
||||
} else if (type == "timed") {
|
||||
return "Timed (" + timelapse["options"]["interval"] + "s)";
|
||||
} else {
|
||||
return "-";
|
||||
}
|
||||
});
|
||||
|
||||
self.fromCurrentData = function(data) {
|
||||
self._fromData(data);
|
||||
}
|
||||
|
||||
self.fromHistoryData = function(data) {
|
||||
self._fromData(data);
|
||||
}
|
||||
|
||||
self.fromTimelapseData = function(data) {
|
||||
self.timelapse(data);
|
||||
}
|
||||
|
||||
self._fromData = function(data) {
|
||||
self._processStateData(data.state)
|
||||
self._processJobData(data.job);
|
||||
self._processProgressData(data.progress);
|
||||
self._processZData(data.currentZ);
|
||||
}
|
||||
|
||||
self._processStateData = function(data) {
|
||||
self.stateString(data.stateString);
|
||||
self.isErrorOrClosed(data.flags.closedOrError);
|
||||
self.isOperational(data.flags.operational);
|
||||
self.isPaused(data.flags.paused);
|
||||
self.isPrinting(data.flags.printing);
|
||||
self.isError(data.flags.error);
|
||||
self.isReady(data.flags.ready);
|
||||
self.isSdReady(data.flags.sdReady);
|
||||
}
|
||||
|
||||
self._processJobData = function(data) {
|
||||
self.filename(data.filename);
|
||||
self.filesize(data.filesize);
|
||||
self.estimatedPrintTime(data.estimatedPrintTime);
|
||||
self.filament(data.filament);
|
||||
self.sd(data.sd);
|
||||
}
|
||||
|
||||
self._processProgressData = function(data) {
|
||||
if (data.progress) {
|
||||
self.progress(Math.round(data.progress * 100));
|
||||
} else {
|
||||
self.progress(undefined);
|
||||
}
|
||||
self.filepos(data.filepos);
|
||||
self.printTime(data.printTime);
|
||||
self.printTimeLeft(data.printTimeLeft);
|
||||
}
|
||||
|
||||
self._processZData = function(data) {
|
||||
self.currentHeight(data);
|
||||
}
|
||||
|
||||
self.print = function() {
|
||||
var printAction = function() {
|
||||
self._jobCommand("start");
|
||||
}
|
||||
|
||||
if (self.isPaused()) {
|
||||
$("#confirmation_dialog .confirmation_dialog_message").text("This will restart the print job from the beginning.");
|
||||
$("#confirmation_dialog .confirmation_dialog_acknowledge").click(function(e) {e.preventDefault(); $("#confirmation_dialog").modal("hide"); printAction(); });
|
||||
$("#confirmation_dialog").modal("show");
|
||||
} else {
|
||||
printAction();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
self.pause = function() {
|
||||
self._jobCommand("pause");
|
||||
}
|
||||
|
||||
self.cancel = function() {
|
||||
self._jobCommand("cancel");
|
||||
}
|
||||
|
||||
self._jobCommand = function(command) {
|
||||
$.ajax({
|
||||
url: AJAX_BASEURL + "control/job",
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: {command: command}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,222 +0,0 @@
|
||||
function TemperatureViewModel(loginStateViewModel, settingsViewModel) {
|
||||
var self = this;
|
||||
|
||||
self.loginState = loginStateViewModel;
|
||||
|
||||
self.temp = ko.observable(undefined);
|
||||
self.bedTemp = ko.observable(undefined);
|
||||
self.targetTemp = ko.observable(undefined);
|
||||
self.bedTargetTemp = ko.observable(undefined);
|
||||
|
||||
self.newTemp = ko.observable(undefined);
|
||||
self.newBedTemp = ko.observable(undefined);
|
||||
|
||||
self.newTempOffset = ko.observable(undefined);
|
||||
self.tempOffset = ko.observable(0);
|
||||
self.newBedTempOffset = ko.observable(undefined);
|
||||
self.bedTempOffset = ko.observable(0);
|
||||
|
||||
self.isErrorOrClosed = ko.observable(undefined);
|
||||
self.isOperational = ko.observable(undefined);
|
||||
self.isPrinting = ko.observable(undefined);
|
||||
self.isPaused = ko.observable(undefined);
|
||||
self.isError = ko.observable(undefined);
|
||||
self.isReady = ko.observable(undefined);
|
||||
self.isLoading = ko.observable(undefined);
|
||||
|
||||
self.temperature_profiles = settingsViewModel.temperature_profiles;
|
||||
|
||||
self.tempString = ko.computed(function() {
|
||||
if (!self.temp())
|
||||
return "-";
|
||||
return self.temp() + " °C";
|
||||
});
|
||||
self.bedTempString = ko.computed(function() {
|
||||
if (!self.bedTemp())
|
||||
return "-";
|
||||
return self.bedTemp() + " °C";
|
||||
});
|
||||
self.targetTempString = ko.computed(function() {
|
||||
if (!self.targetTemp())
|
||||
return "-";
|
||||
return self.targetTemp() + " °C";
|
||||
});
|
||||
self.bedTargetTempString = ko.computed(function() {
|
||||
if (!self.bedTargetTemp())
|
||||
return "-";
|
||||
return self.bedTargetTemp() + " °C";
|
||||
});
|
||||
|
||||
self.temperatures = [];
|
||||
self.plotOptions = {
|
||||
yaxis: {
|
||||
min: 0,
|
||||
max: 310,
|
||||
ticks: 10
|
||||
},
|
||||
xaxis: {
|
||||
mode: "time",
|
||||
minTickSize: [2, "minute"],
|
||||
tickFormatter: function(val, axis) {
|
||||
if (val == undefined || val == 0)
|
||||
return ""; // we don't want to display the minutes since the epoch if not connected yet ;)
|
||||
|
||||
// current time in milliseconds in UTC
|
||||
var timestampUtc = Date.now();
|
||||
|
||||
// calculate difference in milliseconds
|
||||
var diff = timestampUtc - val;
|
||||
|
||||
// convert to minutes
|
||||
var diffInMins = Math.round(diff / (60 * 1000));
|
||||
if (diffInMins == 0)
|
||||
return "just now";
|
||||
else
|
||||
return "- " + diffInMins + " min";
|
||||
}
|
||||
},
|
||||
legend: {
|
||||
noColumns: 4
|
||||
}
|
||||
}
|
||||
|
||||
self.fromCurrentData = function(data) {
|
||||
self._processStateData(data.state);
|
||||
self._processTemperatureUpdateData(data.temperatures);
|
||||
self._processOffsetData(data.offsets);
|
||||
}
|
||||
|
||||
self.fromHistoryData = function(data) {
|
||||
self._processStateData(data.state);
|
||||
self._processTemperatureHistoryData(data.temperatureHistory);
|
||||
self._processOffsetData(data.offsets);
|
||||
}
|
||||
|
||||
self._processStateData = function(data) {
|
||||
self.isErrorOrClosed(data.flags.closedOrError);
|
||||
self.isOperational(data.flags.operational);
|
||||
self.isPaused(data.flags.paused);
|
||||
self.isPrinting(data.flags.printing);
|
||||
self.isError(data.flags.error);
|
||||
self.isReady(data.flags.ready);
|
||||
self.isLoading(data.flags.loading);
|
||||
}
|
||||
|
||||
self._processTemperatureUpdateData = function(data) {
|
||||
if (data.length == 0)
|
||||
return;
|
||||
|
||||
self.temp(data[data.length - 1].temp);
|
||||
self.bedTemp(data[data.length - 1].bedTemp);
|
||||
self.targetTemp(data[data.length - 1].targetTemp);
|
||||
self.bedTargetTemp(data[data.length - 1].targetBedTemp);
|
||||
|
||||
if (!CONFIG_TEMPERATURE_GRAPH) return;
|
||||
|
||||
if (!self.temperatures)
|
||||
self.temperatures = [];
|
||||
if (!self.temperatures.actual)
|
||||
self.temperatures.actual = [];
|
||||
if (!self.temperatures.target)
|
||||
self.temperatures.target = [];
|
||||
if (!self.temperatures.actualBed)
|
||||
self.temperatures.actualBed = [];
|
||||
if (!self.temperatures.targetBed)
|
||||
self.temperatures.targetBed = [];
|
||||
|
||||
_.each(data, function(d) {
|
||||
var time = d.currentTime;
|
||||
self.temperatures.actual.push([time, d.temp]);
|
||||
self.temperatures.target.push([time, d.targetTemp]);
|
||||
self.temperatures.actualBed.push([time, d.bedTemp]);
|
||||
self.temperatures.targetBed.push([time, d.targetBedTemp]);
|
||||
});
|
||||
|
||||
self.temperatures.actual = self.temperatures.actual.slice(-300);
|
||||
self.temperatures.target = self.temperatures.target.slice(-300);
|
||||
self.temperatures.actualBed = self.temperatures.actualBed.slice(-300);
|
||||
self.temperatures.targetBed = self.temperatures.targetBed.slice(-300);
|
||||
|
||||
self.updatePlot();
|
||||
}
|
||||
|
||||
self._processTemperatureHistoryData = function(data) {
|
||||
self.temperatures = data;
|
||||
self.updatePlot();
|
||||
}
|
||||
|
||||
self._processOffsetData = function(data) {
|
||||
self.tempOffset(data[0]);
|
||||
self.bedTempOffset(data[1]);
|
||||
}
|
||||
|
||||
self.updatePlot = function() {
|
||||
var graph = $("#temperature-graph");
|
||||
if (graph.length) {
|
||||
var data = [
|
||||
{label: "Actual", color: "#FF4040", data: self.temperatures.actual},
|
||||
{label: "Target", color: "#FFA0A0", data: self.temperatures.target},
|
||||
{label: "Bed Actual", color: "#4040FF", data: self.temperatures.actualBed},
|
||||
{label: "Bed Target", color: "#A0A0FF", data: self.temperatures.targetBed}
|
||||
]
|
||||
|
||||
$.plot(graph, data, self.plotOptions);
|
||||
}
|
||||
}
|
||||
|
||||
self.setTempFromProfile = function(profile) {
|
||||
if (!profile)
|
||||
return;
|
||||
self._updateTemperature(profile.extruder, "temp");
|
||||
}
|
||||
|
||||
self.setTemp = function() {
|
||||
self._updateTemperature(self.newTemp(), "temp", function(){self.targetTemp(self.newTemp()); self.newTemp("");});
|
||||
};
|
||||
|
||||
self.setTempToZero = function() {
|
||||
self._updateTemperature(0, "temp", function(){self.targetTemp(0); self.newTemp("");});
|
||||
}
|
||||
|
||||
self.setTempOffset = function() {
|
||||
self._updateTemperature(self.newTempOffset(), "tempOffset", function() {self.tempOffset(self.newTempOffset()); self.newTempOffset("");});
|
||||
}
|
||||
|
||||
self.setBedTempFromProfile = function(profile) {
|
||||
self._updateTemperature(profile.bed, "bedTemp");
|
||||
}
|
||||
|
||||
self.setBedTemp = function() {
|
||||
self._updateTemperature(self.newBedTemp(), "bedTemp", function() {self.bedTargetTemp(self.newBedTemp()); self.newBedTemp("");});
|
||||
};
|
||||
|
||||
self.setBedTempToZero = function() {
|
||||
self._updateTemperature(0, "bedTemp", function() {self.bedTargetTemp(0); self.newBedTemp("");});
|
||||
}
|
||||
|
||||
self.setBedTempOffset = function() {
|
||||
self._updateTemperature(self.newBedTempOffset(), "bedTempOffset", function() {self.bedTempOffset(self.newBedTempOffset()); self.newBedTempOffset("");});
|
||||
}
|
||||
|
||||
self._updateTemperature = function(temp, type, callback) {
|
||||
var data = {};
|
||||
data[type] = temp;
|
||||
|
||||
$.ajax({
|
||||
url: AJAX_BASEURL + "control/temperature",
|
||||
type: "POST",
|
||||
data: data,
|
||||
success: function() { if (callback !== undefined) callback(); }
|
||||
});
|
||||
}
|
||||
|
||||
self.handleEnter = function(event, type) {
|
||||
if (event.keyCode == 13) {
|
||||
if (type == "temp") {
|
||||
self.setTemp();
|
||||
} else if (type == "bedTemp") {
|
||||
self.setBedTemp();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* jQuery Pines Notify (pnotify) Plugin 1.2.0
|
||||
*
|
||||
* http://pinesframework.org/pnotify/
|
||||
* Copyright (c) 2009-2012 Hunter Perrin
|
||||
*
|
||||
* Triple license under the GPL, LGPL, and MPL:
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* http://www.mozilla.org/MPL/MPL-1.1.html
|
||||
*/
|
||||
(function(d){var q,j,r,i=d(window),u={jqueryui:{container:"ui-widget ui-widget-content ui-corner-all",notice:"ui-state-highlight",notice_icon:"ui-icon ui-icon-info",info:"",info_icon:"ui-icon ui-icon-info",success:"ui-state-default",success_icon:"ui-icon ui-icon-circle-check",error:"ui-state-error",error_icon:"ui-icon ui-icon-alert",closer:"ui-icon ui-icon-close",pin_up:"ui-icon ui-icon-pin-w",pin_down:"ui-icon ui-icon-pin-s",hi_menu:"ui-state-default ui-corner-bottom",hi_btn:"ui-state-default ui-corner-all",
|
||||
hi_btnhov:"ui-state-hover",hi_hnd:"ui-icon ui-icon-grip-dotted-horizontal"},bootstrap:{container:"alert",notice:"",notice_icon:"icon-exclamation-sign",info:"alert-info",info_icon:"icon-info-sign",success:"alert-success",success_icon:"icon-ok-sign",error:"alert-error",error_icon:"icon-warning-sign",closer:"icon-remove",pin_up:"icon-pause",pin_down:"icon-play",hi_menu:"well",hi_btn:"btn",hi_btnhov:"",hi_hnd:"icon-chevron-down"}},s=function(){r=d("body");i=d(window);i.bind("resize",function(){j&&clearTimeout(j);
|
||||
j=setTimeout(d.pnotify_position_all,10)})};document.body?s():d(s);d.extend({pnotify_remove_all:function(){var e=i.data("pnotify");e&&e.length&&d.each(e,function(){this.pnotify_remove&&this.pnotify_remove()})},pnotify_position_all:function(){j&&clearTimeout(j);j=null;var e=i.data("pnotify");e&&e.length&&(d.each(e,function(){var d=this.opts.stack;if(d)d.nextpos1=d.firstpos1,d.nextpos2=d.firstpos2,d.addpos2=0,d.animation=true}),d.each(e,function(){this.pnotify_position()}))},pnotify:function(e){var g,
|
||||
a;typeof e!="object"?(a=d.extend({},d.pnotify.defaults),a.text=e):a=d.extend({},d.pnotify.defaults,e);for(var p in a)typeof p=="string"&&p.match(/^pnotify_/)&&(a[p.replace(/^pnotify_/,"")]=a[p]);if(a.before_init&&a.before_init(a)===false)return null;var k,o=function(a,c){b.css("display","none");var f=document.elementFromPoint(a.clientX,a.clientY);b.css("display","block");var e=d(f),g=e.css("cursor");b.css("cursor",g!="auto"?g:"default");if(!k||k.get(0)!=f)k&&(n.call(k.get(0),"mouseleave",a.originalEvent),
|
||||
n.call(k.get(0),"mouseout",a.originalEvent)),n.call(f,"mouseenter",a.originalEvent),n.call(f,"mouseover",a.originalEvent);n.call(f,c,a.originalEvent);k=e},f=u[a.styling],b=d("<div />",{"class":"ui-pnotify "+a.addclass,css:{display:"none"},mouseenter:function(l){a.nonblock&&l.stopPropagation();a.mouse_reset&&g=="out"&&(b.stop(true),g="in",b.css("height","auto").animate({width:a.width,opacity:a.nonblock?a.nonblock_opacity:a.opacity},"fast"));a.nonblock&&b.animate({opacity:a.nonblock_opacity},"fast");
|
||||
a.hide&&a.mouse_reset&&b.pnotify_cancel_remove();a.sticker&&!a.nonblock&&b.sticker.trigger("pnotify_icon").css("visibility","visible");a.closer&&!a.nonblock&&b.closer.css("visibility","visible")},mouseleave:function(l){a.nonblock&&l.stopPropagation();k=null;b.css("cursor","auto");a.nonblock&&g!="out"&&b.animate({opacity:a.opacity},"fast");a.hide&&a.mouse_reset&&b.pnotify_queue_remove();a.sticker_hover&&b.sticker.css("visibility","hidden");a.closer_hover&&b.closer.css("visibility","hidden");d.pnotify_position_all()},
|
||||
mouseover:function(b){a.nonblock&&b.stopPropagation()},mouseout:function(b){a.nonblock&&b.stopPropagation()},mousemove:function(b){a.nonblock&&(b.stopPropagation(),o(b,"onmousemove"))},mousedown:function(b){a.nonblock&&(b.stopPropagation(),b.preventDefault(),o(b,"onmousedown"))},mouseup:function(b){a.nonblock&&(b.stopPropagation(),b.preventDefault(),o(b,"onmouseup"))},click:function(b){a.nonblock&&(b.stopPropagation(),o(b,"onclick"))},dblclick:function(b){a.nonblock&&(b.stopPropagation(),o(b,"ondblclick"))}});
|
||||
b.opts=a;b.container=d("<div />",{"class":f.container+" ui-pnotify-container "+(a.type=="error"?f.error:a.type=="info"?f.info:a.type=="success"?f.success:f.notice)}).appendTo(b);a.cornerclass!=""&&b.container.removeClass("ui-corner-all").addClass(a.cornerclass);a.shadow&&b.container.addClass("ui-pnotify-shadow");b.pnotify_version="1.2.0";b.pnotify=function(l){var c=a;typeof l=="string"?a.text=l:a=d.extend({},a,l);for(var e in a)typeof e=="string"&&e.match(/^pnotify_/)&&(a[e.replace(/^pnotify_/,"")]=
|
||||
a[e]);b.opts=a;a.cornerclass!=c.cornerclass&&b.container.removeClass("ui-corner-all").addClass(a.cornerclass);a.shadow!=c.shadow&&(a.shadow?b.container.addClass("ui-pnotify-shadow"):b.container.removeClass("ui-pnotify-shadow"));a.addclass===false?b.removeClass(c.addclass):a.addclass!==c.addclass&&b.removeClass(c.addclass).addClass(a.addclass);a.title===false?b.title_container.slideUp("fast"):a.title!==c.title&&(a.title_escape?b.title_container.text(a.title).slideDown(200):b.title_container.html(a.title).slideDown(200));
|
||||
a.text===false?b.text_container.slideUp("fast"):a.text!==c.text&&(a.text_escape?b.text_container.text(a.text).slideDown(200):b.text_container.html(a.insert_brs?String(a.text).replace(/\n/g,"<br />"):a.text).slideDown(200));b.pnotify_history=a.history;b.pnotify_hide=a.hide;a.type!=c.type&&b.container.removeClass(f.error+" "+f.notice+" "+f.success+" "+f.info).addClass(a.type=="error"?f.error:a.type=="info"?f.info:a.type=="success"?f.success:f.notice);if(a.icon!==c.icon||a.icon===true&&a.type!=c.type)b.container.find("div.ui-pnotify-icon").remove(),
|
||||
a.icon!==false&&d("<div />",{"class":"ui-pnotify-icon"}).append(d("<span />",{"class":a.icon===true?a.type=="error"?f.error_icon:a.type=="info"?f.info_icon:a.type=="success"?f.success_icon:f.notice_icon:a.icon})).prependTo(b.container);a.width!==c.width&&b.animate({width:a.width});a.min_height!==c.min_height&&b.container.animate({minHeight:a.min_height});a.opacity!==c.opacity&&b.fadeTo(a.animate_speed,a.opacity);!a.closer||a.nonblock?b.closer.css("display","none"):b.closer.css("display","block");
|
||||
!a.sticker||a.nonblock?b.sticker.css("display","none"):b.sticker.css("display","block");b.sticker.trigger("pnotify_icon");a.sticker_hover?b.sticker.css("visibility","hidden"):a.nonblock||b.sticker.css("visibility","visible");a.closer_hover?b.closer.css("visibility","hidden"):a.nonblock||b.closer.css("visibility","visible");a.hide?c.hide||b.pnotify_queue_remove():b.pnotify_cancel_remove();b.pnotify_queue_position();return b};b.pnotify_position=function(a){var c=b.opts.stack;if(c){if(!c.nextpos1)c.nextpos1=
|
||||
c.firstpos1;if(!c.nextpos2)c.nextpos2=c.firstpos2;if(!c.addpos2)c.addpos2=0;var d=b.css("display")=="none";if(!d||a){var f,e={},g;switch(c.dir1){case "down":g="top";break;case "up":g="bottom";break;case "left":g="right";break;case "right":g="left"}a=parseInt(b.css(g));isNaN(a)&&(a=0);if(typeof c.firstpos1=="undefined"&&!d)c.firstpos1=a,c.nextpos1=c.firstpos1;var h;switch(c.dir2){case "down":h="top";break;case "up":h="bottom";break;case "left":h="right";break;case "right":h="left"}f=parseInt(b.css(h));
|
||||
isNaN(f)&&(f=0);if(typeof c.firstpos2=="undefined"&&!d)c.firstpos2=f,c.nextpos2=c.firstpos2;if(c.dir1=="down"&&c.nextpos1+b.height()>i.height()||c.dir1=="up"&&c.nextpos1+b.height()>i.height()||c.dir1=="left"&&c.nextpos1+b.width()>i.width()||c.dir1=="right"&&c.nextpos1+b.width()>i.width())c.nextpos1=c.firstpos1,c.nextpos2+=c.addpos2+(typeof c.spacing2=="undefined"?25:c.spacing2),c.addpos2=0;if(c.animation&&c.nextpos2<f)switch(c.dir2){case "down":e.top=c.nextpos2+"px";break;case "up":e.bottom=c.nextpos2+
|
||||
"px";break;case "left":e.right=c.nextpos2+"px";break;case "right":e.left=c.nextpos2+"px"}else b.css(h,c.nextpos2+"px");switch(c.dir2){case "down":case "up":if(b.outerHeight(true)>c.addpos2)c.addpos2=b.height();break;case "left":case "right":if(b.outerWidth(true)>c.addpos2)c.addpos2=b.width()}if(c.nextpos1)if(c.animation&&(a>c.nextpos1||e.top||e.bottom||e.right||e.left))switch(c.dir1){case "down":e.top=c.nextpos1+"px";break;case "up":e.bottom=c.nextpos1+"px";break;case "left":e.right=c.nextpos1+"px";
|
||||
break;case "right":e.left=c.nextpos1+"px"}else b.css(g,c.nextpos1+"px");(e.top||e.bottom||e.right||e.left)&&b.animate(e,{duration:500,queue:false});switch(c.dir1){case "down":case "up":c.nextpos1+=b.height()+(typeof c.spacing1=="undefined"?25:c.spacing1);break;case "left":case "right":c.nextpos1+=b.width()+(typeof c.spacing1=="undefined"?25:c.spacing1)}}}};b.pnotify_queue_position=function(a){j&&clearTimeout(j);a||(a=10);j=setTimeout(d.pnotify_position_all,a)};b.pnotify_display=function(){b.parent().length||
|
||||
b.appendTo(r);a.before_open&&a.before_open(b)===false||(a.stack.push!="top"&&b.pnotify_position(true),a.animation=="fade"||a.animation.effect_in=="fade"?b.show().fadeTo(0,0).hide():a.opacity!=1&&b.show().fadeTo(0,a.opacity).hide(),b.animate_in(function(){a.after_open&&a.after_open(b);b.pnotify_queue_position();a.hide&&b.pnotify_queue_remove()}))};b.pnotify_remove=function(){if(b.timer)window.clearTimeout(b.timer),b.timer=null;a.before_close&&a.before_close(b)===false||b.animate_out(function(){a.after_close&&
|
||||
a.after_close(b)===false||(b.pnotify_queue_position(),a.remove&&b.detach())})};b.animate_in=function(d){g="in";var c;c=typeof a.animation.effect_in!="undefined"?a.animation.effect_in:a.animation;c=="none"?(b.show(),d()):c=="show"?b.show(a.animate_speed,d):c=="fade"?b.show().fadeTo(a.animate_speed,a.opacity,d):c=="slide"?b.slideDown(a.animate_speed,d):typeof c=="function"?c("in",d,b):b.show(c,typeof a.animation.options_in=="object"?a.animation.options_in:{},a.animate_speed,d)};b.animate_out=function(d){g=
|
||||
"out";var c;c=typeof a.animation.effect_out!="undefined"?a.animation.effect_out:a.animation;c=="none"?(b.hide(),d()):c=="show"?b.hide(a.animate_speed,d):c=="fade"?b.fadeOut(a.animate_speed,d):c=="slide"?b.slideUp(a.animate_speed,d):typeof c=="function"?c("out",d,b):b.hide(c,typeof a.animation.options_out=="object"?a.animation.options_out:{},a.animate_speed,d)};b.pnotify_cancel_remove=function(){b.timer&&window.clearTimeout(b.timer)};b.pnotify_queue_remove=function(){b.pnotify_cancel_remove();b.timer=
|
||||
window.setTimeout(function(){b.pnotify_remove()},isNaN(a.delay)?0:a.delay)};b.closer=d("<div />",{"class":"ui-pnotify-closer",css:{cursor:"pointer",visibility:a.closer_hover?"hidden":"visible"},click:function(){b.pnotify_remove();b.sticker.css("visibility","hidden");b.closer.css("visibility","hidden")}}).append(d("<span />",{"class":f.closer})).appendTo(b.container);(!a.closer||a.nonblock)&&b.closer.css("display","none");b.sticker=d("<div />",{"class":"ui-pnotify-sticker",css:{cursor:"pointer",visibility:a.sticker_hover?
|
||||
"hidden":"visible"},click:function(){a.hide=!a.hide;a.hide?b.pnotify_queue_remove():b.pnotify_cancel_remove();d(this).trigger("pnotify_icon")}}).bind("pnotify_icon",function(){d(this).children().removeClass(f.pin_up+" "+f.pin_down).addClass(a.hide?f.pin_up:f.pin_down)}).append(d("<span />",{"class":f.pin_up})).appendTo(b.container);(!a.sticker||a.nonblock)&&b.sticker.css("display","none");a.icon!==false&&d("<div />",{"class":"ui-pnotify-icon"}).append(d("<span />",{"class":a.icon===true?a.type=="error"?
|
||||
f.error_icon:a.type=="info"?f.info_icon:a.type=="success"?f.success_icon:f.notice_icon:a.icon})).prependTo(b.container);b.title_container=d("<h4 />",{"class":"ui-pnotify-title"}).appendTo(b.container);a.title===false?b.title_container.hide():a.title_escape?b.title_container.text(a.title):b.title_container.html(a.title);b.text_container=d("<div />",{"class":"ui-pnotify-text"}).appendTo(b.container);a.text===false?b.text_container.hide():a.text_escape?b.text_container.text(a.text):b.text_container.html(a.insert_brs?
|
||||
String(a.text).replace(/\n/g,"<br />"):a.text);typeof a.width=="string"&&b.css("width",a.width);typeof a.min_height=="string"&&b.container.css("min-height",a.min_height);b.pnotify_history=a.history;b.pnotify_hide=a.hide;var h=i.data("pnotify");if(h==null||typeof h!="object")h=[];h=a.stack.push=="top"?d.merge([b],h):d.merge(h,[b]);i.data("pnotify",h);a.stack.push=="top"&&b.pnotify_queue_position(1);a.after_init&&a.after_init(b);if(a.history){var m=i.data("pnotify_history");typeof m=="undefined"&&(m=
|
||||
d("<div />",{"class":"ui-pnotify-history-container "+f.hi_menu,mouseleave:function(){m.animate({top:"-"+q+"px"},{duration:100,queue:false})}}).append(d("<div />",{"class":"ui-pnotify-history-header",text:"Redisplay"})).append(d("<button />",{"class":"ui-pnotify-history-all "+f.hi_btn,text:"All",mouseenter:function(){d(this).addClass(f.hi_btnhov)},mouseleave:function(){d(this).removeClass(f.hi_btnhov)},click:function(){d.each(h,function(){this.pnotify_history&&(this.is(":visible")?this.pnotify_hide&&
|
||||
this.pnotify_queue_remove():this.pnotify_display&&this.pnotify_display())});return false}})).append(d("<button />",{"class":"ui-pnotify-history-last "+f.hi_btn,text:"Last",mouseenter:function(){d(this).addClass(f.hi_btnhov)},mouseleave:function(){d(this).removeClass(f.hi_btnhov)},click:function(){var a=-1,b;do{b=a==-1?h.slice(a):h.slice(a,a+1);if(!b[0])break;a--}while(!b[0].pnotify_history||b[0].is(":visible"));if(!b[0])return false;b[0].pnotify_display&&b[0].pnotify_display();return false}})).appendTo(r),
|
||||
q=d("<span />",{"class":"ui-pnotify-history-pulldown "+f.hi_hnd,mouseenter:function(){m.animate({top:"0"},{duration:100,queue:false})}}).appendTo(m).offset().top+2,m.css({top:"-"+q+"px"}),i.data("pnotify_history",m))}a.stack.animation=false;b.pnotify_display();return b}});var t=/^on/,v=/^(dbl)?click$|^mouse(move|down|up|over|out|enter|leave)$|^contextmenu$/,w=/^(focus|blur|select|change|reset)$|^key(press|down|up)$/,x=/^(scroll|resize|(un)?load|abort|error)$/,n=function(e,g){var a,e=e.toLowerCase();
|
||||
document.createEvent&&this.dispatchEvent?(e=e.replace(t,""),e.match(v)?(d(this).offset(),a=document.createEvent("MouseEvents"),a.initMouseEvent(e,g.bubbles,g.cancelable,g.view,g.detail,g.screenX,g.screenY,g.clientX,g.clientY,g.ctrlKey,g.altKey,g.shiftKey,g.metaKey,g.button,g.relatedTarget)):e.match(w)?(a=document.createEvent("UIEvents"),a.initUIEvent(e,g.bubbles,g.cancelable,g.view,g.detail)):e.match(x)&&(a=document.createEvent("HTMLEvents"),a.initEvent(e,g.bubbles,g.cancelable)),a&&this.dispatchEvent(a)):
|
||||
(e.match(t)||(e="on"+e),a=document.createEventObject(g),this.fireEvent(e,a))};d.pnotify.defaults={title:false,title_escape:false,text:false,text_escape:false,styling:"bootstrap",addclass:"",cornerclass:"",nonblock:false,nonblock_opacity:0.2,history:true,width:"300px",min_height:"16px",type:"notice",icon:true,animation:"fade",animate_speed:"slow",opacity:1,shadow:true,closer:true,closer_hover:true,sticker:true,sticker_hover:true,hide:true,delay:8E3,mouse_reset:true,remove:true,insert_brs:true,stack:{dir1:"down",
|
||||
dir2:"left",push:"bottom",spacing1:25,spacing2:25}}})(jQuery);
|
||||
@@ -1 +0,0 @@
|
||||
(function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,h=e.reduce,v=e.reduceRight,d=e.filter,g=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,_=Object.keys,j=i.bind,w=function(n){return n instanceof w?n:this instanceof w?(this._wrapped=n,void 0):new w(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=w),exports._=w):n._=w,w.VERSION="1.4.4";var A=w.each=w.forEach=function(n,t,e){if(null!=n)if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a in n)if(w.has(n,a)&&t.call(e,n[a],a,n)===r)return};w.map=w.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e[e.length]=t.call(r,n,u,i)}),e)};var O="Reduce of empty array with no initial value";w.reduce=w.foldl=w.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduce===h)return e&&(t=w.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(O);return r},w.reduceRight=w.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduceRight===v)return e&&(t=w.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=w.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(O);return r},w.find=w.detect=function(n,t,r){var e;return E(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},w.filter=w.select=function(n,t,r){var e=[];return null==n?e:d&&n.filter===d?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&(e[e.length]=n)}),e)},w.reject=function(n,t,r){return w.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},w.every=w.all=function(n,t,e){t||(t=w.identity);var u=!0;return null==n?u:g&&n.every===g?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var E=w.some=w.any=function(n,t,e){t||(t=w.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};w.contains=w.include=function(n,t){return null==n?!1:y&&n.indexOf===y?n.indexOf(t)!=-1:E(n,function(n){return n===t})},w.invoke=function(n,t){var r=o.call(arguments,2),e=w.isFunction(t);return w.map(n,function(n){return(e?t:n[t]).apply(n,r)})},w.pluck=function(n,t){return w.map(n,function(n){return n[t]})},w.where=function(n,t,r){return w.isEmpty(t)?r?null:[]:w[r?"find":"filter"](n,function(n){for(var r in t)if(t[r]!==n[r])return!1;return!0})},w.findWhere=function(n,t){return w.where(n,t,!0)},w.max=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.max.apply(Math,n);if(!t&&w.isEmpty(n))return-1/0;var e={computed:-1/0,value:-1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a>=e.computed&&(e={value:n,computed:a})}),e.value},w.min=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.min.apply(Math,n);if(!t&&w.isEmpty(n))return 1/0;var e={computed:1/0,value:1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;e.computed>a&&(e={value:n,computed:a})}),e.value},w.shuffle=function(n){var t,r=0,e=[];return A(n,function(n){t=w.random(r++),e[r-1]=e[t],e[t]=n}),e};var k=function(n){return w.isFunction(n)?n:function(t){return t[n]}};w.sortBy=function(n,t,r){var e=k(t);return w.pluck(w.map(n,function(n,t,u){return{value:n,index:t,criteria:e.call(r,n,t,u)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.index<t.index?-1:1}),"value")};var F=function(n,t,r,e){var u={},i=k(t||w.identity);return A(n,function(t,a){var o=i.call(r,t,a,n);e(u,o,t)}),u};w.groupBy=function(n,t,r){return F(n,t,r,function(n,t,r){(w.has(n,t)?n[t]:n[t]=[]).push(r)})},w.countBy=function(n,t,r){return F(n,t,r,function(n,t){w.has(n,t)||(n[t]=0),n[t]++})},w.sortedIndex=function(n,t,r,e){r=null==r?w.identity:k(r);for(var u=r.call(e,t),i=0,a=n.length;a>i;){var o=i+a>>>1;u>r.call(e,n[o])?i=o+1:a=o}return i},w.toArray=function(n){return n?w.isArray(n)?o.call(n):n.length===+n.length?w.map(n,w.identity):w.values(n):[]},w.size=function(n){return null==n?0:n.length===+n.length?n.length:w.keys(n).length},w.first=w.head=w.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:o.call(n,0,t)},w.initial=function(n,t,r){return o.call(n,0,n.length-(null==t||r?1:t))},w.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:o.call(n,Math.max(n.length-t,0))},w.rest=w.tail=w.drop=function(n,t,r){return o.call(n,null==t||r?1:t)},w.compact=function(n){return w.filter(n,w.identity)};var R=function(n,t,r){return A(n,function(n){w.isArray(n)?t?a.apply(r,n):R(n,t,r):r.push(n)}),r};w.flatten=function(n,t){return R(n,t,[])},w.without=function(n){return w.difference(n,o.call(arguments,1))},w.uniq=w.unique=function(n,t,r,e){w.isFuncLine truncated
|
||||
@@ -1,487 +0,0 @@
|
||||
<div id="settings_dialog" class="modal hide fade container" tabindex="-1" role="dialog" aria-labelledby="settings_dialog_label" aria-hidden="true">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||
<h3 id="settings_dialog_label">OctoPrint Settings</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="tabbable">
|
||||
<ul class="nav nav-list span4" id="settingsTabs">
|
||||
<li class="nav-header">Printer</li>
|
||||
<li class="active"><a href="#settings_serialConnection" data-toggle="tab">Serial Connection</a></li>
|
||||
<li><a href="#settings_printerParameters" data-toggle="tab">Printer Parameters</a></li>
|
||||
<li><a href="#settings_temperature" data-toggle="tab">Temperatures</a></li>
|
||||
<li><a href="#settings_terminalFilters" data-toggle="tab">Terminal filters</a></li>
|
||||
<li class="nav-header">Features</li>
|
||||
<li><a href="#settings_features" data-toggle="tab">Features</a></li>
|
||||
<li><a href="#settings_webcam" data-toggle="tab">Webcam</a></li>
|
||||
{% if enableAccessControl %}<li><a href="#settings_users" data-toggle="tab">Access Control</a></li>{% endif %}
|
||||
<li><a href="#settings_api" data-toggle="tab">Api</a></li>
|
||||
<li class="nav-header">OctoPrint</li>
|
||||
<li><a href="#settings_folder" data-toggle="tab">Folders</a></li>
|
||||
<li><a href="#settings_appearance" data-toggle="tab">Appearance</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content span8">
|
||||
<div class="tab-pane active" id="settings_serialConnection">
|
||||
<form class="form-horizontal">
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="settings-serialPort">Serial Port</label>
|
||||
<div class="controls">
|
||||
<select id="settings-serialPort" data-bind="options: serial_portOptions, optionsCaption: 'AUTO', value: serial_port"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="settings-baudrate">Baudrate</label>
|
||||
<div class="controls">
|
||||
<select id="settings-baudrate" data-bind="options: serial_baudrateOptions, optionsCaption: 'AUTO', value: serial_baudrate"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: serial_autoconnect" id="settings-serialAutoconnect"> Auto-connect to printer on server start
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="settings-movementSpeedE">Communication timeout</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" step="any" min="0" class="input-mini text-right" data-bind="value: serial_timeoutCommunication" id="settings-serialTimeoutCommunication">
|
||||
<span class="add-on">s</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="settings-movementSpeedE">Connection timeout</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" step="any" min="0" class="input-mini text-right" data-bind="value: serial_timeoutConnection" id="settings-serialTimeoutConnection">
|
||||
<span class="add-on">s</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="settings-movementSpeedE">Autodetection timeout</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" step="any" min="0" class="input-mini text-right" data-bind="value: serial_timeoutDetection" id="settings-serialTimeoutDetection">
|
||||
<span class="add-on">s</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: serial_log" id="settings-serialLog"> Log communication to serial.log (might negatively impact performance) <span class="label label-important">Warning</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="tab-pane" id="settings_printerParameters">
|
||||
<form class="form-horizontal">
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="settings-movementSpeedX">Movement Speed X Axis</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" class="input-mini text-right" data-bind="value: printer_movementSpeedX" id="settings-movementSpeedX">
|
||||
<span class="add-on">mm/min</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="settings-movementSpeedY">Movement Speed Y Axis</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" class="input-mini text-right" data-bind="value: printer_movementSpeedY" id="settings-movementSpeedY">
|
||||
<span class="add-on">mm/min</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="settings-movementSpeedZ">Movement Speed Z Axis</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" class="input-mini text-right" data-bind="value: printer_movementSpeedZ" id="settings-movementSpeedZ">
|
||||
<span class="add-on">mm/min</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="settings-movementSpeedE">Movement Speed Extruder</label>
|
||||
<div class="controls">
|
||||
<div class="input-append">
|
||||
<input type="number" class="input-mini text-right" data-bind="value: printer_movementSpeedE" id="settings-movementSpeedE">
|
||||
<span class="add-on">mm/min</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="tab-pane" id="settings_webcam">
|
||||
<form class="form-horizontal">
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="settings-webcamStreamUrl">Stream URL</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: webcam_streamUrl" id="settings-webcamStreamUrl">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="settings-webcamStreamUrl">Snapshot URL</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: webcam_snapshotUrl" id="settings-webcamSnapshotUrl">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="settings-webcamStreamUrl">Path to FFMPEG</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: webcam_ffmpegPath" id="settings-webcamFfmpegPath">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="settings-webcamBitrate">Timelapse bitrate</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: webcam_bitrate" id="settings-webcamBitrate">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: webcam_watermark" id="settings-webcamWatermark"> Enable OctoPrint watermark in timelapse movies
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: webcam_flipH" id="settings-webcamFlipH"> Flip webcam horizontally
|
||||
</label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: webcam_flipV" id="settings-webcamFlipV"> Flip webcam vertically
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="tab-pane" id="settings_features">
|
||||
<form class="form-horizontal">
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: feature_temperatureGraph" id="settings-featureTemperatureGraph"> Enable Temperature Graph
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: feature_gcodeViewer" id="settings-featureGcodeViewer"> Enable GCode Visualizer
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: feature_sdSupport" id="settings-featureSdSupport"> Enable SD support
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: feature_waitForStart" id="settings-featureWaitForStart"> Wait for <code>start</code> on connect
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: feature_alwaysSendChecksum" id="settings-featureAlwaysSendChecksum"> Send a checksum with <strong>every</strong> command <span class="label">Repetier</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: feature_swallowOkAfterResend" id="settings-swallowOkAfterResend"> Swallow the first "ok" after a resend response
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="tab-pane" id="settings_folder">
|
||||
<form class="form-horizontal">
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="settings-folderUploads">Upload Folder</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: folder_uploads" id="settings-folderUploads">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="settings-folderTimelapse">Timelapse Folder</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: folder_timelapse" id="settings-folderTimelapse">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="settings-folderTimelapseTemp">Timelapse Temp Folder</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: folder_timelapseTmp" id="settings-folderTimelapseTemp">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="settings-folderLogs">Logs Folder</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: folder_logs" id="settings-folderLogs">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="tab-pane" id="settings_temperature">
|
||||
<form class="form-horizontal">
|
||||
<div class="row-fluid">
|
||||
<div class="offset3 span3"><h4>Extruder</h4></div>
|
||||
<div class="span3"><h4>Bed</h4></div>
|
||||
</div>
|
||||
<div data-bind="foreach: temperature_profiles">
|
||||
<div class="row-fluid" style="margin-bottom: 5px">
|
||||
<div class="span3">
|
||||
<input type="text" class="span12 text-right" data-bind="value: name">
|
||||
</div>
|
||||
<div class="input-append span3">
|
||||
<input type="number" class="input-mini text-right" data-bind="value: extruder">
|
||||
<span class="add-on">°C</span>
|
||||
</div>
|
||||
<div class="input-append span3">
|
||||
<input type="number" class="input-mini text-right" data-bind="value: bed">
|
||||
<span class="add-on">°C</span>
|
||||
</div>
|
||||
<div class="span2">
|
||||
<button title="Remove profile" class="btn btn-danger" data-bind="click: $parent.removeTemperatureProfile"><i class="icon-trash"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-fluid">
|
||||
<div class="offset9 span2">
|
||||
<button title="Add Profile" class="btn btn-primary" data-bind="click: addTemperatureProfile"><i class="icon-plus"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="tab-pane" id="settings_terminalFilters">
|
||||
<form class="form-horizontal">
|
||||
<div class="row-fluid">
|
||||
<div class="span4"><h4>Name</h4></div>
|
||||
<div class="span6"><h4>RegExp <small><a href="https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions">?</a></small></h4></div>
|
||||
</div>
|
||||
<div data-bind="foreach: terminalFilters">
|
||||
<div class="row-fluid" style="margin-bottom: 5px">
|
||||
<div class="span4">
|
||||
<input type="text" class="span12" data-bind="value: name">
|
||||
</div>
|
||||
<div class="span6">
|
||||
<input type="text" class="span12" data-bind="value: regex">
|
||||
</div>
|
||||
<div class="span2">
|
||||
<button title="Remove Filter" class="btn btn-danger" data-bind="click: $parent.removeTerminalFilter"><i class="icon-trash"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-fluid">
|
||||
<div class="offset10 span2">
|
||||
<button title="Add Filter" class="btn btn-primary" data-bind="click: addTerminalFilter"><i class="icon-plus"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="tab-pane" id="settings_appearance">
|
||||
<form class="form-horizontal">
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="settings-appearanceName">Title</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: appearance_name" id="settings-appearanceName">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="settings-appearanceColor">Color</label>
|
||||
<div class="controls">
|
||||
<select id="settings-appearanceColor" data-bind="value: appearance_color, options: appearance_available_colors">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="tab-pane" id="settings_api">
|
||||
<form class="form-horizontal">
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" id="settings-apiEnabled" data-bind="checked: api_enabled"> Enable
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="settings-apiKey">Apikey</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: api_key" id="settings-apikey">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{% if enableAccessControl %}
|
||||
<div class="tab-pane" id="settings_users">
|
||||
<table class="table table-condensed table-hover" id="system_users">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="settings_users_name">Name</th>
|
||||
<th class="settings_users_active">Active</th>
|
||||
<th class="settings_users_admin">Admin</th>
|
||||
<th class="settings_users_actions">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody data-bind="foreach: users.listHelper.paginatedItems">
|
||||
<tr>
|
||||
<td class="settings_users_name" data-bind="text: name"></td>
|
||||
<td class="settings_users_active"><i data-bind="css: { 'icon-check': active, 'icon-check-empty': !active }"></i></td>
|
||||
<td class="settings_users_admin"><i data-bind="css: { 'icon-check': admin, 'icon-check-empty': !admin }"></i></td>
|
||||
<td class="settings_users_actions" class="system_users_action">
|
||||
<a href="#" class="icon-pencil" title="Update User" data-bind="click: function() { $root.users.showEditUserDialog($data); }"></a> | <a href="#" class="icon-key" title="Change password" data-bind="click: function() { $root.users.showChangePasswordDialog($data); }"></a> | <a href="#" class="icon-trash" title="Delete user" data-bind="click: function() { $root.users.removeUser($data); }"></a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="pagination pagination-mini pagination-centered">
|
||||
<ul>
|
||||
<li data-bind="css: {disabled: users.listHelper.currentPage() === 0}"><a href="#" data-bind="click: users.listHelper.prevPage">«</a></li>
|
||||
</ul>
|
||||
<ul data-bind="foreach: users.listHelper.pages">
|
||||
<li data-bind="css: { active: $data.number === $root.users.listHelper.currentPage(), disabled: $data.number === -1 }"><a href="#" data-bind="text: $data.text, click: function() { $root.users.listHelper.changePage($data.number); }"></a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li data-bind="css: {disabled: users.listHelper.currentPage() === users.listHelper.lastPage()}"><a href="#" data-bind="click: users.listHelper.nextPage">»</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<button title="Add user" class="btn" data-bind="click: $root.users.showAddUserDialog"><i class="icon-plus"></i> Create new user</button>
|
||||
|
||||
<!-- Modals for user management -->
|
||||
|
||||
<div id="settings-usersDialogAddUser" class="modal hide fade">
|
||||
<div class="modal-header">
|
||||
<a href="#" class="close" data-dismiss="modal" aria-hidden="true">×</a>
|
||||
<h3>Create new user</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form class="form-horizontal">
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="settings-usersDialogAddUserName">Username</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" id="settings-usersDialogAddUserName" data-bind="value: $root.users.editorUsername" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="settings-usersDialogAddUserPassword1">Password</label>
|
||||
<div class="controls">
|
||||
<input type="password" class="input-block-level" id="settings-usersDialogAddUserPassword1" data-bind="value: $root.users.editorPassword" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" data-bind="css: {error: $root.users.editorPasswordMismatch()}">
|
||||
<label class="control-label" for="settings-usersDialogAddUserPassword2">Repeat Password</label>
|
||||
<div class="controls">
|
||||
<input type="password" class="input-block-level" id="settings-usersDialogAddUserPassword2" data-bind="value: $root.users.editorRepeatedPassword, valueUpdate: 'afterkeydown'" required>
|
||||
<span class="help-inline" data-bind="visible: $root.users.editorPasswordMismatch()">Passwords do not match</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" id="settings-usersDialogAddUserActive" data-bind="checked: $root.users.editorActive"> Active
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" id="settings-usersDialogAddUserAdmin" data-bind="checked: $root.users.editorAdmin"> Admin
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn" data-dismiss="modal" aria-hidden="true">Abort</button>
|
||||
<button class="btn btn-primary" data-bind="click: function() { $root.users.confirmAddUser(); }, enable: !$root.users.editorPasswordMismatch()">Confirm</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="settings-usersDialogEditUser" class="modal hide fade">
|
||||
<div class="modal-header">
|
||||
<a href="#" class="close" data-dismiss="modal" aria-hidden="true">×</a>
|
||||
<h3>Edit user "<span data-bind="text: $root.users.editorUsername"></span>"</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form class="form-horizontal">
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" id="settings-usersDialogEditUserActive" data-bind="checked: $root.users.editorActive"> Active
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" id="settings-usersDialogEditUserAdmin" data-bind="checked: $root.users.editorAdmin"> Admin
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn" data-dismiss="modal" aria-hidden="true">Abort</button>
|
||||
<button class="btn btn-primary" data-bind="click: function() { $root.users.confirmEditUser(); }">Confirm</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="settings-usersDialogChangePassword" class="modal hide fade">
|
||||
<div class="modal-header">
|
||||
<a href="#" class="close" data-dismiss="modal" aria-hidden="true">×</a>
|
||||
<h3>Change password for user "<span data-bind="text: $root.users.editorUsername"></span>"</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form class="form-horizontal">
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="settings-usersDialogChangePasswordPassword1">New Password</label>
|
||||
<div class="controls">
|
||||
<input type="password" class="input-block-level" id="settings-usersDialogChangePasswordPassword1" data-bind="value: $root.users.editorPassword" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" data-bind="css: {error: $root.users.editorPasswordMismatch()}">
|
||||
<label class="control-label" for="settings-usersDialogChangePasswordPassword2">Repeat Password</label>
|
||||
<div class="controls">
|
||||
<input type="password" class="input-block-level" id="settings-usersDialogChangePasswordPassword2" data-bind="value: $root.users.editorRepeatedPassword, valueUpdate: 'afterkeydown'" required>
|
||||
<span class="help-inline" data-bind="visible: $root.users.editorPasswordMismatch()">Passwords do not match</span>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn" data-dismiss="modal" aria-hidden="true">Abort</button>
|
||||
<button class="btn btn-primary" data-bind="click: function() { $root.users.confirmChangePassword(); }, enable: !$root.users.editorPasswordMismatch()">Confirm</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
|
||||
<button class="btn btn-primary" data-bind="click: saveData">Save</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,243 +0,0 @@
|
||||
# coding=utf-8
|
||||
__author__ = "Gina Häußge <osd@foosel.net>"
|
||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||
|
||||
from flask.ext.login import UserMixin
|
||||
from flask.ext.principal import Identity
|
||||
import hashlib
|
||||
import os
|
||||
import yaml
|
||||
|
||||
from octoprint.settings import settings
|
||||
|
||||
class UserManager(object):
|
||||
valid_roles = ["user", "admin"]
|
||||
|
||||
@staticmethod
|
||||
def createPasswordHash(password):
|
||||
return hashlib.sha512(password + "mvBUTvwzBzD3yPwvnJ4E4tXNf3CGJvvW").hexdigest()
|
||||
|
||||
def addUser(self, username, password, active, roles):
|
||||
pass
|
||||
|
||||
def changeUserActivation(self, username, active):
|
||||
pass
|
||||
|
||||
def changeUserRoles(self, username, roles):
|
||||
pass
|
||||
|
||||
def addRolesToUser(self, username, roles):
|
||||
pass
|
||||
|
||||
def removeRolesFromUser(self, username, roles):
|
||||
pass
|
||||
|
||||
def changeUserPassword(self, username, password):
|
||||
pass
|
||||
|
||||
def removeUser(self, username):
|
||||
pass
|
||||
|
||||
def findUser(self, username=None):
|
||||
return None
|
||||
|
||||
def getAllUsers(self):
|
||||
return []
|
||||
|
||||
def hasBeenCustomized(self):
|
||||
return False
|
||||
|
||||
##~~ FilebasedUserManager, takes available users from users.yaml file
|
||||
|
||||
class FilebasedUserManager(UserManager):
|
||||
def __init__(self):
|
||||
UserManager.__init__(self)
|
||||
|
||||
userfile = settings().get(["accessControl", "userfile"])
|
||||
if userfile is None:
|
||||
userfile = os.path.join(settings().settings_dir, "users.yaml")
|
||||
self._userfile = userfile
|
||||
self._users = {}
|
||||
self._dirty = False
|
||||
|
||||
self._customized = None
|
||||
self._load()
|
||||
|
||||
def _load(self):
|
||||
if os.path.exists(self._userfile) and os.path.isfile(self._userfile):
|
||||
self._customized = True
|
||||
with open(self._userfile, "r") as f:
|
||||
data = yaml.safe_load(f)
|
||||
for name in data.keys():
|
||||
attributes = data[name]
|
||||
self._users[name] = User(name, attributes["password"], attributes["active"], attributes["roles"])
|
||||
else:
|
||||
self._customized = False
|
||||
|
||||
def _save(self, force=False):
|
||||
if not self._dirty and not force:
|
||||
return
|
||||
|
||||
data = {}
|
||||
for name in self._users.keys():
|
||||
user = self._users[name]
|
||||
data[name] = {
|
||||
"password": user._passwordHash,
|
||||
"active": user._active,
|
||||
"roles": user._roles
|
||||
}
|
||||
|
||||
with open(self._userfile, "wb") as f:
|
||||
yaml.safe_dump(data, f, default_flow_style=False, indent=" ", allow_unicode=True)
|
||||
self._dirty = False
|
||||
self._load()
|
||||
|
||||
def addUser(self, username, password, active=False, roles=["user"]):
|
||||
if username in self._users.keys():
|
||||
raise UserAlreadyExists(username)
|
||||
|
||||
self._users[username] = User(username, UserManager.createPasswordHash(password), active, roles)
|
||||
self._dirty = True
|
||||
self._save()
|
||||
|
||||
def changeUserActivation(self, username, active):
|
||||
if not username in self._users.keys():
|
||||
raise UnknownUser(username)
|
||||
|
||||
if self._users[username]._active != active:
|
||||
self._users[username]._active = active
|
||||
self._dirty = True
|
||||
self._save()
|
||||
|
||||
def changeUserRoles(self, username, roles):
|
||||
if not username in self._users.keys():
|
||||
raise UnknownUser(username)
|
||||
|
||||
user = self._users[username]
|
||||
|
||||
removedRoles = set(user._roles) - set(roles)
|
||||
self.removeRolesFromUser(username, removedRoles)
|
||||
|
||||
addedRoles = set(roles) - set(user._roles)
|
||||
self.addRolesToUser(username, addedRoles)
|
||||
|
||||
def addRolesToUser(self, username, roles):
|
||||
if not username in self._users.keys():
|
||||
raise UnknownUser(username)
|
||||
|
||||
user = self._users[username]
|
||||
for role in roles:
|
||||
if not role in user._roles:
|
||||
user._roles.append(role)
|
||||
self._dirty = True
|
||||
self._save()
|
||||
|
||||
def removeRolesFromUser(self, username, roles):
|
||||
if not username in self._users.keys():
|
||||
raise UnknownUser(username)
|
||||
|
||||
user = self._users[username]
|
||||
for role in roles:
|
||||
if role in user._roles:
|
||||
user._roles.remove(role)
|
||||
self._dirty = True
|
||||
self._save()
|
||||
|
||||
def changeUserPassword(self, username, password):
|
||||
if not username in self._users.keys():
|
||||
raise UnknownUser(username)
|
||||
|
||||
passwordHash = UserManager.createPasswordHash(password)
|
||||
user = self._users[username]
|
||||
if user._passwordHash != passwordHash:
|
||||
user._passwordHash = passwordHash
|
||||
self._dirty = True
|
||||
self._save()
|
||||
|
||||
def removeUser(self, username):
|
||||
if not username in self._users.keys():
|
||||
raise UnknownUser(username)
|
||||
|
||||
del self._users[username]
|
||||
self._dirty = True
|
||||
self._save()
|
||||
|
||||
def findUser(self, username=None):
|
||||
if username is None:
|
||||
return None
|
||||
|
||||
if username not in self._users.keys():
|
||||
return None
|
||||
|
||||
return self._users[username]
|
||||
|
||||
def getAllUsers(self):
|
||||
return map(lambda x: x.asDict(), self._users.values())
|
||||
|
||||
def hasBeenCustomized(self):
|
||||
return self._customized
|
||||
|
||||
##~~ Exceptions
|
||||
|
||||
class UserAlreadyExists(Exception):
|
||||
def __init__(self, username):
|
||||
Exception.__init__(self, "User %s already exists" % username)
|
||||
|
||||
class UnknownUser(Exception):
|
||||
def __init__(self, username):
|
||||
Exception.__init__(self, "Unknown user: %s" % username)
|
||||
|
||||
class UnknownRole(Exception):
|
||||
def _init_(self, role):
|
||||
Exception.__init__(self, "Unknown role: %s" % role)
|
||||
|
||||
##~~ User object
|
||||
|
||||
class User(UserMixin):
|
||||
def __init__(self, username, passwordHash, active, roles):
|
||||
self._username = username
|
||||
self._passwordHash = passwordHash
|
||||
self._active = active
|
||||
self._roles = roles
|
||||
|
||||
def asDict(self):
|
||||
return {
|
||||
"name": self._username,
|
||||
"active": self.is_active(),
|
||||
"admin": self.is_admin(),
|
||||
"user": self.is_user()
|
||||
}
|
||||
|
||||
def check_password(self, passwordHash):
|
||||
return self._passwordHash == passwordHash
|
||||
|
||||
def get_id(self):
|
||||
return self._username
|
||||
|
||||
def get_name(self):
|
||||
return self._username
|
||||
|
||||
def is_active(self):
|
||||
return self._active
|
||||
|
||||
def is_user(self):
|
||||
return "user" in self._roles
|
||||
|
||||
def is_admin(self):
|
||||
return "admin" in self._roles
|
||||
|
||||
##~~ DummyUser object to use when accessControl is disabled
|
||||
|
||||
class DummyUser(User):
|
||||
def __init__(self):
|
||||
User.__init__(self, "dummy", "", True, UserManager.valid_roles)
|
||||
|
||||
def check_password(self, passwordHash):
|
||||
return True
|
||||
|
||||
class DummyIdentity(Identity):
|
||||
def __init__(self):
|
||||
Identity.__init__(self, "dummy")
|
||||
|
||||
def dummy_identity_loader():
|
||||
return DummyIdentity()
|
||||
@@ -1,140 +0,0 @@
|
||||
# coding=utf-8
|
||||
__author__ = "Gina Häußge <osd@foosel.net>"
|
||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||
|
||||
import os
|
||||
import traceback
|
||||
import sys
|
||||
import time
|
||||
import re
|
||||
|
||||
from octoprint.settings import settings
|
||||
|
||||
def getFormattedSize(num):
|
||||
"""
|
||||
Taken from http://stackoverflow.com/a/1094933/2028598
|
||||
"""
|
||||
for x in ["bytes","KB","MB","GB"]:
|
||||
if num < 1024.0:
|
||||
return "%3.1f%s" % (num, x)
|
||||
num /= 1024.0
|
||||
return "%3.1f%s" % (num, "TB")
|
||||
|
||||
|
||||
def isAllowedFile(filename, extensions):
|
||||
return "." in filename and filename.rsplit(".", 1)[1] in extensions
|
||||
|
||||
|
||||
def getFormattedTimeDelta(d):
|
||||
if d is None:
|
||||
return None
|
||||
hours = d.seconds // 3600
|
||||
minutes = (d.seconds % 3600) // 60
|
||||
seconds = d.seconds % 60
|
||||
return "%02d:%02d:%02d" % (hours, minutes, seconds)
|
||||
|
||||
|
||||
def getFormattedDateTime(d):
|
||||
if d is None:
|
||||
return None
|
||||
|
||||
return d.strftime("%Y-%m-%d %H:%M")
|
||||
|
||||
|
||||
def getClass(name):
|
||||
"""
|
||||
Taken from http://stackoverflow.com/a/452981/2028598
|
||||
"""
|
||||
parts = name.split(".")
|
||||
module = ".".join(parts[:-1])
|
||||
m = __import__(module)
|
||||
for comp in parts[1:]:
|
||||
m = getattr(m, comp)
|
||||
return m
|
||||
|
||||
|
||||
def isDevVersion():
|
||||
gitPath = os.path.abspath(os.path.join(os.path.split(os.path.abspath(__file__))[0], "../../.git"))
|
||||
return os.path.exists(gitPath)
|
||||
|
||||
|
||||
def getExceptionString():
|
||||
locationInfo = traceback.extract_tb(sys.exc_info()[2])[0]
|
||||
return "%s: '%s' @ %s:%s:%d" % (str(sys.exc_info()[0].__name__), str(sys.exc_info()[1]), os.path.basename(locationInfo[0]), locationInfo[2], locationInfo[1])
|
||||
|
||||
|
||||
def getGitInfo():
|
||||
gitPath = os.path.abspath(os.path.join(os.path.split(os.path.abspath(__file__))[0], "../../.git"))
|
||||
if not os.path.exists(gitPath):
|
||||
return (None, None)
|
||||
|
||||
headref = None
|
||||
with open(os.path.join(gitPath, "HEAD"), "r") as f:
|
||||
headref = f.readline().strip()
|
||||
|
||||
if headref is None:
|
||||
return (None, None)
|
||||
|
||||
headref = headref[len("ref: "):]
|
||||
branch = headref[headref.rfind("/") + 1:]
|
||||
with open(os.path.join(gitPath, headref)) as f:
|
||||
head = f.readline().strip()
|
||||
|
||||
return (branch, head)
|
||||
|
||||
|
||||
def getNewTimeout(type):
|
||||
now = time.time()
|
||||
|
||||
if type not in ["connection", "detection", "communication"]:
|
||||
return now # timeout immediately for unknown timeout type
|
||||
|
||||
return now + settings().getFloat(["serial", "timeout", type])
|
||||
|
||||
|
||||
def getFreeBytes(path):
|
||||
"""
|
||||
Taken from http://stackoverflow.com/a/2372171/2028598
|
||||
"""
|
||||
if sys.platform == "win32":
|
||||
import ctypes
|
||||
freeBytes = ctypes.c_ulonglong(0)
|
||||
ctypes.windll.kernel32.GetDiskFreeSpaceExW(ctypes.c_wchar_p(path), None, None, ctypes.pointer(freeBytes))
|
||||
return freeBytes.value
|
||||
else:
|
||||
st = os.statvfs(path)
|
||||
return st.f_bavail * st.f_frsize
|
||||
|
||||
|
||||
def getRemoteAddress(request):
|
||||
forwardedFor = request.headers.get("X-Forwarded-For", None)
|
||||
if forwardedFor is not None:
|
||||
return forwardedFor.split(",")[0]
|
||||
return request.remote_addr
|
||||
|
||||
|
||||
def getDosFilename(input, existingFilenames, extension=None):
|
||||
if input is None:
|
||||
return None
|
||||
|
||||
if extension is None:
|
||||
extension = "gco"
|
||||
|
||||
filename, ext = input.rsplit(".", 1)
|
||||
return findCollisionfreeName(filename, extension, existingFilenames)
|
||||
|
||||
|
||||
def findCollisionfreeName(input, extension, existingFilenames):
|
||||
filename = re.sub(r"\s+", "_", input.lower().translate(None, ".\"/\\[]:;=,"))
|
||||
|
||||
counter = 1
|
||||
power = 1
|
||||
while counter < (10 * power):
|
||||
result = filename[:(6 - power + 1)] + "~" + str(counter) + "." + extension
|
||||
if result not in existingFilenames:
|
||||
return result
|
||||
counter += 1
|
||||
if counter == 10 * power:
|
||||
power += 1
|
||||
|
||||
raise ValueError("Can't create a collision free filename")
|
||||
@@ -1,286 +0,0 @@
|
||||
from __future__ import absolute_import
|
||||
# coding=utf-8
|
||||
__author__ = "Gina Häußge <osd@foosel.net>"
|
||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||
|
||||
|
||||
import time
|
||||
import os
|
||||
import re
|
||||
import threading
|
||||
import math
|
||||
|
||||
from octoprint.settings import settings
|
||||
|
||||
class VirtualPrinter():
|
||||
def __init__(self):
|
||||
self.readList = ['start\n', 'Marlin: Virtual Marlin!\n', '\x80\n', 'SD init fail\n'] # no sd card as default startup scenario
|
||||
self.temp = 0.0
|
||||
self.targetTemp = 0.0
|
||||
self.lastTempAt = time.time()
|
||||
self.bedTemp = 1.0
|
||||
self.bedTargetTemp = 1.0
|
||||
|
||||
self._virtualSd = settings().getBaseFolder("virtualSd")
|
||||
self._sdCardReady = False
|
||||
self._sdPrinter = None
|
||||
self._sdPrintingSemaphore = threading.Event()
|
||||
self._selectedSdFile = None
|
||||
self._selectedSdFileSize = None
|
||||
self._selectedSdFilePos = None
|
||||
self._writingToSd = False
|
||||
self._newSdFilePos = None
|
||||
|
||||
self.currentLine = 0
|
||||
self.lastN = 0
|
||||
|
||||
waitThread = threading.Thread(target=self._sendWaitAfterTimeout)
|
||||
waitThread.start()
|
||||
|
||||
def write(self, data):
|
||||
if self.readList is None:
|
||||
return
|
||||
|
||||
data = data.strip()
|
||||
|
||||
# strip checksum
|
||||
if "*" in data:
|
||||
data = data[:data.rfind("*")]
|
||||
self.currentLine += 1
|
||||
elif settings().getBoolean(["devel", "virtualPrinter", "forceChecksum"]):
|
||||
self.readList.append("Error: Missing checksum")
|
||||
return
|
||||
|
||||
# track N = N + 1
|
||||
if data.startswith("N") and "M110" in data:
|
||||
linenumber = int(re.search("N([0-9]+)", data).group(1))
|
||||
self.lastN = linenumber
|
||||
self.currentLine = linenumber
|
||||
return
|
||||
elif data.startswith("N"):
|
||||
linenumber = int(re.search("N([0-9]+)", data).group(1))
|
||||
expected = self.lastN + 1
|
||||
if linenumber != expected:
|
||||
self.readList.append("Error: expected line %d got %d" % (expected, linenumber))
|
||||
self.readList.append("Resend:%d" % expected)
|
||||
if settings().getBoolean(["devel", "virtualPrinter", "okAfterResend"]):
|
||||
self.readList.append("ok")
|
||||
return
|
||||
elif self.currentLine == 100:
|
||||
# simulate a resend at line 100 of the last 5 lines
|
||||
self.lastN = 94
|
||||
self.readList.append("Error: Line Number is not Last Line Number\n")
|
||||
self.readList.append("rs %d\n" % (self.currentLine - 5))
|
||||
if settings().getBoolean(["devel", "virtualPrinter", "okAfterResend"]):
|
||||
self.readList.append("ok")
|
||||
return
|
||||
else:
|
||||
self.lastN = linenumber
|
||||
data = data.split(None, 1)[1].strip()
|
||||
|
||||
data += "\n"
|
||||
|
||||
# shortcut for writing to SD
|
||||
if self._writingToSd and not self._selectedSdFile is None and not "M29" in data:
|
||||
with open(self._selectedSdFile, "a") as f:
|
||||
f.write(data)
|
||||
self._sendOk()
|
||||
return
|
||||
|
||||
#print "Send: %s" % (data.rstrip())
|
||||
if 'M104' in data or 'M109' in data:
|
||||
try:
|
||||
self.targetTemp = float(re.search('S([0-9]+)', data).group(1))
|
||||
except:
|
||||
pass
|
||||
if 'M140' in data or 'M190' in data:
|
||||
try:
|
||||
self.bedTargetTemp = float(re.search('S([0-9]+)', data).group(1))
|
||||
except:
|
||||
pass
|
||||
|
||||
if 'M105' in data:
|
||||
# send simulated temperature data
|
||||
self.readList.append("ok T:%.2f /%.2f B:%.2f /%.2f @:64\n" % (self.temp, self.targetTemp, self.bedTemp, self.bedTargetTemp))
|
||||
elif 'M20' in data:
|
||||
if self._sdCardReady:
|
||||
self._listSd()
|
||||
elif 'M21' in data:
|
||||
self._sdCardReady = True
|
||||
self.readList.append("SD card ok")
|
||||
elif 'M22' in data:
|
||||
self._sdCardReady = False
|
||||
elif 'M23' in data:
|
||||
if self._sdCardReady:
|
||||
filename = data.split(None, 1)[1].strip()
|
||||
self._selectSdFile(filename)
|
||||
elif 'M24' in data:
|
||||
if self._sdCardReady:
|
||||
self._startSdPrint()
|
||||
elif 'M25' in data:
|
||||
if self._sdCardReady:
|
||||
self._pauseSdPrint()
|
||||
elif 'M26' in data:
|
||||
if self._sdCardReady:
|
||||
pos = int(re.search("S([0-9]+)", data).group(1))
|
||||
self._setSdPos(pos)
|
||||
elif 'M27' in data:
|
||||
if self._sdCardReady:
|
||||
self._reportSdStatus()
|
||||
elif 'M28' in data:
|
||||
if self._sdCardReady:
|
||||
filename = data.split(None, 1)[1].strip()
|
||||
self._writeSdFile(filename)
|
||||
elif 'M29' in data:
|
||||
if self._sdCardReady:
|
||||
self._finishSdFile()
|
||||
elif 'M30' in data:
|
||||
if self._sdCardReady:
|
||||
filename = data.split(None, 1)[1].strip()
|
||||
self._deleteSdFile(filename)
|
||||
elif "M114" in data:
|
||||
# send dummy position report
|
||||
self.readList.append("ok C: X:10.00 Y:3.20 Z:5.20 E:1.24")
|
||||
elif "M117" in data:
|
||||
# we'll just use this to echo a message, to allow playing around with pause triggers
|
||||
self.readList.append("ok %s" % re.search("M117\s+(.*)", data).group(1))
|
||||
elif "M999" in data:
|
||||
# mirror Marlin behaviour
|
||||
self.readList.append("Resend: 1")
|
||||
elif len(data.strip()) > 0:
|
||||
self._sendOk()
|
||||
|
||||
def _listSd(self):
|
||||
self.readList.append("Begin file list")
|
||||
for osFile in os.listdir(self._virtualSd):
|
||||
self.readList.append(osFile.upper())
|
||||
self.readList.append("End file list")
|
||||
self._sendOk()
|
||||
|
||||
def _selectSdFile(self, filename):
|
||||
file = os.path.join(self._virtualSd, filename).lower()
|
||||
if not os.path.exists(file) or not os.path.isfile(file):
|
||||
self.readList.append("open failed, File: %s." % filename)
|
||||
else:
|
||||
self._selectedSdFile = file
|
||||
self._selectedSdFileSize = os.stat(file).st_size
|
||||
self.readList.append("File opened: %s Size: %d" % (filename, self._selectedSdFileSize))
|
||||
self.readList.append("File selected")
|
||||
|
||||
def _startSdPrint(self):
|
||||
if self._selectedSdFile is not None:
|
||||
if self._sdPrinter is None:
|
||||
self._sdPrinter = threading.Thread(target=self._sdPrintingWorker)
|
||||
self._sdPrinter.start()
|
||||
self._sdPrintingSemaphore.set()
|
||||
self._sendOk()
|
||||
|
||||
def _pauseSdPrint(self):
|
||||
self._sdPrintingSemaphore.clear()
|
||||
self._sendOk()
|
||||
|
||||
def _setSdPos(self, pos):
|
||||
self._newSdFilePos = pos
|
||||
|
||||
def _reportSdStatus(self):
|
||||
if self._sdPrinter is not None and self._sdPrintingSemaphore.is_set:
|
||||
self.readList.append("SD printing byte %d/%d" % (self._selectedSdFilePos, self._selectedSdFileSize))
|
||||
else:
|
||||
self.readList.append("Not SD printing")
|
||||
|
||||
def _writeSdFile(self, filename):
|
||||
file = os.path.join(self._virtualSd, filename).lower()
|
||||
if os.path.exists(file):
|
||||
if os.path.isfile(file):
|
||||
os.remove(file)
|
||||
else:
|
||||
self.readList.append("error writing to file")
|
||||
|
||||
self._writingToSd = True
|
||||
self._selectedSdFile = file
|
||||
self.readList.append("Writing to file: %s" % filename)
|
||||
self._sendOk()
|
||||
|
||||
def _finishSdFile(self):
|
||||
self._writingToSd = False
|
||||
self._selectedSdFile = None
|
||||
self._sendOk()
|
||||
|
||||
def _sdPrintingWorker(self):
|
||||
self._selectedSdFilePos = 0
|
||||
with open(self._selectedSdFile, "r") as f:
|
||||
for line in f:
|
||||
# reset position if requested by client
|
||||
if self._newSdFilePos is not None:
|
||||
f.seek(self._newSdFilePos)
|
||||
self._newSdFilePos = None
|
||||
|
||||
# read current file position
|
||||
self._selectedSdFilePos = f.tell()
|
||||
|
||||
# if we are paused, wait for unpausing
|
||||
self._sdPrintingSemaphore.wait()
|
||||
|
||||
# set target temps
|
||||
if 'M104' in line or 'M109' in line:
|
||||
try:
|
||||
self.targetTemp = float(re.search('S([0-9]+)', line).group(1))
|
||||
except:
|
||||
pass
|
||||
if 'M140' in line or 'M190' in line:
|
||||
try:
|
||||
self.bedTargetTemp = float(re.search('S([0-9]+)', line).group(1))
|
||||
except:
|
||||
pass
|
||||
|
||||
time.sleep(0.01)
|
||||
|
||||
self._sdPrintingSemaphore.clear()
|
||||
self._selectedSdFilePos = 0
|
||||
self._sdPrinter = None
|
||||
self.readList.append("Done printing file")
|
||||
|
||||
def _deleteSdFile(self, filename):
|
||||
file = os.path.join(self._virtualSd, filename)
|
||||
if os.path.exists(file) and os.path.isfile(file):
|
||||
os.remove(file)
|
||||
self._sendOk()
|
||||
|
||||
def readline(self):
|
||||
if self.readList is None:
|
||||
return ''
|
||||
n = 0
|
||||
timeDiff = self.lastTempAt - time.time()
|
||||
self.lastTempAt = time.time()
|
||||
if abs(self.temp - self.targetTemp) > 1:
|
||||
self.temp += math.copysign(timeDiff * 10, self.targetTemp - self.temp)
|
||||
if self.temp < 0:
|
||||
self.temp = 0
|
||||
if abs(self.bedTemp - self.bedTargetTemp) > 1:
|
||||
self.bedTemp += math.copysign(timeDiff * 10, self.bedTargetTemp - self.bedTemp)
|
||||
if self.bedTemp < 0:
|
||||
self.bedTemp = 0
|
||||
while len(self.readList) < 1:
|
||||
time.sleep(0.1)
|
||||
n += 1
|
||||
if n == 20:
|
||||
return ''
|
||||
if self.readList is None:
|
||||
return ''
|
||||
time.sleep(0.001)
|
||||
return self.readList.pop(0)
|
||||
|
||||
def close(self):
|
||||
self.readList = None
|
||||
|
||||
def _sendOk(self):
|
||||
if settings().getBoolean(["devel", "virtualPrinter", "okWithLinenumber"]):
|
||||
self.readList.append("ok %d" % self.lastN)
|
||||
else:
|
||||
self.readList.append("ok")
|
||||
|
||||
def _sendWaitAfterTimeout(self, timeout=5):
|
||||
time.sleep(timeout)
|
||||
if self.readList is not None:
|
||||
self.readList.append("wait")
|
||||
|
||||
@@ -6,3 +6,10 @@ PyYAML==3.10
|
||||
Flask-Login==0.2.2
|
||||
Flask-Principal==0.3.5
|
||||
netaddr>=0.7.10
|
||||
mock>=1.0.1
|
||||
nose>=1.3.0
|
||||
watchdog
|
||||
sarge
|
||||
|
||||
sphinxcontrib-httpdomain
|
||||
sphinx_rtd_theme
|
||||
@@ -0,0 +1,6 @@
|
||||
mock>=1.0.1
|
||||
nose>=1.3.0
|
||||
sphinxcontrib-httpdomain
|
||||
sphinx_rtd_theme
|
||||
po2json
|
||||
ddt
|
||||
@@ -1,10 +1,15 @@
|
||||
flask==0.9
|
||||
werkzeug==0.8.3
|
||||
tornado==3.0.2
|
||||
tornado==4.0.1
|
||||
sockjs-tornado>=1.0.0
|
||||
PyYAML==3.10
|
||||
Flask-Login==0.2.2
|
||||
Flask-Principal==0.3.5
|
||||
numpy>=1.6.2
|
||||
pyserial>=2.6
|
||||
netaddr>=0.7.10
|
||||
Flask-Babel==0.9
|
||||
pyserial
|
||||
netaddr
|
||||
watchdog
|
||||
sarge
|
||||
netifaces
|
||||
pylru
|
||||
rsa
|
||||
@@ -1,65 +1,22 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from octoprint.daemon import Daemon
|
||||
from octoprint.server import Server
|
||||
|
||||
class Main(Daemon):
|
||||
def __init__(self, pidfile, configfile, basedir, host, port, debug):
|
||||
Daemon.__init__(self, pidfile)
|
||||
basedir = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
self._configfile = configfile
|
||||
self._basedir = basedir
|
||||
self._host = host
|
||||
self._port = port
|
||||
self._debug = debug
|
||||
old = os.path.join(basedir, "octoprint")
|
||||
if os.path.exists(old):
|
||||
# rename left-overs from old file structure
|
||||
print """
|
||||
Found left-overs from old file structure, renaming to
|
||||
"octoprint.backup". Please remove this manually (I don't
|
||||
dare to do so myself since you might have changes in there
|
||||
I don't know anything about).
|
||||
"""
|
||||
os.rename(old, os.path.join(basedir, "octoprint.backup"))
|
||||
|
||||
def run(self):
|
||||
octoprint = Server(self._configfile, self._basedir, self._host, self._port, self._debug)
|
||||
octoprint.run()
|
||||
sys.path.insert(0, os.path.join(basedir, "src"))
|
||||
|
||||
def main():
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser(prog="run")
|
||||
|
||||
parser.add_argument("-d", "--debug", action="store_true", dest="debug",
|
||||
help="Enable debug mode")
|
||||
|
||||
parser.add_argument("--host", action="store", type=str, dest="host",
|
||||
help="Specify the host on which to bind the server")
|
||||
parser.add_argument("--port", action="store", type=int, dest="port",
|
||||
help="Specify the port on which to bind the server")
|
||||
|
||||
parser.add_argument("-c", "--config", action="store", dest="config",
|
||||
help="Specify the config file to use. OctoPrint needs to have write access for the settings dialog to work. Defaults to ~/.octoprint/config.yaml")
|
||||
parser.add_argument("-b", "--basedir", action="store", dest="basedir",
|
||||
help="Specify the basedir to use for uploads, timelapses etc. OctoPrint needs to have write access. Defaults to ~/.octoprint")
|
||||
|
||||
parser.add_argument("--daemon", action="store", type=str, choices=["start", "stop", "restart"],
|
||||
help="Daemonize/control daemonized OctoPrint instance (only supported under Linux right now)")
|
||||
parser.add_argument("--pid", action="store", type=str, dest="pidfile", default="/tmp/octoprint.pid",
|
||||
help="Pidfile to use for daemonizing, defaults to /tmp/octoprint.pid")
|
||||
|
||||
parser.add_argument("--iknowwhatimdoing", action="store_true", dest="allowRoot",
|
||||
help="Allow OctoPrint to run as user root")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.daemon:
|
||||
if sys.platform == "darwin" or sys.platform == "win32":
|
||||
print >> sys.stderr, "Sorry, daemon mode is only supported under Linux right now"
|
||||
sys.exit(2)
|
||||
|
||||
daemon = Main(args.pidfile, args.config, args.basedir, args.host, args.port, args.debug)
|
||||
if "start" == args.daemon:
|
||||
daemon.start()
|
||||
elif "stop" == args.daemon:
|
||||
daemon.stop()
|
||||
elif "restart" == args.daemon:
|
||||
daemon.restart()
|
||||
else:
|
||||
octoprint = Server(args.config, args.basedir, args.host, args.port, args.debug, args.allowRoot)
|
||||
octoprint.run()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
import octoprint
|
||||
octoprint.main()
|
||||
@@ -0,0 +1,19 @@
|
||||
# Configuration for /etc/init.d/octoprint
|
||||
|
||||
# The init.d script will only run if this variable non-empty.
|
||||
OCTOPRINT_USER=pi
|
||||
|
||||
# On what port to run daemon, default is 5000
|
||||
PORT=5000
|
||||
|
||||
# Path to the OctoPrint executable, use this to override the default setting "/usr/bin/octoprint"
|
||||
#DAEMON=/path/to/octoprint/executable
|
||||
|
||||
# What arguments to pass to octoprint, usually no need to touch this
|
||||
DAEMON_ARGS="--port=$PORT"
|
||||
|
||||
# Umask of files octoprint generates, Change this to 000 if running octoprint as its own, separate user
|
||||
UMASK=022
|
||||
|
||||
# Should we run at startup?
|
||||
START=yes
|
||||
@@ -0,0 +1,142 @@
|
||||
#!/bin/sh
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: octoprint
|
||||
# Required-Start: $local_fs networking
|
||||
# Required-Stop:
|
||||
# Should-Start:
|
||||
# Should-Stop:
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: OctoPrint daemon
|
||||
# Description: Starts the OctoPrint daemon with the user specified in
|
||||
# /etc/default/octoprint.
|
||||
### END INIT INFO
|
||||
|
||||
# Author: Sami Olmari
|
||||
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
DESC="Octoprint Daemon"
|
||||
NAME="Octoprint"
|
||||
DAEMON=/usr/local/bin/octoprint
|
||||
NICE=-10
|
||||
PIDFILE=/var/run/$NAME.pid
|
||||
PKGNAME=octoprint
|
||||
SCRIPTNAME=/etc/init.d/$PKGNAME
|
||||
|
||||
# Read configuration variable file if it is present
|
||||
[ -r /etc/default/$PKGNAME ] && . /etc/default/$PKGNAME
|
||||
|
||||
# Exit if the octoprint is not installed
|
||||
[ -x "$DAEMON" ] || exit 0
|
||||
|
||||
# Load the VERBOSE setting and other rcS variables
|
||||
[ -f /etc/default/rcS ] && . /etc/default/rcS
|
||||
|
||||
# Define LSB log_* functions.
|
||||
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
if [ -z "$START" -o "$START" != "yes" ]
|
||||
then
|
||||
log_warning_msg "Not starting $PKGNAME, edit /etc/default/$PKGNAME to start it."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -z "$OCTOPRINT_USER" ]
|
||||
then
|
||||
log_warning_msg "Not starting $PKGNAME, OCTOPRINT_USER not set in /etc/default/$PKGNAME."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
#
|
||||
# Function to verify if a pid is alive
|
||||
#
|
||||
is_alive()
|
||||
{
|
||||
pid=`cat $1` > /dev/null 2>&1
|
||||
kill -0 $pid > /dev/null 2>&1
|
||||
return $?
|
||||
}
|
||||
|
||||
#
|
||||
# Function that starts the daemon/service
|
||||
#
|
||||
do_start()
|
||||
{
|
||||
# Return
|
||||
# 0 if daemon has been started
|
||||
# 1 if daemon was already running
|
||||
# 2 if daemon could not be started
|
||||
|
||||
is_alive $PIDFILE
|
||||
RETVAL="$?"
|
||||
|
||||
if [ $RETVAL != 0 ]; then
|
||||
start-stop-daemon --start --background --quiet --pidfile $PIDFILE --make-pidfile --nicelevel $NICE\
|
||||
--exec $DAEMON --chuid $OCTOPRINT_USER --user $OCTOPRINT_USER --umask $UMASK -- $DAEMON_ARGS
|
||||
RETVAL="$?"
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Function that stops the daemon/service
|
||||
#
|
||||
do_stop()
|
||||
{
|
||||
# Return
|
||||
# 0 if daemon has been stopped
|
||||
# 1 if daemon was already stopped
|
||||
# 2 if daemon could not be stopped
|
||||
# other if a failure occurred
|
||||
|
||||
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --user $OCTOPRINT_USER --pidfile $PIDFILE
|
||||
RETVAL="$?"
|
||||
[ "$RETVAL" = "2" ] && return 2
|
||||
|
||||
rm -f $PIDFILE
|
||||
|
||||
[ "$RETVAL" = "0" ] && return 0 || return 1
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
|
||||
do_start
|
||||
case "$?" in
|
||||
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
||||
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
||||
esac
|
||||
;;
|
||||
stop)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
|
||||
do_stop
|
||||
case "$?" in
|
||||
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
||||
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
||||
esac
|
||||
;;
|
||||
restart)
|
||||
log_daemon_msg "Restarting $DESC" "$NAME"
|
||||
do_stop
|
||||
case "$?" in
|
||||
0|1)
|
||||
do_start
|
||||
case "$?" in
|
||||
0) log_end_msg 0 ;;
|
||||
1) log_end_msg 1 ;; # Old process is still running
|
||||
*) log_end_msg 1 ;; # Failed to start
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
# Failed to stop
|
||||
log_end_msg 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2
|
||||
exit 3
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -1,13 +1,260 @@
|
||||
# coding=utf-8
|
||||
#!/usr/bin/env python
|
||||
|
||||
from setuptools import setup, find_packages
|
||||
import versioneer
|
||||
versioneer.VCS = 'git'
|
||||
versioneer.versionfile_source = 'src/octoprint/_version.py'
|
||||
versioneer.versionfile_build = 'octoprint/_version.py'
|
||||
versioneer.tag_prefix = ''
|
||||
versioneer.parentdir_prefix = ''
|
||||
versioneer.lookupfile = '.versioneer-lookup'
|
||||
|
||||
from setuptools import setup, find_packages, Command
|
||||
import os
|
||||
import shutil
|
||||
import glob
|
||||
|
||||
I18N_MAPPING_FILE = "babel.cfg"
|
||||
I18N_DOMAIN = "messages"
|
||||
I18N_INPUT_DIRS = "."
|
||||
I18N_OUTPUT_DIR_PY = os.path.join("src", "octoprint", "translations")
|
||||
I18N_OUTPUT_DIR_JS = os.path.join("src", "octoprint", "static", "js", "i18n")
|
||||
I18N_POT_FILE = os.path.join(I18N_OUTPUT_DIR_PY, "messages.pot")
|
||||
|
||||
def package_data_dirs(source, sub_folders):
|
||||
dirs = []
|
||||
|
||||
for d in sub_folders:
|
||||
for dirname, _, files in os.walk(os.path.join(source, d)):
|
||||
dirname = os.path.relpath(dirname, source)
|
||||
for f in files:
|
||||
dirs.append(os.path.join(dirname, f))
|
||||
|
||||
return dirs
|
||||
|
||||
|
||||
def _recursively_handle_files(directory, file_matcher, folder_handler=None, file_handler=None):
|
||||
applied_handler = False
|
||||
|
||||
for filename in os.listdir(directory):
|
||||
path = os.path.join(directory, filename)
|
||||
|
||||
if file_handler is not None and file_matcher(filename):
|
||||
file_handler(path)
|
||||
applied_handler = True
|
||||
|
||||
elif os.path.isdir(path):
|
||||
sub_applied_handler = _recursively_handle_files(path, file_matcher, folder_handler=folder_handler, file_handler=file_handler)
|
||||
if sub_applied_handler:
|
||||
applied_handler = True
|
||||
|
||||
if folder_handler is not None:
|
||||
folder_handler(path, sub_applied_handler)
|
||||
|
||||
return applied_handler
|
||||
|
||||
class CleanCommand(Command):
|
||||
description = "clean build artifacts"
|
||||
user_options = []
|
||||
boolean_options = []
|
||||
|
||||
def initialize_options(self):
|
||||
pass
|
||||
|
||||
def finalize_options(self):
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
# build folder
|
||||
if os.path.exists('build'):
|
||||
print "Deleting build directory"
|
||||
shutil.rmtree('build')
|
||||
|
||||
# eggs
|
||||
eggs = glob.glob('OctoPrint*.egg-info')
|
||||
for egg in eggs:
|
||||
print "Deleting %s directory" % egg
|
||||
shutil.rmtree(egg)
|
||||
|
||||
# pyc files
|
||||
def delete_folder_if_empty(path, applied_handler):
|
||||
if not applied_handler:
|
||||
return
|
||||
if len(os.listdir(path)) == 0:
|
||||
shutil.rmtree(path)
|
||||
print "Deleted %s since it was empty" % path
|
||||
|
||||
def delete_file(path):
|
||||
os.remove(path)
|
||||
print "Deleted %s" % path
|
||||
|
||||
import fnmatch
|
||||
_recursively_handle_files(
|
||||
os.path.abspath("src"),
|
||||
lambda name: fnmatch.fnmatch(name.lower(), "*.pyc"),
|
||||
folder_handler=delete_folder_if_empty,
|
||||
file_handler=delete_file
|
||||
)
|
||||
|
||||
# pyc files
|
||||
def delete_folder_if_empty(path, applied_handler):
|
||||
if not applied_handler:
|
||||
return
|
||||
if len(os.listdir(path)) == 0:
|
||||
shutil.rmtree(path)
|
||||
print "Deleted %s since it was empty" % path
|
||||
|
||||
def delete_file(path):
|
||||
os.remove(path)
|
||||
print "Deleted %s" % path
|
||||
|
||||
import fnmatch
|
||||
_recursively_handle_files(
|
||||
os.path.abspath("src"),
|
||||
lambda name: fnmatch.fnmatch(name.lower(), "*.pyc"),
|
||||
folder_handler=delete_folder_if_empty,
|
||||
file_handler=delete_file
|
||||
)
|
||||
|
||||
|
||||
class NewTranslation(Command):
|
||||
description = "create a new translation"
|
||||
user_options = [
|
||||
('locale=', 'l', 'locale for the new translation'),
|
||||
]
|
||||
boolean_options = []
|
||||
|
||||
def __init__(self, dist, **kw):
|
||||
from babel.messages import frontend as babel
|
||||
self.babel_init_messages = babel.init_catalog(dist)
|
||||
Command.__init__(self, dist, **kw)
|
||||
|
||||
def initialize_options(self):
|
||||
self.locale = None
|
||||
self.babel_init_messages.initialize_options()
|
||||
|
||||
def finalize_options(self):
|
||||
self.babel_init_messages.locale = self.locale
|
||||
self.babel_init_messages.input_file = I18N_POT_FILE
|
||||
self.babel_init_messages.output_dir = I18N_OUTPUT_DIR_PY
|
||||
self.babel_init_messages.finalize_options()
|
||||
|
||||
def run(self):
|
||||
self.babel_init_messages.run()
|
||||
|
||||
|
||||
class ExtractTranslation(Command):
|
||||
description = "extract translations"
|
||||
user_options = []
|
||||
boolean_options = []
|
||||
|
||||
def __init__(self, dist, **kw):
|
||||
from babel.messages import frontend as babel
|
||||
self.babel_extract_messages = babel.extract_messages(dist)
|
||||
Command.__init__(self, dist, **kw)
|
||||
|
||||
def initialize_options(self):
|
||||
self.babel_extract_messages.initialize_options()
|
||||
|
||||
def finalize_options(self):
|
||||
self.babel_extract_messages.mapping_file = I18N_MAPPING_FILE
|
||||
self.babel_extract_messages.output_file = I18N_POT_FILE
|
||||
self.babel_extract_messages.input_dirs = I18N_INPUT_DIRS
|
||||
self.babel_extract_messages.msgid_bugs_address = "i18n@octoprint.org"
|
||||
self.babel_extract_messages.copyright_holder = "The OctoPrint Project"
|
||||
self.babel_extract_messages.finalize_options()
|
||||
|
||||
def run(self):
|
||||
self.babel_extract_messages.run()
|
||||
|
||||
|
||||
class RefreshTranslation(Command):
|
||||
description = "refresh translations"
|
||||
user_options = [
|
||||
('locale=', 'l', 'locale for the translation to refresh'),
|
||||
]
|
||||
boolean_options = []
|
||||
|
||||
def __init__(self, dist, **kw):
|
||||
from babel.messages import frontend as babel
|
||||
self.babel_extract_messages = babel.extract_messages(dist)
|
||||
self.babel_update_messages = babel.update_catalog(dist)
|
||||
Command.__init__(self, dist, **kw)
|
||||
|
||||
def initialize_options(self):
|
||||
self.locale = None
|
||||
self.babel_extract_messages.initialize_options()
|
||||
self.babel_update_messages.initialize_options()
|
||||
|
||||
def finalize_options(self):
|
||||
self.babel_extract_messages.mapping_file = I18N_MAPPING_FILE
|
||||
self.babel_extract_messages.output_file = I18N_POT_FILE
|
||||
self.babel_extract_messages.input_dirs = I18N_INPUT_DIRS
|
||||
self.babel_extract_messages.msgid_bugs_address = "i18n@octoprint.org"
|
||||
self.babel_extract_messages.copyright_holder = "The OctoPrint Project"
|
||||
self.babel_extract_messages.finalize_options()
|
||||
|
||||
self.babel_update_messages.input_file = I18N_MAPPING_FILE
|
||||
self.babel_update_messages.output_dir = I18N_OUTPUT_DIR_PY
|
||||
self.babel_update_messages.locale = self.locale
|
||||
|
||||
def run(self):
|
||||
self.babel_extract_messages.run()
|
||||
self.babel_update_messages.run()
|
||||
|
||||
|
||||
class CompileTranslation(Command):
|
||||
description = "compile translations"
|
||||
user_options = []
|
||||
boolean_options = []
|
||||
|
||||
def __init__(self, dist, **kw):
|
||||
from babel.messages import frontend as babel
|
||||
self.babel_compile_messages = babel.compile_catalog(dist)
|
||||
Command.__init__(self, dist, **kw)
|
||||
|
||||
def initialize_options(self):
|
||||
self.babel_compile_messages.initialize_options()
|
||||
|
||||
def finalize_options(self):
|
||||
self.babel_compile_messages.directory = I18N_OUTPUT_DIR_PY
|
||||
|
||||
def run(self):
|
||||
self.babel_compile_messages.run()
|
||||
|
||||
import po2json
|
||||
|
||||
for lang_code in os.listdir(I18N_OUTPUT_DIR_PY):
|
||||
full_path = os.path.join(I18N_OUTPUT_DIR_PY, lang_code)
|
||||
|
||||
if os.path.isdir(full_path):
|
||||
client_po_dir = os.path.join(full_path, "LC_MESSAGES")
|
||||
|
||||
po2json.update_js_file(
|
||||
"%s/%s.po" % (client_po_dir, I18N_DOMAIN),
|
||||
lang_code,
|
||||
I18N_OUTPUT_DIR_JS,
|
||||
I18N_DOMAIN
|
||||
)
|
||||
|
||||
|
||||
def get_cmdclass():
|
||||
cmdclass = versioneer.get_cmdclass()
|
||||
cmdclass.update({
|
||||
'clean': CleanCommand,
|
||||
'babel_new': NewTranslation,
|
||||
'babel_extract': ExtractTranslation,
|
||||
'babel_refresh': RefreshTranslation,
|
||||
'babel_compile': CompileTranslation
|
||||
})
|
||||
return cmdclass
|
||||
|
||||
VERSION = "1.0.0-rc1"
|
||||
|
||||
def params():
|
||||
name = "OctoPrint"
|
||||
version = VERSION
|
||||
version = versioneer.get_version()
|
||||
cmdclass = get_cmdclass()
|
||||
|
||||
description = "A responsive web interface for 3D printers"
|
||||
long_description = open("README.md").read()
|
||||
classifiers = [
|
||||
@@ -34,11 +281,24 @@ def params():
|
||||
url = "http://octoprint.org"
|
||||
license = "AGPLv3"
|
||||
|
||||
packages = find_packages()
|
||||
packages = find_packages(where="src")
|
||||
package_dir = {"octoprint": "src/octoprint"}
|
||||
package_data = {"octoprint": package_data_dirs('src/octoprint', ['static', 'templates', 'plugins'])}
|
||||
|
||||
include_package_data = True
|
||||
zip_safe = False
|
||||
install_requires = open("requirements.txt").read().split("\n")
|
||||
|
||||
entry_points = {
|
||||
"console_scripts": [
|
||||
"octoprint = octoprint:main"
|
||||
]
|
||||
}
|
||||
|
||||
#scripts = {
|
||||
# "scripts/octoprint.init": "/etc/init.d/octoprint"
|
||||
#}
|
||||
|
||||
return locals()
|
||||
|
||||
setup(**params())
|
||||
@@ -0,0 +1,84 @@
|
||||
#!/usr/bin/env python
|
||||
import sys
|
||||
from octoprint.daemon import Daemon
|
||||
from octoprint.server import Server
|
||||
|
||||
#~~ version
|
||||
|
||||
from ._version import get_versions
|
||||
__version__ = get_versions()['version']
|
||||
del get_versions
|
||||
|
||||
#~~ main class
|
||||
|
||||
class Main(Daemon):
|
||||
def __init__(self, pidfile, configfile, basedir, host, port, debug, allowRoot, logConf):
|
||||
Daemon.__init__(self, pidfile)
|
||||
|
||||
self._configfile = configfile
|
||||
self._basedir = basedir
|
||||
self._host = host
|
||||
self._port = port
|
||||
self._debug = debug
|
||||
self._allowRoot = allowRoot
|
||||
self._logConf = logConf
|
||||
|
||||
def run(self):
|
||||
octoprint = Server(self._configfile, self._basedir, self._host, self._port, self._debug, self._allowRoot)
|
||||
octoprint.run()
|
||||
|
||||
def main():
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser(prog="run")
|
||||
|
||||
parser.add_argument("-v", "--version", action="store_true", dest="version",
|
||||
help="Output OctoPrint's version and exit")
|
||||
|
||||
parser.add_argument("-d", "--debug", action="store_true", dest="debug",
|
||||
help="Enable debug mode")
|
||||
|
||||
parser.add_argument("--host", action="store", type=str, dest="host",
|
||||
help="Specify the host on which to bind the server")
|
||||
parser.add_argument("--port", action="store", type=int, dest="port",
|
||||
help="Specify the port on which to bind the server")
|
||||
|
||||
parser.add_argument("-c", "--config", action="store", dest="config",
|
||||
help="Specify the config file to use. OctoPrint needs to have write access for the settings dialog to work. Defaults to ~/.octoprint/config.yaml")
|
||||
parser.add_argument("-b", "--basedir", action="store", dest="basedir",
|
||||
help="Specify the basedir to use for uploads, timelapses etc. OctoPrint needs to have write access. Defaults to ~/.octoprint")
|
||||
parser.add_argument("--logging", action="store", dest="logConf",
|
||||
help="Specify the config file to use for configuring logging. Defaults to ~/.octoprint/logging.yaml")
|
||||
|
||||
parser.add_argument("--daemon", action="store", type=str, choices=["start", "stop", "restart"],
|
||||
help="Daemonize/control daemonized OctoPrint instance (only supported under Linux right now)")
|
||||
parser.add_argument("--pid", action="store", type=str, dest="pidfile", default="/tmp/octoprint.pid",
|
||||
help="Pidfile to use for daemonizing, defaults to /tmp/octoprint.pid")
|
||||
|
||||
parser.add_argument("--iknowwhatimdoing", action="store_true", dest="allowRoot",
|
||||
help="Allow OctoPrint to run as user root")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.version:
|
||||
print "OctoPrint version %s" % __version__
|
||||
sys.exit(0)
|
||||
|
||||
if args.daemon:
|
||||
if sys.platform == "darwin" or sys.platform == "win32":
|
||||
print >> sys.stderr, "Sorry, daemon mode is only supported under Linux right now"
|
||||
sys.exit(2)
|
||||
|
||||
daemon = Main(args.pidfile, args.config, args.basedir, args.host, args.port, args.debug, args.allowRoot, args.logConf)
|
||||
if "start" == args.daemon:
|
||||
daemon.start()
|
||||
elif "stop" == args.daemon:
|
||||
daemon.stop()
|
||||
elif "restart" == args.daemon:
|
||||
daemon.restart()
|
||||
else:
|
||||
octoprint = Server(args.config, args.basedir, args.host, args.port, args.debug, args.allowRoot, args.logConf)
|
||||
octoprint.run()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,278 @@
|
||||
|
||||
# This file helps to compute a version number in source trees obtained from
|
||||
# git-archive tarball (such as those provided by githubs download-from-tag
|
||||
# feature). Distribution tarballs (build by setup.py sdist) and build
|
||||
# directories (produced by setup.py build) will contain a much shorter file
|
||||
# that just contains the computed version number.
|
||||
|
||||
# This file is released into the public domain. Generated by
|
||||
# versioneer-0.10 (https://github.com/warner/python-versioneer)
|
||||
|
||||
# these strings will be replaced by git during git-archive
|
||||
git_refnames = "$Format:%d$"
|
||||
git_full = "$Format:%H$"
|
||||
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
import errno
|
||||
|
||||
|
||||
def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False):
|
||||
assert isinstance(commands, list)
|
||||
p = None
|
||||
for c in commands:
|
||||
try:
|
||||
# remember shell=False, so use git.cmd on windows, not just git
|
||||
p = subprocess.Popen([c] + args, cwd=cwd, stdout=subprocess.PIPE,
|
||||
stderr=(subprocess.PIPE if hide_stderr
|
||||
else None))
|
||||
break
|
||||
except EnvironmentError:
|
||||
e = sys.exc_info()[1]
|
||||
if e.errno == errno.ENOENT:
|
||||
continue
|
||||
if verbose:
|
||||
print("unable to run %s" % args[0])
|
||||
print(e)
|
||||
return None
|
||||
else:
|
||||
if verbose:
|
||||
print("unable to find command, tried %s" % (commands,))
|
||||
return None
|
||||
stdout = p.communicate()[0].strip()
|
||||
if sys.version >= '3':
|
||||
stdout = stdout.decode()
|
||||
if p.returncode != 0:
|
||||
if verbose:
|
||||
print("unable to run %s (error)" % args[0])
|
||||
return None
|
||||
return stdout
|
||||
|
||||
|
||||
import sys
|
||||
import re
|
||||
import os.path
|
||||
|
||||
def get_gits(root, verbose=False):
|
||||
if not os.path.exists(os.path.join(root, ".git")):
|
||||
if verbose:
|
||||
print("no .git in %s" % root)
|
||||
return None
|
||||
|
||||
GITS = ["git"]
|
||||
if sys.platform == "win32":
|
||||
GITS = ["git.cmd", "git.exe"]
|
||||
return GITS
|
||||
|
||||
|
||||
def get_expanded_variables(versionfile_abs):
|
||||
# the code embedded in _version.py can just fetch the value of these
|
||||
# variables. When used from setup.py, we don't want to import
|
||||
# _version.py, so we do it with a regexp instead. This function is not
|
||||
# used from _version.py.
|
||||
variables = {}
|
||||
try:
|
||||
f = open(versionfile_abs,"r")
|
||||
for line in f.readlines():
|
||||
if line.strip().startswith("git_refnames ="):
|
||||
mo = re.search(r'=\s*"(.*)"', line)
|
||||
if mo:
|
||||
variables["refnames"] = mo.group(1)
|
||||
if line.strip().startswith("git_full ="):
|
||||
mo = re.search(r'=\s*"(.*)"', line)
|
||||
if mo:
|
||||
variables["full"] = mo.group(1)
|
||||
f.close()
|
||||
except EnvironmentError:
|
||||
pass
|
||||
return variables
|
||||
|
||||
def versions_from_expanded_variables(variables, tag_prefix, verbose=False):
|
||||
refnames = variables["refnames"].strip()
|
||||
if refnames.startswith("$Format"):
|
||||
if verbose:
|
||||
print("variables are unexpanded, not using")
|
||||
return {} # unexpanded, so not in an unpacked git-archive tarball
|
||||
refs = set([r.strip() for r in refnames.strip("()").split(",")])
|
||||
# starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of
|
||||
# just "foo-1.0". If we see a "tag: " prefix, prefer those.
|
||||
TAG = "tag: "
|
||||
tags = set([r[len(TAG):] for r in refs if r.startswith(TAG)])
|
||||
if not tags:
|
||||
# Either we're using git < 1.8.3, or there really are no tags. We use
|
||||
# a heuristic: assume all version tags have a digit. The old git %d
|
||||
# expansion behaves like git log --decorate=short and strips out the
|
||||
# refs/heads/ and refs/tags/ prefixes that would let us distinguish
|
||||
# between branches and tags. By ignoring refnames without digits, we
|
||||
# filter out many common branch names like "release" and
|
||||
# "stabilization", as well as "HEAD" and "master".
|
||||
tags = set([r for r in refs if re.search(r'\d', r)])
|
||||
if verbose:
|
||||
print("discarding '%s', no digits" % ",".join(refs-tags))
|
||||
if verbose:
|
||||
print("likely tags: %s" % ",".join(sorted(tags)))
|
||||
for ref in sorted(tags):
|
||||
# sorting will prefer e.g. "2.0" over "2.0rc1"
|
||||
if ref.startswith(tag_prefix):
|
||||
r = ref[len(tag_prefix):]
|
||||
if verbose:
|
||||
print("picking %s" % r)
|
||||
return { "version": r,
|
||||
"full": variables["full"].strip() }
|
||||
# no suitable tags, so we use the full revision id
|
||||
if verbose:
|
||||
print("no suitable tags, using full revision id")
|
||||
return { "version": variables["full"].strip(),
|
||||
"full": variables["full"].strip() }
|
||||
|
||||
def versions_from_lookup(lookup, root, verbose=False):
|
||||
GITS = get_gits(root, verbose=verbose)
|
||||
if GITS is None:
|
||||
return {}
|
||||
|
||||
stdout = run_command(GITS, ["rev-parse", "--abbrev-ref", "HEAD"],
|
||||
cwd=root)
|
||||
if stdout is None:
|
||||
return {}
|
||||
|
||||
current_branch = stdout.strip()
|
||||
for matcher, tag, ref_commit in lookup:
|
||||
if matcher.match(current_branch):
|
||||
if tag is None or ref_commit is None:
|
||||
return {}
|
||||
|
||||
stdout = run_command(GITS, ["rev-list", "%s..HEAD" % ref_commit, "--count"], cwd=root)
|
||||
if stdout is None:
|
||||
return {}
|
||||
num_commits = stdout.strip()
|
||||
|
||||
stdout =run_command(GITS, ["rev-parse", "--short", "HEAD"], cwd=root)
|
||||
if stdout is None:
|
||||
return {}
|
||||
short_hash = stdout.strip()
|
||||
|
||||
stdout = run_command(GITS, ["describe", "--tags", "--dirty", "--always"], cwd=root)
|
||||
if stdout is None:
|
||||
return {}
|
||||
dirty = stdout.strip().endswith("-dirty")
|
||||
|
||||
stdout = run_command(GITS, ["rev-parse", "HEAD"], cwd=root)
|
||||
if stdout is None:
|
||||
return {}
|
||||
full = stdout.strip()
|
||||
|
||||
version = "%s-%s-g%s" % (tag, num_commits, short_hash)
|
||||
if dirty:
|
||||
version += "-dirty"
|
||||
full += "-dirty"
|
||||
return {"version": version, "full": full, "branch": current_branch}
|
||||
|
||||
return {}
|
||||
|
||||
def versions_from_vcs(tag_prefix, root, verbose=False):
|
||||
# this runs 'git' from the root of the source tree. This only gets called
|
||||
# if the git-archive 'subst' variables were *not* expanded, and
|
||||
# _version.py hasn't already been rewritten with a short version string,
|
||||
# meaning we're inside a checked out source tree.
|
||||
|
||||
GITS = get_gits(root, verbose=verbose)
|
||||
if GITS is None:
|
||||
return {}
|
||||
|
||||
stdout = run_command(GITS, ["describe", "--tags", "--dirty", "--always"],
|
||||
cwd=root)
|
||||
if stdout is None:
|
||||
return {}
|
||||
if not stdout.startswith(tag_prefix):
|
||||
if verbose:
|
||||
print("tag '%s' doesn't start with prefix '%s'" % (stdout, tag_prefix))
|
||||
return {}
|
||||
tag = stdout[len(tag_prefix):]
|
||||
stdout = run_command(GITS, ["rev-parse", "HEAD"], cwd=root)
|
||||
if stdout is None:
|
||||
return {}
|
||||
full = stdout.strip()
|
||||
if tag.endswith("-dirty"):
|
||||
full += "-dirty"
|
||||
|
||||
stdout = run_command(GITS, ["rev-parse", "--abbrev-ref", "HEAD"],
|
||||
cwd=root)
|
||||
if stdout is None:
|
||||
branch = None
|
||||
else:
|
||||
branch = stdout.strip()
|
||||
return {"version": tag, "full": full, "branch": branch}
|
||||
|
||||
|
||||
def versions_from_parentdir(parentdir_prefix, root, verbose=False):
|
||||
# Source tarballs conventionally unpack into a directory that includes
|
||||
# both the project name and a version string.
|
||||
dirname = os.path.basename(root)
|
||||
if not dirname.startswith(parentdir_prefix):
|
||||
if verbose:
|
||||
print("guessing rootdir is '%s', but '%s' doesn't start with prefix '%s'" %
|
||||
(root, dirname, parentdir_prefix))
|
||||
return None
|
||||
return {"version": dirname[len(parentdir_prefix):], "full": "", "branch": ""}
|
||||
|
||||
tag_prefix = ""
|
||||
parentdir_prefix = ""
|
||||
versionfile_source = "src/octoprint/_version.py"
|
||||
lookupfile = ".versioneer-lookup"
|
||||
|
||||
def parse_lookup_file(root, lookup_path=None):
|
||||
if not lookup_path:
|
||||
lookup_path = lookupfile
|
||||
if not lookup_path:
|
||||
return []
|
||||
|
||||
path = os.path.join(root, lookup_path)
|
||||
if not os.path.exists(path):
|
||||
return []
|
||||
|
||||
import re
|
||||
lookup = []
|
||||
with open(os.path.join(root, lookup_path), "r") as f:
|
||||
for line in f:
|
||||
if '#' in line:
|
||||
line = line[:line.rindex('#')]
|
||||
line = line.strip()
|
||||
try:
|
||||
split_line = line.split()
|
||||
if len(split_line) == 3:
|
||||
pattern, tag, ref_commit = split_line
|
||||
lookup.append([re.compile(pattern), tag, ref_commit])
|
||||
elif len(split_line) >= 1:
|
||||
lookup.append([re.compile(split_line[0]), None, None])
|
||||
except:
|
||||
break
|
||||
return lookup
|
||||
|
||||
def get_versions(default={"version": "unknown", "full": "", "branch": "unknown"}, lookup_path=None, verbose=False):
|
||||
# I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have
|
||||
# __file__, we can work backwards from there to the root. Some
|
||||
# py2exe/bbfreeze/non-CPython implementations don't do __file__, in which
|
||||
# case we can only use expanded variables.
|
||||
|
||||
variables = { "refnames": git_refnames, "full": git_full }
|
||||
ver = versions_from_expanded_variables(variables, tag_prefix, verbose)
|
||||
if ver:
|
||||
return ver
|
||||
|
||||
try:
|
||||
root = os.path.abspath(__file__)
|
||||
# versionfile_source is the relative path from the top of the source
|
||||
# tree (where the .git directory might live) to this file. Invert
|
||||
# this to find the root from __file__.
|
||||
for i in range(len(versionfile_source.split("/"))):
|
||||
root = os.path.dirname(root)
|
||||
except NameError:
|
||||
return default
|
||||
|
||||
lookup = parse_lookup_file(root, lookup_path=lookup_path)
|
||||
return (versions_from_lookup(lookup, root, verbose)
|
||||
or versions_from_vcs(tag_prefix, root, verbose)
|
||||
or versions_from_parentdir(parentdir_prefix, root, verbose)
|
||||
or default)
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
# coding=utf-8
|
||||
__author__ = "Gina Häußge <osd@foosel.net>"
|
||||
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
|
||||
__copyright__ = "Copyright (C) 2014 Gina Häußge - Released under terms of the AGPLv3 License"
|
||||
|
||||
|
||||
@@ -0,0 +1,589 @@
|
||||
# coding=utf-8
|
||||
__author__ = "Gina Häußge <osd@foosel.net>"
|
||||
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
|
||||
__copyright__ = "Copyright (C) 2014 Gina Häußge - Released under terms of the AGPLv3 License"
|
||||
|
||||
|
||||
import logging
|
||||
import os
|
||||
import time
|
||||
from octoprint.events import eventManager, Events
|
||||
from octoprint.comm.transport import MessageReceiver, StateReceiver, LogReceiver, State as TransportState
|
||||
from octoprint.filemanager.destinations import FileDestinations
|
||||
from octoprint.settings import settings
|
||||
|
||||
|
||||
class Protocol(MessageReceiver, StateReceiver, LogReceiver):
|
||||
|
||||
def __init__(self, transport_factory, protocol_listener=None):
|
||||
self._logger = logging.getLogger(__name__)
|
||||
|
||||
self._transport = transport_factory(self, self, self)
|
||||
self._transport_properties = self._transport.get_properties()
|
||||
|
||||
self._protocol_listener = protocol_listener
|
||||
self._state = State.OFFLINE
|
||||
|
||||
self._heatup_start_time = None
|
||||
self._heatup_time_lost = 0.0
|
||||
|
||||
self._pause_start_time = None
|
||||
self._pause_time_lost = 0.0
|
||||
|
||||
self._current_file = None
|
||||
|
||||
self._current_z = 0.0
|
||||
|
||||
self._sd_available = False
|
||||
self._sd_files = []
|
||||
|
||||
self._current_temperature = {}
|
||||
self._temperature_offsets = {}
|
||||
|
||||
self._error = None
|
||||
|
||||
def _reset(self):
|
||||
self._heatup_start_time = None
|
||||
self._heatup_time_lost = 0.0
|
||||
|
||||
self._current_file = None
|
||||
|
||||
self._current_z = 0.0
|
||||
|
||||
self._sd_available = False
|
||||
self._sd_files = []
|
||||
|
||||
self._current_temperature = {}
|
||||
self._temperature_offsets = {}
|
||||
|
||||
self._error = None
|
||||
|
||||
##~~ public
|
||||
|
||||
def connect(self, protocol_options, transport_options):
|
||||
self._transport.connect(transport_options)
|
||||
|
||||
def disconnect(self, on_error=False):
|
||||
if self.is_printing():
|
||||
payload = None
|
||||
if self._current_file is not None:
|
||||
payload = {
|
||||
"file": self._current_file.getFilename(),
|
||||
"filename": os.path.basename(self._current_file.getFilename()),
|
||||
"origin": self._current_file.getFileLocation()
|
||||
}
|
||||
eventManager().fire(Events.PRINT_FAILED, payload)
|
||||
self._transport.disconnect(on_error)
|
||||
|
||||
def send_manually(self, command, high_priority=False):
|
||||
pass
|
||||
|
||||
def select_file(self, filename, origin):
|
||||
pass
|
||||
|
||||
def deselect_file(self):
|
||||
pass
|
||||
|
||||
def start_print(self):
|
||||
if self._current_file is None:
|
||||
raise ValueError("No file selected for printing")
|
||||
|
||||
self._heatup_start_time = None
|
||||
self._heatup_time_lost = 0.0
|
||||
|
||||
self._current_file.start()
|
||||
self._changeState(State.PRINTING)
|
||||
eventManager().fire(Events.PRINT_STARTED, {
|
||||
"file": self._current_file.getFilename(),
|
||||
"filename": os.path.basename(self._current_file.getFilename()),
|
||||
"origin": self._current_file.getFileLocation()
|
||||
})
|
||||
|
||||
def pause_print(self, only_pause=None, only_resume=None):
|
||||
payload = {
|
||||
"file": self._current_file.getFilename(),
|
||||
"filename": os.path.basename(self._current_file.getFilename()),
|
||||
"origin": self._current_file.getFileLocation()
|
||||
}
|
||||
|
||||
if self._state == State.PRINTING and not only_resume:
|
||||
self._pause_start_time = time.time()
|
||||
|
||||
self._changeState(State.PAUSED)
|
||||
eventManager().fire(Events.PRINT_PAUSED, payload)
|
||||
|
||||
elif self._state == State.PAUSED and not only_pause:
|
||||
if self._pause_start_time:
|
||||
self._pause_time_lost += time.time() - self._pause_start_time
|
||||
self._pause_start_time = None
|
||||
|
||||
self._changeState(State.PRINTING)
|
||||
eventManager().fire(Events.PRINT_RESUMED, payload)
|
||||
|
||||
def cancel_print(self):
|
||||
eventManager().fire(Events.PRINT_CANCELLED, {
|
||||
"file": self._current_file.getFilename(),
|
||||
"filename": os.path.basename(self._current_file.getFilename()),
|
||||
"origin": self._current_file.getFileLocation()
|
||||
})
|
||||
self._changeState(State.OPERATIONAL)
|
||||
self._print_cancelled()
|
||||
if self._protocol_listener is not None:
|
||||
self._protocol_listener.onPrintjobCancelled(self)
|
||||
|
||||
def _print_cancelled(self):
|
||||
pass
|
||||
|
||||
def init_sd(self):
|
||||
pass
|
||||
|
||||
def release_sd(self):
|
||||
pass
|
||||
|
||||
def refresh_sd_files(self):
|
||||
pass
|
||||
|
||||
def add_sd_file(self, path, local, remote):
|
||||
pass
|
||||
|
||||
def remove_sd_file(self, filename):
|
||||
pass
|
||||
|
||||
def get_state(self):
|
||||
return self._state
|
||||
|
||||
def get_current_temperatures(self):
|
||||
return self._current_temperature
|
||||
|
||||
def get_temperature_offsets(self):
|
||||
result = {}
|
||||
result.update(self._temperature_offsets)
|
||||
return result
|
||||
|
||||
def set_temperature_offsets(self, new_temperature_offsets):
|
||||
offsets = {}
|
||||
offsets.update(new_temperature_offsets)
|
||||
self._temperature_offsets = offsets
|
||||
|
||||
def get_sd_files(self):
|
||||
return self._sd_files
|
||||
|
||||
def get_print_time(self):
|
||||
if self._current_file is None or self._current_file.getStartTime() is None:
|
||||
return None
|
||||
else:
|
||||
return max(int(time.time() - self._current_file.getStartTime() - self._heatup_time_lost - self._pause_time_lost), 0)
|
||||
|
||||
def get_connection_options(self):
|
||||
return self._transport.get_connection_options()
|
||||
|
||||
def get_current_connection(self):
|
||||
return self._transport.get_current_connection()
|
||||
|
||||
##~~ granular state detection for implementations
|
||||
|
||||
def is_heating_up(self):
|
||||
return self._heatup_start_time is not None
|
||||
|
||||
def is_printing(self):
|
||||
return self._state == State.PRINTING or self._state == State.PAUSED
|
||||
|
||||
def is_sd_printing(self):
|
||||
return isinstance(self._current_file, PrintingSdFileInformation) and self.is_busy()
|
||||
|
||||
def is_streaming(self):
|
||||
return self._state == State.STREAMING
|
||||
|
||||
def is_busy(self):
|
||||
return self.is_printing() or self.is_streaming()
|
||||
|
||||
def is_operational(self):
|
||||
return self._state == State.OPERATIONAL
|
||||
|
||||
def is_sd_ready(self):
|
||||
return self._sd_available
|
||||
|
||||
##~~ state tracking and reporting to protocol listener
|
||||
|
||||
def _changeState(self, newState):
|
||||
oldState = self._state
|
||||
self._state = newState
|
||||
self._stateChanged(newState)
|
||||
if self._protocol_listener is not None:
|
||||
self._protocol_listener.onStateChange(self, oldState, newState)
|
||||
|
||||
def _stateChanged(self, newState):
|
||||
pass
|
||||
|
||||
def _updateTemperature(self, temperatureData):
|
||||
self._current_temperature = temperatureData
|
||||
self._temperatureUpdated(temperatureData)
|
||||
if self._protocol_listener is not None:
|
||||
self._protocol_listener.onTemperatureUpdate(self, temperatureData)
|
||||
|
||||
def _temperatureUpdated(self, temperatureData):
|
||||
pass
|
||||
|
||||
def _reportProgress(self, completion=None, filepos=None):
|
||||
if completion is None:
|
||||
completion = self._getPrintCompletion()
|
||||
if filepos is None:
|
||||
filepos = self._getPrintFilepos()
|
||||
|
||||
progress = {
|
||||
"completion": completion,
|
||||
"filepos": filepos,
|
||||
"printTime": self.get_print_time()
|
||||
}
|
||||
|
||||
self._progressReported(progress)
|
||||
if self._protocol_listener is not None:
|
||||
self._protocol_listener.onProgress(self, progress)
|
||||
|
||||
def _progressReported(self, progress):
|
||||
pass
|
||||
|
||||
def _reportZChange(self, z):
|
||||
old_z = self._current_z
|
||||
self._current_z = z
|
||||
|
||||
self._zChangeReported(z)
|
||||
if self._protocol_listener is not None:
|
||||
self._protocol_listener.onZChange(self, old_z, z)
|
||||
|
||||
def _zChangeReported(self, newZ):
|
||||
pass
|
||||
|
||||
def _changeSdState(self, sdAvailable):
|
||||
self._sd_available = sdAvailable
|
||||
self._sdStateChanged(sdAvailable)
|
||||
if self._sd_available:
|
||||
self.refresh_sd_files()
|
||||
else:
|
||||
self._sd_files = []
|
||||
if self._protocol_listener is not None:
|
||||
self._protocol_listener.onSdStateChange(self, sdAvailable)
|
||||
|
||||
def _sdStateChanged(self, sdAvailable):
|
||||
pass
|
||||
|
||||
def _selectFile(self, currentFile):
|
||||
self._current_file = currentFile
|
||||
self._fileSelected(currentFile)
|
||||
if self._protocol_listener is not None:
|
||||
self._protocol_listener.onFileSelected(self, currentFile.getFilename(), currentFile.getFilesize(), currentFile.getFileLocation())
|
||||
eventManager().fire(Events.FILE_SELECTED, {
|
||||
"file": self._current_file.getFilename(),
|
||||
"origin": self._current_file.getFileLocation()
|
||||
})
|
||||
|
||||
def _fileSelected(self, currentFile):
|
||||
pass
|
||||
|
||||
def _sendSdFiles(self):
|
||||
self._sdFilesSent()
|
||||
if self._protocol_listener is not None:
|
||||
self._protocol_listener.onSdFiles(self, self._sd_files)
|
||||
|
||||
def _sdFilesSent(self):
|
||||
pass
|
||||
|
||||
def _finishPrintjob(self):
|
||||
self._reportProgress(completion=100, filepos=self._current_file.getFilesize())
|
||||
self._changeState(State.OPERATIONAL)
|
||||
if self._protocol_listener is not None:
|
||||
self._protocol_listener.onPrintjobDone(self)
|
||||
eventManager().fire(Events.PRINT_DONE, {
|
||||
"file": self._current_file.getFilename(),
|
||||
"filename": os.path.basename(self._current_file.getFilename()),
|
||||
"origin": self._current_file.getFileLocation(),
|
||||
"time": time.time() - self._current_file.getStartTime() if self._current_file.getStartTime() is not None else None
|
||||
})
|
||||
self._printJobFinished()
|
||||
|
||||
def _printJobFinished(self):
|
||||
pass
|
||||
|
||||
def _startFileTransfer(self, filename, filesize):
|
||||
self._fileTransferStarted(filename, filesize)
|
||||
if self._protocol_listener is not None:
|
||||
self._protocol_listener.onFileTransferStarted(self, filename, filesize)
|
||||
|
||||
def _fileTransferStarted(self, filename, filesize):
|
||||
pass
|
||||
|
||||
def _finishFileTransfer(self):
|
||||
self._changeState(State.OPERATIONAL)
|
||||
|
||||
current_file = self._current_file
|
||||
self._current_file = None
|
||||
|
||||
self._fileTransferFinished(current_file)
|
||||
|
||||
if self._protocol_listener is not None:
|
||||
self._protocol_listener.onFileTransferDone(self)
|
||||
|
||||
def _fileTransferFinished(self, current_file):
|
||||
pass
|
||||
|
||||
def _addSdFile(self, filename, filesize):
|
||||
"""
|
||||
Adds a file to the SD file list
|
||||
|
||||
:param filename: the filename to add to the list
|
||||
:param filesize: the filesize to add to the list, may be None
|
||||
"""
|
||||
self._sd_files.append((filename, filesize))
|
||||
self._sdFileAdded(filename, filesize)
|
||||
|
||||
def _sdFileAdded(self, filename, filesize):
|
||||
"""
|
||||
Called when a file has been added to the SD file list, can be used by the underyling protocol implementation
|
||||
to react to that.
|
||||
|
||||
:param filename: the filename to add to the list
|
||||
:param filesize: the filesize to add to the list, may be None
|
||||
"""
|
||||
pass
|
||||
|
||||
def _addSdFiles(self, files):
|
||||
"""
|
||||
Adds a list of files to the SD file list
|
||||
|
||||
:param files: the list of file tuples (name, size) to add to the list, size may be None
|
||||
"""
|
||||
for f in files:
|
||||
self._sd_files.append(f)
|
||||
self._sdFilesAdded(files)
|
||||
|
||||
def _sdFilesAdded(self, files):
|
||||
"""
|
||||
Called when a list of files has been added to the SD file list, can be used by the underlying protocol
|
||||
implementation to react to that.
|
||||
|
||||
:param files: the file tuples (name, size) added to the list, size may be None
|
||||
"""
|
||||
pass
|
||||
|
||||
def _resetSdFiles(self):
|
||||
"""
|
||||
Resets the SD file list
|
||||
"""
|
||||
self._sd_files = []
|
||||
self._sdFilesReset()
|
||||
|
||||
def _sdFilesReset(self):
|
||||
"""
|
||||
Called when the list of SD files has been reset, can be used in the underlying protocol implementation to
|
||||
react to that
|
||||
"""
|
||||
pass
|
||||
|
||||
def _heatupDetected(self):
|
||||
"""
|
||||
Called when the underlying protocol detects the beginning of a heat-up interval.
|
||||
"""
|
||||
self._heatup_start_time = time.time()
|
||||
|
||||
def _heatupDone(self):
|
||||
"""
|
||||
Called when the underlying protocol detects the end of a heat-up interval.
|
||||
"""
|
||||
if self._heatup_start_time is not None:
|
||||
self._heatup_time_lost += time.time() - self._heatup_start_time
|
||||
self._heatup_start_time = None
|
||||
|
||||
def _log_error(self, error):
|
||||
if self._protocol_listener is not None:
|
||||
self._protocol_listener.onLogError(self, error)
|
||||
|
||||
##~~ StateReceiver
|
||||
|
||||
def onStateChangeReceived(self, source, oldState, newState):
|
||||
if self._transport != source:
|
||||
return
|
||||
|
||||
if newState == TransportState.DETECTING_CONNECTION or newState == TransportState.OPENING_CONNECTION:
|
||||
self._changeState(State.CONNECTING)
|
||||
elif newState == TransportState.CONNECTED:
|
||||
self._changeState(State.CONNECTED)
|
||||
elif newState == TransportState.DISCONNECTED:
|
||||
self._changeState(State.OFFLINE)
|
||||
elif newState == TransportState.DISCONNECTED_WITH_ERROR or newState == TransportState.ERROR:
|
||||
self.onError(self._transport.getError())
|
||||
try:
|
||||
self._transport.disconnect()
|
||||
except:
|
||||
# TODO do we need to handle that?
|
||||
pass
|
||||
|
||||
##~~ MessageReceiver
|
||||
|
||||
def onError(self, error):
|
||||
self._changeState(State.ERROR)
|
||||
self._error = error
|
||||
eventManager().fire(Events.ERROR, {"error": error})
|
||||
|
||||
##~~ LogReceiver
|
||||
|
||||
def onLogRx(self, source, rx):
|
||||
if self._transport != source:
|
||||
return
|
||||
|
||||
if self._protocol_listener is not None:
|
||||
self._protocol_listener.onLogRx(self, rx)
|
||||
|
||||
def onLogTx(self, source, tx):
|
||||
if self._transport != source:
|
||||
return
|
||||
|
||||
if self._protocol_listener is not None:
|
||||
self._protocol_listener.onLogTx(self, tx)
|
||||
|
||||
def onLogError(self, source, error):
|
||||
if self._transport != source:
|
||||
return
|
||||
self._log_error(error)
|
||||
|
||||
##~~ helpers
|
||||
|
||||
def _getPrintCompletion(self):
|
||||
if self._current_file is None:
|
||||
return None
|
||||
return self._current_file.getProgress() * 100
|
||||
|
||||
def _getPrintFilepos(self):
|
||||
if self._current_file is None:
|
||||
return None
|
||||
return self._current_file.getFilepos()
|
||||
|
||||
|
||||
class ProtocolListener(object):
|
||||
def onStateChange(self, source, oldState, newState):
|
||||
pass
|
||||
|
||||
def onTemperatureUpdate(self, source, temperatureData):
|
||||
pass
|
||||
|
||||
def onProgress(self, source, progress):
|
||||
pass
|
||||
|
||||
def onZChange(self, source, oldZ, newZ):
|
||||
pass
|
||||
|
||||
def onFileSelected(self, source, filename, filesize, origin):
|
||||
pass
|
||||
|
||||
def onPrintjobStarted(self, source):
|
||||
pass
|
||||
|
||||
def onPrintjobDone(self, source):
|
||||
pass
|
||||
|
||||
def onPrintjobCancelled(self, source):
|
||||
pass
|
||||
|
||||
def onFileTransferStarted(self, source, filename, filesize):
|
||||
pass
|
||||
|
||||
def onFileTransferDone(self, source):
|
||||
pass
|
||||
|
||||
def onSdStateChange(self, source, sdAvailable):
|
||||
pass
|
||||
|
||||
def onSdFiles(self, source, files):
|
||||
pass
|
||||
|
||||
def onLogTx(self, source, tx):
|
||||
pass
|
||||
|
||||
def onLogRx(self, source, rx):
|
||||
pass
|
||||
|
||||
def onLogError(self, source, error):
|
||||
pass
|
||||
|
||||
|
||||
class State(object):
|
||||
|
||||
OFFLINE = "Offline"
|
||||
CONNECTING = "Connecting"
|
||||
CONNECTED = "Connected"
|
||||
OPERATIONAL = "Operational"
|
||||
PRINTING = "Printing"
|
||||
STREAMING = "Streaming"
|
||||
PAUSED = "Paused"
|
||||
ERROR = "Error"
|
||||
|
||||
|
||||
### Printing file information classes ##################################################################################
|
||||
|
||||
class PrintingFileInformation(object):
|
||||
"""
|
||||
Encapsulates information regarding the current file being printed: file name, current position, total size and
|
||||
time the print started.
|
||||
Allows to reset the current file position to 0 and to calculate the current progress as a floating point
|
||||
value between 0 and 1.
|
||||
"""
|
||||
|
||||
def __init__(self, filename):
|
||||
self._filename = filename
|
||||
self._filepos = 0
|
||||
self._filesize = None
|
||||
self._startTime = None
|
||||
|
||||
def getStartTime(self):
|
||||
return self._startTime
|
||||
|
||||
def getFilename(self):
|
||||
return self._filename
|
||||
|
||||
def getFilesize(self):
|
||||
return self._filesize
|
||||
|
||||
def getFilepos(self):
|
||||
return self._filepos
|
||||
|
||||
def getFileLocation(self):
|
||||
return FileDestinations.LOCAL
|
||||
|
||||
def getProgress(self):
|
||||
"""
|
||||
The current progress of the file, calculated as relation between file position and absolute size. Returns -1
|
||||
if file size is None or < 1.
|
||||
"""
|
||||
if self._filesize is None or not self._filesize > 0:
|
||||
return -1
|
||||
return float(self._filepos) / float(self._filesize)
|
||||
|
||||
def reset(self):
|
||||
"""
|
||||
Resets the current file position to 0.
|
||||
"""
|
||||
self._filepos = 0
|
||||
|
||||
def start(self):
|
||||
"""
|
||||
Marks the print job as started and remembers the start time.
|
||||
"""
|
||||
self._startTime = time.time()
|
||||
|
||||
|
||||
class PrintingSdFileInformation(PrintingFileInformation):
|
||||
"""
|
||||
Encapsulates information regarding an ongoing print from SD.
|
||||
"""
|
||||
|
||||
def __init__(self, filename, filesize):
|
||||
PrintingFileInformation.__init__(self, filename)
|
||||
self._filesize = filesize
|
||||
|
||||
def setFilepos(self, filepos):
|
||||
"""
|
||||
Sets the current file position.
|
||||
"""
|
||||
self._filepos = filepos
|
||||
|
||||
def getFileLocation(self):
|
||||
return FileDestinations.SDCARD
|
||||
@@ -0,0 +1,59 @@
|
||||
# coding=utf-8
|
||||
__author__ = "Gina Häußge <osd@foosel.net>"
|
||||
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
|
||||
__copyright__ = "Copyright (C) 2014 Gina Häußge - Released under terms of the AGPLv3 License"
|
||||
|
||||
import re
|
||||
|
||||
from octoprint.comm.protocol.reprap import RepRapProtocol
|
||||
|
||||
|
||||
class RepetierTextualProtocol(RepRapProtocol):
|
||||
|
||||
__protocolinfo__ = ("repetier", "RepRap (Repetier Flavor)", False)
|
||||
|
||||
MESSAGE_TARGET_TEMPERATURE = staticmethod(lambda line: "TargetExtr" in line or "TargetBed" in line)
|
||||
MESSAGE_TEMPERATURE = staticmethod(lambda line: RepRapProtocol.MESSAGE_TEMPERATURE(line) or RepetierTextualProtocol.MESSAGE_TARGET_TEMPERATURE(line))
|
||||
|
||||
REGEX_POSITIVE_FLOAT = "[+]?[0-9]*\.?[0-9]+"
|
||||
REGEX_TARGET_EXTRUDER_TEMPERATURE = re.compile("TargetExtr([0-9]+):(%s)" % REGEX_POSITIVE_FLOAT)
|
||||
REGEX_TARGET_BED_TEMPERATURE = re.compile("TargetBed:(%s)" % REGEX_POSITIVE_FLOAT)
|
||||
|
||||
def __init__(self, transport_factory, protocol_listener=None):
|
||||
RepRapProtocol.__init__(self, transport_factory, protocol_listener)
|
||||
self._sd_available = True
|
||||
|
||||
def _reset(self, from_start=False):
|
||||
RepRapProtocol._reset(self, from_start=from_start)
|
||||
self._sd_available = True
|
||||
|
||||
def _process_temperatures(self, line):
|
||||
if RepetierTextualProtocol.MESSAGE_TARGET_TEMPERATURE(line):
|
||||
match_extr = RepetierTextualProtocol.REGEX_TARGET_EXTRUDER_TEMPERATURE.match(line)
|
||||
match_bed = RepetierTextualProtocol.REGEX_TARGET_BED_TEMPERATURE.match(line)
|
||||
|
||||
current_temperatures = self.get_current_temperatures()
|
||||
key = None
|
||||
target = None
|
||||
try:
|
||||
if match_extr is not None:
|
||||
tool_num = int(match_extr.group(1))
|
||||
key = "tool%d" % tool_num
|
||||
target = float(match_extr.group(2))
|
||||
elif match_bed is not None:
|
||||
key = "bed"
|
||||
target = float(match_bed.group(1))
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
if key is None:
|
||||
return False
|
||||
|
||||
if key in current_temperatures and current_temperatures[key] is not None and isinstance(current_temperatures[key], tuple):
|
||||
(actual, old_target) = current_temperatures[key]
|
||||
current_temperatures[key] = (actual, target)
|
||||
else:
|
||||
current_temperatures[key] = (None, target)
|
||||
self._updateTemperature(current_temperatures)
|
||||
else:
|
||||
RepRapProtocol._process_temperatures(self, line)
|
||||
@@ -0,0 +1,377 @@
|
||||
# coding=utf-8
|
||||
__author__ = "Gina Häußge <osd@foosel.net>"
|
||||
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
|
||||
__copyright__ = "Copyright (C) 2014 Gina Häußge - Released under terms of the AGPLv3 License"
|
||||
|
||||
import Queue
|
||||
import re
|
||||
import heapq
|
||||
import os
|
||||
import time
|
||||
import itertools
|
||||
|
||||
from octoprint.comm.protocol import PrintingFileInformation
|
||||
|
||||
|
||||
class GcodeCommand(object):
|
||||
|
||||
KNOWN_FLOAT_ATTRIBUTES = ("x", "y", "z", "e", "s", "p", "r")
|
||||
KNOWN_INT_ATTRIBUTES = ("f", "t", "n")
|
||||
KNOWN_ATTRIBUTES = KNOWN_FLOAT_ATTRIBUTES + KNOWN_INT_ATTRIBUTES
|
||||
|
||||
COMMAND_REGEX = re.compile("^([GMT])(\d+)")
|
||||
ARGUMENT_REGEX = re.compile("\s+([%s][-+]?\d*\.?\d+|[%s][-+]?\d+)" % ("".join(map(lambda x: x.upper(), KNOWN_FLOAT_ATTRIBUTES)), "".join(map(lambda x: x.upper(), KNOWN_INT_ATTRIBUTES))))
|
||||
PARAM_REGEX = re.compile("^[GMT]\d+\s+(.*?)$")
|
||||
|
||||
@staticmethod
|
||||
def from_line(line):
|
||||
line = line.strip()
|
||||
command = ""
|
||||
args = {"original": line}
|
||||
match = GcodeCommand.COMMAND_REGEX.match(line)
|
||||
if match is None:
|
||||
args["unknown"] = True
|
||||
else:
|
||||
commandType = match.group(1)
|
||||
commandNumber = int(match.group(2))
|
||||
command = "%s%d" % (commandType, commandNumber)
|
||||
|
||||
|
||||
if commandType == "T":
|
||||
args["tool"] = commandNumber
|
||||
else:
|
||||
matchedArgs = GcodeCommand.ARGUMENT_REGEX.findall(line)
|
||||
if len(matchedArgs) == 0:
|
||||
paramMatch = GcodeCommand.PARAM_REGEX.match(line)
|
||||
if paramMatch is not None:
|
||||
args["param"] = paramMatch.group(1)
|
||||
else:
|
||||
for arg in matchedArgs:
|
||||
key = arg[0].lower()
|
||||
if key in GcodeCommand.KNOWN_INT_ATTRIBUTES:
|
||||
value = int(arg[1:])
|
||||
elif key in GcodeCommand.KNOWN_FLOAT_ATTRIBUTES:
|
||||
value = float(arg[1:])
|
||||
else:
|
||||
value = str(arg[1:])
|
||||
args[key] = value
|
||||
|
||||
return GcodeCommand(command, **args)
|
||||
|
||||
def __init__(self, command, **kwargs):
|
||||
self.command = command
|
||||
self.x = None
|
||||
self.y = None
|
||||
self.z = None
|
||||
self.e = None
|
||||
self.s = None
|
||||
self.p = None
|
||||
self.r = None
|
||||
self.f = None
|
||||
self.t = None
|
||||
self.n = None
|
||||
|
||||
self.tool = None
|
||||
self.original = None
|
||||
self.param = None
|
||||
|
||||
self.progress = None
|
||||
self.callback = None
|
||||
|
||||
self.unknown = False
|
||||
|
||||
for key, value in kwargs.iteritems():
|
||||
if key in GcodeCommand.KNOWN_ATTRIBUTES + ("tool", "original", "param", "progress", "callback", "unknown"):
|
||||
self.__setattr__(key, value)
|
||||
|
||||
def isGetTemperatureCommand(self):
|
||||
return self.command == "M105"
|
||||
|
||||
def isSetTemperatureCommand(self):
|
||||
return self.command in ("M104", "M140", "M109", "M190")
|
||||
|
||||
def isSelectToolCommand(self):
|
||||
return self.command.startswith("T")
|
||||
|
||||
def __repr__(self):
|
||||
return "GcodeCommand(\"{str}\",progress={progress})".format(str=str(self), progress=self.progress)
|
||||
|
||||
def __str__(self):
|
||||
if self.original is not None:
|
||||
return self.original
|
||||
else:
|
||||
attr = []
|
||||
for key in GcodeCommand.KNOWN_ATTRIBUTES:
|
||||
value = self.__getattribute__(key)
|
||||
if value is not None:
|
||||
if key in GcodeCommand.KNOWN_INT_ATTRIBUTES:
|
||||
attr.append("%s%d" % (key.upper(), value))
|
||||
elif key in GcodeCommand.KNOWN_FLOAT_ATTRIBUTES:
|
||||
attr.append("%s%f" % (key.upper(), value))
|
||||
else:
|
||||
attr.append("%s%r" % (key.upper(), value))
|
||||
attributeStr = " ".join(attr)
|
||||
return "%s%s%s" % (self.command.upper(), " " + attributeStr if attributeStr else "", " " + self.param if self.param else "")
|
||||
|
||||
|
||||
class CommandQueueEntry(object):
|
||||
PRIORITY_RESEND = 1
|
||||
PRIORITY_HIGH = 2
|
||||
PRIORITY_NORMAL = 3
|
||||
|
||||
def __init__(self, priority, command, line_number=None, command_type=None, prepared=None):
|
||||
self.priority = priority
|
||||
self.command = command
|
||||
self.line_number = line_number
|
||||
self.command_type = command_type
|
||||
self._prepared = prepared
|
||||
self._size = 0
|
||||
|
||||
@property
|
||||
def prepared(self):
|
||||
return self._prepared
|
||||
|
||||
@prepared.setter
|
||||
def prepared(self, prepared):
|
||||
self._prepared = prepared
|
||||
self._size = (len(prepared) + 1) if prepared is not None else 0
|
||||
|
||||
@property
|
||||
def size(self):
|
||||
return self._size
|
||||
|
||||
def __radd__(self, other):
|
||||
return other + self._size
|
||||
|
||||
def __repr__(self):
|
||||
return "CommandQueueEntry({command},prepared={prepared})".format(command=repr(self.command), prepared=self.prepared)
|
||||
|
||||
|
||||
class SpecialCommandQueueEntry(CommandQueueEntry):
|
||||
TYPE_JOBDONE = "JobDone"
|
||||
TYPE_JOBCANCELLED = "JobCancelled"
|
||||
|
||||
def __init__(self, type):
|
||||
CommandQueueEntry.__init__(self, CommandQueueEntry.PRIORITY_NORMAL, None)
|
||||
self.type = type
|
||||
|
||||
def __repr__(self):
|
||||
return "SpecialCommandQueueEntry(type={type})".format(type=self.type)
|
||||
|
||||
|
||||
class CommandQueue(Queue.Queue):
|
||||
'''Variant of Queue that retrieves open entries in priority order (lowest first, followed by addition order).
|
||||
|
||||
Entries need to be of the form (priority, command). An optional third argument commandType may be given:
|
||||
(priority, command, commandType), the queue will ensure that only one command of a given commandType will ever
|
||||
be in the queue.
|
||||
'''
|
||||
|
||||
def _init(self, maxsize):
|
||||
self.queue = []
|
||||
self.lookup = {}
|
||||
self.counter = itertools.count()
|
||||
|
||||
import threading
|
||||
self.clearlock = threading.RLock()
|
||||
|
||||
def _qsize(self, len=len):
|
||||
return len(self.queue)
|
||||
|
||||
def _put(self, item, heappush=heapq.heappush):
|
||||
if not isinstance(item, CommandQueueEntry):
|
||||
raise ValueError("queue can only take CommandQueueEntries, can't accept %r" % item)
|
||||
|
||||
command_type = item.command_type
|
||||
if command_type is not None:
|
||||
if command_type not in self.lookup:
|
||||
self.lookup[command_type] = item
|
||||
else:
|
||||
raise TypeAlreadyInQueue()
|
||||
|
||||
heappush(self.queue, (item.priority, next(self.counter), item))
|
||||
|
||||
def _get(self, heappop=heapq.heappop):
|
||||
priority, counter, item = heappop(self.queue)
|
||||
if item.command_type in self.lookup:
|
||||
del self.lookup[item.command_type]
|
||||
return item
|
||||
|
||||
def _entry_at(self, index):
|
||||
try:
|
||||
return self.queue[index]
|
||||
except IndexError:
|
||||
return None
|
||||
|
||||
def _del(self, entry, heapify=True):
|
||||
item = entry[2]
|
||||
try:
|
||||
self.queue.remove(entry)
|
||||
if heapify:
|
||||
heapq.heapify(self.queue)
|
||||
except ValueError:
|
||||
# that's ok, the entry probably just got removed already e.g. by print cancelling
|
||||
pass
|
||||
|
||||
if item.command_type in self.lookup:
|
||||
del self.lookup[item.command_type]
|
||||
|
||||
def peek(self):
|
||||
"""
|
||||
Returns the left most entry, result is either a tuple (priority, counter, CommandQueueEntry) or None (if queue
|
||||
was empty).
|
||||
"""
|
||||
|
||||
with self.mutex:
|
||||
entry = self._entry_at(0)
|
||||
return entry[2] if entry is not None else None, entry
|
||||
|
||||
def remove(self, entry):
|
||||
with self.mutex:
|
||||
self._del(entry)
|
||||
|
||||
def clear(self, matcher=None):
|
||||
if matcher is None:
|
||||
matcher = lambda x: True
|
||||
|
||||
cleared = []
|
||||
with self.clearlock:
|
||||
for entry in self.queue[:]:
|
||||
priority, counter, item = entry
|
||||
if matcher(item):
|
||||
self._del(entry, heapify=False)
|
||||
cleared.append(entry)
|
||||
heapq.heapify(self.queue)
|
||||
return cleared
|
||||
|
||||
def __repr__(self):
|
||||
return repr(self.queue)
|
||||
|
||||
class TypeAlreadyInQueue(Exception):
|
||||
pass
|
||||
|
||||
class PrintingGcodeFileInformation(PrintingFileInformation):
|
||||
"""
|
||||
Encapsulates information regarding an ongoing direct print. Takes care of the needed file handle and ensures
|
||||
that the file is closed in case of an error.
|
||||
"""
|
||||
|
||||
def __init__(self, filename, offsetCallback):
|
||||
PrintingFileInformation.__init__(self, filename)
|
||||
self._lineCount = None
|
||||
self._firstLine = None
|
||||
self._currentTool = 0
|
||||
|
||||
self._offsetCallback = offsetCallback
|
||||
|
||||
self._fileHandle = None
|
||||
if not os.path.exists(self._filename) or not os.path.isfile(self._filename):
|
||||
raise IOError("File %s does not exist" % self._filename)
|
||||
self._filesize = os.stat(self._filename).st_size
|
||||
|
||||
def start(self):
|
||||
"""
|
||||
Opens the file for reading and determines the file size. Start time won't be recorded until 100 lines in
|
||||
"""
|
||||
self._filehandle = open(self._filename, "r")
|
||||
self._lineCount = None
|
||||
self._startTime = None
|
||||
|
||||
def getNext(self):
|
||||
"""
|
||||
Retrieves the next line for printing.
|
||||
"""
|
||||
if self._filehandle is None:
|
||||
raise ValueError("File %s is not open for reading" % self._filename)
|
||||
|
||||
if self._lineCount is None:
|
||||
self._lineCount = 0
|
||||
self._startTime = time.time()
|
||||
return GcodeCommand.from_line("M110 N0")
|
||||
|
||||
try:
|
||||
command = None
|
||||
while command is None:
|
||||
if self._filehandle is None:
|
||||
# file got closed just now
|
||||
return None
|
||||
line = self._filehandle.readline()
|
||||
if not line:
|
||||
self._filehandle.close()
|
||||
self._filehandle = None
|
||||
command = self._process_command(line)
|
||||
self._lineCount += 1
|
||||
self._filepos = self._filehandle.tell()
|
||||
|
||||
return command
|
||||
except Exception as (e):
|
||||
if self._filehandle is not None:
|
||||
self._filehandle.close()
|
||||
self._filehandle = None
|
||||
raise e
|
||||
|
||||
def _process_command(self, line):
|
||||
# remove all comments and trim the line
|
||||
if ";" in line:
|
||||
line = line[0:line.find(";")]
|
||||
line = line.strip()
|
||||
|
||||
if len(line) > 0:
|
||||
# we still got something left => parse the command
|
||||
command = GcodeCommand.from_line(line)
|
||||
if command is None:
|
||||
return None
|
||||
|
||||
if command.isSelectToolCommand():
|
||||
# track tool changes
|
||||
self._currentTool = command.tool
|
||||
|
||||
elif command.isSetTemperatureCommand() and self._offsetCallback is not None:
|
||||
# if we have a temperature command and an offset callback, retrieve current offsets
|
||||
offsets = self._offsetCallback()
|
||||
|
||||
# extruder temperature, determine which one and retrieve corresponding offset
|
||||
if command.command == "M104" or command.command == "M109":
|
||||
tool_num = self._currentTool
|
||||
if command.t is not None:
|
||||
tool_num = command.t
|
||||
|
||||
key = "tool%d" % tool_num
|
||||
|
||||
# bed temperature
|
||||
elif command.command == "M140" or command.command == "M190":
|
||||
key = "bed"
|
||||
|
||||
# unknown, should never happen
|
||||
else:
|
||||
key = None
|
||||
|
||||
if key is not None and key in offsets:
|
||||
offset = offsets[key]
|
||||
command.s = command.s + offset
|
||||
if command.original is not None:
|
||||
command.original = None
|
||||
|
||||
# finally return the processed command
|
||||
return command
|
||||
else:
|
||||
# no command, return None
|
||||
return None
|
||||
|
||||
|
||||
class StreamingGcodeFileInformation(PrintingGcodeFileInformation):
|
||||
def __init__(self, path, localFilename, remoteFilename):
|
||||
PrintingGcodeFileInformation.__init__(self, path, None)
|
||||
self._localFilename = localFilename
|
||||
self._remoteFilename = remoteFilename
|
||||
|
||||
def start(self):
|
||||
PrintingGcodeFileInformation.start(self)
|
||||
self._startTime = time.time()
|
||||
|
||||
def getLocalFilename(self):
|
||||
return self._localFilename
|
||||
|
||||
def getRemoteFilename(self):
|
||||
return self._remoteFilename
|
||||
|
||||