Example #1
0
        public static DateTime GetReaderTime(string host, ReaderType reader_type, bool is_async = false)
        {
            int    port = 0;
            string cmd  = "ab00000222";

            if (reader_type == ReaderType.Lite)
            {
                port = 10000;
            }
            else if (reader_type == ReaderType.Elite)
            {
                port = 9999;
            }
            DateTime reader_time = DateTime.Now;

            if (is_async)
            {
                reader_time = ParseReaderTime(AsyncTcpSocketUtil.SendRecieve(host, port, cmd).Trim());
            }
            else
            {
                reader_time = ParseReaderTime(SyncTcpSocketUtil.SendRecieve(host, port, cmd, 36).Trim());
            }
            return(reader_time);
        }
Example #2
0
        /// <summary>
        /// Clearly history of a reader, only apply to elite
        /// </summary>
        /// <param name="host"></param>
        public static string ClearEliteReaderHistory(string host)
        {
            string rdrResponse = String.Empty;

            rdrResponse = SyncTcpSocketUtil.SendRecieve(host, 9999, "clear_history", 15);
            return(rdrResponse);
        }
Example #3
0
        public static string UpdateReaderTime(string address, ReaderType reader_type, bool is_async = false)
        {
            int      port          = 0;
            string   cmd           = "000701";
            string   rdrResponse   = String.Empty;
            DateTime pcTime        = DateTime.Now;
            string   formattedTime = String.Empty;

            if (reader_type == ReaderType.Lite)
            {
                port = 10000;
            }
            else if (reader_type == ReaderType.Elite)
            {
                port = 9999;
            }
            formattedTime = SystemUtil.GetFormattedPCTime(pcTime, GetLatency(address));
            cmd          += formattedTime;
            cmd           = "ab" + cmd + SystemUtil.ComputeCheckSum(cmd);
            rdrResponse   = null;
            if (is_async)
            {
                rdrResponse = AsyncTcpSocketUtil.SendRecieve(address, port, cmd);
            }
            else
            {
                rdrResponse = SyncTcpSocketUtil.SendRecieve(address, port, cmd, 10);
            }
            if (rdrResponse.Trim() == "ab00000121" || rdrResponse == "ab00000121" + System.Environment.NewLine || rdrResponse != null)
            {
                return(pcTime.ToString());
            }
            else
            {
                return("Error!");
            }
        }