Skip to content

Latest commit

 

History

History
77 lines (50 loc) · 3.01 KB

File metadata and controls

77 lines (50 loc) · 3.01 KB

Printer Billing Integration

This is how the Large Format Printer's billing system works.

Theory

The printer is configured to email print accounting reports to a dummy email address. The SMTP email server is actually a python script that interprets the email and sends the accounting info to the portal.

Windows should send the currently logged on user's name to the printer via the print driver. Sometimes this doesn't happen, so data from the Logon Tracker Integration is used.

Setup

Printer Reporting

Open printer's web config, ie. http://172.17.18.153

Setup > Printer settings:

  • Send accounting files: Enabled
  • Send accounting files to: spaceport@example.com
  • Send accounting files every: 1 prints
  • Exclude personal information from accounting e-mail: Off
  • Hit Apply

Go to Email server page:

AutoSend can remain disabled.

The SMTP server 172.17.17.181 needs to point to the server running the python script, currently the Integrations Server.

Python Script

Python script can be found here:

https://github.com/Protospace/telemetry/tree/master/printer_report

The script parses the printer's email and sends the data to the portal.

The script is kept alive with Supervisor:

[program:printer]
user=tanner
directory=/home/tanner/telemetry/printer_report
environment=PYTHONUNBUFFERED=TRUE
command=/home/tanner/telemetry/printer_report/env/bin/python main.py
stopasgroup=true
stopsignal=INT
autostart=true
autorestart=true
stderr_logfile=/var/log/printer.log
stderr_logfile_maxbytes=10MB
stdout_logfile=/var/log/printer.log
stdout_logfile_maxbytes=10MB

Portal

Configure PRINTER_API_TOKEN in secrets.py and copy it to the python script's secrets.py.

The function printer_report(...) in views.py is where the data is processed into a transaction that deducts from a user's Protocoin balance.

Material costs are configured in the PAPER_COSTS dictionary. To add a new type of paper, find the exact name the printer sends by reading the log files.

Protocoin Balance Display

The Arduino code for this is here:

https://github.com/Protospace/telemetry/blob/master/printer_balance/printer_balance.ino

It polls the portal's /protocoin/printer_balance/ API route handled by printer_balance(...) in views.py. The computer's name must match what gets sent by the Logon Tracker Integration (currently "ARTEMUS"). The balance gets displayed when the computer is logged in.