using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace UnifiedPOS.SmartCardRWEvents.V1_4
{
    [ServiceContract(Namespace = "http://www.nrf-arts.org/UnifiedPOS/SmartCardRWEvents/")]
    public interface SmartCardRWEvent
    {

        //
        // Events
        //

        [OperationContract(Action = "http://www.nrf-arts.org/UnifiedPOS/SmartCardRWEvents/DataEvent", ReplyAction = "http://www.nrf-arts.org/UnifiedPOS/SmartCardRWEvents/DataEventResponse")]
        void DataEvent(string ConsumerID, string Source, int EventID, DateTime TimeStamp, int Status);

        [OperationContract(Action = "http://www.nrf-arts.org/UnifiedPOS/SmartCardRWEvents/DirectIOEvent", ReplyAction = "http://www.nrf-arts.org/UnifiedPOS/SmartCardRWEvents/DirectIOEventResponse")]
        DirectIOData DirectIOEvent(string ConsumerID, string Source, int EventID, DateTime TimeStamp, int EventNumber, int Data, object Obj);

        [OperationContract(Action = "http://www.nrf-arts.org/UnifiedPOS/SmartCardRWEvents/ErrorEvent", ReplyAction = "http://www.nrf-arts.org/UnifiedPOS/SmartCardRWEvents/ErrorEventResponse")]
        ErrorResponse ErrorEvent(string ConsumerID, string Source, int EventID, DateTime TimeStamp, ErrorCode ErrorCode, int ErrorCodeExtended, ErrorLocus ErrorLocus, ErrorResponse ErrorResponse);

        [OperationContract(Action = "http://www.nrf-arts.org/UnifiedPOS/SmartCardRWEvents/OutputCompleteEvent", ReplyAction = "http://www.nrf-arts.org/UnifiedPOS/SmartCardRWEvents/OutputCompleteEventResponse")]
        void OutputCompleteEvent(string ConsumerID, string Source, int EventID, DateTime TimeStamp, int OutputID);

        [OperationContract(Action = "http://www.nrf-arts.org/UnifiedPOS/SmartCardRWEvents/StatusUpdateEvent", ReplyAction = "http://www.nrf-arts.org/UnifiedPOS/SmartCardRWEvents/StatusUpdateEventResponse")]
        void StatusUpdateEvent(string ConsumerID, string Source, int EventID, DateTime TimeStamp, int Status);

        [OperationContract(Action = "http://www.nrf-arts.org/UnifiedPOS/SmartCardRWEvents/DataContainedEvent", ReplyAction = "http://www.nrf-arts.org/UnifiedPOS/BillAcceptorEvents/DataContainedEventResponse")]
        DataContainedEventData DataContainedEvent(string ConsumerID, string Source, int EventID, DateTime TimeStamp, int Status, ParameterList Parameters);
    }

    //
    // Common Data Types
    //

    [DataContract(Namespace = "http://www.nrf-arts.org/UnifiedPOS/SmartCardRWEvents/")]
    public class DirectIOData
    {
        [DataMember]
        public int Data { get; set; }
        [DataMember]
        public object Obj { get; set; }
    }

    [DataContract(Namespace = "http://www.nrf-arts.org/UnifiedPOS/SmartCardRWEvents/")]
    public class DataContainedEventData
    {
        [DataMember]
        public int EventID { get; set; }
        [DataMember]
        public bool SetDataEventEnabled { get; set; }
        [DataMember]
        public bool CallClearInputProperties { get; set; }
    }

    [CollectionDataContract(Namespace = "http://www.nrf-arts.org/UnifiedPOS/SmartCardRWEvents/", ItemName = "Parameter")]
    public class ParameterList : Dictionary<string, object>
    {
    }

    //
    // Common Enumerations
    //

    [DataContract(Namespace = "http://www.nrf-arts.org/UnifiedPOS/SmartCardRWEvents/")]
    public enum ErrorCode
    {
        [EnumMember]
        E_CLOSED,
        [EnumMember]
        E_CLAIMED,
        [EnumMember]
        E_NOTCLAIMED,
        [EnumMember]
        E_NOSERVICE,
        [EnumMember]
        E_DISABLED,
        [EnumMember]
        E_ILLEGAL,
        [EnumMember]
        E_NOHARDWARE,
        [EnumMember]
        E_OFFLINE,
        [EnumMember]
        E_NOEXIST,
        [EnumMember]
        E_EXISTS,
        [EnumMember]
        E_FAILURE,
        [EnumMember]
        E_TIMEOUT,
        [EnumMember]
        E_BUSY,
        [EnumMember]
        E_EXTENDED,
        [EnumMember]
        E_DEPRECATED,
    }

    [DataContract(Namespace = "http://www.nrf-arts.org/UnifiedPOS/SmartCardRWEvents/")]
    public enum ErrorLocus
    {
        [EnumMember]
        EL_INPUT,
        [EnumMember]
        EL_INPUT_DATA,
        [EnumMember]
        EL_OUTPUT,
    }

    [DataContract(Namespace = "http://www.nrf-arts.org/UnifiedPOS/SmartCardRWEvents/")]
    public enum ErrorResponse
    {
        [EnumMember]
        ER_CLEAR,
        [EnumMember]
        ER_CONTINUEINPUT,
        [EnumMember]
        ER_RETRY,
    }

    //
    // Specific Data Types
    //

    //
    // Specific Enumerations
    //

    //
    // Constants
    //

    public class ExtendedError
    {
        public const int EFIRMWARE_BAD_FILE = 281;
        public const int ESTATS_ERROR = 280;
        public const int ESTATS_DEPENDENCY = 282;

		//
		// Specific Constants
		//
		public const int ESC_READ = 201;
		public const int ESC_WRITE = 202;
		public const int ESC_TORN = 203;
		public const int ESC_NO_CARD = 204;

	}

    public class Status
    {
        public const int SUE_POWER_ONLINE = 2001;
        public const int SUE_POWER_OFF = 2002;
        public const int SUE_POWER_OFFLINE = 2003;
        public const int SUE_POWER_OFF_OFFLINE = 2004;
        public const int SUE_UF_COMPLETE = 2200;
        public const int SUE_UF_PROGRESS = 2100;
        public const int SUE_UF_FAILED_DEV_OK = 2201;
        public const int SUE_UF_FAILED_DEV_UNRECOVERABLE = 2202;
        public const int SUE_UF_FAILED_DEV_UNKNOWN = 2204;
        public const int SUE_UF_COMPLETE_DEV_NOT_RESTORED = 2205;
        public const int SUE_UF_FAILED_DEV_NEEDS_FIRMWARE = 2203;

		//
		//Specific Constants
		//

		public const int SC_SUE_NO_CARD = 1;
		public const int SC_SUE_CARD_PRESENT = 2;
	}
}
