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); }
public override CommResultState ProcessReceived(byte[] data) { return(XGCommandMaker.CheckReceivedData(NewAddress, XGDefinition.DEVICE_TYPE, XGDefinition.FC_MODIFY_ADDRESS, data)); }
public override byte[] MakeCommand() { return(XGCommandMaker.MakeCommand(Station.Address, XGDefinition.DEVICE_TYPE, XGDefinition.FC_READ_TOTALCOUNT, null)); }
public override byte[] MakeCommand() { return(XGCommandMaker.MakeCommand(Station.Address, XGDefinition.DEVICE_TYPE, XGDefinition.FC_QUERY_ADDRESS, null)); }
public override byte[] MakeCommand() { return(XGCommandMaker.MakeCommand(this.Station.Address, XGDefinition.DEVICE_TYPE, XGDefinition.FC_READ_DATE, null)); }
public override CommResultState ProcessReceived(byte[] data) { return(XGCommandMaker.CheckReceivedData(Station.Address, XGDefinition.DEVICE_TYPE, XGDefinition.FC_REMOVE_ALL, data)); }
public override byte[] MakeCommand() { byte[] datas = new byte[] { (byte)NewAddress }; return(XGCommandMaker.MakeCommand(Station.Address, XGDefinition.DEVICE_TYPE, XGDefinition.FC_MODIFY_ADDRESS, datas)); }
//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)); }
public override byte[] MakeCommand() { byte[] datas = new byte[1]; datas[0] = (byte)_recordIndex; return(XGCommandMaker.MakeCommand(this.Station.Address, XGDefinition.DEVICE_TYPE, XGDefinition.FC_READ_RECORD, datas)); }
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); }
public override byte[] MakeCommand() { byte[] datas = new byte[3]; datas[0] = (byte)BCDConvert.DecToBCD(Day); datas[1] = (byte)BCDConvert.DecToBCD(Month); datas[2] = (byte)BCDConvert.DecToBCD(Year); return(XGCommandMaker.MakeCommand(Station.Address, XGDefinition.DEVICE_TYPE, XGDefinition.FC_MODIFY_DATE, datas)); }
/// <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); } }
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); }
/// <summary> /// /// </summary> /// <param name="fromIP"></param> /// <param name="bs"></param> public void Process(string fromIP, byte[] bs) { GrDataPicker grdp = new GrDataPicker(); byte[][] grdatas = grdp.Picker(bs); if (grdatas != null) { foreach (byte[] aGrData in grdatas) { if (GRCommandMaker.IsRealData(aGrData)) { GrRealDataParser grrdparser = new GrRealDataParser(aGrData); GRRealData rd = grrdparser.ToValue() as GRRealData; if (rd != null) { CommTaskResultProcessor.Default.ProcessGRRealData( fromIP, rd.FromAddress, rd ); } } } } XgDataPicker xgdp = new XgDataPicker(); byte[][] xgdatas = xgdp.Picker(bs); if (xgdatas != null) { foreach (byte[] aXgData in xgdatas) { if (XGCommandMaker.IsXgRecord(aXgData)) { XgRecordParser xgrp = new XgRecordParser(aXgData); XGData xgdata = xgrp.ToValue() as XGData; if (xgdata != null) { XGDB.InsertXGData( fromIP, //cmd.Station.DestinationIP, xgdata ); } } } } }
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); }
/// <summary> /// 生成设置时间命令 /// </summary> /// <returns></returns> public override byte[] MakeCommand() { //Debug.Assert ( station != null && station is XGStation ); //Debug.Assert (parameters!= null && parameters.Length == 3 ); ////byte[] ba = parameters as byte[]; //byte hour = (byte) BCDConvert.DecToBCD ( Convert.ToInt32(parameters[2]) ); //byte minute = (byte) BCDConvert.DecToBCD ( Convert.ToInt32(parameters[1]) ); //byte second = (byte) BCDConvert.DecToBCD ( Convert.ToInt32(parameters[0]) ); // //RangeChecker.Check( hour, 0, 23, true, true ); //RangeChecker.Check( minute, 0, 59, true, true ); //RangeChecker.Check( second, 0, 59, true, true ); byte[] datas = new byte[3]; datas[0] = (byte)BCDConvert.DecToBCD(Second); datas[1] = (byte)BCDConvert.DecToBCD(Minute); datas[2] = (byte)BCDConvert.DecToBCD(Hour); return(XGCommandMaker.MakeCommand(Station.Address, XGDefinition.DEVICE_TYPE, XGDefinition.FC_MODIFY_TIME, datas)); }