Ejemplo n.º 1
0
        /// <summary>
        /// Клонирование объекта
        /// </summary>
        /// <returns></returns>
        public PacInfo Clone()
        {
            var cloned = new PacInfo();

            cloned.IP               = IP;
            cloned.IPEmulator       = IPEmulator;
            cloned.EmulationEnabled = EmulationEnabled;
            cloned.CycleTime        = CycleTime;
            cloned.TimeOut          = TimeOut;
            cloned.Port             = Port;
            cloned.GateEnabled      = GateEnabled;
            cloned.Station          = Station;

            return(cloned);
        }
Ejemplo n.º 2
0
        public static PacInfo GetPacInfo(Format format, byte[] data)
        {
            var info = new PacInfo();

            switch (format)
            {
            case Format.Corporate1000:
                if (data.Length != 5)
                {
                    throw new Exception($"Incorrect data length for Corporate1000. Was {data.Length} expected 5");
                }

                var fullLongBytes = new byte[8];
                Buffer.BlockCopy(data, 0, fullLongBytes, 3, 5);
                var fullLong = BitConverter.ToUInt64(fullLongBytes.Reverse().ToArray(), 0);
                info.CardId = (fullLong & 0x3FFFFc0) >> 6;
                return(info);

            default:
                throw new Exception($"Format {format} not supported yet");
            }
        }