コード例 #1
0
        public PanelState(AccessControlCard card, UInt64 uptime, DateTime timestamp)
        {
            if (card != null)
            {
                this.card = new AccessControlCard(card);
            }


            this.uptime    = uptime;
            this.timestamp = timestamp;
        }
コード例 #2
0
        private Task Refresh()
        {
            return(Task.Run(delegate()
            {
                UInt64 uid, uptime;
                DateTime uid_read_timestamp;

                PanelCommandHandle pch = connection.EnqueueCommand(new PanelCommand(PanelCommand.POLL_CARD_PRESENCE));
                pch.Handle.WaitOne(); //uid will be waiting
                uid_read_timestamp = DateTime.Now;

                byte[] conversion_buffer = new byte[8];
                Array.Copy(pch.Command.RxPacket, 1, conversion_buffer, 1, 7);
                Array.Reverse(conversion_buffer);

                uid = BitConverter.ToUInt64(conversion_buffer, 0);

                if (uid != 0)
                {
                    connection.EnqueueCommand(new PanelCommand(PanelCommand.CLEAR_CARD)).Handle.WaitOne();
                }

                pch = connection.EnqueueCommand(new PanelCommand(PanelCommand.GET_UPTIME));
                pch.Handle.WaitOne(); //uid will be waiting
                uptime = BitConverter.ToUInt64(pch.Command.RxPacket, 1);

                PanelState stcpy = null;
                lock (state_lock)
                    if (state != null)
                    {
                        stcpy = new PanelState(state);
                    }
                    else
                    {
                        state = new PanelState(new AccessControlCard(uid, AccessControlCard.MIFARE_CLASSIC, uid_read_timestamp), uptime, uid_read_timestamp);
                    }

                if (stcpy != null)
                {
                    AccessControlCard accessctlcd = stcpy.Card;

                    //if this is a different card then continue
                    if (accessctlcd.UID != uid)
                    {
                        accessctlcd = new AccessControlCard(uid, AccessControlCard.MIFARE_CLASSIC, uid_read_timestamp);

                        if (uid != 0)
                        {
                            if (presented != null)
                            {
                                presented(this, new PanelEventArgs(new PanelState(accessctlcd, uptime, uid_read_timestamp)));
                            }
                        }
                    }

                    lock (state_lock)
                        state = new PanelState(accessctlcd, uptime, uid_read_timestamp);

                    if (newstate != null)
                    {
                        newstate(this, new PanelEventArgs(new PanelState(accessctlcd, uptime, uid_read_timestamp)));
                    }
                }
            }));
        }
コード例 #3
0
 public AccessControlCard(AccessControlCard card) : this(card.UID, card.Type, card.Timestamp)
 {
 }