55 lines
1.4 KiB
Python
55 lines
1.4 KiB
Python
'''
|
|
Created on 27 set 2019
|
|
|
|
@author: Emanuele Trabattoni
|
|
'''
|
|
import time
|
|
import sys
|
|
import printer as p
|
|
import logging
|
|
import protocol
|
|
|
|
def main():
|
|
isRunning = True
|
|
while isRunning:
|
|
printer = p.MarkoPrinter('./conf.json', LOGGER)
|
|
connessa = printer.connetti()
|
|
while connessa:
|
|
lastTimestamp = int(time.time()*100)
|
|
commandString = protocol.callPrintImage(imageName='TM2.00I',
|
|
printMode='10',
|
|
fieldContent='{0}\r{0}'.format(lastTimestamp))
|
|
try:
|
|
printer.sendCommand(commandString)
|
|
LOGGER.debug('SENT: {}'.format(commandString))
|
|
r=printer.readResponse('callPrintImage')
|
|
LOGGER.debug('RECEIVED: {}'.format(r))
|
|
protocol.checkResponse('callPrintImage',r)
|
|
except Exception as e:
|
|
LOGGER.error(str(e))
|
|
pass
|
|
pass
|
|
pass
|
|
|
|
if __name__ == '__main__':
|
|
# Setup Logger
|
|
LOGGER = logging.getLogger(__name__)
|
|
LOGGER.setLevel(logging.DEBUG)
|
|
LOGGER.propagate = False
|
|
FORMATTER = logging.Formatter(("%(asctime)s|%(levelname)-7s|%(funcName)-10s|%(lineno)-3d: %(message)-50s"),
|
|
("%m-%d %H:%M:%S"))
|
|
# File Logging
|
|
fh = logging.FileHandler(("./log/dimelog.log"))
|
|
fh.setLevel(logging.DEBUG)
|
|
fh.setFormatter(FORMATTER)
|
|
LOGGER.addHandler(fh)
|
|
# Console Logging
|
|
cl= logging.StreamHandler(sys.stdout)
|
|
cl.setLevel(logging.DEBUG)
|
|
cl.setFormatter(FORMATTER)
|
|
LOGGER.addHandler(cl)
|
|
|
|
LOGGER.warning("MarcaturaDime Started!")
|
|
|
|
sys.exit(main())
|
|
pass |