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)); }
public static Record Analyze(byte[] datas) { Debug.Assert(datas.Length == XGDefinition.RECODE_DATA_LENGTH); int year = BCDConvert.BCDToDec(datas[YEAR_POS]); int month = BCDConvert.BCDToDec(datas[MONTH_POS]); int day = BCDConvert.BCDToDec(datas[DAY_POS]); int hour = BCDConvert.BCDToDec(datas[HOUR_POS]); int minute = BCDConvert.BCDToDec(datas[MINUTE_POS]); int second = BCDConvert.BCDToDec(datas[SECOND_POS]); byte[] cardIdDatas = new byte[CARD_ID_DATA_LENGTH]; Array.Copy(datas, CARD_ID_BEGIN_POS, cardIdDatas, 0, CARD_ID_DATA_LENGTH); string cardId = MakeCardId(cardIdDatas); return(new Record(year, month, day, hour, minute, second, cardId)); }
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)); }