using System;

namespace com.itac.mes.imsapi.protocol
{
    public enum IhapProtocolMode : byte
    {
        BinaryHash = 1,
        BinaryField = 17
    }

    public sealed class IhapRemoteException : Exception
    {
        public int FaultCode { get; }
        public IhapRemoteException(int code, string message) : base(message) { FaultCode = code; }
    }

    public sealed class IhapCommunicationException : Exception
    {
        public IhapCommunicationException(string message) : base(message) { }
        public IhapCommunicationException(string message, Exception inner) : base(message, inner) { }
    }

    internal static class IhapConstants
    {
        public const byte NULL_VALUE=0, BOOL_FALSE=1, BOOL_TRUE=2, BYTE=3, CHAR=4,
            DOUBLE_0=5, DOUBLE_1=6, DOUBLE_1BYTE=7, DOUBLE_2BYTE=8, DOUBLE_4BYTE=9, DOUBLE=10,
            FLOAT_1BYTE=11, FLOAT_2BYTE=12, FLOAT=13, INT=14, LONG_4BYTE=15, LONG=16, SHORT=17,
            STRING_NFINAL=18, STRING_FINAL=19, OBJECT=20, ENUM=21, COLLECTION=22, MAP=23, DATE=24,
            EXCEPTION=25, BOOL_ARRAY=26, BYTE_ARRAY_NFINAL=27, BYTE_ARRAY_FINAL=28, CHAR_ARRAY=29,
            DOUBLE_ARRAY=30, FLOAT_ARRAY=31, INT_ARRAY=32, LONG_ARRAY=33, SHORT_ARRAY=34,
            STRING_ARRAY=35, OBJECT_ARRAY=36, REF_VALUE_1BYTE=37, REF_VALUE_2BYTE=38,
            REF_VALUE_4BYTE=39, REF_STRING_1BYTE=40, REF_STRING_2BYTE=41, REF_STRING_4BYTE=42;
        public const int SHORT_BYTE_ARRAY_LENGTH_BASE=64, SHORT_BYTE_ARRAY_MAX_LENGTH=15;
        public const int INT_1BYTE_MIN=-16, INT_1BYTE_BASE=96, INT_1BYTE_MAX=47;
        public const int INT_2BYTE_MIN=-2048, INT_2BYTE_BASE=152, INT_2BYTE_MAX=2047;
        public const int INT_3BYTE_MIN=-262144, INT_3BYTE_BASE=164, INT_3BYTE_MAX=262143;
        public const long LONG_1BYTE_MIN=-8, LONG_1BYTE_BASE=176, LONG_1BYTE_MAX=15;
        public const long LONG_2BYTE_MIN=-2048, LONG_2BYTE_BASE=200, LONG_2BYTE_MAX=2047;
        public const long LONG_3BYTE_MIN=-262144, LONG_3BYTE_BASE=212, LONG_3BYTE_MAX=262143;
        public const int SHORT_STRING_BASE=216, SHORT_STRING_MAX=39, BLOCK_SIZE=65535;
        public const byte PROTOCOL_IDENTIFIER=105, RPC_CALL=1, RPC_REPLY=2, RPC_FAULTREPLY=3;
    }
}
