Esempio n. 1
0
 public override CommResultState ProcessReceived(byte[] data)
 {
     return(XGCommandMaker.CheckReceivedData(NewAddress,
                                             XGDefinition.DEVICE_TYPE,
                                             XGDefinition.FC_MODIFY_ADDRESS,
                                             data));
 }
Esempio n. 2
0
        public override CommResultState ProcessReceived(byte[] data)
        {
            CommResultState state = XGCommandMaker.CheckReceivedData(this.Station.Address,
                                                                     XGDefinition.DEVICE_TYPE,
                                                                     XGDefinition.FC_READ_RECORD,
                                                                     data);

            // 正确时处理记录数据,错误时保留上次读取的数据不变。
            //
            if (state == CommResultState.Correct)
            {
                byte[] innerDatas   = XGCommandMaker.GetReceivedInnerData(data);
                int    innerDataLen = innerDatas.Length;

                //
                if (innerDataLen == XGDefinition.RECODE_DATA_LENGTH)
                {
                    // analyse recode data
                    //
                    _record           = Record.Analyze(innerDatas);
                    _recordTotalCount = -1;
                }
                else if (innerDataLen == 1) // recode index error
                {
                    _recordTotalCount = innerDatas[0];
                }
                else
                {
                    throw new Exception("Read recode inner data error.");
                }
            }
            return(state);
        }
Esempio n. 3
0
 public override CommResultState ProcessReceived(byte[] data)
 {
     return(XGCommandMaker.CheckReceivedData(Station.Address,
                                             XGDefinition.DEVICE_TYPE,
                                             XGDefinition.FC_REMOVE_ALL,
                                             data));
 }
Esempio n. 4
0
        //public void MakeCommand(XGStation station, int hour, int minute, int second)
        //{
        //    // check hour, minute, second range
        //    //
        //
        //    // convert h,m,s to BCD value
        //    //
        //
        //    object[] para = new object[3]{  (byte)BCDConvert.DecToBCD( second ),
        //                                (byte)BCDConvert.DecToBCD( minute ),
        //                                (byte)BCDConvert.DecToBCD( hour ) };
        //    MakeCommand(station, para);
        //}

        public override CommResultState ProcessReceived(byte[] data)
        {
            //return new CommResultState ();
            return(XGCommandMaker.CheckReceivedData(Station.Address,
                                                    XGDefinition.DEVICE_TYPE,
                                                    XGDefinition.FC_MODIFY_TIME,
                                                    data));
        }
Esempio n. 5
0
        public override CommResultState ProcessReceived(byte[] data)
        {
            CommResultState r = XGCommandMaker.CheckReceivedData(Station.Address,
                                                                 XGDefinition.DEVICE_TYPE,
                                                                 XGDefinition.FC_QUERY_ADDRESS,
                                                                 data);

            System.Windows.Forms.MessageBox.Show("re" + data.Length + r.ToString());
            return(r);
        }
Esempio n. 6
0
        /// <summary>
        /// reutrn xgdata or null
        /// </summary>
        /// <returns></returns>
        public override object ToValue()
        {
            byte[]          data  = _bytes;
            CommResultState state = XGCommandMaker.CheckReceivedData(// this.Station.Address,
                XGDefinition.DEVICE_TYPE,
                XGDefinition.FC_READ_RECORD,
                data);

            _commResultState = state;

            // 正确时处理记录数据,错误时保留上次读取的数据不变。
            //
            if (state == CommResultState.Correct)
            {
                int address = data[XGDefinition.ADDRESS_POS];

                byte[] innerDatas   = XGCommandMaker.GetReceivedInnerData(data);
                int    innerDataLen = innerDatas.Length;

                //
                if (innerDataLen == XGDefinition.RECODE_DATA_LENGTH)
                {
                    // analyse recode data
                    //
                    Record record = Record.Analyze(innerDatas);
                    if (record == null)
                    {
                        return(null);
                    }

                    XGData xgdata = new XGData(record.CardSN, address, record.DateTime, false);
                    _value = xgdata;
                    return(xgdata);
                }
                else if (innerDataLen == 1) // recode index error
                {
                    //_recordTotalCount = innerDatas[0];
                    return(null);
                }
                else
                {
                    //throw new Exception("Read recode inner data error.");
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Esempio n. 7
0
        public override CommResultState ProcessReceived(byte[] data)
        {
            CommResultState state = XGCommandMaker.CheckReceivedData(Station.Address,
                                                                     XGDefinition.DEVICE_TYPE,
                                                                     XGDefinition.FC_READ_TOTALCOUNT,
                                                                     data);

            if (state == CommResultState.Correct)
            {
                byte[] innerDatas = XGCommandMaker.GetReceivedInnerData(data);
                _totalCount = innerDatas[0];
            }
            return(state);
        }
Esempio n. 8
0
        public override CommResultState ProcessReceived(byte[] data)
        {
            CommResultState state = XGCommandMaker.CheckReceivedData(
                Station.Address,
                XGDefinition.DEVICE_TYPE,
                XGDefinition.FC_READ_DATE,
                data);

            if (state == CommResultState.Correct)
            {
                byte[] innerDatas = XGCommandMaker.GetReceivedInnerData(data);
                _day   = BCDConvert.BCDToDec(innerDatas[0]);
                _month = BCDConvert.BCDToDec(innerDatas[1]);
                _year  = BCDConvert.BCDToDec(innerDatas[2]);
            }
            else
            {
                SetInvalidValue();
            }

            return(state);
        }