#!/usr/bin/python3.5
# -*- coding: utf-8 -*-
import base64
import ctypes
import sys
import json
import datetime
import os
import platform
from pprint import pprint
from lib import IFptr
#fptr = IFptr("")
#get extr param
if len(sys.argv)==1:
print ("Возможные параметры:")
print ("--info IP - общая информация о ККМ")
exit(0)
arg=sys.argv[1]
if arg=="--info":
ip=sys.argv[2];
LIBRARY_PATH = os.path.dirname(os.path.abspath(__file__))
fptr = IFptr(os.path.join(LIBRARY_PATH, "libfptr10.so"))
#connect to ATOL
fptr.setSingleSetting(IFptr.LIBFPTR_SETTING_MODEL, str(IFptr.LIBFPTR_MODEL_ATOL_AUTO))
fptr.setSingleSetting(IFptr.LIBFPTR_SETTING_PORT, str(IFptr.LIBFPTR_PORT_TCPIP))
fptr.setSingleSetting(IFptr.LIBFPTR_SETTING_IPADDRESS, ip)
fptr.setSingleSetting(IFptr.LIBFPTR_SETTING_IPPORT,"5555")
fptr.setSingleSetting(IFptr.LIBFPTR_SETTING_ACCESS_PASSWORD,"0")
fptr.setSingleSetting(IFptr.LIBFPTR_SETTING_USER_PASSWORD,"30")
fptr.applySingleSettings()
#открываем соединение
fptr.open()
isOpened = fptr.isOpened()
if isOpened==0:
print ("9) Доступность:",0)
exit(1)
if arg=="--info":
fptr.setParam(IFptr.LIBFPTR_PARAM_FN_DATA_TYPE, IFptr.LIBFPTR_FNDT_REG_INFO)
fptr.fnQueryData()
taxationTypes = fptr.getParamInt(1062)
agentSign = fptr.getParamInt(1057)
ffdVersion = fptr.getParamInt(1209)
print("Версия ФН:",ffdVersion)
autoModeSign = fptr.getParamBool(1001)
offlineModeSign = fptr.getParamBool(1002)
encryptionSign = fptr.getParamBool(1056)
internetSign = fptr.getParamBool(1108)
serviceSign = fptr.getParamBool(1109)
bsoSign = fptr.getParamBool(1110)
lotterySign = fptr.getParamBool(1126)
gamblingSign = fptr.getParamBool(1193)
exciseSign = fptr.getParamBool(1207)
machineInstallationSign = fptr.getParamBool(1221)
fnsUrl = fptr.getParamString(1060)
organizationVATIN = fptr.getParamString(1018)
organizationName = fptr.getParamString(1048)
organizationEmail = fptr.getParamString(1117)
paymentsAddress = fptr.getParamString(1187)
registrationNumber = fptr.getParamString(1037)
machineNumber = fptr.getParamString(1036)
ofdVATIN = fptr.getParamString(1017)
ofdName = fptr.getParamString(1046)
print("1) Организация:",organizationName)
print("2) ОФД:",ofdName)
fptr.setParam(IFptr.LIBFPTR_PARAM_DATA_TYPE, IFptr.LIBFPTR_DT_STATUS)
fptr.queryData()
serialNumber = fptr.getParamString(IFptr.LIBFPTR_PARAM_SERIAL_NUMBER)
modelName = fptr.getParamString(IFptr.LIBFPTR_PARAM_MODEL_NAME)
firmwareVersion = fptr.getParamString(IFptr.LIBFPTR_PARAM_UNIT_VERSION)
print("3) S/N:",serialNumber)
print("4) Модель:",modelName)
print("5) Прошивка:",firmwareVersion)
fptr.setParam(IFptr.LIBFPTR_PARAM_FN_DATA_TYPE, IFptr.LIBFPTR_FNDT_VALIDITY)
fptr.fnQueryData()
dateTime = fptr.getParamDateTime(IFptr.LIBFPTR_PARAM_DATE_TIME)
print("6) Дата окончания ФН:",dateTime)
fptr.setParam(IFptr.LIBFPTR_PARAM_FN_DATA_TYPE, IFptr.LIBFPTR_FNDT_LAST_RECEIPT)
fptr.fnQueryData()
documentNumber = fptr.getParamInt(IFptr.LIBFPTR_PARAM_DOCUMENT_NUMBER)
print("7) Номер чека:",documentNumber)
# Получение информации о неотправленных документах
fptr.setParam(IFptr.LIBFPTR_PARAM_FN_DATA_TYPE, IFptr.LIBFPTR_FNDT_OFD_EXCHANGE_STATUS)
res=fptr.fnQueryData()
unsentCount = fptr.getParamInt(IFptr.LIBFPTR_PARAM_DOCUMENTS_COUNT)
if unsentCount>0:
unsentFirstNumber = fptr.getParamInt(IFptr.LIBFPTR_PARAM_DOCUMENT_NUMBER)
unsentDateTime = fptr.getParamDateTime(IFptr.LIBFPTR_PARAM_DATE_TIME)
print ("8) Не фискализировано:",unsentCount)
fptr.close()
del fptr
exit(1)
else:
print ("8) Не фискализировано:",0)
print ("9) Доступность:",1)