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

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

        //
        // Events
        //

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

        [OperationContract(Action = "http://www.nrf-arts.org/UnifiedPOS/BeltEvents/DirectIOEvent", ReplyAction = "http://www.nrf-arts.org/UnifiedPOS/BeltEvents/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/BeltEvents/ErrorEvent", ReplyAction = "http://www.nrf-arts.org/UnifiedPOS/BeltEvents/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/BeltEvents/OutputCompleteEvent", ReplyAction = "http://www.nrf-arts.org/UnifiedPOS/BeltEvents/OutputCompleteEventResponse")]
        // void OutputCompleteEvent(string ConsumerID, string Source, int EventID, DateTime TimeStamp, int OutputID);

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

    //
    // Common Data Types
    //

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

    //
    // Common Enumerations
    //

    /*
    [DataContract(Namespace = "http://www.nrf-arts.org/UnifiedPOS/BeltEvents/")]
    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/BeltEvents/")]
    public enum ErrorLocus
    {
        [EnumMember]
        EL_INPUT,
        [EnumMember]
        EL_INPUT_DATA,
        [EnumMember]
        EL_OUTPUT,
    }

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

    //
    // Specific Data Types
    //

    //
    // Specific Enumerations
    //

    //
    // Constants
    //

    /*
    public class Constants
    {
        public const int StatusAutoStop = 11;
        public const int StatusEmergencyStop = 12;
        public const int StatusLightBarrierBackwardInterrupted = 17;
        public const int StatusLightBarrierBackwardOk = 18;
        public const int StatusLightBarrierForwardInterrupted = 19;
        public const int StatusLightBarrierForwardOk = 20;
        public const int StatusMotorFuseDefect = 16;
        public const int StatusMotorOverheating = 15;
        public const int StatusPowerOff = 2002;
        public const int StatusPowerOffline = 2003;
        public const int StatusPowerOffOffline = 2004;
        public const int StatusPowerOnline = 2001;
        public const int StatusSafetyStop = 13;
        public const int StatusSecurityFlapBackwardClosed = 22;
        public const int StatusSecurityFlapBackwardOpened = 21;
        public const int StatusSecurityFlapForwardClosed = 24;
        public const int StatusSecurityFlapForwardOpened = 23;
        public const int StatusTimeoutStop = 14;
        public const int StatusUpdateFirmwareComplete = 2200;
        public const int StatusUpdateFirmwareCompleteDeviceNotRestored = 2205;
        public const int StatusUpdateFirmwareFailedDeviceNeedsFirmware = 2203;
        public const int StatusUpdateFirmwareFailedDeviceOk = 2201;
        public const int StatusUpdateFirmwareFailedDeviceUnknown = 2204;
        public const int StatusUpdateFirmwareFailedDeviceUnrecoverable = 2202;
        public const int StatusUpdateFirmwareProgress = 2100;
    }
    */

    public class Status
    {
        public const int BELT_SUE_AUTO_STOP = 11;
        public const int BELT_SUE_EMERGENCY_STOP = 12;
        public const int BELT_SUE_SAFETY_STOP = 13;
        public const int BELT_SUE_TIMEOUT_STOP = 14;
        public const int BELT_SUE_MOTOR_OVERHEATING = 15;
        public const int BELT_SUE_MOTOR_FUSE_DEFECT = 16;
        public const int BELT_SUE_LIGHT_BARRIER_BACKWARD_INTERRUPTED = 17;
        public const int BELT_SUE_LIGHT_BARRIER_BACKWARD_OK = 18;
        public const int BELT_SUE_LIGHT_BARRIER_FORWARD_INTERRUPTED = 19;
        public const int BELT_SUE_LIGHT_BARRIER_FORWARD_OK = 20;
        public const int BELT_SUE_SECURITY_FLAP_BACKWARD_OPENED = 21;
        public const int BELT_SUE_SECURITY_FLAP_BACKWARD_CLOSED = 22;
        public const int BELT_SUE_SECURITY_FLAP_FORWARD_OPENED = 23;
        public const int BELT_SUE_SECURITY_FLAP_FORWARD_CLOSED = 24;
        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;
    }
}
