
// WS-POS version 1.3 参照実装
// 2013/05/23 13:39:33

using UnifiedPOS.FiscalPrinter.V1_4;
using System;
using System.Collections.Generic;

using System.ServiceModel;
using System.ServiceModel.Description;
using System.Text;
using System.Text.RegularExpressions;
using System.Reflection;
using System.Threading;
using WSPOSInitiative.Common;

namespace WSPOSInitiative.FiscalPrinter
{
    /// <summary>
    /// FiscalPrinterの参照実装基底クラス
    /// </summary>
    public class FiscalPrinterServiceProviderBehaviorCore : ServiceProviderBehavior, UnifiedPOS.FiscalPrinter.V1_4.FiscalPrinter, IDisposable
    {
        #region FiscalPrinter Enumration Converter
        private static Dictionary<Enum, Enum> Convert = new Dictionary<Enum, Enum>()
            {
                { Microsoft.PointOfService.PowerReporting.Advanced, PowerReporting.PR_ADVANCED },
                { Microsoft.PointOfService.PowerReporting.None, PowerReporting.PR_NONE },
                { Microsoft.PointOfService.PowerReporting.Standard, PowerReporting.PR_STANDARD },
                { PowerReporting.PR_ADVANCED, Microsoft.PointOfService.PowerReporting.Advanced },
                { PowerReporting.PR_NONE, Microsoft.PointOfService.PowerReporting.None },
                { PowerReporting.PR_STANDARD, Microsoft.PointOfService.PowerReporting.Standard },

                { Microsoft.PointOfService.PowerNotification.Disabled, PowerNotification.PN_DISABLED },
                { Microsoft.PointOfService.PowerNotification.Enabled, PowerNotification.PN_ENABLED},
                { PowerNotification.PN_DISABLED, Microsoft.PointOfService.PowerNotification.Disabled },
                { PowerNotification.PN_ENABLED, Microsoft.PointOfService.PowerNotification.Enabled },

                { Microsoft.PointOfService.PowerState.Off, PowerState.PS_OFF},
                { Microsoft.PointOfService.PowerState.Offline, PowerState.PS_OFFLINE },
                { Microsoft.PointOfService.PowerState.OffOffline, PowerState.PS_OFF_OFFLINE },
                { Microsoft.PointOfService.PowerState.Online, PowerState.PS_ONLINE },
                { Microsoft.PointOfService.PowerState.Unknown, PowerState.PS_UNKNOWN },
                { PowerState.PS_OFF, Microsoft.PointOfService.PowerState.Off },
                { PowerState.PS_OFFLINE, Microsoft.PointOfService.PowerState.Offline },
                { PowerState.PS_OFF_OFFLINE, Microsoft.PointOfService.PowerState.OffOffline },
                { PowerState.PS_ONLINE, Microsoft.PointOfService.PowerState.Online },
                { PowerState.PS_UNKNOWN, Microsoft.PointOfService.PowerState.Unknown },

                { Microsoft.PointOfService.ControlState.Busy, ControlState.S_BUSY },
                { Microsoft.PointOfService.ControlState.Closed, ControlState.S_CLOSED },
                { Microsoft.PointOfService.ControlState.Error, ControlState.S_ERROR },
                { Microsoft.PointOfService.ControlState.Idle, ControlState.S_IDLE },
                { ControlState.S_BUSY, Microsoft.PointOfService.ControlState.Busy },
                { ControlState.S_CLOSED, Microsoft.PointOfService.ControlState.Closed },
                { ControlState.S_ERROR, Microsoft.PointOfService.ControlState.Error },
                { ControlState.S_IDLE, Microsoft.PointOfService.ControlState.Idle },

                { Microsoft.PointOfService.HealthCheckLevel.External, HealthCheckLevel.CH_EXTERNAL },
                { Microsoft.PointOfService.HealthCheckLevel.Interactive, HealthCheckLevel.CH_INTERACTIVE },
                { Microsoft.PointOfService.HealthCheckLevel.Internal, HealthCheckLevel.CH_INTERNAL },
                { HealthCheckLevel.CH_EXTERNAL, Microsoft.PointOfService.HealthCheckLevel.External },
                { HealthCheckLevel.CH_INTERACTIVE, Microsoft.PointOfService.HealthCheckLevel.Interactive },
                { HealthCheckLevel.CH_INTERNAL, Microsoft.PointOfService.HealthCheckLevel.Internal },

                { Microsoft.PointOfService.CompareFirmwareResult.Different, CompareFirmwareResult.CFV_FIRMWARE_DIFFERENT },
                { Microsoft.PointOfService.CompareFirmwareResult.Newer, CompareFirmwareResult.CFV_FIRMWARE_NEWER },
                { Microsoft.PointOfService.CompareFirmwareResult.Older, CompareFirmwareResult.CFV_FIRMWARE_OLDER },
                { Microsoft.PointOfService.CompareFirmwareResult.Same, CompareFirmwareResult.CFV_FIRMWARE_SAME },
                { Microsoft.PointOfService.CompareFirmwareResult.Unknown, CompareFirmwareResult.CFV_FIRMWARE_UNKNOWN },
                { CompareFirmwareResult.CFV_FIRMWARE_DIFFERENT, Microsoft.PointOfService.CompareFirmwareResult.Different },
                { CompareFirmwareResult.CFV_FIRMWARE_NEWER, Microsoft.PointOfService.CompareFirmwareResult.Newer },
                { CompareFirmwareResult.CFV_FIRMWARE_OLDER, Microsoft.PointOfService.CompareFirmwareResult.Older },
                { CompareFirmwareResult.CFV_FIRMWARE_SAME, Microsoft.PointOfService.CompareFirmwareResult.Same },
                { CompareFirmwareResult.CFV_FIRMWARE_UNKNOWN, Microsoft.PointOfService.CompareFirmwareResult.Unknown },

                { Microsoft.PointOfService.ErrorCode.Busy, UnifiedPOS.FiscalPrinter.V1_4.ErrorCode.E_BUSY },
                { Microsoft.PointOfService.ErrorCode.Claimed, UnifiedPOS.FiscalPrinter.V1_4.ErrorCode.E_CLAIMED },
                { Microsoft.PointOfService.ErrorCode.Closed, UnifiedPOS.FiscalPrinter.V1_4.ErrorCode.E_CLOSED },
                { Microsoft.PointOfService.ErrorCode.Deprecated, UnifiedPOS.FiscalPrinter.V1_4.ErrorCode.E_DEPRECATED },
                { Microsoft.PointOfService.ErrorCode.Disabled, UnifiedPOS.FiscalPrinter.V1_4.ErrorCode.E_DISABLED },
                { Microsoft.PointOfService.ErrorCode.Exists, UnifiedPOS.FiscalPrinter.V1_4.ErrorCode.E_EXISTS },
                { Microsoft.PointOfService.ErrorCode.Extended, UnifiedPOS.FiscalPrinter.V1_4.ErrorCode.E_EXTENDED },
                { Microsoft.PointOfService.ErrorCode.Failure, UnifiedPOS.FiscalPrinter.V1_4.ErrorCode.E_FAILURE },
                { Microsoft.PointOfService.ErrorCode.Illegal, UnifiedPOS.FiscalPrinter.V1_4.ErrorCode.E_ILLEGAL },
                { Microsoft.PointOfService.ErrorCode.NoExist, UnifiedPOS.FiscalPrinter.V1_4.ErrorCode.E_NOEXIST },
                { Microsoft.PointOfService.ErrorCode.NoHardware, UnifiedPOS.FiscalPrinter.V1_4.ErrorCode.E_NOHARDWARE },
                { Microsoft.PointOfService.ErrorCode.NoService, UnifiedPOS.FiscalPrinter.V1_4.ErrorCode.E_NOSERVICE },
                { Microsoft.PointOfService.ErrorCode.NotClaimed, UnifiedPOS.FiscalPrinter.V1_4.ErrorCode.E_NOTCLAIMED },
                { Microsoft.PointOfService.ErrorCode.Offline, UnifiedPOS.FiscalPrinter.V1_4.ErrorCode.E_OFFLINE },
                //{ Microsoft.PointOfService.ErrorCode.Success, UnifiedPOS.FiscalPrinter.V1_4.ErrorCode.SUCCESS },
                { Microsoft.PointOfService.ErrorCode.Timeout, UnifiedPOS.FiscalPrinter.V1_4.ErrorCode.E_TIMEOUT },
                { UnifiedPOS.FiscalPrinter.V1_4.ErrorCode.E_BUSY, Microsoft.PointOfService.ErrorCode.Busy },
                { UnifiedPOS.FiscalPrinter.V1_4.ErrorCode.E_CLAIMED, Microsoft.PointOfService.ErrorCode.Claimed },
                { UnifiedPOS.FiscalPrinter.V1_4.ErrorCode.E_CLOSED, Microsoft.PointOfService.ErrorCode.Closed },
                { UnifiedPOS.FiscalPrinter.V1_4.ErrorCode.E_DEPRECATED, Microsoft.PointOfService.ErrorCode.Deprecated },
                { UnifiedPOS.FiscalPrinter.V1_4.ErrorCode.E_DISABLED, Microsoft.PointOfService.ErrorCode.Disabled },
                { UnifiedPOS.FiscalPrinter.V1_4.ErrorCode.E_EXISTS, Microsoft.PointOfService.ErrorCode.Exists },
                { UnifiedPOS.FiscalPrinter.V1_4.ErrorCode.E_EXTENDED, Microsoft.PointOfService.ErrorCode.Extended },
                { UnifiedPOS.FiscalPrinter.V1_4.ErrorCode.E_FAILURE, Microsoft.PointOfService.ErrorCode.Failure },
                { UnifiedPOS.FiscalPrinter.V1_4.ErrorCode.E_ILLEGAL, Microsoft.PointOfService.ErrorCode.Illegal },
                { UnifiedPOS.FiscalPrinter.V1_4.ErrorCode.E_NOEXIST, Microsoft.PointOfService.ErrorCode.NoExist },
                { UnifiedPOS.FiscalPrinter.V1_4.ErrorCode.E_NOHARDWARE, Microsoft.PointOfService.ErrorCode.NoHardware },
                { UnifiedPOS.FiscalPrinter.V1_4.ErrorCode.E_NOSERVICE, Microsoft.PointOfService.ErrorCode.NoService },
                { UnifiedPOS.FiscalPrinter.V1_4.ErrorCode.E_NOTCLAIMED, Microsoft.PointOfService.ErrorCode.NotClaimed },
                { UnifiedPOS.FiscalPrinter.V1_4.ErrorCode.E_OFFLINE, Microsoft.PointOfService.ErrorCode.Offline },
                //{ UnifiedPOS.FiscalPrinter.V1_4.ErrorCode.SUCCESS, Microsoft.PointOfService.ErrorCode.Success },
                { UnifiedPOS.FiscalPrinter.V1_4.ErrorCode.E_TIMEOUT, Microsoft.PointOfService.ErrorCode.Timeout },

                { Microsoft.PointOfService.FiscalCurrency.BrazilianCruceiro, UnifiedPOS.FiscalPrinter.V1_4.FiscalCurrency.BrazilianCruceiro },
                { Microsoft.PointOfService.FiscalCurrency.BulgarianLev, UnifiedPOS.FiscalPrinter.V1_4.FiscalCurrency.BulgarianLev },
                { Microsoft.PointOfService.FiscalCurrency.CzechianKoruna, UnifiedPOS.FiscalPrinter.V1_4.FiscalCurrency.CzechianKoruna },
                { Microsoft.PointOfService.FiscalCurrency.Euro, UnifiedPOS.FiscalPrinter.V1_4.FiscalCurrency.Euro },
                { Microsoft.PointOfService.FiscalCurrency.GreekDrachma, UnifiedPOS.FiscalPrinter.V1_4.FiscalCurrency.GreekDrachma },
                { Microsoft.PointOfService.FiscalCurrency.HungarianForint, UnifiedPOS.FiscalPrinter.V1_4.FiscalCurrency.HungarianForint },
                { Microsoft.PointOfService.FiscalCurrency.ItalianLira, UnifiedPOS.FiscalPrinter.V1_4.FiscalCurrency.ItalianLira },
                { Microsoft.PointOfService.FiscalCurrency.Other, UnifiedPOS.FiscalPrinter.V1_4.FiscalCurrency.Other },
                { Microsoft.PointOfService.FiscalCurrency.PolishZloty, UnifiedPOS.FiscalPrinter.V1_4.FiscalCurrency.PolishZloty },
                { Microsoft.PointOfService.FiscalCurrency.RomanianLeu, UnifiedPOS.FiscalPrinter.V1_4.FiscalCurrency.RomanianLeu },
                { Microsoft.PointOfService.FiscalCurrency.RussianRouble, UnifiedPOS.FiscalPrinter.V1_4.FiscalCurrency.RussianRouble },
                { Microsoft.PointOfService.FiscalCurrency.SwedishKrona, UnifiedPOS.FiscalPrinter.V1_4.FiscalCurrency.SwedishKrona },
                { Microsoft.PointOfService.FiscalCurrency.TurkishLira, UnifiedPOS.FiscalPrinter.V1_4.FiscalCurrency.TurkishLira },
                { Microsoft.PointOfService.FiscalCurrency.UkrainianHryvnia, UnifiedPOS.FiscalPrinter.V1_4.FiscalCurrency.UkrainianHryvnia },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalCurrency.BrazilianCruceiro, Microsoft.PointOfService.FiscalCurrency.BrazilianCruceiro },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalCurrency.BulgarianLev, Microsoft.PointOfService.FiscalCurrency.BulgarianLev },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalCurrency.CzechianKoruna, Microsoft.PointOfService.FiscalCurrency.CzechianKoruna },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalCurrency.Euro, Microsoft.PointOfService.FiscalCurrency.Euro },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalCurrency.GreekDrachma, Microsoft.PointOfService.FiscalCurrency.GreekDrachma },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalCurrency.HungarianForint, Microsoft.PointOfService.FiscalCurrency.HungarianForint },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalCurrency.ItalianLira, Microsoft.PointOfService.FiscalCurrency.ItalianLira },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalCurrency.Other, Microsoft.PointOfService.FiscalCurrency.Other },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalCurrency.PolishZloty, Microsoft.PointOfService.FiscalCurrency.PolishZloty },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalCurrency.RomanianLeu, Microsoft.PointOfService.FiscalCurrency.RomanianLeu },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalCurrency.RussianRouble, Microsoft.PointOfService.FiscalCurrency.RussianRouble },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalCurrency.SwedishKrona, Microsoft.PointOfService.FiscalCurrency.SwedishKrona },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalCurrency.TurkishLira, Microsoft.PointOfService.FiscalCurrency.TurkishLira },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalCurrency.UkrainianHryvnia, Microsoft.PointOfService.FiscalCurrency.UkrainianHryvnia },

                { Microsoft.PointOfService.FiscalContractorId.First, UnifiedPOS.FiscalPrinter.V1_4.FiscalContractorID.FPTR_CID_FIRST},
                { Microsoft.PointOfService.FiscalContractorId.Second, UnifiedPOS.FiscalPrinter.V1_4.FiscalContractorID.FPTR_CID_SECOND},
                { Microsoft.PointOfService.FiscalContractorId.Single, UnifiedPOS.FiscalPrinter.V1_4.FiscalContractorID.FPTR_CID_SINGLE},
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalContractorID.FPTR_CID_FIRST, Microsoft.PointOfService.FiscalContractorId.First },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalContractorID.FPTR_CID_SECOND, Microsoft.PointOfService.FiscalContractorId.Second },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalContractorID.FPTR_CID_SINGLE, Microsoft.PointOfService.FiscalContractorId.Single },

                { Microsoft.PointOfService.FiscalDateType.Configuration, UnifiedPOS.FiscalPrinter.V1_4.FiscalDateType.FPTR_DT_CONF },
                { Microsoft.PointOfService.FiscalDateType.EndOfDay, UnifiedPOS.FiscalPrinter.V1_4.FiscalDateType.FPTR_DT_EOD },
                { Microsoft.PointOfService.FiscalDateType.RealTimeClock, UnifiedPOS.FiscalPrinter.V1_4.FiscalDateType.FPTR_DT_RTC },
                { Microsoft.PointOfService.FiscalDateType.Reset, UnifiedPOS.FiscalPrinter.V1_4.FiscalDateType.FPTR_DT_RESET},
                { Microsoft.PointOfService.FiscalDateType.Start, UnifiedPOS.FiscalPrinter.V1_4.FiscalDateType.FPTR_DT_START},
                { Microsoft.PointOfService.FiscalDateType.VatChange, UnifiedPOS.FiscalPrinter.V1_4.FiscalDateType.FPTR_DT_VAT },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalDateType.FPTR_DT_CONF, Microsoft.PointOfService.FiscalDateType.Configuration },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalDateType.FPTR_DT_EOD, Microsoft.PointOfService.FiscalDateType.EndOfDay },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalDateType.FPTR_DT_RTC, Microsoft.PointOfService.FiscalDateType.RealTimeClock },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalDateType.FPTR_DT_RESET, Microsoft.PointOfService.FiscalDateType.Reset },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalDateType.FPTR_DT_START, Microsoft.PointOfService.FiscalDateType.Start },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalDateType.FPTR_DT_VAT, Microsoft.PointOfService.FiscalDateType.VatChange },

                { Microsoft.PointOfService.FiscalErrorLevel.Blocked, UnifiedPOS.FiscalPrinter.V1_4.FiscalErrorLevel.FPTR_EL_BLOCKED },
                { Microsoft.PointOfService.FiscalErrorLevel.Fatal, UnifiedPOS.FiscalPrinter.V1_4.FiscalErrorLevel.FPTR_EL_FATAL},
                { Microsoft.PointOfService.FiscalErrorLevel.None, UnifiedPOS.FiscalPrinter.V1_4.FiscalErrorLevel.FPTR_EL_NONE},
                { Microsoft.PointOfService.FiscalErrorLevel.Recoverable, UnifiedPOS.FiscalPrinter.V1_4.FiscalErrorLevel.FPTR_EL_RECOVERABLE},
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalErrorLevel.FPTR_EL_BLOCKED, Microsoft.PointOfService.FiscalErrorLevel.Blocked },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalErrorLevel.FPTR_EL_FATAL, Microsoft.PointOfService.FiscalErrorLevel.Fatal },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalErrorLevel.FPTR_EL_NONE, Microsoft.PointOfService.FiscalErrorLevel.None },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalErrorLevel.FPTR_EL_RECOVERABLE, Microsoft.PointOfService.FiscalErrorLevel.Recoverable },

                { Microsoft.PointOfService.FiscalPrinterState.FiscalDocument, UnifiedPOS.FiscalPrinter.V1_4.FiscalPrinterState.FPTR_PS_FISCAL_DOCUMENT },
                { Microsoft.PointOfService.FiscalPrinterState.FiscalReceipt, UnifiedPOS.FiscalPrinter.V1_4.FiscalPrinterState.FPTR_PS_FISCAL_RECEIPT },
                { Microsoft.PointOfService.FiscalPrinterState.FiscalReceiptEnding, UnifiedPOS.FiscalPrinter.V1_4.FiscalPrinterState.FPTR_PS_FISCAL_RECEIPT_ENDING },
                { Microsoft.PointOfService.FiscalPrinterState.FiscalReceiptTotal, UnifiedPOS.FiscalPrinter.V1_4.FiscalPrinterState.FPTR_PS_FISCAL_RECEIPT_TOTAL },
                { Microsoft.PointOfService.FiscalPrinterState.FixedOutput, UnifiedPOS.FiscalPrinter.V1_4.FiscalPrinterState.FPTR_PS_FIXED_OUTPUT },
                { Microsoft.PointOfService.FiscalPrinterState.ItemList, UnifiedPOS.FiscalPrinter.V1_4.FiscalPrinterState.FPTR_PS_ITEM_LIST },
                { Microsoft.PointOfService.FiscalPrinterState.Locked, UnifiedPOS.FiscalPrinter.V1_4.FiscalPrinterState.FPTR_PS_LOCKED },
                { Microsoft.PointOfService.FiscalPrinterState.Monitor, UnifiedPOS.FiscalPrinter.V1_4.FiscalPrinterState.FPTR_PS_MONITOR},
                { Microsoft.PointOfService.FiscalPrinterState.NonFiscal, UnifiedPOS.FiscalPrinter.V1_4.FiscalPrinterState.FPTR_PS_NONFISCAL},
                { Microsoft.PointOfService.FiscalPrinterState.Report, UnifiedPOS.FiscalPrinter.V1_4.FiscalPrinterState.FPTR_PS_REPORT},

                { Microsoft.PointOfService.FiscalPrinterStations.Journal, UnifiedPOS.FiscalPrinter.V1_4.FiscalPrinterStations.FPTR_S_JOURNAL},
                { Microsoft.PointOfService.FiscalPrinterStations.JournalReceipt, UnifiedPOS.FiscalPrinter.V1_4.FiscalPrinterStations.FPTR_S_JOURNAL_RECEIPT },
                { Microsoft.PointOfService.FiscalPrinterStations.JournalSlip, UnifiedPOS.FiscalPrinter.V1_4.FiscalPrinterStations.FPTR_S_JOURNAL_SLIP },
                { Microsoft.PointOfService.FiscalPrinterStations.Receipt, UnifiedPOS.FiscalPrinter.V1_4.FiscalPrinterStations.FPTR_S_RECEIPT },
                { Microsoft.PointOfService.FiscalPrinterStations.ReceiptSlip, UnifiedPOS.FiscalPrinter.V1_4.FiscalPrinterStations.FPTR_S_RECEIPT_SLIP },
                { Microsoft.PointOfService.FiscalPrinterStations.Slip, UnifiedPOS.FiscalPrinter.V1_4.FiscalPrinterStations.FPTR_S_SLIP},
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalPrinterStations.FPTR_S_JOURNAL, Microsoft.PointOfService.FiscalPrinterStations.Journal },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalPrinterStations.FPTR_S_JOURNAL_RECEIPT, Microsoft.PointOfService.FiscalPrinterStations.JournalReceipt },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalPrinterStations.FPTR_S_JOURNAL_SLIP, Microsoft.PointOfService.FiscalPrinterStations.JournalSlip },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalPrinterStations.FPTR_S_RECEIPT, Microsoft.PointOfService.FiscalPrinterStations.Receipt },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalPrinterStations.FPTR_S_RECEIPT_SLIP, Microsoft.PointOfService.FiscalPrinterStations.ReceiptSlip },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalPrinterStations.FPTR_S_SLIP, Microsoft.PointOfService.FiscalPrinterStations.Slip },

                { Microsoft.PointOfService.FiscalReceiptStation.Receipt, UnifiedPOS.FiscalPrinter.V1_4.FiscalReceiptStation.FPTR_RS_RECEIPT},
                { Microsoft.PointOfService.FiscalReceiptStation.Slip, UnifiedPOS.FiscalPrinter.V1_4.FiscalReceiptStation.FPTR_RS_SLIP},
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalReceiptStation.FPTR_RS_RECEIPT, Microsoft.PointOfService.FiscalReceiptStation.Receipt },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalReceiptStation.FPTR_RS_SLIP, Microsoft.PointOfService.FiscalReceiptStation.Slip },

                { Microsoft.PointOfService.FiscalReceiptType.CashIn, UnifiedPOS.FiscalPrinter.V1_4.FiscalReceiptType.FPTR_RT_CASH_IN },
                { Microsoft.PointOfService.FiscalReceiptType.CashOut, UnifiedPOS.FiscalPrinter.V1_4.FiscalReceiptType.FPTR_RT_CASH_OUT },
                { Microsoft.PointOfService.FiscalReceiptType.Generic, UnifiedPOS.FiscalPrinter.V1_4.FiscalReceiptType.FPTR_RT_GENERIC },
                { Microsoft.PointOfService.FiscalReceiptType.Refund, UnifiedPOS.FiscalPrinter.V1_4.FiscalReceiptType.FPTR_RT_REFUND},
                { Microsoft.PointOfService.FiscalReceiptType.Sales, UnifiedPOS.FiscalPrinter.V1_4.FiscalReceiptType.FPTR_RT_SALES},
                { Microsoft.PointOfService.FiscalReceiptType.Service, UnifiedPOS.FiscalPrinter.V1_4.FiscalReceiptType.FPTR_RT_SERVICE},
                { Microsoft.PointOfService.FiscalReceiptType.SimpleInvoice, UnifiedPOS.FiscalPrinter.V1_4.FiscalReceiptType.FPTR_RT_SIMPLE_INVOICE },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalReceiptType.FPTR_RT_CASH_IN, Microsoft.PointOfService.FiscalReceiptType.CashIn },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalReceiptType.FPTR_RT_CASH_OUT, Microsoft.PointOfService.FiscalReceiptType.CashOut },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalReceiptType.FPTR_RT_GENERIC, Microsoft.PointOfService.FiscalReceiptType.Generic },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalReceiptType.FPTR_RT_REFUND, Microsoft.PointOfService.FiscalReceiptType.Refund },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalReceiptType.FPTR_RT_SALES, Microsoft.PointOfService.FiscalReceiptType.Sales },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalReceiptType.FPTR_RT_SERVICE, Microsoft.PointOfService.FiscalReceiptType.Service },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalReceiptType.FPTR_RT_SIMPLE_INVOICE, Microsoft.PointOfService.FiscalReceiptType.SimpleInvoice },

                { Microsoft.PointOfService.FiscalMessageType.Advance, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_ADVANCE},
                { Microsoft.PointOfService.FiscalMessageType.AdvancePaid, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_ADVANCE_PAID },
                { Microsoft.PointOfService.FiscalMessageType.AmountToBePaid, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_AMOUNT_TO_BE_PAID },
                { Microsoft.PointOfService.FiscalMessageType.AmountToBePaidBack, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_AMOUNT_TO_BE_PAID_BACK },
                { Microsoft.PointOfService.FiscalMessageType.Card, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_CARD },
                { Microsoft.PointOfService.FiscalMessageType.CardNumber, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_CARD_NUMBER },
                { Microsoft.PointOfService.FiscalMessageType.CardType, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_CARD_TYPE },
                { Microsoft.PointOfService.FiscalMessageType.Cash, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_CASH },
                { Microsoft.PointOfService.FiscalMessageType.Cashier, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_CASHIER },
                { Microsoft.PointOfService.FiscalMessageType.CashRegisterNumber, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_CASH_REGISTER_NUMBER },
                { Microsoft.PointOfService.FiscalMessageType.Change, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_CHANGE },
                { Microsoft.PointOfService.FiscalMessageType.Cheque, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_CHEQUE },
                { Microsoft.PointOfService.FiscalMessageType.ClientNumber, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_CLIENT_NUMBER },
                { Microsoft.PointOfService.FiscalMessageType.ClientSignature, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_CLIENT_SIGNATURE },
                { Microsoft.PointOfService.FiscalMessageType.CounterState, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_COUNTER_STATE },
                { Microsoft.PointOfService.FiscalMessageType.CreditCard, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_CREDIT_CARD },
                { Microsoft.PointOfService.FiscalMessageType.Currency, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_CURRENCY },
                { Microsoft.PointOfService.FiscalMessageType.CurrencyValue, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_CURRENCY_VALUE },
                { Microsoft.PointOfService.FiscalMessageType.Deposit, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_DEPOSIT},
                { Microsoft.PointOfService.FiscalMessageType.DepositReturned, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_DEPOSIT_RETURNED },
                { Microsoft.PointOfService.FiscalMessageType.DotLine, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_DOT_LINE },
                { Microsoft.PointOfService.FiscalMessageType.DriverNumber, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_DRIVER_NUMB },
                { Microsoft.PointOfService.FiscalMessageType.EmptyLine, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_EMPTY_LINE },
                { Microsoft.PointOfService.FiscalMessageType.FreeText, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_FREE_TEXT },
                { Microsoft.PointOfService.FiscalMessageType.FreeTextWithDayLimit, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_FREE_TEXT_WITH_DAY_LIMIT },
                { Microsoft.PointOfService.FiscalMessageType.GivenDiscount, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_GIVEN_DISCOUNT },
                { Microsoft.PointOfService.FiscalMessageType.LocalCredit, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_LOCAL_CREDIT },
                { Microsoft.PointOfService.FiscalMessageType.MileageKilometers, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_MILEAGE_KM },
                { Microsoft.PointOfService.FiscalMessageType.Note, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_NOTE},
                { Microsoft.PointOfService.FiscalMessageType.Paid, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_PAID},
                { Microsoft.PointOfService.FiscalMessageType.PayIn, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_PAY_IN },
                { Microsoft.PointOfService.FiscalMessageType.PointGranted, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_POINT_GRANTED },
                { Microsoft.PointOfService.FiscalMessageType.PointsBonus, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_POINTS_BONUS },
                { Microsoft.PointOfService.FiscalMessageType.PointsReceipt, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_POINTS_RECEIPT },
                { Microsoft.PointOfService.FiscalMessageType.PointsTotal, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_POINTS_TOTAL },
                { Microsoft.PointOfService.FiscalMessageType.Profited, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_PROFITED},
                { Microsoft.PointOfService.FiscalMessageType.Rate, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_RATE},
                { Microsoft.PointOfService.FiscalMessageType.RegisterNumber, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_REGISTER_NUMB },
                { Microsoft.PointOfService.FiscalMessageType.ShiftNumber, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_SHIFT_NUMBER },
                { Microsoft.PointOfService.FiscalMessageType.StateOfAnAccount, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_STATE_OF_AN_ACCOUNT },
                { Microsoft.PointOfService.FiscalMessageType.Subscription, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_SUBSCRIPTION},
                { Microsoft.PointOfService.FiscalMessageType.Table, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_TABLE},
                { Microsoft.PointOfService.FiscalMessageType.ThankYouForLoyalty, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_THANK_YOU_FOR_LOYALTY },
                { Microsoft.PointOfService.FiscalMessageType.TransactionNumber, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_TRANSACTION_NUMB },
                { Microsoft.PointOfService.FiscalMessageType.ValidTo, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_VALID_TO },
                { Microsoft.PointOfService.FiscalMessageType.Voucher, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_VOUCHER },
                { Microsoft.PointOfService.FiscalMessageType.VoucherPaid, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_VOUCHER_PAID },
                { Microsoft.PointOfService.FiscalMessageType.VoucherValue, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_VOUCHER_VALUE },
                { Microsoft.PointOfService.FiscalMessageType.WithDiscount, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_WITH_DISCOUNT },
                { Microsoft.PointOfService.FiscalMessageType.WithoutUplift, UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_WITHOUT_UPLIFT },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_ADVANCE, Microsoft.PointOfService.FiscalMessageType.Advance },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_ADVANCE_PAID, Microsoft.PointOfService.FiscalMessageType.AdvancePaid },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_AMOUNT_TO_BE_PAID, Microsoft.PointOfService.FiscalMessageType.AmountToBePaid },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_AMOUNT_TO_BE_PAID_BACK, Microsoft.PointOfService.FiscalMessageType.AmountToBePaidBack },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_CARD, Microsoft.PointOfService.FiscalMessageType.Card },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_CARD_NUMBER, Microsoft.PointOfService.FiscalMessageType.CardNumber },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_CARD_TYPE, Microsoft.PointOfService.FiscalMessageType.CardType },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_CASH, Microsoft.PointOfService.FiscalMessageType.Cash },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_CASHIER, Microsoft.PointOfService.FiscalMessageType.Cashier },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_CASH_REGISTER_NUMBER, Microsoft.PointOfService.FiscalMessageType.CashRegisterNumber },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_CHANGE, Microsoft.PointOfService.FiscalMessageType.Change },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_CHEQUE, Microsoft.PointOfService.FiscalMessageType.Cheque },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_CLIENT_NUMBER, Microsoft.PointOfService.FiscalMessageType.ClientNumber },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_CLIENT_SIGNATURE, Microsoft.PointOfService.FiscalMessageType.ClientSignature },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_COUNTER_STATE, Microsoft.PointOfService.FiscalMessageType.CounterState },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_CREDIT_CARD, Microsoft.PointOfService.FiscalMessageType.CreditCard },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_CURRENCY, Microsoft.PointOfService.FiscalMessageType.Currency },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_CURRENCY_VALUE, Microsoft.PointOfService.FiscalMessageType.CurrencyValue },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_DEPOSIT, Microsoft.PointOfService.FiscalMessageType.Deposit },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_DEPOSIT_RETURNED, Microsoft.PointOfService.FiscalMessageType.DepositReturned },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_DOT_LINE, Microsoft.PointOfService.FiscalMessageType.DotLine },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_DRIVER_NUMB, Microsoft.PointOfService.FiscalMessageType.DriverNumber },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_EMPTY_LINE, Microsoft.PointOfService.FiscalMessageType.EmptyLine },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_FREE_TEXT, Microsoft.PointOfService.FiscalMessageType.FreeText },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_FREE_TEXT_WITH_DAY_LIMIT, Microsoft.PointOfService.FiscalMessageType.FreeTextWithDayLimit },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_GIVEN_DISCOUNT, Microsoft.PointOfService.FiscalMessageType.GivenDiscount },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_LOCAL_CREDIT, Microsoft.PointOfService.FiscalMessageType.LocalCredit },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_MILEAGE_KM, Microsoft.PointOfService.FiscalMessageType.MileageKilometers },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_NOTE, Microsoft.PointOfService.FiscalMessageType.Note },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_PAID, Microsoft.PointOfService.FiscalMessageType.Paid },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_PAY_IN, Microsoft.PointOfService.FiscalMessageType.PayIn },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_POINT_GRANTED, Microsoft.PointOfService.FiscalMessageType.PointGranted },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_POINTS_BONUS, Microsoft.PointOfService.FiscalMessageType.PointsBonus },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_POINTS_RECEIPT, Microsoft.PointOfService.FiscalMessageType.PointsReceipt },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_POINTS_TOTAL, Microsoft.PointOfService.FiscalMessageType.PointsTotal },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_PROFITED, Microsoft.PointOfService.FiscalMessageType.Profited },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_RATE, Microsoft.PointOfService.FiscalMessageType.Rate },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_REGISTER_NUMB, Microsoft.PointOfService.FiscalMessageType.RegisterNumber },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_SHIFT_NUMBER, Microsoft.PointOfService.FiscalMessageType.ShiftNumber },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_STATE_OF_AN_ACCOUNT, Microsoft.PointOfService.FiscalMessageType.StateOfAnAccount },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_SUBSCRIPTION, Microsoft.PointOfService.FiscalMessageType.Subscription },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_TABLE, Microsoft.PointOfService.FiscalMessageType.Table },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_THANK_YOU_FOR_LOYALTY, Microsoft.PointOfService.FiscalMessageType.ThankYouForLoyalty },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_TRANSACTION_NUMB, Microsoft.PointOfService.FiscalMessageType.TransactionNumber },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_VALID_TO, Microsoft.PointOfService.FiscalMessageType.ValidTo },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_VOUCHER, Microsoft.PointOfService.FiscalMessageType.Voucher },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_VOUCHER_PAID, Microsoft.PointOfService.FiscalMessageType.VoucherPaid },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_VOUCHER_VALUE, Microsoft.PointOfService.FiscalMessageType.VoucherValue },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_WITH_DISCOUNT, Microsoft.PointOfService.FiscalMessageType.WithDiscount },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalMessageType.FPTR_MT_WITHOUT_UPLIFT, Microsoft.PointOfService.FiscalMessageType.WithoutUplift },

                { Microsoft.PointOfService.FiscalSlipSelection.FullLength, UnifiedPOS.FiscalPrinter.V1_4.FiscalSlipSelection.FPTR_SS_FULL_LENGTH },
                { Microsoft.PointOfService.FiscalSlipSelection.Validation, UnifiedPOS.FiscalPrinter.V1_4.FiscalSlipSelection.FPTR_SS_VALIDATION},
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalSlipSelection.FPTR_SS_FULL_LENGTH, Microsoft.PointOfService.FiscalSlipSelection.FullLength },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalSlipSelection.FPTR_SS_VALIDATION, Microsoft.PointOfService.FiscalSlipSelection.Validation },

                { Microsoft.PointOfService.FiscalTotalizerType.Day, UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizerType.FPTR_TT_DAY},
                { Microsoft.PointOfService.FiscalTotalizerType.Document, UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizerType.FPTR_TT_DOCUMENT},
                { Microsoft.PointOfService.FiscalTotalizerType.Grand, UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizerType.FPTR_TT_GRAND},
                { Microsoft.PointOfService.FiscalTotalizerType.Receipt, UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizerType.FPTR_TT_RECEIPT},
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizerType.FPTR_TT_DAY, Microsoft.PointOfService.FiscalTotalizerType.Day },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizerType.FPTR_TT_DOCUMENT, Microsoft.PointOfService.FiscalTotalizerType.Document },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizerType.FPTR_TT_GRAND, Microsoft.PointOfService.FiscalTotalizerType.Grand },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizerType.FPTR_TT_RECEIPT, Microsoft.PointOfService.FiscalTotalizerType.Receipt },

                { Microsoft.PointOfService.FiscalAdjustment.AmountDiscount, UnifiedPOS.FiscalPrinter.V1_4.FiscalAdjustment.FPTR_AT_AMOUNT_DISCOUNT },
                { Microsoft.PointOfService.FiscalAdjustment.AmountSurcharge, UnifiedPOS.FiscalPrinter.V1_4.FiscalAdjustment.FPTR_AT_AMOUNT_SURCHARGE },
                { Microsoft.PointOfService.FiscalAdjustment.CouponAmountDiscount, UnifiedPOS.FiscalPrinter.V1_4.FiscalAdjustment.FPTR_AT_COUPON_AMOUNT_DISCOUNT },
                { Microsoft.PointOfService.FiscalAdjustment.CouponPercentageDiscount, UnifiedPOS.FiscalPrinter.V1_4.FiscalAdjustment.FPTR_AT_COUPON_AMOUNT_PERCENTAGE_DISCOUNT },
                { Microsoft.PointOfService.FiscalAdjustment.PercentageDiscount, UnifiedPOS.FiscalPrinter.V1_4.FiscalAdjustment.FPTR_AT_PERCENTAGE_DISCOUNT },
                { Microsoft.PointOfService.FiscalAdjustment.PercentageSurcharge, UnifiedPOS.FiscalPrinter.V1_4.FiscalAdjustment.FPTR_AT_PERCENTAGE_SURCHARGE },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalAdjustment.FPTR_AT_AMOUNT_DISCOUNT, Microsoft.PointOfService.FiscalAdjustment.AmountDiscount },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalAdjustment.FPTR_AT_AMOUNT_SURCHARGE, Microsoft.PointOfService.FiscalAdjustment.AmountSurcharge },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalAdjustment.FPTR_AT_COUPON_AMOUNT_DISCOUNT, Microsoft.PointOfService.FiscalAdjustment.CouponAmountDiscount },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalAdjustment.FPTR_AT_COUPON_AMOUNT_PERCENTAGE_DISCOUNT, Microsoft.PointOfService.FiscalAdjustment.CouponPercentageDiscount },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalAdjustment.FPTR_AT_PERCENTAGE_DISCOUNT, Microsoft.PointOfService.FiscalAdjustment.PercentageDiscount },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalAdjustment.FPTR_AT_PERCENTAGE_SURCHARGE, Microsoft.PointOfService.FiscalAdjustment.PercentageSurcharge },

                { Microsoft.PointOfService.FiscalAdjustmentType.Discount, UnifiedPOS.FiscalPrinter.V1_4.FiscalAdjustmentType.FPTR_AT_DISCOUNT},
                { Microsoft.PointOfService.FiscalAdjustmentType.Surcharge, UnifiedPOS.FiscalPrinter.V1_4.FiscalAdjustmentType.FPTR_AT_SURCHARGE},
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalAdjustmentType.FPTR_AT_DISCOUNT, Microsoft.PointOfService.FiscalAdjustmentType.Discount },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalAdjustmentType.FPTR_AT_SURCHARGE, Microsoft.PointOfService.FiscalAdjustmentType.Surcharge },

                { Microsoft.PointOfService.ReportType.Date, UnifiedPOS.FiscalPrinter.V1_4.ReportType.FPTR_RT_DATE},
                { Microsoft.PointOfService.ReportType.EndOfDayOrdinal, UnifiedPOS.FiscalPrinter.V1_4.ReportType.FPTR_RT_EOD_ORDINAL },
                { Microsoft.PointOfService.ReportType.Ordinal, UnifiedPOS.FiscalPrinter.V1_4.ReportType.FPTR_RT_ORDINAL},
                { UnifiedPOS.FiscalPrinter.V1_4.ReportType.FPTR_RT_DATE, Microsoft.PointOfService.ReportType.Date },
                { UnifiedPOS.FiscalPrinter.V1_4.ReportType.FPTR_RT_EOD_ORDINAL, Microsoft.PointOfService.ReportType.EndOfDayOrdinal },
                { UnifiedPOS.FiscalPrinter.V1_4.ReportType.FPTR_RT_ORDINAL, Microsoft.PointOfService.ReportType.Ordinal },

                { Microsoft.PointOfService.FiscalData.CurrentTotal, UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_CURRENT_TOTAL },
                { Microsoft.PointOfService.FiscalData.DailyTotal, UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_DAILY_TOTAL },
                { Microsoft.PointOfService.FiscalData.DescriptionLength, UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_DESCRIPTION_LENGTH },
                { Microsoft.PointOfService.FiscalData.Firmware, UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_FIRMWARE },
                { Microsoft.PointOfService.FiscalData.FiscalDocument, UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_FISCAL_DOC },
                { Microsoft.PointOfService.FiscalData.FiscalDocumentVoid, UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_FISCAL_DOC_VOID },
                { Microsoft.PointOfService.FiscalData.FiscalReceipt, UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_FISCAL_REC },
                { Microsoft.PointOfService.FiscalData.FiscalReceiptVoid, UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_FISCAL_REC_VOID },
                { Microsoft.PointOfService.FiscalData.GrandTotal, UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_GRAND_TOTAL },
                { Microsoft.PointOfService.FiscalData.LineCount, UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_LINECOUNT },
                { Microsoft.PointOfService.FiscalData.NonFiscalDocument, UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_NONFISCAL_DOC },
                { Microsoft.PointOfService.FiscalData.NonFiscalDocumentVoid, UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_NONFISCAL_DOC_VOID },
                { Microsoft.PointOfService.FiscalData.NonFiscalReceipt, UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_NONFISCAL_REC },
                { Microsoft.PointOfService.FiscalData.NotPaid, UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_NOT_PAID },
                { Microsoft.PointOfService.FiscalData.NumberOfConfigurationBlocks, UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_NUMB_CONFIG_BLOCK },
                { Microsoft.PointOfService.FiscalData.NumberOfCurrencyBlocks, UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_NUMB_CURRENCY_BLOCK },
                { Microsoft.PointOfService.FiscalData.NumberOfHeaderBlocks, UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_NUMB_HDR_BLOCK },
                { Microsoft.PointOfService.FiscalData.NumberOfResetBlocks, UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_NUMB_RESET_BLOCK },
                { Microsoft.PointOfService.FiscalData.NumberOfVatBlocks, UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_NUMB_VAT_BLOCK },
                { Microsoft.PointOfService.FiscalData.NumberOfVoidedReceipts, UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_MID_VOID },
                { Microsoft.PointOfService.FiscalData.PrinterId, UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_PRINTER_ID },
                { Microsoft.PointOfService.FiscalData.ReceiptNumber, UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_RECEIPT_NUMBER },
                { Microsoft.PointOfService.FiscalData.Refund, UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_REFUND },
                { Microsoft.PointOfService.FiscalData.RefundVoid, UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_REFUND_VOID },
                { Microsoft.PointOfService.FiscalData.Restart, UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_RESTART },
                { Microsoft.PointOfService.FiscalData.SimplifiedInvoice, UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_SIMP_INVOICE },
                { Microsoft.PointOfService.FiscalData.Tender, UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_TENDER },
                { Microsoft.PointOfService.FiscalData.ZReport, UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_Z_REPORT },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_CURRENT_TOTAL, Microsoft.PointOfService.FiscalData.CurrentTotal },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_DAILY_TOTAL, Microsoft.PointOfService.FiscalData.DailyTotal },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_DESCRIPTION_LENGTH, Microsoft.PointOfService.FiscalData.DescriptionLength },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_FIRMWARE, Microsoft.PointOfService.FiscalData.Firmware },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_FISCAL_DOC, Microsoft.PointOfService.FiscalData.FiscalDocument },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_FISCAL_DOC_VOID, Microsoft.PointOfService.FiscalData.FiscalDocumentVoid },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_FISCAL_REC, Microsoft.PointOfService.FiscalData.FiscalReceipt },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_FISCAL_REC_VOID, Microsoft.PointOfService.FiscalData.FiscalReceiptVoid },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_GRAND_TOTAL, Microsoft.PointOfService.FiscalData.GrandTotal },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_LINECOUNT, Microsoft.PointOfService.FiscalData.LineCount },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_NONFISCAL_DOC, Microsoft.PointOfService.FiscalData.NonFiscalDocument },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_NONFISCAL_DOC_VOID, Microsoft.PointOfService.FiscalData.NonFiscalDocumentVoid },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_NONFISCAL_REC, Microsoft.PointOfService.FiscalData.NonFiscalReceipt },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_NOT_PAID, Microsoft.PointOfService.FiscalData.NotPaid },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_NUMB_CONFIG_BLOCK, Microsoft.PointOfService.FiscalData.NumberOfConfigurationBlocks },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_NUMB_CURRENCY_BLOCK, Microsoft.PointOfService.FiscalData.NumberOfCurrencyBlocks },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_NUMB_HDR_BLOCK, Microsoft.PointOfService.FiscalData.NumberOfHeaderBlocks },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_NUMB_RESET_BLOCK, Microsoft.PointOfService.FiscalData.NumberOfResetBlocks },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_NUMB_VAT_BLOCK, Microsoft.PointOfService.FiscalData.NumberOfVatBlocks },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_MID_VOID, Microsoft.PointOfService.FiscalData.NumberOfVoidedReceipts },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_PRINTER_ID, Microsoft.PointOfService.FiscalData.PrinterId },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_RECEIPT_NUMBER, Microsoft.PointOfService.FiscalData.ReceiptNumber },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_REFUND, Microsoft.PointOfService.FiscalData.Refund },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_REFUND_VOID, Microsoft.PointOfService.FiscalData.RefundVoid },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_RESTART, Microsoft.PointOfService.FiscalData.Restart },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_SIMP_INVOICE, Microsoft.PointOfService.FiscalData.SimplifiedInvoice },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_TENDER, Microsoft.PointOfService.FiscalData.Tender },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalData.FPTR_GD_Z_REPORT, Microsoft.PointOfService.FiscalData.ZReport },

                { Microsoft.PointOfService.FiscalTotalizer.Discount, UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizer.FPTR_GT_DISCOUNT},
                { Microsoft.PointOfService.FiscalTotalizer.DiscountVoid, UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizer.FPTR_GT_DISCOUNT_VOID },
                { Microsoft.PointOfService.FiscalTotalizer.Gross, UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizer.FPTR_GT_GROSS },
                { Microsoft.PointOfService.FiscalTotalizer.Item, UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizer.FPTR_GT_ITEM },
                { Microsoft.PointOfService.FiscalTotalizer.ItemVoid, UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizer.FPTR_GT_ITEM_VOID },
                { Microsoft.PointOfService.FiscalTotalizer.Net, UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizer.FPTR_GT_NET },
                { Microsoft.PointOfService.FiscalTotalizer.NotPaid, UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizer.FPTR_GT_NOT_PAID },
                { Microsoft.PointOfService.FiscalTotalizer.Refund, UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizer.FPTR_GT_REFUND },
                { Microsoft.PointOfService.FiscalTotalizer.RefundVoid, UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizer.FPTR_GT_REFUND_VOID },
                { Microsoft.PointOfService.FiscalTotalizer.SubtotalDiscount, UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizer.FPTR_GT_SUBTOTAL_DISCOUNT },
                { Microsoft.PointOfService.FiscalTotalizer.SubtotalDiscountVoid, UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizer.FPTR_GT_SUBTOTAL_DISCOUNT_VOID },
                { Microsoft.PointOfService.FiscalTotalizer.SubtotalSurcharges, UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizer.FPTR_GT_SUBTOTAL_SURCHARGES },
                { Microsoft.PointOfService.FiscalTotalizer.SubtotalSurchargesVoid, UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizer.FPTR_GT_SUBTOTAL_SURCHARGES_VOID },
                { Microsoft.PointOfService.FiscalTotalizer.Surcharge, UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizer.FPTR_GT_SURCHARGE },
                { Microsoft.PointOfService.FiscalTotalizer.SurchargeVoid, UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizer.FPTR_GT_SURCHARGE_VOID },
                { Microsoft.PointOfService.FiscalTotalizer.Vat, UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizer.FPTR_GT_VAT },
                { Microsoft.PointOfService.FiscalTotalizer.VatCategory, UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizer.FPTR_GT_VAT_CATEGORY },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizer.FPTR_GT_DISCOUNT, Microsoft.PointOfService.FiscalTotalizer.Discount },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizer.FPTR_GT_DISCOUNT_VOID, Microsoft.PointOfService.FiscalTotalizer.DiscountVoid },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizer.FPTR_GT_GROSS, Microsoft.PointOfService.FiscalTotalizer.Gross },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizer.FPTR_GT_ITEM, Microsoft.PointOfService.FiscalTotalizer.Item },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizer.FPTR_GT_ITEM_VOID, Microsoft.PointOfService.FiscalTotalizer.ItemVoid },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizer.FPTR_GT_NET, Microsoft.PointOfService.FiscalTotalizer.Net },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizer.FPTR_GT_NOT_PAID, Microsoft.PointOfService.FiscalTotalizer.NotPaid },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizer.FPTR_GT_REFUND, Microsoft.PointOfService.FiscalTotalizer.Refund },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizer.FPTR_GT_REFUND_VOID, Microsoft.PointOfService.FiscalTotalizer.RefundVoid },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizer.FPTR_GT_SUBTOTAL_DISCOUNT, Microsoft.PointOfService.FiscalTotalizer.SubtotalDiscount },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizer.FPTR_GT_SUBTOTAL_DISCOUNT_VOID, Microsoft.PointOfService.FiscalTotalizer.SubtotalDiscountVoid },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizer.FPTR_GT_SUBTOTAL_SURCHARGES, Microsoft.PointOfService.FiscalTotalizer.SubtotalSurcharges },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizer.FPTR_GT_SUBTOTAL_SURCHARGES_VOID, Microsoft.PointOfService.FiscalTotalizer.SubtotalSurchargesVoid },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizer.FPTR_GT_SURCHARGE, Microsoft.PointOfService.FiscalTotalizer.Surcharge },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizer.FPTR_GT_SURCHARGE_VOID, Microsoft.PointOfService.FiscalTotalizer.SurchargeVoid },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizer.FPTR_GT_VAT, Microsoft.PointOfService.FiscalTotalizer.Vat },
                { UnifiedPOS.FiscalPrinter.V1_4.FiscalTotalizer.FPTR_GT_VAT_CATEGORY, Microsoft.PointOfService.FiscalTotalizer.VatCategory },
            };

        private static Dictionary<Enum, Enum> EventConvert = new Dictionary<Enum, Enum>()
            {
                { Microsoft.PointOfService.ErrorCode.Busy, UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorCode.E_BUSY },
                { Microsoft.PointOfService.ErrorCode.Claimed, UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorCode.E_CLAIMED },
                { Microsoft.PointOfService.ErrorCode.Closed, UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorCode.E_CLOSED },
                { Microsoft.PointOfService.ErrorCode.Deprecated, UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorCode.E_DEPRECATED },
                { Microsoft.PointOfService.ErrorCode.Disabled, UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorCode.E_DISABLED },
                { Microsoft.PointOfService.ErrorCode.Exists, UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorCode.E_EXISTS },
                { Microsoft.PointOfService.ErrorCode.Extended, UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorCode.E_EXTENDED },
                { Microsoft.PointOfService.ErrorCode.Failure, UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorCode.E_FAILURE },
                { Microsoft.PointOfService.ErrorCode.Illegal, UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorCode.E_ILLEGAL },
                { Microsoft.PointOfService.ErrorCode.NoExist, UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorCode.E_NOEXIST },
                { Microsoft.PointOfService.ErrorCode.NoHardware, UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorCode.E_NOHARDWARE },
                { Microsoft.PointOfService.ErrorCode.NoService, UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorCode.E_NOSERVICE },
                { Microsoft.PointOfService.ErrorCode.NotClaimed, UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorCode.E_NOTCLAIMED },
                { Microsoft.PointOfService.ErrorCode.Offline, UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorCode.E_OFFLINE },
                //{ Microsoft.PointOfService.ErrorCode.Success, UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorCode.SUCCESS },
                { Microsoft.PointOfService.ErrorCode.Timeout, UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorCode.E_TIMEOUT },
                { UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorCode.E_BUSY, Microsoft.PointOfService.ErrorCode.Busy },
                { UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorCode.E_CLAIMED, Microsoft.PointOfService.ErrorCode.Claimed },
                { UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorCode.E_CLOSED, Microsoft.PointOfService.ErrorCode.Closed },
                { UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorCode.E_DEPRECATED, Microsoft.PointOfService.ErrorCode.Deprecated },
                { UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorCode.E_DISABLED, Microsoft.PointOfService.ErrorCode.Disabled },
                { UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorCode.E_EXISTS, Microsoft.PointOfService.ErrorCode.Exists },
                { UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorCode.E_EXTENDED, Microsoft.PointOfService.ErrorCode.Extended },
                { UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorCode.E_FAILURE, Microsoft.PointOfService.ErrorCode.Failure },
                { UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorCode.E_ILLEGAL, Microsoft.PointOfService.ErrorCode.Illegal },
                { UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorCode.E_NOEXIST, Microsoft.PointOfService.ErrorCode.NoExist },
                { UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorCode.E_NOHARDWARE, Microsoft.PointOfService.ErrorCode.NoHardware },
                { UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorCode.E_NOSERVICE, Microsoft.PointOfService.ErrorCode.NoService },
                { UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorCode.E_NOTCLAIMED, Microsoft.PointOfService.ErrorCode.NotClaimed },
                { UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorCode.E_OFFLINE, Microsoft.PointOfService.ErrorCode.Offline },
                //{ UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorCode.SUCCESS, Microsoft.PointOfService.ErrorCode.Success },
                { UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorCode.E_TIMEOUT, Microsoft.PointOfService.ErrorCode.Timeout },

                { Microsoft.PointOfService.ErrorLocus.Input, UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorLocus.EL_INPUT },
                { Microsoft.PointOfService.ErrorLocus.InputData, UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorLocus.EL_INPUT_DATA },
                { Microsoft.PointOfService.ErrorLocus.Output, UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorLocus.EL_OUTPUT },
                { UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorLocus.EL_INPUT, Microsoft.PointOfService.ErrorLocus.Input },
                { UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorLocus.EL_INPUT_DATA, Microsoft.PointOfService.ErrorLocus.InputData },
                { UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorLocus.EL_OUTPUT, Microsoft.PointOfService.ErrorLocus.Output },

                { Microsoft.PointOfService.ErrorResponse.Clear, UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorResponse.ER_CLEAR },
                { Microsoft.PointOfService.ErrorResponse.ContinueInput, UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorResponse.ER_CONTINUEINPUT },
                { Microsoft.PointOfService.ErrorResponse.Retry, UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorResponse.ER_RETRY },
                { UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorResponse.ER_CLEAR, Microsoft.PointOfService.ErrorResponse.Clear },
                { UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorResponse.ER_CONTINUEINPUT, Microsoft.PointOfService.ErrorResponse.ContinueInput },
                { UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorResponse.ER_RETRY, Microsoft.PointOfService.ErrorResponse.Retry },

                // Long Polling時の受信の名前空間はデバイスの名前空間にEventsがサフィックスされない
                // Events are not suffixed to the name space of event class which is received by PollForUPOSEvent
                { UnifiedPOS.FiscalPrinter.V1_4.ErrorResponse.ER_CLEAR, Microsoft.PointOfService.ErrorResponse.Clear },
                { UnifiedPOS.FiscalPrinter.V1_4.ErrorResponse.ER_CONTINUEINPUT, Microsoft.PointOfService.ErrorResponse.ContinueInput },
                { UnifiedPOS.FiscalPrinter.V1_4.ErrorResponse.ER_RETRY, Microsoft.PointOfService.ErrorResponse.Retry },
            };
        #endregion


        /// <summary>
        /// 派生クラスからコンストラクタに渡されるDeviceControlDescriptionを格納
        /// </summary>
        private string _deviceControlDescription;

        /// <summary>
        /// 派生クラスからコンストラクタに渡されるDeviceControlVersionを格納
        /// </summary>
        private UposVersion _deviceControlVersion;

        /// <summary>
        /// 派生クラスからコンストラクタに渡されるWS-POSVersionを格納
        /// </summary>
        private UposVersion _wsposVersion;




        #region Constructor

        /// <summary>
        /// 呼び出せないようにprivateで宣言されています
        /// It is declared as private so that it cannot call. 
        /// </summary>
        private FiscalPrinterServiceProviderBehaviorCore()
        {
        }

        /// <summary>
        /// コンストラクタ
        /// Constructor
        /// </summary>
        /// <param name="deviceControlDescription">DeviceControlDescription string</param>
        /// <param name="deviceControlVersion">Version value of DeviceControlVersion</param>
        /// <param name="wsposVersion">Version value of WS-POS</param>
        /// <param name="providerSessionTimeoutCheckPeriod">プロバイダのセッションタイムアウトをチェックする間隔（秒）| Interval to check the session timeout of the provider (second)</param>
        public FiscalPrinterServiceProviderBehaviorCore(string deviceControlDescription, UposVersion deviceControlVersion, UposVersion wsposVersion, int providerSessionTimeoutCheckPeriod)
            : base(providerSessionTimeoutCheckPeriod)
        {
            _deviceControlDescription = deviceControlDescription;
            _deviceControlVersion = deviceControlVersion;
            _wsposVersion = wsposVersion;
        }

        #endregion

        #region FiscalPrinter Member

        #region FiscalPrinter Properties

        public virtual int GetOutputID(string ConsumerID)
        {
            try
            {
                int value = 0;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).OutputId;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapAdditionalHeader(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapAdditionalHeader;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapAdditionalLines(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapAdditionalLines;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapAdditionalTrailer(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapAdditionalTrailer;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapAmountAdjustment(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapAmountAdjustment;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapChangeDue(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapChangeDue;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapCheckTotal(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapCheckTotal;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapCoverSensor(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapCoverSensor;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapDoubleWidth(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapDoubleWidth;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapDuplicateReceipt(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapDuplicateReceipt;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapEmptyReceiptIsVoidable(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapEmptyReceiptIsVoidable;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapFiscalReceiptStation(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapFiscalReceiptStation;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapFiscalReceiptType(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapFiscalReceiptType;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapFixedOutput(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapFixedOutput;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapHasVatTable(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapHasVatTable;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapIndependentHeader(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapIndependentHeader;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapItemList(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapItemList;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapJrnEmptySensor(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapJrnEmptySensor;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapJrnNearEndSensor(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapJrnNearEndSensor;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapJrnPresent(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapJrnPresent;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapMultiContractor(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapMultiContractor;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapNonFiscalMode(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapNonFiscalMode;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapOnlyVoidLastItem(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapOnlyVoidLastItem;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapOrderAdjustmentFirst(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapOrderAdjustmentFirst;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapPackageAdjustment(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapPackageAdjustment;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapPercentAdjustment(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapPercentAdjustment;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapPositiveAdjustment(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapPositiveAdjustment;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapPositiveSubtotalAdjustment(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapPositiveSubtotalAdjustment;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapPostPreLine(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapPostPreLine;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapPowerLossReport(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapPowerLossReport;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapPredefinedPaymentLines(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapPredefinedPaymentLines;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapReceiptNotPaid(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapReceiptNotPaid;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapRecEmptySensor(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapRecEmptySensor;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapRecNearEndSensor(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapRecNearEndSensor;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapRecPresent(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapRecPresent;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapRemainingFiscalMemory(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapRemainingFiscalMemory;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapReservedWord(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapReservedWord;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapSetCurrency(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapSetCurrency;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapSetHeader(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapSetHeader;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapSetPOSID(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapSetPosId;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapSetStoreFiscalID(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapSetStoreFiscalId;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapSetTrailer(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapSetTrailer;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapSetVatTable(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapSetVatTable;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapSlpEmptySensor(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapSlpEmptySensor;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapSlpFiscalDocument(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapSlpFiscalDocument;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapSlpFullSlip(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapSlpFullSlip;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapSlpNearEndSensor(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapSlpNearEndSensor;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapSlpPresent(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapSlpPresent;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapSlpValidation(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapSlpValidation;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapSubAmountAdjustment(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapSubAmountAdjustment;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapSubPercentAdjustment(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapSubPercentAdjustment;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapSubtotal(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapSubtotal;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapTotalizerType(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapTotalizerType;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapTrainingMode(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapTrainingMode;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapValidateJournal(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapValidateJournal;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapXReport(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapXReport;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual FiscalCurrency GetActualCurrency(string ConsumerID)
        {
            try
            {
                FiscalCurrency value = FiscalCurrency.Other;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = (FiscalCurrency)Convert[ConcretizationDevice(sessionContext.Device).ActualCurrency];
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual string GetAdditionalHeader(string ConsumerID)
        {
            try
            {
                string value = null;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).AdditionalHeader;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual void SetAdditionalHeader(string ConsumerID, string AdditionalHeader)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).AdditionalHeader = AdditionalHeader;
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual string GetAdditionalTrailer(string ConsumerID)
        {
            try
            {
                string value = null;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).AdditionalTrailer;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual void SetAdditionalTrailer(string ConsumerID, string AdditionalTrailer)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).AdditionalTrailer = AdditionalTrailer;
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual int GetAmountDecimalPlaces(string ConsumerID)
        {
            try
            {
                int value = 0;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).AmountDecimalPlaces;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetAsyncMode(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).AsyncMode;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual void SetAsyncMode(string ConsumerID, bool AsyncMode)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).AsyncMode = AsyncMode;
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual string GetChangeDue(string ConsumerID)
        {
            try
            {
                string value = null;
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).ChangeDue;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual void SetChangeDue(string ConsumerID, string ChangeDue)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).ChangeDue = ChangeDue;
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCheckTotal(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CheckTotal;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual void SetCheckTotal(string ConsumerID, bool CheckTotal)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).CheckTotal = CheckTotal;
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual FiscalContractorID GetContractorID(string ConsumerID)
        {
            try
            {
                FiscalContractorID value = FiscalContractorID.FPTR_CID_SINGLE;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = (FiscalContractorID)Convert[ConcretizationDevice(sessionContext.Device).ContractorId];
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual void SetContractorID(string ConsumerID, FiscalContractorID ContractorID)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).ContractorId = (Microsoft.PointOfService.FiscalContractorId)Convert[ContractorID];
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual int GetCountryCode(string ConsumerID)
        {
            try
            {
                int value = 0;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = (int)ConcretizationDevice(sessionContext.Device).CountryCode;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual bool GetCoverOpen(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CoverOpen;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual FiscalDateType GetDateType(string ConsumerID)
        {
            try
            {
                FiscalDateType value = FiscalDateType.FPTR_DT_CONF;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = (FiscalDateType)Convert[ConcretizationDevice(sessionContext.Device).DateType];
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual void SetDateType(string ConsumerID, FiscalDateType DateType)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).DateType = (Microsoft.PointOfService.FiscalDateType)Convert[DateType];
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetDayOpened(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).DayOpened;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual int GetDescriptionLength(string ConsumerID)
        {
            try
            {
                int value = 0;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).DescriptionLength;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetDuplicateReceipt(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).DuplicateReceipt;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual void SetDuplicateReceipt(string ConsumerID, bool DuplicateReceipt)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).DuplicateReceipt = DuplicateReceipt;
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual FiscalErrorLevel GetErrorLevel(string ConsumerID)
        {
            try
            {
                FiscalErrorLevel value = FiscalErrorLevel.FPTR_EL_NONE;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = (FiscalErrorLevel)Convert[ConcretizationDevice(sessionContext.Device).ErrorLevel];
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual int GetErrorOutID(string ConsumerID)
        {
            try
            {
                int value = 0;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).ErrorOutId;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual FiscalPrinterState GetErrorState(string ConsumerID)
        {
            try
            {
                FiscalPrinterState value = FiscalPrinterState.FPTR_PS_FISCAL_DOCUMENT;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = (FiscalPrinterState)Convert[ConcretizationDevice(sessionContext.Device).ErrorState];
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual FiscalPrinterStations GetErrorStation(string ConsumerID)
        {
            try
            {
                FiscalPrinterStations value = FiscalPrinterStations.FPTR_S_RECEIPT;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = (FiscalPrinterStations)Convert[ConcretizationDevice(sessionContext.Device).ErrorStation];
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual string GetErrorString(string ConsumerID)
        {
            try
            {
                string value = null;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).ErrorString;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual FiscalReceiptStation GetFiscalReceiptStation(string ConsumerID)
        {
            try
            {
                FiscalReceiptStation value = FiscalReceiptStation.FPTR_RS_RECEIPT;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = (FiscalReceiptStation)Convert[ConcretizationDevice(sessionContext.Device).FiscalReceiptStation];
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual void SetFiscalReceiptStation(string ConsumerID, FiscalReceiptStation FiscalReceiptStation)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).FiscalReceiptStation = (Microsoft.PointOfService.FiscalReceiptStation)Convert[FiscalReceiptStation];
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual FiscalReceiptType GetFiscalReceiptType(string ConsumerID)
        {
            try
            {
                FiscalReceiptType value = FiscalReceiptType.FPTR_RT_GENERIC;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = (FiscalReceiptType)Convert[ConcretizationDevice(sessionContext.Device).FiscalReceiptType];
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual void SetFiscalReceiptType(string ConsumerID, FiscalReceiptType FiscalReceiptType)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).FiscalReceiptType = (Microsoft.PointOfService.FiscalReceiptType)Convert[FiscalReceiptType];
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetFlagWhenIdle(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).FlagWhenIdle;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual void SetFlagWhenIdle(string ConsumerID, bool FlagWhenIdle)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).FlagWhenIdle = FlagWhenIdle;
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetJrnEmpty(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).JrnEmpty;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetJrnNearEnd(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).JrnNearEnd;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual int GetMessageLength(string ConsumerID)
        {
            try
            {
                int value = 0;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).MessageLength;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual FiscalMessageType GetMessageType(string ConsumerID)
        {
            try
            {
                FiscalMessageType value = FiscalMessageType.FPTR_MT_ADVANCE;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = (FiscalMessageType)Convert[ConcretizationDevice(sessionContext.Device).MessageType];
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual void SetMessageType(string ConsumerID, FiscalMessageType MessageType)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).MessageType = (Microsoft.PointOfService.FiscalMessageType)Convert[MessageType];
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual int GetNumHeaderLines(string ConsumerID)
        {
            try
            {
                int value = 0;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).NumHeaderLines;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual int GetNumTrailerLines(string ConsumerID)
        {
            try
            {
                int value = 0;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).NumTrailerLines;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual int GetNumVatRates(string ConsumerID)
        {
            try
            {
                int value = 0;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).NumVatRates;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual string GetPostLine(string ConsumerID)
        {
            try
            {
                string value = null;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).PostLine;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual void SetPostLine(string ConsumerID, string PostLine)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).PostLine = PostLine;
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual PaymentLinesList GetPredefinedPaymentLines(string ConsumerID)
        {
            try
            {
                PaymentLinesList res = new PaymentLinesList();

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    res.AddRange(ConcretizationDevice(sessionContext.Device).PredefinedPaymentLines);
                });

                return res;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual string GetPreLine(string ConsumerID)
        {
            try
            {
                string value = null;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).PreLine;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual void SetPreLine(string ConsumerID, string PreLine)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).PreLine = PreLine;
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual FiscalPrinterState GetPrinterState(string ConsumerID)
        {
            try
            {
                FiscalPrinterState value = FiscalPrinterState.FPTR_PS_FISCAL_DOCUMENT;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = (FiscalPrinterState)Convert[ConcretizationDevice(sessionContext.Device).PrinterState];
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual int GetQuantityDecimalPlaces(string ConsumerID)
        {
            try
            {
                int value = 0;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).QuantityDecimalPlaces;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual int GetQuantityLength(string ConsumerID)
        {
            try
            {
                int value = 0;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).QuantityLength;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetRecEmpty(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).RecEmpty;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetRecNearEnd(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).RecNearEnd;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual int GetRemainingFiscalMemory(string ConsumerID)
        {
            try
            {
                int value = 0;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).RemainingFiscalMemory;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual string GetReservedWord(string ConsumerID)
        {
            try
            {
                string value = null;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).ReservedWord;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetSlpEmpty(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).SlpEmpty;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetSlpNearEnd(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).SlpNearEnd;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual FiscalSlipSelection GetSlipSelection(string ConsumerID)
        {
            try
            {
                FiscalSlipSelection value = FiscalSlipSelection.FPTR_SS_FULL_LENGTH;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = (FiscalSlipSelection)Convert[ConcretizationDevice(sessionContext.Device).SlipSelection];
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual void SetSlipSelection(string ConsumerID, FiscalSlipSelection SlipSelection)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).SlipSelection = (Microsoft.PointOfService.FiscalSlipSelection)Convert[SlipSelection];
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual FiscalTotalizerType GetTotalizerType(string ConsumerID)
        {
            try
            {
                FiscalTotalizerType value = FiscalTotalizerType.FPTR_TT_DOCUMENT;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = (FiscalTotalizerType)Convert[ConcretizationDevice(sessionContext.Device).TotalizerType];
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual void SetTotalizerType(string ConsumerID, FiscalTotalizerType TotalizerType)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).TotalizerType = (Microsoft.PointOfService.FiscalTotalizerType)Convert[TotalizerType];
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetTrainingModeActive(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).TrainingModeActive;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual PowerReporting GetCapPowerReporting(string ConsumerID)
        {
            try
            {
                PowerReporting value = PowerReporting.PR_NONE;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = (PowerReporting)Convert[ConcretizationDevice(sessionContext.Device).CapPowerReporting];
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapStatisticsReporting(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapStatisticsReporting;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapUpdateStatistics(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapUpdateStatistics;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual string GetCheckHealthText(string ConsumerID)
        {
            try
            {
                string value = null;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CheckHealthText;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetClaimed(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).Claimed;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetDeviceEnabled(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).DeviceEnabled;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual void SetDeviceEnabled(string ConsumerID, bool DeviceEnabled)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).DeviceEnabled = DeviceEnabled;
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetFreezeEvents(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).FreezeEvents;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual void SetFreezeEvents(string ConsumerID, bool FreezeEvents)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).FreezeEvents = FreezeEvents;
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual PowerNotification GetPowerNotify(string ConsumerID)
        {
            try
            {
                PowerNotification value = PowerNotification.PN_DISABLED;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = (PowerNotification)Convert[ConcretizationDevice(sessionContext.Device).PowerNotify];
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual void SetPowerNotify(string ConsumerID, PowerNotification PowerNotify)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).PowerNotify = (Microsoft.PointOfService.PowerNotification)Convert[PowerNotify];
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual PowerState GetPowerState(string ConsumerID)
        {
            try
            {
                PowerState value = PowerState.PS_UNKNOWN;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = (PowerState)Convert[ConcretizationDevice(sessionContext.Device).PowerState];
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual ControlState GetState(string ConsumerID)
        {
            try
            {
                ControlState value = ControlState.S_CLOSED;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = (ControlState)Convert[ConcretizationDevice(sessionContext.Device).State];
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapCompareFirmwareVersion(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapCompareFirmwareVersion;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }
        public virtual bool GetCapUpdateFirmware(string ConsumerID)
        {
            try
            {
                bool value = false;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).CapUpdateFirmware;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual string GetDeviceControlDescription(string ConsumerID)
        {
            base.GetSessionContext(ConsumerID); // セッションタイムアウトをクリアするために取得する
            return _deviceControlDescription;
        }

        public virtual UposVersion GetDeviceControlVersion(string ConsumerID)
        {
            base.GetSessionContext(ConsumerID); // セッションタイムアウトをクリアするために取得する
            return _deviceControlVersion;
        }

        public virtual string GetDeviceServiceDescription(string ConsumerID)
        {
            try
            {
                string value = null;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).ServiceObjectDescription;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual UposVersion GetDeviceServiceVersion(string ConsumerID)
        {
            try
            {
                Version value = new Version(0, 0, 0);
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).ServiceObjectVersion;
                });
                return new UposVersion() { Build = value.Build, Major = value.Major, Minor = value.Minor };
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }

        }

        public virtual string GetPhysicalDeviceDescription(string ConsumerID)
        {
            try
            {
                string value = null;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).DeviceDescription;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual string GetPhysicalDeviceName(string ConsumerID)
        {
            try
            {
                string value = null;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).DeviceName;
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        #endregion

        #region FiscalPrinter Methods

        public virtual string GetEncryptedClaimedConsumerID()
        {
            try
            {
                var consumerIDs = base.GetAllSessionIDs();

                string claimedConsumerID = null;

            LOOP_START:

                foreach (var id in consumerIDs)
                {
                    try
                    {
                        if (claimedConsumerID != null)
                        {
                            break;
                        }

                        var sessionContext = base.GetSessionContext(id);
                        sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                        {
                            if (ConcretizationDevice(sessionContext.Device).Claimed)
                            {
                                claimedConsumerID = id;
                            }
                        });
                    }
                    catch (KeyNotFoundException)
                    {
                        ;// 時間差で削除された
                    }
                    catch (InvalidOperationException)
                    {
                        goto LOOP_START;// 時間差で削除された
                    }
                    catch (Microsoft.PointOfService.PosControlException)
                    {
                        ;// Closeされた
                    }
                }

                if (claimedConsumerID != null)
                {
                    return base.EncryptConsumerID(claimedConsumerID);
                }
                else
                {
                    return null;
                }
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void OpenSession(string ConsumerID, string EndpointAddress)
        {
            try
            {
                UnifiedPOS.FiscalPrinterEvents.V1_4.FiscalPrinterEvent deviceEvent = null;
                if (EndpointAddress != null)
                {
                    ChannelFactory<UnifiedPOS.FiscalPrinterEvents.V1_4.FiscalPrinterEvent> factory =
                        new ChannelFactory<UnifiedPOS.FiscalPrinterEvents.V1_4.FiscalPrinterEvent>("FiscalPrinterEventPort", new EndpointAddress(EndpointAddress));

                    deviceEvent = factory.CreateChannel();
                }

                ISessionContext sessionContext = base.CreateSessionContext(ConsumerID, deviceEvent);

                sessionContext.ServiceDirectIOEvent += new EventHandler<Microsoft.PointOfService.DirectIOEventArgs>(SessionContext_ServiceDirectIOEvent);
                sessionContext.ServiceDataEvent += new EventHandler<Microsoft.PointOfService.DataEventArgs>(SessionContext_ServiceDataEvent);
                sessionContext.ServiceErrorEvent += new EventHandler<Microsoft.PointOfService.DeviceErrorEventArgs>(SessionContext_ServiceErrorEvent);
                sessionContext.ServiceOutputCompleteEvent += new EventHandler<Microsoft.PointOfService.OutputCompleteEventArgs>(SessionContext_ServiceOutputCompleteEvent);
                sessionContext.ServiceStatusUpdateEvent += new EventHandler<Microsoft.PointOfService.StatusUpdateEventArgs>(SessionContext_ServiceStatusUpdateEvent);

                foreach (ServiceEndpoint Endpoint in OperationContext.Current.Host.Description.Endpoints)
                {
                    if (Endpoint.Address.Equals(OperationContext.Current.Channel.LocalAddress))
                    {
                        ConfigDeviceBehavior ConfigDevice = Endpoint.Behaviors.Find<ConfigDeviceBehavior>();
                        if (ConfigDevice != null)
                        {
                            sessionContext.DeviceName = ConfigDevice.deviceName;
                            sessionContext.ProviderSessionTimeout = ConfigDevice.providerSessionTimeout;
                            sessionContext.EventPollingTimeout = ConfigDevice.eventPollingTimeout > 0 ? ConfigDevice.eventPollingTimeout * 1000 : ConfigDevice.eventPollingTimeout;
                            sessionContext.EventResponseTimeout = ConfigDevice.eventResponseTimeout > 0 ? ConfigDevice.eventResponseTimeout * 1000 : ConfigDevice.eventResponseTimeout;
                            sessionContext.CodePageConversion = ConfigDevice.codePageConversion;
                        }
                    }
                }

                base.AddSession(ConsumerID, sessionContext);
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void OpenDevice(string ConsumerID)
        {
            try
            {
                ISessionContext sessionContext = GetSessionContext(ConsumerID);

                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    base.OpenDeviceInSessionContext(sessionContext, "FiscalPrinter", sessionContext.DeviceName);

                    var device = ConcretizationDevice(sessionContext.Device);
                    device.Open();
                    //device.DataEvent += new Microsoft.PointOfService.DataEventHandler(sessionContext.DeviceDataEventHandler);
                    device.DirectIOEvent += new Microsoft.PointOfService.DirectIOEventHandler(sessionContext.DeviceDirectIOEventHandler);
                    device.ErrorEvent += new Microsoft.PointOfService.DeviceErrorEventHandler(sessionContext.DeviceErrorEventHandler);
                    device.OutputCompleteEvent += new Microsoft.PointOfService.OutputCompleteEventHandler(sessionContext.DeviceOutputCompleteEventHandler);
                    device.StatusUpdateEvent += new Microsoft.PointOfService.StatusUpdateEventHandler(sessionContext.DeviceStatusUpdateEventHandler);

                    sessionContext.IsLegacySO = false;
                    try
                    {
                        // OPOS Legacy SO の場合は BinaryConversion を設定する。設定に成功するならば LegacySOと判断する。
                        var legacyDevice = (Microsoft.PointOfService.ILegacyControlObject)device;
                        sessionContext.IsLegacySO = true;
                        legacyDevice.BinaryConversion = Microsoft.PointOfService.BinaryConversion.Nibble;
                    }
                    catch { }
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void CloseDevice(string ConsumerID)
        {
            try
            {
                ISessionContext sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    DisposeDevice(sessionContext);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void CloseSession(string ConsumerID)
        {
            try
            {
                ISessionContext sessionContext = base.GetSessionContext(ConsumerID);
                CloseSessionResources(sessionContext);

                base.RemoveSessionContext(ConsumerID);
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }


        public virtual void BeginRemoval(string ConsumerID, int Timeout)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).BeginRemoval(Timeout);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void BeginTraining(string ConsumerID)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).BeginTraining();
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void ClearError(string ConsumerID)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).ClearError();
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void EndFiscalDocument(string ConsumerID)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).EndFiscalDocument();
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void EndFiscalReceipt(string ConsumerID, bool PrintHeader)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).EndFiscalReceipt(PrintHeader);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void EndFixedOutput(string ConsumerID)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).EndFixedOutput();
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void EndInsertion(string ConsumerID)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).EndInsertion();
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void EndItemList(string ConsumerID)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).EndItemList();
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void EndNonFiscal(string ConsumerID)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).EndNonFiscal();
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void EndRemoval(string ConsumerID)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).EndRemoval();
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void EndTraining(string ConsumerID)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).EndTraining();
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual FiscalDataItem GetData(string ConsumerID, FiscalData DataItem, int OptArgs)
        {
            try
            {
                Microsoft.PointOfService.FiscalDataItem value = new Microsoft.PointOfService.FiscalDataItem();

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).GetData((Microsoft.PointOfService.FiscalData)DataItem, OptArgs);
                });

                return new FiscalDataItem() { Data = value.Data, ItemOption = value.ItemOption };
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual DateTime GetDate(string ConsumerID)
        {
            try
            {
                DateTime value = DateTime.MinValue;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).GetDate();
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual string GetTotalizer(string ConsumerID, int VatID, FiscalTotalizer OptArgs)
        {
            try
            {
                string value = null;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).GetTotalizer(VatID, (Microsoft.PointOfService.FiscalTotalizer)Convert[OptArgs]);
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual int GetVatEntry(string ConsumerID, int VatID, int OptArgs)
        {
            try
            {
                int value = 0;

                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    value = ConcretizationDevice(sessionContext.Device).GetVatEntry(VatID, OptArgs);
                });

                return value;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void PrintDuplicateReceipt(string ConsumerID)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).PrintDuplicateReceipt();
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void PrintFiscalDocumentLine(string ConsumerID, string DocumentLine)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).PrintFiscalDocumentLine(DocumentLine);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void PrintFixedOutput(string ConsumerID, int DocumentType, int LineNumber, string Data)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).PrintFixedOutput(DocumentType, LineNumber, base.ProcessEscapeSequence(Data));
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void PrintNormal(string ConsumerID, FiscalPrinterStations Station, string Data)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    var value = base.ConvertARTSBinaryToString(sessionContext.IsLegacySO, sessionContext.CodePageConversion, Data);
                    ConcretizationDevice(sessionContext.Device).PrintNormal((Microsoft.PointOfService.FiscalPrinterStations)Convert[Station], base.ProcessEscapeSequence(value));
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void PrintPeriodicTotalsReport(string ConsumerID, DateTime Date1, DateTime Date2)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).PrintPeriodicTotalsReport(Date1, Date2);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void PrintPowerLossReport(string ConsumerID)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).PrintPowerLossReport();
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void PrintRecCash(string ConsumerID, Decimal Amount)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).PrintRecCash(Amount);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void PrintRecItem(string ConsumerID, string Description, Decimal Price, int Quantity, int VatInfo, Decimal UnitPrice, string UnitName)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).PrintRecItem(Description, Price, Quantity, VatInfo, UnitPrice, UnitName);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void PrintRecItemAdjustment(string ConsumerID, FiscalAdjustment AdjustmentType, string Description, Decimal Amount, int VatInfo)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).PrintRecItemAdjustment((Microsoft.PointOfService.FiscalAdjustment)Convert[AdjustmentType], Description, Amount, VatInfo);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void PrintRecItemAdjustmentVoid(string ConsumerID, FiscalAdjustment AdjustmentType, string Description, Decimal Amount, int VatInfo)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).PrintRecItemAdjustmentVoid((Microsoft.PointOfService.FiscalAdjustment)Convert[AdjustmentType], Description, Amount, VatInfo);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void PrintRecItemFuel(string ConsumerID, string Description, Decimal Price, int Quantity, int VatInfo, Decimal UnitPrice, string UnitName, Decimal SpecialTax, string SpecialTaxName)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).PrintRecItemFuel(Description, Price, Quantity, VatInfo, UnitPrice, UnitName, SpecialTax, SpecialTaxName);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void PrintRecItemFuelVoid(string ConsumerID, string Description, Decimal Price, int VatInfo, Decimal SpecialTax)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).PrintRecItemFuelVoid(Description, Price, VatInfo, SpecialTax);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void PrintRecItemVoid(string ConsumerID, string Description, Decimal Price, int Quantity, int VatInfo, Decimal UnitPrice, string UnitName)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).PrintRecItemVoid(Description, Price, Quantity, VatInfo, UnitPrice, UnitName);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void PrintRecMessage(string ConsumerID, string Message)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).PrintRecMessage(Message);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void PrintRecNotPaid(string ConsumerID, string Description, Decimal Amount)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).PrintRecNotPaid(Description, Amount);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void PrintRecPackageAdjustment(string ConsumerID, FiscalAdjustmentType AdjustmentType, string Description, VatInfoList VatAdjustments)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    var vatInfoListForPosNet = new List<Microsoft.PointOfService.VatInfo>();
                    foreach (var vat in VatAdjustments)
                    {
                        vatInfoListForPosNet.Add(new Microsoft.PointOfService.VatInfo(vat.ID, vat.Amount));
                    }

                    ConcretizationDevice(sessionContext.Device).PrintRecPackageAdjustment((Microsoft.PointOfService.FiscalAdjustmentType)Convert[AdjustmentType], Description, vatInfoListForPosNet);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void PrintRecPackageAdjustVoid(string ConsumerID, FiscalAdjustmentType AdjustmentType, VatInfoList VatAdjustments)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    var vatInfoListForPosNet = new List<Microsoft.PointOfService.VatInfo>();
                    foreach (var vat in VatAdjustments)
                    {
                        vatInfoListForPosNet.Add(new Microsoft.PointOfService.VatInfo(vat.ID, vat.Amount));
                    }
                    ConcretizationDevice(sessionContext.Device).PrintRecPackageAdjustVoid((Microsoft.PointOfService.FiscalAdjustmentType)Convert[AdjustmentType], vatInfoListForPosNet);
                });

            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void PrintRecRefund(string ConsumerID, string Description, Decimal Amount, int VatInfo)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).PrintRecRefund(Description, Amount, VatInfo);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void PrintRecRefundVoid(string ConsumerID, string Description, Decimal Amount, int VatInfo)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).PrintRecRefundVoid(Description, Amount, VatInfo);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void PrintRecSubtotal(string ConsumerID, Decimal Amount)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).PrintRecSubtotal(Amount);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void PrintRecSubtotalAdjustment(string ConsumerID, FiscalAdjustment AdjustmentType, string Description, Decimal Amount)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).PrintRecSubtotalAdjustment((Microsoft.PointOfService.FiscalAdjustment)Convert[AdjustmentType], Description, Amount);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void PrintRecSubtotalAdjustVoid(string ConsumerID, FiscalAdjustment AdjustmentType, Decimal Amount)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).PrintRecSubtotalAdjustVoid((Microsoft.PointOfService.FiscalAdjustment)Convert[AdjustmentType], Amount);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void PrintRecTaxID(string ConsumerID, string TaxID)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).PrintRecTaxId(TaxID);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void PrintRecTotal(string ConsumerID, Decimal Total, Decimal Payment, string Description)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).PrintRecTotal(Total, Payment, Description);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void PrintRecVoid(string ConsumerID, string Description)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).PrintRecVoid(Description);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void PrintReport(string ConsumerID, ReportType ReportType, string StartNum, string EndNum)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).PrintReport((Microsoft.PointOfService.ReportType)Convert[ReportType], StartNum, EndNum);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void PrintXReport(string ConsumerID)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).PrintXReport();
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void PrintZReport(string ConsumerID)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).PrintZReport();
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void ResetPrinter(string ConsumerID)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).ResetPrinter();
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void SetCurrency(string ConsumerID, FiscalCurrency NewCurrency)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).SetCurrency((Microsoft.PointOfService.FiscalCurrency)Convert[NewCurrency]);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void SetDate(string ConsumerID, DateTime Date)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).SetDate(Date);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void SetHeaderLine(string ConsumerID, int LineNumber, string Text, bool DoubleWidth)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).SetHeaderLine(LineNumber, Text, DoubleWidth);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void SetPOSID(string ConsumerID, string POSID, string CashierID)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).SetPosId(POSID, CashierID);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void SetStoreFiscalID(string ConsumerID, string ID)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).SetStoreFiscalId(ID);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void SetTrailerLine(string ConsumerID, int LineNumber, string Text, bool DoubleWidth)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).SetTrailerLine(LineNumber, Text, DoubleWidth);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void SetVatTable(string ConsumerID)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).SetVatTable();
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void SetVatValue(string ConsumerID, int VatID, string VatValue)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).SetVatValue(VatID, VatValue);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void VerifyItem(string ConsumerID, string ItemName, int VatID)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).VerifyItem(ItemName, VatID);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void PrintRecItemRefund(string ConsumerID, string Description, Decimal Amount, int Quantity, int VatInfo, Decimal UnitAmount, string UnitName)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).PrintRecItemRefund(Description, Amount, Quantity, VatInfo, UnitAmount, UnitName);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void PrintRecItemRefundVoid(string ConsumerID, string Description, Decimal Amount, int Quantity, int VatInfo, Decimal UnitAmount, string UnitName)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).PrintRecItemRefundVoid(Description, Amount, Quantity, VatInfo, UnitAmount, UnitName);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void ClearOutput(string ConsumerID)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).ClearOutput();
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void BeginFiscalDocument(string ConsumerID, int DocumentAmount)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).BeginFiscalDocument(DocumentAmount);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void BeginFiscalReceipt(string ConsumerID, bool PrintHeader)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).BeginFiscalReceipt(PrintHeader);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void BeginFixedOutput(string ConsumerID, FiscalReceiptStation Station, int DocumentType)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).BeginFixedOutput((Microsoft.PointOfService.FiscalReceiptStation)Convert[Station], DocumentType);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void BeginInsertion(string ConsumerID, int Timeout)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).BeginInsertion(Timeout);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void BeginItemList(string ConsumerID, int VatID)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).BeginItemList(VatID);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void BeginNonFiscal(string ConsumerID)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).BeginNonFiscal();
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void CheckHealth(string ConsumerID, HealthCheckLevel Level)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).CheckHealth((Microsoft.PointOfService.HealthCheckLevel)Convert[Level]);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void Claim(string ConsumerID, int Timeout)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    ConcretizationDevice(sessionContext.Device).Claim(Timeout);
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual DirectIOData DirectIO(string ConsumerID, int Command, int Data, object Obj)
        {
            try
            {
                Microsoft.PointOfService.DirectIOData value = new Microsoft.PointOfService.DirectIOData();
                var sessionContext = (base.GetSessionContext(ConsumerID));
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    string artsB = (string)Obj;
                    var str = base.ConvertARTSBinaryToString(sessionContext.IsLegacySO, sessionContext.CodePageConversion, artsB);
                    value = ConcretizationDevice(sessionContext.Device).DirectIO(Command, Data, str);
                });
                return new DirectIOData() { Data = value.Data, Obj = base.ConvertStringToARTSBinary(sessionContext.IsLegacySO, sessionContext.CodePageConversion, (string)value.Object) };
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void Release(string ConsumerID)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    var freezeEvents = ConcretizationDevice(sessionContext.Device).FreezeEvents;
                    ConcretizationDevice(sessionContext.Device).FreezeEvents = true;
                    base.WaitForEventHandlerReturned(sessionContext);

                    ConcretizationDevice(sessionContext.Device).Release();
                    base.DeleteAsyncTemporaryFiles(sessionContext);

                    ConcretizationDevice(sessionContext.Device).FreezeEvents = freezeEvents;
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void ResetStatistics(string ConsumerID, StatisticList StatisticsBuffer)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    var device = ConcretizationDevice(sessionContext.Device);

                    var value = new List<string>(); foreach (var s in StatisticsBuffer) { value.Add(s.Name); }　// .NET FW 3のため、Linq使用不可 var value = from el in StatisticsBuffer select el.Name;;
                    switch (value.Count)
                    {
                        case 0:
                            device.ResetStatistics();
                            break;
                        case 1:
                            string name = value[0];
                            switch (name)
                            {
                                case StatisticCategories.All:
                                    device.ResetStatistics(Microsoft.PointOfService.StatisticCategories.All);
                                    break;
                                case StatisticCategories.Manufacturer:
                                    device.ResetStatistics(Microsoft.PointOfService.StatisticCategories.Manufacturer);
                                    break;
                                case StatisticCategories.Upos:
                                    device.ResetStatistics(Microsoft.PointOfService.StatisticCategories.Upos);
                                    break;
                                default:
                                    device.ResetStatistic(name);
                                    break;
                            }
                            break;
                        default:
                            device.ResetStatistics(value.ToArray());
                            break;
                    }
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }


        public virtual string RetrieveStatistics(string ConsumerID, StatisticList StatisticsBuffer)
        {
            try
            {
                string res = null;
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    var device = ConcretizationDevice(sessionContext.Device);
                    var value = new List<string>(); foreach (var s in StatisticsBuffer) { value.Add(s.Name); }　// .NET FW 3のため、Linq使用不可 var value = from el in StatisticsBuffer select el.Name;;
                    switch (value.Count)
                    {
                        case 0:
                            res = device.RetrieveStatistics();
                            break;
                        case 1:
                            string name = value[0];
                            switch (name)
                            {
                                case StatisticCategories.All:
                                    res = device.RetrieveStatistics(Microsoft.PointOfService.StatisticCategories.All);
                                    break;
                                case StatisticCategories.Manufacturer:
                                    res = device.RetrieveStatistics(Microsoft.PointOfService.StatisticCategories.Manufacturer);
                                    break;
                                case StatisticCategories.Upos:
                                    res = device.RetrieveStatistics(Microsoft.PointOfService.StatisticCategories.Upos);
                                    break;
                                default:
                                    res = device.RetrieveStatistic(name);
                                    break;
                            }
                            break;
                        default:
                            res = device.RetrieveStatistics(value.ToArray());
                            break;
                    }
                });
                return res;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void UpdateStatistics(string ConsumerID, StatisticList StatisticsBuffer)
        {
            try
            {
                var sessionContext = base.GetSessionContext(ConsumerID);
                sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                {
                    var device = ConcretizationDevice(sessionContext.Device);
                    var value = new List<Microsoft.PointOfService.Statistic>(); foreach (var s in StatisticsBuffer) { value.Add(new Microsoft.PointOfService.Statistic(s.Name, s.Value)); } // var value = from el in StatisticsBuffer select new Microsoft.PointOfService.Statistic(el.Name, el.Value);
                    switch (value.Count)
                    {
                        case 0:
                            device.UpdateStatistics(value.ToArray());
                            break;
                        case 1:
                            Microsoft.PointOfService.Statistic statistic = value[0];
                            switch (statistic.Name)
                            {
                                case StatisticCategories.All:
                                    device.UpdateStatistics(Microsoft.PointOfService.StatisticCategories.All, statistic.Value);
                                    break;
                                case StatisticCategories.Manufacturer:
                                    device.UpdateStatistics(Microsoft.PointOfService.StatisticCategories.Manufacturer, statistic.Value);
                                    break;
                                case StatisticCategories.Upos:
                                    device.UpdateStatistics(Microsoft.PointOfService.StatisticCategories.Upos, statistic.Value);
                                    break;
                                default:
                                    device.UpdateStatistic(statistic.Name, statistic.Value);
                                    break;
                            }
                            break;
                        default:
                            device.UpdateStatistics(value.ToArray());
                            break;
                    }
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual CompareFirmwareResult CompareFirmwareVersion(string ConsumerID, string FirmwareFileName)
        {
            try
            {
                CompareFirmwareResult result = CompareFirmwareResult.CFV_FIRMWARE_UNKNOWN;

                UriToTempFileHelper.UriToTempFileExecuteTargetMethod(FirmwareFileName, true, (tempFileName) =>
                {
                    var sessionContext = base.GetSessionContext(ConsumerID);
                    sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                    {
                        sessionContext.TempFileNamesForDeleteWhenCloseDevice.Add(tempFileName);
                        result = (CompareFirmwareResult)Convert[ConcretizationDevice(sessionContext.Device).CompareFirmwareVersion(tempFileName)];
                    });
                });

                return result;
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }


        public virtual void UpdateFirmware(string ConsumerID, string FirmwareFileName)
        {
            try
            {
                UriToTempFileHelper.UriToTempFileExecuteTargetMethod(FirmwareFileName, false, (tempFileName) =>
                {
                    var sessionContext = base.GetSessionContext(ConsumerID);
                    sessionContext.DeviceThread.ExecuteOnWorkerThread(() =>
                    {
                        sessionContext.TempFileNamesForDeleteWhenCloseDevice.Add(tempFileName);
                        ConcretizationDevice(sessionContext.Device).UpdateFirmware(tempFileName);
                    });
                });
            }
            catch (Microsoft.PointOfService.PosControlException pex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), pex);
                UposException uex = new UposException();
                uex.ErrorCode = (ErrorCode)Convert[pex.ErrorCode];
                uex.ErrorCodeExtended = pex.ErrorCodeExtended;
                throw new FaultException<UposException>(uex, pex.Message);
            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual UposVersion GetWSPOSVersion()
        {
            return _wsposVersion;
        }

        #endregion

        #region FiscalPrinter Events

        /// <summary>
        /// サービス内でのDataEventハンドラ
        /// DataEvent handler in the service
        /// </summary>
        /// <param name="sender">Sender instance</param>
        /// <param name="e">Event argument</param>
        protected override void SessionContext_ServiceDataEvent(object sender, Microsoft.PointOfService.DataEventArgs e)
        {
            try
            {
                ISessionContext sessionContext = sender as ISessionContext;

                // デバイスをCloseする際に、このイベントハンドラが実行中でないことを確認するためのフラグを設定する。
                // When Closing a device, the flag for checking that this event handler is not going.
                sessionContext.UPOSEventHandlingOnGoing = true;

                if (sessionContext.ConsumerEventPort != null)
                {
                    // 双方向通信
                    // LegacySOのSTAからのRPC呼び出しに伴うアパートメントブロックによるデッドロックを回避するため、ワーカスレッドで呼び出します。
                    // Bi-directional communication: 
                    // In order to avoid the deadlock by the apartment block accompanying the RPC call from STA of LegacySO, it is called by a worker thread. 
                    System.Threading.Thread eventCallThread = new System.Threading.Thread(new System.Threading.ThreadStart(() =>
                    {
                        var deviceEvent = ConcretizationConsumerEventPort(sessionContext.ConsumerEventPort);
                        bool isTimeoutHappened = false;
                        do
                        {
                            try
                            {
                                //deviceEvent.DataEvent(sessionContext.ConsumerID, sessionContext.Device.ToString(), e.EventId, e.TimeStamp, e.Status);
                            }
                            catch (Exception ex)
                            {
                                if (ex is TimeoutException || ex is EndpointNotFoundException)
                                {
                                    isTimeoutHappened = true;
                                    // レスポンスが帰ってこない場合、再度通知します。
                                    // タイムアウトになり続けた場合、ProviderSessionTimeout値によって
                                    // セッションが閉じられるまでこれを続けます。
                                    // When a response does not come back, it notifies again. 
                                    // When it continues being timing out, this is continued until a 
                                    // session is closed by the ProviderSessionTimeout value. 
                                    if (sessionContext.IsClosed)
                                    {
                                        base.LogWriteLineMessage(MethodBase.GetCurrentMethod(), "Network timeout when event notify, and session closed.");
                                        break;
                                    }
                                    base.LogWriteLineMessage(MethodBase.GetCurrentMethod(), "Network timeout when event notify, then retry.");
                                }
                                else
                                {
                                    break;
                                }
                            }
                        } while (isTimeoutHappened);
                    }));
                    eventCallThread.Start();
                    eventCallThread.Join();
                }
                else
                {
                    // ロングポーリング
                    // Long polling

                    // PollForUPOSEventでの待ちに対して通知する
                    // Notifying wait in PollForUPOSEvent

                    sessionContext.DeviceEventArgs = e;
                    sessionContext.DeviceEventHappened.Signal();

                    // EventResponseの呼び出しを待つ
                    // It waits for the call of EventResponse.
                    sessionContext.SetEventResponseCalled.Wait(sessionContext.EventResponseTimeout);
                }
            }
            catch (ObjectDisposedException ex)
            {
                // 待ち合わせ中にセッションが閉じた場合
                // WaitOneがObjectDisposedException例外をスローします。
                // デバイス側は異常ではないため、例外をデバイスにスローせず
                // 記録ログのみ書きます
                // When a session closes during waiting 
                // WaitOne will throw of the ObjectDisposedException exception. 
                // Since the device side is not unusual, it does not throw the exception 
                // to a device, but only writes log records. 
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
            }
            catch (Exception ex)
            {
                // デバイスからのイベントハンドラ内部での例外はデバイスによってハンドリングされないため
                // ログは書き込みますが例外をデバイスにスローしません
                // Since the exception inside the event handler from a device is not handled by the device, 
                // although a log writes in, it does not throw the exception to a device. 
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
            }
            finally
            {
                ISessionContext sessionContext = sender as ISessionContext;
                sessionContext.UPOSEventHandlingOnGoing = false;
            }

        }

        /// <summary>
        /// サービス内でのDirectIOEventハンドラ
        /// </summary>
        /// <param name="sender">送信者インスタンス</param>
        /// <param name="e">イベント引数</param>
        protected override void SessionContext_ServiceDirectIOEvent(object sender, Microsoft.PointOfService.DirectIOEventArgs e)
        {
            try
            {
                ISessionContext sessionContext = sender as ISessionContext;

                // デバイスをCloseする際に、このイベントハンドラが実行中でないことを確認するためのフラグを設定する。
                // When Closing a device, the flag for checking that this event handler is not going.
                sessionContext.UPOSEventHandlingOnGoing = true;

                if (sessionContext.ConsumerEventPort != null)
                {
                    // 双方向通信
                    // LegacySOのSTAからのRPC呼び出しに伴うアパートメントブロックによるデッドロックを回避するため、ワーカスレッドで呼び出します。
                    // Bi-directional communication: 
                    // In order to avoid the deadlock by the apartment block accompanying the RPC call from STA of LegacySO, it is called by a worker thread. 
                    System.Threading.Thread eventCallThread = new System.Threading.Thread(new System.Threading.ThreadStart(() =>
                    {
                        var deviceEvent = ConcretizationConsumerEventPort(sessionContext.ConsumerEventPort);
                        bool isTimeoutHappened = false;
                        do
                        {
                            try
                            {
                                string artsB = (string)e.Object;
                                var str = base.ConvertARTSBinaryToString(sessionContext.IsLegacySO, sessionContext.CodePageConversion, artsB);
                                var value = deviceEvent.DirectIOEvent(sessionContext.ConsumerID, sessionContext.Device.ToString(), e.EventId, e.TimeStamp, e.EventNumber, e.Data, str);
                                e.Data = value.Data;
                                e.Object = base.ConvertStringToARTSBinary(sessionContext.IsLegacySO, sessionContext.CodePageConversion, (string)value.Obj);
                            }
                            catch (Exception ex)
                            {
                                if (ex is TimeoutException || ex is EndpointNotFoundException)
                                {
                                    isTimeoutHappened = true;
                                    // レスポンスが帰ってこない場合、再度通知します。
                                    // タイムアウトになり続けた場合、ProviderSessionTimeout値によって
                                    // セッションが閉じられるまでこれを続けます。
                                    // When a response does not come back, it notifies again. 
                                    // When it continues being timing out, this is continued until a 
                                    // session is closed by the ProviderSessionTimeout value. 
                                    if (sessionContext.IsClosed)
                                    {
                                        base.LogWriteLineMessage(MethodBase.GetCurrentMethod(), "Network timeout when event notify, and session closed.");
                                        break;
                                    }
                                    base.LogWriteLineMessage(MethodBase.GetCurrentMethod(), "Network timeout when event notify, then retry.");
                                }
                                else
                                {
                                    break;
                                }
                            }
                        } while (isTimeoutHappened);
                    }));
                    eventCallThread.Start();
                    eventCallThread.Join();
                }
                else
                {
                    // ロングポーリング
                    // Long polling

                    // PollForUPOSEventでの待ちに対して通知する
                    // Notifying wait in PollForUPOSEvent

                    sessionContext.DeviceEventArgs = e;
                    sessionContext.DeviceEventHappened.Signal();

                    // EventResponseの呼び出しをまつ
                    if (sessionContext.SetEventResponseCalled.Wait(sessionContext.EventResponseTimeout))
                    {
                        DirectIOData value = sessionContext.DeviceEventResponse as DirectIOData;

                        e.Data = value.Data;
                        e.Object = base.ConvertARTSBinaryToString(sessionContext.IsLegacySO, sessionContext.CodePageConversion, (string)value.Obj);
                    }
                }
            }
            catch (ObjectDisposedException ex)
            {
                // 待ち合わせ中にセッションが閉じた場合
                // WaitOneがObjectDisposedException例外をスローします。
                // デバイス側は異常ではないため、例外をデバイスにスローせず
                // 記録ログのみ書きます
                // When a session closes during waiting 
                // WaitOne will throw of the ObjectDisposedException exception. 
                // Since the device side is not unusual, it does not throw the exception 
                // to a device, but only writes log records. 
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
            }
            catch (Exception ex)
            {
                // デバイスからのイベントハンドラ内部での例外はデバイスによってハンドリングされないため
                // ログは書き込みますが例外をデバイスにスローしません
                // Since the exception inside the event handler from a device is not handled by the device, 
                // although a log writes in, it does not throw the exception to a device. 
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
            }
            finally
            {
                ISessionContext sessionContext = sender as ISessionContext;
                sessionContext.UPOSEventHandlingOnGoing = false;
            }

        }

        /// <summary>
        /// サービス内でのErrorEvventハンドラ
        /// </summary>
        /// <param name="sender">送信者インスタンス</param>
        /// <param name="e">イベント引数</param>
        protected override void SessionContext_ServiceErrorEvent(object sender, Microsoft.PointOfService.DeviceErrorEventArgs e)
        {
            try
            {
                ISessionContext sessionContext = sender as ISessionContext;

                // デバイスをCloseする際に、このイベントハンドラが実行中でないことを確認するためのフラグを設定する。
                // When Closing a device, the flag for checking that this event handler is not going.
                sessionContext.UPOSEventHandlingOnGoing = true;

                if (sessionContext.ConsumerEventPort != null)
                {
                    // 双方向通信
                    // LegacySOのSTAからのRPC呼び出しに伴うアパートメントブロックによるデッドロックを回避するため、ワーカスレッドで呼び出します。
                    // Bi-directional communication: 
                    // In order to avoid the deadlock by the apartment block accompanying the RPC call from STA of LegacySO, it is called by a worker thread. 
                    System.Threading.Thread eventCallThread = new System.Threading.Thread(new System.Threading.ThreadStart(() =>
                    {
                        var deviceEvent = ConcretizationConsumerEventPort(sessionContext.ConsumerEventPort);
                        bool isTimeoutHappened = false;
                        do
                        {
                            try
                            {
                                var value = deviceEvent.ErrorEvent(sessionContext.ConsumerID, sessionContext.Device.ToString(), e.EventId, e.TimeStamp, (UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorCode)EventConvert[e.ErrorCode], e.ErrorCodeExtended, (UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorLocus)EventConvert[e.ErrorLocus], (UnifiedPOS.FiscalPrinterEvents.V1_4.ErrorResponse)EventConvert[e.ErrorResponse]);
                                e.ErrorResponse = (Microsoft.PointOfService.ErrorResponse)EventConvert[value];
                            }
                            catch (Exception ex)
                            {
                                if (ex is TimeoutException || ex is EndpointNotFoundException)
                                {
                                    isTimeoutHappened = true;
                                    // レスポンスが帰ってこない場合、再度通知します。
                                    // タイムアウトになり続けた場合、ProviderSessionTimeout値によって
                                    // セッションが閉じられるまでこれを続けます。
                                    // When a response does not come back, it notifies again. 
                                    // When it continues being timing out, this is continued until a 
                                    // session is closed by the ProviderSessionTimeout value. 
                                    if (sessionContext.IsClosed)
                                    {
                                        base.LogWriteLineMessage(MethodBase.GetCurrentMethod(), "Network timeout when event notify, and session closed.");
                                        e.ErrorResponse = Microsoft.PointOfService.ErrorResponse.Clear;
                                        break;
                                    }
                                    base.LogWriteLineMessage(MethodBase.GetCurrentMethod(), "Network timeout when event notify, then retry.");
                                }
                                else
                                {
                                    break;
                                }
                            }
                        } while (isTimeoutHappened);
                    }));
                    eventCallThread.Start();
                    eventCallThread.Join();
                }
                else
                {
                    // ロングポーリング
                    // Long polling

                    // PollForUPOSEventでの待ちに対して通知する
                    // Notifying wait in PollForUPOSEvent

                    sessionContext.DeviceEventArgs = e;
                    sessionContext.DeviceEventHappened.Signal();

                    // SetEventResponseの呼び出しを待つ
                    if (sessionContext.SetEventResponseCalled.Wait(sessionContext.EventResponseTimeout))
                    {
                        ErrorResponse value = (ErrorResponse)sessionContext.DeviceEventResponse;
                        e.ErrorResponse = (Microsoft.PointOfService.ErrorResponse)EventConvert[value];
                    }
                    else
                    {
                        e.ErrorResponse = Microsoft.PointOfService.ErrorResponse.Clear;
                    }
                }
            }
            catch (ObjectDisposedException ex)
            {
                // 待ち合わせ中にセッションが閉じた場合
                // WaitOneがObjectDisposedException例外をスローします。
                // デバイス側は異常ではないため、例外をデバイスにスローせず
                // 記録ログのみ書きます
                // When a session closes during waiting 
                // WaitOne will throw of the ObjectDisposedException exception. 
                // Since the device side is not unusual, it does not throw the exception 
                // to a device, but only writes log records. 
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
            }
            catch (Exception ex)
            {
                // デバイスからのイベントハンドラ内部での例外はデバイスによってハンドリングされないため
                // ログは書き込みますが例外をデバイスにスローしません
                // Since the exception inside the event handler from a device is not handled by the device, 
                // although a log writes in, it does not throw the exception to a device. 
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
            }
            finally
            {
                ISessionContext sessionContext = sender as ISessionContext;
                sessionContext.UPOSEventHandlingOnGoing = false;
            }

        }

        /// <summary>
        /// サービス内でのOutputCompleteEventハンドラ
        /// </summary>
        /// <param name="sender">送信者インスタンス</param>
        /// <param name="e">イベント引数</param>
        protected override void SessionContext_ServiceOutputCompleteEvent(object sender, Microsoft.PointOfService.OutputCompleteEventArgs e)
        {
            try
            {
                ISessionContext sessionContext = sender as ISessionContext;

                // デバイスをCloseする際に、このイベントハンドラが実行中でないことを確認するためのフラグを設定する。
                // When Closing a device, the flag for checking that this event handler is not going.
                sessionContext.UPOSEventHandlingOnGoing = true;

                if (sessionContext.ConsumerEventPort != null)
                {
                    // 双方向通信
                    // LegacySOのSTAからのRPC呼び出しに伴うアパートメントブロックによるデッドロックを回避するため、ワーカスレッドで呼び出します。
                    // Bi-directional communication: 
                    // In order to avoid the deadlock by the apartment block accompanying the RPC call from STA of LegacySO, it is called by a worker thread. 
                    System.Threading.Thread eventCallThread = new System.Threading.Thread(new System.Threading.ThreadStart(() =>
                    {
                        var deviceEvent = ConcretizationConsumerEventPort(sessionContext.ConsumerEventPort);
                        bool isTimeoutHappened = false;
                        do
                        {
                            try
                            {
                                deviceEvent.OutputCompleteEvent(sessionContext.ConsumerID, sessionContext.Device.ToString(), e.EventId, e.TimeStamp, e.OutputId);
                            }
                            catch (Exception ex)
                            {
                                if (ex is TimeoutException || ex is EndpointNotFoundException)
                                {
                                    isTimeoutHappened = true;
                                    // レスポンスが帰ってこない場合、再度通知します。
                                    // タイムアウトになり続けた場合、ProviderSessionTimeout値によって
                                    // セッションが閉じられるまでこれを続けます。
                                    // When a response does not come back, it notifies again. 
                                    // When it continues being timing out, this is continued until a 
                                    // session is closed by the ProviderSessionTimeout value. 
                                    if (sessionContext.IsClosed)
                                    {
                                        base.LogWriteLineMessage(MethodBase.GetCurrentMethod(), "Network timeout when event notify, and session closed.");
                                        break;
                                    }
                                    base.LogWriteLineMessage(MethodBase.GetCurrentMethod(), "Network timeout when event notify, then retry.");
                                }
                                else
                                {
                                    break;
                                }
                            }
                        } while (isTimeoutHappened);
                    }));
                    eventCallThread.Start();
                    eventCallThread.Join();
                }
                else
                {
                    // ロングポーリング
                    // Long polling

                    // PollForUPOSEventでの待ちに対して通知する
                    // Notifying wait in PollForUPOSEvent

                    sessionContext.DeviceEventArgs = e;
                    sessionContext.DeviceEventHappened.Signal();

                    // SetEventResponseの呼び出しを待つ
                    sessionContext.SetEventResponseCalled.Wait(sessionContext.EventResponseTimeout);
                }
            }
            catch (ObjectDisposedException ex)
            {
                // 待ち合わせ中にセッションが閉じた場合
                // WaitOneがObjectDisposedException例外をスローします。
                // デバイス側は異常ではないため、例外をデバイスにスローせず
                // 記録ログのみ書きます
                // When a session closes during waiting 
                // WaitOne will throw of the ObjectDisposedException exception. 
                // Since the device side is not unusual, it does not throw the exception 
                // to a device, but only writes log records. 
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
            }
            catch (Exception ex)
            {
                // デバイスからのイベントハンドラ内部での例外はデバイスによってハンドリングされないため
                // ログは書き込みますが例外をデバイスにスローしません
                // Since the exception inside the event handler from a device is not handled by the device, 
                // although a log writes in, it does not throw the exception to a device. 
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
            }
            finally
            {
                ISessionContext sessionContext = sender as ISessionContext;
                sessionContext.UPOSEventHandlingOnGoing = false;
            }

        }

        /// <summary>
        /// サービス内でのStatusUpdateEventハンドラ
        /// </summary>
        /// <param name="sender">送信者インスタンス</param>
        /// <param name="e">イベント引数</param>
        protected override void SessionContext_ServiceStatusUpdateEvent(object sender, Microsoft.PointOfService.StatusUpdateEventArgs e)
        {
            try
            {
                ISessionContext sessionContext = sender as ISessionContext;

                // デバイスをCloseする際に、このイベントハンドラが実行中でないことを確認するためのフラグを設定する。
                // When Closing a device, the flag for checking that this event handler is not going.
                sessionContext.UPOSEventHandlingOnGoing = true;

                if (sessionContext.ConsumerEventPort != null)
                {
                    // 双方向通信
                    // LegacySOのSTAからのRPC呼び出しに伴うアパートメントブロックによるデッドロックを回避するため、ワーカスレッドで呼び出します。
                    // Bi-directional communication: 
                    // In order to avoid the deadlock by the apartment block accompanying the RPC call from STA of LegacySO, it is called by a worker thread. 
                    System.Threading.Thread eventCallThread = new System.Threading.Thread(new System.Threading.ThreadStart(() =>
                    {
                        var deviceEvent = ConcretizationConsumerEventPort(sessionContext.ConsumerEventPort);
                        bool isTimeoutHappened = false;
                        do
                        {
                            try
                            {
                                deviceEvent.StatusUpdateEvent(sessionContext.ConsumerID, sessionContext.Device.ToString(), e.EventId, e.TimeStamp, e.Status);
                            }
                            catch (Exception ex)
                            {
                                if (ex is TimeoutException || ex is EndpointNotFoundException)
                                {
                                    isTimeoutHappened = true;
                                    // レスポンスが帰ってこない場合、再度通知します。
                                    // タイムアウトになり続けた場合、ProviderSessionTimeout値によって
                                    // セッションが閉じられるまでこれを続けます。
                                    // When a response does not come back, it notifies again. 
                                    // When it continues being timing out, this is continued until a 
                                    // session is closed by the ProviderSessionTimeout value. 
                                    if (sessionContext.IsClosed)
                                    {
                                        base.LogWriteLineMessage(MethodBase.GetCurrentMethod(), "Network timeout when event notify, and session closed.");
                                        break;
                                    }
                                    base.LogWriteLineMessage(MethodBase.GetCurrentMethod(), "Network timeout when event notify, then retry.");
                                }
                                else
                                {
                                    break;
                                }
                            }
                        } while (isTimeoutHappened);
                    }));
                    eventCallThread.Start();
                    eventCallThread.Join();
                }
                else
                {
                    // ロングポーリング
                    // Long polling

                    // PollForUPOSEventでの待ちに対して通知する
                    // Notifying wait in PollForUPOSEvent

                    sessionContext.DeviceEventArgs = e;
                    sessionContext.DeviceEventHappened.Signal();

                    // SetEventResponseの呼び出しを待つ
                    sessionContext.SetEventResponseCalled.Wait(sessionContext.EventResponseTimeout);
                }
            }
            catch (ObjectDisposedException ex)
            {
                // 待ち合わせ中にセッションが閉じた場合
                // WaitOneがObjectDisposedException例外をスローします。
                // デバイス側は異常ではないため、例外をデバイスにスローせず
                // 記録ログのみ書きます
                // When a session closes during waiting 
                // WaitOne will throw of the ObjectDisposedException exception. 
                // Since the device side is not unusual, it does not throw the exception 
                // to a device, but only writes log records. 
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
            }
            catch (Exception ex)
            {
                // デバイスからのイベントハンドラ内部での例外はデバイスによってハンドリングされないため
                // ログは書き込みますが例外をデバイスにスローしません
                // Since the exception inside the event handler from a device is not handled by the device, 
                // although a log writes in, it does not throw the exception to a device. 
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
            }
            finally
            {
                ISessionContext sessionContext = sender as ISessionContext;
                sessionContext.UPOSEventHandlingOnGoing = false;
            }

        }

        public virtual FiscalPrinterEvent PollForUPOSEvent(string ConsumerID)
        {
            try
            {
                ISessionContext sessionContext = base.GetSessionContext(ConsumerID);
                if (sessionContext.ConsumerEventPort != null)
                {
                    // 双方向通信でOpenSessionを呼び出した場合はPollForUPOSEventは使えません
                    // PollForUPOSEvent cannot be used when OpenSession is called by bi-directional communication. 
                    throw new FaultException<UposException>(new UposException() { ErrorCode = ErrorCode.E_ILLEGAL }, "bi-direction mode.", new FaultCode("Server"));
                }

                // このセッションで、既にPollForUPOSEventが呼ばれていた場合に前のPollForUPOSEventを終了して新たに待ち始めます。
                // これは、前のPollForUPOSEvent待ち時にネットワークが切断され、待ち時間内にアプリから再度PollForUPOSEventされたケースを想定しています。
                // これをしなくともセッションタイムアウトで解放されるので、最終的にリークはしませんが、アプリケーションにとって、
                // 既に(ネットワークの)エラーになった前のPollForUPOSEventが終わるまで新たにイベントがとれないというのは問題になります。
                // In this session, when PollForUPOSEvent is already called, front PollForUPOSEvent is ended and it newly begins to wait. 
                // A network is disconnected at the time of front PollForUPOSEvent waiting, and this assumes the case again PollForUPOSEvent from the application in waiting time. 
                // Since it is released by session timeout even if it does not carry out this, finally leak is not carried out, 
                // but it becomes a problem that an event cannot newly be taken until PollForUPOSEvent before already becoming an network) error finishes for application. 
                lock (sessionContext)
                {
                    if (sessionContext.IsPollingNow)
                    {
                        // 自分以外のスレッドがPollForUPOSEventしているなら前のスレッドに
                        // 終了するように通知する
                        // If threads other than themselves are PollForUPOSEvent(ing), 
                        // it will be reported that it ends to a front thread.
                        sessionContext.OtherPollForUPOSEventCalled.Signal();
                        // 前のスレッドの終了を待つ（すぐに待ち終わります）
                        // It waits for the end of a front thread (it finishes waiting immediately). 
                        sessionContext.PreviousPollForUPOSEventEnded.Wait(sessionContext.EventPollingTimeout);
                    }
                }
                sessionContext.IsPollingNow = true;

                IEventWait[] waits = new IEventWait[2];
                waits[0] = sessionContext.DeviceEventHappened;
                waits[1] = sessionContext.OtherPollForUPOSEventCalled;

                int signaledIndex = sessionContext.DeviceEventHappened.WaitForAny(waits, sessionContext.EventPollingTimeout);

                try
                {
                    if (signaledIndex != 0)
                    {
                        // タイムアウトまたは他のPollForUPOSEventによって待ちが中断
                        // Waiting is interrupted by timeout or other PollForUPOSEvent(s). 
                        base.LogWriteLineMessage(MethodBase.GetCurrentMethod(), "PollForUPOSEvent aborted by timeout or other PollForUPOSEvent call.");

                        return null;
                    }
                    if (sessionContext.DeviceEventArgs is Microsoft.PointOfService.DirectIOEventArgs)
                    {
                        Microsoft.PointOfService.DirectIOEventArgs e = sessionContext.DeviceEventArgs as Microsoft.PointOfService.DirectIOEventArgs;

                        FiscalPrinterEvent posServiceEvent = new FiscalPrinterEvent();
                        posServiceEvent.DirectIOEvent = new DirectIOEvent();

                        posServiceEvent.DirectIOEvent.Source = sessionContext.Device.ToString();
                        posServiceEvent.DirectIOEvent.EventID = e.EventId;
                        posServiceEvent.DirectIOEvent.TimeStamp = e.TimeStamp;
                        posServiceEvent.DirectIOEvent.EventNumber = e.EventNumber;
                        posServiceEvent.DirectIOEvent.Data = e.Data;
                        posServiceEvent.DirectIOEvent.Obj = base.ConvertStringToARTSBinary(sessionContext.IsLegacySO, sessionContext.CodePageConversion, (string)e.Object);;

                        return posServiceEvent;
                    }
                    else if (sessionContext.DeviceEventArgs is Microsoft.PointOfService.DataEventArgs)
                    {
                        Microsoft.PointOfService.DataEventArgs e = sessionContext.DeviceEventArgs as Microsoft.PointOfService.DataEventArgs;

                        FiscalPrinterEvent posServiceEvent = new FiscalPrinterEvent();
                        //posServiceEvent.DataEvent = new DataEvent();

                        //posServiceEvent.DataEvent.Source = sessionContext.Device.ToString();
                        //posServiceEvent.DataEvent.EventID = e.EventId;
                        //posServiceEvent.DataEvent.TimeStamp = e.TimeStamp;
                        //posServiceEvent.DataEvent.Status = e.Status;

                        return posServiceEvent;
                    }
                    else if (sessionContext.DeviceEventArgs is Microsoft.PointOfService.DeviceErrorEventArgs)
                    {
                        Microsoft.PointOfService.DeviceErrorEventArgs e = sessionContext.DeviceEventArgs as Microsoft.PointOfService.DeviceErrorEventArgs;

                        FiscalPrinterEvent posServiceEvent = new FiscalPrinterEvent();
                        posServiceEvent.ErrorEvent = new ErrorEvent();

                        posServiceEvent.ErrorEvent.Source = sessionContext.Device.ToString();
                        posServiceEvent.ErrorEvent.EventID = e.EventId;
                        posServiceEvent.ErrorEvent.TimeStamp = e.TimeStamp;
                        posServiceEvent.ErrorEvent.ErrorCode = (ErrorCode)EventConvert[e.ErrorCode];
                        posServiceEvent.ErrorEvent.ErrorCodeExtended = e.ErrorCodeExtended;
                        posServiceEvent.ErrorEvent.ErrorLocus = (ErrorLocus)EventConvert[e.ErrorLocus];
                        posServiceEvent.ErrorEvent.ErrorResponse = (ErrorResponse)EventConvert[e.ErrorResponse];

                        return posServiceEvent;
                    }
                    else if (sessionContext.DeviceEventArgs is Microsoft.PointOfService.OutputCompleteEventArgs)
                    {
                        Microsoft.PointOfService.OutputCompleteEventArgs e = sessionContext.DeviceEventArgs as Microsoft.PointOfService.OutputCompleteEventArgs;

                        FiscalPrinterEvent posServiceEvent = new FiscalPrinterEvent();
                        posServiceEvent.OutputCompleteEvent = new OutputCompleteEvent();

                        posServiceEvent.OutputCompleteEvent.Source = sessionContext.Device.ToString();
                        posServiceEvent.OutputCompleteEvent.EventID = e.EventId;
                        posServiceEvent.OutputCompleteEvent.TimeStamp = e.TimeStamp;
                        posServiceEvent.OutputCompleteEvent.OutputID = e.OutputId;

                        return posServiceEvent;
                    }
                    else if (sessionContext.DeviceEventArgs is Microsoft.PointOfService.StatusUpdateEventArgs)
                    {
                        Microsoft.PointOfService.StatusUpdateEventArgs e = sessionContext.DeviceEventArgs as Microsoft.PointOfService.StatusUpdateEventArgs;

                        FiscalPrinterEvent posServiceEvent = new FiscalPrinterEvent();
                        posServiceEvent.StatusUpdateEvent = new StatusUpdateEvent();

                        posServiceEvent.StatusUpdateEvent.Source = sessionContext.Device.ToString();
                        posServiceEvent.StatusUpdateEvent.EventID = e.EventId;
                        posServiceEvent.StatusUpdateEvent.TimeStamp = e.TimeStamp;
                        posServiceEvent.StatusUpdateEvent.Status = e.Status;

                        return posServiceEvent;
                    }
                    else
                    {
                        throw new FaultException<UposException>(new UposException() { ErrorCode = ErrorCode.E_FAILURE }, "Invalid Device Event type.", new FaultCode("Server"));
                    }
                }
                finally
                {
                    sessionContext.IsPollingNow = false;
                    if (signaledIndex == 1)
                    {
                        sessionContext.PreviousPollForUPOSEventEnded.Signal();
                    }
                }
            }
            catch (Exception ex)
            {
                // 待ち合わせ中にセッションが閉じられると
                // WaitEventHandleハンドルがDisposeされるため
                // ObjectDisposedException例外がスローされます。
                // 例外処理そのものはException例外の処理と同じですが、
                // 待ち合わせ中のセッションタイムアウトの考慮をした記録として
                // コメントを残します
                // If a session is closed during waiting, 
                // since a WaitEventHandle handle is Dispose(d),
                // ObjectDisposedException exception is thrown. 
                // Although the exception handling itself is the same as processing of an Exception exception, 
                // leave this comment as a record of the session timed out while waiting for a consideration

                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }

        public virtual void SetEventResponse(string ConsumerID, FiscalPrinterEventResponse Response)
        {
            try
            {
                ISessionContext sessionContext = base.GetSessionContext(ConsumerID);
                if (sessionContext.ConsumerEventPort != null)
                {
                    // 双方向通信でOpenSessionを呼び出した場合はSetEventResponseは使えません
                    // SetEventResponse cannot be used when OpenSession is called by bi-directional communication. 
                    throw new FaultException<UposException>(new UposException() { ErrorCode = ErrorCode.E_ILLEGAL }, "bi-direction mode.", new FaultCode("Server"));
                }

                if (Response.DirectIOEventResponse != null)
                {
                    var sessionContextArgs = sessionContext.DeviceEventArgs as Microsoft.PointOfService.DirectIOEventArgs;
                    if (sessionContextArgs == null)
                    {
                        throw new FaultException<UposException>(new UposException() { ErrorCode = ErrorCode.E_ILLEGAL }, "Invalid Operation.", new FaultCode("Server"));
                    }
                    if (Response.DirectIOEventResponse.EventID != sessionContextArgs.EventId)
                    {
                        throw new FaultException<UposException>(new UposException() { ErrorCode = ErrorCode.E_ILLEGAL }, "Invalid EventID.", new FaultCode("Server"));
                    }
                    sessionContext.DeviceEventResponse = Response.DirectIOEventResponse.DirectIOData;
                }
                //else if (Response.DataEventResponse != null)
                //{
                //    var sessionContextArgs = sessionContext.DeviceEventArgs as Microsoft.PointOfService.DataEventArgs;
                //    if (sessionContextArgs == null)
                //    {
                //        throw new FaultException<UposException>(new UposException() { ErrorCode = ErrorCode.E_ILLEGAL }, "Invalid Operation.", new FaultCode("Server"));
                //    }
                //    if (Response.DataEventResponse.EventID != sessionContextArgs.EventId)
                //    {
                //        throw new FaultException<UposException>(new UposException() { ErrorCode = ErrorCode.E_ILLEGAL }, "Invalid EventID.", new FaultCode("Server"));
                //    }
                //}
                else if (Response.ErrorEventResponse != null)
                {
                    var sessionContextArgs = sessionContext.DeviceEventArgs as Microsoft.PointOfService.DeviceErrorEventArgs;
                    if (sessionContextArgs == null)
                    {
                        throw new FaultException<UposException>(new UposException() { ErrorCode = ErrorCode.E_ILLEGAL }, "Invalid Operation.", new FaultCode("Server"));
                    }
                    if (Response.ErrorEventResponse.EventID != sessionContextArgs.EventId)
                    {
                        throw new FaultException<UposException>(new UposException() { ErrorCode = ErrorCode.E_ILLEGAL }, "Invalid EventID.", new FaultCode("Server"));
                    }
                    sessionContext.DeviceEventResponse = Response.ErrorEventResponse.ErrorResponse;
                }
                else if (Response.OutputCompleteEventResponse != null)
                {
                    var sessionContextArgs = sessionContext.DeviceEventArgs as Microsoft.PointOfService.OutputCompleteEventArgs;
                    if (sessionContextArgs == null)
                    {
                        throw new FaultException<UposException>(new UposException() { ErrorCode = ErrorCode.E_ILLEGAL }, "Invalid Operation.", new FaultCode("Server"));
                    }
                    if (Response.OutputCompleteEventResponse.EventID != sessionContextArgs.EventId)
                    {
                        throw new FaultException<UposException>(new UposException() { ErrorCode = ErrorCode.E_ILLEGAL }, "Invalid EventID.", new FaultCode("Server"));
                    }
                }
                else if (Response.StatusUpdateEventResponse != null)
                {
                    var sessionContextArgs = sessionContext.DeviceEventArgs as Microsoft.PointOfService.StatusUpdateEventArgs;
                    if (sessionContextArgs == null)
                    {
                        throw new FaultException<UposException>(new UposException() { ErrorCode = ErrorCode.E_ILLEGAL }, "Invalid Operation.", new FaultCode("Server"));
                    }
                    if (Response.StatusUpdateEventResponse.EventID != sessionContextArgs.EventId)
                    {
                        throw new FaultException<UposException>(new UposException() { ErrorCode = ErrorCode.E_ILLEGAL }, "Invalid EventID.", new FaultCode("Server"));
                    }
                }
                else
                {
                    throw new FaultException<UposException>(new UposException() { ErrorCode = ErrorCode.E_ILLEGAL }, "Invalid EventResponse argument.", new FaultCode("Server"));
                }

                // イベントレスポンスの設定が終わったのでデバイスのイベントハンドラを動かす
                // Since a setup of the event response finished, the event handler of a device is started. 
                sessionContext.SetEventResponseCalled.Signal();

            }
            catch (Exception ex)
            {
                base.LogWriteLineException(MethodBase.GetCurrentMethod(), ex);
                throw;
            }
        }


        #endregion

        #endregion

        #region IDisposable Member

        public override void Dispose()
        {
            base.Dispose();
        }

        #endregion

        /// <summary>
        /// セッションIDのチェック用メソッド
        /// チェックした結果、セッションIDが不正の場合は例外をスローする。
        /// セッションマネージャの内部やServiceBaseでの実装ではなく、
        /// ServiceBaseで抽象メソッドとして定義し、各デバイスサービスに実装させているのは、
        /// UposExceptionクラスがUPOS共通ではなく、各デバイスのネームスペースに所属しているため。
        /// 共通部分のコードでは、UposExceptionを書けない。
        /// A method to check SessionID.
        /// If the SessionID is incorrect, an exception is thrown. 
        /// Since a UposException class belongs to the name space of each device rather than common to UPOS, 
        /// this is defined as an abstract method in ServiceBase and implemented in each device service 
        /// instead of an implementation as a ServiceBase or inside of Session Manager.
        /// </summary>
        /// <param name="consumerID">Session ID</param>
        /// <param name="throwWhenExistId">true時は、すでにIDがセッションマネージャに登録されていたら例外をスローする。false時はIDがセッションマネージャに登録されていないならば例外をスローする |At the time of true, if ID is already registered into the session manager, this throws an exception. </param>
        protected override void ValidateSessionID(string consumerID, bool throwWhenExistId)
        {
            if (!base.IsValidSessionID(consumerID))
            {
                throw new FaultException<UposException>(new UposException() { ErrorCode = ErrorCode.E_ILLEGAL }, "Invalid sessionID.", new FaultCode("Server"));
            }

            if (throwWhenExistId)
            {
                if (base.IsExistSession(consumerID))
                {
                    throw new FaultException<UposException>(new UposException() { ErrorCode = ErrorCode.E_ILLEGAL }, "Duplicated sessionID.", new FaultCode("Server"));
                }
            }
            else
            {
                if (!base.IsExistSession(consumerID))
                {
                    throw new FaultException<UposException>(new UposException() { ErrorCode = ErrorCode.E_ILLEGAL }, "Not Active sessionID.", new FaultCode("Server"));
                }
            }
        }

        /// <summary>
        /// 指定されたセッションに関連されたリソースを解放します
        /// Releases the resources that are related to the specified session.
        /// </summary>
        /// <param name="sessionContext">セッションコンテキスト | Session context</param>
        protected override void CloseSessionResources(ISessionContext sessionContext)
        {
            DisposeDevice(sessionContext);
            base.CloseSessionBase(sessionContext, null, SessionContext_ServiceDirectIOEvent, SessionContext_ServiceErrorEvent, SessionContext_ServiceOutputCompleteEvent, SessionContext_ServiceStatusUpdateEvent);
        }

        /// <summary>
        /// 指定されたセッションに関連されたデバイスのインスタンスを破棄します。
        /// Destory the instance of the device associated with the specified session.
        /// </summary>
        /// <param name="sessionContext">セッションコンテキスト|Session Context</param>
        protected virtual void DisposeDevice(ISessionContext sessionContext)
        {
            if (sessionContext.Device == null)
            {
                // CloseDeviceの後にCloseDeviceを呼び出された場合、
                // すでにインスタンスは破棄されているので、なにもしない。
                // If called the CloseDevice after CloseDevice, 
                // Because instances are discarded already, nothing is done. 
                return;
            }

            var device = ConcretizationDevice(sessionContext.Device);

            if (device.State != Microsoft.PointOfService.ControlState.Closed)
            {
                device.FreezeEvents = true;
                base.WaitForEventHandlerReturned(sessionContext);

                device.Close();
                device.DirectIOEvent -= sessionContext.DeviceDirectIOEventHandler;
                device.ErrorEvent -= sessionContext.DeviceErrorEventHandler;
                device.OutputCompleteEvent -= sessionContext.DeviceOutputCompleteEventHandler;
                device.StatusUpdateEvent -= sessionContext.DeviceStatusUpdateEventHandler;
                //device.DataEvent -= sessionContext.DeviceDataEventHandler;
                sessionContext.Device = null;

                base.DeleteAsyncTemporaryFiles(sessionContext);
            }
        }

        /// <summary>
        /// デバイスを明示的にダウンキャストする
        /// このリファレンスを基に多数のデバイス（種類）をコーディングする際、
        /// デバイス種別へのダウンキャストコーディングの変更箇所を減らすためにこれを用いる
        /// 
        /// Downcast device explicitly.
        /// When coding on many devices (types) based on this reference, 
        /// the use of this in order to reduce the change in the downcast coding to the device type.
        /// </summary>
        /// <param name="device"></param>
        /// <returns></returns>
        protected virtual Microsoft.PointOfService.FiscalPrinter ConcretizationDevice(Microsoft.PointOfService.PosDevice device)
        {
            if (device == null)
            {
                throw new FaultException<UposException>(new UposException() { ErrorCode = ErrorCode.E_CLOSED }, "Closed", new FaultCode("Server"));
            }

            return device as Microsoft.PointOfService.FiscalPrinter;
        }

        /// <summary>
        /// クライアントへのイベントポートを明示的にダウンキャストする
        /// このリファレンスを基に多数のデバイス（種類）をコーディングする際、
        /// デバイス種別へのダウンキャストコーディングの変更箇所を減らすためにこれを用いる
        /// 
        /// Event port to the client to downcast explicitly.
        /// When coding on many devices (types) based on this reference, 
        /// the use of this in order to reduce the change in the downcast coding to the device type
        /// </summary>
        /// <param name="device"></param>
        /// <returns></returns>
        protected virtual UnifiedPOS.FiscalPrinterEvents.V1_4.FiscalPrinterEvent ConcretizationConsumerEventPort(object deviceEvent)
        {
            return deviceEvent as UnifiedPOS.FiscalPrinterEvents.V1_4.FiscalPrinterEvent;
        }

    }
}
