1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- using Edge.Core.Parser.BinaryParser.MessageEntity;
- using Org.BouncyCastle.Asn1.Ocsp;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace HengshanPaymentTerminal.MessageEntity.Outgoing
- {
- /// <summary>
- /// 发送授权请求给油机数据对象
- /// </summary>
- public class SendAuthorization : CommonMessage
- {
- /// <summary>
- /// 请求授权的枪号
- /// </summary>
- public int NozzleNum { get; set; }
- /// <summary>
- /// 请求授权时间
- /// </summary>
- private DateTime AuthorizationTime { get; set; }
- /// <summary>
- /// 授权类型:01:定金额,02:定升数
- /// </summary>
- private int AuthorizationType { get; set; }
- /// <summary>
- /// 定值量
- /// </summary>
- private decimal Value { get; set; }
- public SendAuthorization(int nozzleNum, DateTime authorizationTime, int authorizationType, decimal value,byte frame)
- {
- this.Handle = (byte)Command.ACCREDIT;
- NozzleNum = nozzleNum;
- AuthorizationTime = authorizationTime;
- AuthorizationType = authorizationType;
- Value = value;
- this.FrameNum = frame;
- }
- public override byte[] ToCommonByteArray()
- {
- List<Byte> list = new List<Byte>();
- byte[] commandAndNozzle = { this.Handle, (byte)this.NozzleNum };
- byte[] authorizationTimeBytes = ConvertDateTimeToByteArray(this.AuthorizationTime);
- //将小数点后移两位,因为油机只支持两位小数点,这边传过去的3位字节转为int后取后两位为十分位和百分位
- int value = (int)this.Value * 100;
- byte[] valueBytes = NumberToByteArrayWithPadding(value, 3);
- list.AddRange(commandAndNozzle);
- list.AddRange(authorizationTimeBytes);
- list.Add((byte)this.AuthorizationType);
- list.AddRange(valueBytes);
- byte[] sendBytes = content2data(list.ToArray());
- return sendBytes;
- }
- public override CommonMessage ToObject(byte[] datas)
- {
- return this;
- }
- }
- }
|