Wed, 20 Jan 2021 10:15:13 +0100
updated and added new files for printrun
46 | 1 | # This file is part of the Printrun suite. |
2 | # | |
3 | # Printrun is free software: you can redistribute it and/or modify | |
4 | # it under the terms of the GNU General Public License as published by | |
5 | # the Free Software Foundation, either version 3 of the License, or | |
6 | # (at your option) any later version. | |
7 | # | |
8 | # Printrun is distributed in the hope that it will be useful, | |
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | # GNU General Public License for more details. | |
12 | # | |
13 | # You should have received a copy of the GNU General Public License | |
14 | # along with Printrun. If not, see <http://www.gnu.org/licenses/>. | |
15 | ||
16 | class PrinterEventHandler: | |
17 | ''' | |
18 | Defines a skeletton of an event-handler for printer events. It | |
19 | allows attaching to the printcore and will be triggered for | |
20 | different events. | |
21 | ''' | |
22 | def __init__(self): | |
23 | ''' | |
24 | Constructor. | |
25 | ''' | |
26 | pass | |
27 | ||
28 | def on_init(self): | |
29 | ''' | |
30 | Called whenever a new printcore is initialized. | |
31 | ''' | |
32 | pass | |
33 | ||
34 | def on_send(self, command, gline): | |
35 | ''' | |
36 | Called on every command sent to the printer. | |
37 | ||
38 | @param command: The command to be sent. | |
39 | @param gline: The parsed high-level command. | |
40 | ''' | |
41 | pass | |
42 | ||
43 | def on_recv(self, line): | |
44 | ''' | |
45 | Called on every line read from the printer. | |
46 | ||
47 | @param line: The data has been read from printer. | |
48 | ''' | |
49 | pass | |
50 | ||
51 | ||
52 | def on_connect(self): | |
53 | ''' | |
54 | Called whenever printcore is connected. | |
55 | ''' | |
56 | pass | |
57 | ||
58 | def on_disconnect(self): | |
59 | ''' | |
60 | Called whenever printcore is disconnected. | |
61 | ''' | |
62 | pass | |
63 | ||
64 | def on_error(self, error): | |
65 | ''' | |
66 | Called whenever an error occurs. | |
67 | ||
68 | @param error: The error that has been triggered. | |
69 | ''' | |
70 | pass | |
71 | ||
72 | def on_online(self): | |
73 | ''' | |
74 | Called when printer got online. | |
75 | ''' | |
76 | pass | |
77 | ||
78 | def on_temp(self, line): | |
79 | ''' | |
80 | Called for temp, status, whatever. | |
81 | ||
82 | @param line: Line of data. | |
83 | ''' | |
84 | pass | |
85 | ||
86 | def on_start(self, resume): | |
87 | ''' | |
88 | Called when printing is started. | |
89 | ||
90 | @param resume: If true, the print is resumed. | |
91 | ''' | |
92 | pass | |
93 | ||
94 | def on_end(self): | |
95 | ''' | |
96 | Called when printing ends. | |
97 | ''' | |
98 | pass | |
99 | ||
100 | def on_layerchange(self, layer): | |
101 | ''' | |
102 | Called on layer changed. | |
103 | ||
104 | @param layer: The new layer. | |
105 | ''' | |
106 | pass | |
107 | ||
108 | def on_preprintsend(self, gline, index, mainqueue): | |
109 | ''' | |
110 | Called pre sending printing command. | |
111 | ||
112 | @param gline: Line to be send. | |
113 | @param index: Index in the mainqueue. | |
114 | @param mainqueue: The main queue of commands. | |
115 | ''' | |
116 | pass | |
117 | ||
118 | def on_printsend(self, gline): | |
119 | ''' | |
120 | Called whenever a line is sent to the printer. | |
121 | ||
122 | @param gline: The line send to the printer. | |
123 | ''' | |
124 | pass | |
125 | ||
126 |